babylon.d.ts 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955
  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. /**
  79. * Container with a set of assets that can be added or removed from a scene.
  80. */
  81. class AssetContainer {
  82. /**
  83. * The scene the AssetContainer belongs to.
  84. */
  85. scene: Scene;
  86. /**
  87. * Cameras populated in the container.
  88. */
  89. cameras: Camera[];
  90. /**
  91. * Lights populated in the container.
  92. */
  93. lights: Light[];
  94. /**
  95. * Meshes populated in the container.
  96. */
  97. meshes: AbstractMesh[];
  98. /**
  99. * Skeletons populated in the container.
  100. */
  101. skeletons: Skeleton[];
  102. /**
  103. * ParticleSystems populated in the container.
  104. */
  105. particleSystems: IParticleSystem[];
  106. /**
  107. * Animations populated in the container.
  108. */
  109. animations: Animation[];
  110. /**
  111. * AnimationGroups populated in the container.
  112. */
  113. animationGroups: AnimationGroup[];
  114. /**
  115. * MultiMaterials populated in the container.
  116. */
  117. multiMaterials: MultiMaterial[];
  118. /**
  119. * Materials populated in the container.
  120. */
  121. materials: Material[];
  122. /**
  123. * MorphTargetManagers populated in the container.
  124. */
  125. morphTargetManagers: MorphTargetManager[];
  126. /**
  127. * Geometries populated in the container.
  128. */
  129. geometries: Geometry[];
  130. /**
  131. * TransformNodes populated in the container.
  132. */
  133. transformNodes: TransformNode[];
  134. /**
  135. * LensFlareSystems populated in the container.
  136. */
  137. lensFlareSystems: LensFlareSystem[];
  138. /**
  139. * ShadowGenerators populated in the container.
  140. */
  141. shadowGenerators: ShadowGenerator[];
  142. /**
  143. * ActionManagers populated in the container.
  144. */
  145. actionManagers: ActionManager[];
  146. /**
  147. * Sounds populated in the container.
  148. */
  149. sounds: Sound[];
  150. /**
  151. * Textures populated in the container.
  152. */
  153. textures: Texture[];
  154. /**
  155. * Instantiates an AssetContainer.
  156. * @param scene The scene the AssetContainer belongs to.
  157. */
  158. constructor(scene: Scene);
  159. /**
  160. * Adds all the assets from the container to the scene.
  161. */
  162. addAllToScene(): void;
  163. /**
  164. * Removes all the assets in the container from the scene
  165. */
  166. removeAllFromScene(): void;
  167. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  168. /**
  169. * Removes all the assets contained in the scene and adds them to the container.
  170. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  171. */
  172. moveAllFromScene(keepAssets?: KeepAssets): void;
  173. }
  174. }
  175. interface Window {
  176. mozIndexedDB: IDBFactory;
  177. webkitIndexedDB: IDBFactory;
  178. msIndexedDB: IDBFactory;
  179. webkitURL: typeof URL;
  180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  182. WebGLRenderingContext: WebGLRenderingContext;
  183. MSGesture: MSGesture;
  184. CANNON: any;
  185. AudioContext: AudioContext;
  186. webkitAudioContext: AudioContext;
  187. PointerEvent: any;
  188. Math: Math;
  189. Uint8Array: Uint8ArrayConstructor;
  190. Float32Array: Float32ArrayConstructor;
  191. mozURL: typeof URL;
  192. msURL: typeof URL;
  193. VRFrameData: any;
  194. DracoDecoderModule: any;
  195. }
  196. interface WebGLRenderingContext {
  197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  199. vertexAttribDivisor(index: number, divisor: number): void;
  200. createVertexArray(): any;
  201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  204. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  208. createQuery(): WebGLQuery;
  209. deleteQuery(query: WebGLQuery): void;
  210. beginQuery(target: number, query: WebGLQuery): void;
  211. endQuery(target: number): void;
  212. getQueryParameter(query: WebGLQuery, pname: number): any;
  213. getQuery(target: number, pname: number): any;
  214. MAX_SAMPLES: number;
  215. RGBA8: number;
  216. READ_FRAMEBUFFER: number;
  217. DRAW_FRAMEBUFFER: number;
  218. UNIFORM_BUFFER: number;
  219. HALF_FLOAT_OES: number;
  220. RGBA16F: number;
  221. RGBA32F: number;
  222. R32F: number;
  223. RG32F: number;
  224. RGB32F: number;
  225. RED: number;
  226. RG: number;
  227. UNSIGNED_INT_24_8: number;
  228. DEPTH24_STENCIL8: number;
  229. drawBuffers(buffers: number[]): void;
  230. readBuffer(src: number): void;
  231. readonly COLOR_ATTACHMENT0: number;
  232. readonly COLOR_ATTACHMENT1: number;
  233. readonly COLOR_ATTACHMENT2: number;
  234. readonly COLOR_ATTACHMENT3: number;
  235. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  236. ANY_SAMPLES_PASSED: number;
  237. QUERY_RESULT_AVAILABLE: number;
  238. QUERY_RESULT: number;
  239. }
  240. interface Document {
  241. mozCancelFullScreen(): void;
  242. msCancelFullScreen(): void;
  243. mozFullScreen: boolean;
  244. msIsFullScreen: boolean;
  245. fullscreen: boolean;
  246. mozPointerLockElement: HTMLElement;
  247. msPointerLockElement: HTMLElement;
  248. webkitPointerLockElement: HTMLElement;
  249. }
  250. interface HTMLCanvasElement {
  251. msRequestPointerLock?(): void;
  252. mozRequestPointerLock?(): void;
  253. webkitRequestPointerLock?(): void;
  254. }
  255. interface CanvasRenderingContext2D {
  256. msImageSmoothingEnabled: boolean;
  257. }
  258. interface WebGLBuffer {
  259. references: number;
  260. capacity: number;
  261. is32Bits: boolean;
  262. }
  263. interface WebGLProgram {
  264. transformFeedback?: WebGLTransformFeedback | null;
  265. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  266. }
  267. interface MouseEvent {
  268. mozMovementX: number;
  269. mozMovementY: number;
  270. webkitMovementX: number;
  271. webkitMovementY: number;
  272. msMovementX: number;
  273. msMovementY: number;
  274. }
  275. interface Navigator {
  276. mozGetVRDevices: (any: any) => any;
  277. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  278. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. webkitGetGamepads(): Gamepad[];
  281. msGetGamepads(): Gamepad[];
  282. webkitGamepads(): Gamepad[];
  283. }
  284. interface HTMLVideoElement {
  285. mozSrcObject: any;
  286. }
  287. interface Screen {
  288. orientation: string;
  289. mozOrientation: string;
  290. }
  291. interface Math {
  292. fround(x: number): number;
  293. imul(a: number, b: number): number;
  294. }
  295. interface GamepadPose {
  296. hasOrientation: boolean;
  297. hasPosition: boolean;
  298. position?: Float32Array;
  299. linearVelocity?: Float32Array;
  300. linearAcceleration?: Float32Array;
  301. orientation?: Float32Array;
  302. angularVelocity?: Float32Array;
  303. angularAcceleration?: Float32Array;
  304. }
  305. interface EXT_disjoint_timer_query {
  306. QUERY_COUNTER_BITS_EXT: number;
  307. TIME_ELAPSED_EXT: number;
  308. TIMESTAMP_EXT: number;
  309. GPU_DISJOINT_EXT: number;
  310. QUERY_RESULT_EXT: number;
  311. QUERY_RESULT_AVAILABLE_EXT: number;
  312. queryCounterEXT(query: WebGLQuery, target: number): void;
  313. createQueryEXT(): WebGLQuery;
  314. beginQueryEXT(target: number, query: WebGLQuery): void;
  315. endQueryEXT(target: number): void;
  316. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  317. deleteQueryEXT(query: WebGLQuery): void;
  318. }
  319. interface WebGLUniformLocation {
  320. _currentState: any;
  321. }
  322. declare module BABYLON {
  323. /**
  324. * Node is the basic class for all scene objects (Mesh, Light Camera).
  325. */
  326. class Node {
  327. /**
  328. * Gets or sets the name of the node
  329. */
  330. name: string;
  331. /**
  332. * Gets or sets the id of the node
  333. */
  334. id: string;
  335. /**
  336. * Gets or sets the unique id of the node
  337. */
  338. uniqueId: number;
  339. /**
  340. * Gets or sets a string used to store user defined state for the node
  341. */
  342. state: string;
  343. /**
  344. * Gets or sets an object used to store user defined information for the node
  345. */
  346. metadata: any;
  347. /**
  348. * Gets or sets a boolean used to define if the node must be serialized
  349. */
  350. doNotSerialize: boolean;
  351. /** @ignore */
  352. _isDisposed: boolean;
  353. /**
  354. * Gets a list of Animations associated with the node
  355. */
  356. animations: Animation[];
  357. private _ranges;
  358. /**
  359. * Callback raised when the node is ready to be used
  360. */
  361. onReady: (node: Node) => void;
  362. private _isEnabled;
  363. private _isReady;
  364. /** @ignore */
  365. _currentRenderId: number;
  366. private _parentRenderId;
  367. protected _childRenderId: number;
  368. /** @ignore */
  369. _waitingParentId: Nullable<string>;
  370. private _scene;
  371. /** @ignore */
  372. _cache: any;
  373. private _parentNode;
  374. private _children;
  375. /**
  376. * Gets a boolean indicating if the node has been disposed
  377. * @returns true if the node was disposed
  378. */
  379. isDisposed(): boolean;
  380. /**
  381. * Gets or sets the parent of the node
  382. */
  383. parent: Nullable<Node>;
  384. private _animationPropertiesOverride;
  385. /**
  386. * Gets or sets the animation properties override
  387. */
  388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  389. /**
  390. * Gets a string idenfifying the name of the class
  391. * @returns "Node" string
  392. */
  393. getClassName(): string;
  394. /**
  395. * An event triggered when the mesh is disposed
  396. */
  397. onDisposeObservable: Observable<Node>;
  398. private _onDisposeObserver;
  399. /**
  400. * Sets a callback that will be raised when the node will be disposed
  401. */
  402. onDispose: () => void;
  403. /**
  404. * Creates a new Node
  405. * @param {string} name - the name and id to be given to this node
  406. * @param {BABYLON.Scene} the scene this node will be added to
  407. */
  408. constructor(name: string, scene?: Nullable<Scene>);
  409. /**
  410. * Gets the scene of the node
  411. * @returns a {BABYLON.Scene}
  412. */
  413. getScene(): Scene;
  414. /**
  415. * Gets the engine of the node
  416. * @returns a {BABYLON.Engine}
  417. */
  418. getEngine(): Engine;
  419. private _behaviors;
  420. /**
  421. * Attach a behavior to the node
  422. * @see http://doc.babylonjs.com/features/behaviour
  423. * @param behavior defines the behavior to attach
  424. * @returns the current Node
  425. */
  426. addBehavior(behavior: Behavior<Node>): Node;
  427. /**
  428. * Remove an attached behavior
  429. * @see http://doc.babylonjs.com/features/behaviour
  430. * @param behavior defines the behavior to attach
  431. * @returns the current Node
  432. */
  433. removeBehavior(behavior: Behavior<Node>): Node;
  434. /**
  435. * Gets the list of attached behaviors
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. */
  438. readonly behaviors: Behavior<Node>[];
  439. /**
  440. * Gets an attached behavior by name
  441. * @param name defines the name of the behavior to look for
  442. * @see http://doc.babylonjs.com/features/behaviour
  443. * @returns null if behavior was not found else the requested behavior
  444. */
  445. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  446. /**
  447. * Returns the world matrix of the node
  448. * @returns a matrix containing the node's world matrix
  449. */
  450. getWorldMatrix(): Matrix;
  451. /** @ignore */
  452. _initCache(): void;
  453. /** @ignore */
  454. updateCache(force?: boolean): void;
  455. /** @ignore */
  456. _updateCache(ignoreParentClass?: boolean): void;
  457. /** @ignore */
  458. _isSynchronized(): boolean;
  459. /** @ignore */
  460. _markSyncedWithParent(): void;
  461. /** @ignore */
  462. isSynchronizedWithParent(): boolean;
  463. /** @ignore */
  464. isSynchronized(updateCache?: boolean): boolean;
  465. /** @ignore */
  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. /** @ignore */
  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. /** @ignore */
  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. /** @ignore */
  694. _environmentBRDFTexture: BaseTexture;
  695. /** @ignore */
  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. /** @ignore */
  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. /**
  742. * Gets or sets a boolean indicating if a constant deltatime has to be used
  743. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  744. */
  745. useConstantAnimationDeltaTime: boolean;
  746. /**
  747. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  748. * Please note that it requires to run a ray cast through the scene on every frame
  749. */
  750. constantlyUpdateMeshUnderPointer: boolean;
  751. /**
  752. * Defines the HTML cursor to use when hovering over interactive elements
  753. */
  754. hoverCursor: string;
  755. /**
  756. * Defines the HTML default cursor to use (empty by default)
  757. */
  758. defaultCursor: string;
  759. /**
  760. * This is used to call preventDefault() on pointer down
  761. * in order to block unwanted artifacts like system double clicks
  762. */
  763. preventDefaultOnPointerDown: boolean;
  764. /**
  765. * Gets or sets user defined metadata
  766. */
  767. metadata: any;
  768. /**
  769. * Gets the name of the plugin used to load this scene (null by default)
  770. */
  771. loadingPluginName: string;
  772. /**
  773. * Use this array to add regular expressions used to disable offline support for specific urls
  774. */
  775. disableOfflineSupportExceptionRules: RegExp[];
  776. private _spritePredicate;
  777. /**
  778. * An event triggered when the scene is disposed.
  779. */
  780. onDisposeObservable: Observable<Scene>;
  781. private _onDisposeObserver;
  782. /** Sets a function to be executed when this scene is disposed. */
  783. onDispose: () => void;
  784. /**
  785. * An event triggered before rendering the scene (right after animations and physics)
  786. */
  787. onBeforeRenderObservable: Observable<Scene>;
  788. private _onBeforeRenderObserver;
  789. /** Sets a function to be executed before rendering this scene */
  790. beforeRender: Nullable<() => void>;
  791. /**
  792. * An event triggered after rendering the scene
  793. */
  794. onAfterRenderObservable: Observable<Scene>;
  795. private _onAfterRenderObserver;
  796. /** Sets a function to be executed after rendering this scene */
  797. afterRender: Nullable<() => void>;
  798. /**
  799. * An event triggered before animating the scene
  800. */
  801. onBeforeAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered after animations processing
  804. */
  805. onAfterAnimationsObservable: Observable<Scene>;
  806. /**
  807. * An event triggered before draw calls are ready to be sent
  808. */
  809. onBeforeDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after draw calls have been sent
  812. */
  813. onAfterDrawPhaseObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when physic simulation is about to be run
  816. */
  817. onBeforePhysicsObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when physic simulation has been done
  820. */
  821. onAfterPhysicsObservable: Observable<Scene>;
  822. /**
  823. * An event triggered when the scene is ready
  824. */
  825. onReadyObservable: Observable<Scene>;
  826. /**
  827. * An event triggered before rendering a camera
  828. */
  829. onBeforeCameraRenderObservable: Observable<Camera>;
  830. private _onBeforeCameraRenderObserver;
  831. /** Sets a function to be executed before rendering a camera*/
  832. beforeCameraRender: () => void;
  833. /**
  834. * An event triggered after rendering a camera
  835. */
  836. onAfterCameraRenderObservable: Observable<Camera>;
  837. private _onAfterCameraRenderObserver;
  838. /** Sets a function to be executed after rendering a camera*/
  839. afterCameraRender: () => void;
  840. /**
  841. * An event triggered when active meshes evaluation is about to start
  842. */
  843. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when active meshes evaluation is done
  846. */
  847. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  848. /**
  849. * An event triggered when particles rendering is about to start
  850. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  851. */
  852. onBeforeParticlesRenderingObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is done
  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. onAfterParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when sprites rendering is about to start
  860. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  861. */
  862. onBeforeSpritesRenderingObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  870. */
  871. onDataLoadedObservable: Observable<Scene>;
  872. /**
  873. * An event triggered when a camera is created
  874. */
  875. onNewCameraAddedObservable: Observable<Camera>;
  876. /**
  877. * An event triggered when a camera is removed
  878. */
  879. onCameraRemovedObservable: Observable<Camera>;
  880. /**
  881. * An event triggered when a light is created
  882. */
  883. onNewLightAddedObservable: Observable<Light>;
  884. /**
  885. * An event triggered when a light is removed
  886. */
  887. onLightRemovedObservable: Observable<Light>;
  888. /**
  889. * An event triggered when a geometry is created
  890. */
  891. onNewGeometryAddedObservable: Observable<Geometry>;
  892. /**
  893. * An event triggered when a geometry is removed
  894. */
  895. onGeometryRemovedObservable: Observable<Geometry>;
  896. /**
  897. * An event triggered when a transform node is created
  898. */
  899. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  900. /**
  901. * An event triggered when a transform node is removed
  902. */
  903. onTransformNodeRemovedObservable: Observable<TransformNode>;
  904. /**
  905. * An event triggered when a mesh is created
  906. */
  907. onNewMeshAddedObservable: Observable<AbstractMesh>;
  908. /**
  909. * An event triggered when a mesh is removed
  910. */
  911. onMeshRemovedObservable: Observable<AbstractMesh>;
  912. /**
  913. * An event triggered when render targets are about to be rendered
  914. * Can happen multiple times per frame.
  915. */
  916. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  917. /**
  918. * An event triggered when render targets were rendered.
  919. * Can happen multiple times per frame.
  920. */
  921. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  922. /**
  923. * An event triggered before calculating deterministic simulation step
  924. */
  925. onBeforeStepObservable: Observable<Scene>;
  926. /**
  927. * An event triggered after calculating deterministic simulation step
  928. */
  929. onAfterStepObservable: Observable<Scene>;
  930. /**
  931. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  932. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  933. * 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)
  934. */
  935. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  936. /**
  937. * Gets a list of Animations associated with the scene
  938. */
  939. animations: Animation[];
  940. private _registeredForLateAnimationBindings;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  943. */
  944. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  945. /**
  946. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  947. */
  948. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  949. /**
  950. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  951. */
  952. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  953. private _onPointerMove;
  954. private _onPointerDown;
  955. private _onPointerUp;
  956. /** Deprecated. Use onPointerObservable instead */
  957. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  958. /** Deprecated. Use onPointerObservable instead */
  959. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  960. /** Deprecated. Use onPointerObservable instead */
  961. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  962. /** Deprecated. Use onPointerObservable instead */
  963. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  964. private _gamepadManager;
  965. /**
  966. * Gets the gamepad manager associated with the scene
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  968. */
  969. readonly gamepadManager: GamepadManager;
  970. /**
  971. * 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).
  972. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  973. */
  974. onPrePointerObservable: Observable<PointerInfoPre>;
  975. /**
  976. * Observable event triggered each time an input event is received from the rendering canvas
  977. */
  978. onPointerObservable: Observable<PointerInfo>;
  979. /**
  980. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  981. */
  982. readonly unTranslatedPointer: Vector2;
  983. /** The distance in pixel that you have to move to prevent some events */
  984. static DragMovementThreshold: number;
  985. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  986. static LongPressDelay: number;
  987. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  988. static DoubleClickDelay: number;
  989. /** If you need to check double click without raising a single click at first click, enable this flag */
  990. static ExclusiveDoubleClickMode: boolean;
  991. private _initClickEvent;
  992. private _initActionManager;
  993. private _delayedSimpleClick;
  994. private _delayedSimpleClickTimeout;
  995. private _previousDelayedSimpleClickTimeout;
  996. private _meshPickProceed;
  997. private _previousButtonPressed;
  998. private _currentPickResult;
  999. private _previousPickResult;
  1000. private _totalPointersPressed;
  1001. private _doubleClickOccured;
  1002. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1003. cameraToUseForPointers: Nullable<Camera>;
  1004. private _pointerX;
  1005. private _pointerY;
  1006. private _unTranslatedPointerX;
  1007. private _unTranslatedPointerY;
  1008. private _startingPointerPosition;
  1009. private _previousStartingPointerPosition;
  1010. private _startingPointerTime;
  1011. private _previousStartingPointerTime;
  1012. private _timeAccumulator;
  1013. private _currentStepId;
  1014. private _currentInternalStep;
  1015. /** @ignore */
  1016. _mirroredCameraPosition: Nullable<Vector3>;
  1017. /**
  1018. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1019. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1020. */
  1021. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1022. /**
  1023. * Observable event triggered each time an keyboard event is received from the hosting window
  1024. */
  1025. onKeyboardObservable: Observable<KeyboardInfo>;
  1026. private _onKeyDown;
  1027. private _onKeyUp;
  1028. private _onCanvasFocusObserver;
  1029. private _onCanvasBlurObserver;
  1030. private _useRightHandedSystem;
  1031. /**
  1032. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1033. */
  1034. useRightHandedSystem: boolean;
  1035. /**
  1036. * Sets the step Id used by deterministic lock step
  1037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1038. * @param newStepId defines the step Id
  1039. */
  1040. setStepId(newStepId: number): void;
  1041. /**
  1042. * Gets the step Id used by deterministic lock step
  1043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1044. * @returns the step Id
  1045. */
  1046. getStepId(): number;
  1047. /**
  1048. * Gets the internal step used by deterministic lock step
  1049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1050. * @returns the internal step
  1051. */
  1052. getInternalStep(): number;
  1053. private _fogEnabled;
  1054. /**
  1055. * Gets or sets a boolean indicating if fog is enabled on this scene
  1056. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1057. */
  1058. fogEnabled: boolean;
  1059. private _fogMode;
  1060. /**
  1061. * Gets or sets the fog mode to use
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. */
  1064. fogMode: number;
  1065. /**
  1066. * Gets or sets the fog color to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogColor: Color3;
  1070. /**
  1071. * Gets or sets the fog density to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogDensity: number;
  1075. /**
  1076. * Gets or sets the fog start distance to use
  1077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1078. */
  1079. fogStart: number;
  1080. /**
  1081. * Gets or sets the fog end distance to use
  1082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1083. */
  1084. fogEnd: number;
  1085. private _shadowsEnabled;
  1086. /**
  1087. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1088. */
  1089. shadowsEnabled: boolean;
  1090. private _lightsEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if lights are enabled on this scene
  1093. */
  1094. lightsEnabled: boolean;
  1095. /**
  1096. * All of the lights added to this scene
  1097. * @see http://doc.babylonjs.com/babylon101/lights
  1098. */
  1099. lights: Light[];
  1100. /** All of the cameras added to this scene.
  1101. * @see http://doc.babylonjs.com/babylon101/cameras
  1102. */
  1103. cameras: Camera[];
  1104. /** All of the active cameras added to this scene. */
  1105. activeCameras: Camera[];
  1106. /** The current active camera */
  1107. activeCamera: Nullable<Camera>;
  1108. /**
  1109. * All of the tranform nodes added to this scene
  1110. * @see http://doc.babylonjs.com/how_to/transformnode
  1111. */
  1112. transformNodes: TransformNode[];
  1113. /**
  1114. * All of the (abstract) meshes added to this scene
  1115. */
  1116. meshes: AbstractMesh[];
  1117. /**
  1118. * All of the animation groups added to this scene
  1119. * @see http://doc.babylonjs.com/how_to/group
  1120. */
  1121. animationGroups: AnimationGroup[];
  1122. private _geometries;
  1123. /**
  1124. * All of the materials added to this scene
  1125. * @see http://doc.babylonjs.com/babylon101/materials
  1126. */
  1127. materials: Material[];
  1128. /**
  1129. * All of the multi-materials added to this scene
  1130. * @see http://doc.babylonjs.com/how_to/multi_materials
  1131. */
  1132. multiMaterials: MultiMaterial[];
  1133. private _defaultMaterial;
  1134. /** The default material used on meshes when no material is affected */
  1135. /** The default material used on meshes when no material is affected */
  1136. defaultMaterial: Material;
  1137. private _texturesEnabled;
  1138. /**
  1139. * Gets or sets a boolean indicating if textures are enabled on this scene
  1140. */
  1141. texturesEnabled: boolean;
  1142. /**
  1143. * All of the textures added to this scene
  1144. */
  1145. textures: BaseTexture[];
  1146. /**
  1147. * Gets or sets a boolean indicating if particles are enabled on this scene
  1148. */
  1149. particlesEnabled: boolean;
  1150. /**
  1151. * All of the particle systems added to this scene
  1152. * @see http://doc.babylonjs.com/babylon101/particles
  1153. */
  1154. particleSystems: IParticleSystem[];
  1155. /**
  1156. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1157. */
  1158. spritesEnabled: boolean;
  1159. /**
  1160. * All of the sprite managers added to this scene
  1161. * @see http://doc.babylonjs.com/babylon101/sprites
  1162. */
  1163. spriteManagers: SpriteManager[];
  1164. /**
  1165. * The list of layers (background and foreground) of the scene
  1166. */
  1167. layers: Layer[];
  1168. /**
  1169. * The list of effect layers (highlights/glow) added to the scene
  1170. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1171. * @see http://doc.babylonjs.com/how_to/glow_layer
  1172. */
  1173. effectLayers: EffectLayer[];
  1174. private _skeletonsEnabled;
  1175. /**
  1176. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1177. */
  1178. skeletonsEnabled: boolean;
  1179. /**
  1180. * The list of skeletons added to the scene
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1182. */
  1183. skeletons: Skeleton[];
  1184. /**
  1185. * The list of morph target managers added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1187. */
  1188. morphTargetManagers: MorphTargetManager[];
  1189. /**
  1190. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1191. */
  1192. lensFlaresEnabled: boolean;
  1193. /**
  1194. * The list of lens flare system added to the scene
  1195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1196. */
  1197. lensFlareSystems: LensFlareSystem[];
  1198. /**
  1199. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1201. */
  1202. collisionsEnabled: boolean;
  1203. private _workerCollisions;
  1204. /** @ignore */
  1205. collisionCoordinator: ICollisionCoordinator;
  1206. /**
  1207. * Defines the gravity applied to this scene (used only for collisions)
  1208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1209. */
  1210. gravity: Vector3;
  1211. /**
  1212. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1213. */
  1214. postProcessesEnabled: boolean;
  1215. /**
  1216. * The list of postprocesses added to the scene
  1217. */
  1218. postProcesses: PostProcess[];
  1219. /**
  1220. * Gets the current postprocess manager
  1221. */
  1222. postProcessManager: PostProcessManager;
  1223. private _postProcessRenderPipelineManager;
  1224. /**
  1225. * Gets the postprocess render pipeline manager
  1226. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1227. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1228. */
  1229. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1230. /**
  1231. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1232. */
  1233. renderTargetsEnabled: boolean;
  1234. /**
  1235. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1236. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1237. */
  1238. dumpNextRenderTargets: boolean;
  1239. /**
  1240. * The list of user defined render targets added to the scene
  1241. */
  1242. customRenderTargets: RenderTargetTexture[];
  1243. /**
  1244. * Defines if texture loading must be delayed
  1245. * If true, textures will only be loaded when they need to be rendered
  1246. */
  1247. useDelayedTextureLoading: boolean;
  1248. /**
  1249. * Gets the list of meshes imported to the scene through SceneLoader
  1250. */
  1251. importedMeshesFiles: String[];
  1252. /**
  1253. * Gets or sets a boolean indicating if probes are enabled on this scene
  1254. */
  1255. probesEnabled: boolean;
  1256. /**
  1257. * The list of reflection probes added to the scene
  1258. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1259. */
  1260. reflectionProbes: ReflectionProbe[];
  1261. /**
  1262. * @ignore
  1263. */
  1264. database: Database;
  1265. /**
  1266. * Gets or sets the action manager associated with the scene
  1267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1268. */
  1269. actionManager: ActionManager;
  1270. /** @ignore */
  1271. _actionManagers: ActionManager[];
  1272. private _meshesForIntersections;
  1273. /**
  1274. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1275. */
  1276. proceduralTexturesEnabled: boolean;
  1277. /**
  1278. * The list of procedural textures added to the scene
  1279. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1280. */
  1281. proceduralTextures: ProceduralTexture[];
  1282. private _mainSoundTrack;
  1283. /**
  1284. * The list of sound tracks added to the scene
  1285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1286. */
  1287. soundTracks: SoundTrack[];
  1288. private _audioEnabled;
  1289. private _headphone;
  1290. /**
  1291. * Gets the main soundtrack associated with the scene
  1292. */
  1293. readonly mainSoundTrack: SoundTrack;
  1294. /**
  1295. * Gets or sets the VRExperienceHelper attached to the scene
  1296. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1297. * @ignoreNaming
  1298. */
  1299. VRHelper: VRExperienceHelper;
  1300. /**
  1301. * Gets or sets the simplification queue attached to the scene
  1302. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1303. */
  1304. simplificationQueue: SimplificationQueue;
  1305. private _engine;
  1306. private _totalVertices;
  1307. /** @ignore */
  1308. _activeIndices: PerfCounter;
  1309. /** @ignore */
  1310. _activeParticles: PerfCounter;
  1311. /** @ignore */
  1312. _activeBones: PerfCounter;
  1313. private _animationRatio;
  1314. private _animationTimeLast;
  1315. private _animationTime;
  1316. /**
  1317. * Gets or sets a general scale for animation speed
  1318. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1319. */
  1320. animationTimeScale: number;
  1321. /** @ignore */
  1322. _cachedMaterial: Nullable<Material>;
  1323. /** @ignore */
  1324. _cachedEffect: Nullable<Effect>;
  1325. /** @ignore */
  1326. _cachedVisibility: Nullable<number>;
  1327. private _renderId;
  1328. private _executeWhenReadyTimeoutId;
  1329. private _intermediateRendering;
  1330. private _viewUpdateFlag;
  1331. private _projectionUpdateFlag;
  1332. private _alternateViewUpdateFlag;
  1333. private _alternateProjectionUpdateFlag;
  1334. /** @ignore */
  1335. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1336. private _activeRequests;
  1337. private _pendingData;
  1338. private _isDisposed;
  1339. /**
  1340. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1341. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1342. */
  1343. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1344. private _activeMeshes;
  1345. private _processedMaterials;
  1346. private _renderTargets;
  1347. /** @ignore */
  1348. _activeParticleSystems: SmartArray<IParticleSystem>;
  1349. private _activeSkeletons;
  1350. private _softwareSkinnedMeshes;
  1351. private _renderingManager;
  1352. private _physicsEngine;
  1353. /** @ignore */
  1354. _activeAnimatables: Animatable[];
  1355. private _transformMatrix;
  1356. private _sceneUbo;
  1357. private _alternateSceneUbo;
  1358. private _pickWithRayInverseMatrix;
  1359. private _boundingBoxRenderer;
  1360. private _outlineRenderer;
  1361. private _viewMatrix;
  1362. private _projectionMatrix;
  1363. private _alternateViewMatrix;
  1364. private _alternateProjectionMatrix;
  1365. private _alternateTransformMatrix;
  1366. private _useAlternateCameraConfiguration;
  1367. private _alternateRendering;
  1368. /** @ignore */
  1369. _forcedViewPosition: Nullable<Vector3>;
  1370. /** @ignore */
  1371. readonly _isAlternateRenderingEnabled: boolean;
  1372. private _frustumPlanes;
  1373. /**
  1374. * Gets the list of frustum planes (built from the active camera)
  1375. */
  1376. readonly frustumPlanes: Plane[];
  1377. /**
  1378. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1379. * This is useful if there are more lights that the maximum simulteanous authorized
  1380. */
  1381. requireLightSorting: boolean;
  1382. private _selectionOctree;
  1383. private _pointerOverMesh;
  1384. private _pointerOverSprite;
  1385. private _debugLayer;
  1386. private _depthRenderer;
  1387. private _geometryBufferRenderer;
  1388. /**
  1389. * Gets the current geometry buffer associated to the scene.
  1390. */
  1391. /**
  1392. * Sets the current geometry buffer for the scene.
  1393. */
  1394. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1395. private _pickedDownMesh;
  1396. private _pickedUpMesh;
  1397. private _pickedDownSprite;
  1398. private _externalData;
  1399. private _uid;
  1400. /**
  1401. * Creates a new Scene
  1402. * @param engine defines the engine to use to render this scene
  1403. */
  1404. constructor(engine: Engine);
  1405. /**
  1406. * Gets the debug layer associated with the scene
  1407. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1408. */
  1409. readonly debugLayer: DebugLayer;
  1410. /**
  1411. * Gets a boolean indicating if collisions are processed on a web worker
  1412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1413. */
  1414. workerCollisions: boolean;
  1415. /**
  1416. * Gets the octree used to boost mesh selection (picking)
  1417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1418. */
  1419. readonly selectionOctree: Octree<AbstractMesh>;
  1420. /**
  1421. * Gets the mesh that is currently under the pointer
  1422. */
  1423. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1424. /**
  1425. * Gets the current on-screen X position of the pointer
  1426. */
  1427. readonly pointerX: number;
  1428. /**
  1429. * Gets the current on-screen Y position of the pointer
  1430. */
  1431. readonly pointerY: number;
  1432. /**
  1433. * Gets the cached material (ie. the latest rendered one)
  1434. * @returns the cached material
  1435. */
  1436. getCachedMaterial(): Nullable<Material>;
  1437. /**
  1438. * Gets the cached effect (ie. the latest rendered one)
  1439. * @returns the cached effect
  1440. */
  1441. getCachedEffect(): Nullable<Effect>;
  1442. /**
  1443. * Gets the cached visibility state (ie. the latest rendered one)
  1444. * @returns the cached visibility state
  1445. */
  1446. getCachedVisibility(): Nullable<number>;
  1447. /**
  1448. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1449. * @param material defines the current material
  1450. * @param effect defines the current effect
  1451. * @param visibility defines the current visibility state
  1452. * @returns true if one parameter is not cached
  1453. */
  1454. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1455. /**
  1456. * Gets the bounding box renderer associated with the scene
  1457. * @returns a BoundingBoxRenderer
  1458. */
  1459. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1460. /**
  1461. * Gets the outline renderer associated with the scene
  1462. * @returns a OutlineRenderer
  1463. */
  1464. getOutlineRenderer(): OutlineRenderer;
  1465. /**
  1466. * Gets the engine associated with the scene
  1467. * @returns an Engine
  1468. */
  1469. getEngine(): Engine;
  1470. /**
  1471. * Gets the total number of vertices rendered per frame
  1472. * @returns the total number of vertices rendered per frame
  1473. */
  1474. getTotalVertices(): number;
  1475. /**
  1476. * Gets the performance counter for total vertices
  1477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1478. */
  1479. readonly totalVerticesPerfCounter: PerfCounter;
  1480. /**
  1481. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1482. * @returns the total number of active indices rendered per frame
  1483. */
  1484. getActiveIndices(): number;
  1485. /**
  1486. * Gets the performance counter for active indices
  1487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1488. */
  1489. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1490. /**
  1491. * Gets the total number of active particles rendered per frame
  1492. * @returns the total number of active particles rendered per frame
  1493. */
  1494. getActiveParticles(): number;
  1495. /**
  1496. * Gets the performance counter for active particles
  1497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1498. */
  1499. readonly activeParticlesPerfCounter: PerfCounter;
  1500. /**
  1501. * Gets the total number of active bones rendered per frame
  1502. * @returns the total number of active bones rendered per frame
  1503. */
  1504. getActiveBones(): number;
  1505. /**
  1506. * Gets the performance counter for active bones
  1507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1508. */
  1509. readonly activeBonesPerfCounter: PerfCounter;
  1510. /** @ignore */
  1511. getInterFramePerfCounter(): number;
  1512. /** @ignore */
  1513. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1514. /** @ignore */
  1515. getLastFrameDuration(): number;
  1516. /** @ignore */
  1517. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1518. /** @ignore */
  1519. getEvaluateActiveMeshesDuration(): number;
  1520. /** @ignore */
  1521. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1522. /**
  1523. * Gets the array of active meshes
  1524. * @returns an array of AbstractMesh
  1525. */
  1526. getActiveMeshes(): SmartArray<AbstractMesh>;
  1527. /** @ignore */
  1528. getRenderTargetsDuration(): number;
  1529. /** @ignore */
  1530. getRenderDuration(): number;
  1531. /** @ignore */
  1532. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1533. /** @ignore */
  1534. getParticlesDuration(): number;
  1535. /** @ignore */
  1536. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1537. /** @ignore */
  1538. getSpritesDuration(): number;
  1539. /** @ignore */
  1540. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1541. /**
  1542. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1543. * @returns a number
  1544. */
  1545. getAnimationRatio(): number;
  1546. /**
  1547. * Gets an unique Id for the current frame
  1548. * @returns a number
  1549. */
  1550. getRenderId(): number;
  1551. /** Call this function if you want to manually increment the render Id*/
  1552. incrementRenderId(): void;
  1553. private _updatePointerPosition(evt);
  1554. private _createUbo();
  1555. private _createAlternateUbo();
  1556. /**
  1557. * Use this method to simulate a pointer move on a mesh
  1558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1561. * @returns the current scene
  1562. */
  1563. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1564. private _processPointerMove(pickResult, evt);
  1565. /**
  1566. * Use this method to simulate a pointer down on a mesh
  1567. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1568. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1569. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1570. * @returns the current scene
  1571. */
  1572. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1573. private _processPointerDown(pickResult, evt);
  1574. /**
  1575. * Use this method to simulate a pointer up on a mesh
  1576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1579. * @returns the current scene
  1580. */
  1581. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerUp(pickResult, evt, clickInfo);
  1583. /**
  1584. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1585. * @param attachUp defines if you want to attach events to pointerup
  1586. * @param attachDown defines if you want to attach events to pointerdown
  1587. * @param attachMove defines if you want to attach events to pointermove
  1588. */
  1589. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1590. /** Detaches all event handlers*/
  1591. detachControl(): void;
  1592. /**
  1593. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1594. * Delay loaded resources are not taking in account
  1595. * @return true if all required resources are ready
  1596. */
  1597. isReady(): boolean;
  1598. /** Resets all cached information relative to material (including effect and visibility) */
  1599. resetCachedMaterial(): void;
  1600. /**
  1601. * Registers a function to be called before every frame render
  1602. * @param func defines the function to register
  1603. */
  1604. registerBeforeRender(func: () => void): void;
  1605. /**
  1606. * Unregisters a function called before every frame render
  1607. * @param func defines the function to unregister
  1608. */
  1609. unregisterBeforeRender(func: () => void): void;
  1610. /**
  1611. * Registers a function to be called after every frame render
  1612. * @param func defines the function to register
  1613. */
  1614. registerAfterRender(func: () => void): void;
  1615. /**
  1616. * Unregisters a function called after every frame render
  1617. * @param func defines the function to unregister
  1618. */
  1619. unregisterAfterRender(func: () => void): void;
  1620. private _executeOnceBeforeRender(func);
  1621. /**
  1622. * The provided function will run before render once and will be disposed afterwards.
  1623. * A timeout delay can be provided so that the function will be executed in N ms.
  1624. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1625. * @param func The function to be executed.
  1626. * @param timeout optional delay in ms
  1627. */
  1628. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1629. /** @ignore */
  1630. _addPendingData(data: any): void;
  1631. /** @ignore */
  1632. _removePendingData(data: any): void;
  1633. /**
  1634. * Returns the number of items waiting to be loaded
  1635. * @returns the number of items waiting to be loaded
  1636. */
  1637. getWaitingItemsCount(): number;
  1638. /**
  1639. * Returns a boolean indicating if the scene is still loading data
  1640. */
  1641. readonly isLoading: boolean;
  1642. /**
  1643. * Registers a function to be executed when the scene is ready
  1644. * @param {Function} func - the function to be executed
  1645. */
  1646. executeWhenReady(func: () => void): void;
  1647. /**
  1648. * Returns a promise that resolves when the scene is ready
  1649. * @returns A promise that resolves when the scene is ready
  1650. */
  1651. whenReadyAsync(): Promise<void>;
  1652. /** @ignore */
  1653. _checkIsReady(): void;
  1654. /**
  1655. * Will start the animation sequence of a given target
  1656. * @param target defines the target
  1657. * @param from defines from which frame should animation start
  1658. * @param to defines until which frame should animation run.
  1659. * @param weight defines the weight to apply to the animation (1.0 by default)
  1660. * @param loop defines if the animation loops
  1661. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1662. * @param onAnimationEnd defines the function to be executed when the animation ends
  1663. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1664. * @returns the animatable object created for this animation
  1665. */
  1666. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1667. /**
  1668. * Will start the animation sequence of a given target
  1669. * @param target defines the target
  1670. * @param from defines from which frame should animation start
  1671. * @param to defines until which frame should animation run.
  1672. * @param loop defines if the animation loops
  1673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1674. * @param onAnimationEnd defines the function to be executed when the animation ends
  1675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1676. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1677. * @returns the animatable object created for this animation
  1678. */
  1679. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1680. /**
  1681. * Begin a new animation on a given node
  1682. * @param target defines the target where the animation will take place
  1683. * @param animations defines the list of animations to start
  1684. * @param from defines the initial value
  1685. * @param to defines the final value
  1686. * @param loop defines if you want animation to loop (off by default)
  1687. * @param speedRatio defines the speed ratio to apply to all animations
  1688. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1689. * @returns the list of created animatables
  1690. */
  1691. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1692. /**
  1693. * Begin a new animation on a given node and its hierarchy
  1694. * @param target defines the root node where the animation will take place
  1695. * @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.
  1696. * @param animations defines the list of animations to start
  1697. * @param from defines the initial value
  1698. * @param to defines the final value
  1699. * @param loop defines if you want animation to loop (off by default)
  1700. * @param speedRatio defines the speed ratio to apply to all animations
  1701. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1702. * @returns the list of animatables created for all nodes
  1703. */
  1704. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1705. /**
  1706. * Gets the animatable associated with a specific target
  1707. * @param target defines the target of the animatable
  1708. * @returns the required animatable if found
  1709. */
  1710. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1711. /**
  1712. * Gets all animatables associated with a given target
  1713. * @param target defines the target to look animatables for
  1714. * @returns an array of Animatables
  1715. */
  1716. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1717. /**
  1718. * Gets all animatable attached to the scene
  1719. */
  1720. readonly animatables: Animatable[];
  1721. /**
  1722. * Will stop the animation of the given target
  1723. * @param target - the target
  1724. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1725. */
  1726. stopAnimation(target: any, animationName?: string): void;
  1727. /**
  1728. * Stops and removes all animations that have been applied to the scene
  1729. */
  1730. stopAllAnimations(): void;
  1731. private _animate();
  1732. /** @ignore */
  1733. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1734. private _processLateAnimationBindings();
  1735. /** @ignore */
  1736. _switchToAlternateCameraConfiguration(active: boolean): void;
  1737. /**
  1738. * Gets the current view matrix
  1739. * @returns a Matrix
  1740. */
  1741. getViewMatrix(): Matrix;
  1742. /**
  1743. * Gets the current projection matrix
  1744. * @returns a Matrix
  1745. */
  1746. getProjectionMatrix(): Matrix;
  1747. /**
  1748. * Gets the current transform matrix
  1749. * @returns a Matrix made of View * Projection
  1750. */
  1751. getTransformMatrix(): Matrix;
  1752. /**
  1753. * Sets the current transform matrix
  1754. * @param view defines the View matrix to use
  1755. * @param projection defines the Projection matrix to use
  1756. */
  1757. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1758. /** @ignore */
  1759. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1760. /**
  1761. * Gets the uniform buffer used to store scene data
  1762. * @returns a UniformBuffer
  1763. */
  1764. getSceneUniformBuffer(): UniformBuffer;
  1765. /**
  1766. * Gets an unique (relatively to the current scene) Id
  1767. * @returns an unique number for the scene
  1768. */
  1769. getUniqueId(): number;
  1770. /**
  1771. * Add a mesh to the list of scene's meshes
  1772. * @param newMesh defines the mesh to add
  1773. */
  1774. addMesh(newMesh: AbstractMesh): void;
  1775. /**
  1776. * Remove a mesh for the list of scene's meshes
  1777. * @param toRemove defines the mesh to remove
  1778. * @returns the index where the mesh was in the mesh list
  1779. */
  1780. removeMesh(toRemove: AbstractMesh): number;
  1781. /**
  1782. * Add a transform node to the list of scene's transform nodes
  1783. * @param newTransformNode defines the transform node to add
  1784. */
  1785. addTransformNode(newTransformNode: TransformNode): void;
  1786. /**
  1787. * Remove a transform node for the list of scene's transform nodes
  1788. * @param toRemove defines the transform node to remove
  1789. * @returns the index where the transform node was in the transform node list
  1790. */
  1791. removeTransformNode(toRemove: TransformNode): number;
  1792. /**
  1793. * Remove a skeleton for the list of scene's skeletons
  1794. * @param toRemove defines the skeleton to remove
  1795. * @returns the index where the skeleton was in the skeleton list
  1796. */
  1797. removeSkeleton(toRemove: Skeleton): number;
  1798. /**
  1799. * Remove a morph target for the list of scene's morph targets
  1800. * @param toRemove defines the morph target to remove
  1801. * @returns the index where the morph target was in the morph target list
  1802. */
  1803. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1804. /**
  1805. * Remove a light for the list of scene's lights
  1806. * @param toRemove defines the light to remove
  1807. * @returns the index where the light was in the light list
  1808. */
  1809. removeLight(toRemove: Light): number;
  1810. /**
  1811. * Remove a camera for the list of scene's cameras
  1812. * @param toRemove defines the camera to remove
  1813. * @returns the index where the camera was in the camera list
  1814. */
  1815. removeCamera(toRemove: Camera): number;
  1816. /**
  1817. * Remove a particle system for the list of scene's particle systems
  1818. * @param toRemove defines the particle system to remove
  1819. * @returns the index where the particle system was in the particle system list
  1820. */
  1821. removeParticleSystem(toRemove: IParticleSystem): number;
  1822. /**
  1823. * Remove a animation for the list of scene's animations
  1824. * @param toRemove defines the animation to remove
  1825. * @returns the index where the animation was in the animation list
  1826. */
  1827. removeAnimation(toRemove: Animation): number;
  1828. /**
  1829. * Removes the given animation group from this scene.
  1830. * @param toRemove The animation group to remove
  1831. * @returns The index of the removed animation group
  1832. */
  1833. removeAnimationGroup(toRemove: AnimationGroup): number;
  1834. /**
  1835. * Removes the given multi-material from this scene.
  1836. * @param toRemove The multi-material to remove
  1837. * @returns The index of the removed multi-material
  1838. */
  1839. removeMultiMaterial(toRemove: MultiMaterial): number;
  1840. /**
  1841. * Removes the given material from this scene.
  1842. * @param toRemove The material to remove
  1843. * @returns The index of the removed material
  1844. */
  1845. removeMaterial(toRemove: Material): number;
  1846. /**
  1847. * Removes the given lens flare system from this scene.
  1848. * @param toRemove The lens flare system to remove
  1849. * @returns The index of the removed lens flare system
  1850. */
  1851. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1852. /**
  1853. * Removes the given action manager from this scene.
  1854. * @param toRemove The action manager to remove
  1855. * @returns The index of the removed action manager
  1856. */
  1857. removeActionManager(toRemove: ActionManager): number;
  1858. /**
  1859. * Removes the given texture from this scene.
  1860. * @param toRemove The texture to remove
  1861. * @returns The index of the removed texture
  1862. */
  1863. removeTexture(toRemove: BaseTexture): number;
  1864. /**
  1865. * Adds the given light to this scene
  1866. * @param newLight The light to add
  1867. */
  1868. addLight(newLight: Light): void;
  1869. /**
  1870. * Sorts the list list based on light priorities
  1871. */
  1872. sortLightsByPriority(): void;
  1873. /**
  1874. * Adds the given camera to this scene
  1875. * @param newCamera The camera to add
  1876. */
  1877. addCamera(newCamera: Camera): void;
  1878. /**
  1879. * Adds the given skeleton to this scene
  1880. * @param newSkeleton The skeleton to add
  1881. */
  1882. addSkeleton(newSkeleton: Skeleton): void;
  1883. /**
  1884. * Adds the given particle system to this scene
  1885. * @param newParticleSystem The particle system to add
  1886. */
  1887. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1888. /**
  1889. * Adds the given animation to this scene
  1890. * @param newAnimation The animation to add
  1891. */
  1892. addAnimation(newAnimation: Animation): void;
  1893. /**
  1894. * Adds the given animation group to this scene.
  1895. * @param newAnimationGroup The animation group to add
  1896. */
  1897. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1898. /**
  1899. * Adds the given multi-material to this scene
  1900. * @param newMultiMaterial The multi-material to add
  1901. */
  1902. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1903. /**
  1904. * Adds the given material to this scene
  1905. * @param newMaterial The material to add
  1906. */
  1907. addMaterial(newMaterial: Material): void;
  1908. /**
  1909. * Adds the given morph target to this scene
  1910. * @param newMorphTargetManager The morph target to add
  1911. */
  1912. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1913. /**
  1914. * Adds the given geometry to this scene
  1915. * @param newGeometry The geometry to add
  1916. */
  1917. addGeometry(newGeometry: Geometry): void;
  1918. /**
  1919. * Adds the given lens flare system to this scene
  1920. * @param newLensFlareSystem The lens flare system to add
  1921. */
  1922. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1923. /**
  1924. * Adds the given action manager to this scene
  1925. * @param newActionManager The action manager to add
  1926. */
  1927. addActionManager(newActionManager: ActionManager): void;
  1928. /**
  1929. * Adds the given texture to this scene.
  1930. * @param newTexture The texture to add
  1931. */
  1932. addTexture(newTexture: BaseTexture): void;
  1933. /**
  1934. * Switch active camera
  1935. * @param newCamera defines the new active camera
  1936. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1937. */
  1938. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1939. /**
  1940. * sets the active camera of the scene using its ID
  1941. * @param id defines the camera's ID
  1942. * @return the new active camera or null if none found.
  1943. */
  1944. setActiveCameraByID(id: string): Nullable<Camera>;
  1945. /**
  1946. * sets the active camera of the scene using its name
  1947. * @param name defines the camera's name
  1948. * @returns the new active camera or null if none found.
  1949. */
  1950. setActiveCameraByName(name: string): Nullable<Camera>;
  1951. /**
  1952. * get an animation group using its name
  1953. * @param name defines the material's name
  1954. * @return the animation group or null if none found.
  1955. */
  1956. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1957. /**
  1958. * get a material using its id
  1959. * @param id defines the material's ID
  1960. * @return the material or null if none found.
  1961. */
  1962. getMaterialByID(id: string): Nullable<Material>;
  1963. /**
  1964. * Gets a material using its name
  1965. * @param name defines the material's name
  1966. * @return the material or null if none found.
  1967. */
  1968. getMaterialByName(name: string): Nullable<Material>;
  1969. /**
  1970. * Gets a lens flare system using its name
  1971. * @param name defines the name to look for
  1972. * @returns the lens flare system or null if not found
  1973. */
  1974. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1975. /**
  1976. * Gets a lens flare system using its id
  1977. * @param id defines the id to look for
  1978. * @returns the lens flare system or null if not found
  1979. */
  1980. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1981. /**
  1982. * Gets a camera using its id
  1983. * @param id defines the id to look for
  1984. * @returns the camera or null if not found
  1985. */
  1986. getCameraByID(id: string): Nullable<Camera>;
  1987. /**
  1988. * Gets a camera using its unique id
  1989. * @param uniqueId defines the unique id to look for
  1990. * @returns the camera or null if not found
  1991. */
  1992. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1993. /**
  1994. * Gets a camera using its name
  1995. * @param name defines the camera's name
  1996. * @return the camera or null if none found.
  1997. */
  1998. getCameraByName(name: string): Nullable<Camera>;
  1999. /**
  2000. * Gets a bone using its id
  2001. * @param id defines the bone's id
  2002. * @return the bone or null if not found
  2003. */
  2004. getBoneByID(id: string): Nullable<Bone>;
  2005. /**
  2006. * Gets a bone using its id
  2007. * @param name defines the bone's name
  2008. * @return the bone or null if not found
  2009. */
  2010. getBoneByName(name: string): Nullable<Bone>;
  2011. /**
  2012. * Gets a light node using its name
  2013. * @param name defines the the light's name
  2014. * @return the light or null if none found.
  2015. */
  2016. getLightByName(name: string): Nullable<Light>;
  2017. /**
  2018. * Gets a light node using its id
  2019. * @param id defines the light's id
  2020. * @return the light or null if none found.
  2021. */
  2022. getLightByID(id: string): Nullable<Light>;
  2023. /**
  2024. * Gets a light node using its scene-generated unique ID
  2025. * @param uniqueId defines the light's unique id
  2026. * @return the light or null if none found.
  2027. */
  2028. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2029. /**
  2030. * Gets a particle system by id
  2031. * @param id defines the particle system id
  2032. * @return the corresponding system or null if none found
  2033. */
  2034. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2035. /**
  2036. * Gets a geometry using its ID
  2037. * @param id defines the geometry's id
  2038. * @return the geometry or null if none found.
  2039. */
  2040. getGeometryByID(id: string): Nullable<Geometry>;
  2041. /**
  2042. * Add a new geometry to this scene
  2043. * @param geometry defines the geometry to be added to the scene.
  2044. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2045. * @return a boolean defining if the geometry was added or not
  2046. */
  2047. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2048. /**
  2049. * Removes an existing geometry
  2050. * @param geometry defines the geometry to be removed from the scene
  2051. * @return a boolean defining if the geometry was removed or not
  2052. */
  2053. removeGeometry(geometry: Geometry): boolean;
  2054. /**
  2055. * Gets the list of geometries attached to the scene
  2056. * @returns an array of Geometry
  2057. */
  2058. getGeometries(): Geometry[];
  2059. /**
  2060. * Gets the first added mesh found of a given ID
  2061. * @param id defines the id to search for
  2062. * @return the mesh found or null if not found at all
  2063. */
  2064. getMeshByID(id: string): Nullable<AbstractMesh>;
  2065. /**
  2066. * Gets a list of meshes using their id
  2067. * @param id defines the id to search for
  2068. * @returns a list of meshes
  2069. */
  2070. getMeshesByID(id: string): Array<AbstractMesh>;
  2071. /**
  2072. * Gets the first added transform node found of a given ID
  2073. * @param id defines the id to search for
  2074. * @return the found transform node or null if not found at all.
  2075. */
  2076. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2077. /**
  2078. * Gets a list of transform nodes using their id
  2079. * @param id defines the id to search for
  2080. * @returns a list of transform nodes
  2081. */
  2082. getTransformNodesByID(id: string): Array<TransformNode>;
  2083. /**
  2084. * Gets a mesh with its auto-generated unique id
  2085. * @param uniqueId defines the unique id to search for
  2086. * @return the found mesh or null if not found at all.
  2087. */
  2088. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2089. /**
  2090. * Gets a the last added mesh using a given id
  2091. * @param id defines the id to search for
  2092. * @return the found mesh or null if not found at all.
  2093. */
  2094. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2095. /**
  2096. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2097. * @param id defines the id to search for
  2098. * @return the found node or null if not found at all
  2099. */
  2100. getLastEntryByID(id: string): Nullable<Node>;
  2101. /**
  2102. * Gets a node (Mesh, Camera, Light) using a given id
  2103. * @param id defines the id to search for
  2104. * @return the found node or null if not found at all
  2105. */
  2106. getNodeByID(id: string): Nullable<Node>;
  2107. /**
  2108. * Gets a node (Mesh, Camera, Light) using a given name
  2109. * @param name defines the name to search for
  2110. * @return the found node or null if not found at all.
  2111. */
  2112. getNodeByName(name: string): Nullable<Node>;
  2113. /**
  2114. * Gets a mesh using a given name
  2115. * @param name defines the name to search for
  2116. * @return the found mesh or null if not found at all.
  2117. */
  2118. getMeshByName(name: string): Nullable<AbstractMesh>;
  2119. /**
  2120. * Gets a transform node using a given name
  2121. * @param name defines the name to search for
  2122. * @return the found transform node or null if not found at all.
  2123. */
  2124. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2125. /**
  2126. * Gets a sound using a given name
  2127. * @param name defines the name to search for
  2128. * @return the found sound or null if not found at all.
  2129. */
  2130. getSoundByName(name: string): Nullable<Sound>;
  2131. /**
  2132. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2133. * @param id defines the id to search for
  2134. * @return the found skeleton or null if not found at all.
  2135. */
  2136. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2137. /**
  2138. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2139. * @param id defines the id to search for
  2140. * @return the found skeleton or null if not found at all.
  2141. */
  2142. getSkeletonById(id: string): Nullable<Skeleton>;
  2143. /**
  2144. * Gets a skeleton using a given name
  2145. * @param name defines the name to search for
  2146. * @return the found skeleton or null if not found at all.
  2147. */
  2148. getSkeletonByName(name: string): Nullable<Skeleton>;
  2149. /**
  2150. * Gets a morph target manager 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 morph target manager or null if not found at all.
  2153. */
  2154. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2155. /**
  2156. * Gets a boolean indicating if the given mesh is active
  2157. * @param mesh defines the mesh to look for
  2158. * @returns true if the mesh is in the active list
  2159. */
  2160. isActiveMesh(mesh: AbstractMesh): boolean;
  2161. /**
  2162. * Return a the first highlight layer of the scene with a given name.
  2163. * @param name The name of the highlight layer to look for.
  2164. * @return The highlight layer if found otherwise null.
  2165. */
  2166. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2167. /**
  2168. * Return a the first highlight layer of the scene with a given name.
  2169. * @param name The name of the highlight layer to look for.
  2170. * @return The highlight layer if found otherwise null.
  2171. */
  2172. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2173. /**
  2174. * Return a unique id as a string which can serve as an identifier for the scene
  2175. */
  2176. readonly uid: string;
  2177. /**
  2178. * Add an externaly attached data from its key.
  2179. * This method call will fail and return false, if such key already exists.
  2180. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2181. * @param key the unique key that identifies the data
  2182. * @param data the data object to associate to the key for this Engine instance
  2183. * @return true if no such key were already present and the data was added successfully, false otherwise
  2184. */
  2185. addExternalData<T>(key: string, data: T): boolean;
  2186. /**
  2187. * Get an externaly attached data from its key
  2188. * @param key the unique key that identifies the data
  2189. * @return the associated data, if present (can be null), or undefined if not present
  2190. */
  2191. getExternalData<T>(key: string): Nullable<T>;
  2192. /**
  2193. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2194. * @param key the unique key that identifies the data
  2195. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2196. * @return the associated data, can be null if the factory returned null.
  2197. */
  2198. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2199. /**
  2200. * Remove an externaly attached data from the Engine instance
  2201. * @param key the unique key that identifies the data
  2202. * @return true if the data was successfully removed, false if it doesn't exist
  2203. */
  2204. removeExternalData(key: string): boolean;
  2205. private _evaluateSubMesh(subMesh, mesh);
  2206. /**
  2207. * Clear the processed materials smart array preventing retention point in material dispose.
  2208. */
  2209. freeProcessedMaterials(): void;
  2210. /**
  2211. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2212. */
  2213. freeActiveMeshes(): void;
  2214. /**
  2215. * Clear the info related to rendering groups preventing retention points during dispose.
  2216. */
  2217. freeRenderingGroups(): void;
  2218. /** @ignore */
  2219. _isInIntermediateRendering(): boolean;
  2220. private _activeMeshCandidateProvider;
  2221. /**
  2222. * Defines the current active mesh candidate provider
  2223. * @param provider defines the provider to use
  2224. */
  2225. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2226. /**
  2227. * Gets the current active mesh candidate provider
  2228. * @returns the current active mesh candidate provider
  2229. */
  2230. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2231. private _activeMeshesFrozen;
  2232. /**
  2233. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2234. * @returns the current scene
  2235. */
  2236. freezeActiveMeshes(): Scene;
  2237. /**
  2238. * Use this function to restart evaluating active meshes on every frame
  2239. * @returns the current scene
  2240. */
  2241. unfreezeActiveMeshes(): Scene;
  2242. private _evaluateActiveMeshes();
  2243. private _activeMesh(sourceMesh, mesh);
  2244. /**
  2245. * Update the transform matrix to update from the current active camera
  2246. * @param force defines a boolean used to force the update even if cache is up to date
  2247. */
  2248. updateTransformMatrix(force?: boolean): void;
  2249. /**
  2250. * 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)
  2251. * @param alternateCamera defines the camera to use
  2252. */
  2253. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2254. private _renderForCamera(camera, rigParent?);
  2255. private _processSubCameras(camera);
  2256. private _checkIntersections();
  2257. /**
  2258. * Render the scene
  2259. */
  2260. render(): void;
  2261. private _updateAudioParameters();
  2262. /**
  2263. * Gets or sets if audio support is enabled
  2264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2265. */
  2266. audioEnabled: boolean;
  2267. private _disableAudio();
  2268. private _enableAudio();
  2269. /**
  2270. * Gets or sets if audio will be output to headphones
  2271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2272. */
  2273. headphone: boolean;
  2274. private _switchAudioModeForHeadphones();
  2275. private _switchAudioModeForNormalSpeakers();
  2276. /**
  2277. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2278. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2279. * @returns the created depth renderer
  2280. */
  2281. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2282. /**
  2283. * Disables a depth renderer for a given camera
  2284. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2285. */
  2286. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2287. /**
  2288. * Enables a GeometryBufferRender and associates it with the scene
  2289. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2290. * @returns the GeometryBufferRenderer
  2291. */
  2292. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2293. /**
  2294. * Disables the GeometryBufferRender associated with the scene
  2295. */
  2296. disableGeometryBufferRenderer(): void;
  2297. /**
  2298. * Freeze all materials
  2299. * A frozen material will not be updatable but should be faster to render
  2300. */
  2301. freezeMaterials(): void;
  2302. /**
  2303. * Unfreeze all materials
  2304. * A frozen material will not be updatable but should be faster to render
  2305. */
  2306. unfreezeMaterials(): void;
  2307. /**
  2308. * Releases all held ressources
  2309. */
  2310. dispose(): void;
  2311. /**
  2312. * Gets if the scene is already disposed
  2313. */
  2314. readonly isDisposed: boolean;
  2315. /**
  2316. * Releases sounds & soundtracks
  2317. */
  2318. disposeSounds(): void;
  2319. /**
  2320. * Get the world extend vectors with an optional filter
  2321. *
  2322. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2323. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2324. */
  2325. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2326. min: Vector3;
  2327. max: Vector3;
  2328. };
  2329. /**
  2330. * Creates or updates the octree used to boost selection (picking)
  2331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2332. * @param maxCapacity defines the maximum capacity per leaf
  2333. * @param maxDepth defines the maximum depth of the octree
  2334. * @returns an octree of AbstractMesh
  2335. */
  2336. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2337. /**
  2338. * Creates a ray that can be used to pick in the scene
  2339. * @param x defines the x coordinate of the origin (on-screen)
  2340. * @param y defines the y coordinate of the origin (on-screen)
  2341. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2342. * @param camera defines the camera to use for the picking
  2343. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2344. * @returns a Ray
  2345. */
  2346. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2347. /**
  2348. * Creates a ray that can be used to pick in the scene
  2349. * @param x defines the x coordinate of the origin (on-screen)
  2350. * @param y defines the y coordinate of the origin (on-screen)
  2351. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2352. * @param result defines the ray where to store the picking ray
  2353. * @param camera defines the camera to use for the picking
  2354. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2355. * @returns the current scene
  2356. */
  2357. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2358. /**
  2359. * Creates a ray that can be used to pick in the scene
  2360. * @param x defines the x coordinate of the origin (on-screen)
  2361. * @param y defines the y coordinate of the origin (on-screen)
  2362. * @param camera defines the camera to use for the picking
  2363. * @returns a Ray
  2364. */
  2365. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2366. /**
  2367. * Creates a ray that can be used to pick in the scene
  2368. * @param x defines the x coordinate of the origin (on-screen)
  2369. * @param y defines the y coordinate of the origin (on-screen)
  2370. * @param result defines the ray where to store the picking ray
  2371. * @param camera defines the camera to use for the picking
  2372. * @returns the current scene
  2373. */
  2374. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2375. private _internalPick(rayFunction, predicate?, fastCheck?);
  2376. private _internalMultiPick(rayFunction, predicate?);
  2377. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2378. private _tempPickingRay;
  2379. /** Launch a ray to try to pick a mesh in the scene
  2380. * @param x position on screen
  2381. * @param y position on screen
  2382. * @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
  2383. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2384. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2385. * @returns a PickingInfo
  2386. */
  2387. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2388. /** Launch a ray to try to pick a sprite in the scene
  2389. * @param x position on screen
  2390. * @param y position on screen
  2391. * @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
  2392. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2393. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2394. * @returns a PickingInfo
  2395. */
  2396. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2397. private _cachedRayForTransform;
  2398. /** Use the given ray to pick a mesh in the scene
  2399. * @param ray The ray to use to pick meshes
  2400. * @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
  2401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2402. * @returns a PickingInfo
  2403. */
  2404. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2405. /**
  2406. * Launch a ray to try to pick a mesh in the scene
  2407. * @param x X position on screen
  2408. * @param y Y position on screen
  2409. * @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
  2410. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2411. * @returns an array of PickingInfo
  2412. */
  2413. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2414. /**
  2415. * Launch a ray to try to pick a mesh in the scene
  2416. * @param ray Ray to use
  2417. * @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
  2418. * @returns an array of PickingInfo
  2419. */
  2420. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2421. /**
  2422. * Force the value of meshUnderPointer
  2423. * @param mesh defines the mesh to use
  2424. */
  2425. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2426. /**
  2427. * Gets the mesh under the pointer
  2428. * @returns a Mesh or null if no mesh is under the pointer
  2429. */
  2430. getPointerOverMesh(): Nullable<AbstractMesh>;
  2431. /**
  2432. * Force the sprite under the pointer
  2433. * @param sprite defines the sprite to use
  2434. */
  2435. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2436. /**
  2437. * Gets the sprite under the pointer
  2438. * @returns a Sprite or null if no sprite is under the pointer
  2439. */
  2440. getPointerOverSprite(): Nullable<Sprite>;
  2441. /**
  2442. * Gets the current physics engine
  2443. * @returns a PhysicsEngine or null if none attached
  2444. */
  2445. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2446. /**
  2447. * Enables physics to the current scene
  2448. * @param gravity defines the scene's gravity for the physics engine
  2449. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2450. * @return a boolean indicating if the physics engine was initialized
  2451. */
  2452. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2453. /**
  2454. * Disables and disposes the physics engine associated with the scene
  2455. */
  2456. disablePhysicsEngine(): void;
  2457. /**
  2458. * Gets a boolean indicating if there is an active physics engine
  2459. * @returns a boolean indicating if there is an active physics engine
  2460. */
  2461. isPhysicsEnabled(): boolean;
  2462. /**
  2463. * Deletes a physics compound impostor
  2464. * @param compound defines the compound to delete
  2465. */
  2466. deleteCompoundImpostor(compound: any): void;
  2467. /** @ignore */
  2468. _rebuildGeometries(): void;
  2469. /** @ignore */
  2470. _rebuildTextures(): void;
  2471. /**
  2472. * Creates a default light for the scene.
  2473. * @param replace Whether to replace the existing lights in the scene.
  2474. */
  2475. createDefaultLight(replace?: boolean): void;
  2476. /**
  2477. * Creates a default camera for the scene.
  2478. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2479. * @param replace Whether to replace the existing active camera in the scene.
  2480. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2481. */
  2482. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2483. /**
  2484. * Creates a default camera and a default light
  2485. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2486. * @param replace defines if the camera and/or light will replace the existing ones
  2487. * @param attachCameraControls defines if attachControl will be called on the new camera
  2488. */
  2489. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2490. /**
  2491. * Creates a new sky box
  2492. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2493. * @param environmentTexture defines the texture to use as environment texture
  2494. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2495. * @param scale defines the overall scale of the skybox
  2496. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2497. * @returns a new mesh holding the sky box
  2498. */
  2499. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  2500. /**
  2501. * Creates a new environment
  2502. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2503. * @param options defines the options you can use to configure the environment
  2504. * @returns the new EnvironmentHelper
  2505. */
  2506. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2507. /**
  2508. * Creates a new VREXperienceHelper
  2509. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2510. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2511. * @returns a new VREXperienceHelper
  2512. */
  2513. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2514. private _getByTags(list, tagsQuery, forEach?);
  2515. /**
  2516. * Get a list of meshes by tags
  2517. * @param tagsQuery defines the tags query to use
  2518. * @param forEach defines a predicate used to filter results
  2519. * @returns an array of Mesh
  2520. */
  2521. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2522. /**
  2523. * Get a list of cameras by tags
  2524. * @param tagsQuery defines the tags query to use
  2525. * @param forEach defines a predicate used to filter results
  2526. * @returns an array of Camera
  2527. */
  2528. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2529. /**
  2530. * Get a list of lights by tags
  2531. * @param tagsQuery defines the tags query to use
  2532. * @param forEach defines a predicate used to filter results
  2533. * @returns an array of Light
  2534. */
  2535. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2536. /**
  2537. * Get a list of materials by tags
  2538. * @param tagsQuery defines the tags query to use
  2539. * @param forEach defines a predicate used to filter results
  2540. * @returns an array of Material
  2541. */
  2542. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2543. /**
  2544. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2545. * This allowed control for front to back rendering or reversly depending of the special needs.
  2546. *
  2547. * @param renderingGroupId The rendering group id corresponding to its index
  2548. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2549. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2550. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2551. */
  2552. 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;
  2553. /**
  2554. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2555. *
  2556. * @param renderingGroupId The rendering group id corresponding to its index
  2557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2558. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2559. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2560. */
  2561. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2562. /**
  2563. * Will flag all materials as dirty to trigger new shader compilation
  2564. * @param flag defines the flag used to specify which material part must be marked as dirty
  2565. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2566. */
  2567. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2568. /** @ignore */
  2569. _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;
  2570. /** @ignore */
  2571. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2572. }
  2573. }
  2574. declare module BABYLON {
  2575. type Nullable<T> = T | null;
  2576. type float = number;
  2577. type double = number;
  2578. type int = number;
  2579. type FloatArray = number[] | Float32Array;
  2580. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2581. /**
  2582. * Alias for types that can be used by a Buffer or VertexBuffer.
  2583. */
  2584. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2585. }
  2586. declare module BABYLON {
  2587. /**
  2588. * The action to be carried out following a trigger
  2589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2590. */
  2591. class Action {
  2592. triggerOptions: any;
  2593. /**
  2594. * Trigger for the action
  2595. */
  2596. trigger: number;
  2597. /**
  2598. * Internal only - manager for action
  2599. * @ignore
  2600. */
  2601. _actionManager: ActionManager;
  2602. private _nextActiveAction;
  2603. private _child;
  2604. private _condition?;
  2605. private _triggerParameter;
  2606. /**
  2607. * An event triggered prior to action being executed.
  2608. */
  2609. onBeforeExecuteObservable: Observable<Action>;
  2610. /**
  2611. * Creates a new Action
  2612. * @param triggerOptions the trigger, with or without parameters, for the action
  2613. * @param condition an optional determinant of action
  2614. */
  2615. constructor(triggerOptions: any, condition?: Condition);
  2616. /**
  2617. * Internal only
  2618. * @ignore
  2619. */
  2620. _prepare(): void;
  2621. /**
  2622. * Gets the trigger parameters
  2623. * @returns the trigger parameters
  2624. */
  2625. getTriggerParameter(): any;
  2626. /**
  2627. * Internal only - executes current action event
  2628. * @ignore
  2629. */
  2630. _executeCurrent(evt?: ActionEvent): void;
  2631. /**
  2632. * Execute placeholder for child classes
  2633. * @param evt optional action event
  2634. */
  2635. execute(evt?: ActionEvent): void;
  2636. /**
  2637. * Skips to next active action
  2638. */
  2639. skipToNextActiveAction(): void;
  2640. /**
  2641. * Adds action to chain of actions, may be a DoNothingAction
  2642. * @param index The index of the attribute.
  2643. * @returns The action passed in
  2644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2645. */
  2646. then(action: Action): Action;
  2647. /**
  2648. * Internal only
  2649. * @ignore
  2650. */
  2651. _getProperty(propertyPath: string): string;
  2652. /**
  2653. * Internal only
  2654. * @ignore
  2655. */
  2656. _getEffectiveTarget(target: any, propertyPath: string): any;
  2657. /**
  2658. * Serialize placeholder for child classes
  2659. * @param parent of child
  2660. * @returns the serialized object
  2661. */
  2662. serialize(parent: any): any;
  2663. /**
  2664. * Internal only called by serialize
  2665. * @ignore
  2666. */
  2667. protected _serialize(serializedAction: any, parent?: any): any;
  2668. /**
  2669. * Internal only
  2670. * @ignore
  2671. */
  2672. static _SerializeValueAsString: (value: any) => string;
  2673. /**
  2674. * Internal only
  2675. * @ignore
  2676. */
  2677. static _GetTargetProperty: (target: Scene | Node) => {
  2678. name: string;
  2679. targetType: string;
  2680. value: string;
  2681. };
  2682. }
  2683. }
  2684. declare module BABYLON {
  2685. /**
  2686. * ActionEvent is the event being sent when an action is triggered.
  2687. */
  2688. class ActionEvent {
  2689. source: any;
  2690. pointerX: number;
  2691. pointerY: number;
  2692. meshUnderPointer: Nullable<AbstractMesh>;
  2693. sourceEvent: any;
  2694. additionalData: any;
  2695. /**
  2696. * @param source The mesh or sprite that triggered the action.
  2697. * @param pointerX The X mouse cursor position at the time of the event
  2698. * @param pointerY The Y mouse cursor position at the time of the event
  2699. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2700. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2701. */
  2702. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  2703. /**
  2704. * Helper function to auto-create an ActionEvent from a source mesh.
  2705. * @param source The source mesh that triggered the event
  2706. * @param evt {Event} The original (browser) event
  2707. */
  2708. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2709. /**
  2710. * Helper function to auto-create an ActionEvent from a source mesh.
  2711. * @param source The source sprite that triggered the event
  2712. * @param scene Scene associated with the sprite
  2713. * @param evt {Event} The original (browser) event
  2714. */
  2715. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2716. /**
  2717. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2718. * @param scene the scene where the event occurred
  2719. * @param evt {Event} The original (browser) event
  2720. */
  2721. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2722. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2723. }
  2724. /**
  2725. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2726. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2727. */
  2728. class ActionManager {
  2729. private static _NothingTrigger;
  2730. private static _OnPickTrigger;
  2731. private static _OnLeftPickTrigger;
  2732. private static _OnRightPickTrigger;
  2733. private static _OnCenterPickTrigger;
  2734. private static _OnPickDownTrigger;
  2735. private static _OnDoublePickTrigger;
  2736. private static _OnPickUpTrigger;
  2737. private static _OnLongPressTrigger;
  2738. private static _OnPointerOverTrigger;
  2739. private static _OnPointerOutTrigger;
  2740. private static _OnEveryFrameTrigger;
  2741. private static _OnIntersectionEnterTrigger;
  2742. private static _OnIntersectionExitTrigger;
  2743. private static _OnKeyDownTrigger;
  2744. private static _OnKeyUpTrigger;
  2745. private static _OnPickOutTrigger;
  2746. static readonly NothingTrigger: number;
  2747. static readonly OnPickTrigger: number;
  2748. static readonly OnLeftPickTrigger: number;
  2749. static readonly OnRightPickTrigger: number;
  2750. static readonly OnCenterPickTrigger: number;
  2751. static readonly OnPickDownTrigger: number;
  2752. static readonly OnDoublePickTrigger: number;
  2753. static readonly OnPickUpTrigger: number;
  2754. static readonly OnPickOutTrigger: number;
  2755. static readonly OnLongPressTrigger: number;
  2756. static readonly OnPointerOverTrigger: number;
  2757. static readonly OnPointerOutTrigger: number;
  2758. static readonly OnEveryFrameTrigger: number;
  2759. static readonly OnIntersectionEnterTrigger: number;
  2760. static readonly OnIntersectionExitTrigger: number;
  2761. static readonly OnKeyDownTrigger: number;
  2762. static readonly OnKeyUpTrigger: number;
  2763. static Triggers: {
  2764. [key: string]: number;
  2765. };
  2766. actions: Action[];
  2767. hoverCursor: string;
  2768. private _scene;
  2769. constructor(scene: Scene);
  2770. dispose(): void;
  2771. getScene(): Scene;
  2772. /**
  2773. * Does this action manager handles actions of any of the given triggers
  2774. * @param {number[]} triggers - the triggers to be tested
  2775. * @return {boolean} whether one (or more) of the triggers is handeled
  2776. */
  2777. hasSpecificTriggers(triggers: number[]): boolean;
  2778. /**
  2779. * Does this action manager handles actions of a given trigger
  2780. * @param {number} trigger - the trigger to be tested
  2781. * @return {boolean} whether the trigger is handeled
  2782. */
  2783. hasSpecificTrigger(trigger: number): boolean;
  2784. /**
  2785. * Does this action manager has pointer triggers
  2786. * @return {boolean} whether or not it has pointer triggers
  2787. */
  2788. readonly hasPointerTriggers: boolean;
  2789. /**
  2790. * Does this action manager has pick triggers
  2791. * @return {boolean} whether or not it has pick triggers
  2792. */
  2793. readonly hasPickTriggers: boolean;
  2794. /**
  2795. * Does exist one action manager with at least one trigger
  2796. * @return {boolean} whether or not it exists one action manager with one trigger
  2797. **/
  2798. static readonly HasTriggers: boolean;
  2799. /**
  2800. * Does exist one action manager with at least one pick trigger
  2801. * @return {boolean} whether or not it exists one action manager with one pick trigger
  2802. **/
  2803. static readonly HasPickTriggers: boolean;
  2804. /**
  2805. * Does exist one action manager that handles actions of a given trigger
  2806. * @param {number} trigger - the trigger to be tested
  2807. * @return {boolean} whether the trigger is handeled by at least one action manager
  2808. **/
  2809. static HasSpecificTrigger(trigger: number): boolean;
  2810. /**
  2811. * Registers an action to this action manager
  2812. * @param {BABYLON.Action} action - the action to be registered
  2813. * @return {BABYLON.Action} the action amended (prepared) after registration
  2814. */
  2815. registerAction(action: Action): Nullable<Action>;
  2816. /**
  2817. * Unregisters an action to this action manager
  2818. * @param action The action to be unregistered
  2819. * @return whether the action has been unregistered
  2820. */
  2821. unregisterAction(action: Action): Boolean;
  2822. /**
  2823. * Process a specific trigger
  2824. * @param {number} trigger - the trigger to process
  2825. * @param evt {BABYLON.ActionEvent} the event details to be processed
  2826. */
  2827. processTrigger(trigger: number, evt?: ActionEvent): void;
  2828. _getEffectiveTarget(target: any, propertyPath: string): any;
  2829. _getProperty(propertyPath: string): string;
  2830. serialize(name: string): any;
  2831. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2832. static GetTriggerName(trigger: number): string;
  2833. }
  2834. }
  2835. declare module BABYLON {
  2836. /**
  2837. * A Condition applied to an Action
  2838. */
  2839. class Condition {
  2840. /**
  2841. * Internal only - manager for action
  2842. * @ignore
  2843. */
  2844. _actionManager: ActionManager;
  2845. /**
  2846. * Internal only
  2847. * @ignore
  2848. */
  2849. _evaluationId: number;
  2850. /**
  2851. * Internal only
  2852. * @ignore
  2853. */
  2854. _currentResult: boolean;
  2855. /**
  2856. * Creates a new Condition
  2857. * @param actionManager the manager of the action the condition is applied to
  2858. */
  2859. constructor(actionManager: ActionManager);
  2860. /**
  2861. * Check if the current condition is valid
  2862. * @returns a boolean
  2863. */
  2864. isValid(): boolean;
  2865. /**
  2866. * Internal only
  2867. * @ignore
  2868. */
  2869. _getProperty(propertyPath: string): string;
  2870. /**
  2871. * Internal only
  2872. * @ignore
  2873. */
  2874. _getEffectiveTarget(target: any, propertyPath: string): any;
  2875. /**
  2876. * Serialize placeholder for child classes
  2877. * @returns the serialized object
  2878. */
  2879. serialize(): any;
  2880. /**
  2881. * Internal only
  2882. * @ignore
  2883. */
  2884. protected _serialize(serializedCondition: any): any;
  2885. }
  2886. /**
  2887. * Defines specific conditional operators as extensions of Condition
  2888. */
  2889. class ValueCondition extends Condition {
  2890. propertyPath: string;
  2891. value: any;
  2892. operator: number;
  2893. /**
  2894. * Internal only
  2895. * @ignore
  2896. */
  2897. private static _IsEqual;
  2898. /**
  2899. * Internal only
  2900. * @ignore
  2901. */
  2902. private static _IsDifferent;
  2903. /**
  2904. * Internal only
  2905. * @ignore
  2906. */
  2907. private static _IsGreater;
  2908. /**
  2909. * Internal only
  2910. * @ignore
  2911. */
  2912. private static _IsLesser;
  2913. /**
  2914. * returns the number for IsEqual
  2915. */
  2916. static readonly IsEqual: number;
  2917. /**
  2918. * Returns the number for IsDifferent
  2919. */
  2920. static readonly IsDifferent: number;
  2921. /**
  2922. * Returns the number for IsGreater
  2923. */
  2924. static readonly IsGreater: number;
  2925. /**
  2926. * Returns the number for IsLesser
  2927. */
  2928. static readonly IsLesser: number;
  2929. /**
  2930. * Internal only The action manager for the condition
  2931. * @ignore
  2932. */
  2933. _actionManager: ActionManager;
  2934. /**
  2935. * Internal only
  2936. * @ignore
  2937. */
  2938. private _target;
  2939. /**
  2940. * Internal only
  2941. * @ignore
  2942. */
  2943. private _effectiveTarget;
  2944. /**
  2945. * Internal only
  2946. * @ignore
  2947. */
  2948. private _property;
  2949. /**
  2950. * Creates a new ValueCondition
  2951. * @param actionManager manager for the action the condition applies to
  2952. * @param target for the action
  2953. * @param propertyPath path to specify the property of the target the conditional operator uses
  2954. * @param value the vale compared by the conditional operator against the current value of the property
  2955. * @param operator the conditional operator, default {BABYLON.ValueCondition.IsEqual}
  2956. */
  2957. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  2958. /**
  2959. * Compares the given value with the property value for the specified conditional operator
  2960. * @returns the result of the comparison
  2961. */
  2962. isValid(): boolean;
  2963. /**
  2964. * Serialize the ValueCondition into a JSON compatible object
  2965. * @returns serialization object
  2966. */
  2967. serialize(): any;
  2968. /**
  2969. * Gets the name of the conditional operator for the ValueCondition
  2970. * @param operator the conditional operator
  2971. * @returns the name
  2972. */
  2973. static GetOperatorName(operator: number): string;
  2974. }
  2975. /**
  2976. * Defines a predicate condition as an extension of Condition
  2977. */
  2978. class PredicateCondition extends Condition {
  2979. predicate: () => boolean;
  2980. /**
  2981. * Internal only - manager for action
  2982. * @ignore
  2983. */
  2984. _actionManager: ActionManager;
  2985. /**
  2986. * Creates a new {BABYLON.PredicateCondition}
  2987. * @param actionManager manager for the action the condition applies to
  2988. * @param predicate
  2989. */
  2990. constructor(actionManager: ActionManager, predicate: () => boolean);
  2991. /**
  2992. * @returns the validity of the predicate condition
  2993. */
  2994. isValid(): boolean;
  2995. }
  2996. /**
  2997. * Defines a state condition as an extension of {BABYLON.Condition}
  2998. */
  2999. class StateCondition extends Condition {
  3000. value: string;
  3001. /**
  3002. * Internal only - manager for action
  3003. * @ignore
  3004. */
  3005. _actionManager: ActionManager;
  3006. /**
  3007. * Internal only
  3008. * @ignore
  3009. */
  3010. private _target;
  3011. /**
  3012. * Creates a new {BABYLON.StateCondition}
  3013. * @param actionManager manager for the action the condition applies to
  3014. * @param target of the condition
  3015. * @param value to compare with target state
  3016. */
  3017. constructor(actionManager: ActionManager, target: any, value: string);
  3018. /**
  3019. * @returns the validity of the state
  3020. */
  3021. isValid(): boolean;
  3022. /**
  3023. * Serialize the {BABYLON.StateCondition} into a JSON compatible object
  3024. * @returns serialization object
  3025. */
  3026. serialize(): any;
  3027. }
  3028. }
  3029. declare module BABYLON {
  3030. class SwitchBooleanAction extends Action {
  3031. propertyPath: string;
  3032. private _target;
  3033. private _effectiveTarget;
  3034. private _property;
  3035. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3036. _prepare(): void;
  3037. execute(): void;
  3038. serialize(parent: any): any;
  3039. }
  3040. class SetStateAction extends Action {
  3041. value: string;
  3042. private _target;
  3043. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3044. execute(): void;
  3045. serialize(parent: any): any;
  3046. }
  3047. class SetValueAction extends Action {
  3048. propertyPath: string;
  3049. value: any;
  3050. private _target;
  3051. private _effectiveTarget;
  3052. private _property;
  3053. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3054. _prepare(): void;
  3055. execute(): void;
  3056. serialize(parent: any): any;
  3057. }
  3058. class IncrementValueAction extends Action {
  3059. propertyPath: string;
  3060. value: any;
  3061. private _target;
  3062. private _effectiveTarget;
  3063. private _property;
  3064. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3065. _prepare(): void;
  3066. execute(): void;
  3067. serialize(parent: any): any;
  3068. }
  3069. class PlayAnimationAction extends Action {
  3070. from: number;
  3071. to: number;
  3072. loop: boolean | undefined;
  3073. private _target;
  3074. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3075. _prepare(): void;
  3076. execute(): void;
  3077. serialize(parent: any): any;
  3078. }
  3079. class StopAnimationAction extends Action {
  3080. private _target;
  3081. constructor(triggerOptions: any, target: any, condition?: Condition);
  3082. _prepare(): void;
  3083. execute(): void;
  3084. serialize(parent: any): any;
  3085. }
  3086. class DoNothingAction extends Action {
  3087. constructor(triggerOptions?: any, condition?: Condition);
  3088. execute(): void;
  3089. serialize(parent: any): any;
  3090. }
  3091. class CombineAction extends Action {
  3092. children: Action[];
  3093. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3094. _prepare(): void;
  3095. execute(evt: ActionEvent): void;
  3096. serialize(parent: any): any;
  3097. }
  3098. class ExecuteCodeAction extends Action {
  3099. func: (evt: ActionEvent) => void;
  3100. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3101. execute(evt: ActionEvent): void;
  3102. }
  3103. class SetParentAction extends Action {
  3104. private _parent;
  3105. private _target;
  3106. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3107. _prepare(): void;
  3108. execute(): void;
  3109. serialize(parent: any): any;
  3110. }
  3111. class PlaySoundAction extends Action {
  3112. private _sound;
  3113. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3114. _prepare(): void;
  3115. execute(): void;
  3116. serialize(parent: any): any;
  3117. }
  3118. class StopSoundAction extends Action {
  3119. private _sound;
  3120. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3121. _prepare(): void;
  3122. execute(): void;
  3123. serialize(parent: any): any;
  3124. }
  3125. }
  3126. declare module BABYLON {
  3127. class InterpolateValueAction extends Action {
  3128. propertyPath: string;
  3129. value: any;
  3130. duration: number;
  3131. stopOtherAnimations: boolean | undefined;
  3132. onInterpolationDone: (() => void) | undefined;
  3133. private _target;
  3134. private _effectiveTarget;
  3135. private _property;
  3136. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3137. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3138. _prepare(): void;
  3139. execute(): void;
  3140. serialize(parent: any): any;
  3141. }
  3142. }
  3143. declare module BABYLON {
  3144. class Analyser {
  3145. SMOOTHING: number;
  3146. FFT_SIZE: number;
  3147. BARGRAPHAMPLITUDE: number;
  3148. DEBUGCANVASPOS: {
  3149. x: number;
  3150. y: number;
  3151. };
  3152. DEBUGCANVASSIZE: {
  3153. width: number;
  3154. height: number;
  3155. };
  3156. private _byteFreqs;
  3157. private _byteTime;
  3158. private _floatFreqs;
  3159. private _webAudioAnalyser;
  3160. private _debugCanvas;
  3161. private _debugCanvasContext;
  3162. private _scene;
  3163. private _registerFunc;
  3164. private _audioEngine;
  3165. constructor(scene: Scene);
  3166. getFrequencyBinCount(): number;
  3167. getByteFrequencyData(): Uint8Array;
  3168. getByteTimeDomainData(): Uint8Array;
  3169. getFloatFrequencyData(): Uint8Array;
  3170. drawDebugCanvas(): void;
  3171. stopDebugCanvas(): void;
  3172. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3173. dispose(): void;
  3174. }
  3175. }
  3176. declare module BABYLON {
  3177. class AudioEngine {
  3178. private _audioContext;
  3179. private _audioContextInitialized;
  3180. canUseWebAudio: boolean;
  3181. masterGain: GainNode;
  3182. private _connectedAnalyser;
  3183. WarnedWebAudioUnsupported: boolean;
  3184. unlocked: boolean;
  3185. onAudioUnlocked: () => any;
  3186. isMP3supported: boolean;
  3187. isOGGsupported: boolean;
  3188. readonly audioContext: Nullable<AudioContext>;
  3189. constructor();
  3190. private _unlockiOSaudio();
  3191. private _initializeAudioContext();
  3192. dispose(): void;
  3193. getGlobalVolume(): number;
  3194. setGlobalVolume(newVolume: number): void;
  3195. connectToAnalyser(analyser: Analyser): void;
  3196. }
  3197. }
  3198. declare module BABYLON {
  3199. class Sound {
  3200. name: string;
  3201. autoplay: boolean;
  3202. loop: boolean;
  3203. useCustomAttenuation: boolean;
  3204. soundTrackId: number;
  3205. spatialSound: boolean;
  3206. refDistance: number;
  3207. rolloffFactor: number;
  3208. maxDistance: number;
  3209. distanceModel: string;
  3210. private _panningModel;
  3211. onended: () => any;
  3212. private _playbackRate;
  3213. private _streaming;
  3214. private _startTime;
  3215. private _startOffset;
  3216. private _position;
  3217. private _localDirection;
  3218. private _volume;
  3219. private _isReadyToPlay;
  3220. isPlaying: boolean;
  3221. isPaused: boolean;
  3222. private _isDirectional;
  3223. private _readyToPlayCallback;
  3224. private _audioBuffer;
  3225. private _soundSource;
  3226. private _streamingSource;
  3227. private _soundPanner;
  3228. private _soundGain;
  3229. private _inputAudioNode;
  3230. private _ouputAudioNode;
  3231. private _coneInnerAngle;
  3232. private _coneOuterAngle;
  3233. private _coneOuterGain;
  3234. private _scene;
  3235. private _connectedMesh;
  3236. private _customAttenuationFunction;
  3237. private _registerFunc;
  3238. private _isOutputConnected;
  3239. private _htmlAudioElement;
  3240. private _urlType;
  3241. /**
  3242. * Create a sound and attach it to a scene
  3243. * @param name Name of your sound
  3244. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3245. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3246. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3247. */
  3248. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3249. dispose(): void;
  3250. isReady(): boolean;
  3251. private _soundLoaded(audioData);
  3252. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3253. updateOptions(options: any): void;
  3254. private _createSpatialParameters();
  3255. private _updateSpatialParameters();
  3256. switchPanningModelToHRTF(): void;
  3257. switchPanningModelToEqualPower(): void;
  3258. private _switchPanningModel();
  3259. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3260. /**
  3261. * Transform this sound into a directional source
  3262. * @param coneInnerAngle Size of the inner cone in degree
  3263. * @param coneOuterAngle Size of the outer cone in degree
  3264. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3265. */
  3266. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3267. setPosition(newPosition: Vector3): void;
  3268. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3269. private _updateDirection();
  3270. updateDistanceFromListener(): void;
  3271. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3272. /**
  3273. * Play the sound
  3274. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3275. * @param offset (optional) Start the sound setting it at a specific time
  3276. */
  3277. play(time?: number, offset?: number): void;
  3278. private _onended();
  3279. /**
  3280. * Stop the sound
  3281. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3282. */
  3283. stop(time?: number): void;
  3284. pause(): void;
  3285. setVolume(newVolume: number, time?: number): void;
  3286. setPlaybackRate(newPlaybackRate: number): void;
  3287. getVolume(): number;
  3288. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3289. detachFromMesh(): void;
  3290. private _onRegisterAfterWorldMatrixUpdate(node);
  3291. clone(): Nullable<Sound>;
  3292. getAudioBuffer(): AudioBuffer | null;
  3293. serialize(): any;
  3294. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3295. }
  3296. }
  3297. declare module BABYLON {
  3298. class SoundTrack {
  3299. private _outputAudioNode;
  3300. private _scene;
  3301. id: number;
  3302. soundCollection: Array<Sound>;
  3303. private _isMainTrack;
  3304. private _connectedAnalyser;
  3305. private _options;
  3306. private _isInitialized;
  3307. constructor(scene: Scene, options?: any);
  3308. private _initializeSoundTrackAudioGraph();
  3309. dispose(): void;
  3310. AddSound(sound: Sound): void;
  3311. RemoveSound(sound: Sound): void;
  3312. setVolume(newVolume: number): void;
  3313. switchPanningModelToHRTF(): void;
  3314. switchPanningModelToEqualPower(): void;
  3315. connectToAnalyser(analyser: Analyser): void;
  3316. }
  3317. }
  3318. declare module BABYLON {
  3319. class Animatable {
  3320. target: any;
  3321. fromFrame: number;
  3322. toFrame: number;
  3323. loopAnimation: boolean;
  3324. onAnimationEnd: (() => void) | null | undefined;
  3325. private _localDelayOffset;
  3326. private _pausedDelay;
  3327. private _runtimeAnimations;
  3328. private _paused;
  3329. private _scene;
  3330. private _speedRatio;
  3331. private _weight;
  3332. private _syncRoot;
  3333. animationStarted: boolean;
  3334. /**
  3335. * Gets the root Animatable used to synchronize and normalize animations
  3336. */
  3337. readonly syncRoot: Animatable;
  3338. /**
  3339. * Gets the current frame of the first RuntimeAnimation
  3340. * Used to synchronize Animatables
  3341. */
  3342. readonly masterFrame: number;
  3343. /**
  3344. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3345. */
  3346. weight: number;
  3347. /**
  3348. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3349. */
  3350. speedRatio: number;
  3351. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3352. /**
  3353. * Synchronize and normalize current Animatable with a source Animatable.
  3354. * This is useful when using animation weights and when animations are not of the same length
  3355. * @param root defines the root Animatable to synchronize with
  3356. * @returns the current Animatable
  3357. */
  3358. syncWith(root: Animatable): Animatable;
  3359. getAnimations(): RuntimeAnimation[];
  3360. appendAnimations(target: any, animations: Animation[]): void;
  3361. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3362. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3363. reset(): void;
  3364. enableBlending(blendingSpeed: number): void;
  3365. disableBlending(): void;
  3366. goToFrame(frame: number): void;
  3367. pause(): void;
  3368. restart(): void;
  3369. stop(animationName?: string): void;
  3370. _animate(delay: number): boolean;
  3371. }
  3372. }
  3373. declare module BABYLON {
  3374. class AnimationRange {
  3375. name: string;
  3376. from: number;
  3377. to: number;
  3378. constructor(name: string, from: number, to: number);
  3379. clone(): AnimationRange;
  3380. }
  3381. /**
  3382. * Composed of a frame, and an action function
  3383. */
  3384. class AnimationEvent {
  3385. frame: number;
  3386. action: () => void;
  3387. onlyOnce: boolean | undefined;
  3388. isDone: boolean;
  3389. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  3390. }
  3391. class PathCursor {
  3392. private path;
  3393. private _onchange;
  3394. value: number;
  3395. animations: Animation[];
  3396. constructor(path: Path2);
  3397. getPoint(): Vector3;
  3398. moveAhead(step?: number): PathCursor;
  3399. moveBack(step?: number): PathCursor;
  3400. move(step: number): PathCursor;
  3401. private ensureLimits();
  3402. private raiseOnChange();
  3403. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3404. }
  3405. interface IAnimationKey {
  3406. frame: number;
  3407. value: any;
  3408. inTangent?: any;
  3409. outTangent?: any;
  3410. interpolation?: AnimationKeyInterpolation;
  3411. }
  3412. enum AnimationKeyInterpolation {
  3413. /**
  3414. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  3415. */
  3416. STEP = 1,
  3417. }
  3418. class Animation {
  3419. name: string;
  3420. targetProperty: string;
  3421. framePerSecond: number;
  3422. dataType: number;
  3423. loopMode: number | undefined;
  3424. enableBlending: boolean | undefined;
  3425. static AllowMatricesInterpolation: boolean;
  3426. private _keys;
  3427. private _easingFunction;
  3428. _runtimeAnimations: RuntimeAnimation[];
  3429. private _events;
  3430. targetPropertyPath: string[];
  3431. blendingSpeed: number;
  3432. private _ranges;
  3433. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3434. /**
  3435. * Sets up an animation.
  3436. * @param property the property to animate
  3437. * @param animationType the animation type to apply
  3438. * @param easingFunction the easing function used in the animation
  3439. * @returns The created animation
  3440. */
  3441. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3442. /**
  3443. * Create and start an animation on a node
  3444. * @param {string} name defines the name of the global animation that will be run on all nodes
  3445. * @param {BABYLON.Node} node defines the root node where the animation will take place
  3446. * @param {string} targetProperty defines property to animate
  3447. * @param {number} framePerSecond defines the number of frame per second yo use
  3448. * @param {number} totalFrame defines the number of frames in total
  3449. * @param {any} from defines the initial value
  3450. * @param {any} to defines the final value
  3451. * @param {number} loopMode defines which loop mode you want to use (off by default)
  3452. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  3453. * @param onAnimationEnd defines the callback to call when animation end
  3454. * @returns the animatable created for this animation
  3455. */
  3456. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3457. /**
  3458. * Create and start an animation on a node and its descendants
  3459. * @param {string} name defines the name of the global animation that will be run on all nodes
  3460. * @param {BABYLON.Node} node defines the root node where the animation will take place
  3461. * @param {boolean} 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.
  3462. * @param {string} targetProperty defines property to animate
  3463. * @param {number} framePerSecond defines the number of frame per second yo use
  3464. * @param {number} totalFrame defines the number of frames in total
  3465. * @param {any} from defines the initial value
  3466. * @param {any} to defines the final value
  3467. * @param {number} loopMode defines which loop mode you want to use (off by default)
  3468. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  3469. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3470. * @returns the list of animatables created for all nodes
  3471. * @example https://www.babylonjs-playground.com/#MH0VLI
  3472. */
  3473. 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[]>;
  3474. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3475. /**
  3476. * Transition property of the Camera to the target Value.
  3477. * @param property The property to transition
  3478. * @param targetValue The target Value of the property
  3479. * @param host The object where the property to animate belongs
  3480. * @param scene Scene used to run the animation
  3481. * @param frameRate Framerate (in frame/s) to use
  3482. * @param transition The transition type we want to use
  3483. * @param duration The duration of the animation, in milliseconds
  3484. * @param onAnimationEnd Call back trigger at the end of the animation.
  3485. */
  3486. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3487. /**
  3488. * Return the array of runtime animations currently using this animation
  3489. */
  3490. readonly runtimeAnimations: RuntimeAnimation[];
  3491. readonly hasRunningRuntimeAnimations: boolean;
  3492. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  3493. /**
  3494. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3495. */
  3496. toString(fullDetails?: boolean): string;
  3497. /**
  3498. * Add an event to this animation.
  3499. */
  3500. addEvent(event: AnimationEvent): void;
  3501. /**
  3502. * Remove all events found at the given frame
  3503. * @param frame
  3504. */
  3505. removeEvents(frame: number): void;
  3506. getEvents(): AnimationEvent[];
  3507. createRange(name: string, from: number, to: number): void;
  3508. deleteRange(name: string, deleteFrames?: boolean): void;
  3509. getRange(name: string): Nullable<AnimationRange>;
  3510. getKeys(): Array<IAnimationKey>;
  3511. getHighestFrame(): number;
  3512. getEasingFunction(): IEasingFunction;
  3513. setEasingFunction(easingFunction: EasingFunction): void;
  3514. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3515. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3516. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3517. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3518. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3519. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3520. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3521. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3522. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3523. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3524. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  3525. clone(): Animation;
  3526. setKeys(values: Array<IAnimationKey>): void;
  3527. serialize(): any;
  3528. private static _ANIMATIONTYPE_FLOAT;
  3529. private static _ANIMATIONTYPE_VECTOR3;
  3530. private static _ANIMATIONTYPE_QUATERNION;
  3531. private static _ANIMATIONTYPE_MATRIX;
  3532. private static _ANIMATIONTYPE_COLOR3;
  3533. private static _ANIMATIONTYPE_VECTOR2;
  3534. private static _ANIMATIONTYPE_SIZE;
  3535. private static _ANIMATIONLOOPMODE_RELATIVE;
  3536. private static _ANIMATIONLOOPMODE_CYCLE;
  3537. private static _ANIMATIONLOOPMODE_CONSTANT;
  3538. static readonly ANIMATIONTYPE_FLOAT: number;
  3539. static readonly ANIMATIONTYPE_VECTOR3: number;
  3540. static readonly ANIMATIONTYPE_VECTOR2: number;
  3541. static readonly ANIMATIONTYPE_SIZE: number;
  3542. static readonly ANIMATIONTYPE_QUATERNION: number;
  3543. static readonly ANIMATIONTYPE_MATRIX: number;
  3544. static readonly ANIMATIONTYPE_COLOR3: number;
  3545. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3546. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3547. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3548. static Parse(parsedAnimation: any): Animation;
  3549. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  3550. }
  3551. }
  3552. declare module BABYLON {
  3553. /**
  3554. * This class defines the direct association between an animation and a target
  3555. */
  3556. class TargetedAnimation {
  3557. animation: Animation;
  3558. target: any;
  3559. }
  3560. /**
  3561. * Use this class to create coordinated animations on multiple targets
  3562. */
  3563. class AnimationGroup implements IDisposable {
  3564. name: string;
  3565. private _scene;
  3566. private _targetedAnimations;
  3567. private _animatables;
  3568. private _from;
  3569. private _to;
  3570. private _isStarted;
  3571. private _speedRatio;
  3572. onAnimationEndObservable: Observable<TargetedAnimation>;
  3573. /**
  3574. * Define if the animations are started
  3575. */
  3576. readonly isStarted: boolean;
  3577. /**
  3578. * Gets or sets the speed ratio to use for all animations
  3579. */
  3580. /**
  3581. * Gets or sets the speed ratio to use for all animations
  3582. */
  3583. speedRatio: number;
  3584. /**
  3585. * Gets the targeted animations for this animation group
  3586. */
  3587. readonly targetedAnimations: Array<TargetedAnimation>;
  3588. /**
  3589. * returning the list of animatables controlled by this animation group.
  3590. */
  3591. readonly animatables: Array<Animatable>;
  3592. constructor(name: string, scene?: Nullable<Scene>);
  3593. /**
  3594. * Add an animation (with its target) in the group
  3595. * @param animation defines the animation we want to add
  3596. * @param target defines the target of the animation
  3597. * @returns the {BABYLON.TargetedAnimation} object
  3598. */
  3599. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3600. /**
  3601. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3602. * It can add constant keys at begin or end
  3603. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  3604. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  3605. */
  3606. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  3607. /**
  3608. * Start all animations on given targets
  3609. * @param loop defines if animations must loop
  3610. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3611. * @param from defines the from key (optional)
  3612. * @param to defines the to key (optional)
  3613. * @returns the current animation group
  3614. */
  3615. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  3616. /**
  3617. * Pause all animations
  3618. */
  3619. pause(): AnimationGroup;
  3620. /**
  3621. * Play all animations to initial state
  3622. * This function will start() the animations if they were not started or will restart() them if they were paused
  3623. * @param loop defines if animations must loop
  3624. */
  3625. play(loop?: boolean): AnimationGroup;
  3626. /**
  3627. * Reset all animations to initial state
  3628. */
  3629. reset(): AnimationGroup;
  3630. /**
  3631. * Restart animations from key 0
  3632. */
  3633. restart(): AnimationGroup;
  3634. /**
  3635. * Stop all animations
  3636. */
  3637. stop(): AnimationGroup;
  3638. /**
  3639. * Goes to a specific frame in this animation group
  3640. *
  3641. * @param frame the frame number to go to
  3642. * @return the animationGroup
  3643. */
  3644. goToFrame(frame: number): AnimationGroup;
  3645. /**
  3646. * Dispose all associated resources
  3647. */
  3648. dispose(): void;
  3649. }
  3650. }
  3651. declare module BABYLON {
  3652. /**
  3653. * Class used to override all child animations of a given target
  3654. */
  3655. class AnimationPropertiesOverride {
  3656. /**
  3657. * Gets or sets a value indicating if animation blending must be used
  3658. */
  3659. enableBlending: boolean;
  3660. /**
  3661. * Gets or sets the blending speed to use when enableBlending is true
  3662. */
  3663. blendingSpeed: number;
  3664. /**
  3665. * Gets or sets the default loop mode to use
  3666. */
  3667. loopMode: number;
  3668. }
  3669. }
  3670. declare module BABYLON {
  3671. interface IEasingFunction {
  3672. ease(gradient: number): number;
  3673. }
  3674. class EasingFunction implements IEasingFunction {
  3675. private static _EASINGMODE_EASEIN;
  3676. private static _EASINGMODE_EASEOUT;
  3677. private static _EASINGMODE_EASEINOUT;
  3678. static readonly EASINGMODE_EASEIN: number;
  3679. static readonly EASINGMODE_EASEOUT: number;
  3680. static readonly EASINGMODE_EASEINOUT: number;
  3681. private _easingMode;
  3682. setEasingMode(easingMode: number): void;
  3683. getEasingMode(): number;
  3684. easeInCore(gradient: number): number;
  3685. ease(gradient: number): number;
  3686. }
  3687. class CircleEase extends EasingFunction implements IEasingFunction {
  3688. easeInCore(gradient: number): number;
  3689. }
  3690. class BackEase extends EasingFunction implements IEasingFunction {
  3691. amplitude: number;
  3692. constructor(amplitude?: number);
  3693. easeInCore(gradient: number): number;
  3694. }
  3695. class BounceEase extends EasingFunction implements IEasingFunction {
  3696. bounces: number;
  3697. bounciness: number;
  3698. constructor(bounces?: number, bounciness?: number);
  3699. easeInCore(gradient: number): number;
  3700. }
  3701. class CubicEase extends EasingFunction implements IEasingFunction {
  3702. easeInCore(gradient: number): number;
  3703. }
  3704. class ElasticEase extends EasingFunction implements IEasingFunction {
  3705. oscillations: number;
  3706. springiness: number;
  3707. constructor(oscillations?: number, springiness?: number);
  3708. easeInCore(gradient: number): number;
  3709. }
  3710. class ExponentialEase extends EasingFunction implements IEasingFunction {
  3711. exponent: number;
  3712. constructor(exponent?: number);
  3713. easeInCore(gradient: number): number;
  3714. }
  3715. class PowerEase extends EasingFunction implements IEasingFunction {
  3716. power: number;
  3717. constructor(power?: number);
  3718. easeInCore(gradient: number): number;
  3719. }
  3720. class QuadraticEase extends EasingFunction implements IEasingFunction {
  3721. easeInCore(gradient: number): number;
  3722. }
  3723. class QuarticEase extends EasingFunction implements IEasingFunction {
  3724. easeInCore(gradient: number): number;
  3725. }
  3726. class QuinticEase extends EasingFunction implements IEasingFunction {
  3727. easeInCore(gradient: number): number;
  3728. }
  3729. class SineEase extends EasingFunction implements IEasingFunction {
  3730. easeInCore(gradient: number): number;
  3731. }
  3732. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  3733. x1: number;
  3734. y1: number;
  3735. x2: number;
  3736. y2: number;
  3737. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  3738. easeInCore(gradient: number): number;
  3739. }
  3740. }
  3741. declare module BABYLON {
  3742. class RuntimeAnimation {
  3743. private _currentFrame;
  3744. private _animation;
  3745. private _target;
  3746. private _host;
  3747. private _originalValue;
  3748. private _originalBlendValue;
  3749. private _offsetsCache;
  3750. private _highLimitsCache;
  3751. private _stopped;
  3752. private _blendingFactor;
  3753. private _scene;
  3754. private _currentValue;
  3755. private _activeTarget;
  3756. private _targetPath;
  3757. private _weight;
  3758. /**
  3759. * Gets the current frame
  3760. */
  3761. readonly currentFrame: number;
  3762. /**
  3763. * Gets the weight of the runtime animation
  3764. */
  3765. readonly weight: number;
  3766. /**
  3767. * Gets the original value of the runtime animation
  3768. */
  3769. readonly originalValue: any;
  3770. /**
  3771. * Gets the current value of the runtime animation
  3772. */
  3773. readonly currentValue: any;
  3774. /**
  3775. * Gets the path where to store the animated value in the target
  3776. */
  3777. readonly targetPath: string;
  3778. /**
  3779. * Gets the actual target of the runtime animation
  3780. */
  3781. readonly target: any;
  3782. /**
  3783. * Create a new RuntimeAnimation object
  3784. * @param target defines the target of the animation
  3785. * @param animation defines the source {BABYLON.Animation} object
  3786. * @param scene defines the hosting scene
  3787. * @param host defines the initiating Animatable
  3788. */
  3789. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  3790. readonly animation: Animation;
  3791. reset(): void;
  3792. isStopped(): boolean;
  3793. dispose(): void;
  3794. private _getKeyValue(value);
  3795. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  3796. /**
  3797. * Affect the interpolated value to the target
  3798. * @param currentValue defines the value computed by the animation
  3799. * @param weight defines the weight to apply to this value
  3800. */
  3801. setValue(currentValue: any, weight?: number): void;
  3802. private _getCorrectLoopMode();
  3803. /**
  3804. * Move the current animation to a given frame
  3805. * @param frame defines the frame to move to
  3806. */
  3807. goToFrame(frame: number): void;
  3808. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  3809. private _ratioOffset;
  3810. private _previousDelay;
  3811. private _previousRatio;
  3812. /**
  3813. * Execute the current animation
  3814. * @param delay defines the delay to add to the current frame
  3815. * @param from defines the lower bound of the animation range
  3816. * @param to defines the upper bound of the animation range
  3817. * @param loop defines if the current animation must loop
  3818. * @param speedRatio defines the current speed ratio
  3819. * @param weight defines the weight of the animation (default is -1 so no weight)
  3820. * @returns a boolean indicating if the animation has ended
  3821. */
  3822. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  3823. }
  3824. }
  3825. declare module BABYLON {
  3826. interface Behavior<T extends Node> {
  3827. name: string;
  3828. init(): void;
  3829. attach(node: T): void;
  3830. detach(): void;
  3831. }
  3832. }
  3833. declare module BABYLON {
  3834. class Bone extends Node {
  3835. name: string;
  3836. private static _tmpVecs;
  3837. private static _tmpQuat;
  3838. private static _tmpMats;
  3839. children: Bone[];
  3840. animations: Animation[];
  3841. length: number;
  3842. _index: Nullable<number>;
  3843. private _skeleton;
  3844. private _localMatrix;
  3845. private _restPose;
  3846. private _baseMatrix;
  3847. private _worldTransform;
  3848. private _absoluteTransform;
  3849. private _invertedAbsoluteTransform;
  3850. private _parent;
  3851. private _scaleMatrix;
  3852. private _scaleVector;
  3853. private _negateScaleChildren;
  3854. private _scalingDeterminant;
  3855. _matrix: Matrix;
  3856. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  3857. getSkeleton(): Skeleton;
  3858. getParent(): Nullable<Bone>;
  3859. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  3860. getLocalMatrix(): Matrix;
  3861. getBaseMatrix(): Matrix;
  3862. getRestPose(): Matrix;
  3863. returnToRest(): void;
  3864. getWorldMatrix(): Matrix;
  3865. getInvertedAbsoluteTransform(): Matrix;
  3866. getAbsoluteTransform(): Matrix;
  3867. position: Vector3;
  3868. rotation: Vector3;
  3869. rotationQuaternion: Quaternion;
  3870. scaling: Vector3;
  3871. /**
  3872. * Gets the animation properties override
  3873. */
  3874. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  3875. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  3876. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  3877. markAsDirty(): void;
  3878. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  3879. /**
  3880. * Translate the bone in local or world space.
  3881. * @param vec The amount to translate the bone.
  3882. * @param space The space that the translation is in.
  3883. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3884. */
  3885. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3886. /**
  3887. * Set the postion of the bone in local or world space.
  3888. * @param position The position to set the bone.
  3889. * @param space The space that the position is in.
  3890. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3891. */
  3892. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3893. /**
  3894. * Set the absolute postion of the bone (world space).
  3895. * @param position The position to set the bone.
  3896. * @param mesh The mesh that this bone is attached to.
  3897. */
  3898. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  3899. /**
  3900. * Set the scale of the bone on the x, y and z axes.
  3901. * @param x The scale of the bone on the x axis.
  3902. * @param x The scale of the bone on the y axis.
  3903. * @param z The scale of the bone on the z axis.
  3904. * @param scaleChildren Set this to true if children of the bone should be scaled.
  3905. */
  3906. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  3907. /**
  3908. * Scale the bone on the x, y and z axes.
  3909. * @param x The amount to scale the bone on the x axis.
  3910. * @param x The amount to scale the bone on the y axis.
  3911. * @param z The amount to scale the bone on the z axis.
  3912. * @param scaleChildren Set this to true if children of the bone should be scaled.
  3913. */
  3914. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  3915. /**
  3916. * Set the yaw, pitch, and roll of the bone in local or world space.
  3917. * @param yaw The rotation of the bone on the y axis.
  3918. * @param pitch The rotation of the bone on the x axis.
  3919. * @param roll The rotation of the bone on the z axis.
  3920. * @param space The space that the axes of rotation are in.
  3921. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3922. */
  3923. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  3924. /**
  3925. * Rotate the bone on an axis in local or world space.
  3926. * @param axis The axis to rotate the bone on.
  3927. * @param amount The amount to rotate the bone.
  3928. * @param space The space that the axis is in.
  3929. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3930. */
  3931. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  3932. /**
  3933. * Set the rotation of the bone to a particular axis angle in local or world space.
  3934. * @param axis The axis to rotate the bone on.
  3935. * @param angle The angle that the bone should be rotated to.
  3936. * @param space The space that the axis is in.
  3937. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3938. */
  3939. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  3940. /**
  3941. * Set the euler rotation of the bone in local of world space.
  3942. * @param rotation The euler rotation that the bone should be set to.
  3943. * @param space The space that the rotation is in.
  3944. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3945. */
  3946. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3947. /**
  3948. * Set the quaternion rotation of the bone in local of world space.
  3949. * @param quat The quaternion rotation that the bone should be set to.
  3950. * @param space The space that the rotation is in.
  3951. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3952. */
  3953. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  3954. /**
  3955. * Set the rotation matrix of the bone in local of world space.
  3956. * @param rotMat The rotation matrix that the bone should be set to.
  3957. * @param space The space that the rotation is in.
  3958. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3959. */
  3960. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  3961. private _rotateWithMatrix(rmat, space?, mesh?);
  3962. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  3963. /**
  3964. * Get the scale of the bone
  3965. * @returns the scale of the bone
  3966. */
  3967. getScale(): Vector3;
  3968. /**
  3969. * Copy the scale of the bone to a vector3.
  3970. * @param result The vector3 to copy the scale to
  3971. */
  3972. getScaleToRef(result: Vector3): void;
  3973. /**
  3974. * Get the position of the bone in local or world space.
  3975. * @param space The space that the returned position is in.
  3976. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3977. * @returns The position of the bone
  3978. */
  3979. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  3980. /**
  3981. * Copy the position of the bone to a vector3 in local or world space.
  3982. * @param space The space that the returned position is in.
  3983. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3984. * @param result The vector3 to copy the position to.
  3985. */
  3986. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  3987. /**
  3988. * Get the absolute position of the bone (world space).
  3989. * @param mesh The mesh that this bone is attached to.
  3990. * @returns The absolute position of the bone
  3991. */
  3992. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  3993. /**
  3994. * Copy the absolute position of the bone (world space) to the result param.
  3995. * @param mesh The mesh that this bone is attached to.
  3996. * @param result The vector3 to copy the absolute position to.
  3997. */
  3998. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  3999. /**
  4000. * Compute the absolute transforms of this bone and its children.
  4001. */
  4002. computeAbsoluteTransforms(): void;
  4003. private _syncScaleVector();
  4004. /**
  4005. * Get the world direction from an axis that is in the local space of the bone.
  4006. * @param localAxis The local direction that is used to compute the world direction.
  4007. * @param mesh The mesh that this bone is attached to.
  4008. * @returns The world direction
  4009. */
  4010. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4011. /**
  4012. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  4013. * @param localAxis The local direction that is used to compute the world direction.
  4014. * @param mesh The mesh that this bone is attached to.
  4015. * @param result The vector3 that the world direction will be copied to.
  4016. */
  4017. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4018. /**
  4019. * Get the euler rotation of the bone in local or world space.
  4020. * @param space The space that the rotation should be in.
  4021. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4022. * @returns The euler rotation
  4023. */
  4024. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4025. /**
  4026. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  4027. * @param space The space that the rotation should be in.
  4028. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4029. * @param result The vector3 that the rotation should be copied to.
  4030. */
  4031. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4032. /**
  4033. * Get the quaternion rotation of the bone in either local or world space.
  4034. * @param space The space that the rotation should be in.
  4035. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4036. * @returns The quaternion rotation
  4037. */
  4038. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4039. /**
  4040. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  4041. * @param space The space that the rotation should be in.
  4042. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4043. * @param result The quaternion that the rotation should be copied to.
  4044. */
  4045. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4046. /**
  4047. * Get the rotation matrix of the bone in local or world space.
  4048. * @param space The space that the rotation should be in.
  4049. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4050. * @returns The rotation matrix
  4051. */
  4052. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4053. /**
  4054. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  4055. * @param space The space that the rotation should be in.
  4056. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4057. * @param result The quaternion that the rotation should be copied to.
  4058. */
  4059. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4060. /**
  4061. * Get the world position of a point that is in the local space of the bone.
  4062. * @param position The local position
  4063. * @param mesh The mesh that this bone is attached to.
  4064. * @returns The world position
  4065. */
  4066. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4067. /**
  4068. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  4069. * @param position The local position
  4070. * @param mesh The mesh that this bone is attached to.
  4071. * @param result The vector3 that the world position should be copied to.
  4072. */
  4073. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4074. /**
  4075. * Get the local position of a point that is in world space.
  4076. * @param position The world position
  4077. * @param mesh The mesh that this bone is attached to.
  4078. * @returns The local position
  4079. */
  4080. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4081. /**
  4082. * Get the local position of a point that is in world space and copy it to the result param.
  4083. * @param position The world position
  4084. * @param mesh The mesh that this bone is attached to.
  4085. * @param result The vector3 that the local position should be copied to.
  4086. */
  4087. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4088. }
  4089. }
  4090. declare module BABYLON {
  4091. class BoneIKController {
  4092. private static _tmpVecs;
  4093. private static _tmpQuat;
  4094. private static _tmpMats;
  4095. targetMesh: AbstractMesh;
  4096. poleTargetMesh: AbstractMesh;
  4097. poleTargetBone: Nullable<Bone>;
  4098. targetPosition: Vector3;
  4099. poleTargetPosition: Vector3;
  4100. poleTargetLocalOffset: Vector3;
  4101. poleAngle: number;
  4102. mesh: AbstractMesh;
  4103. slerpAmount: number;
  4104. private _bone1Quat;
  4105. private _bone1Mat;
  4106. private _bone2Ang;
  4107. private _bone1;
  4108. private _bone2;
  4109. private _bone1Length;
  4110. private _bone2Length;
  4111. private _maxAngle;
  4112. private _maxReach;
  4113. private _rightHandedSystem;
  4114. private _bendAxis;
  4115. private _slerping;
  4116. private _adjustRoll;
  4117. maxAngle: number;
  4118. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  4119. targetMesh?: AbstractMesh;
  4120. poleTargetMesh?: AbstractMesh;
  4121. poleTargetBone?: Bone;
  4122. poleTargetLocalOffset?: Vector3;
  4123. poleAngle?: number;
  4124. bendAxis?: Vector3;
  4125. maxAngle?: number;
  4126. slerpAmount?: number;
  4127. });
  4128. private _setMaxAngle(ang);
  4129. update(): void;
  4130. }
  4131. }
  4132. declare module BABYLON {
  4133. class BoneLookController {
  4134. private static _tmpVecs;
  4135. private static _tmpQuat;
  4136. private static _tmpMats;
  4137. /**
  4138. * The target Vector3 that the bone will look at.
  4139. */
  4140. target: Vector3;
  4141. /**
  4142. * The mesh that the bone is attached to.
  4143. */
  4144. mesh: AbstractMesh;
  4145. /**
  4146. * The bone that will be looking to the target.
  4147. */
  4148. bone: Bone;
  4149. /**
  4150. * The up axis of the coordinate system that is used when the bone is rotated.
  4151. */
  4152. upAxis: Vector3;
  4153. /**
  4154. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4155. */
  4156. upAxisSpace: Space;
  4157. /**
  4158. * Used to make an adjustment to the yaw of the bone.
  4159. */
  4160. adjustYaw: number;
  4161. /**
  4162. * Used to make an adjustment to the pitch of the bone.
  4163. */
  4164. adjustPitch: number;
  4165. /**
  4166. * Used to make an adjustment to the roll of the bone.
  4167. */
  4168. adjustRoll: number;
  4169. /**
  4170. * 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).
  4171. */
  4172. slerpAmount: number;
  4173. private _minYaw;
  4174. private _maxYaw;
  4175. private _minPitch;
  4176. private _maxPitch;
  4177. private _minYawSin;
  4178. private _minYawCos;
  4179. private _maxYawSin;
  4180. private _maxYawCos;
  4181. private _midYawConstraint;
  4182. private _minPitchTan;
  4183. private _maxPitchTan;
  4184. private _boneQuat;
  4185. private _slerping;
  4186. private _transformYawPitch;
  4187. private _transformYawPitchInv;
  4188. private _firstFrameSkipped;
  4189. private _yawRange;
  4190. private _fowardAxis;
  4191. /**
  4192. * Get/set the minimum yaw angle that the bone can look to.
  4193. */
  4194. minYaw: number;
  4195. /**
  4196. * Get/set the maximum yaw angle that the bone can look to.
  4197. */
  4198. maxYaw: number;
  4199. /**
  4200. * Get/set the minimum pitch angle that the bone can look to.
  4201. */
  4202. minPitch: number;
  4203. /**
  4204. * Get/set the maximum pitch angle that the bone can look to.
  4205. */
  4206. maxPitch: number;
  4207. /**
  4208. * Create a BoneLookController
  4209. * @param mesh the mesh that the bone belongs to
  4210. * @param bone the bone that will be looking to the target
  4211. * @param target the target Vector3 to look at
  4212. * @param settings optional settings:
  4213. * - maxYaw: the maximum angle the bone will yaw to
  4214. * - minYaw: the minimum angle the bone will yaw to
  4215. * - maxPitch: the maximum angle the bone will pitch to
  4216. * - minPitch: the minimum angle the bone will yaw to
  4217. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  4218. * - upAxis: the up axis of the coordinate system
  4219. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4220. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  4221. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  4222. * - adjustYaw: used to make an adjustment to the yaw of the bone
  4223. * - adjustPitch: used to make an adjustment to the pitch of the bone
  4224. * - adjustRoll: used to make an adjustment to the roll of the bone
  4225. **/
  4226. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  4227. maxYaw?: number;
  4228. minYaw?: number;
  4229. maxPitch?: number;
  4230. minPitch?: number;
  4231. slerpAmount?: number;
  4232. upAxis?: Vector3;
  4233. upAxisSpace?: Space;
  4234. yawAxis?: Vector3;
  4235. pitchAxis?: Vector3;
  4236. adjustYaw?: number;
  4237. adjustPitch?: number;
  4238. adjustRoll?: number;
  4239. });
  4240. /**
  4241. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  4242. */
  4243. update(): void;
  4244. private _getAngleDiff(ang1, ang2);
  4245. private _getAngleBetween(ang1, ang2);
  4246. private _isAngleBetween(ang, ang1, ang2);
  4247. }
  4248. }
  4249. declare module BABYLON {
  4250. class Skeleton implements IAnimatable {
  4251. name: string;
  4252. id: string;
  4253. bones: Bone[];
  4254. dimensionsAtRest: Vector3;
  4255. needInitialSkinMatrix: boolean;
  4256. animations: Array<Animation>;
  4257. private _scene;
  4258. private _isDirty;
  4259. private _transformMatrices;
  4260. private _meshesWithPoseMatrix;
  4261. private _animatables;
  4262. private _identity;
  4263. private _synchronizedWithMesh;
  4264. private _ranges;
  4265. private _lastAbsoluteTransformsUpdateId;
  4266. /**
  4267. * Specifies if the skeleton should be serialized.
  4268. */
  4269. doNotSerialize: boolean;
  4270. /**
  4271. * Gets or sets the animation properties override
  4272. */
  4273. animationPropertiesOverride: AnimationPropertiesOverride;
  4274. /**
  4275. * An event triggered before computing the skeleton's matrices
  4276. */
  4277. onBeforeComputeObservable: Observable<Skeleton>;
  4278. constructor(name: string, id: string, scene: Scene);
  4279. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  4280. getScene(): Scene;
  4281. /**
  4282. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4283. */
  4284. toString(fullDetails?: boolean): string;
  4285. /**
  4286. * Get bone's index searching by name
  4287. * @param {string} name is bone's name to search for
  4288. * @return {number} Indice of the bone. Returns -1 if not found
  4289. */
  4290. getBoneIndexByName(name: string): number;
  4291. createAnimationRange(name: string, from: number, to: number): void;
  4292. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  4293. getAnimationRange(name: string): Nullable<AnimationRange>;
  4294. /**
  4295. * Returns as an Array, all AnimationRanges defined on this skeleton
  4296. */
  4297. getAnimationRanges(): Nullable<AnimationRange>[];
  4298. /**
  4299. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  4300. */
  4301. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  4302. returnToRest(): void;
  4303. private _getHighestAnimationFrame();
  4304. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  4305. _markAsDirty(): void;
  4306. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4307. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4308. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  4309. prepare(): void;
  4310. getAnimatables(): IAnimatable[];
  4311. clone(name: string, id: string): Skeleton;
  4312. enableBlending(blendingSpeed?: number): void;
  4313. dispose(): void;
  4314. serialize(): any;
  4315. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  4316. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  4317. getPoseMatrix(): Nullable<Matrix>;
  4318. sortBones(): void;
  4319. private _sortBones(index, bones, visited);
  4320. }
  4321. }
  4322. declare module BABYLON {
  4323. class Collider {
  4324. /** Define if a collision was found */
  4325. collisionFound: boolean;
  4326. /**
  4327. * Define last intersection point in local space
  4328. */
  4329. intersectionPoint: Vector3;
  4330. /**
  4331. * Define last collided mesh
  4332. */
  4333. collidedMesh: Nullable<AbstractMesh>;
  4334. private _collisionPoint;
  4335. private _planeIntersectionPoint;
  4336. private _tempVector;
  4337. private _tempVector2;
  4338. private _tempVector3;
  4339. private _tempVector4;
  4340. private _edge;
  4341. private _baseToVertex;
  4342. private _destinationPoint;
  4343. private _slidePlaneNormal;
  4344. private _displacementVector;
  4345. _radius: Vector3;
  4346. _retry: number;
  4347. private _velocity;
  4348. private _basePoint;
  4349. private _epsilon;
  4350. _velocityWorldLength: number;
  4351. _basePointWorld: Vector3;
  4352. private _velocityWorld;
  4353. private _normalizedVelocity;
  4354. _initialVelocity: Vector3;
  4355. _initialPosition: Vector3;
  4356. private _nearestDistance;
  4357. private _collisionMask;
  4358. collisionMask: number;
  4359. /**
  4360. * Gets the plane normal used to compute the sliding response (in local space)
  4361. */
  4362. readonly slidePlaneNormal: Vector3;
  4363. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4364. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4365. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4366. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4367. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4368. _getResponse(pos: Vector3, vel: Vector3): void;
  4369. }
  4370. }
  4371. declare module BABYLON {
  4372. var CollisionWorker: string;
  4373. interface ICollisionCoordinator {
  4374. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4375. init(scene: Scene): void;
  4376. destroy(): void;
  4377. onMeshAdded(mesh: AbstractMesh): void;
  4378. onMeshUpdated(mesh: AbstractMesh): void;
  4379. onMeshRemoved(mesh: AbstractMesh): void;
  4380. onGeometryAdded(geometry: Geometry): void;
  4381. onGeometryUpdated(geometry: Geometry): void;
  4382. onGeometryDeleted(geometry: Geometry): void;
  4383. }
  4384. interface SerializedMesh {
  4385. id: string;
  4386. name: string;
  4387. uniqueId: number;
  4388. geometryId: Nullable<string>;
  4389. sphereCenter: Array<number>;
  4390. sphereRadius: number;
  4391. boxMinimum: Array<number>;
  4392. boxMaximum: Array<number>;
  4393. worldMatrixFromCache: any;
  4394. subMeshes: Array<SerializedSubMesh>;
  4395. checkCollisions: boolean;
  4396. }
  4397. interface SerializedSubMesh {
  4398. position: number;
  4399. verticesStart: number;
  4400. verticesCount: number;
  4401. indexStart: number;
  4402. indexCount: number;
  4403. hasMaterial: boolean;
  4404. sphereCenter: Array<number>;
  4405. sphereRadius: number;
  4406. boxMinimum: Array<number>;
  4407. boxMaximum: Array<number>;
  4408. }
  4409. /**
  4410. * Interface describing the value associated with a geometry
  4411. */
  4412. interface SerializedGeometry {
  4413. /**
  4414. * Defines the unique ID of the geometry
  4415. */
  4416. id: string;
  4417. /**
  4418. * Defines the array containing the positions
  4419. */
  4420. positions: Float32Array;
  4421. /**
  4422. * Defines the array containing the indices
  4423. */
  4424. indices: Uint32Array;
  4425. /**
  4426. * Defines the array containing the normals
  4427. */
  4428. normals: Float32Array;
  4429. }
  4430. interface BabylonMessage {
  4431. taskType: WorkerTaskType;
  4432. payload: InitPayload | CollidePayload | UpdatePayload;
  4433. }
  4434. interface SerializedColliderToWorker {
  4435. position: Array<number>;
  4436. velocity: Array<number>;
  4437. radius: Array<number>;
  4438. }
  4439. enum WorkerTaskType {
  4440. INIT = 0,
  4441. UPDATE = 1,
  4442. COLLIDE = 2,
  4443. }
  4444. interface WorkerReply {
  4445. error: WorkerReplyType;
  4446. taskType: WorkerTaskType;
  4447. payload?: any;
  4448. }
  4449. interface CollisionReplyPayload {
  4450. newPosition: Array<number>;
  4451. collisionId: number;
  4452. collidedMeshUniqueId: number;
  4453. }
  4454. interface InitPayload {
  4455. }
  4456. interface CollidePayload {
  4457. collisionId: number;
  4458. collider: SerializedColliderToWorker;
  4459. maximumRetry: number;
  4460. excludedMeshUniqueId: Nullable<number>;
  4461. }
  4462. interface UpdatePayload {
  4463. updatedMeshes: {
  4464. [n: number]: SerializedMesh;
  4465. };
  4466. updatedGeometries: {
  4467. [s: string]: SerializedGeometry;
  4468. };
  4469. removedMeshes: Array<number>;
  4470. removedGeometries: Array<string>;
  4471. }
  4472. enum WorkerReplyType {
  4473. SUCCESS = 0,
  4474. UNKNOWN_ERROR = 1,
  4475. }
  4476. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4477. private _scene;
  4478. private _scaledPosition;
  4479. private _scaledVelocity;
  4480. private _collisionsCallbackArray;
  4481. private _init;
  4482. private _runningUpdated;
  4483. private _worker;
  4484. private _addUpdateMeshesList;
  4485. private _addUpdateGeometriesList;
  4486. private _toRemoveMeshesArray;
  4487. private _toRemoveGeometryArray;
  4488. constructor();
  4489. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4490. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4491. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4492. init(scene: Scene): void;
  4493. destroy(): void;
  4494. onMeshAdded(mesh: AbstractMesh): void;
  4495. onMeshUpdated: (transformNode: TransformNode) => void;
  4496. onMeshRemoved(mesh: AbstractMesh): void;
  4497. onGeometryAdded(geometry: Geometry): void;
  4498. onGeometryUpdated: (geometry: Geometry) => void;
  4499. onGeometryDeleted(geometry: Geometry): void;
  4500. private _afterRender;
  4501. private _onMessageFromWorker;
  4502. }
  4503. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4504. private _scene;
  4505. private _scaledPosition;
  4506. private _scaledVelocity;
  4507. private _finalPosition;
  4508. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4509. init(scene: Scene): void;
  4510. destroy(): void;
  4511. onMeshAdded(mesh: AbstractMesh): void;
  4512. onMeshUpdated(mesh: AbstractMesh): void;
  4513. onMeshRemoved(mesh: AbstractMesh): void;
  4514. onGeometryAdded(geometry: Geometry): void;
  4515. onGeometryUpdated(geometry: Geometry): void;
  4516. onGeometryDeleted(geometry: Geometry): void;
  4517. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  4518. }
  4519. }
  4520. declare function importScripts(...urls: string[]): void;
  4521. declare const safePostMessage: any;
  4522. declare module BABYLON {
  4523. var WorkerIncluded: boolean;
  4524. class CollisionCache {
  4525. private _meshes;
  4526. private _geometries;
  4527. getMeshes(): {
  4528. [n: number]: SerializedMesh;
  4529. };
  4530. getGeometries(): {
  4531. [s: number]: SerializedGeometry;
  4532. };
  4533. getMesh(id: any): SerializedMesh;
  4534. addMesh(mesh: SerializedMesh): void;
  4535. removeMesh(uniqueId: number): void;
  4536. getGeometry(id: string): SerializedGeometry;
  4537. addGeometry(geometry: SerializedGeometry): void;
  4538. removeGeometry(id: string): void;
  4539. }
  4540. class CollideWorker {
  4541. collider: Collider;
  4542. private _collisionCache;
  4543. private finalPosition;
  4544. private collisionsScalingMatrix;
  4545. private collisionTranformationMatrix;
  4546. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  4547. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  4548. private checkCollision(mesh);
  4549. private processCollisionsForSubMeshes(transformMatrix, mesh);
  4550. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  4551. private checkSubmeshCollision(subMesh);
  4552. }
  4553. interface ICollisionDetector {
  4554. onInit(payload: InitPayload): void;
  4555. onUpdate(payload: UpdatePayload): void;
  4556. onCollision(payload: CollidePayload): void;
  4557. }
  4558. class CollisionDetectorTransferable implements ICollisionDetector {
  4559. private _collisionCache;
  4560. onInit(payload: InitPayload): void;
  4561. onUpdate(payload: UpdatePayload): void;
  4562. onCollision(payload: CollidePayload): void;
  4563. }
  4564. }
  4565. declare module BABYLON {
  4566. class IntersectionInfo {
  4567. bu: Nullable<number>;
  4568. bv: Nullable<number>;
  4569. distance: number;
  4570. faceId: number;
  4571. subMeshId: number;
  4572. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  4573. }
  4574. class PickingInfo {
  4575. hit: boolean;
  4576. distance: number;
  4577. pickedPoint: Nullable<Vector3>;
  4578. pickedMesh: Nullable<AbstractMesh>;
  4579. bu: number;
  4580. bv: number;
  4581. faceId: number;
  4582. subMeshId: number;
  4583. pickedSprite: Nullable<Sprite>;
  4584. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  4585. getTextureCoordinates(): Nullable<Vector2>;
  4586. }
  4587. }
  4588. declare module BABYLON {
  4589. class BoundingBox implements ICullable {
  4590. minimum: Vector3;
  4591. maximum: Vector3;
  4592. vectors: Vector3[];
  4593. center: Vector3;
  4594. centerWorld: Vector3;
  4595. extendSize: Vector3;
  4596. extendSizeWorld: Vector3;
  4597. directions: Vector3[];
  4598. vectorsWorld: Vector3[];
  4599. minimumWorld: Vector3;
  4600. maximumWorld: Vector3;
  4601. private _worldMatrix;
  4602. constructor(minimum: Vector3, maximum: Vector3);
  4603. getWorldMatrix(): Matrix;
  4604. setWorldMatrix(matrix: Matrix): BoundingBox;
  4605. _update(world: Matrix): void;
  4606. isInFrustum(frustumPlanes: Plane[]): boolean;
  4607. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4608. intersectsPoint(point: Vector3): boolean;
  4609. intersectsSphere(sphere: BoundingSphere): boolean;
  4610. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  4611. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  4612. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  4613. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4614. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. interface ICullable {
  4619. isInFrustum(frustumPlanes: Plane[]): boolean;
  4620. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4621. }
  4622. class BoundingInfo implements ICullable {
  4623. minimum: Vector3;
  4624. maximum: Vector3;
  4625. boundingBox: BoundingBox;
  4626. boundingSphere: BoundingSphere;
  4627. private _isLocked;
  4628. constructor(minimum: Vector3, maximum: Vector3);
  4629. isLocked: boolean;
  4630. update(world: Matrix): void;
  4631. /**
  4632. * Recreate the bounding info to be centered around a specific point given a specific extend.
  4633. * @param center New center of the bounding info
  4634. * @param extend New extend of the bounding info
  4635. */
  4636. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  4637. isInFrustum(frustumPlanes: Plane[]): boolean;
  4638. /**
  4639. * Gets the world distance between the min and max points of the bounding box
  4640. */
  4641. readonly diagonalLength: number;
  4642. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4643. _checkCollision(collider: Collider): boolean;
  4644. intersectsPoint(point: Vector3): boolean;
  4645. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  4646. }
  4647. }
  4648. declare module BABYLON {
  4649. class BoundingSphere {
  4650. minimum: Vector3;
  4651. maximum: Vector3;
  4652. center: Vector3;
  4653. radius: number;
  4654. centerWorld: Vector3;
  4655. radiusWorld: number;
  4656. private _tempRadiusVector;
  4657. constructor(minimum: Vector3, maximum: Vector3);
  4658. _update(world: Matrix): void;
  4659. isInFrustum(frustumPlanes: Plane[]): boolean;
  4660. intersectsPoint(point: Vector3): boolean;
  4661. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  4662. }
  4663. }
  4664. declare module BABYLON {
  4665. class Ray {
  4666. origin: Vector3;
  4667. direction: Vector3;
  4668. length: number;
  4669. private _edge1;
  4670. private _edge2;
  4671. private _pvec;
  4672. private _tvec;
  4673. private _qvec;
  4674. private _tmpRay;
  4675. constructor(origin: Vector3, direction: Vector3, length?: number);
  4676. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  4677. intersectsBox(box: BoundingBox): boolean;
  4678. intersectsSphere(sphere: BoundingSphere): boolean;
  4679. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  4680. intersectsPlane(plane: Plane): Nullable<number>;
  4681. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  4682. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  4683. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  4684. private static smallnum;
  4685. private static rayl;
  4686. /**
  4687. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  4688. * @param sega the first point of the segment to test the intersection against
  4689. * @param segb the second point of the segment to test the intersection against
  4690. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  4691. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  4692. */
  4693. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  4694. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4695. static Zero(): Ray;
  4696. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4697. /**
  4698. * 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
  4699. * transformed to the given world matrix.
  4700. * @param origin The origin point
  4701. * @param end The end point
  4702. * @param world a matrix to transform the ray to. Default is the identity matrix.
  4703. */
  4704. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  4705. static Transform(ray: Ray, matrix: Matrix): Ray;
  4706. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  4707. }
  4708. }
  4709. declare module BABYLON {
  4710. class ArcRotateCamera extends TargetCamera {
  4711. alpha: number;
  4712. beta: number;
  4713. radius: number;
  4714. protected _target: Vector3;
  4715. protected _targetHost: Nullable<AbstractMesh>;
  4716. target: Vector3;
  4717. inertialAlphaOffset: number;
  4718. inertialBetaOffset: number;
  4719. inertialRadiusOffset: number;
  4720. lowerAlphaLimit: Nullable<number>;
  4721. upperAlphaLimit: Nullable<number>;
  4722. lowerBetaLimit: number;
  4723. upperBetaLimit: number;
  4724. lowerRadiusLimit: Nullable<number>;
  4725. upperRadiusLimit: Nullable<number>;
  4726. inertialPanningX: number;
  4727. inertialPanningY: number;
  4728. pinchToPanMaxDistance: number;
  4729. panningDistanceLimit: Nullable<number>;
  4730. panningOriginTarget: Vector3;
  4731. panningInertia: number;
  4732. angularSensibilityX: number;
  4733. angularSensibilityY: number;
  4734. pinchPrecision: number;
  4735. pinchDeltaPercentage: number;
  4736. panningSensibility: number;
  4737. keysUp: number[];
  4738. keysDown: number[];
  4739. keysLeft: number[];
  4740. keysRight: number[];
  4741. wheelPrecision: number;
  4742. wheelDeltaPercentage: number;
  4743. zoomOnFactor: number;
  4744. targetScreenOffset: Vector2;
  4745. allowUpsideDown: boolean;
  4746. _viewMatrix: Matrix;
  4747. _useCtrlForPanning: boolean;
  4748. _panningMouseButton: number;
  4749. inputs: ArcRotateCameraInputsManager;
  4750. _reset: () => void;
  4751. panningAxis: Vector3;
  4752. protected _localDirection: Vector3;
  4753. protected _transformedDirection: Vector3;
  4754. private _bouncingBehavior;
  4755. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  4756. useBouncingBehavior: boolean;
  4757. private _framingBehavior;
  4758. readonly framingBehavior: Nullable<FramingBehavior>;
  4759. useFramingBehavior: boolean;
  4760. private _autoRotationBehavior;
  4761. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  4762. useAutoRotationBehavior: boolean;
  4763. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  4764. onCollide: (collidedMesh: AbstractMesh) => void;
  4765. checkCollisions: boolean;
  4766. collisionRadius: Vector3;
  4767. protected _collider: Collider;
  4768. protected _previousPosition: Vector3;
  4769. protected _collisionVelocity: Vector3;
  4770. protected _newPosition: Vector3;
  4771. protected _previousAlpha: number;
  4772. protected _previousBeta: number;
  4773. protected _previousRadius: number;
  4774. protected _collisionTriggered: boolean;
  4775. protected _targetBoundingCenter: Nullable<Vector3>;
  4776. private _computationVector;
  4777. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  4778. _initCache(): void;
  4779. _updateCache(ignoreParentClass?: boolean): void;
  4780. protected _getTargetPosition(): Vector3;
  4781. /**
  4782. * Store current camera state (fov, position, etc..)
  4783. */
  4784. private _storedAlpha;
  4785. private _storedBeta;
  4786. private _storedRadius;
  4787. private _storedTarget;
  4788. storeState(): Camera;
  4789. /**
  4790. * Restored camera state. You must call storeState() first
  4791. */
  4792. _restoreStateValues(): boolean;
  4793. _isSynchronizedViewMatrix(): boolean;
  4794. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  4795. detachControl(element: HTMLElement): void;
  4796. _checkInputs(): void;
  4797. protected _checkLimits(): void;
  4798. rebuildAnglesAndRadius(): void;
  4799. setPosition(position: Vector3): void;
  4800. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  4801. _getViewMatrix(): Matrix;
  4802. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  4803. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  4804. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  4805. min: Vector3;
  4806. max: Vector3;
  4807. distance: number;
  4808. }, doNotUpdateMaxZ?: boolean): void;
  4809. /**
  4810. * @override
  4811. * Override Camera.createRigCamera
  4812. */
  4813. createRigCamera(name: string, cameraIndex: number): Camera;
  4814. /**
  4815. * @override
  4816. * Override Camera._updateRigCameras
  4817. */
  4818. _updateRigCameras(): void;
  4819. dispose(): void;
  4820. getClassName(): string;
  4821. }
  4822. }
  4823. declare module BABYLON {
  4824. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  4825. constructor(camera: ArcRotateCamera);
  4826. addMouseWheel(): ArcRotateCameraInputsManager;
  4827. addPointers(): ArcRotateCameraInputsManager;
  4828. addKeyboard(): ArcRotateCameraInputsManager;
  4829. addGamepad(): ArcRotateCameraInputsManager;
  4830. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  4831. }
  4832. }
  4833. declare module BABYLON {
  4834. class Camera extends Node {
  4835. inputs: CameraInputsManager<Camera>;
  4836. private static _PERSPECTIVE_CAMERA;
  4837. private static _ORTHOGRAPHIC_CAMERA;
  4838. private static _FOVMODE_VERTICAL_FIXED;
  4839. private static _FOVMODE_HORIZONTAL_FIXED;
  4840. private static _RIG_MODE_NONE;
  4841. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  4842. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  4843. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  4844. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  4845. private static _RIG_MODE_VR;
  4846. private static _RIG_MODE_WEBVR;
  4847. static readonly PERSPECTIVE_CAMERA: number;
  4848. static readonly ORTHOGRAPHIC_CAMERA: number;
  4849. /**
  4850. * This is the default FOV mode for perspective cameras.
  4851. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  4852. *
  4853. */
  4854. static readonly FOVMODE_VERTICAL_FIXED: number;
  4855. /**
  4856. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  4857. *
  4858. */
  4859. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  4860. static readonly RIG_MODE_NONE: number;
  4861. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  4862. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  4863. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  4864. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  4865. static readonly RIG_MODE_VR: number;
  4866. static readonly RIG_MODE_WEBVR: number;
  4867. static ForceAttachControlToAlwaysPreventDefault: boolean;
  4868. static UseAlternateWebVRRendering: boolean;
  4869. position: Vector3;
  4870. /**
  4871. * The vector the camera should consider as up.
  4872. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  4873. */
  4874. upVector: Vector3;
  4875. orthoLeft: Nullable<number>;
  4876. orthoRight: Nullable<number>;
  4877. orthoBottom: Nullable<number>;
  4878. orthoTop: Nullable<number>;
  4879. /**
  4880. * FOV is set in Radians. (default is 0.8)
  4881. */
  4882. fov: number;
  4883. minZ: number;
  4884. maxZ: number;
  4885. inertia: number;
  4886. mode: number;
  4887. isIntermediate: boolean;
  4888. viewport: Viewport;
  4889. /**
  4890. * Restricts the camera to viewing objects with the same layerMask.
  4891. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  4892. */
  4893. layerMask: number;
  4894. /**
  4895. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  4896. */
  4897. fovMode: number;
  4898. cameraRigMode: number;
  4899. interaxialDistance: number;
  4900. isStereoscopicSideBySide: boolean;
  4901. _cameraRigParams: any;
  4902. _rigCameras: Camera[];
  4903. _rigPostProcess: Nullable<PostProcess>;
  4904. protected _webvrViewMatrix: Matrix;
  4905. _skipRendering: boolean;
  4906. _alternateCamera: Camera;
  4907. customRenderTargets: RenderTargetTexture[];
  4908. onViewMatrixChangedObservable: Observable<Camera>;
  4909. onProjectionMatrixChangedObservable: Observable<Camera>;
  4910. onAfterCheckInputsObservable: Observable<Camera>;
  4911. onRestoreStateObservable: Observable<Camera>;
  4912. private _computedViewMatrix;
  4913. _projectionMatrix: Matrix;
  4914. private _doNotComputeProjectionMatrix;
  4915. private _worldMatrix;
  4916. _postProcesses: Nullable<PostProcess>[];
  4917. private _transformMatrix;
  4918. _activeMeshes: SmartArray<AbstractMesh>;
  4919. private _globalPosition;
  4920. private _frustumPlanes;
  4921. private _refreshFrustumPlanes;
  4922. constructor(name: string, position: Vector3, scene: Scene);
  4923. private _storedFov;
  4924. private _stateStored;
  4925. /**
  4926. * Store current camera state (fov, position, etc..)
  4927. */
  4928. storeState(): Camera;
  4929. /**
  4930. * Restores the camera state values if it has been stored. You must call storeState() first
  4931. */
  4932. protected _restoreStateValues(): boolean;
  4933. /**
  4934. * Restored camera state. You must call storeState() first
  4935. */
  4936. restoreState(): boolean;
  4937. getClassName(): string;
  4938. /**
  4939. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4940. */
  4941. toString(fullDetails?: boolean): string;
  4942. readonly globalPosition: Vector3;
  4943. getActiveMeshes(): SmartArray<AbstractMesh>;
  4944. isActiveMesh(mesh: Mesh): boolean;
  4945. /**
  4946. * Is this camera ready to be used/rendered
  4947. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  4948. * @return true if the camera is ready
  4949. */
  4950. isReady(completeCheck?: boolean): boolean;
  4951. _initCache(): void;
  4952. _updateCache(ignoreParentClass?: boolean): void;
  4953. _isSynchronized(): boolean;
  4954. _isSynchronizedViewMatrix(): boolean;
  4955. _isSynchronizedProjectionMatrix(): boolean;
  4956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  4957. detachControl(element: HTMLElement): void;
  4958. update(): void;
  4959. _checkInputs(): void;
  4960. readonly rigCameras: Camera[];
  4961. readonly rigPostProcess: Nullable<PostProcess>;
  4962. /**
  4963. * Internal, gets the first post proces.
  4964. * @returns the first post process to be run on this camera.
  4965. */
  4966. _getFirstPostProcess(): Nullable<PostProcess>;
  4967. private _cascadePostProcessesToRigCams();
  4968. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  4969. detachPostProcess(postProcess: PostProcess): void;
  4970. getWorldMatrix(): Matrix;
  4971. _getViewMatrix(): Matrix;
  4972. getViewMatrix(force?: boolean): Matrix;
  4973. freezeProjectionMatrix(projection?: Matrix): void;
  4974. unfreezeProjectionMatrix(): void;
  4975. getProjectionMatrix(force?: boolean): Matrix;
  4976. getTranformationMatrix(): Matrix;
  4977. private updateFrustumPlanes();
  4978. isInFrustum(target: ICullable): boolean;
  4979. isCompletelyInFrustum(target: ICullable): boolean;
  4980. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  4981. /**
  4982. * Releases resources associated with this node.
  4983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  4984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  4985. */
  4986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  4987. readonly leftCamera: Nullable<FreeCamera>;
  4988. readonly rightCamera: Nullable<FreeCamera>;
  4989. getLeftTarget(): Nullable<Vector3>;
  4990. getRightTarget(): Nullable<Vector3>;
  4991. setCameraRigMode(mode: number, rigParams: any): void;
  4992. private _getVRProjectionMatrix();
  4993. protected _updateCameraRotationMatrix(): void;
  4994. protected _updateWebVRCameraRotationMatrix(): void;
  4995. /**
  4996. * This function MUST be overwritten by the different WebVR cameras available.
  4997. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4998. */
  4999. protected _getWebVRProjectionMatrix(): Matrix;
  5000. /**
  5001. * This function MUST be overwritten by the different WebVR cameras available.
  5002. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5003. */
  5004. protected _getWebVRViewMatrix(): Matrix;
  5005. setCameraRigParameter(name: string, value: any): void;
  5006. /**
  5007. * needs to be overridden by children so sub has required properties to be copied
  5008. */
  5009. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5010. /**
  5011. * May need to be overridden by children
  5012. */
  5013. _updateRigCameras(): void;
  5014. _setupInputs(): void;
  5015. serialize(): any;
  5016. clone(name: string): Camera;
  5017. getDirection(localAxis: Vector3): Vector3;
  5018. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5019. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5020. computeWorldMatrix(): Matrix;
  5021. static Parse(parsedCamera: any, scene: Scene): Camera;
  5022. }
  5023. }
  5024. declare module BABYLON {
  5025. var CameraInputTypes: {};
  5026. interface ICameraInput<TCamera extends Camera> {
  5027. camera: Nullable<TCamera>;
  5028. getClassName(): string;
  5029. getSimpleName(): string;
  5030. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5031. detachControl: (element: Nullable<HTMLElement>) => void;
  5032. checkInputs?: () => void;
  5033. }
  5034. interface CameraInputsMap<TCamera extends Camera> {
  5035. [name: string]: ICameraInput<TCamera>;
  5036. [idx: number]: ICameraInput<TCamera>;
  5037. }
  5038. class CameraInputsManager<TCamera extends Camera> {
  5039. attached: CameraInputsMap<TCamera>;
  5040. attachedElement: Nullable<HTMLElement>;
  5041. noPreventDefault: boolean;
  5042. camera: TCamera;
  5043. checkInputs: () => void;
  5044. constructor(camera: TCamera);
  5045. /**
  5046. * Add an input method to a camera.
  5047. * builtin inputs example: camera.inputs.addGamepad();
  5048. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5049. * @param input camera input method
  5050. */
  5051. add(input: ICameraInput<TCamera>): void;
  5052. /**
  5053. * Remove a specific input method from a camera
  5054. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5055. * @param inputToRemove camera input method
  5056. */
  5057. remove(inputToRemove: ICameraInput<TCamera>): void;
  5058. removeByType(inputType: string): void;
  5059. private _addCheckInputs(fn);
  5060. attachInput(input: ICameraInput<TCamera>): void;
  5061. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5062. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5063. rebuildInputCheck(): void;
  5064. /**
  5065. * Remove all attached input methods from a camera
  5066. */
  5067. clear(): void;
  5068. serialize(serializedCamera: any): void;
  5069. parse(parsedCamera: any): void;
  5070. }
  5071. }
  5072. declare module BABYLON {
  5073. /**
  5074. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5075. * being tilted forward or back and left or right.
  5076. */
  5077. class DeviceOrientationCamera extends FreeCamera {
  5078. private _initialQuaternion;
  5079. private _quaternionCache;
  5080. /**
  5081. * Creates a new device orientation camera
  5082. * @param name The name of the camera
  5083. * @param position The start position camera
  5084. * @param scene The scene the camera belongs to
  5085. */
  5086. constructor(name: string, position: Vector3, scene: Scene);
  5087. /**
  5088. * Gets the current instance class name ("DeviceOrientationCamera").
  5089. * This helps avoiding instanceof at run time.
  5090. * @returns the class name
  5091. */
  5092. getClassName(): string;
  5093. /**
  5094. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5095. */
  5096. _checkInputs(): void;
  5097. /**
  5098. * Reset the camera to its default orientation on the specified axis only.
  5099. * @param axis The axis to reset
  5100. */
  5101. resetToCurrentRotation(axis?: Axis): void;
  5102. }
  5103. }
  5104. declare module BABYLON {
  5105. class FollowCamera extends TargetCamera {
  5106. radius: number;
  5107. rotationOffset: number;
  5108. heightOffset: number;
  5109. cameraAcceleration: number;
  5110. maxCameraSpeed: number;
  5111. lockedTarget: Nullable<AbstractMesh>;
  5112. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5113. private getRadians(degrees);
  5114. private follow(cameraTarget);
  5115. _checkInputs(): void;
  5116. getClassName(): string;
  5117. }
  5118. class ArcFollowCamera extends TargetCamera {
  5119. alpha: number;
  5120. beta: number;
  5121. radius: number;
  5122. target: Nullable<AbstractMesh>;
  5123. private _cartesianCoordinates;
  5124. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5125. private follow();
  5126. _checkInputs(): void;
  5127. getClassName(): string;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. class FreeCamera extends TargetCamera {
  5132. ellipsoid: Vector3;
  5133. ellipsoidOffset: Vector3;
  5134. checkCollisions: boolean;
  5135. applyGravity: boolean;
  5136. inputs: FreeCameraInputsManager;
  5137. /**
  5138. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5139. * Higher values reduce sensitivity.
  5140. */
  5141. /**
  5142. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5143. * Higher values reduce sensitivity.
  5144. */
  5145. angularSensibility: number;
  5146. keysUp: number[];
  5147. keysDown: number[];
  5148. keysLeft: number[];
  5149. keysRight: number[];
  5150. onCollide: (collidedMesh: AbstractMesh) => void;
  5151. private _collider;
  5152. private _needMoveForGravity;
  5153. private _oldPosition;
  5154. private _diffPosition;
  5155. private _newPosition;
  5156. _localDirection: Vector3;
  5157. _transformedDirection: Vector3;
  5158. constructor(name: string, position: Vector3, scene: Scene);
  5159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5160. detachControl(element: HTMLElement): void;
  5161. private _collisionMask;
  5162. collisionMask: number;
  5163. _collideWithWorld(displacement: Vector3): void;
  5164. private _onCollisionPositionChange;
  5165. _checkInputs(): void;
  5166. _decideIfNeedsToMove(): boolean;
  5167. _updatePosition(): void;
  5168. dispose(): void;
  5169. getClassName(): string;
  5170. }
  5171. }
  5172. declare module BABYLON {
  5173. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5174. constructor(camera: FreeCamera);
  5175. addKeyboard(): FreeCameraInputsManager;
  5176. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5177. addGamepad(): FreeCameraInputsManager;
  5178. addDeviceOrientation(): FreeCameraInputsManager;
  5179. addTouch(): FreeCameraInputsManager;
  5180. addVirtualJoystick(): FreeCameraInputsManager;
  5181. }
  5182. }
  5183. declare module BABYLON {
  5184. class GamepadCamera extends UniversalCamera {
  5185. gamepadAngularSensibility: number;
  5186. gamepadMoveSensibility: number;
  5187. constructor(name: string, position: Vector3, scene: Scene);
  5188. getClassName(): string;
  5189. }
  5190. }
  5191. declare module BABYLON {
  5192. class AnaglyphFreeCamera extends FreeCamera {
  5193. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5194. getClassName(): string;
  5195. }
  5196. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  5197. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  5198. getClassName(): string;
  5199. }
  5200. class AnaglyphGamepadCamera extends GamepadCamera {
  5201. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5202. getClassName(): string;
  5203. }
  5204. class AnaglyphUniversalCamera extends UniversalCamera {
  5205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5206. getClassName(): string;
  5207. }
  5208. class StereoscopicFreeCamera extends FreeCamera {
  5209. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5210. getClassName(): string;
  5211. }
  5212. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  5213. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5214. getClassName(): string;
  5215. }
  5216. class StereoscopicGamepadCamera extends GamepadCamera {
  5217. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5218. getClassName(): string;
  5219. }
  5220. class StereoscopicUniversalCamera extends UniversalCamera {
  5221. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5222. getClassName(): string;
  5223. }
  5224. }
  5225. declare module BABYLON {
  5226. class TargetCamera extends Camera {
  5227. cameraDirection: Vector3;
  5228. cameraRotation: Vector2;
  5229. rotation: Vector3;
  5230. rotationQuaternion: Quaternion;
  5231. speed: number;
  5232. noRotationConstraint: boolean;
  5233. lockedTarget: any;
  5234. _currentTarget: Vector3;
  5235. _viewMatrix: Matrix;
  5236. _camMatrix: Matrix;
  5237. _cameraTransformMatrix: Matrix;
  5238. _cameraRotationMatrix: Matrix;
  5239. private _rigCamTransformMatrix;
  5240. _referencePoint: Vector3;
  5241. private _currentUpVector;
  5242. _transformedReferencePoint: Vector3;
  5243. _lookAtTemp: Matrix;
  5244. _tempMatrix: Matrix;
  5245. _reset: () => void;
  5246. constructor(name: string, position: Vector3, scene: Scene);
  5247. getFrontPosition(distance: number): Vector3;
  5248. _getLockedTargetPosition(): Nullable<Vector3>;
  5249. /**
  5250. * Store current camera state (fov, position, etc..)
  5251. */
  5252. private _storedPosition;
  5253. private _storedRotation;
  5254. private _storedRotationQuaternion;
  5255. storeState(): Camera;
  5256. /**
  5257. * Restored camera state. You must call storeState() first
  5258. */
  5259. _restoreStateValues(): boolean;
  5260. _initCache(): void;
  5261. _updateCache(ignoreParentClass?: boolean): void;
  5262. _isSynchronizedViewMatrix(): boolean;
  5263. _computeLocalCameraSpeed(): number;
  5264. setTarget(target: Vector3): void;
  5265. /**
  5266. * Return the current target position of the camera. This value is expressed in local space.
  5267. */
  5268. getTarget(): Vector3;
  5269. _decideIfNeedsToMove(): boolean;
  5270. _updatePosition(): void;
  5271. _checkInputs(): void;
  5272. protected _updateCameraRotationMatrix(): void;
  5273. _getViewMatrix(): Matrix;
  5274. /**
  5275. * @override
  5276. * Override Camera.createRigCamera
  5277. */
  5278. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5279. /**
  5280. * @override
  5281. * Override Camera._updateRigCameras
  5282. */
  5283. _updateRigCameras(): void;
  5284. private _getRigCamPosition(halfSpace, result);
  5285. getClassName(): string;
  5286. }
  5287. }
  5288. declare module BABYLON {
  5289. class TouchCamera extends FreeCamera {
  5290. touchAngularSensibility: number;
  5291. touchMoveSensibility: number;
  5292. constructor(name: string, position: Vector3, scene: Scene);
  5293. getClassName(): string;
  5294. _setupInputs(): void;
  5295. }
  5296. }
  5297. declare module BABYLON {
  5298. class UniversalCamera extends TouchCamera {
  5299. gamepadAngularSensibility: number;
  5300. gamepadMoveSensibility: number;
  5301. constructor(name: string, position: Vector3, scene: Scene);
  5302. getClassName(): string;
  5303. }
  5304. }
  5305. declare module BABYLON {
  5306. class VirtualJoysticksCamera extends FreeCamera {
  5307. constructor(name: string, position: Vector3, scene: Scene);
  5308. getClassName(): string;
  5309. }
  5310. }
  5311. interface VRDisplay extends EventTarget {
  5312. /**
  5313. * Dictionary of capabilities describing the VRDisplay.
  5314. */
  5315. readonly capabilities: VRDisplayCapabilities;
  5316. /**
  5317. * z-depth defining the far plane of the eye view frustum
  5318. * enables mapping of values in the render target depth
  5319. * attachment to scene coordinates. Initially set to 10000.0.
  5320. */
  5321. depthFar: number;
  5322. /**
  5323. * z-depth defining the near plane of the eye view frustum
  5324. * enables mapping of values in the render target depth
  5325. * attachment to scene coordinates. Initially set to 0.01.
  5326. */
  5327. depthNear: number;
  5328. /**
  5329. * An identifier for this distinct VRDisplay. Used as an
  5330. * association point in the Gamepad API.
  5331. */
  5332. readonly displayId: number;
  5333. /**
  5334. * A display name, a user-readable name identifying it.
  5335. */
  5336. readonly displayName: string;
  5337. readonly isConnected: boolean;
  5338. readonly isPresenting: boolean;
  5339. /**
  5340. * If this VRDisplay supports room-scale experiences, the optional
  5341. * stage attribute contains details on the room-scale parameters.
  5342. */
  5343. readonly stageParameters: VRStageParameters | null;
  5344. /**
  5345. * Passing the value returned by `requestAnimationFrame` to
  5346. * `cancelAnimationFrame` will unregister the callback.
  5347. */
  5348. cancelAnimationFrame(handle: number): void;
  5349. /**
  5350. * Stops presenting to the VRDisplay.
  5351. */
  5352. exitPresent(): Promise<void>;
  5353. getEyeParameters(whichEye: string): VREyeParameters;
  5354. /**
  5355. * Populates the passed VRFrameData with the information required to render
  5356. * the current frame.
  5357. */
  5358. getFrameData(frameData: VRFrameData): boolean;
  5359. /**
  5360. * Get the layers currently being presented.
  5361. */
  5362. getLayers(): VRLayer[];
  5363. /**
  5364. * Return a VRPose containing the future predicted pose of the VRDisplay
  5365. * when the current frame will be presented. The value returned will not
  5366. * change until JavaScript has returned control to the browser.
  5367. *
  5368. * The VRPose will contain the position, orientation, velocity,
  5369. * and acceleration of each of these properties.
  5370. */
  5371. getPose(): VRPose;
  5372. /**
  5373. * Return the current instantaneous pose of the VRDisplay, with no
  5374. * prediction applied.
  5375. */
  5376. getImmediatePose(): VRPose;
  5377. /**
  5378. * The callback passed to `requestAnimationFrame` will be called
  5379. * any time a new frame should be rendered. When the VRDisplay is
  5380. * presenting the callback will be called at the native refresh
  5381. * rate of the HMD. When not presenting this function acts
  5382. * identically to how window.requestAnimationFrame acts. Content should
  5383. * make no assumptions of frame rate or vsync behavior as the HMD runs
  5384. * asynchronously from other displays and at differing refresh rates.
  5385. */
  5386. requestAnimationFrame(callback: FrameRequestCallback): number;
  5387. /**
  5388. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  5389. * Repeat calls while already presenting will update the VRLayers being displayed.
  5390. */
  5391. requestPresent(layers: VRLayer[]): Promise<void>;
  5392. /**
  5393. * Reset the pose for this display, treating its current position and
  5394. * orientation as the "origin/zero" values. VRPose.position,
  5395. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  5396. * updated when calling resetPose(). This should be called in only
  5397. * sitting-space experiences.
  5398. */
  5399. resetPose(): void;
  5400. /**
  5401. * The VRLayer provided to the VRDisplay will be captured and presented
  5402. * in the HMD. Calling this function has the same effect on the source
  5403. * canvas as any other operation that uses its source image, and canvases
  5404. * created without preserveDrawingBuffer set to true will be cleared.
  5405. */
  5406. submitFrame(pose?: VRPose): void;
  5407. }
  5408. declare var VRDisplay: {
  5409. prototype: VRDisplay;
  5410. new (): VRDisplay;
  5411. };
  5412. interface VRLayer {
  5413. leftBounds?: number[] | null;
  5414. rightBounds?: number[] | null;
  5415. source?: HTMLCanvasElement | null;
  5416. }
  5417. interface VRDisplayCapabilities {
  5418. readonly canPresent: boolean;
  5419. readonly hasExternalDisplay: boolean;
  5420. readonly hasOrientation: boolean;
  5421. readonly hasPosition: boolean;
  5422. readonly maxLayers: number;
  5423. }
  5424. interface VREyeParameters {
  5425. /** @deprecated */
  5426. readonly fieldOfView: VRFieldOfView;
  5427. readonly offset: Float32Array;
  5428. readonly renderHeight: number;
  5429. readonly renderWidth: number;
  5430. }
  5431. interface VRFieldOfView {
  5432. readonly downDegrees: number;
  5433. readonly leftDegrees: number;
  5434. readonly rightDegrees: number;
  5435. readonly upDegrees: number;
  5436. }
  5437. interface VRFrameData {
  5438. readonly leftProjectionMatrix: Float32Array;
  5439. readonly leftViewMatrix: Float32Array;
  5440. readonly pose: VRPose;
  5441. readonly rightProjectionMatrix: Float32Array;
  5442. readonly rightViewMatrix: Float32Array;
  5443. readonly timestamp: number;
  5444. }
  5445. interface VRPose {
  5446. readonly angularAcceleration: Float32Array | null;
  5447. readonly angularVelocity: Float32Array | null;
  5448. readonly linearAcceleration: Float32Array | null;
  5449. readonly linearVelocity: Float32Array | null;
  5450. readonly orientation: Float32Array | null;
  5451. readonly position: Float32Array | null;
  5452. readonly timestamp: number;
  5453. }
  5454. interface VRStageParameters {
  5455. sittingToStandingTransform?: Float32Array;
  5456. sizeX?: number;
  5457. sizeY?: number;
  5458. }
  5459. interface Navigator {
  5460. getVRDisplays(): Promise<VRDisplay[]>;
  5461. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  5462. }
  5463. interface Window {
  5464. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  5465. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  5466. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  5467. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5468. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5469. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  5470. }
  5471. interface Gamepad {
  5472. readonly displayId: number;
  5473. }
  5474. declare module BABYLON {
  5475. class DebugLayer {
  5476. private _scene;
  5477. static InspectorURL: string;
  5478. private _inspector;
  5479. private BJSINSPECTOR;
  5480. constructor(scene: Scene);
  5481. /** Creates the inspector window. */
  5482. private _createInspector(config?);
  5483. isVisible(): boolean;
  5484. hide(): void;
  5485. show(config?: {
  5486. popup?: boolean;
  5487. initialTab?: number;
  5488. parentElement?: HTMLElement;
  5489. newColors?: {
  5490. backgroundColor?: string;
  5491. backgroundColorLighter?: string;
  5492. backgroundColorLighter2?: string;
  5493. backgroundColorLighter3?: string;
  5494. color?: string;
  5495. colorTop?: string;
  5496. colorBot?: string;
  5497. };
  5498. }): void;
  5499. }
  5500. }
  5501. declare module BABYLON {
  5502. class Debug {
  5503. static AxesViewer: {
  5504. new (scene: Scene, scaleLines?: number): {
  5505. _xline: Vector3[];
  5506. _yline: Vector3[];
  5507. _zline: Vector3[];
  5508. _xmesh: Nullable<LinesMesh>;
  5509. _ymesh: Nullable<LinesMesh>;
  5510. _zmesh: Nullable<LinesMesh>;
  5511. scene: Nullable<Scene>;
  5512. scaleLines: number;
  5513. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5514. dispose(): void;
  5515. };
  5516. };
  5517. static BoneAxesViewer: {
  5518. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  5519. mesh: Nullable<Mesh>;
  5520. bone: Nullable<Bone>;
  5521. pos: Vector3;
  5522. xaxis: Vector3;
  5523. yaxis: Vector3;
  5524. zaxis: Vector3;
  5525. update(): void;
  5526. dispose(): void;
  5527. _xline: Vector3[];
  5528. _yline: Vector3[];
  5529. _zline: Vector3[];
  5530. _xmesh: Nullable<LinesMesh>;
  5531. _ymesh: Nullable<LinesMesh>;
  5532. _zmesh: Nullable<LinesMesh>;
  5533. scene: Nullable<Scene>;
  5534. scaleLines: number;
  5535. };
  5536. };
  5537. static PhysicsViewer: {
  5538. new (scene: Scene): {
  5539. _impostors: Nullable<PhysicsImpostor>[];
  5540. _meshes: Nullable<AbstractMesh>[];
  5541. _scene: Nullable<Scene>;
  5542. _numMeshes: number;
  5543. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5544. _renderFunction: () => void;
  5545. _debugBoxMesh: Mesh;
  5546. _debugSphereMesh: Mesh;
  5547. _debugMaterial: StandardMaterial;
  5548. _updateDebugMeshes(): void;
  5549. showImpostor(impostor: PhysicsImpostor): void;
  5550. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5551. _getDebugMaterial(scene: Scene): Material;
  5552. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  5553. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  5554. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  5555. dispose(): void;
  5556. };
  5557. };
  5558. static SkeletonViewer: {
  5559. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  5560. color: Color3;
  5561. _scene: Scene;
  5562. _debugLines: Vector3[][];
  5563. _debugMesh: Nullable<LinesMesh>;
  5564. _isEnabled: boolean;
  5565. _renderFunction: () => void;
  5566. skeleton: Skeleton;
  5567. mesh: AbstractMesh;
  5568. autoUpdateBonesMatrices: boolean;
  5569. renderingGroupId: number;
  5570. isEnabled: boolean;
  5571. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  5572. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  5573. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  5574. update(): void;
  5575. dispose(): void;
  5576. };
  5577. };
  5578. }
  5579. }
  5580. declare module BABYLON {
  5581. class RayHelper {
  5582. ray: Nullable<Ray>;
  5583. private _renderPoints;
  5584. private _renderLine;
  5585. private _renderFunction;
  5586. private _scene;
  5587. private _updateToMeshFunction;
  5588. private _attachedToMesh;
  5589. private _meshSpaceDirection;
  5590. private _meshSpaceOrigin;
  5591. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5592. constructor(ray: Ray);
  5593. show(scene: Scene, color: Color3): void;
  5594. hide(): void;
  5595. private _render();
  5596. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5597. detachFromMesh(): void;
  5598. private _updateToMesh();
  5599. dispose(): void;
  5600. }
  5601. }
  5602. declare module BABYLON {
  5603. class KeyboardEventTypes {
  5604. static _KEYDOWN: number;
  5605. static _KEYUP: number;
  5606. static readonly KEYDOWN: number;
  5607. static readonly KEYUP: number;
  5608. }
  5609. class KeyboardInfo {
  5610. type: number;
  5611. event: KeyboardEvent;
  5612. constructor(type: number, event: KeyboardEvent);
  5613. }
  5614. /**
  5615. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5616. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5617. */
  5618. class KeyboardInfoPre extends KeyboardInfo {
  5619. constructor(type: number, event: KeyboardEvent);
  5620. skipOnPointerObservable: boolean;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. class PointerEventTypes {
  5625. static _POINTERDOWN: number;
  5626. static _POINTERUP: number;
  5627. static _POINTERMOVE: number;
  5628. static _POINTERWHEEL: number;
  5629. static _POINTERPICK: number;
  5630. static _POINTERTAP: number;
  5631. static _POINTERDOUBLETAP: number;
  5632. static readonly POINTERDOWN: number;
  5633. static readonly POINTERUP: number;
  5634. static readonly POINTERMOVE: number;
  5635. static readonly POINTERWHEEL: number;
  5636. static readonly POINTERPICK: number;
  5637. static readonly POINTERTAP: number;
  5638. static readonly POINTERDOUBLETAP: number;
  5639. }
  5640. class PointerInfoBase {
  5641. type: number;
  5642. event: PointerEvent | MouseWheelEvent;
  5643. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5644. }
  5645. /**
  5646. * This class is used to store pointer related info for the onPrePointerObservable event.
  5647. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5648. */
  5649. class PointerInfoPre extends PointerInfoBase {
  5650. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5651. localPosition: Vector2;
  5652. skipOnPointerObservable: boolean;
  5653. }
  5654. /**
  5655. * This type contains all the data related to a pointer event in Babylon.js.
  5656. * 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.
  5657. */
  5658. class PointerInfo extends PointerInfoBase {
  5659. pickInfo: Nullable<PickingInfo>;
  5660. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5661. }
  5662. }
  5663. declare module BABYLON {
  5664. class InstancingAttributeInfo {
  5665. /**
  5666. * Index/offset of the attribute in the vertex shader
  5667. */
  5668. index: number;
  5669. /**
  5670. * size of the attribute, 1, 2, 3 or 4
  5671. */
  5672. attributeSize: number;
  5673. /**
  5674. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5675. * default is FLOAT
  5676. */
  5677. attribyteType: number;
  5678. /**
  5679. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5680. */
  5681. normalized: boolean;
  5682. /**
  5683. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5684. */
  5685. offset: number;
  5686. /**
  5687. * Name of the GLSL attribute, for debugging purpose only
  5688. */
  5689. attributeName: string;
  5690. }
  5691. /**
  5692. * Define options used to create a render target texture
  5693. */
  5694. class RenderTargetCreationOptions {
  5695. /**
  5696. * Specifies is mipmaps must be generated
  5697. */
  5698. generateMipMaps?: boolean;
  5699. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5700. generateDepthBuffer?: boolean;
  5701. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5702. generateStencilBuffer?: boolean;
  5703. /** Defines texture type (int by default) */
  5704. type?: number;
  5705. /** Defines sampling mode (trilinear by default) */
  5706. samplingMode?: number;
  5707. /** Defines format (RGBA by default) */
  5708. format?: number;
  5709. }
  5710. /**
  5711. * Define options used to create a depth texture
  5712. */
  5713. class DepthTextureCreationOptions {
  5714. /** Specifies whether or not a stencil should be allocated in the texture */
  5715. generateStencil?: boolean;
  5716. /** Specifies whether or not bilinear filtering is enable on the texture */
  5717. bilinearFiltering?: boolean;
  5718. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  5719. comparisonFunction?: number;
  5720. /** Specifies if the created texture is a cube texture */
  5721. isCube?: boolean;
  5722. }
  5723. /**
  5724. * Regroup several parameters relative to the browser in use
  5725. */
  5726. class EngineCapabilities {
  5727. /** The maximum textures image */
  5728. maxTexturesImageUnits: number;
  5729. maxVertexTextureImageUnits: number;
  5730. maxCombinedTexturesImageUnits: number;
  5731. /** The maximum texture size */
  5732. maxTextureSize: number;
  5733. maxCubemapTextureSize: number;
  5734. maxRenderTextureSize: number;
  5735. maxVertexAttribs: number;
  5736. maxVaryingVectors: number;
  5737. maxVertexUniformVectors: number;
  5738. maxFragmentUniformVectors: number;
  5739. standardDerivatives: boolean;
  5740. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  5741. pvrtc: any;
  5742. etc1: any;
  5743. etc2: any;
  5744. astc: any;
  5745. textureFloat: boolean;
  5746. vertexArrayObject: boolean;
  5747. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  5748. maxAnisotropy: number;
  5749. instancedArrays: boolean;
  5750. uintIndices: boolean;
  5751. highPrecisionShaderSupported: boolean;
  5752. fragmentDepthSupported: boolean;
  5753. textureFloatLinearFiltering: boolean;
  5754. textureFloatRender: boolean;
  5755. textureHalfFloat: boolean;
  5756. textureHalfFloatLinearFiltering: boolean;
  5757. textureHalfFloatRender: boolean;
  5758. textureLOD: boolean;
  5759. drawBuffersExtension: boolean;
  5760. depthTextureExtension: boolean;
  5761. colorBufferFloat: boolean;
  5762. timerQuery: EXT_disjoint_timer_query;
  5763. canUseTimestampForTimerQuery: boolean;
  5764. }
  5765. interface EngineOptions extends WebGLContextAttributes {
  5766. limitDeviceRatio?: number;
  5767. autoEnableWebVR?: boolean;
  5768. disableWebGL2Support?: boolean;
  5769. audioEngine?: boolean;
  5770. deterministicLockstep?: boolean;
  5771. lockstepMaxSteps?: number;
  5772. doNotHandleContextLost?: boolean;
  5773. }
  5774. interface IDisplayChangedEventArgs {
  5775. vrDisplay: Nullable<any>;
  5776. vrSupported: boolean;
  5777. }
  5778. /**
  5779. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  5780. */
  5781. class Engine {
  5782. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  5783. static ExceptionList: ({
  5784. key: string;
  5785. capture: string;
  5786. captureConstraint: number;
  5787. targets: string[];
  5788. } | {
  5789. key: string;
  5790. capture: null;
  5791. captureConstraint: null;
  5792. targets: string[];
  5793. })[];
  5794. static Instances: Engine[];
  5795. static readonly LastCreatedEngine: Nullable<Engine>;
  5796. static readonly LastCreatedScene: Nullable<Scene>;
  5797. /**
  5798. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  5799. */
  5800. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  5801. private static _ALPHA_DISABLE;
  5802. private static _ALPHA_ADD;
  5803. private static _ALPHA_COMBINE;
  5804. private static _ALPHA_SUBTRACT;
  5805. private static _ALPHA_MULTIPLY;
  5806. private static _ALPHA_MAXIMIZED;
  5807. private static _ALPHA_ONEONE;
  5808. private static _ALPHA_PREMULTIPLIED;
  5809. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  5810. private static _ALPHA_INTERPOLATE;
  5811. private static _ALPHA_SCREENMODE;
  5812. private static _DELAYLOADSTATE_NONE;
  5813. private static _DELAYLOADSTATE_LOADED;
  5814. private static _DELAYLOADSTATE_LOADING;
  5815. private static _DELAYLOADSTATE_NOTLOADED;
  5816. private static _TEXTUREFORMAT_ALPHA;
  5817. private static _TEXTUREFORMAT_LUMINANCE;
  5818. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  5819. private static _TEXTUREFORMAT_RGB;
  5820. private static _TEXTUREFORMAT_RGBA;
  5821. private static _TEXTUREFORMAT_R32F;
  5822. private static _TEXTUREFORMAT_RG32F;
  5823. private static _TEXTUREFORMAT_RGB32F;
  5824. private static _TEXTUREFORMAT_RGBA32F;
  5825. private static _TEXTURETYPE_UNSIGNED_INT;
  5826. private static _TEXTURETYPE_FLOAT;
  5827. private static _TEXTURETYPE_HALF_FLOAT;
  5828. private static _NEVER;
  5829. private static _ALWAYS;
  5830. private static _LESS;
  5831. private static _EQUAL;
  5832. private static _LEQUAL;
  5833. private static _GREATER;
  5834. private static _GEQUAL;
  5835. private static _NOTEQUAL;
  5836. static readonly NEVER: number;
  5837. static readonly ALWAYS: number;
  5838. static readonly LESS: number;
  5839. static readonly EQUAL: number;
  5840. static readonly LEQUAL: number;
  5841. static readonly GREATER: number;
  5842. static readonly GEQUAL: number;
  5843. static readonly NOTEQUAL: number;
  5844. private static _KEEP;
  5845. private static _REPLACE;
  5846. private static _INCR;
  5847. private static _DECR;
  5848. private static _INVERT;
  5849. private static _INCR_WRAP;
  5850. private static _DECR_WRAP;
  5851. static readonly KEEP: number;
  5852. static readonly REPLACE: number;
  5853. static readonly INCR: number;
  5854. static readonly DECR: number;
  5855. static readonly INVERT: number;
  5856. static readonly INCR_WRAP: number;
  5857. static readonly DECR_WRAP: number;
  5858. static readonly ALPHA_DISABLE: number;
  5859. static readonly ALPHA_ONEONE: number;
  5860. static readonly ALPHA_ADD: number;
  5861. static readonly ALPHA_COMBINE: number;
  5862. static readonly ALPHA_SUBTRACT: number;
  5863. static readonly ALPHA_MULTIPLY: number;
  5864. static readonly ALPHA_MAXIMIZED: number;
  5865. static readonly ALPHA_PREMULTIPLIED: number;
  5866. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  5867. static readonly ALPHA_INTERPOLATE: number;
  5868. static readonly ALPHA_SCREENMODE: number;
  5869. static readonly DELAYLOADSTATE_NONE: number;
  5870. static readonly DELAYLOADSTATE_LOADED: number;
  5871. static readonly DELAYLOADSTATE_LOADING: number;
  5872. static readonly DELAYLOADSTATE_NOTLOADED: number;
  5873. static readonly TEXTUREFORMAT_ALPHA: number;
  5874. static readonly TEXTUREFORMAT_LUMINANCE: number;
  5875. /**
  5876. * R32F
  5877. */
  5878. static readonly TEXTUREFORMAT_R32F: number;
  5879. /**
  5880. * RG32F
  5881. */
  5882. static readonly TEXTUREFORMAT_RG32F: number;
  5883. /**
  5884. * RGB32F
  5885. */
  5886. static readonly TEXTUREFORMAT_RGB32F: number;
  5887. /**
  5888. * RGBA32F
  5889. */
  5890. static readonly TEXTUREFORMAT_RGBA32F: number;
  5891. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  5892. static readonly TEXTUREFORMAT_RGB: number;
  5893. static readonly TEXTUREFORMAT_RGBA: number;
  5894. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  5895. static readonly TEXTURETYPE_FLOAT: number;
  5896. static readonly TEXTURETYPE_HALF_FLOAT: number;
  5897. private static _SCALEMODE_FLOOR;
  5898. private static _SCALEMODE_NEAREST;
  5899. private static _SCALEMODE_CEILING;
  5900. static readonly SCALEMODE_FLOOR: number;
  5901. static readonly SCALEMODE_NEAREST: number;
  5902. static readonly SCALEMODE_CEILING: number;
  5903. static readonly Version: string;
  5904. static CollisionsEpsilon: number;
  5905. static CodeRepository: string;
  5906. static ShadersRepository: string;
  5907. forcePOTTextures: boolean;
  5908. isFullscreen: boolean;
  5909. isPointerLock: boolean;
  5910. cullBackFaces: boolean;
  5911. renderEvenInBackground: boolean;
  5912. preventCacheWipeBetweenFrames: boolean;
  5913. /**
  5914. * To enable/disable IDB support and avoid XHR on .manifest
  5915. **/
  5916. enableOfflineSupport: boolean;
  5917. scenes: Scene[];
  5918. postProcesses: PostProcess[];
  5919. /**
  5920. * Observable event triggered each time the rendering canvas is resized
  5921. */
  5922. onResizeObservable: Observable<Engine>;
  5923. /**
  5924. * Observable event triggered each time the canvas loses focus
  5925. */
  5926. onCanvasBlurObservable: Observable<Engine>;
  5927. /**
  5928. * Observable event triggered each time the canvas gains focus
  5929. */
  5930. onCanvasFocusObservable: Observable<Engine>;
  5931. /**
  5932. * Observable event triggered each time the canvas receives pointerout event
  5933. */
  5934. onCanvasPointerOutObservable: Observable<PointerEvent>;
  5935. /**
  5936. * Observable event triggered before each texture is initialized
  5937. */
  5938. onBeforeTextureInitObservable: Observable<Texture>;
  5939. private _vrDisplay;
  5940. private _vrSupported;
  5941. private _oldSize;
  5942. private _oldHardwareScaleFactor;
  5943. private _vrExclusivePointerMode;
  5944. private _webVRInitPromise;
  5945. readonly isInVRExclusivePointerMode: boolean;
  5946. disableUniformBuffers: boolean;
  5947. _uniformBuffers: UniformBuffer[];
  5948. readonly supportsUniformBuffers: boolean;
  5949. /**
  5950. * Observable raised when the engine begins a new frame
  5951. */
  5952. onBeginFrameObservable: Observable<Engine>;
  5953. /**
  5954. * Observable raised when the engine ends the current frame
  5955. */
  5956. onEndFrameObservable: Observable<Engine>;
  5957. /**
  5958. * Observable raised when the engine is about to compile a shader
  5959. */
  5960. onBeforeShaderCompilationObservable: Observable<Engine>;
  5961. /**
  5962. * Observable raised when the engine has jsut compiled a shader
  5963. */
  5964. onAfterShaderCompilationObservable: Observable<Engine>;
  5965. private _gl;
  5966. private _renderingCanvas;
  5967. private _windowIsBackground;
  5968. private _webGLVersion;
  5969. readonly needPOTTextures: boolean;
  5970. private _badOS;
  5971. readonly badOS: boolean;
  5972. private _badDesktopOS;
  5973. readonly badDesktopOS: boolean;
  5974. /**
  5975. * Gets or sets a value indicating if we want to disable texture binding optmization.
  5976. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  5977. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  5978. */
  5979. disableTextureBindingOptimization: boolean;
  5980. static audioEngine: AudioEngine;
  5981. private _onFocus;
  5982. private _onBlur;
  5983. private _onCanvasPointerOut;
  5984. private _onCanvasBlur;
  5985. private _onCanvasFocus;
  5986. private _onFullscreenChange;
  5987. private _onPointerLockChange;
  5988. private _onVRDisplayPointerRestricted;
  5989. private _onVRDisplayPointerUnrestricted;
  5990. private _onVrDisplayConnect;
  5991. private _onVrDisplayDisconnect;
  5992. private _onVrDisplayPresentChange;
  5993. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  5994. onVRRequestPresentComplete: Observable<boolean>;
  5995. onVRRequestPresentStart: Observable<Engine>;
  5996. private _hardwareScalingLevel;
  5997. protected _caps: EngineCapabilities;
  5998. private _pointerLockRequested;
  5999. private _isStencilEnable;
  6000. private _colorWrite;
  6001. private _loadingScreen;
  6002. _drawCalls: PerfCounter;
  6003. _textureCollisions: PerfCounter;
  6004. private _glVersion;
  6005. private _glRenderer;
  6006. private _glVendor;
  6007. private _videoTextureSupported;
  6008. private _renderingQueueLaunched;
  6009. private _activeRenderLoops;
  6010. private _deterministicLockstep;
  6011. private _lockstepMaxSteps;
  6012. onContextLostObservable: Observable<Engine>;
  6013. onContextRestoredObservable: Observable<Engine>;
  6014. private _onContextLost;
  6015. private _onContextRestored;
  6016. private _contextWasLost;
  6017. private _doNotHandleContextLost;
  6018. private _performanceMonitor;
  6019. private _fps;
  6020. private _deltaTime;
  6021. /**
  6022. * Turn this value on if you want to pause FPS computation when in background
  6023. */
  6024. disablePerformanceMonitorInBackground: boolean;
  6025. readonly performanceMonitor: PerformanceMonitor;
  6026. protected _depthCullingState: _DepthCullingState;
  6027. protected _stencilState: _StencilState;
  6028. protected _alphaState: _AlphaState;
  6029. protected _alphaMode: number;
  6030. private _internalTexturesCache;
  6031. protected _activeChannel: number;
  6032. private _currentTextureChannel;
  6033. protected _boundTexturesCache: {
  6034. [key: string]: Nullable<InternalTexture>;
  6035. };
  6036. protected _currentEffect: Nullable<Effect>;
  6037. protected _currentProgram: Nullable<WebGLProgram>;
  6038. private _compiledEffects;
  6039. private _vertexAttribArraysEnabled;
  6040. protected _cachedViewport: Nullable<Viewport>;
  6041. private _cachedVertexArrayObject;
  6042. protected _cachedVertexBuffers: any;
  6043. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6044. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6045. protected _currentRenderTarget: Nullable<InternalTexture>;
  6046. private _uintIndicesCurrentlySet;
  6047. private _currentBoundBuffer;
  6048. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6049. private _currentBufferPointers;
  6050. private _currentInstanceLocations;
  6051. private _currentInstanceBuffers;
  6052. private _textureUnits;
  6053. private _firstBoundInternalTextureTracker;
  6054. private _lastBoundInternalTextureTracker;
  6055. private _workingCanvas;
  6056. private _workingContext;
  6057. private _rescalePostProcess;
  6058. private _dummyFramebuffer;
  6059. private _externalData;
  6060. private _bindedRenderFunction;
  6061. private _vaoRecordInProgress;
  6062. private _mustWipeVertexAttributes;
  6063. private _emptyTexture;
  6064. private _emptyCubeTexture;
  6065. private _emptyTexture3D;
  6066. private _frameHandler;
  6067. private _nextFreeTextureSlots;
  6068. private _maxSimultaneousTextures;
  6069. private _activeRequests;
  6070. private _texturesSupported;
  6071. private _textureFormatInUse;
  6072. readonly texturesSupported: Array<string>;
  6073. readonly textureFormatInUse: Nullable<string>;
  6074. readonly currentViewport: Nullable<Viewport>;
  6075. readonly emptyTexture: InternalTexture;
  6076. readonly emptyTexture3D: InternalTexture;
  6077. readonly emptyCubeTexture: InternalTexture;
  6078. /**
  6079. * @constructor
  6080. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6081. * @param antialias defines enable antialiasing (default: false)
  6082. * @param options defines further options to be sent to the getContext() function
  6083. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6084. */
  6085. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6086. private _rebuildInternalTextures();
  6087. private _rebuildEffects();
  6088. private _rebuildBuffers();
  6089. private _initGLContext();
  6090. readonly webGLVersion: number;
  6091. /**
  6092. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6093. */
  6094. readonly isStencilEnable: boolean;
  6095. private _prepareWorkingCanvas();
  6096. resetTextureCache(): void;
  6097. isDeterministicLockStep(): boolean;
  6098. getLockstepMaxSteps(): number;
  6099. getGlInfo(): {
  6100. vendor: string;
  6101. renderer: string;
  6102. version: string;
  6103. };
  6104. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6105. getRenderWidth(useScreen?: boolean): number;
  6106. getRenderHeight(useScreen?: boolean): number;
  6107. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6108. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6109. setHardwareScalingLevel(level: number): void;
  6110. getHardwareScalingLevel(): number;
  6111. getLoadedTexturesCache(): InternalTexture[];
  6112. getCaps(): EngineCapabilities;
  6113. /** The number of draw calls submitted last frame */
  6114. readonly drawCalls: number;
  6115. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6116. getDepthFunction(): Nullable<number>;
  6117. setDepthFunction(depthFunc: number): void;
  6118. setDepthFunctionToGreater(): void;
  6119. setDepthFunctionToGreaterOrEqual(): void;
  6120. setDepthFunctionToLess(): void;
  6121. setDepthFunctionToLessOrEqual(): void;
  6122. getStencilBuffer(): boolean;
  6123. setStencilBuffer(enable: boolean): void;
  6124. getStencilMask(): number;
  6125. setStencilMask(mask: number): void;
  6126. getStencilFunction(): number;
  6127. getStencilFunctionReference(): number;
  6128. getStencilFunctionMask(): number;
  6129. setStencilFunction(stencilFunc: number): void;
  6130. setStencilFunctionReference(reference: number): void;
  6131. setStencilFunctionMask(mask: number): void;
  6132. getStencilOperationFail(): number;
  6133. getStencilOperationDepthFail(): number;
  6134. getStencilOperationPass(): number;
  6135. setStencilOperationFail(operation: number): void;
  6136. setStencilOperationDepthFail(operation: number): void;
  6137. setStencilOperationPass(operation: number): void;
  6138. setDitheringState(value: boolean): void;
  6139. setRasterizerState(value: boolean): void;
  6140. /**
  6141. * stop executing a render loop function and remove it from the execution array
  6142. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  6143. */
  6144. stopRenderLoop(renderFunction?: () => void): void;
  6145. _renderLoop(): void;
  6146. /**
  6147. * Register and execute a render loop. The engine can have more than one render function.
  6148. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  6149. * @example
  6150. * engine.runRenderLoop(function () {
  6151. * scene.render()
  6152. * })
  6153. */
  6154. runRenderLoop(renderFunction: () => void): void;
  6155. /**
  6156. * Toggle full screen mode.
  6157. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  6158. * @param {any} options - an options object to be sent to the requestFullscreen function
  6159. */
  6160. switchFullscreen(requestPointerLock: boolean): void;
  6161. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6162. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6163. /**
  6164. * Set the WebGL's viewport
  6165. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  6166. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  6167. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  6168. */
  6169. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6170. /**
  6171. * Directly set the WebGL Viewport
  6172. * The x, y, width & height are directly passed to the WebGL call
  6173. * @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.
  6174. */
  6175. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6176. beginFrame(): void;
  6177. endFrame(): void;
  6178. /**
  6179. * resize the view according to the canvas' size.
  6180. * @example
  6181. * window.addEventListener("resize", function () {
  6182. * engine.resize();
  6183. * });
  6184. */
  6185. resize(): void;
  6186. /**
  6187. * force a specific size of the canvas
  6188. * @param {number} width - the new canvas' width
  6189. * @param {number} height - the new canvas' height
  6190. */
  6191. setSize(width: number, height: number): void;
  6192. isVRDevicePresent(): boolean;
  6193. getVRDevice(): any;
  6194. /**
  6195. * Initializes a webVR display and starts listening to display change events.
  6196. * The onVRDisplayChangedObservable will be notified upon these changes.
  6197. * @returns The onVRDisplayChangedObservable.
  6198. */
  6199. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6200. /**
  6201. * Initializes a webVR display and starts listening to display change events.
  6202. * The onVRDisplayChangedObservable will be notified upon these changes.
  6203. * @returns A promise containing a VRDisplay and if vr is supported.
  6204. */
  6205. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6206. enableVR(): void;
  6207. disableVR(): void;
  6208. private _onVRFullScreenTriggered;
  6209. private _getVRDisplaysAsync();
  6210. /**
  6211. * Binds the frame buffer to the specified texture.
  6212. * @param texture The texture to render to or null for the default canvas
  6213. * @param faceIndex The face of the texture to render to in case of cube texture
  6214. * @param requiredWidth The width of the target to render to
  6215. * @param requiredHeight The height of the target to render to
  6216. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6217. * @param depthStencilTexture The depth stencil texture to use to render
  6218. */
  6219. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6220. private bindUnboundFramebuffer(framebuffer);
  6221. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6222. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6223. generateMipMapsForCubemap(texture: InternalTexture): void;
  6224. flushFramebuffer(): void;
  6225. restoreDefaultFramebuffer(): void;
  6226. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6227. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6228. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6229. private _resetVertexBufferBinding();
  6230. /**
  6231. * Creates a vertex buffer
  6232. * @param data the data for the vertex buffer
  6233. * @returns the new WebGL static buffer
  6234. */
  6235. createVertexBuffer(data: DataArray): WebGLBuffer;
  6236. /**
  6237. * Creates a dynamic vertex buffer
  6238. * @param data the data for the dynamic vertex buffer
  6239. * @returns the new WebGL dynamic buffer
  6240. */
  6241. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  6242. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  6243. /**
  6244. * Updates a dynamic vertex buffer.
  6245. * @param vertexBuffer the vertex buffer to update
  6246. * @param data the data used to update the vertex buffer
  6247. * @param byteOffset the byte offset of the data (optional)
  6248. * @param byteLength the byte length of the data (optional)
  6249. */
  6250. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  6251. private _resetIndexBufferBinding();
  6252. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  6253. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  6254. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  6255. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  6256. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  6257. private bindIndexBuffer(buffer);
  6258. private bindBuffer(buffer, target);
  6259. updateArrayBuffer(data: Float32Array): void;
  6260. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  6261. private _bindIndexBufferWithCache(indexBuffer);
  6262. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  6263. recordVertexArrayObject(vertexBuffers: {
  6264. [key: string]: VertexBuffer;
  6265. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  6266. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  6267. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  6268. private _unbindVertexArrayObject();
  6269. bindBuffers(vertexBuffers: {
  6270. [key: string]: Nullable<VertexBuffer>;
  6271. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  6272. unbindInstanceAttributes(): void;
  6273. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  6274. _releaseBuffer(buffer: WebGLBuffer): boolean;
  6275. createInstancesBuffer(capacity: number): WebGLBuffer;
  6276. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  6277. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  6278. applyStates(): void;
  6279. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  6280. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6281. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6282. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  6283. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6284. private _drawMode(fillMode);
  6285. _releaseEffect(effect: Effect): void;
  6286. _deleteProgram(program: WebGLProgram): void;
  6287. /**
  6288. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  6289. * @param samplers An array of string used to represent textures
  6290. */
  6291. 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;
  6292. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  6293. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6294. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6295. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  6296. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  6297. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  6298. enableEffect(effect: Nullable<Effect>): void;
  6299. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6300. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6301. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6302. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6303. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6304. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6305. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6306. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6307. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6308. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6309. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6310. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6311. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  6312. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  6313. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  6314. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  6315. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  6316. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  6317. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  6318. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  6319. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  6320. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  6321. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  6322. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  6323. /**
  6324. * Sets a Color4 on a uniform variable
  6325. * @param uniform defines the uniform location
  6326. * @param color4 defines the value to be set
  6327. */
  6328. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  6329. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  6330. setZOffset(value: number): void;
  6331. getZOffset(): number;
  6332. setDepthBuffer(enable: boolean): void;
  6333. getDepthWrite(): boolean;
  6334. setDepthWrite(enable: boolean): void;
  6335. setColorWrite(enable: boolean): void;
  6336. getColorWrite(): boolean;
  6337. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  6338. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  6339. getAlphaMode(): number;
  6340. wipeCaches(bruteForce?: boolean): void;
  6341. /**
  6342. * Set the compressed texture format to use, based on the formats you have, and the formats
  6343. * supported by the hardware / browser.
  6344. *
  6345. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  6346. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  6347. * to API arguments needed to compressed textures. This puts the burden on the container
  6348. * generator to house the arcane code for determining these for current & future formats.
  6349. *
  6350. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  6351. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  6352. *
  6353. * Note: The result of this call is not taken into account when a texture is base64.
  6354. *
  6355. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  6356. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  6357. *
  6358. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  6359. * @returns The extension selected.
  6360. */
  6361. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  6362. _createTexture(): WebGLTexture;
  6363. /**
  6364. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  6365. * @param {string} urlArg- This contains one of the following:
  6366. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  6367. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  6368. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  6369. *
  6370. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  6371. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  6372. * @param {Scene} scene- Needed for loading to the correct scene.
  6373. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  6374. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  6375. * @param {callback} onError- Optional callback to be called upon failure.
  6376. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  6377. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  6378. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  6379. *
  6380. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  6381. */
  6382. 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;
  6383. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  6384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  6385. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  6386. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  6387. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  6388. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  6389. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  6390. /**
  6391. * Updates a depth texture Comparison Mode and Function.
  6392. * If the comparison Function is equal to 0, the mode will be set to none.
  6393. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  6394. * @param texture The texture to set the comparison function for
  6395. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  6396. */
  6397. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  6398. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  6399. /**
  6400. * Creates a depth stencil texture.
  6401. * This is only available in WebGL 2 or with the depth texture extension available.
  6402. * @param size The size of face edge in the texture.
  6403. * @param options The options defining the texture.
  6404. * @returns The texture
  6405. */
  6406. createDepthStencilTexture(size: number | {
  6407. width: number;
  6408. height: number;
  6409. }, options: DepthTextureCreationOptions): InternalTexture;
  6410. /**
  6411. * Creates a depth stencil texture.
  6412. * This is only available in WebGL 2 or with the depth texture extension available.
  6413. * @param size The size of face edge in the texture.
  6414. * @param options The options defining the texture.
  6415. * @returns The texture
  6416. */
  6417. private _createDepthStencilTexture(size, options);
  6418. /**
  6419. * Creates a depth stencil cube texture.
  6420. * This is only available in WebGL 2.
  6421. * @param size The size of face edge in the cube texture.
  6422. * @param options The options defining the cube texture.
  6423. * @returns The cube texture
  6424. */
  6425. private _createDepthStencilCubeTexture(size, options);
  6426. /**
  6427. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  6428. * @param renderTarget The render target to set the frame buffer for
  6429. */
  6430. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  6431. createRenderTargetTexture(size: number | {
  6432. width: number;
  6433. height: number;
  6434. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  6435. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  6436. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  6437. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  6438. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  6439. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  6440. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  6441. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  6442. 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;
  6443. 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): InternalTexture;
  6444. private setCubeMapTextureParams(gl, loadMipmap);
  6445. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  6446. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  6447. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  6448. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  6449. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  6450. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  6451. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  6452. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  6453. _releaseFramebufferObjects(texture: InternalTexture): void;
  6454. _releaseTexture(texture: InternalTexture): void;
  6455. private setProgram(program);
  6456. private _boundUniforms;
  6457. bindSamplers(effect: Effect): void;
  6458. private _moveBoundTextureOnTop(internalTexture);
  6459. private _getCorrectTextureChannel(channel, internalTexture);
  6460. private _linkTrackers(previous, next);
  6461. private _removeDesignatedSlot(internalTexture);
  6462. private _activateCurrentTexture();
  6463. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  6464. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  6465. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  6466. /**
  6467. * Binds the output of the passed in post process to the texture channel specified
  6468. * @param channel The channel the texture should be bound to
  6469. * @param postProcess The post process which's output should be bound
  6470. */
  6471. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  6472. unbindAllTextures(): void;
  6473. /**
  6474. * Sets a texture to the according uniform.
  6475. * @param channel The texture channel
  6476. * @param uniform The uniform to set
  6477. * @param texture The texture to apply
  6478. */
  6479. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  6480. /**
  6481. * Sets a depth stencil texture from a render target to the according uniform.
  6482. * @param channel The texture channel
  6483. * @param uniform The uniform to set
  6484. * @param texture The render target texture containing the depth stencil texture to apply
  6485. */
  6486. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  6487. private _bindSamplerUniformToChannel(sourceSlot, destination);
  6488. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  6489. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  6490. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  6491. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  6492. /**
  6493. * Add an externaly attached data from its key.
  6494. * This method call will fail and return false, if such key already exists.
  6495. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  6496. * @param key the unique key that identifies the data
  6497. * @param data the data object to associate to the key for this Engine instance
  6498. * @return true if no such key were already present and the data was added successfully, false otherwise
  6499. */
  6500. addExternalData<T>(key: string, data: T): boolean;
  6501. /**
  6502. * Get an externaly attached data from its key
  6503. * @param key the unique key that identifies the data
  6504. * @return the associated data, if present (can be null), or undefined if not present
  6505. */
  6506. getExternalData<T>(key: string): T;
  6507. /**
  6508. * Get an externaly attached data from its key, create it using a factory if it's not already present
  6509. * @param key the unique key that identifies the data
  6510. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  6511. * @return the associated data, can be null if the factory returned null.
  6512. */
  6513. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  6514. /**
  6515. * Remove an externaly attached data from the Engine instance
  6516. * @param key the unique key that identifies the data
  6517. * @return true if the data was successfully removed, false if it doesn't exist
  6518. */
  6519. removeExternalData(key: string): boolean;
  6520. unbindAllAttributes(): void;
  6521. releaseEffects(): void;
  6522. dispose(): void;
  6523. displayLoadingUI(): void;
  6524. hideLoadingUI(): void;
  6525. loadingScreen: ILoadingScreen;
  6526. loadingUIText: string;
  6527. loadingUIBackgroundColor: string;
  6528. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  6529. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  6530. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  6531. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  6532. getError(): number;
  6533. getFps(): number;
  6534. getDeltaTime(): number;
  6535. private _measureFps();
  6536. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  6537. private _canRenderToFloatFramebuffer();
  6538. private _canRenderToHalfFloatFramebuffer();
  6539. private _canRenderToFramebuffer(type);
  6540. _getWebGLTextureType(type: number): number;
  6541. private _getInternalFormat(format);
  6542. /** @ignore */
  6543. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  6544. _getRGBAMultiSampleBufferFormat(type: number): number;
  6545. createQuery(): WebGLQuery;
  6546. deleteQuery(query: WebGLQuery): Engine;
  6547. isQueryResultAvailable(query: WebGLQuery): boolean;
  6548. getQueryResult(query: WebGLQuery): number;
  6549. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  6550. endOcclusionQuery(algorithmType: number): Engine;
  6551. private _createTimeQuery();
  6552. private _deleteTimeQuery(query);
  6553. private _getTimeQueryResult(query);
  6554. private _getTimeQueryAvailability(query);
  6555. private _currentNonTimestampToken;
  6556. startTimeQuery(): Nullable<_TimeToken>;
  6557. endTimeQuery(token: _TimeToken): int;
  6558. private getGlAlgorithmType(algorithmType);
  6559. createTransformFeedback(): WebGLTransformFeedback;
  6560. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  6561. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  6562. beginTransformFeedback(usePoints?: boolean): void;
  6563. endTransformFeedback(): void;
  6564. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  6565. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  6566. _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;
  6567. /** @ignore */
  6568. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  6569. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  6570. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  6571. static isSupported(): boolean;
  6572. }
  6573. }
  6574. declare module BABYLON {
  6575. class NullEngineOptions {
  6576. renderWidth: number;
  6577. renderHeight: number;
  6578. textureSize: number;
  6579. deterministicLockstep: boolean;
  6580. lockstepMaxSteps: number;
  6581. }
  6582. /**
  6583. * The null engine class provides support for headless version of babylon.js.
  6584. * This can be used in server side scenario or for testing purposes
  6585. */
  6586. class NullEngine extends Engine {
  6587. private _options;
  6588. isDeterministicLockStep(): boolean;
  6589. getLockstepMaxSteps(): number;
  6590. getHardwareScalingLevel(): number;
  6591. constructor(options?: NullEngineOptions);
  6592. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  6593. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  6594. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6595. getRenderWidth(useScreen?: boolean): number;
  6596. getRenderHeight(useScreen?: boolean): number;
  6597. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6598. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  6599. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  6600. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  6601. bindSamplers(effect: Effect): void;
  6602. enableEffect(effect: Effect): void;
  6603. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  6604. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  6605. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  6606. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  6607. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  6608. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  6609. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  6610. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  6611. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  6612. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  6613. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  6614. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  6615. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  6616. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  6617. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  6618. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  6619. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  6620. setFloat(uniform: WebGLUniformLocation, value: number): void;
  6621. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  6622. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  6623. setBool(uniform: WebGLUniformLocation, bool: number): void;
  6624. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  6625. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  6626. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  6627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  6628. bindBuffers(vertexBuffers: {
  6629. [key: string]: VertexBuffer;
  6630. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  6631. wipeCaches(bruteForce?: boolean): void;
  6632. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  6633. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  6634. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6635. _createTexture(): WebGLTexture;
  6636. _releaseTexture(texture: InternalTexture): void;
  6637. 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;
  6638. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  6639. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  6640. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  6641. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6642. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  6643. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  6644. /**
  6645. * Updates a dynamic vertex buffer.
  6646. * @param vertexBuffer the vertex buffer to update
  6647. * @param data the data used to update the vertex buffer
  6648. * @param byteOffset the byte offset of the data (optional)
  6649. * @param byteLength the byte length of the data (optional)
  6650. */
  6651. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  6652. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  6653. _bindTexture(channel: number, texture: InternalTexture): void;
  6654. _releaseBuffer(buffer: WebGLBuffer): boolean;
  6655. }
  6656. }
  6657. interface WebGLRenderingContext {
  6658. readonly RASTERIZER_DISCARD: number;
  6659. readonly DEPTH_COMPONENT24: number;
  6660. readonly TEXTURE_3D: number;
  6661. readonly TEXTURE_2D_ARRAY: number;
  6662. readonly TEXTURE_COMPARE_FUNC: number;
  6663. readonly TEXTURE_COMPARE_MODE: number;
  6664. readonly COMPARE_REF_TO_TEXTURE: number;
  6665. readonly TEXTURE_WRAP_R: number;
  6666. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  6667. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  6668. 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;
  6669. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  6670. readonly TRANSFORM_FEEDBACK: number;
  6671. readonly INTERLEAVED_ATTRIBS: number;
  6672. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  6673. createTransformFeedback(): WebGLTransformFeedback;
  6674. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  6675. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  6676. beginTransformFeedback(primitiveMode: number): void;
  6677. endTransformFeedback(): void;
  6678. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  6679. }
  6680. interface ImageBitmap {
  6681. readonly width: number;
  6682. readonly height: number;
  6683. close(): void;
  6684. }
  6685. interface WebGLQuery extends WebGLObject {
  6686. }
  6687. declare var WebGLQuery: {
  6688. prototype: WebGLQuery;
  6689. new (): WebGLQuery;
  6690. };
  6691. interface WebGLSampler extends WebGLObject {
  6692. }
  6693. declare var WebGLSampler: {
  6694. prototype: WebGLSampler;
  6695. new (): WebGLSampler;
  6696. };
  6697. interface WebGLSync extends WebGLObject {
  6698. }
  6699. declare var WebGLSync: {
  6700. prototype: WebGLSync;
  6701. new (): WebGLSync;
  6702. };
  6703. interface WebGLTransformFeedback extends WebGLObject {
  6704. }
  6705. declare var WebGLTransformFeedback: {
  6706. prototype: WebGLTransformFeedback;
  6707. new (): WebGLTransformFeedback;
  6708. };
  6709. interface WebGLVertexArrayObject extends WebGLObject {
  6710. }
  6711. declare var WebGLVertexArrayObject: {
  6712. prototype: WebGLVertexArrayObject;
  6713. new (): WebGLVertexArrayObject;
  6714. };
  6715. declare module BABYLON {
  6716. class StickValues {
  6717. x: number;
  6718. y: number;
  6719. constructor(x: number, y: number);
  6720. }
  6721. interface GamepadButtonChanges {
  6722. changed: boolean;
  6723. pressChanged: boolean;
  6724. touchChanged: boolean;
  6725. valueChanged: boolean;
  6726. }
  6727. class Gamepad {
  6728. id: string;
  6729. index: number;
  6730. browserGamepad: any;
  6731. type: number;
  6732. private _leftStick;
  6733. private _rightStick;
  6734. _isConnected: boolean;
  6735. private _leftStickAxisX;
  6736. private _leftStickAxisY;
  6737. private _rightStickAxisX;
  6738. private _rightStickAxisY;
  6739. private _onleftstickchanged;
  6740. private _onrightstickchanged;
  6741. static GAMEPAD: number;
  6742. static GENERIC: number;
  6743. static XBOX: number;
  6744. static POSE_ENABLED: number;
  6745. protected _invertLeftStickY: boolean;
  6746. readonly isConnected: boolean;
  6747. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  6748. onleftstickchanged(callback: (values: StickValues) => void): void;
  6749. onrightstickchanged(callback: (values: StickValues) => void): void;
  6750. leftStick: StickValues;
  6751. rightStick: StickValues;
  6752. update(): void;
  6753. dispose(): void;
  6754. }
  6755. class GenericPad extends Gamepad {
  6756. private _buttons;
  6757. private _onbuttondown;
  6758. private _onbuttonup;
  6759. onButtonDownObservable: Observable<number>;
  6760. onButtonUpObservable: Observable<number>;
  6761. onbuttondown(callback: (buttonPressed: number) => void): void;
  6762. onbuttonup(callback: (buttonReleased: number) => void): void;
  6763. constructor(id: string, index: number, browserGamepad: any);
  6764. private _setButtonValue(newValue, currentValue, buttonIndex);
  6765. update(): void;
  6766. dispose(): void;
  6767. }
  6768. }
  6769. declare module BABYLON {
  6770. class GamepadManager {
  6771. private _scene;
  6772. private _babylonGamepads;
  6773. private _oneGamepadConnected;
  6774. _isMonitoring: boolean;
  6775. private _gamepadEventSupported;
  6776. private _gamepadSupport;
  6777. onGamepadConnectedObservable: Observable<Gamepad>;
  6778. onGamepadDisconnectedObservable: Observable<Gamepad>;
  6779. private _onGamepadConnectedEvent;
  6780. private _onGamepadDisconnectedEvent;
  6781. constructor(_scene?: Scene | undefined);
  6782. readonly gamepads: Gamepad[];
  6783. getGamepadByType(type?: number): Nullable<Gamepad>;
  6784. dispose(): void;
  6785. private _addNewGamepad(gamepad);
  6786. private _startMonitoringGamepads();
  6787. private _stopMonitoringGamepads();
  6788. _checkGamepadsStatus(): void;
  6789. private _updateGamepadObjects();
  6790. }
  6791. }
  6792. declare module BABYLON {
  6793. enum Xbox360Button {
  6794. A = 0,
  6795. B = 1,
  6796. X = 2,
  6797. Y = 3,
  6798. Start = 4,
  6799. Back = 5,
  6800. LB = 6,
  6801. RB = 7,
  6802. LeftStick = 8,
  6803. RightStick = 9,
  6804. }
  6805. enum Xbox360Dpad {
  6806. Up = 0,
  6807. Down = 1,
  6808. Left = 2,
  6809. Right = 3,
  6810. }
  6811. class Xbox360Pad extends Gamepad {
  6812. private _leftTrigger;
  6813. private _rightTrigger;
  6814. private _onlefttriggerchanged;
  6815. private _onrighttriggerchanged;
  6816. private _onbuttondown;
  6817. private _onbuttonup;
  6818. private _ondpaddown;
  6819. private _ondpadup;
  6820. onButtonDownObservable: Observable<Xbox360Button>;
  6821. onButtonUpObservable: Observable<Xbox360Button>;
  6822. onPadDownObservable: Observable<Xbox360Dpad>;
  6823. onPadUpObservable: Observable<Xbox360Dpad>;
  6824. private _buttonA;
  6825. private _buttonB;
  6826. private _buttonX;
  6827. private _buttonY;
  6828. private _buttonBack;
  6829. private _buttonStart;
  6830. private _buttonLB;
  6831. private _buttonRB;
  6832. private _buttonLeftStick;
  6833. private _buttonRightStick;
  6834. private _dPadUp;
  6835. private _dPadDown;
  6836. private _dPadLeft;
  6837. private _dPadRight;
  6838. private _isXboxOnePad;
  6839. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  6840. onlefttriggerchanged(callback: (value: number) => void): void;
  6841. onrighttriggerchanged(callback: (value: number) => void): void;
  6842. leftTrigger: number;
  6843. rightTrigger: number;
  6844. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  6845. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  6846. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  6847. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  6848. private _setButtonValue(newValue, currentValue, buttonType);
  6849. private _setDPadValue(newValue, currentValue, buttonType);
  6850. buttonA: number;
  6851. buttonB: number;
  6852. buttonX: number;
  6853. buttonY: number;
  6854. buttonStart: number;
  6855. buttonBack: number;
  6856. buttonLB: number;
  6857. buttonRB: number;
  6858. buttonLeftStick: number;
  6859. buttonRightStick: number;
  6860. dPadUp: number;
  6861. dPadDown: number;
  6862. dPadLeft: number;
  6863. dPadRight: number;
  6864. update(): void;
  6865. dispose(): void;
  6866. }
  6867. }
  6868. declare module BABYLON {
  6869. /**
  6870. * Represents the different options available during the creation of
  6871. * a Environment helper.
  6872. *
  6873. * This can control the default ground, skybox and image processing setup of your scene.
  6874. */
  6875. interface IEnvironmentHelperOptions {
  6876. /**
  6877. * Specifies wether or not to create a ground.
  6878. * True by default.
  6879. */
  6880. createGround: boolean;
  6881. /**
  6882. * Specifies the ground size.
  6883. * 15 by default.
  6884. */
  6885. groundSize: number;
  6886. /**
  6887. * The texture used on the ground for the main color.
  6888. * Comes from the BabylonJS CDN by default.
  6889. *
  6890. * Remarks: Can be either a texture or a url.
  6891. */
  6892. groundTexture: string | BaseTexture;
  6893. /**
  6894. * The color mixed in the ground texture by default.
  6895. * BabylonJS clearColor by default.
  6896. */
  6897. groundColor: Color3;
  6898. /**
  6899. * Specifies the ground opacity.
  6900. * 1 by default.
  6901. */
  6902. groundOpacity: number;
  6903. /**
  6904. * Enables the ground to receive shadows.
  6905. * True by default.
  6906. */
  6907. enableGroundShadow: boolean;
  6908. /**
  6909. * Helps preventing the shadow to be fully black on the ground.
  6910. * 0.5 by default.
  6911. */
  6912. groundShadowLevel: number;
  6913. /**
  6914. * Creates a mirror texture attach to the ground.
  6915. * false by default.
  6916. */
  6917. enableGroundMirror: boolean;
  6918. /**
  6919. * Specifies the ground mirror size ratio.
  6920. * 0.3 by default as the default kernel is 64.
  6921. */
  6922. groundMirrorSizeRatio: number;
  6923. /**
  6924. * Specifies the ground mirror blur kernel size.
  6925. * 64 by default.
  6926. */
  6927. groundMirrorBlurKernel: number;
  6928. /**
  6929. * Specifies the ground mirror visibility amount.
  6930. * 1 by default
  6931. */
  6932. groundMirrorAmount: number;
  6933. /**
  6934. * Specifies the ground mirror reflectance weight.
  6935. * This uses the standard weight of the background material to setup the fresnel effect
  6936. * of the mirror.
  6937. * 1 by default.
  6938. */
  6939. groundMirrorFresnelWeight: number;
  6940. /**
  6941. * Specifies the ground mirror Falloff distance.
  6942. * This can helps reducing the size of the reflection.
  6943. * 0 by Default.
  6944. */
  6945. groundMirrorFallOffDistance: number;
  6946. /**
  6947. * Specifies the ground mirror texture type.
  6948. * Unsigned Int by Default.
  6949. */
  6950. groundMirrorTextureType: number;
  6951. /**
  6952. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  6953. * the shown objects.
  6954. */
  6955. groundYBias: number;
  6956. /**
  6957. * Specifies wether or not to create a skybox.
  6958. * True by default.
  6959. */
  6960. createSkybox: boolean;
  6961. /**
  6962. * Specifies the skybox size.
  6963. * 20 by default.
  6964. */
  6965. skyboxSize: number;
  6966. /**
  6967. * The texture used on the skybox for the main color.
  6968. * Comes from the BabylonJS CDN by default.
  6969. *
  6970. * Remarks: Can be either a texture or a url.
  6971. */
  6972. skyboxTexture: string | BaseTexture;
  6973. /**
  6974. * The color mixed in the skybox texture by default.
  6975. * BabylonJS clearColor by default.
  6976. */
  6977. skyboxColor: Color3;
  6978. /**
  6979. * The background rotation around the Y axis of the scene.
  6980. * This helps aligning the key lights of your scene with the background.
  6981. * 0 by default.
  6982. */
  6983. backgroundYRotation: number;
  6984. /**
  6985. * Compute automatically the size of the elements to best fit with the scene.
  6986. */
  6987. sizeAuto: boolean;
  6988. /**
  6989. * Default position of the rootMesh if autoSize is not true.
  6990. */
  6991. rootPosition: Vector3;
  6992. /**
  6993. * Sets up the image processing in the scene.
  6994. * true by default.
  6995. */
  6996. setupImageProcessing: boolean;
  6997. /**
  6998. * The texture used as your environment texture in the scene.
  6999. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  7000. *
  7001. * Remarks: Can be either a texture or a url.
  7002. */
  7003. environmentTexture: string | BaseTexture;
  7004. /**
  7005. * The value of the exposure to apply to the scene.
  7006. * 0.6 by default if setupImageProcessing is true.
  7007. */
  7008. cameraExposure: number;
  7009. /**
  7010. * The value of the contrast to apply to the scene.
  7011. * 1.6 by default if setupImageProcessing is true.
  7012. */
  7013. cameraContrast: number;
  7014. /**
  7015. * Specifies wether or not tonemapping should be enabled in the scene.
  7016. * true by default if setupImageProcessing is true.
  7017. */
  7018. toneMappingEnabled: boolean;
  7019. }
  7020. /**
  7021. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  7022. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  7023. * It also helps with the default setup of your imageProcessing configuration.
  7024. */
  7025. class EnvironmentHelper {
  7026. /**
  7027. * Default ground texture URL.
  7028. */
  7029. private static _groundTextureCDNUrl;
  7030. /**
  7031. * Default skybox texture URL.
  7032. */
  7033. private static _skyboxTextureCDNUrl;
  7034. /**
  7035. * Default environment texture URL.
  7036. */
  7037. private static _environmentTextureCDNUrl;
  7038. /**
  7039. * Creates the default options for the helper.
  7040. */
  7041. private static _getDefaultOptions();
  7042. private _rootMesh;
  7043. /**
  7044. * Gets the root mesh created by the helper.
  7045. */
  7046. readonly rootMesh: Mesh;
  7047. private _skybox;
  7048. /**
  7049. * Gets the skybox created by the helper.
  7050. */
  7051. readonly skybox: Nullable<Mesh>;
  7052. private _skyboxTexture;
  7053. /**
  7054. * Gets the skybox texture created by the helper.
  7055. */
  7056. readonly skyboxTexture: Nullable<BaseTexture>;
  7057. private _skyboxMaterial;
  7058. /**
  7059. * Gets the skybox material created by the helper.
  7060. */
  7061. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  7062. private _ground;
  7063. /**
  7064. * Gets the ground mesh created by the helper.
  7065. */
  7066. readonly ground: Nullable<Mesh>;
  7067. private _groundTexture;
  7068. /**
  7069. * Gets the ground texture created by the helper.
  7070. */
  7071. readonly groundTexture: Nullable<BaseTexture>;
  7072. private _groundMirror;
  7073. /**
  7074. * Gets the ground mirror created by the helper.
  7075. */
  7076. readonly groundMirror: Nullable<MirrorTexture>;
  7077. /**
  7078. * Gets the ground mirror render list to helps pushing the meshes
  7079. * you wish in the ground reflection.
  7080. */
  7081. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  7082. private _groundMaterial;
  7083. /**
  7084. * Gets the ground material created by the helper.
  7085. */
  7086. readonly groundMaterial: Nullable<BackgroundMaterial>;
  7087. /**
  7088. * Stores the creation options.
  7089. */
  7090. private readonly _scene;
  7091. private _options;
  7092. /**
  7093. * This observable will be notified with any error during the creation of the environment,
  7094. * mainly texture creation errors.
  7095. */
  7096. onErrorObservable: Observable<{
  7097. message?: string;
  7098. exception?: any;
  7099. }>;
  7100. /**
  7101. * constructor
  7102. * @param options
  7103. * @param scene The scene to add the material to
  7104. */
  7105. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  7106. /**
  7107. * Updates the background according to the new options
  7108. * @param options
  7109. */
  7110. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  7111. /**
  7112. * Sets the primary color of all the available elements.
  7113. * @param color
  7114. */
  7115. setMainColor(color: Color3): void;
  7116. /**
  7117. * Setup the image processing according to the specified options.
  7118. */
  7119. private _setupImageProcessing();
  7120. /**
  7121. * Setup the environment texture according to the specified options.
  7122. */
  7123. private _setupEnvironmentTexture();
  7124. /**
  7125. * Setup the background according to the specified options.
  7126. */
  7127. private _setupBackground();
  7128. /**
  7129. * Get the scene sizes according to the setup.
  7130. */
  7131. private _getSceneSize();
  7132. /**
  7133. * Setup the ground according to the specified options.
  7134. */
  7135. private _setupGround(sceneSize);
  7136. /**
  7137. * Setup the ground material according to the specified options.
  7138. */
  7139. private _setupGroundMaterial();
  7140. /**
  7141. * Setup the ground diffuse texture according to the specified options.
  7142. */
  7143. private _setupGroundDiffuseTexture();
  7144. /**
  7145. * Setup the ground mirror texture according to the specified options.
  7146. */
  7147. private _setupGroundMirrorTexture(sceneSize);
  7148. /**
  7149. * Setup the ground to receive the mirror texture.
  7150. */
  7151. private _setupMirrorInGroundMaterial();
  7152. /**
  7153. * Setup the skybox according to the specified options.
  7154. */
  7155. private _setupSkybox(sceneSize);
  7156. /**
  7157. * Setup the skybox material according to the specified options.
  7158. */
  7159. private _setupSkyboxMaterial();
  7160. /**
  7161. * Setup the skybox reflection texture according to the specified options.
  7162. */
  7163. private _setupSkyboxReflectionTexture();
  7164. private _errorHandler;
  7165. /**
  7166. * Dispose all the elements created by the Helper.
  7167. */
  7168. dispose(): void;
  7169. }
  7170. }
  7171. declare module BABYLON {
  7172. /**
  7173. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  7174. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  7175. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  7176. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  7177. */
  7178. class VideoDome extends Node {
  7179. /**
  7180. * The video texture being displayed on the sphere
  7181. */
  7182. protected _videoTexture: VideoTexture;
  7183. /**
  7184. * The skybox material
  7185. */
  7186. protected _material: BackgroundMaterial;
  7187. /**
  7188. * The surface used for the skybox
  7189. */
  7190. protected _mesh: Mesh;
  7191. /**
  7192. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  7193. * Also see the options.resolution property.
  7194. */
  7195. fovMultiplier: number;
  7196. /**
  7197. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  7198. * @param name Element's name, child elements will append suffixes for their own names.
  7199. * @param urlsOrVideo
  7200. * @param options An object containing optional or exposed sub element properties:
  7201. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  7202. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  7203. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  7204. * @param options **loop=true** Automatically loop video on end.
  7205. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  7206. */
  7207. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  7208. resolution?: number;
  7209. clickToPlay?: boolean;
  7210. autoPlay?: boolean;
  7211. loop?: boolean;
  7212. size?: number;
  7213. }, scene: Scene);
  7214. /**
  7215. * Releases resources associated with this node.
  7216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7218. */
  7219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7220. }
  7221. }
  7222. declare module BABYLON {
  7223. /**
  7224. * This class can be used to get instrumentation data from a Babylon engine
  7225. */
  7226. class EngineInstrumentation implements IDisposable {
  7227. engine: Engine;
  7228. private _captureGPUFrameTime;
  7229. private _gpuFrameTimeToken;
  7230. private _gpuFrameTime;
  7231. private _captureShaderCompilationTime;
  7232. private _shaderCompilationTime;
  7233. private _onBeginFrameObserver;
  7234. private _onEndFrameObserver;
  7235. private _onBeforeShaderCompilationObserver;
  7236. private _onAfterShaderCompilationObserver;
  7237. /**
  7238. * Gets the perf counter used for GPU frame time
  7239. */
  7240. readonly gpuFrameTimeCounter: PerfCounter;
  7241. /**
  7242. * Gets the GPU frame time capture status
  7243. */
  7244. /**
  7245. * Enable or disable the GPU frame time capture
  7246. */
  7247. captureGPUFrameTime: boolean;
  7248. /**
  7249. * Gets the perf counter used for shader compilation time
  7250. */
  7251. readonly shaderCompilationTimeCounter: PerfCounter;
  7252. /**
  7253. * Gets the shader compilation time capture status
  7254. */
  7255. /**
  7256. * Enable or disable the shader compilation time capture
  7257. */
  7258. captureShaderCompilationTime: boolean;
  7259. constructor(engine: Engine);
  7260. dispose(): void;
  7261. }
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * This class can be used to get instrumentation data from a Babylon engine
  7266. */
  7267. class SceneInstrumentation implements IDisposable {
  7268. scene: Scene;
  7269. private _captureActiveMeshesEvaluationTime;
  7270. private _activeMeshesEvaluationTime;
  7271. private _captureRenderTargetsRenderTime;
  7272. private _renderTargetsRenderTime;
  7273. private _captureFrameTime;
  7274. private _frameTime;
  7275. private _captureRenderTime;
  7276. private _renderTime;
  7277. private _captureInterFrameTime;
  7278. private _interFrameTime;
  7279. private _captureParticlesRenderTime;
  7280. private _particlesRenderTime;
  7281. private _captureSpritesRenderTime;
  7282. private _spritesRenderTime;
  7283. private _capturePhysicsTime;
  7284. private _physicsTime;
  7285. private _captureAnimationsTime;
  7286. private _animationsTime;
  7287. private _onBeforeActiveMeshesEvaluationObserver;
  7288. private _onAfterActiveMeshesEvaluationObserver;
  7289. private _onBeforeRenderTargetsRenderObserver;
  7290. private _onAfterRenderTargetsRenderObserver;
  7291. private _onAfterRenderObserver;
  7292. private _onBeforeDrawPhaseObserver;
  7293. private _onAfterDrawPhaseObserver;
  7294. private _onBeforeAnimationsObserver;
  7295. private _onBeforeParticlesRenderingObserver;
  7296. private _onAfterParticlesRenderingObserver;
  7297. private _onBeforeSpritesRenderingObserver;
  7298. private _onAfterSpritesRenderingObserver;
  7299. private _onBeforePhysicsObserver;
  7300. private _onAfterPhysicsObserver;
  7301. private _onAfterAnimationsObserver;
  7302. /**
  7303. * Gets the perf counter used for active meshes evaluation time
  7304. */
  7305. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  7306. /**
  7307. * Gets the active meshes evaluation time capture status
  7308. */
  7309. /**
  7310. * Enable or disable the active meshes evaluation time capture
  7311. */
  7312. captureActiveMeshesEvaluationTime: boolean;
  7313. /**
  7314. * Gets the perf counter used for render targets render time
  7315. */
  7316. readonly renderTargetsRenderTimeCounter: PerfCounter;
  7317. /**
  7318. * Gets the render targets render time capture status
  7319. */
  7320. /**
  7321. * Enable or disable the render targets render time capture
  7322. */
  7323. captureRenderTargetsRenderTime: boolean;
  7324. /**
  7325. * Gets the perf counter used for particles render time
  7326. */
  7327. readonly particlesRenderTimeCounter: PerfCounter;
  7328. /**
  7329. * Gets the particles render time capture status
  7330. */
  7331. /**
  7332. * Enable or disable the particles render time capture
  7333. */
  7334. captureParticlesRenderTime: boolean;
  7335. /**
  7336. * Gets the perf counter used for sprites render time
  7337. */
  7338. readonly spritesRenderTimeCounter: PerfCounter;
  7339. /**
  7340. * Gets the sprites render time capture status
  7341. */
  7342. /**
  7343. * Enable or disable the sprites render time capture
  7344. */
  7345. captureSpritesRenderTime: boolean;
  7346. /**
  7347. * Gets the perf counter used for physics time
  7348. */
  7349. readonly physicsTimeCounter: PerfCounter;
  7350. /**
  7351. * Gets the physics time capture status
  7352. */
  7353. /**
  7354. * Enable or disable the physics time capture
  7355. */
  7356. capturePhysicsTime: boolean;
  7357. /**
  7358. * Gets the perf counter used for animations time
  7359. */
  7360. readonly animationsTimeCounter: PerfCounter;
  7361. /**
  7362. * Gets the animations time capture status
  7363. */
  7364. /**
  7365. * Enable or disable the animations time capture
  7366. */
  7367. captureAnimationsTime: boolean;
  7368. /**
  7369. * Gets the perf counter used for frame time capture
  7370. */
  7371. readonly frameTimeCounter: PerfCounter;
  7372. /**
  7373. * Gets the frame time capture status
  7374. */
  7375. /**
  7376. * Enable or disable the frame time capture
  7377. */
  7378. captureFrameTime: boolean;
  7379. /**
  7380. * Gets the perf counter used for inter-frames time capture
  7381. */
  7382. readonly interFrameTimeCounter: PerfCounter;
  7383. /**
  7384. * Gets the inter-frames time capture status
  7385. */
  7386. /**
  7387. * Enable or disable the inter-frames time capture
  7388. */
  7389. captureInterFrameTime: boolean;
  7390. /**
  7391. * Gets the perf counter used for render time capture
  7392. */
  7393. readonly renderTimeCounter: PerfCounter;
  7394. /**
  7395. * Gets the render time capture status
  7396. */
  7397. /**
  7398. * Enable or disable the render time capture
  7399. */
  7400. captureRenderTime: boolean;
  7401. /**
  7402. * Gets the perf counter used for draw calls
  7403. */
  7404. readonly drawCallsCounter: PerfCounter;
  7405. /**
  7406. * Gets the perf counter used for texture collisions
  7407. */
  7408. readonly textureCollisionsCounter: PerfCounter;
  7409. constructor(scene: Scene);
  7410. dispose(): void;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. class _TimeToken {
  7415. _startTimeQuery: Nullable<WebGLQuery>;
  7416. _endTimeQuery: Nullable<WebGLQuery>;
  7417. _timeElapsedQuery: Nullable<WebGLQuery>;
  7418. _timeElapsedQueryEnded: boolean;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Effect layer options. This helps customizing the behaviour
  7424. * of the effect layer.
  7425. */
  7426. interface IEffectLayerOptions {
  7427. /**
  7428. * Multiplication factor apply to the canvas size to compute the render target size
  7429. * used to generated the objects (the smaller the faster).
  7430. */
  7431. mainTextureRatio: number;
  7432. /**
  7433. * Enforces a fixed size texture to ensure effect stability across devices.
  7434. */
  7435. mainTextureFixedSize?: number;
  7436. /**
  7437. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  7438. */
  7439. alphaBlendingMode: number;
  7440. /**
  7441. * The camera attached to the layer.
  7442. */
  7443. camera: Nullable<Camera>;
  7444. }
  7445. /**
  7446. * The effect layer Helps adding post process effect blended with the main pass.
  7447. *
  7448. * This can be for instance use to generate glow or higlight effects on the scene.
  7449. *
  7450. * The effect layer class can not be used directly and is intented to inherited from to be
  7451. * customized per effects.
  7452. */
  7453. abstract class EffectLayer {
  7454. /** The Friendly of the effect in the scene */
  7455. name: string;
  7456. private _vertexBuffers;
  7457. private _indexBuffer;
  7458. private _cachedDefines;
  7459. private _effectLayerMapGenerationEffect;
  7460. private _effectLayerOptions;
  7461. private _mergeEffect;
  7462. protected _scene: Scene;
  7463. protected _engine: Engine;
  7464. protected _maxSize: number;
  7465. protected _mainTextureDesiredSize: ISize;
  7466. protected _mainTexture: RenderTargetTexture;
  7467. protected _shouldRender: boolean;
  7468. protected _postProcesses: PostProcess[];
  7469. protected _textures: BaseTexture[];
  7470. protected _emissiveTextureAndColor: {
  7471. texture: Nullable<BaseTexture>;
  7472. color: Color4;
  7473. };
  7474. /**
  7475. * The clear color of the texture used to generate the glow map.
  7476. */
  7477. neutralColor: Color4;
  7478. /**
  7479. * Specifies wether the highlight layer is enabled or not.
  7480. */
  7481. isEnabled: boolean;
  7482. /**
  7483. * Gets the camera attached to the layer.
  7484. */
  7485. readonly camera: Nullable<Camera>;
  7486. /**
  7487. * An event triggered when the effect layer has been disposed.
  7488. */
  7489. onDisposeObservable: Observable<EffectLayer>;
  7490. /**
  7491. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  7492. */
  7493. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  7494. /**
  7495. * An event triggered when the generated texture is being merged in the scene.
  7496. */
  7497. onBeforeComposeObservable: Observable<EffectLayer>;
  7498. /**
  7499. * An event triggered when the generated texture has been merged in the scene.
  7500. */
  7501. onAfterComposeObservable: Observable<EffectLayer>;
  7502. /**
  7503. * An event triggered when the efffect layer changes its size.
  7504. */
  7505. onSizeChangedObservable: Observable<EffectLayer>;
  7506. /**
  7507. * Instantiates a new effect Layer and references it in the scene.
  7508. * @param name The name of the layer
  7509. * @param scene The scene to use the layer in
  7510. */
  7511. constructor(
  7512. /** The Friendly of the effect in the scene */
  7513. name: string, scene: Scene);
  7514. /**
  7515. * Get the effect name of the layer.
  7516. * @return The effect name
  7517. */
  7518. abstract getEffectName(): string;
  7519. /**
  7520. * Checks for the readiness of the element composing the layer.
  7521. * @param subMesh the mesh to check for
  7522. * @param useInstances specify wether or not to use instances to render the mesh
  7523. * @return true if ready otherwise, false
  7524. */
  7525. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  7526. /**
  7527. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  7528. * @returns true if the effect requires stencil during the main canvas render pass.
  7529. */
  7530. abstract needStencil(): boolean;
  7531. /**
  7532. * Create the merge effect. This is the shader use to blit the information back
  7533. * to the main canvas at the end of the scene rendering.
  7534. * @returns The effect containing the shader used to merge the effect on the main canvas
  7535. */
  7536. protected abstract _createMergeEffect(): Effect;
  7537. /**
  7538. * Creates the render target textures and post processes used in the effect layer.
  7539. */
  7540. protected abstract _createTextureAndPostProcesses(): void;
  7541. /**
  7542. * Implementation specific of rendering the generating effect on the main canvas.
  7543. * @param effect The effect used to render through
  7544. */
  7545. protected abstract _internalRender(effect: Effect): void;
  7546. /**
  7547. * Sets the required values for both the emissive texture and and the main color.
  7548. */
  7549. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  7550. /**
  7551. * Free any resources and references associated to a mesh.
  7552. * Internal use
  7553. * @param mesh The mesh to free.
  7554. */
  7555. abstract _disposeMesh(mesh: Mesh): void;
  7556. /**
  7557. * Initializes the effect layer with the required options.
  7558. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  7559. */
  7560. protected _init(options: Partial<IEffectLayerOptions>): void;
  7561. /**
  7562. * Generates the index buffer of the full screen quad blending to the main canvas.
  7563. */
  7564. private _generateIndexBuffer();
  7565. /**
  7566. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  7567. */
  7568. private _genrateVertexBuffer();
  7569. /**
  7570. * Sets the main texture desired size which is the closest power of two
  7571. * of the engine canvas size.
  7572. */
  7573. private _setMainTextureSize();
  7574. /**
  7575. * Creates the main texture for the effect layer.
  7576. */
  7577. protected _createMainTexture(): void;
  7578. /**
  7579. * Checks for the readiness of the element composing the layer.
  7580. * @param subMesh the mesh to check for
  7581. * @param useInstances specify wether or not to use instances to render the mesh
  7582. * @param emissiveTexture the associated emissive texture used to generate the glow
  7583. * @return true if ready otherwise, false
  7584. */
  7585. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  7586. /**
  7587. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  7588. */
  7589. render(): void;
  7590. /**
  7591. * Determine if a given mesh will be used in the current effect.
  7592. * @param mesh mesh to test
  7593. * @returns true if the mesh will be used
  7594. */
  7595. hasMesh(mesh: AbstractMesh): boolean;
  7596. /**
  7597. * Returns true if the layer contains information to display, otherwise false.
  7598. * @returns true if the glow layer should be rendered
  7599. */
  7600. shouldRender(): boolean;
  7601. /**
  7602. * Returns true if the mesh should render, otherwise false.
  7603. * @param mesh The mesh to render
  7604. * @returns true if it should render otherwise false
  7605. */
  7606. protected _shouldRenderMesh(mesh: Mesh): boolean;
  7607. /**
  7608. * Returns true if the mesh should render, otherwise false.
  7609. * @param mesh The mesh to render
  7610. * @returns true if it should render otherwise false
  7611. */
  7612. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  7613. /**
  7614. * Renders the submesh passed in parameter to the generation map.
  7615. */
  7616. protected _renderSubMesh(subMesh: SubMesh): void;
  7617. /**
  7618. * Rebuild the required buffers.
  7619. * @ignore Internal use only.
  7620. */
  7621. _rebuild(): void;
  7622. /**
  7623. * Dispose only the render target textures and post process.
  7624. */
  7625. private _disposeTextureAndPostProcesses();
  7626. /**
  7627. * Dispose the highlight layer and free resources.
  7628. */
  7629. dispose(): void;
  7630. }
  7631. }
  7632. declare module BABYLON {
  7633. /**
  7634. * Glow layer options. This helps customizing the behaviour
  7635. * of the glow layer.
  7636. */
  7637. interface IGlowLayerOptions {
  7638. /**
  7639. * Multiplication factor apply to the canvas size to compute the render target size
  7640. * used to generated the glowing objects (the smaller the faster).
  7641. */
  7642. mainTextureRatio: number;
  7643. /**
  7644. * Enforces a fixed size texture to ensure resize independant blur.
  7645. */
  7646. mainTextureFixedSize?: number;
  7647. /**
  7648. * How big is the kernel of the blur texture.
  7649. */
  7650. blurKernelSize: number;
  7651. /**
  7652. * The camera attached to the layer.
  7653. */
  7654. camera: Nullable<Camera>;
  7655. /**
  7656. * Enable MSAA by chosing the number of samples.
  7657. */
  7658. mainTextureSamples?: number;
  7659. }
  7660. /**
  7661. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  7662. *
  7663. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  7664. * glowy meshes to your scene.
  7665. *
  7666. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  7667. */
  7668. class GlowLayer extends EffectLayer {
  7669. name: string;
  7670. /**
  7671. * Effect Name of the layer.
  7672. */
  7673. static readonly EffectName: string;
  7674. /**
  7675. * The default blur kernel size used for the glow.
  7676. */
  7677. static DefaultBlurKernelSize: number;
  7678. /**
  7679. * The default texture size ratio used for the glow.
  7680. */
  7681. static DefaultTextureRatio: number;
  7682. /**
  7683. * Gets the kernel size of the blur.
  7684. */
  7685. /**
  7686. * Sets the kernel size of the blur.
  7687. */
  7688. blurKernelSize: number;
  7689. /**
  7690. * Gets the glow intensity.
  7691. */
  7692. /**
  7693. * Sets the glow intensity.
  7694. */
  7695. intensity: number;
  7696. private _options;
  7697. private _intensity;
  7698. private _horizontalBlurPostprocess1;
  7699. private _verticalBlurPostprocess1;
  7700. private _horizontalBlurPostprocess2;
  7701. private _verticalBlurPostprocess2;
  7702. private _blurTexture1;
  7703. private _blurTexture2;
  7704. private _postProcesses1;
  7705. private _postProcesses2;
  7706. private _includedOnlyMeshes;
  7707. private _excludedMeshes;
  7708. /**
  7709. * Callback used to let the user override the color selection on a per mesh basis
  7710. */
  7711. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  7712. /**
  7713. * Callback used to let the user override the texture selection on a per mesh basis
  7714. */
  7715. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  7716. /**
  7717. * Instantiates a new glow Layer and references it to the scene.
  7718. * @param name The name of the layer
  7719. * @param scene The scene to use the layer in
  7720. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  7721. */
  7722. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  7723. /**
  7724. * Get the effect name of the layer.
  7725. * @return The effect name
  7726. */
  7727. getEffectName(): string;
  7728. /**
  7729. * Create the merge effect. This is the shader use to blit the information back
  7730. * to the main canvas at the end of the scene rendering.
  7731. */
  7732. protected _createMergeEffect(): Effect;
  7733. /**
  7734. * Creates the render target textures and post processes used in the glow layer.
  7735. */
  7736. protected _createTextureAndPostProcesses(): void;
  7737. /**
  7738. * Checks for the readiness of the element composing the layer.
  7739. * @param subMesh the mesh to check for
  7740. * @param useInstances specify wether or not to use instances to render the mesh
  7741. * @param emissiveTexture the associated emissive texture used to generate the glow
  7742. * @return true if ready otherwise, false
  7743. */
  7744. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  7745. /**
  7746. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  7747. */
  7748. needStencil(): boolean;
  7749. /**
  7750. * Implementation specific of rendering the generating effect on the main canvas.
  7751. * @param effect The effect used to render through
  7752. */
  7753. protected _internalRender(effect: Effect): void;
  7754. /**
  7755. * Sets the required values for both the emissive texture and and the main color.
  7756. */
  7757. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  7758. /**
  7759. * Returns true if the mesh should render, otherwise false.
  7760. * @param mesh The mesh to render
  7761. * @returns true if it should render otherwise false
  7762. */
  7763. protected _shouldRenderMesh(mesh: Mesh): boolean;
  7764. /**
  7765. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  7766. * @param mesh The mesh to exclude from the glow layer
  7767. */
  7768. addExcludedMesh(mesh: Mesh): void;
  7769. /**
  7770. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  7771. * @param mesh The mesh to remove
  7772. */
  7773. removeExcludedMesh(mesh: Mesh): void;
  7774. /**
  7775. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  7776. * @param mesh The mesh to include in the glow layer
  7777. */
  7778. addIncludedOnlyMesh(mesh: Mesh): void;
  7779. /**
  7780. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  7781. * @param mesh The mesh to remove
  7782. */
  7783. removeIncludedOnlyMesh(mesh: Mesh): void;
  7784. /**
  7785. * Determine if a given mesh will be used in the glow layer
  7786. * @param mesh The mesh to test
  7787. * @returns true if the mesh will be highlighted by the current glow layer
  7788. */
  7789. hasMesh(mesh: AbstractMesh): boolean;
  7790. /**
  7791. * Free any resources and references associated to a mesh.
  7792. * Internal use
  7793. * @param mesh The mesh to free.
  7794. */
  7795. _disposeMesh(mesh: Mesh): void;
  7796. }
  7797. }
  7798. declare module BABYLON {
  7799. /**
  7800. * Highlight layer options. This helps customizing the behaviour
  7801. * of the highlight layer.
  7802. */
  7803. interface IHighlightLayerOptions {
  7804. /**
  7805. * Multiplication factor apply to the canvas size to compute the render target size
  7806. * used to generated the glowing objects (the smaller the faster).
  7807. */
  7808. mainTextureRatio: number;
  7809. /**
  7810. * Enforces a fixed size texture to ensure resize independant blur.
  7811. */
  7812. mainTextureFixedSize?: number;
  7813. /**
  7814. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  7815. * of the picture to blur (the smaller the faster).
  7816. */
  7817. blurTextureSizeRatio: number;
  7818. /**
  7819. * How big in texel of the blur texture is the vertical blur.
  7820. */
  7821. blurVerticalSize: number;
  7822. /**
  7823. * How big in texel of the blur texture is the horizontal blur.
  7824. */
  7825. blurHorizontalSize: number;
  7826. /**
  7827. * Alpha blending mode used to apply the blur. Default is combine.
  7828. */
  7829. alphaBlendingMode: number;
  7830. /**
  7831. * The camera attached to the layer.
  7832. */
  7833. camera: Nullable<Camera>;
  7834. /**
  7835. * Should we display highlight as a solid stroke?
  7836. */
  7837. isStroke?: boolean;
  7838. }
  7839. /**
  7840. * The highlight layer Helps adding a glow effect around a mesh.
  7841. *
  7842. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  7843. * glowy meshes to your scene.
  7844. *
  7845. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  7846. */
  7847. class HighlightLayer extends EffectLayer {
  7848. name: string;
  7849. /**
  7850. * Effect Name of the highlight layer.
  7851. */
  7852. static readonly EffectName: string;
  7853. /**
  7854. * The neutral color used during the preparation of the glow effect.
  7855. * This is black by default as the blend operation is a blend operation.
  7856. */
  7857. static NeutralColor: Color4;
  7858. /**
  7859. * Stencil value used for glowing meshes.
  7860. */
  7861. static GlowingMeshStencilReference: number;
  7862. /**
  7863. * Stencil value used for the other meshes in the scene.
  7864. */
  7865. static NormalMeshStencilReference: number;
  7866. /**
  7867. * Specifies whether or not the inner glow is ACTIVE in the layer.
  7868. */
  7869. innerGlow: boolean;
  7870. /**
  7871. * Specifies whether or not the outer glow is ACTIVE in the layer.
  7872. */
  7873. outerGlow: boolean;
  7874. /**
  7875. * Gets the horizontal size of the blur.
  7876. */
  7877. /**
  7878. * Specifies the horizontal size of the blur.
  7879. */
  7880. blurHorizontalSize: number;
  7881. /**
  7882. * Gets the vertical size of the blur.
  7883. */
  7884. /**
  7885. * Specifies the vertical size of the blur.
  7886. */
  7887. blurVerticalSize: number;
  7888. /**
  7889. * An event triggered when the highlight layer is being blurred.
  7890. */
  7891. onBeforeBlurObservable: Observable<HighlightLayer>;
  7892. /**
  7893. * An event triggered when the highlight layer has been blurred.
  7894. */
  7895. onAfterBlurObservable: Observable<HighlightLayer>;
  7896. private _instanceGlowingMeshStencilReference;
  7897. private _options;
  7898. private _downSamplePostprocess;
  7899. private _horizontalBlurPostprocess;
  7900. private _verticalBlurPostprocess;
  7901. private _blurTexture;
  7902. private _meshes;
  7903. private _excludedMeshes;
  7904. /**
  7905. * Instantiates a new highlight Layer and references it to the scene..
  7906. * @param name The name of the layer
  7907. * @param scene The scene to use the layer in
  7908. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  7909. */
  7910. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  7911. /**
  7912. * Get the effect name of the layer.
  7913. * @return The effect name
  7914. */
  7915. getEffectName(): string;
  7916. /**
  7917. * Create the merge effect. This is the shader use to blit the information back
  7918. * to the main canvas at the end of the scene rendering.
  7919. */
  7920. protected _createMergeEffect(): Effect;
  7921. /**
  7922. * Creates the render target textures and post processes used in the highlight layer.
  7923. */
  7924. protected _createTextureAndPostProcesses(): void;
  7925. /**
  7926. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  7927. */
  7928. needStencil(): boolean;
  7929. /**
  7930. * Checks for the readiness of the element composing the layer.
  7931. * @param subMesh the mesh to check for
  7932. * @param useInstances specify wether or not to use instances to render the mesh
  7933. * @param emissiveTexture the associated emissive texture used to generate the glow
  7934. * @return true if ready otherwise, false
  7935. */
  7936. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  7937. /**
  7938. * Implementation specific of rendering the generating effect on the main canvas.
  7939. * @param effect The effect used to render through
  7940. */
  7941. protected _internalRender(effect: Effect): void;
  7942. /**
  7943. * Returns true if the layer contains information to display, otherwise false.
  7944. */
  7945. shouldRender(): boolean;
  7946. /**
  7947. * Returns true if the mesh should render, otherwise false.
  7948. * @param mesh The mesh to render
  7949. * @returns true if it should render otherwise false
  7950. */
  7951. protected _shouldRenderMesh(mesh: Mesh): boolean;
  7952. /**
  7953. * Sets the required values for both the emissive texture and and the main color.
  7954. */
  7955. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  7956. /**
  7957. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  7958. * @param mesh The mesh to exclude from the highlight layer
  7959. */
  7960. addExcludedMesh(mesh: Mesh): void;
  7961. /**
  7962. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  7963. * @param mesh The mesh to highlight
  7964. */
  7965. removeExcludedMesh(mesh: Mesh): void;
  7966. /**
  7967. * Determine if a given mesh will be highlighted by the current HighlightLayer
  7968. * @param mesh mesh to test
  7969. * @returns true if the mesh will be highlighted by the current HighlightLayer
  7970. */
  7971. hasMesh(mesh: AbstractMesh): boolean;
  7972. /**
  7973. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  7974. * @param mesh The mesh to highlight
  7975. * @param color The color of the highlight
  7976. * @param glowEmissiveOnly Extract the glow from the emissive texture
  7977. */
  7978. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  7979. /**
  7980. * Remove a mesh from the highlight layer in order to make it stop glowing.
  7981. * @param mesh The mesh to highlight
  7982. */
  7983. removeMesh(mesh: Mesh): void;
  7984. /**
  7985. * Force the stencil to the normal expected value for none glowing parts
  7986. */
  7987. private _defaultStencilReference(mesh);
  7988. /**
  7989. * Free any resources and references associated to a mesh.
  7990. * Internal use
  7991. * @param mesh The mesh to free.
  7992. */
  7993. _disposeMesh(mesh: Mesh): void;
  7994. /**
  7995. * Dispose the highlight layer and free resources.
  7996. */
  7997. dispose(): void;
  7998. }
  7999. }
  8000. declare module BABYLON {
  8001. class Layer {
  8002. name: string;
  8003. texture: Nullable<Texture>;
  8004. isBackground: boolean;
  8005. color: Color4;
  8006. scale: Vector2;
  8007. offset: Vector2;
  8008. alphaBlendingMode: number;
  8009. alphaTest: boolean;
  8010. layerMask: number;
  8011. private _scene;
  8012. private _vertexBuffers;
  8013. private _indexBuffer;
  8014. private _effect;
  8015. private _alphaTestEffect;
  8016. /**
  8017. * An event triggered when the layer is disposed.
  8018. */
  8019. onDisposeObservable: Observable<Layer>;
  8020. private _onDisposeObserver;
  8021. onDispose: () => void;
  8022. /**
  8023. * An event triggered before rendering the scene
  8024. */
  8025. onBeforeRenderObservable: Observable<Layer>;
  8026. private _onBeforeRenderObserver;
  8027. onBeforeRender: () => void;
  8028. /**
  8029. * An event triggered after rendering the scene
  8030. */
  8031. onAfterRenderObservable: Observable<Layer>;
  8032. private _onAfterRenderObserver;
  8033. onAfterRender: () => void;
  8034. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  8035. private _createIndexBuffer();
  8036. _rebuild(): void;
  8037. render(): void;
  8038. dispose(): void;
  8039. }
  8040. }
  8041. declare module BABYLON {
  8042. class LensFlare {
  8043. size: number;
  8044. position: number;
  8045. color: Color3;
  8046. texture: Nullable<Texture>;
  8047. alphaMode: number;
  8048. private _system;
  8049. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  8050. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  8051. dispose(): void;
  8052. }
  8053. }
  8054. declare module BABYLON {
  8055. class LensFlareSystem {
  8056. name: string;
  8057. lensFlares: LensFlare[];
  8058. borderLimit: number;
  8059. viewportBorder: number;
  8060. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  8061. layerMask: number;
  8062. id: string;
  8063. private _scene;
  8064. private _emitter;
  8065. private _vertexBuffers;
  8066. private _indexBuffer;
  8067. private _effect;
  8068. private _positionX;
  8069. private _positionY;
  8070. private _isEnabled;
  8071. constructor(name: string, emitter: any, scene: Scene);
  8072. isEnabled: boolean;
  8073. getScene(): Scene;
  8074. getEmitter(): any;
  8075. setEmitter(newEmitter: any): void;
  8076. getEmitterPosition(): Vector3;
  8077. computeEffectivePosition(globalViewport: Viewport): boolean;
  8078. _isVisible(): boolean;
  8079. render(): boolean;
  8080. dispose(): void;
  8081. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  8082. serialize(): any;
  8083. }
  8084. }
  8085. declare module BABYLON {
  8086. interface ILoadingScreen {
  8087. displayLoadingUI: () => void;
  8088. hideLoadingUI: () => void;
  8089. loadingUIBackgroundColor: string;
  8090. loadingUIText: string;
  8091. }
  8092. class DefaultLoadingScreen implements ILoadingScreen {
  8093. private _renderingCanvas;
  8094. private _loadingText;
  8095. private _loadingDivBackgroundColor;
  8096. private _loadingDiv;
  8097. private _loadingTextDiv;
  8098. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  8099. displayLoadingUI(): void;
  8100. hideLoadingUI(): void;
  8101. loadingUIText: string;
  8102. loadingUIBackgroundColor: string;
  8103. private _resizeLoadingUI;
  8104. }
  8105. }
  8106. declare module BABYLON {
  8107. class SceneLoaderProgressEvent {
  8108. readonly lengthComputable: boolean;
  8109. readonly loaded: number;
  8110. readonly total: number;
  8111. constructor(lengthComputable: boolean, loaded: number, total: number);
  8112. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  8113. }
  8114. interface ISceneLoaderPluginExtensions {
  8115. [extension: string]: {
  8116. isBinary: boolean;
  8117. };
  8118. }
  8119. interface ISceneLoaderPluginFactory {
  8120. name: string;
  8121. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  8122. canDirectLoad?: (data: string) => boolean;
  8123. }
  8124. interface ISceneLoaderPlugin {
  8125. /**
  8126. * The friendly name of this plugin.
  8127. */
  8128. name: string;
  8129. /**
  8130. * The file extensions supported by this plugin.
  8131. */
  8132. extensions: string | ISceneLoaderPluginExtensions;
  8133. /**
  8134. * Import meshes into a scene.
  8135. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8136. * @param scene The scene to import into
  8137. * @param data The data to import
  8138. * @param rootUrl The root url for scene and resources
  8139. * @param meshes The meshes array to import into
  8140. * @param particleSystems The particle systems array to import into
  8141. * @param skeletons The skeletons array to import into
  8142. * @param onError The callback when import fails
  8143. * @returns True if successful or false otherwise
  8144. */
  8145. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  8146. /**
  8147. * Load into a scene.
  8148. * @param scene The scene to load into
  8149. * @param data The data to import
  8150. * @param rootUrl The root url for scene and resources
  8151. * @param onError The callback when import fails
  8152. * @returns true if successful or false otherwise
  8153. */
  8154. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  8155. /**
  8156. * The callback that returns true if the data can be directly loaded.
  8157. */
  8158. canDirectLoad?: (data: string) => boolean;
  8159. /**
  8160. * The callback that allows custom handling of the root url based on the response url.
  8161. */
  8162. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  8163. /**
  8164. * Load into an asset container.
  8165. * @param scene The scene to load into
  8166. * @param data The data to import
  8167. * @param rootUrl The root url for scene and resources
  8168. * @param onError The callback when import fails
  8169. * @returns The loaded asset container
  8170. */
  8171. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  8172. }
  8173. interface ISceneLoaderPluginAsync {
  8174. /**
  8175. * The friendly name of this plugin.
  8176. */
  8177. name: string;
  8178. /**
  8179. * The file extensions supported by this plugin.
  8180. */
  8181. extensions: string | ISceneLoaderPluginExtensions;
  8182. /**
  8183. * Import meshes into a scene.
  8184. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8185. * @param scene The scene to import into
  8186. * @param data The data to import
  8187. * @param rootUrl The root url for scene and resources
  8188. * @param onProgress The callback when the load progresses
  8189. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  8190. */
  8191. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  8192. meshes: AbstractMesh[];
  8193. particleSystems: ParticleSystem[];
  8194. skeletons: Skeleton[];
  8195. animationGroups: AnimationGroup[];
  8196. }>;
  8197. /**
  8198. * Load into a scene.
  8199. * @param scene The scene to load into
  8200. * @param data The data to import
  8201. * @param rootUrl The root url for scene and resources
  8202. * @param onProgress The callback when the load progresses
  8203. * @returns Nothing
  8204. */
  8205. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  8206. /**
  8207. * The callback that returns true if the data can be directly loaded.
  8208. */
  8209. canDirectLoad?: (data: string) => boolean;
  8210. /**
  8211. * The callback that allows custom handling of the root url based on the response url.
  8212. */
  8213. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  8214. /**
  8215. * Load into an asset container.
  8216. * @param scene The scene to load into
  8217. * @param data The data to import
  8218. * @param rootUrl The root url for scene and resources
  8219. * @param onProgress The callback when the load progresses
  8220. * @returns The loaded asset container
  8221. */
  8222. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  8223. }
  8224. class SceneLoader {
  8225. private static _ForceFullSceneLoadingForIncremental;
  8226. private static _ShowLoadingScreen;
  8227. private static _CleanBoneMatrixWeights;
  8228. static readonly NO_LOGGING: number;
  8229. static readonly MINIMAL_LOGGING: number;
  8230. static readonly SUMMARY_LOGGING: number;
  8231. static readonly DETAILED_LOGGING: number;
  8232. private static _loggingLevel;
  8233. static ForceFullSceneLoadingForIncremental: boolean;
  8234. static ShowLoadingScreen: boolean;
  8235. static loggingLevel: number;
  8236. static CleanBoneMatrixWeights: boolean;
  8237. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  8238. private static _registeredPlugins;
  8239. private static _getDefaultPlugin();
  8240. private static _getPluginForExtension(extension);
  8241. private static _getPluginForDirectLoad(data);
  8242. private static _getPluginForFilename(sceneFilename);
  8243. private static _getDirectLoad(sceneFilename);
  8244. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  8245. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  8246. static IsPluginForExtensionAvailable(extension: string): boolean;
  8247. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  8248. /**
  8249. * Import meshes into a scene
  8250. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8251. * @param rootUrl a string that defines the root url for scene and resources
  8252. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8253. * @param scene the instance of BABYLON.Scene to append to
  8254. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  8255. * @param onProgress a callback with a progress event for each file being loaded
  8256. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8257. * @param pluginExtension the extension used to determine the plugin
  8258. * @returns The loaded plugin
  8259. */
  8260. 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>;
  8261. /**
  8262. * Import meshes into a scene
  8263. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8264. * @param rootUrl a string that defines the root url for scene and resources
  8265. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8266. * @param scene the instance of BABYLON.Scene to append to
  8267. * @param onProgress a callback with a progress event for each file being loaded
  8268. * @param pluginExtension the extension used to determine the plugin
  8269. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  8270. */
  8271. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  8272. meshes: AbstractMesh[];
  8273. particleSystems: ParticleSystem[];
  8274. skeletons: Skeleton[];
  8275. animationGroups: AnimationGroup[];
  8276. }>;
  8277. /**
  8278. * Load a scene
  8279. * @param rootUrl a string that defines the root url for scene and resources
  8280. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8281. * @param engine is the instance of BABYLON.Engine to use to create the scene
  8282. * @param onSuccess a callback with the scene when import succeeds
  8283. * @param onProgress a callback with a progress event for each file being loaded
  8284. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8285. * @param pluginExtension the extension used to determine the plugin
  8286. * @returns The loaded plugin
  8287. */
  8288. 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>;
  8289. /**
  8290. * Load a scene
  8291. * @param rootUrl a string that defines the root url for scene and resources
  8292. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8293. * @param engine is the instance of BABYLON.Engine to use to create the scene
  8294. * @param onProgress a callback with a progress event for each file being loaded
  8295. * @param pluginExtension the extension used to determine the plugin
  8296. * @returns The loaded scene
  8297. */
  8298. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  8299. /**
  8300. * Append a scene
  8301. * @param rootUrl a string that defines the root url for scene and resources
  8302. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8303. * @param scene is the instance of BABYLON.Scene to append to
  8304. * @param onSuccess a callback with the scene when import succeeds
  8305. * @param onProgress a callback with a progress event for each file being loaded
  8306. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8307. * @param pluginExtension the extension used to determine the plugin
  8308. * @returns The loaded plugin
  8309. */
  8310. 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>;
  8311. /**
  8312. * Append a scene
  8313. * @param rootUrl a string that defines the root url for scene and resources
  8314. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8315. * @param scene is the instance of BABYLON.Scene to append to
  8316. * @param onProgress a callback with a progress event for each file being loaded
  8317. * @param pluginExtension the extension used to determine the plugin
  8318. * @returns The given scene
  8319. */
  8320. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  8321. /**
  8322. * Load a scene into an asset container
  8323. * @param rootUrl a string that defines the root url for scene and resources
  8324. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8325. * @param scene is the instance of BABYLON.Scene to append to
  8326. * @param onSuccess a callback with the scene when import succeeds
  8327. * @param onProgress a callback with a progress event for each file being loaded
  8328. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8329. * @param pluginExtension the extension used to determine the plugin
  8330. * @returns The loaded plugin
  8331. */
  8332. 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>;
  8333. /**
  8334. * Load a scene into an asset container
  8335. * @param rootUrl a string that defines the root url for scene and resources
  8336. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8337. * @param scene is the instance of BABYLON.Scene to append to
  8338. * @param onProgress a callback with a progress event for each file being loaded
  8339. * @param pluginExtension the extension used to determine the plugin
  8340. * @returns The loaded asset container
  8341. */
  8342. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  8343. }
  8344. }
  8345. declare module BABYLON {
  8346. /**
  8347. * A directional light is defined by a direction (what a surprise!).
  8348. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  8349. * 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.
  8350. * Documentation: https://doc.babylonjs.com/babylon101/lights
  8351. */
  8352. class DirectionalLight extends ShadowLight {
  8353. private _shadowFrustumSize;
  8354. /**
  8355. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  8356. */
  8357. /**
  8358. * Specifies a fix frustum size for the shadow generation.
  8359. */
  8360. shadowFrustumSize: number;
  8361. private _shadowOrthoScale;
  8362. /**
  8363. * Gets the shadow projection scale against the optimal computed one.
  8364. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  8365. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  8366. */
  8367. /**
  8368. * Sets the shadow projection scale against the optimal computed one.
  8369. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  8370. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  8371. */
  8372. shadowOrthoScale: number;
  8373. /**
  8374. * Automatically compute the projection matrix to best fit (including all the casters)
  8375. * on each frame.
  8376. */
  8377. autoUpdateExtends: boolean;
  8378. private _orthoLeft;
  8379. private _orthoRight;
  8380. private _orthoTop;
  8381. private _orthoBottom;
  8382. /**
  8383. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  8384. * The directional light is emitted from everywhere in the given direction.
  8385. * It can cast shawdows.
  8386. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8387. * @param name The friendly name of the light
  8388. * @param direction The direction of the light
  8389. * @param scene The scene the light belongs to
  8390. */
  8391. constructor(name: string, direction: Vector3, scene: Scene);
  8392. /**
  8393. * Returns the string "DirectionalLight".
  8394. * @return The class name
  8395. */
  8396. getClassName(): string;
  8397. /**
  8398. * Returns the integer 1.
  8399. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8400. */
  8401. getTypeID(): number;
  8402. /**
  8403. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  8404. * Returns the DirectionalLight Shadow projection matrix.
  8405. */
  8406. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8407. /**
  8408. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  8409. * Returns the DirectionalLight Shadow projection matrix.
  8410. */
  8411. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  8412. /**
  8413. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  8414. * Returns the DirectionalLight Shadow projection matrix.
  8415. */
  8416. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8417. protected _buildUniformLayout(): void;
  8418. /**
  8419. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  8420. * @param effect The effect to update
  8421. * @param lightIndex The index of the light in the effect to update
  8422. * @returns The directional light
  8423. */
  8424. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  8425. /**
  8426. * Gets the minZ used for shadow according to both the scene and the light.
  8427. *
  8428. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  8429. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  8430. * @param activeCamera The camera we are returning the min for
  8431. * @returns the depth min z
  8432. */
  8433. getDepthMinZ(activeCamera: Camera): number;
  8434. /**
  8435. * Gets the maxZ used for shadow according to both the scene and the light.
  8436. *
  8437. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  8438. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  8439. * @param activeCamera The camera we are returning the max for
  8440. * @returns the depth max z
  8441. */
  8442. getDepthMaxZ(activeCamera: Camera): number;
  8443. }
  8444. }
  8445. declare module BABYLON {
  8446. /**
  8447. * The HemisphericLight simulates the ambient environment light,
  8448. * so the passed direction is the light reflection direction, not the incoming direction.
  8449. */
  8450. class HemisphericLight extends Light {
  8451. /**
  8452. * The groundColor is the light in the opposite direction to the one specified during creation.
  8453. * 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.
  8454. */
  8455. groundColor: Color3;
  8456. /**
  8457. * The light reflection direction, not the incoming direction.
  8458. */
  8459. direction: Vector3;
  8460. private _worldMatrix;
  8461. /**
  8462. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  8463. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  8464. * The HemisphericLight can't cast shadows.
  8465. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8466. * @param name The friendly name of the light
  8467. * @param direction The direction of the light reflection
  8468. * @param scene The scene the light belongs to
  8469. */
  8470. constructor(name: string, direction: Vector3, scene: Scene);
  8471. protected _buildUniformLayout(): void;
  8472. /**
  8473. * Returns the string "HemisphericLight".
  8474. * @return The class name
  8475. */
  8476. getClassName(): string;
  8477. /**
  8478. * Sets the HemisphericLight direction towards the passed target (Vector3).
  8479. * Returns the updated direction.
  8480. * @param target The target the direction should point to
  8481. * @return The computed direction
  8482. */
  8483. setDirectionToTarget(target: Vector3): Vector3;
  8484. /**
  8485. * Returns the shadow generator associated to the light.
  8486. * @returns Always null for hemispheric lights because it does not support shadows.
  8487. */
  8488. getShadowGenerator(): Nullable<ShadowGenerator>;
  8489. /**
  8490. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  8491. * @param effect The effect to update
  8492. * @param lightIndex The index of the light in the effect to update
  8493. * @returns The hemispheric light
  8494. */
  8495. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  8496. /**
  8497. * @ignore internal use only.
  8498. */
  8499. _getWorldMatrix(): Matrix;
  8500. /**
  8501. * Returns the integer 3.
  8502. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8503. */
  8504. getTypeID(): number;
  8505. }
  8506. }
  8507. declare module BABYLON {
  8508. /**
  8509. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8510. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8511. * 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.
  8512. */
  8513. abstract class Light extends Node {
  8514. private static _LIGHTMAP_DEFAULT;
  8515. private static _LIGHTMAP_SPECULAR;
  8516. private static _LIGHTMAP_SHADOWSONLY;
  8517. /**
  8518. * If every light affecting the material is in this lightmapMode,
  8519. * material.lightmapTexture adds or multiplies
  8520. * (depends on material.useLightmapAsShadowmap)
  8521. * after every other light calculations.
  8522. */
  8523. static readonly LIGHTMAP_DEFAULT: number;
  8524. /**
  8525. * material.lightmapTexture as only diffuse lighting from this light
  8526. * adds only specular lighting from this light
  8527. * adds dynamic shadows
  8528. */
  8529. static readonly LIGHTMAP_SPECULAR: number;
  8530. /**
  8531. * material.lightmapTexture as only lighting
  8532. * no light calculation from this light
  8533. * only adds dynamic shadows from this light
  8534. */
  8535. static readonly LIGHTMAP_SHADOWSONLY: number;
  8536. private static _INTENSITYMODE_AUTOMATIC;
  8537. private static _INTENSITYMODE_LUMINOUSPOWER;
  8538. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  8539. private static _INTENSITYMODE_ILLUMINANCE;
  8540. private static _INTENSITYMODE_LUMINANCE;
  8541. /**
  8542. * Each light type uses the default quantity according to its type:
  8543. * point/spot lights use luminous intensity
  8544. * directional lights use illuminance
  8545. */
  8546. static readonly INTENSITYMODE_AUTOMATIC: number;
  8547. /**
  8548. * lumen (lm)
  8549. */
  8550. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8551. /**
  8552. * candela (lm/sr)
  8553. */
  8554. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8555. /**
  8556. * lux (lm/m^2)
  8557. */
  8558. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8559. /**
  8560. * nit (cd/m^2)
  8561. */
  8562. static readonly INTENSITYMODE_LUMINANCE: number;
  8563. private static _LIGHTTYPEID_POINTLIGHT;
  8564. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  8565. private static _LIGHTTYPEID_SPOTLIGHT;
  8566. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  8567. /**
  8568. * Light type const id of the point light.
  8569. */
  8570. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8571. /**
  8572. * Light type const id of the directional light.
  8573. */
  8574. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8575. /**
  8576. * Light type const id of the spot light.
  8577. */
  8578. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8579. /**
  8580. * Light type const id of the hemispheric light.
  8581. */
  8582. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8583. /**
  8584. * Diffuse gives the basic color to an object.
  8585. */
  8586. diffuse: Color3;
  8587. /**
  8588. * Specular produces a highlight color on an object.
  8589. * Note: This is note affecting PBR materials.
  8590. */
  8591. specular: Color3;
  8592. /**
  8593. * Strength of the light.
  8594. * Note: By default it is define in the framework own unit.
  8595. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8596. */
  8597. intensity: number;
  8598. /**
  8599. * Defines how far from the source the light is impacting in scene units.
  8600. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8601. */
  8602. range: number;
  8603. /**
  8604. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8605. * of light.
  8606. */
  8607. private _photometricScale;
  8608. private _intensityMode;
  8609. /**
  8610. * Gets the photometric scale used to interpret the intensity.
  8611. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8612. */
  8613. /**
  8614. * Sets the photometric scale used to interpret the intensity.
  8615. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8616. */
  8617. intensityMode: number;
  8618. private _radius;
  8619. /**
  8620. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8621. */
  8622. /**
  8623. * sets the light radius used by PBR Materials to simulate soft area lights.
  8624. */
  8625. radius: number;
  8626. private _renderPriority;
  8627. /**
  8628. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8629. * exceeding the number allowed of the materials.
  8630. */
  8631. renderPriority: number;
  8632. /**
  8633. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8634. * the current shadow generator.
  8635. */
  8636. shadowEnabled: boolean;
  8637. private _includedOnlyMeshes;
  8638. /**
  8639. * Gets the only meshes impacted by this light.
  8640. */
  8641. /**
  8642. * Sets the only meshes impacted by this light.
  8643. */
  8644. includedOnlyMeshes: AbstractMesh[];
  8645. private _excludedMeshes;
  8646. /**
  8647. * Gets the meshes not impacted by this light.
  8648. */
  8649. /**
  8650. * Sets the meshes not impacted by this light.
  8651. */
  8652. excludedMeshes: AbstractMesh[];
  8653. private _excludeWithLayerMask;
  8654. /**
  8655. * Gets the layer id use to find what meshes are not impacted by the light.
  8656. * Inactive if 0
  8657. */
  8658. /**
  8659. * Sets the layer id use to find what meshes are not impacted by the light.
  8660. * Inactive if 0
  8661. */
  8662. excludeWithLayerMask: number;
  8663. private _includeOnlyWithLayerMask;
  8664. /**
  8665. * Gets the layer id use to find what meshes are impacted by the light.
  8666. * Inactive if 0
  8667. */
  8668. /**
  8669. * Sets the layer id use to find what meshes are impacted by the light.
  8670. * Inactive if 0
  8671. */
  8672. includeOnlyWithLayerMask: number;
  8673. private _lightmapMode;
  8674. /**
  8675. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8676. */
  8677. /**
  8678. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8679. */
  8680. lightmapMode: number;
  8681. private _parentedWorldMatrix;
  8682. /**
  8683. * Shadow generator associted to the light.
  8684. * Internal use only.
  8685. */
  8686. _shadowGenerator: Nullable<IShadowGenerator>;
  8687. /**
  8688. * @ignore Internal use only.
  8689. */
  8690. _excludedMeshesIds: string[];
  8691. /**
  8692. * @ignore Internal use only.
  8693. */
  8694. _includedOnlyMeshesIds: string[];
  8695. /**
  8696. * The current light unifom buffer.
  8697. * @ignore Internal use only.
  8698. */
  8699. _uniformBuffer: UniformBuffer;
  8700. /**
  8701. * Creates a Light object in the scene.
  8702. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8703. * @param name The firendly name of the light
  8704. * @param scene The scene the light belongs too
  8705. */
  8706. constructor(name: string, scene: Scene);
  8707. protected abstract _buildUniformLayout(): void;
  8708. /**
  8709. * Sets the passed Effect "effect" with the Light information.
  8710. * @param effect The effect to update
  8711. * @param lightIndex The index of the light in the effect to update
  8712. * @returns The light
  8713. */
  8714. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8715. /**
  8716. * @ignore internal use only.
  8717. */
  8718. abstract _getWorldMatrix(): Matrix;
  8719. /**
  8720. * Returns the string "Light".
  8721. * @returns the class name
  8722. */
  8723. getClassName(): string;
  8724. /**
  8725. * Converts the light information to a readable string for debug purpose.
  8726. * @param fullDetails Supports for multiple levels of logging within scene loading
  8727. * @returns the human readable light info
  8728. */
  8729. toString(fullDetails?: boolean): string;
  8730. /**
  8731. * Set the enabled state of this node.
  8732. * @param value - the new enabled state
  8733. */
  8734. setEnabled(value: boolean): void;
  8735. /**
  8736. * Returns the Light associated shadow generator if any.
  8737. * @return the associated shadow generator.
  8738. */
  8739. getShadowGenerator(): Nullable<IShadowGenerator>;
  8740. /**
  8741. * Returns a Vector3, the absolute light position in the World.
  8742. * @returns the world space position of the light
  8743. */
  8744. getAbsolutePosition(): Vector3;
  8745. /**
  8746. * Specifies if the light will affect the passed mesh.
  8747. * @param mesh The mesh to test against the light
  8748. * @return true the mesh is affected otherwise, false.
  8749. */
  8750. canAffectMesh(mesh: AbstractMesh): boolean;
  8751. /**
  8752. * Computes and Returns the light World matrix.
  8753. * @returns the world matrix
  8754. */
  8755. getWorldMatrix(): Matrix;
  8756. /**
  8757. * Sort function to order lights for rendering.
  8758. * @param a First Light object to compare to second.
  8759. * @param b Second Light object to compare first.
  8760. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8761. */
  8762. static CompareLightsPriority(a: Light, b: Light): number;
  8763. /**
  8764. * Releases resources associated with this node.
  8765. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8766. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8767. */
  8768. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8769. /**
  8770. * Returns the light type ID (integer).
  8771. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8772. */
  8773. getTypeID(): number;
  8774. /**
  8775. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8776. * @returns the scaled intensity in intensity mode unit
  8777. */
  8778. getScaledIntensity(): number;
  8779. /**
  8780. * Returns a new Light object, named "name", from the current one.
  8781. * @param name The name of the cloned light
  8782. * @returns the new created light
  8783. */
  8784. clone(name: string): Nullable<Light>;
  8785. /**
  8786. * Serializes the current light into a Serialization object.
  8787. * @returns the serialized object.
  8788. */
  8789. serialize(): any;
  8790. /**
  8791. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8792. * This new light is named "name" and added to the passed scene.
  8793. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8794. * @param name The friendly name of the light
  8795. * @param scene The scene the new light will belong to
  8796. * @returns the constructor function
  8797. */
  8798. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8799. /**
  8800. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8801. * @param parsedLight The JSON representation of the light
  8802. * @param scene The scene to create the parsed light in
  8803. * @returns the created light after parsing
  8804. */
  8805. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8806. private _hookArrayForExcluded(array);
  8807. private _hookArrayForIncludedOnly(array);
  8808. private _resyncMeshes();
  8809. /**
  8810. * Forces the meshes to update their light related information in their rendering used effects
  8811. * @ignore Internal Use Only
  8812. */
  8813. _markMeshesAsLightDirty(): void;
  8814. /**
  8815. * Recomputes the cached photometric scale if needed.
  8816. */
  8817. private _computePhotometricScale();
  8818. /**
  8819. * Returns the Photometric Scale according to the light type and intensity mode.
  8820. */
  8821. private _getPhotometricScale();
  8822. /**
  8823. * Reorder the light in the scene according to their defined priority.
  8824. * @ignore Internal Use Only
  8825. */
  8826. _reorderLightsInScene(): void;
  8827. }
  8828. }
  8829. declare module BABYLON {
  8830. /**
  8831. * A point light is a light defined by an unique point in world space.
  8832. * The light is emitted in every direction from this point.
  8833. * A good example of a point light is a standard light bulb.
  8834. * Documentation: https://doc.babylonjs.com/babylon101/lights
  8835. */
  8836. class PointLight extends ShadowLight {
  8837. private _shadowAngle;
  8838. /**
  8839. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8840. * This specifies what angle the shadow will use to be created.
  8841. *
  8842. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  8843. */
  8844. /**
  8845. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8846. * This specifies what angle the shadow will use to be created.
  8847. *
  8848. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  8849. */
  8850. shadowAngle: number;
  8851. /**
  8852. * Gets the direction if it has been set.
  8853. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8854. */
  8855. /**
  8856. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8857. */
  8858. direction: Vector3;
  8859. /**
  8860. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  8861. * A PointLight emits the light in every direction.
  8862. * It can cast shadows.
  8863. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  8864. * ```javascript
  8865. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  8866. * ```
  8867. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8868. * @param name The light friendly name
  8869. * @param position The position of the point light in the scene
  8870. * @param scene The scene the lights belongs to
  8871. */
  8872. constructor(name: string, position: Vector3, scene: Scene);
  8873. /**
  8874. * Returns the string "PointLight"
  8875. * @returns the class name
  8876. */
  8877. getClassName(): string;
  8878. /**
  8879. * Returns the integer 0.
  8880. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8881. */
  8882. getTypeID(): number;
  8883. /**
  8884. * Specifies wether or not the shadowmap should be a cube texture.
  8885. * @returns true if the shadowmap needs to be a cube texture.
  8886. */
  8887. needCube(): boolean;
  8888. /**
  8889. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  8890. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8891. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8892. */
  8893. getShadowDirection(faceIndex?: number): Vector3;
  8894. /**
  8895. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  8896. * - fov = PI / 2
  8897. * - aspect ratio : 1.0
  8898. * - z-near and far equal to the active camera minZ and maxZ.
  8899. * Returns the PointLight.
  8900. */
  8901. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8902. protected _buildUniformLayout(): void;
  8903. /**
  8904. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  8905. * @param effect The effect to update
  8906. * @param lightIndex The index of the light in the effect to update
  8907. * @returns The point light
  8908. */
  8909. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  8910. }
  8911. }
  8912. declare module BABYLON {
  8913. /**
  8914. * Interface describing all the common properties and methods a shadow light needs to implement.
  8915. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8916. * as well as binding the different shadow properties to the effects.
  8917. */
  8918. interface IShadowLight extends Light {
  8919. /**
  8920. * The light id in the scene (used in scene.findLighById for instance)
  8921. */
  8922. id: string;
  8923. /**
  8924. * The position the shdow will be casted from.
  8925. */
  8926. position: Vector3;
  8927. /**
  8928. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8929. */
  8930. direction: Vector3;
  8931. /**
  8932. * The transformed position. Position of the light in world space taking parenting in account.
  8933. */
  8934. transformedPosition: Vector3;
  8935. /**
  8936. * The transformed direction. Direction of the light in world space taking parenting in account.
  8937. */
  8938. transformedDirection: Vector3;
  8939. /**
  8940. * The friendly name of the light in the scene.
  8941. */
  8942. name: string;
  8943. /**
  8944. * Defines the shadow projection clipping minimum z value.
  8945. */
  8946. shadowMinZ: number;
  8947. /**
  8948. * Defines the shadow projection clipping maximum z value.
  8949. */
  8950. shadowMaxZ: number;
  8951. /**
  8952. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8953. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8954. */
  8955. computeTransformedInformation(): boolean;
  8956. /**
  8957. * Gets the scene the light belongs to.
  8958. * @returns The scene
  8959. */
  8960. getScene(): Scene;
  8961. /**
  8962. * Callback defining a custom Projection Matrix Builder.
  8963. * This can be used to override the default projection matrix computation.
  8964. */
  8965. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8966. /**
  8967. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8968. * @param matrix The materix to updated with the projection information
  8969. * @param viewMatrix The transform matrix of the light
  8970. * @param renderList The list of mesh to render in the map
  8971. * @returns The current light
  8972. */
  8973. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8974. /**
  8975. * Gets the current depth scale used in ESM.
  8976. * @returns The scale
  8977. */
  8978. getDepthScale(): number;
  8979. /**
  8980. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8981. * @returns true if a cube texture needs to be use
  8982. */
  8983. needCube(): boolean;
  8984. /**
  8985. * Detects if the projection matrix requires to be recomputed this frame.
  8986. * @returns true if it requires to be recomputed otherwise, false.
  8987. */
  8988. needProjectionMatrixCompute(): boolean;
  8989. /**
  8990. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8991. */
  8992. forceProjectionMatrixCompute(): void;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Gets the minZ used for shadow according to both the scene and the light.
  9001. * @param activeCamera The camera we are returning the min for
  9002. * @returns the depth min z
  9003. */
  9004. getDepthMinZ(activeCamera: Camera): number;
  9005. /**
  9006. * Gets the maxZ used for shadow according to both the scene and the light.
  9007. * @param activeCamera The camera we are returning the max for
  9008. * @returns the depth max z
  9009. */
  9010. getDepthMaxZ(activeCamera: Camera): number;
  9011. }
  9012. /**
  9013. * Base implementation IShadowLight
  9014. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9015. */
  9016. abstract class ShadowLight extends Light implements IShadowLight {
  9017. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9018. protected _position: Vector3;
  9019. protected _setPosition(value: Vector3): void;
  9020. /**
  9021. * Sets the position the shadow will be casted from. Also use as the light position for both
  9022. * point and spot lights.
  9023. */
  9024. /**
  9025. * Sets the position the shadow will be casted from. Also use as the light position for both
  9026. * point and spot lights.
  9027. */
  9028. position: Vector3;
  9029. protected _direction: Vector3;
  9030. protected _setDirection(value: Vector3): void;
  9031. /**
  9032. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9033. * Also use as the light direction on spot and directional lights.
  9034. */
  9035. /**
  9036. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9037. * Also use as the light direction on spot and directional lights.
  9038. */
  9039. direction: Vector3;
  9040. private _shadowMinZ;
  9041. /**
  9042. * Gets the shadow projection clipping minimum z value.
  9043. */
  9044. /**
  9045. * Sets the shadow projection clipping minimum z value.
  9046. */
  9047. shadowMinZ: number;
  9048. private _shadowMaxZ;
  9049. /**
  9050. * Sets the shadow projection clipping maximum z value.
  9051. */
  9052. /**
  9053. * Gets the shadow projection clipping maximum z value.
  9054. */
  9055. shadowMaxZ: number;
  9056. /**
  9057. * Callback defining a custom Projection Matrix Builder.
  9058. * This can be used to override the default projection matrix computation.
  9059. */
  9060. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9061. /**
  9062. * The transformed position. Position of the light in world space taking parenting in account.
  9063. */
  9064. transformedPosition: Vector3;
  9065. /**
  9066. * The transformed direction. Direction of the light in world space taking parenting in account.
  9067. */
  9068. transformedDirection: Vector3;
  9069. private _worldMatrix;
  9070. private _needProjectionMatrixCompute;
  9071. /**
  9072. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9073. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9074. */
  9075. computeTransformedInformation(): boolean;
  9076. /**
  9077. * Return the depth scale used for the shadow map.
  9078. * @returns the depth scale.
  9079. */
  9080. getDepthScale(): number;
  9081. /**
  9082. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9083. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9084. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9085. */
  9086. getShadowDirection(faceIndex?: number): Vector3;
  9087. /**
  9088. * Returns the ShadowLight absolute position in the World.
  9089. * @returns the position vector in world space
  9090. */
  9091. getAbsolutePosition(): Vector3;
  9092. /**
  9093. * Sets the ShadowLight direction toward the passed target.
  9094. * @param target The point tot target in local space
  9095. * @returns the updated ShadowLight direction
  9096. */
  9097. setDirectionToTarget(target: Vector3): Vector3;
  9098. /**
  9099. * Returns the light rotation in euler definition.
  9100. * @returns the x y z rotation in local space.
  9101. */
  9102. getRotation(): Vector3;
  9103. /**
  9104. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9105. * @returns true if a cube texture needs to be use
  9106. */
  9107. needCube(): boolean;
  9108. /**
  9109. * Detects if the projection matrix requires to be recomputed this frame.
  9110. * @returns true if it requires to be recomputed otherwise, false.
  9111. */
  9112. needProjectionMatrixCompute(): boolean;
  9113. /**
  9114. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9115. */
  9116. forceProjectionMatrixCompute(): void;
  9117. /**
  9118. * Get the world matrix of the sahdow lights.
  9119. * @ignore Internal Use Only
  9120. */
  9121. _getWorldMatrix(): Matrix;
  9122. /**
  9123. * Gets the minZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the min for
  9125. * @returns the depth min z
  9126. */
  9127. getDepthMinZ(activeCamera: Camera): number;
  9128. /**
  9129. * Gets the maxZ used for shadow according to both the scene and the light.
  9130. * @param activeCamera The camera we are returning the max for
  9131. * @returns the depth max z
  9132. */
  9133. getDepthMaxZ(activeCamera: Camera): number;
  9134. /**
  9135. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9136. * @param matrix The materix to updated with the projection information
  9137. * @param viewMatrix The transform matrix of the light
  9138. * @param renderList The list of mesh to render in the map
  9139. * @returns The current light
  9140. */
  9141. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9142. }
  9143. }
  9144. declare module BABYLON {
  9145. /**
  9146. * A spot light is defined by a position, a direction, an angle, and an exponent.
  9147. * These values define a cone of light starting from the position, emitting toward the direction.
  9148. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  9149. * and the exponent defines the speed of the decay of the light with distance (reach).
  9150. * Documentation: https://doc.babylonjs.com/babylon101/lights
  9151. */
  9152. class SpotLight extends ShadowLight {
  9153. private _angle;
  9154. /**
  9155. * Gets the cone angle of the spot light in Radians.
  9156. */
  9157. /**
  9158. * Sets the cone angle of the spot light in Radians.
  9159. */
  9160. angle: number;
  9161. private _shadowAngleScale;
  9162. /**
  9163. * Allows scaling the angle of the light for shadow generation only.
  9164. */
  9165. /**
  9166. * Allows scaling the angle of the light for shadow generation only.
  9167. */
  9168. shadowAngleScale: number;
  9169. /**
  9170. * The light decay speed with the distance from the emission spot.
  9171. */
  9172. exponent: number;
  9173. private _projectionTextureMatrix;
  9174. /**
  9175. * Allows reading the projecton texture
  9176. */
  9177. readonly projectionTextureMatrix: Matrix;
  9178. protected _projectionTextureLightNear: number;
  9179. /**
  9180. * Gets the near clip of the Spotlight for texture projection.
  9181. */
  9182. /**
  9183. * Sets the near clip of the Spotlight for texture projection.
  9184. */
  9185. projectionTextureLightNear: number;
  9186. protected _projectionTextureLightFar: number;
  9187. /**
  9188. * Gets the far clip of the Spotlight for texture projection.
  9189. */
  9190. /**
  9191. * Sets the far clip of the Spotlight for texture projection.
  9192. */
  9193. projectionTextureLightFar: number;
  9194. protected _projectionTextureUpDirection: Vector3;
  9195. /**
  9196. * Gets the Up vector of the Spotlight for texture projection.
  9197. */
  9198. /**
  9199. * Sets the Up vector of the Spotlight for texture projection.
  9200. */
  9201. projectionTextureUpDirection: Vector3;
  9202. private _projectionTexture;
  9203. /**
  9204. * Gets the projection texture of the light.
  9205. */
  9206. /**
  9207. * Sets the projection texture of the light.
  9208. */
  9209. projectionTexture: Nullable<BaseTexture>;
  9210. private _projectionTextureViewLightDirty;
  9211. private _projectionTextureProjectionLightDirty;
  9212. private _projectionTextureDirty;
  9213. private _projectionTextureViewTargetVector;
  9214. private _projectionTextureViewLightMatrix;
  9215. private _projectionTextureProjectionLightMatrix;
  9216. private _projectionTextureScalingMatrix;
  9217. /**
  9218. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  9219. * It can cast shadows.
  9220. * Documentation : http://doc.babylonjs.com/tutorials/lights
  9221. * @param name The light friendly name
  9222. * @param position The position of the spot light in the scene
  9223. * @param direction The direction of the light in the scene
  9224. * @param angle The cone angle of the light in Radians
  9225. * @param exponent The light decay speed with the distance from the emission spot
  9226. * @param scene The scene the lights belongs to
  9227. */
  9228. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  9229. /**
  9230. * Returns the string "SpotLight".
  9231. * @returns the class name
  9232. */
  9233. getClassName(): string;
  9234. /**
  9235. * Returns the integer 2.
  9236. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9237. */
  9238. getTypeID(): number;
  9239. /**
  9240. * Overrides the direction setter to recompute the projection texture view light Matrix.
  9241. */
  9242. protected _setDirection(value: Vector3): void;
  9243. /**
  9244. * Overrides the position setter to recompute the projection texture view light Matrix.
  9245. */
  9246. protected _setPosition(value: Vector3): void;
  9247. /**
  9248. * 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.
  9249. * Returns the SpotLight.
  9250. */
  9251. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9252. protected _computeProjectionTextureViewLightMatrix(): void;
  9253. protected _computeProjectionTextureProjectionLightMatrix(): void;
  9254. /**
  9255. * Main function for light texture projection matrix computing.
  9256. */
  9257. protected _computeProjectionTextureMatrix(): void;
  9258. protected _buildUniformLayout(): void;
  9259. /**
  9260. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  9261. * @param effect The effect to update
  9262. * @param lightIndex The index of the light in the effect to update
  9263. * @returns The spot light
  9264. */
  9265. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  9266. /**
  9267. * Disposes the light and the associated resources.
  9268. */
  9269. dispose(): void;
  9270. }
  9271. }
  9272. declare module BABYLON {
  9273. /**
  9274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9276. * 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;
  9277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9278. */
  9279. class ColorCurves {
  9280. private _dirty;
  9281. private _tempColor;
  9282. private _globalCurve;
  9283. private _highlightsCurve;
  9284. private _midtonesCurve;
  9285. private _shadowsCurve;
  9286. private _positiveCurve;
  9287. private _negativeCurve;
  9288. private _globalHue;
  9289. private _globalDensity;
  9290. private _globalSaturation;
  9291. private _globalExposure;
  9292. /**
  9293. * Gets the global Hue value.
  9294. * 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).
  9295. */
  9296. /**
  9297. * Sets the global Hue value.
  9298. * 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).
  9299. */
  9300. globalHue: number;
  9301. /**
  9302. * Gets the global Density value.
  9303. * 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.
  9304. * Values less than zero provide a filter of opposite hue.
  9305. */
  9306. /**
  9307. * Sets the global Density value.
  9308. * 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.
  9309. * Values less than zero provide a filter of opposite hue.
  9310. */
  9311. globalDensity: number;
  9312. /**
  9313. * Gets the global Saturation value.
  9314. * 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.
  9315. */
  9316. /**
  9317. * Sets the global Saturation value.
  9318. * 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.
  9319. */
  9320. globalSaturation: number;
  9321. private _highlightsHue;
  9322. private _highlightsDensity;
  9323. private _highlightsSaturation;
  9324. private _highlightsExposure;
  9325. /**
  9326. * Gets the highlights Hue value.
  9327. * 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).
  9328. */
  9329. /**
  9330. * Sets the highlights Hue value.
  9331. * 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).
  9332. */
  9333. highlightsHue: number;
  9334. /**
  9335. * Gets the highlights Density value.
  9336. * 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.
  9337. * Values less than zero provide a filter of opposite hue.
  9338. */
  9339. /**
  9340. * Sets the highlights Density value.
  9341. * 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.
  9342. * Values less than zero provide a filter of opposite hue.
  9343. */
  9344. highlightsDensity: number;
  9345. /**
  9346. * Gets the highlights Saturation value.
  9347. * 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.
  9348. */
  9349. /**
  9350. * Sets the highlights Saturation value.
  9351. * 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.
  9352. */
  9353. highlightsSaturation: number;
  9354. /**
  9355. * Gets the highlights Exposure value.
  9356. * 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.
  9357. */
  9358. /**
  9359. * Sets the highlights Exposure value.
  9360. * 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.
  9361. */
  9362. highlightsExposure: number;
  9363. private _midtonesHue;
  9364. private _midtonesDensity;
  9365. private _midtonesSaturation;
  9366. private _midtonesExposure;
  9367. /**
  9368. * Gets the midtones Hue value.
  9369. * 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).
  9370. */
  9371. /**
  9372. * Sets the midtones Hue value.
  9373. * 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).
  9374. */
  9375. midtonesHue: number;
  9376. /**
  9377. * Gets the midtones Density value.
  9378. * 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.
  9379. * Values less than zero provide a filter of opposite hue.
  9380. */
  9381. /**
  9382. * Sets the midtones Density value.
  9383. * 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.
  9384. * Values less than zero provide a filter of opposite hue.
  9385. */
  9386. midtonesDensity: number;
  9387. /**
  9388. * Gets the midtones Saturation value.
  9389. * 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.
  9390. */
  9391. /**
  9392. * Sets the midtones Saturation value.
  9393. * 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.
  9394. */
  9395. midtonesSaturation: number;
  9396. /**
  9397. * Gets the midtones Exposure value.
  9398. * 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.
  9399. */
  9400. /**
  9401. * Sets the midtones Exposure value.
  9402. * 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.
  9403. */
  9404. midtonesExposure: number;
  9405. private _shadowsHue;
  9406. private _shadowsDensity;
  9407. private _shadowsSaturation;
  9408. private _shadowsExposure;
  9409. /**
  9410. * Gets the shadows Hue value.
  9411. * 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).
  9412. */
  9413. /**
  9414. * Sets the shadows Hue value.
  9415. * 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).
  9416. */
  9417. shadowsHue: number;
  9418. /**
  9419. * Gets the shadows Density value.
  9420. * 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.
  9421. * Values less than zero provide a filter of opposite hue.
  9422. */
  9423. /**
  9424. * Sets the shadows Density value.
  9425. * 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.
  9426. * Values less than zero provide a filter of opposite hue.
  9427. */
  9428. shadowsDensity: number;
  9429. /**
  9430. * Gets the shadows Saturation value.
  9431. * 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.
  9432. */
  9433. /**
  9434. * Sets the shadows Saturation value.
  9435. * 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.
  9436. */
  9437. shadowsSaturation: number;
  9438. /**
  9439. * Gets the shadows Exposure value.
  9440. * 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.
  9441. */
  9442. /**
  9443. * Sets the shadows Exposure value.
  9444. * 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.
  9445. */
  9446. shadowsExposure: number;
  9447. getClassName(): string;
  9448. /**
  9449. * Binds the color curves to the shader.
  9450. * @param colorCurves The color curve to bind
  9451. * @param effect The effect to bind to
  9452. */
  9453. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  9454. /**
  9455. * Prepare the list of uniforms associated with the ColorCurves effects.
  9456. * @param uniformsList The list of uniforms used in the effect
  9457. */
  9458. static PrepareUniforms(uniformsList: string[]): void;
  9459. /**
  9460. * Returns color grading data based on a hue, density, saturation and exposure value.
  9461. * @param filterHue The hue of the color filter.
  9462. * @param filterDensity The density of the color filter.
  9463. * @param saturation The saturation.
  9464. * @param exposure The exposure.
  9465. * @param result The result data container.
  9466. */
  9467. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  9468. /**
  9469. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  9470. * @param value The input slider value in range [-100,100].
  9471. * @returns Adjusted value.
  9472. */
  9473. private static applyColorGradingSliderNonlinear(value);
  9474. /**
  9475. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  9476. * @param hue The hue (H) input.
  9477. * @param saturation The saturation (S) input.
  9478. * @param brightness The brightness (B) input.
  9479. * @result An RGBA color represented as Vector4.
  9480. */
  9481. private static fromHSBToRef(hue, saturation, brightness, result);
  9482. /**
  9483. * Returns a value clamped between min and max
  9484. * @param value The value to clamp
  9485. * @param min The minimum of value
  9486. * @param max The maximum of value
  9487. * @returns The clamped value.
  9488. */
  9489. private static clamp(value, min, max);
  9490. /**
  9491. * Clones the current color curve instance.
  9492. * @return The cloned curves
  9493. */
  9494. clone(): ColorCurves;
  9495. /**
  9496. * Serializes the current color curve instance to a json representation.
  9497. * @return a JSON representation
  9498. */
  9499. serialize(): any;
  9500. /**
  9501. * Parses the color curve from a json representation.
  9502. * @param source the JSON source to parse
  9503. * @return The parsed curves
  9504. */
  9505. static Parse(source: any): ColorCurves;
  9506. }
  9507. }
  9508. declare module BABYLON {
  9509. /**
  9510. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9511. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9512. */
  9513. class EffectFallbacks {
  9514. private _defines;
  9515. private _currentRank;
  9516. private _maxRank;
  9517. private _mesh;
  9518. /**
  9519. * Removes the fallback from the bound mesh.
  9520. */
  9521. unBindMesh(): void;
  9522. /**
  9523. * Adds a fallback on the specified property.
  9524. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9525. * @param define The name of the define in the shader
  9526. */
  9527. addFallback(rank: number, define: string): void;
  9528. /**
  9529. * Sets the mesh to use CPU skinning when needing to fallback.
  9530. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9531. * @param mesh The mesh to use the fallbacks.
  9532. */
  9533. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9534. /**
  9535. * Checks to see if more fallbacks are still availible.
  9536. */
  9537. readonly isMoreFallbacks: boolean;
  9538. /**
  9539. * Removes the defines that shoould be removed when falling back.
  9540. * @param currentDefines defines the current define statements for the shader.
  9541. * @param effect defines the current effect we try to compile
  9542. * @returns The resulting defines with defines of the current rank removed.
  9543. */
  9544. reduce(currentDefines: string, effect: Effect): string;
  9545. }
  9546. /**
  9547. * Options to be used when creating an effect.
  9548. */
  9549. class EffectCreationOptions {
  9550. /**
  9551. * Atrributes that will be used in the shader.
  9552. */
  9553. attributes: string[];
  9554. /**
  9555. * Uniform varible names that will be set in the shader.
  9556. */
  9557. uniformsNames: string[];
  9558. /**
  9559. * Uniform buffer varible names that will be set in the shader.
  9560. */
  9561. uniformBuffersNames: string[];
  9562. /**
  9563. * Sampler texture variable names that will be set in the shader.
  9564. */
  9565. samplers: string[];
  9566. /**
  9567. * Define statements that will be set in the shader.
  9568. */
  9569. defines: any;
  9570. /**
  9571. * Possible fallbacks for this effect to improve performance when needed.
  9572. */
  9573. fallbacks: Nullable<EffectFallbacks>;
  9574. /**
  9575. * Callback that will be called when the shader is compiled.
  9576. */
  9577. onCompiled: Nullable<(effect: Effect) => void>;
  9578. /**
  9579. * Callback that will be called if an error occurs during shader compilation.
  9580. */
  9581. onError: Nullable<(effect: Effect, errors: string) => void>;
  9582. /**
  9583. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  9584. */
  9585. indexParameters: any;
  9586. /**
  9587. * Max number of lights that can be used in the shader.
  9588. */
  9589. maxSimultaneousLights: number;
  9590. /**
  9591. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  9592. */
  9593. transformFeedbackVaryings: Nullable<string[]>;
  9594. }
  9595. /**
  9596. * Effect containing vertex and fragment shader that can be executed on an object.
  9597. */
  9598. class Effect {
  9599. /**
  9600. * Name of the effect.
  9601. */
  9602. name: any;
  9603. /**
  9604. * String container all the define statements that should be set on the shader.
  9605. */
  9606. defines: string;
  9607. /**
  9608. * Callback that will be called when the shader is compiled.
  9609. */
  9610. onCompiled: Nullable<(effect: Effect) => void>;
  9611. /**
  9612. * Callback that will be called if an error occurs during shader compilation.
  9613. */
  9614. onError: Nullable<(effect: Effect, errors: string) => void>;
  9615. /**
  9616. * Callback that will be called when effect is bound.
  9617. */
  9618. onBind: Nullable<(effect: Effect) => void>;
  9619. /**
  9620. * Unique ID of the effect.
  9621. */
  9622. uniqueId: number;
  9623. /**
  9624. * Observable that will be called when the shader is compiled.
  9625. */
  9626. onCompileObservable: Observable<Effect>;
  9627. /**
  9628. * Observable that will be called if an error occurs during shader compilation.
  9629. */
  9630. onErrorObservable: Observable<Effect>;
  9631. /**
  9632. * Observable that will be called when effect is bound.
  9633. */
  9634. onBindObservable: Observable<Effect>;
  9635. private static _uniqueIdSeed;
  9636. private _engine;
  9637. private _uniformBuffersNames;
  9638. private _uniformsNames;
  9639. private _samplers;
  9640. private _isReady;
  9641. private _compilationError;
  9642. private _attributesNames;
  9643. private _attributes;
  9644. private _uniforms;
  9645. /**
  9646. * Key for the effect.
  9647. */
  9648. _key: string;
  9649. private _indexParameters;
  9650. private _fallbacks;
  9651. private _vertexSourceCode;
  9652. private _fragmentSourceCode;
  9653. private _vertexSourceCodeOverride;
  9654. private _fragmentSourceCodeOverride;
  9655. private _transformFeedbackVaryings;
  9656. /**
  9657. * Compiled shader to webGL program.
  9658. */
  9659. _program: WebGLProgram;
  9660. private _valueCache;
  9661. private static _baseCache;
  9662. /**
  9663. * Instantiates an effect.
  9664. * An effect can be used to create/manage/execute vertex and fragment shaders.
  9665. * @param baseName Name of the effect.
  9666. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  9667. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  9668. * @param samplers List of sampler variables that will be passed to the shader.
  9669. * @param engine Engine to be used to render the effect
  9670. * @param defines Define statements to be added to the shader.
  9671. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  9672. * @param onCompiled Callback that will be called when the shader is compiled.
  9673. * @param onError Callback that will be called if an error occurs during shader compilation.
  9674. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  9675. */
  9676. 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);
  9677. /**
  9678. * Unique key for this effect
  9679. */
  9680. readonly key: string;
  9681. /**
  9682. * If the effect has been compiled and prepared.
  9683. * @returns if the effect is compiled and prepared.
  9684. */
  9685. isReady(): boolean;
  9686. /**
  9687. * The engine the effect was initialized with.
  9688. * @returns the engine.
  9689. */
  9690. getEngine(): Engine;
  9691. /**
  9692. * The compiled webGL program for the effect
  9693. * @returns the webGL program.
  9694. */
  9695. getProgram(): WebGLProgram;
  9696. /**
  9697. * The set of names of attribute variables for the shader.
  9698. * @returns An array of attribute names.
  9699. */
  9700. getAttributesNames(): string[];
  9701. /**
  9702. * Returns the attribute at the given index.
  9703. * @param index The index of the attribute.
  9704. * @returns The location of the attribute.
  9705. */
  9706. getAttributeLocation(index: number): number;
  9707. /**
  9708. * Returns the attribute based on the name of the variable.
  9709. * @param name of the attribute to look up.
  9710. * @returns the attribute location.
  9711. */
  9712. getAttributeLocationByName(name: string): number;
  9713. /**
  9714. * The number of attributes.
  9715. * @returns the numnber of attributes.
  9716. */
  9717. getAttributesCount(): number;
  9718. /**
  9719. * Gets the index of a uniform variable.
  9720. * @param uniformName of the uniform to look up.
  9721. * @returns the index.
  9722. */
  9723. getUniformIndex(uniformName: string): number;
  9724. /**
  9725. * Returns the attribute based on the name of the variable.
  9726. * @param uniformName of the uniform to look up.
  9727. * @returns the location of the uniform.
  9728. */
  9729. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  9730. /**
  9731. * Returns an array of sampler variable names
  9732. * @returns The array of sampler variable neames.
  9733. */
  9734. getSamplers(): string[];
  9735. /**
  9736. * The error from the last compilation.
  9737. * @returns the error string.
  9738. */
  9739. getCompilationError(): string;
  9740. /**
  9741. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  9742. * @param func The callback to be used.
  9743. */
  9744. executeWhenCompiled(func: (effect: Effect) => void): void;
  9745. /** @ignore */
  9746. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  9747. /** @ignore */
  9748. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  9749. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  9750. private _processShaderConversion(sourceCode, isFragment, callback);
  9751. private _processIncludes(sourceCode, callback);
  9752. private _processPrecision(source);
  9753. /**
  9754. * Recompiles the webGL program
  9755. * @param vertexSourceCode The source code for the vertex shader.
  9756. * @param fragmentSourceCode The source code for the fragment shader.
  9757. * @param onCompiled Callback called when completed.
  9758. * @param onError Callback called on error.
  9759. */
  9760. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  9761. /**
  9762. * Gets the uniform locations of the the specified variable names
  9763. * @param names THe names of the variables to lookup.
  9764. * @returns Array of locations in the same order as variable names.
  9765. */
  9766. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  9767. /**
  9768. * Prepares the effect
  9769. */
  9770. _prepareEffect(): void;
  9771. /**
  9772. * Checks if the effect is supported. (Must be called after compilation)
  9773. */
  9774. readonly isSupported: boolean;
  9775. /**
  9776. * Binds a texture to the engine to be used as output of the shader.
  9777. * @param channel Name of the output variable.
  9778. * @param texture Texture to bind.
  9779. */
  9780. _bindTexture(channel: string, texture: InternalTexture): void;
  9781. /**
  9782. * Sets a texture on the engine to be used in the shader.
  9783. * @param channel Name of the sampler variable.
  9784. * @param texture Texture to set.
  9785. */
  9786. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  9787. /**
  9788. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  9789. * @param channel Name of the sampler variable.
  9790. * @param texture Texture to set.
  9791. */
  9792. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  9793. /**
  9794. * Sets an array of textures on the engine to be used in the shader.
  9795. * @param channel Name of the variable.
  9796. * @param textures Textures to set.
  9797. */
  9798. setTextureArray(channel: string, textures: BaseTexture[]): void;
  9799. /**
  9800. * 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)
  9801. * @param channel Name of the sampler variable.
  9802. * @param postProcess Post process to get the input texture from.
  9803. */
  9804. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  9805. /**
  9806. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  9807. * 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)
  9808. * @param channel Name of the sampler variable.
  9809. * @param postProcess Post process to get the output texture from.
  9810. */
  9811. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  9812. /** @ignore */
  9813. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  9814. /** @ignore */
  9815. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  9816. /** @ignore */
  9817. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  9818. /** @ignore */
  9819. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  9820. /**
  9821. * Binds a buffer to a uniform.
  9822. * @param buffer Buffer to bind.
  9823. * @param name Name of the uniform variable to bind to.
  9824. */
  9825. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  9826. /**
  9827. * Binds block to a uniform.
  9828. * @param blockName Name of the block to bind.
  9829. * @param index Index to bind.
  9830. */
  9831. bindUniformBlock(blockName: string, index: number): void;
  9832. /**
  9833. * Sets an interger value on a uniform variable.
  9834. * @param uniformName Name of the variable.
  9835. * @param value Value to be set.
  9836. * @returns this effect.
  9837. */
  9838. setInt(uniformName: string, value: number): Effect;
  9839. /**
  9840. * Sets an int array on a uniform variable.
  9841. * @param uniformName Name of the variable.
  9842. * @param array array to be set.
  9843. * @returns this effect.
  9844. */
  9845. setIntArray(uniformName: string, array: Int32Array): Effect;
  9846. /**
  9847. * 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)
  9848. * @param uniformName Name of the variable.
  9849. * @param array array to be set.
  9850. * @returns this effect.
  9851. */
  9852. setIntArray2(uniformName: string, array: Int32Array): Effect;
  9853. /**
  9854. * 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)
  9855. * @param uniformName Name of the variable.
  9856. * @param array array to be set.
  9857. * @returns this effect.
  9858. */
  9859. setIntArray3(uniformName: string, array: Int32Array): Effect;
  9860. /**
  9861. * 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)
  9862. * @param uniformName Name of the variable.
  9863. * @param array array to be set.
  9864. * @returns this effect.
  9865. */
  9866. setIntArray4(uniformName: string, array: Int32Array): Effect;
  9867. /**
  9868. * Sets an float array on a uniform variable.
  9869. * @param uniformName Name of the variable.
  9870. * @param array array to be set.
  9871. * @returns this effect.
  9872. */
  9873. setFloatArray(uniformName: string, array: Float32Array): Effect;
  9874. /**
  9875. * 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)
  9876. * @param uniformName Name of the variable.
  9877. * @param array array to be set.
  9878. * @returns this effect.
  9879. */
  9880. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  9881. /**
  9882. * 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)
  9883. * @param uniformName Name of the variable.
  9884. * @param array array to be set.
  9885. * @returns this effect.
  9886. */
  9887. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  9888. /**
  9889. * 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)
  9890. * @param uniformName Name of the variable.
  9891. * @param array array to be set.
  9892. * @returns this effect.
  9893. */
  9894. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  9895. /**
  9896. * Sets an array on a uniform variable.
  9897. * @param uniformName Name of the variable.
  9898. * @param array array to be set.
  9899. * @returns this effect.
  9900. */
  9901. setArray(uniformName: string, array: number[]): Effect;
  9902. /**
  9903. * 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)
  9904. * @param uniformName Name of the variable.
  9905. * @param array array to be set.
  9906. * @returns this effect.
  9907. */
  9908. setArray2(uniformName: string, array: number[]): Effect;
  9909. /**
  9910. * 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)
  9911. * @param uniformName Name of the variable.
  9912. * @param array array to be set.
  9913. * @returns this effect.
  9914. */
  9915. setArray3(uniformName: string, array: number[]): Effect;
  9916. /**
  9917. * 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)
  9918. * @param uniformName Name of the variable.
  9919. * @param array array to be set.
  9920. * @returns this effect.
  9921. */
  9922. setArray4(uniformName: string, array: number[]): Effect;
  9923. /**
  9924. * Sets matrices on a uniform variable.
  9925. * @param uniformName Name of the variable.
  9926. * @param matrices matrices to be set.
  9927. * @returns this effect.
  9928. */
  9929. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  9930. /**
  9931. * Sets matrix on a uniform variable.
  9932. * @param uniformName Name of the variable.
  9933. * @param matrix matrix to be set.
  9934. * @returns this effect.
  9935. */
  9936. setMatrix(uniformName: string, matrix: Matrix): Effect;
  9937. /**
  9938. * 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)
  9939. * @param uniformName Name of the variable.
  9940. * @param matrix matrix to be set.
  9941. * @returns this effect.
  9942. */
  9943. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  9944. /**
  9945. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  9946. * @param uniformName Name of the variable.
  9947. * @param matrix matrix to be set.
  9948. * @returns this effect.
  9949. */
  9950. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  9951. /**
  9952. * Sets a float on a uniform variable.
  9953. * @param uniformName Name of the variable.
  9954. * @param value value to be set.
  9955. * @returns this effect.
  9956. */
  9957. setFloat(uniformName: string, value: number): Effect;
  9958. /**
  9959. * Sets a boolean on a uniform variable.
  9960. * @param uniformName Name of the variable.
  9961. * @param bool value to be set.
  9962. * @returns this effect.
  9963. */
  9964. setBool(uniformName: string, bool: boolean): Effect;
  9965. /**
  9966. * Sets a Vector2 on a uniform variable.
  9967. * @param uniformName Name of the variable.
  9968. * @param vector2 vector2 to be set.
  9969. * @returns this effect.
  9970. */
  9971. setVector2(uniformName: string, vector2: Vector2): Effect;
  9972. /**
  9973. * Sets a float2 on a uniform variable.
  9974. * @param uniformName Name of the variable.
  9975. * @param x First float in float2.
  9976. * @param y Second float in float2.
  9977. * @returns this effect.
  9978. */
  9979. setFloat2(uniformName: string, x: number, y: number): Effect;
  9980. /**
  9981. * Sets a Vector3 on a uniform variable.
  9982. * @param uniformName Name of the variable.
  9983. * @param vector3 Value to be set.
  9984. * @returns this effect.
  9985. */
  9986. setVector3(uniformName: string, vector3: Vector3): Effect;
  9987. /**
  9988. * Sets a float3 on a uniform variable.
  9989. * @param uniformName Name of the variable.
  9990. * @param x First float in float3.
  9991. * @param y Second float in float3.
  9992. * @param z Third float in float3.
  9993. * @returns this effect.
  9994. */
  9995. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  9996. /**
  9997. * Sets a Vector4 on a uniform variable.
  9998. * @param uniformName Name of the variable.
  9999. * @param vector4 Value to be set.
  10000. * @returns this effect.
  10001. */
  10002. setVector4(uniformName: string, vector4: Vector4): Effect;
  10003. /**
  10004. * Sets a float4 on a uniform variable.
  10005. * @param uniformName Name of the variable.
  10006. * @param x First float in float4.
  10007. * @param y Second float in float4.
  10008. * @param z Third float in float4.
  10009. * @param w Fourth float in float4.
  10010. * @returns this effect.
  10011. */
  10012. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  10013. /**
  10014. * Sets a Color3 on a uniform variable.
  10015. * @param uniformName Name of the variable.
  10016. * @param color3 Value to be set.
  10017. * @returns this effect.
  10018. */
  10019. setColor3(uniformName: string, color3: Color3): Effect;
  10020. /**
  10021. * Sets a Color4 on a uniform variable.
  10022. * @param uniformName Name of the variable.
  10023. * @param color3 Value to be set.
  10024. * @param alpha Alpha value to be set.
  10025. * @returns this effect.
  10026. */
  10027. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  10028. /**
  10029. * Sets a Color4 on a uniform variable
  10030. * @param uniformName defines the name of the variable
  10031. * @param color4 defines the value to be set
  10032. * @returns this effect.
  10033. */
  10034. setDirectColor4(uniformName: string, color4: Color4): Effect;
  10035. /**
  10036. * Store of each shader (The can be looked up using effect.key)
  10037. */
  10038. static ShadersStore: {
  10039. [key: string]: string;
  10040. };
  10041. /**
  10042. * Store of each included file for a shader (The can be looked up using effect.key)
  10043. */
  10044. static IncludesShadersStore: {
  10045. [key: string]: string;
  10046. };
  10047. /**
  10048. * Resets the cache of effects.
  10049. */
  10050. static ResetCache(): void;
  10051. }
  10052. }
  10053. declare module BABYLON {
  10054. class FresnelParameters {
  10055. private _isEnabled;
  10056. isEnabled: boolean;
  10057. leftColor: Color3;
  10058. rightColor: Color3;
  10059. bias: number;
  10060. power: number;
  10061. clone(): FresnelParameters;
  10062. serialize(): any;
  10063. static Parse(parsedFresnelParameters: any): FresnelParameters;
  10064. }
  10065. }
  10066. declare module BABYLON {
  10067. /**
  10068. * Interface to follow in your material defines to integrate easily the
  10069. * Image proccessing functions.
  10070. * @ignore
  10071. */
  10072. interface IImageProcessingConfigurationDefines {
  10073. IMAGEPROCESSING: boolean;
  10074. VIGNETTE: boolean;
  10075. VIGNETTEBLENDMODEMULTIPLY: boolean;
  10076. VIGNETTEBLENDMODEOPAQUE: boolean;
  10077. TONEMAPPING: boolean;
  10078. CONTRAST: boolean;
  10079. EXPOSURE: boolean;
  10080. COLORCURVES: boolean;
  10081. COLORGRADING: boolean;
  10082. COLORGRADING3D: boolean;
  10083. SAMPLER3DGREENDEPTH: boolean;
  10084. SAMPLER3DBGRMAP: boolean;
  10085. IMAGEPROCESSINGPOSTPROCESS: boolean;
  10086. }
  10087. /**
  10088. * This groups together the common properties used for image processing either in direct forward pass
  10089. * or through post processing effect depending on the use of the image processing pipeline in your scene
  10090. * or not.
  10091. */
  10092. class ImageProcessingConfiguration {
  10093. /**
  10094. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  10095. */
  10096. colorCurves: Nullable<ColorCurves>;
  10097. private _colorCurvesEnabled;
  10098. /**
  10099. * Gets wether the color curves effect is enabled.
  10100. */
  10101. /**
  10102. * Sets wether the color curves effect is enabled.
  10103. */
  10104. colorCurvesEnabled: boolean;
  10105. /**
  10106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  10107. */
  10108. colorGradingTexture: Nullable<BaseTexture>;
  10109. private _colorGradingEnabled;
  10110. /**
  10111. * Gets wether the color grading effect is enabled.
  10112. */
  10113. /**
  10114. * Sets wether the color grading effect is enabled.
  10115. */
  10116. colorGradingEnabled: boolean;
  10117. private _colorGradingWithGreenDepth;
  10118. /**
  10119. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  10120. */
  10121. /**
  10122. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  10123. */
  10124. colorGradingWithGreenDepth: boolean;
  10125. private _colorGradingBGR;
  10126. /**
  10127. * Gets wether the color grading texture contains BGR values.
  10128. */
  10129. /**
  10130. * Sets wether the color grading texture contains BGR values.
  10131. */
  10132. colorGradingBGR: boolean;
  10133. _exposure: number;
  10134. /**
  10135. * Gets the Exposure used in the effect.
  10136. */
  10137. /**
  10138. * Sets the Exposure used in the effect.
  10139. */
  10140. exposure: number;
  10141. private _toneMappingEnabled;
  10142. /**
  10143. * Gets wether the tone mapping effect is enabled.
  10144. */
  10145. /**
  10146. * Sets wether the tone mapping effect is enabled.
  10147. */
  10148. toneMappingEnabled: boolean;
  10149. protected _contrast: number;
  10150. /**
  10151. * Gets the contrast used in the effect.
  10152. */
  10153. /**
  10154. * Sets the contrast used in the effect.
  10155. */
  10156. contrast: number;
  10157. /**
  10158. * Vignette stretch size.
  10159. */
  10160. vignetteStretch: number;
  10161. /**
  10162. * Vignette centre X Offset.
  10163. */
  10164. vignetteCentreX: number;
  10165. /**
  10166. * Vignette centre Y Offset.
  10167. */
  10168. vignetteCentreY: number;
  10169. /**
  10170. * Vignette weight or intensity of the vignette effect.
  10171. */
  10172. vignetteWeight: number;
  10173. /**
  10174. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  10175. * if vignetteEnabled is set to true.
  10176. */
  10177. vignetteColor: Color4;
  10178. /**
  10179. * Camera field of view used by the Vignette effect.
  10180. */
  10181. vignetteCameraFov: number;
  10182. private _vignetteBlendMode;
  10183. /**
  10184. * Gets the vignette blend mode allowing different kind of effect.
  10185. */
  10186. /**
  10187. * Sets the vignette blend mode allowing different kind of effect.
  10188. */
  10189. vignetteBlendMode: number;
  10190. private _vignetteEnabled;
  10191. /**
  10192. * Gets wether the vignette effect is enabled.
  10193. */
  10194. /**
  10195. * Sets wether the vignette effect is enabled.
  10196. */
  10197. vignetteEnabled: boolean;
  10198. private _applyByPostProcess;
  10199. /**
  10200. * Gets wether the image processing is applied through a post process or not.
  10201. */
  10202. /**
  10203. * Sets wether the image processing is applied through a post process or not.
  10204. */
  10205. applyByPostProcess: boolean;
  10206. private _isEnabled;
  10207. /**
  10208. * Gets wether the image processing is enabled or not.
  10209. */
  10210. /**
  10211. * Sets wether the image processing is enabled or not.
  10212. */
  10213. isEnabled: boolean;
  10214. /**
  10215. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  10216. */
  10217. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  10218. /**
  10219. * Method called each time the image processing information changes requires to recompile the effect.
  10220. */
  10221. protected _updateParameters(): void;
  10222. getClassName(): string;
  10223. /**
  10224. * Prepare the list of uniforms associated with the Image Processing effects.
  10225. * @param uniformsList The list of uniforms used in the effect
  10226. * @param defines the list of defines currently in use
  10227. */
  10228. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  10229. /**
  10230. * Prepare the list of samplers associated with the Image Processing effects.
  10231. * @param uniformsList The list of uniforms used in the effect
  10232. * @param defines the list of defines currently in use
  10233. */
  10234. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  10235. /**
  10236. * Prepare the list of defines associated to the shader.
  10237. * @param defines the list of defines to complete
  10238. */
  10239. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  10240. /**
  10241. * Returns true if all the image processing information are ready.
  10242. */
  10243. isReady(): boolean;
  10244. /**
  10245. * Binds the image processing to the shader.
  10246. * @param effect The effect to bind to
  10247. */
  10248. bind(effect: Effect, aspectRatio?: number): void;
  10249. /**
  10250. * Clones the current image processing instance.
  10251. * @return The cloned image processing
  10252. */
  10253. clone(): ImageProcessingConfiguration;
  10254. /**
  10255. * Serializes the current image processing instance to a json representation.
  10256. * @return a JSON representation
  10257. */
  10258. serialize(): any;
  10259. /**
  10260. * Parses the image processing from a json representation.
  10261. * @param source the JSON source to parse
  10262. * @return The parsed image processing
  10263. */
  10264. static Parse(source: any): ImageProcessingConfiguration;
  10265. private static _VIGNETTEMODE_MULTIPLY;
  10266. private static _VIGNETTEMODE_OPAQUE;
  10267. /**
  10268. * Used to apply the vignette as a mix with the pixel color.
  10269. */
  10270. static readonly VIGNETTEMODE_MULTIPLY: number;
  10271. /**
  10272. * Used to apply the vignette as a replacement of the pixel color.
  10273. */
  10274. static readonly VIGNETTEMODE_OPAQUE: number;
  10275. }
  10276. }
  10277. declare module BABYLON {
  10278. /**
  10279. * Manages the defines for the Material.
  10280. */
  10281. class MaterialDefines {
  10282. private _keys;
  10283. private _isDirty;
  10284. _renderId: number;
  10285. _areLightsDirty: boolean;
  10286. _areAttributesDirty: boolean;
  10287. _areTexturesDirty: boolean;
  10288. _areFresnelDirty: boolean;
  10289. _areMiscDirty: boolean;
  10290. _areImageProcessingDirty: boolean;
  10291. _normals: boolean;
  10292. _uvs: boolean;
  10293. _needNormals: boolean;
  10294. _needUVs: boolean;
  10295. /**
  10296. * Specifies if the material needs to be re-calculated.
  10297. */
  10298. readonly isDirty: boolean;
  10299. /**
  10300. * Marks the material to indicate that it has been re-calculated.
  10301. */
  10302. markAsProcessed(): void;
  10303. /**
  10304. * Marks the material to indicate that it needs to be re-calculated.
  10305. */
  10306. markAsUnprocessed(): void;
  10307. /**
  10308. * Marks the material to indicate all of its defines need to be re-calculated.
  10309. */
  10310. markAllAsDirty(): void;
  10311. /**
  10312. * Marks the material to indicate that image processing needs to be re-calculated.
  10313. */
  10314. markAsImageProcessingDirty(): void;
  10315. /**
  10316. * Marks the material to indicate the lights need to be re-calculated.
  10317. */
  10318. markAsLightDirty(): void;
  10319. /**
  10320. * Marks the attribute state as changed.
  10321. */
  10322. markAsAttributesDirty(): void;
  10323. /**
  10324. * Marks the texture state as changed.
  10325. */
  10326. markAsTexturesDirty(): void;
  10327. /**
  10328. * Marks the fresnel state as changed.
  10329. */
  10330. markAsFresnelDirty(): void;
  10331. /**
  10332. * Marks the misc state as changed.
  10333. */
  10334. markAsMiscDirty(): void;
  10335. /**
  10336. * Rebuilds the material defines.
  10337. */
  10338. rebuild(): void;
  10339. /**
  10340. * Specifies if two material defines are equal.
  10341. * @param other - A material define instance to compare to.
  10342. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  10343. */
  10344. isEqual(other: MaterialDefines): boolean;
  10345. /**
  10346. * Clones this instance's defines to another instance.
  10347. * @param other - material defines to clone values to.
  10348. */
  10349. cloneTo(other: MaterialDefines): void;
  10350. /**
  10351. * Resets the material define values.
  10352. */
  10353. reset(): void;
  10354. /**
  10355. * Converts the material define values to a string.
  10356. * @returns - String of material define information.
  10357. */
  10358. toString(): string;
  10359. }
  10360. /**
  10361. * This offers the main features of a material in BJS.
  10362. */
  10363. class Material implements IAnimatable {
  10364. private static _TriangleFillMode;
  10365. private static _WireFrameFillMode;
  10366. private static _PointFillMode;
  10367. private static _PointListDrawMode;
  10368. private static _LineListDrawMode;
  10369. private static _LineLoopDrawMode;
  10370. private static _LineStripDrawMode;
  10371. private static _TriangleStripDrawMode;
  10372. private static _TriangleFanDrawMode;
  10373. /**
  10374. * Returns the triangle fill mode.
  10375. */
  10376. static readonly TriangleFillMode: number;
  10377. /**
  10378. * Returns the wireframe mode.
  10379. */
  10380. static readonly WireFrameFillMode: number;
  10381. /**
  10382. * Returns the point fill mode.
  10383. */
  10384. static readonly PointFillMode: number;
  10385. /**
  10386. * Returns the point list draw mode.
  10387. */
  10388. static readonly PointListDrawMode: number;
  10389. /**
  10390. * Returns the line list draw mode.
  10391. */
  10392. static readonly LineListDrawMode: number;
  10393. /**
  10394. * Returns the line loop draw mode.
  10395. */
  10396. static readonly LineLoopDrawMode: number;
  10397. /**
  10398. * Returns the line strip draw mode.
  10399. */
  10400. static readonly LineStripDrawMode: number;
  10401. /**
  10402. * Returns the triangle strip draw mode.
  10403. */
  10404. static readonly TriangleStripDrawMode: number;
  10405. /**
  10406. * Returns the triangle fan draw mode.
  10407. */
  10408. static readonly TriangleFanDrawMode: number;
  10409. /**
  10410. * Stores the clock-wise side orientation.
  10411. */
  10412. private static _ClockWiseSideOrientation;
  10413. /**
  10414. * Stores the counter clock-wise side orientation.
  10415. */
  10416. private static _CounterClockWiseSideOrientation;
  10417. /**
  10418. * Returns the clock-wise side orientation.
  10419. */
  10420. static readonly ClockWiseSideOrientation: number;
  10421. /**
  10422. * Returns the counter clock-wise side orientation.
  10423. */
  10424. static readonly CounterClockWiseSideOrientation: number;
  10425. /**
  10426. * The dirty texture flag value.
  10427. */
  10428. private static _TextureDirtyFlag;
  10429. /**
  10430. * The dirty light flag value.
  10431. */
  10432. private static _LightDirtyFlag;
  10433. /**
  10434. * The dirty fresnel flag value.
  10435. */
  10436. private static _FresnelDirtyFlag;
  10437. /**
  10438. * The dirty attribute flag value.
  10439. */
  10440. private static _AttributesDirtyFlag;
  10441. /**
  10442. * The dirty misc flag value.
  10443. */
  10444. private static _MiscDirtyFlag;
  10445. /**
  10446. * Returns the dirty texture flag value.
  10447. */
  10448. static readonly TextureDirtyFlag: number;
  10449. /**
  10450. * Returns the dirty light flag value.
  10451. */
  10452. static readonly LightDirtyFlag: number;
  10453. /**
  10454. * Returns the dirty fresnel flag value.
  10455. */
  10456. static readonly FresnelDirtyFlag: number;
  10457. /**
  10458. * Returns the dirty attributes flag value.
  10459. */
  10460. static readonly AttributesDirtyFlag: number;
  10461. /**
  10462. * Returns the dirty misc flag value.
  10463. */
  10464. static readonly MiscDirtyFlag: number;
  10465. /**
  10466. * The ID of the material.
  10467. */
  10468. id: string;
  10469. /**
  10470. * The name of the material.
  10471. */
  10472. name: string;
  10473. /**
  10474. * Specifies if the ready state should be checked on each call.
  10475. */
  10476. checkReadyOnEveryCall: boolean;
  10477. /**
  10478. * Specifies if the ready state should be checked once.
  10479. */
  10480. checkReadyOnlyOnce: boolean;
  10481. /**
  10482. * The state of the material.
  10483. */
  10484. state: string;
  10485. /**
  10486. * The alpha value of the material.
  10487. */
  10488. protected _alpha: number;
  10489. /**
  10490. * Gets the alpha value of the material.
  10491. */
  10492. /**
  10493. * Sets the alpha value of the material.
  10494. */
  10495. alpha: number;
  10496. /**
  10497. * Specifies if back face culling is enabled.
  10498. */
  10499. protected _backFaceCulling: boolean;
  10500. /**
  10501. * Gets the back-face culling state.
  10502. */
  10503. /**
  10504. * Sets the back-face culling state.
  10505. */
  10506. backFaceCulling: boolean;
  10507. /**
  10508. * Stores the value for side orientation.
  10509. */
  10510. sideOrientation: number;
  10511. /**
  10512. * Callback triggered when the material is compiled.
  10513. */
  10514. onCompiled: (effect: Effect) => void;
  10515. /**
  10516. * Callback triggered when an error occurs.
  10517. */
  10518. onError: (effect: Effect, errors: string) => void;
  10519. /**
  10520. * Callback triggered to get the render target textures.
  10521. */
  10522. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  10523. /**
  10524. * Specifies if the material should be serialized.
  10525. */
  10526. doNotSerialize: boolean;
  10527. /**
  10528. * Specifies if the effect should be stored on sub meshes.
  10529. */
  10530. storeEffectOnSubMeshes: boolean;
  10531. /**
  10532. * Stores the animations for the material.
  10533. */
  10534. animations: Array<Animation>;
  10535. /**
  10536. * An event triggered when the material is disposed.
  10537. */
  10538. onDisposeObservable: Observable<Material>;
  10539. /**
  10540. * An observer which watches for dispose events.
  10541. */
  10542. private _onDisposeObserver;
  10543. /**
  10544. * Called during a dispose event.
  10545. */
  10546. onDispose: () => void;
  10547. /**
  10548. * An event triggered when the material is bound.
  10549. */
  10550. onBindObservable: Observable<AbstractMesh>;
  10551. /**
  10552. * An observer which watches for bind events.
  10553. */
  10554. private _onBindObserver;
  10555. /**
  10556. * Called during a bind event.
  10557. */
  10558. onBind: (Mesh: AbstractMesh) => void;
  10559. /**
  10560. * An event triggered when the material is unbound.
  10561. */
  10562. onUnBindObservable: Observable<Material>;
  10563. /**
  10564. * Stores the value of the alpha mode.
  10565. */
  10566. private _alphaMode;
  10567. /**
  10568. * Gets the value of the alpha mode.
  10569. */
  10570. /**
  10571. * Sets the value of the alpha mode.
  10572. *
  10573. * | Value | Type | Description |
  10574. * | --- | --- | --- |
  10575. * | 0 | ALPHA_DISABLE | |
  10576. * | 1 | ALPHA_ADD | |
  10577. * | 2 | ALPHA_COMBINE | |
  10578. * | 3 | ALPHA_SUBTRACT | |
  10579. * | 4 | ALPHA_MULTIPLY | |
  10580. * | 5 | ALPHA_MAXIMIZED | |
  10581. * | 6 | ALPHA_ONEONE | |
  10582. * | 7 | ALPHA_PREMULTIPLIED | |
  10583. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  10584. * | 9 | ALPHA_INTERPOLATE | |
  10585. * | 10 | ALPHA_SCREENMODE | |
  10586. *
  10587. */
  10588. alphaMode: number;
  10589. /**
  10590. * Stores the state of the need depth pre-pass value.
  10591. */
  10592. private _needDepthPrePass;
  10593. /**
  10594. * Gets the depth pre-pass value.
  10595. */
  10596. /**
  10597. * Sets the need depth pre-pass value.
  10598. */
  10599. needDepthPrePass: boolean;
  10600. /**
  10601. * Specifies if depth writing should be disabled.
  10602. */
  10603. disableDepthWrite: boolean;
  10604. /**
  10605. * Specifies if depth writing should be forced.
  10606. */
  10607. forceDepthWrite: boolean;
  10608. /**
  10609. * Specifies if there should be a separate pass for culling.
  10610. */
  10611. separateCullingPass: boolean;
  10612. /**
  10613. * Stores the state specifing if fog should be enabled.
  10614. */
  10615. private _fogEnabled;
  10616. /**
  10617. * Gets the value of the fog enabled state.
  10618. */
  10619. /**
  10620. * Sets the state for enabling fog.
  10621. */
  10622. fogEnabled: boolean;
  10623. /**
  10624. * Stores the size of points.
  10625. */
  10626. pointSize: number;
  10627. /**
  10628. * Stores the z offset value.
  10629. */
  10630. zOffset: number;
  10631. /**
  10632. * Gets a value specifying if wireframe mode is enabled.
  10633. */
  10634. /**
  10635. * Sets the state of wireframe mode.
  10636. */
  10637. wireframe: boolean;
  10638. /**
  10639. * Gets the value specifying if point clouds are enabled.
  10640. */
  10641. /**
  10642. * Sets the state of point cloud mode.
  10643. */
  10644. pointsCloud: boolean;
  10645. /**
  10646. * Gets the material fill mode.
  10647. */
  10648. /**
  10649. * Sets the material fill mode.
  10650. */
  10651. fillMode: number;
  10652. /**
  10653. * Stores the effects for the material.
  10654. */
  10655. _effect: Nullable<Effect>;
  10656. /**
  10657. * Specifies if the material was previously ready.
  10658. */
  10659. _wasPreviouslyReady: boolean;
  10660. /**
  10661. * Specifies if uniform buffers should be used.
  10662. */
  10663. private _useUBO;
  10664. /**
  10665. * Stores a reference to the scene.
  10666. */
  10667. private _scene;
  10668. /**
  10669. * Stores the fill mode state.
  10670. */
  10671. private _fillMode;
  10672. /**
  10673. * Specifies if the depth write state should be cached.
  10674. */
  10675. private _cachedDepthWriteState;
  10676. /**
  10677. * Stores the uniform buffer.
  10678. */
  10679. protected _uniformBuffer: UniformBuffer;
  10680. /**
  10681. * Creates a material instance.
  10682. * @param name - The name of the material.
  10683. * @param scene - The BJS scene to reference.
  10684. * @param doNotAdd - Specifies if the material should be added to the scene.
  10685. */
  10686. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  10687. /**
  10688. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  10689. * subclasses should override adding information pertainent to themselves.
  10690. * @returns - String with material information.
  10691. */
  10692. toString(fullDetails?: boolean): string;
  10693. /**
  10694. * Gets the class name of the material.
  10695. * @returns - String with the class name of the material.
  10696. */
  10697. getClassName(): string;
  10698. /**
  10699. * Specifies if updates for the material been locked.
  10700. */
  10701. readonly isFrozen: boolean;
  10702. /**
  10703. * Locks updates for the material.
  10704. */
  10705. freeze(): void;
  10706. /**
  10707. * Unlocks updates for the material.
  10708. */
  10709. unfreeze(): void;
  10710. /**
  10711. * Specifies if the material is ready to be used.
  10712. * @param mesh - BJS mesh.
  10713. * @param useInstances - Specifies if instances should be used.
  10714. * @returns - Boolean indicating if the material is ready to be used.
  10715. */
  10716. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  10717. /**
  10718. * Specifies that the submesh is ready to be used.
  10719. * @param mesh - BJS mesh.
  10720. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  10721. * @param useInstances - Specifies that instances should be used.
  10722. * @returns - boolean indicating that the submesh is ready or not.
  10723. */
  10724. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  10725. /**
  10726. * Returns the material effect.
  10727. * @returns - Nullable material effect.
  10728. */
  10729. getEffect(): Nullable<Effect>;
  10730. /**
  10731. * Returns the BJS scene.
  10732. * @returns - BJS Scene.
  10733. */
  10734. getScene(): Scene;
  10735. /**
  10736. * Specifies if the material will require alpha blending
  10737. * @returns - Boolean specifying if alpha blending is needed.
  10738. */
  10739. needAlphaBlending(): boolean;
  10740. /**
  10741. * Specifies if the mesh will require alpha blending.
  10742. * @param mesh - BJS mesh.
  10743. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  10744. */
  10745. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  10746. /**
  10747. * Specifies if this material should be rendered in alpha test mode.
  10748. * @returns - Boolean specifying if an alpha test is needed.
  10749. */
  10750. needAlphaTesting(): boolean;
  10751. /**
  10752. * Gets the texture used for the alpha test.
  10753. * @returns - Nullable alpha test texture.
  10754. */
  10755. getAlphaTestTexture(): Nullable<BaseTexture>;
  10756. /**
  10757. * Marks the material to indicate that it needs to be re-calculated.
  10758. */
  10759. markDirty(): void;
  10760. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  10761. /**
  10762. * Binds the material to the mesh.
  10763. * @param world - World transformation matrix.
  10764. * @param mesh - Mesh to bind the material to.
  10765. */
  10766. bind(world: Matrix, mesh?: Mesh): void;
  10767. /**
  10768. * Binds the submesh to the material.
  10769. * @param world - World transformation matrix.
  10770. * @param mesh - Mesh containing the submesh.
  10771. * @param subMesh - Submesh to bind the material to.
  10772. */
  10773. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  10774. /**
  10775. * Binds the world matrix to the material.
  10776. * @param world - World transformation matrix.
  10777. */
  10778. bindOnlyWorldMatrix(world: Matrix): void;
  10779. /**
  10780. * Binds the scene's uniform buffer to the effect.
  10781. * @param effect - Effect to bind to the scene uniform buffer.
  10782. * @param sceneUbo - Scene uniform buffer.
  10783. */
  10784. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  10785. /**
  10786. * Binds the view matrix to the effect.
  10787. * @param effect - Effect to bind the view matrix to.
  10788. */
  10789. bindView(effect: Effect): void;
  10790. /**
  10791. * Binds the view projection matrix to the effect.
  10792. * @param effect - Effect to bind the view projection matrix to.
  10793. */
  10794. bindViewProjection(effect: Effect): void;
  10795. /**
  10796. * Specifies if material alpha testing should be turned on for the mesh.
  10797. * @param mesh - BJS mesh.
  10798. */
  10799. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  10800. /**
  10801. * Processes to execute after binding the material to a mesh.
  10802. * @param mesh - BJS mesh.
  10803. */
  10804. protected _afterBind(mesh?: Mesh): void;
  10805. /**
  10806. * Unbinds the material from the mesh.
  10807. */
  10808. unbind(): void;
  10809. /**
  10810. * Gets the active textures from the material.
  10811. * @returns - Array of textures.
  10812. */
  10813. getActiveTextures(): BaseTexture[];
  10814. /**
  10815. * Specifies if the material uses a texture.
  10816. * @param texture - Texture to check against the material.
  10817. * @returns - Boolean specifying if the material uses the texture.
  10818. */
  10819. hasTexture(texture: BaseTexture): boolean;
  10820. /**
  10821. * Makes a duplicate of the material, and gives it a new name.
  10822. * @param name - Name to call the duplicated material.
  10823. * @returns - Nullable cloned material
  10824. */
  10825. clone(name: string): Nullable<Material>;
  10826. /**
  10827. * Gets the meshes bound to the material.
  10828. * @returns - Array of meshes bound to the material.
  10829. */
  10830. getBindedMeshes(): AbstractMesh[];
  10831. /**
  10832. * Force shader compilation
  10833. * @param mesh - BJS mesh.
  10834. * @param onCompiled - function to execute once the material is compiled.
  10835. * @param options - options to pass to this function.
  10836. */
  10837. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  10838. clipPlane: boolean;
  10839. }>): void;
  10840. /**
  10841. * Force shader compilation.
  10842. * @param mesh The mesh that will use this material
  10843. * @param options Additional options for compiling the shaders
  10844. * @returns A promise that resolves when the compilation completes
  10845. */
  10846. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  10847. clipPlane: boolean;
  10848. }>): Promise<void>;
  10849. /**
  10850. * Marks a define in the material to indicate that it needs to be re-computed.
  10851. * @param flag - Material define flag.
  10852. */
  10853. markAsDirty(flag: number): void;
  10854. /**
  10855. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  10856. * @param func - function which checks material defines against the submeshes.
  10857. */
  10858. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  10859. /**
  10860. * Indicates that image processing needs to be re-calculated for all submeshes.
  10861. */
  10862. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  10863. /**
  10864. * Indicates that textures need to be re-calculated for all submeshes.
  10865. */
  10866. protected _markAllSubMeshesAsTexturesDirty(): void;
  10867. /**
  10868. * Indicates that fresnel needs to be re-calculated for all submeshes.
  10869. */
  10870. protected _markAllSubMeshesAsFresnelDirty(): void;
  10871. /**
  10872. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  10873. */
  10874. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  10875. /**
  10876. * Indicates that lights need to be re-calculated for all submeshes.
  10877. */
  10878. protected _markAllSubMeshesAsLightsDirty(): void;
  10879. /**
  10880. * Indicates that attributes need to be re-calculated for all submeshes.
  10881. */
  10882. protected _markAllSubMeshesAsAttributesDirty(): void;
  10883. /**
  10884. * Indicates that misc needs to be re-calculated for all submeshes.
  10885. */
  10886. protected _markAllSubMeshesAsMiscDirty(): void;
  10887. /**
  10888. * Indicates that textures and misc need to be re-calculated for all submeshes.
  10889. */
  10890. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  10891. /**
  10892. * Disposes the material.
  10893. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  10894. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  10895. */
  10896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  10897. /**
  10898. * Serializes this material.
  10899. * @returns - serialized material object.
  10900. */
  10901. serialize(): any;
  10902. /**
  10903. * Creates a MultiMaterial from parse MultiMaterial data.
  10904. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  10905. * @param scene - BJS scene.
  10906. * @returns - MultiMaterial.
  10907. */
  10908. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  10909. /**
  10910. * Creates a material from parsed material data.
  10911. * @param parsedMaterial - Parsed material data.
  10912. * @param scene - BJS scene.
  10913. * @param rootUrl - Root URL containing the material information.
  10914. * @returns - Parsed material.
  10915. */
  10916. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  10917. }
  10918. }
  10919. declare module BABYLON {
  10920. /**
  10921. * "Static Class" containing the most commonly used helper while dealing with material for
  10922. * rendering purpose.
  10923. *
  10924. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10925. *
  10926. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10927. */
  10928. class MaterialHelper {
  10929. /**
  10930. * Bind the current view position to an effect.
  10931. * @param effect The effect to be bound
  10932. * @param scene The scene the eyes position is used from
  10933. */
  10934. static BindEyePosition(effect: Effect, scene: Scene): void;
  10935. /**
  10936. * Helps preparing the defines values about the UVs in used in the effect.
  10937. * UVs are shared as much as we can accross chanels in the shaders.
  10938. * @param texture The texture we are preparing the UVs for
  10939. * @param defines The defines to update
  10940. * @param key The chanel key "diffuse", "specular"... used in the shader
  10941. */
  10942. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10943. /**
  10944. * Binds a texture matrix value to its corrsponding uniform
  10945. * @param texture The texture to bind the matrix for
  10946. * @param uniformBuffer The uniform buffer receivin the data
  10947. * @param key The chanel key "diffuse", "specular"... used in the shader
  10948. */
  10949. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10950. /**
  10951. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10952. * @param mesh defines the current mesh
  10953. * @param scene defines the current scene
  10954. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10955. * @param pointsCloud defines if point cloud rendering has to be turned on
  10956. * @param fogEnabled defines if fog has to be turned on
  10957. * @param alphaTest defines if alpha testing has to be turned on
  10958. * @param defines defines the current list of defines
  10959. */
  10960. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10961. /**
  10962. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10963. * @param scene defines the current scene
  10964. * @param engine defines the current engine
  10965. * @param defines specifies the list of active defines
  10966. * @param useInstances defines if instances have to be turned on
  10967. * @param useClipPlane defines if clip plane have to be turned on
  10968. */
  10969. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10970. /**
  10971. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10972. * @param mesh The mesh containing the geometry data we will draw
  10973. * @param defines The defines to update
  10974. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10975. * @param useBones Precise whether bones should be used or not (override mesh info)
  10976. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10977. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10978. * @returns false if defines are considered not dirty and have not been checked
  10979. */
  10980. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10981. /**
  10982. * Prepares the defines related to the light information passed in parameter
  10983. * @param scene The scene we are intending to draw
  10984. * @param mesh The mesh the effect is compiling for
  10985. * @param defines The defines to update
  10986. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10987. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10988. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10989. * @returns true if normals will be required for the rest of the effect
  10990. */
  10991. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10992. /**
  10993. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10994. * that won t be acctive due to defines being turned off.
  10995. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10996. * @param samplersList The samplers list
  10997. * @param defines The defines helping in the list generation
  10998. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10999. */
  11000. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11001. /**
  11002. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11003. * @param defines The defines to update while falling back
  11004. * @param fallbacks The authorized effect fallbacks
  11005. * @param maxSimultaneousLights The maximum number of lights allowed
  11006. * @param rank the current rank of the Effect
  11007. * @returns The newly affected rank
  11008. */
  11009. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11010. /**
  11011. * Prepares the list of attributes required for morph targets according to the effect defines.
  11012. * @param attribs The current list of supported attribs
  11013. * @param mesh The mesh to prepare the morph targets attributes for
  11014. * @param defines The current Defines of the effect
  11015. */
  11016. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11017. /**
  11018. * Prepares the list of attributes required for bones according to the effect defines.
  11019. * @param attribs The current list of supported attribs
  11020. * @param mesh The mesh to prepare the bones attributes for
  11021. * @param defines The current Defines of the effect
  11022. * @param fallbacks The current efffect fallback strategy
  11023. */
  11024. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11025. /**
  11026. * Prepares the list of attributes required for instances according to the effect defines.
  11027. * @param attribs The current list of supported attribs
  11028. * @param defines The current Defines of the effect
  11029. */
  11030. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  11031. /**
  11032. * Binds the light shadow information to the effect for the given mesh.
  11033. * @param light The light containing the generator
  11034. * @param scene The scene the lights belongs to
  11035. * @param mesh The mesh we are binding the information to render
  11036. * @param lightIndex The light index in the effect used to render the mesh
  11037. * @param effect The effect we are binding the data to
  11038. */
  11039. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11040. /**
  11041. * Binds the light information to the effect.
  11042. * @param light The light containing the generator
  11043. * @param effect The effect we are binding the data to
  11044. * @param lightIndex The light index in the effect used to render
  11045. */
  11046. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11047. /**
  11048. * Binds the lights information from the scene to the effect for the given mesh.
  11049. * @param scene The scene the lights belongs to
  11050. * @param mesh The mesh we are binding the information to render
  11051. * @param effect The effect we are binding the data to
  11052. * @param defines The generated defines for the effect
  11053. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11054. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11055. */
  11056. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11057. /**
  11058. * Binds the fog information from the scene to the effect for the given mesh.
  11059. * @param scene The scene the lights belongs to
  11060. * @param mesh The mesh we are binding the information to render
  11061. * @param effect The effect we are binding the data to
  11062. */
  11063. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  11064. /**
  11065. * Binds the bones information from the mesh to the effect.
  11066. * @param mesh The mesh we are binding the information to render
  11067. * @param effect The effect we are binding the data to
  11068. */
  11069. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11070. /**
  11071. * Binds the morph targets information from the mesh to the effect.
  11072. * @param abstractMesh The mesh we are binding the information to render
  11073. * @param effect The effect we are binding the data to
  11074. */
  11075. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11076. /**
  11077. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11078. * @param defines The generated defines used in the effect
  11079. * @param effect The effect we are binding the data to
  11080. * @param scene The scene we are willing to render with logarithmic scale for
  11081. */
  11082. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11083. /**
  11084. * Binds the clip plane information from the scene to the effect.
  11085. * @param scene The scene the clip plane information are extracted from
  11086. * @param effect The effect we are binding the data to
  11087. */
  11088. static BindClipPlane(effect: Effect, scene: Scene): void;
  11089. }
  11090. }
  11091. declare module BABYLON {
  11092. class MultiMaterial extends Material {
  11093. private _subMaterials;
  11094. subMaterials: Nullable<Material>[];
  11095. constructor(name: string, scene: Scene);
  11096. private _hookArray(array);
  11097. getSubMaterial(index: number): Nullable<Material>;
  11098. getActiveTextures(): BaseTexture[];
  11099. getClassName(): string;
  11100. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  11101. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  11102. serialize(): any;
  11103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  11104. }
  11105. }
  11106. declare module BABYLON {
  11107. class PushMaterial extends Material {
  11108. protected _activeEffect: Effect;
  11109. protected _normalMatrix: Matrix;
  11110. constructor(name: string, scene: Scene);
  11111. getEffect(): Effect;
  11112. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  11113. /**
  11114. * Binds the given world matrix to the active effect
  11115. *
  11116. * @param world the matrix to bind
  11117. */
  11118. bindOnlyWorldMatrix(world: Matrix): void;
  11119. /**
  11120. * Binds the given normal matrix to the active effect
  11121. *
  11122. * @param normalMatrix the matrix to bind
  11123. */
  11124. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  11125. bind(world: Matrix, mesh?: Mesh): void;
  11126. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  11127. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  11128. }
  11129. }
  11130. declare module BABYLON {
  11131. class ShaderMaterial extends Material {
  11132. private _shaderPath;
  11133. private _options;
  11134. private _textures;
  11135. private _textureArrays;
  11136. private _floats;
  11137. private _ints;
  11138. private _floatsArrays;
  11139. private _colors3;
  11140. private _colors3Arrays;
  11141. private _colors4;
  11142. private _vectors2;
  11143. private _vectors3;
  11144. private _vectors4;
  11145. private _matrices;
  11146. private _matrices3x3;
  11147. private _matrices2x2;
  11148. private _vectors2Arrays;
  11149. private _vectors3Arrays;
  11150. private _cachedWorldViewMatrix;
  11151. private _renderId;
  11152. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  11153. getClassName(): string;
  11154. needAlphaBlending(): boolean;
  11155. needAlphaTesting(): boolean;
  11156. private _checkUniform(uniformName);
  11157. setTexture(name: string, texture: Texture): ShaderMaterial;
  11158. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  11159. setFloat(name: string, value: number): ShaderMaterial;
  11160. setInt(name: string, value: number): ShaderMaterial;
  11161. setFloats(name: string, value: number[]): ShaderMaterial;
  11162. setColor3(name: string, value: Color3): ShaderMaterial;
  11163. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  11164. setColor4(name: string, value: Color4): ShaderMaterial;
  11165. setVector2(name: string, value: Vector2): ShaderMaterial;
  11166. setVector3(name: string, value: Vector3): ShaderMaterial;
  11167. setVector4(name: string, value: Vector4): ShaderMaterial;
  11168. setMatrix(name: string, value: Matrix): ShaderMaterial;
  11169. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  11170. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  11171. setArray2(name: string, value: number[]): ShaderMaterial;
  11172. setArray3(name: string, value: number[]): ShaderMaterial;
  11173. private _checkCache(scene, mesh?, useInstances?);
  11174. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  11175. bindOnlyWorldMatrix(world: Matrix): void;
  11176. bind(world: Matrix, mesh?: Mesh): void;
  11177. getActiveTextures(): BaseTexture[];
  11178. hasTexture(texture: BaseTexture): boolean;
  11179. clone(name: string): ShaderMaterial;
  11180. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  11181. serialize(): any;
  11182. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  11183. }
  11184. }
  11185. declare module BABYLON {
  11186. /** @ignore */
  11187. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11188. MAINUV1: boolean;
  11189. MAINUV2: boolean;
  11190. DIFFUSE: boolean;
  11191. DIFFUSEDIRECTUV: number;
  11192. AMBIENT: boolean;
  11193. AMBIENTDIRECTUV: number;
  11194. OPACITY: boolean;
  11195. OPACITYDIRECTUV: number;
  11196. OPACITYRGB: boolean;
  11197. REFLECTION: boolean;
  11198. EMISSIVE: boolean;
  11199. EMISSIVEDIRECTUV: number;
  11200. SPECULAR: boolean;
  11201. SPECULARDIRECTUV: number;
  11202. BUMP: boolean;
  11203. BUMPDIRECTUV: number;
  11204. PARALLAX: boolean;
  11205. PARALLAXOCCLUSION: boolean;
  11206. SPECULAROVERALPHA: boolean;
  11207. CLIPPLANE: boolean;
  11208. ALPHATEST: boolean;
  11209. DEPTHPREPASS: boolean;
  11210. ALPHAFROMDIFFUSE: boolean;
  11211. POINTSIZE: boolean;
  11212. FOG: boolean;
  11213. SPECULARTERM: boolean;
  11214. DIFFUSEFRESNEL: boolean;
  11215. OPACITYFRESNEL: boolean;
  11216. REFLECTIONFRESNEL: boolean;
  11217. REFRACTIONFRESNEL: boolean;
  11218. EMISSIVEFRESNEL: boolean;
  11219. FRESNEL: boolean;
  11220. NORMAL: boolean;
  11221. UV1: boolean;
  11222. UV2: boolean;
  11223. VERTEXCOLOR: boolean;
  11224. VERTEXALPHA: boolean;
  11225. NUM_BONE_INFLUENCERS: number;
  11226. BonesPerMesh: number;
  11227. INSTANCES: boolean;
  11228. GLOSSINESS: boolean;
  11229. ROUGHNESS: boolean;
  11230. EMISSIVEASILLUMINATION: boolean;
  11231. LINKEMISSIVEWITHDIFFUSE: boolean;
  11232. REFLECTIONFRESNELFROMSPECULAR: boolean;
  11233. LIGHTMAP: boolean;
  11234. LIGHTMAPDIRECTUV: number;
  11235. OBJECTSPACE_NORMALMAP: boolean;
  11236. USELIGHTMAPASSHADOWMAP: boolean;
  11237. REFLECTIONMAP_3D: boolean;
  11238. REFLECTIONMAP_SPHERICAL: boolean;
  11239. REFLECTIONMAP_PLANAR: boolean;
  11240. REFLECTIONMAP_CUBIC: boolean;
  11241. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  11242. REFLECTIONMAP_PROJECTION: boolean;
  11243. REFLECTIONMAP_SKYBOX: boolean;
  11244. REFLECTIONMAP_EXPLICIT: boolean;
  11245. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  11246. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  11247. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  11248. INVERTCUBICMAP: boolean;
  11249. LOGARITHMICDEPTH: boolean;
  11250. REFRACTION: boolean;
  11251. REFRACTIONMAP_3D: boolean;
  11252. REFLECTIONOVERALPHA: boolean;
  11253. TWOSIDEDLIGHTING: boolean;
  11254. SHADOWFLOAT: boolean;
  11255. MORPHTARGETS: boolean;
  11256. MORPHTARGETS_NORMAL: boolean;
  11257. MORPHTARGETS_TANGENT: boolean;
  11258. NUM_MORPH_INFLUENCERS: number;
  11259. NONUNIFORMSCALING: boolean;
  11260. PREMULTIPLYALPHA: boolean;
  11261. IMAGEPROCESSING: boolean;
  11262. VIGNETTE: boolean;
  11263. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11264. VIGNETTEBLENDMODEOPAQUE: boolean;
  11265. TONEMAPPING: boolean;
  11266. CONTRAST: boolean;
  11267. COLORCURVES: boolean;
  11268. COLORGRADING: boolean;
  11269. COLORGRADING3D: boolean;
  11270. SAMPLER3DGREENDEPTH: boolean;
  11271. SAMPLER3DBGRMAP: boolean;
  11272. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11273. EXPOSURE: boolean;
  11274. constructor();
  11275. setReflectionMode(modeToEnable: string): void;
  11276. }
  11277. class StandardMaterial extends PushMaterial {
  11278. private _diffuseTexture;
  11279. diffuseTexture: Nullable<BaseTexture>;
  11280. private _ambientTexture;
  11281. ambientTexture: Nullable<BaseTexture>;
  11282. private _opacityTexture;
  11283. opacityTexture: Nullable<BaseTexture>;
  11284. private _reflectionTexture;
  11285. reflectionTexture: Nullable<BaseTexture>;
  11286. private _emissiveTexture;
  11287. emissiveTexture: Nullable<BaseTexture>;
  11288. private _specularTexture;
  11289. specularTexture: Nullable<BaseTexture>;
  11290. private _bumpTexture;
  11291. bumpTexture: Nullable<BaseTexture>;
  11292. private _lightmapTexture;
  11293. lightmapTexture: Nullable<BaseTexture>;
  11294. private _refractionTexture;
  11295. refractionTexture: Nullable<BaseTexture>;
  11296. ambientColor: Color3;
  11297. diffuseColor: Color3;
  11298. specularColor: Color3;
  11299. emissiveColor: Color3;
  11300. specularPower: number;
  11301. private _useAlphaFromDiffuseTexture;
  11302. useAlphaFromDiffuseTexture: boolean;
  11303. private _useEmissiveAsIllumination;
  11304. useEmissiveAsIllumination: boolean;
  11305. private _linkEmissiveWithDiffuse;
  11306. linkEmissiveWithDiffuse: boolean;
  11307. private _useSpecularOverAlpha;
  11308. useSpecularOverAlpha: boolean;
  11309. private _useReflectionOverAlpha;
  11310. useReflectionOverAlpha: boolean;
  11311. private _disableLighting;
  11312. disableLighting: boolean;
  11313. private _useObjectSpaceNormalMap;
  11314. /**
  11315. * Allows using an object space normal map (instead of tangent space).
  11316. */
  11317. useObjectSpaceNormalMap: boolean;
  11318. private _useParallax;
  11319. useParallax: boolean;
  11320. private _useParallaxOcclusion;
  11321. useParallaxOcclusion: boolean;
  11322. parallaxScaleBias: number;
  11323. private _roughness;
  11324. roughness: number;
  11325. indexOfRefraction: number;
  11326. invertRefractionY: boolean;
  11327. private _useLightmapAsShadowmap;
  11328. useLightmapAsShadowmap: boolean;
  11329. private _diffuseFresnelParameters;
  11330. diffuseFresnelParameters: FresnelParameters;
  11331. private _opacityFresnelParameters;
  11332. opacityFresnelParameters: FresnelParameters;
  11333. private _reflectionFresnelParameters;
  11334. reflectionFresnelParameters: FresnelParameters;
  11335. private _refractionFresnelParameters;
  11336. refractionFresnelParameters: FresnelParameters;
  11337. private _emissiveFresnelParameters;
  11338. emissiveFresnelParameters: FresnelParameters;
  11339. private _useReflectionFresnelFromSpecular;
  11340. useReflectionFresnelFromSpecular: boolean;
  11341. private _useGlossinessFromSpecularMapAlpha;
  11342. useGlossinessFromSpecularMapAlpha: boolean;
  11343. private _maxSimultaneousLights;
  11344. maxSimultaneousLights: number;
  11345. /**
  11346. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  11347. */
  11348. private _invertNormalMapX;
  11349. invertNormalMapX: boolean;
  11350. /**
  11351. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  11352. */
  11353. private _invertNormalMapY;
  11354. invertNormalMapY: boolean;
  11355. /**
  11356. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  11357. */
  11358. private _twoSidedLighting;
  11359. twoSidedLighting: boolean;
  11360. /**
  11361. * Default configuration related to image processing available in the standard Material.
  11362. */
  11363. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11364. /**
  11365. * Gets the image processing configuration used either in this material.
  11366. */
  11367. /**
  11368. * Sets the Default image processing configuration used either in the this material.
  11369. *
  11370. * If sets to null, the scene one is in use.
  11371. */
  11372. imageProcessingConfiguration: ImageProcessingConfiguration;
  11373. /**
  11374. * Keep track of the image processing observer to allow dispose and replace.
  11375. */
  11376. private _imageProcessingObserver;
  11377. /**
  11378. * Attaches a new image processing configuration to the Standard Material.
  11379. * @param configuration
  11380. */
  11381. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11382. /**
  11383. * Gets wether the color curves effect is enabled.
  11384. */
  11385. /**
  11386. * Sets wether the color curves effect is enabled.
  11387. */
  11388. cameraColorCurvesEnabled: boolean;
  11389. /**
  11390. * Gets wether the color grading effect is enabled.
  11391. */
  11392. /**
  11393. * Gets wether the color grading effect is enabled.
  11394. */
  11395. cameraColorGradingEnabled: boolean;
  11396. /**
  11397. * Gets wether tonemapping is enabled or not.
  11398. */
  11399. /**
  11400. * Sets wether tonemapping is enabled or not
  11401. */
  11402. cameraToneMappingEnabled: boolean;
  11403. /**
  11404. * The camera exposure used on this material.
  11405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  11406. * This corresponds to a photographic exposure.
  11407. */
  11408. /**
  11409. * The camera exposure used on this material.
  11410. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  11411. * This corresponds to a photographic exposure.
  11412. */
  11413. cameraExposure: number;
  11414. /**
  11415. * Gets The camera contrast used on this material.
  11416. */
  11417. /**
  11418. * Sets The camera contrast used on this material.
  11419. */
  11420. cameraContrast: number;
  11421. /**
  11422. * Gets the Color Grading 2D Lookup Texture.
  11423. */
  11424. /**
  11425. * Sets the Color Grading 2D Lookup Texture.
  11426. */
  11427. cameraColorGradingTexture: Nullable<BaseTexture>;
  11428. /**
  11429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11431. * 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;
  11432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11433. */
  11434. /**
  11435. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11436. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11437. * 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;
  11438. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11439. */
  11440. cameraColorCurves: Nullable<ColorCurves>;
  11441. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  11442. protected _renderTargets: SmartArray<RenderTargetTexture>;
  11443. protected _worldViewProjectionMatrix: Matrix;
  11444. protected _globalAmbientColor: Color3;
  11445. protected _useLogarithmicDepth: boolean;
  11446. constructor(name: string, scene: Scene);
  11447. getClassName(): string;
  11448. useLogarithmicDepth: boolean;
  11449. needAlphaBlending(): boolean;
  11450. needAlphaTesting(): boolean;
  11451. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  11452. getAlphaTestTexture(): Nullable<BaseTexture>;
  11453. /**
  11454. * Child classes can use it to update shaders
  11455. */
  11456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  11457. buildUniformLayout(): void;
  11458. unbind(): void;
  11459. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  11460. getAnimatables(): IAnimatable[];
  11461. getActiveTextures(): BaseTexture[];
  11462. hasTexture(texture: BaseTexture): boolean;
  11463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  11464. clone(name: string): StandardMaterial;
  11465. serialize(): any;
  11466. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  11467. static _DiffuseTextureEnabled: boolean;
  11468. static DiffuseTextureEnabled: boolean;
  11469. static _AmbientTextureEnabled: boolean;
  11470. static AmbientTextureEnabled: boolean;
  11471. static _OpacityTextureEnabled: boolean;
  11472. static OpacityTextureEnabled: boolean;
  11473. static _ReflectionTextureEnabled: boolean;
  11474. static ReflectionTextureEnabled: boolean;
  11475. static _EmissiveTextureEnabled: boolean;
  11476. static EmissiveTextureEnabled: boolean;
  11477. static _SpecularTextureEnabled: boolean;
  11478. static SpecularTextureEnabled: boolean;
  11479. static _BumpTextureEnabled: boolean;
  11480. static BumpTextureEnabled: boolean;
  11481. static _LightmapTextureEnabled: boolean;
  11482. static LightmapTextureEnabled: boolean;
  11483. static _RefractionTextureEnabled: boolean;
  11484. static RefractionTextureEnabled: boolean;
  11485. static _ColorGradingTextureEnabled: boolean;
  11486. static ColorGradingTextureEnabled: boolean;
  11487. static _FresnelEnabled: boolean;
  11488. static FresnelEnabled: boolean;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. class UniformBuffer {
  11493. private _engine;
  11494. private _buffer;
  11495. private _data;
  11496. private _bufferData;
  11497. private _dynamic?;
  11498. private _uniformLocations;
  11499. private _uniformSizes;
  11500. private _uniformLocationPointer;
  11501. private _needSync;
  11502. private _noUBO;
  11503. private _currentEffect;
  11504. private static _MAX_UNIFORM_SIZE;
  11505. private static _tempBuffer;
  11506. /**
  11507. * Wrapper for updateUniform.
  11508. * @method updateMatrix3x3
  11509. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11510. * @param {Float32Array} matrix
  11511. */
  11512. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  11513. /**
  11514. * Wrapper for updateUniform.
  11515. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11516. * @param {Float32Array} matrix
  11517. */
  11518. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  11519. /**
  11520. * Wrapper for updateUniform.
  11521. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11522. * @param {number} x
  11523. */
  11524. updateFloat: (name: string, x: number) => void;
  11525. /**
  11526. * Wrapper for updateUniform.
  11527. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11528. * @param {number} x
  11529. * @param {number} y
  11530. * @param {string} [suffix] Suffix to add to the uniform name.
  11531. */
  11532. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  11533. /**
  11534. * Wrapper for updateUniform.
  11535. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11536. * @param {number} x
  11537. * @param {number} y
  11538. * @param {number} z
  11539. * @param {string} [suffix] Suffix to add to the uniform name.
  11540. */
  11541. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  11542. /**
  11543. * Wrapper for updateUniform.
  11544. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11545. * @param {number} x
  11546. * @param {number} y
  11547. * @param {number} z
  11548. * @param {number} w
  11549. * @param {string} [suffix] Suffix to add to the uniform name.
  11550. */
  11551. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  11552. /**
  11553. * Wrapper for updateUniform.
  11554. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11555. * @param {Matrix} A 4x4 matrix.
  11556. */
  11557. updateMatrix: (name: string, mat: Matrix) => void;
  11558. /**
  11559. * Wrapper for updateUniform.
  11560. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11561. * @param {Vector3} vector
  11562. */
  11563. updateVector3: (name: string, vector: Vector3) => void;
  11564. /**
  11565. * Wrapper for updateUniform.
  11566. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11567. * @param {Vector4} vector
  11568. */
  11569. updateVector4: (name: string, vector: Vector4) => void;
  11570. /**
  11571. * Wrapper for updateUniform.
  11572. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11573. * @param {Color3} color
  11574. * @param {string} [suffix] Suffix to add to the uniform name.
  11575. */
  11576. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  11577. /**
  11578. * Wrapper for updateUniform.
  11579. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11580. * @param {Color3} color
  11581. * @param {number} alpha
  11582. * @param {string} [suffix] Suffix to add to the uniform name.
  11583. */
  11584. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  11585. /**
  11586. * Uniform buffer objects.
  11587. *
  11588. * Handles blocks of uniform on the GPU.
  11589. *
  11590. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  11591. *
  11592. * For more information, please refer to :
  11593. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  11594. */
  11595. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  11596. /**
  11597. * Indicates if the buffer is using the WebGL2 UBO implementation,
  11598. * or just falling back on setUniformXXX calls.
  11599. */
  11600. readonly useUbo: boolean;
  11601. /**
  11602. * Indicates if the WebGL underlying uniform buffer is in sync
  11603. * with the javascript cache data.
  11604. */
  11605. readonly isSync: boolean;
  11606. /**
  11607. * Indicates if the WebGL underlying uniform buffer is dynamic.
  11608. * Also, a dynamic UniformBuffer will disable cache verification and always
  11609. * update the underlying WebGL uniform buffer to the GPU.
  11610. */
  11611. isDynamic(): boolean;
  11612. /**
  11613. * The data cache on JS side.
  11614. */
  11615. getData(): Float32Array;
  11616. /**
  11617. * The underlying WebGL Uniform buffer.
  11618. */
  11619. getBuffer(): Nullable<WebGLBuffer>;
  11620. /**
  11621. * std140 layout specifies how to align data within an UBO structure.
  11622. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  11623. * for specs.
  11624. */
  11625. private _fillAlignment(size);
  11626. /**
  11627. * Adds an uniform in the buffer.
  11628. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  11629. * for the layout to be correct !
  11630. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11631. * @param {number|number[]} size Data size, or data directly.
  11632. */
  11633. addUniform(name: string, size: number | number[]): void;
  11634. /**
  11635. * Wrapper for addUniform.
  11636. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11637. * @param {Matrix} mat A 4x4 matrix.
  11638. */
  11639. addMatrix(name: string, mat: Matrix): void;
  11640. /**
  11641. * Wrapper for addUniform.
  11642. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11643. * @param {number} x
  11644. * @param {number} y
  11645. */
  11646. addFloat2(name: string, x: number, y: number): void;
  11647. /**
  11648. * Wrapper for addUniform.
  11649. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11650. * @param {number} x
  11651. * @param {number} y
  11652. * @param {number} z
  11653. */
  11654. addFloat3(name: string, x: number, y: number, z: number): void;
  11655. /**
  11656. * Wrapper for addUniform.
  11657. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11658. * @param {Color3} color
  11659. */
  11660. addColor3(name: string, color: Color3): void;
  11661. /**
  11662. * Wrapper for addUniform.
  11663. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11664. * @param {Color3} color
  11665. * @param {number} alpha
  11666. */
  11667. addColor4(name: string, color: Color3, alpha: number): void;
  11668. /**
  11669. * Wrapper for addUniform.
  11670. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11671. * @param {Vector3} vector
  11672. */
  11673. addVector3(name: string, vector: Vector3): void;
  11674. /**
  11675. * Wrapper for addUniform.
  11676. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11677. */
  11678. addMatrix3x3(name: string): void;
  11679. /**
  11680. * Wrapper for addUniform.
  11681. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  11682. */
  11683. addMatrix2x2(name: string): void;
  11684. /**
  11685. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  11686. */
  11687. create(): void;
  11688. _rebuild(): void;
  11689. /**
  11690. * Updates the WebGL Uniform Buffer on the GPU.
  11691. * If the `dynamic` flag is set to true, no cache comparison is done.
  11692. * Otherwise, the buffer will be updated only if the cache differs.
  11693. */
  11694. update(): void;
  11695. /**
  11696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  11697. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  11698. * @param {number[]|Float32Array} data Flattened data
  11699. * @param {number} size Size of the data.
  11700. */
  11701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  11702. private _updateMatrix3x3ForUniform(name, matrix);
  11703. private _updateMatrix3x3ForEffect(name, matrix);
  11704. private _updateMatrix2x2ForEffect(name, matrix);
  11705. private _updateMatrix2x2ForUniform(name, matrix);
  11706. private _updateFloatForEffect(name, x);
  11707. private _updateFloatForUniform(name, x);
  11708. private _updateFloat2ForEffect(name, x, y, suffix?);
  11709. private _updateFloat2ForUniform(name, x, y, suffix?);
  11710. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  11711. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  11712. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  11713. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  11714. private _updateMatrixForEffect(name, mat);
  11715. private _updateMatrixForUniform(name, mat);
  11716. private _updateVector3ForEffect(name, vector);
  11717. private _updateVector3ForUniform(name, vector);
  11718. private _updateVector4ForEffect(name, vector);
  11719. private _updateVector4ForUniform(name, vector);
  11720. private _updateColor3ForEffect(name, color, suffix?);
  11721. private _updateColor3ForUniform(name, color, suffix?);
  11722. private _updateColor4ForEffect(name, color, alpha, suffix?);
  11723. private _updateColor4ForUniform(name, color, alpha, suffix?);
  11724. /**
  11725. * Sets a sampler uniform on the effect.
  11726. * @param {string} name Name of the sampler.
  11727. * @param {Texture} texture
  11728. */
  11729. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  11730. /**
  11731. * Directly updates the value of the uniform in the cache AND on the GPU.
  11732. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  11733. * @param {number[]|Float32Array} data Flattened data
  11734. */
  11735. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  11736. /**
  11737. * Binds this uniform buffer to an effect.
  11738. * @param {Effect} effect
  11739. * @param {string} name Name of the uniform block in the shader.
  11740. */
  11741. bindToEffect(effect: Effect, name: string): void;
  11742. /**
  11743. * Disposes the uniform buffer.
  11744. */
  11745. dispose(): void;
  11746. }
  11747. }
  11748. declare module BABYLON {
  11749. class Scalar {
  11750. /**
  11751. * Two pi constants convenient for computation.
  11752. */
  11753. static TwoPi: number;
  11754. /**
  11755. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  11756. */
  11757. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  11758. /**
  11759. * Returns a string : the upper case translation of the number i to hexadecimal.
  11760. */
  11761. static ToHex(i: number): string;
  11762. /**
  11763. * Returns -1 if value is negative and +1 is value is positive.
  11764. * Returns the value itself if it's equal to zero.
  11765. */
  11766. static Sign(value: number): number;
  11767. /**
  11768. * Returns the value itself if it's between min and max.
  11769. * Returns min if the value is lower than min.
  11770. * Returns max if the value is greater than max.
  11771. */
  11772. static Clamp(value: number, min?: number, max?: number): number;
  11773. /**
  11774. * Returns the log2 of value.
  11775. */
  11776. static Log2(value: number): number;
  11777. /**
  11778. * Loops the value, so that it is never larger than length and never smaller than 0.
  11779. *
  11780. * This is similar to the modulo operator but it works with floating point numbers.
  11781. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  11782. * With t = 5 and length = 2.5, the result would be 0.0.
  11783. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  11784. */
  11785. static Repeat(value: number, length: number): number;
  11786. /**
  11787. * Normalize the value between 0.0 and 1.0 using min and max values
  11788. */
  11789. static Normalize(value: number, min: number, max: number): number;
  11790. /**
  11791. * Denormalize the value from 0.0 and 1.0 using min and max values
  11792. */
  11793. static Denormalize(normalized: number, min: number, max: number): number;
  11794. /**
  11795. * Calculates the shortest difference between two given angles given in degrees.
  11796. */
  11797. static DeltaAngle(current: number, target: number): number;
  11798. /**
  11799. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  11800. *
  11801. * The returned value will move back and forth between 0 and length
  11802. */
  11803. static PingPong(tx: number, length: number): number;
  11804. /**
  11805. * Interpolates between min and max with smoothing at the limits.
  11806. *
  11807. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  11808. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  11809. */
  11810. static SmoothStep(from: number, to: number, tx: number): number;
  11811. /**
  11812. * Moves a value current towards target.
  11813. *
  11814. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  11815. * Negative values of maxDelta pushes the value away from target.
  11816. */
  11817. static MoveTowards(current: number, target: number, maxDelta: number): number;
  11818. /**
  11819. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11820. *
  11821. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  11822. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  11823. */
  11824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  11825. /**
  11826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  11827. */
  11828. static Lerp(start: number, end: number, amount: number): number;
  11829. /**
  11830. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11831. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  11832. */
  11833. static LerpAngle(start: number, end: number, amount: number): number;
  11834. /**
  11835. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  11836. */
  11837. static InverseLerp(a: number, b: number, value: number): number;
  11838. /**
  11839. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  11840. */
  11841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  11842. /**
  11843. * Returns a random float number between and min and max values
  11844. */
  11845. static RandomRange(min: number, max: number): number;
  11846. /**
  11847. * This function returns percentage of a number in a given range.
  11848. *
  11849. * RangeToPercent(40,20,60) will return 0.5 (50%)
  11850. * RangeToPercent(34,0,100) will return 0.34 (34%)
  11851. */
  11852. static RangeToPercent(number: number, min: number, max: number): number;
  11853. /**
  11854. * This function returns number that corresponds to the percentage in a given range.
  11855. *
  11856. * PercentToRange(0.34,0,100) will return 34.
  11857. */
  11858. static PercentToRange(percent: number, min: number, max: number): number;
  11859. /**
  11860. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  11861. * @param angle The angle to normalize in radian.
  11862. * @return The converted angle.
  11863. */
  11864. static NormalizeRadians(angle: number): number;
  11865. }
  11866. }
  11867. declare module BABYLON {
  11868. const ToGammaSpace: number;
  11869. const ToLinearSpace = 2.2;
  11870. const Epsilon = 0.001;
  11871. /**
  11872. * Class used to hold a RBG color
  11873. */
  11874. class Color3 {
  11875. /**
  11876. * Defines the red component (between 0 and 1, default is 0)
  11877. */
  11878. r: number;
  11879. /**
  11880. * Defines the green component (between 0 and 1, default is 0)
  11881. */
  11882. g: number;
  11883. /**
  11884. * Defines the blue component (between 0 and 1, default is 0)
  11885. */
  11886. b: number;
  11887. /**
  11888. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  11889. * @param r defines the red component (between 0 and 1, default is 0)
  11890. * @param g defines the green component (between 0 and 1, default is 0)
  11891. * @param b defines the blue component (between 0 and 1, default is 0)
  11892. */
  11893. constructor(
  11894. /**
  11895. * Defines the red component (between 0 and 1, default is 0)
  11896. */
  11897. r?: number,
  11898. /**
  11899. * Defines the green component (between 0 and 1, default is 0)
  11900. */
  11901. g?: number,
  11902. /**
  11903. * Defines the blue component (between 0 and 1, default is 0)
  11904. */
  11905. b?: number);
  11906. /**
  11907. * Creates a string with the Color3 current values
  11908. * @returns the string representation of the Color3 object
  11909. */
  11910. toString(): string;
  11911. /**
  11912. * Returns the string "Color3"
  11913. * @returns "Color3"
  11914. */
  11915. getClassName(): string;
  11916. /**
  11917. * Compute the Color3 hash code
  11918. * @returns an unique number that can be used to hash Color3 objects
  11919. */
  11920. getHashCode(): number;
  11921. /**
  11922. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  11923. * @param array defines the array where to store the r,g,b components
  11924. * @param index defines an optional index in the target array to define where to start storing values
  11925. * @returns the current Color3 object
  11926. */
  11927. toArray(array: FloatArray, index?: number): Color3;
  11928. /**
  11929. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  11930. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  11931. * @returns a new {BABYLON.Color4} object
  11932. */
  11933. toColor4(alpha?: number): Color4;
  11934. /**
  11935. * Returns a new array populated with 3 numeric elements : red, green and blue values
  11936. * @returns the new array
  11937. */
  11938. asArray(): number[];
  11939. /**
  11940. * Returns the luminance value
  11941. * @returns a float value
  11942. */
  11943. toLuminance(): number;
  11944. /**
  11945. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  11946. * @param otherColor defines the second operand
  11947. * @returns the new Color3 object
  11948. */
  11949. multiply(otherColor: Color3): Color3;
  11950. /**
  11951. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  11952. * @param otherColor defines the second operand
  11953. * @param result defines the Color3 object where to store the result
  11954. * @returns the current Color3
  11955. */
  11956. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  11957. /**
  11958. * Determines equality between Color3 objects
  11959. * @param otherColor defines the second operand
  11960. * @returns true if the rgb values are equal to the passed ones
  11961. */
  11962. equals(otherColor: Color3): boolean;
  11963. /**
  11964. * Determines equality between the current Color3 object and a set of r,b,g values
  11965. * @param r defines the red component to check
  11966. * @param g defines the green component to check
  11967. * @param b defines the blue component to check
  11968. * @returns true if the rgb values are equal to the passed ones
  11969. */
  11970. equalsFloats(r: number, g: number, b: number): boolean;
  11971. /**
  11972. * Multiplies in place each rgb value by scale
  11973. * @param scale defines the scaling factor
  11974. * @returns the updated Color3
  11975. */
  11976. scale(scale: number): Color3;
  11977. /**
  11978. * Multiplies the rgb values by scale and stores the result into "result"
  11979. * @param scale defines the scaling factor
  11980. * @param result defines the Color3 object where to store the result
  11981. * @returns the unmodified current Color3
  11982. */
  11983. scaleToRef(scale: number, result: Color3): Color3;
  11984. /**
  11985. * Scale the current Color3 values by a factor and add the result to a given Color3
  11986. * @param scale defines the scale factor
  11987. * @param result defines color to store the result into
  11988. * @returns the unmodified current Color3
  11989. */
  11990. scaleAndAddToRef(scale: number, result: Color3): Color3;
  11991. /**
  11992. * Clamps the rgb values by the min and max values and stores the result into "result"
  11993. * @param min defines minimum clamping value (default is 0)
  11994. * @param max defines maximum clamping value (default is 1)
  11995. * @param result defines color to store the result into
  11996. * @returns the original Color3
  11997. */
  11998. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  11999. /**
  12000. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  12001. * @param otherColor defines the second operand
  12002. * @returns the new Color3
  12003. */
  12004. add(otherColor: Color3): Color3;
  12005. /**
  12006. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  12007. * @param otherColor defines the second operand
  12008. * @param result defines Color3 object to store the result into
  12009. * @returns the unmodified current Color3
  12010. */
  12011. addToRef(otherColor: Color3, result: Color3): Color3;
  12012. /**
  12013. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  12014. * @param otherColor defines the second operand
  12015. * @returns the new Color3
  12016. */
  12017. subtract(otherColor: Color3): Color3;
  12018. /**
  12019. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  12020. * @param otherColor defines the second operand
  12021. * @param result defines Color3 object to store the result into
  12022. * @returns the unmodified current Color3
  12023. */
  12024. subtractToRef(otherColor: Color3, result: Color3): Color3;
  12025. /**
  12026. * Copy the current object
  12027. * @returns a new Color3 copied the current one
  12028. */
  12029. clone(): Color3;
  12030. /**
  12031. * Copies the rgb values from the source in the current Color3
  12032. * @param source defines the source Color3 object
  12033. * @returns the updated Color3 object
  12034. */
  12035. copyFrom(source: Color3): Color3;
  12036. /**
  12037. * Updates the Color3 rgb values from the passed floats
  12038. * @param r defines the red component to read from
  12039. * @param g defines the green component to read from
  12040. * @param b defines the blue component to read from
  12041. * @returns the current Color3 object
  12042. */
  12043. copyFromFloats(r: number, g: number, b: number): Color3;
  12044. /**
  12045. * Updates the Color3 rgb values from the passed floats
  12046. * @param r defines the red component to read from
  12047. * @param g defines the green component to read from
  12048. * @param b defines the blue component to read from
  12049. * @returns the current Color3 object
  12050. */
  12051. set(r: number, g: number, b: number): Color3;
  12052. /**
  12053. * Compute the Color3 hexadecimal code as a string
  12054. * @returns a string containing the hexadecimal representation of the Color3 object
  12055. */
  12056. toHexString(): string;
  12057. /**
  12058. * Computes a new Color3 converted from the current one to linear space
  12059. * @returns a new Color3 object
  12060. */
  12061. toLinearSpace(): Color3;
  12062. /**
  12063. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  12064. * @param convertedColor defines the Color3 object where to store the linear space version
  12065. * @returns the unmodified Color3
  12066. */
  12067. toLinearSpaceToRef(convertedColor: Color3): Color3;
  12068. /**
  12069. * Computes a new Color3 converted from the current one to gamma space
  12070. * @returns a new Color3 object
  12071. */
  12072. toGammaSpace(): Color3;
  12073. /**
  12074. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  12075. * @param convertedColor defines the Color3 object where to store the gamma space version
  12076. * @returns the unmodified Color3
  12077. */
  12078. toGammaSpaceToRef(convertedColor: Color3): Color3;
  12079. /**
  12080. * Creates a new Color3 from the string containing valid hexadecimal values
  12081. * @param hex defines a string containing valid hexadecimal values
  12082. * @returns a new Color3 object
  12083. */
  12084. static FromHexString(hex: string): Color3;
  12085. /**
  12086. * Creates a new Vector3 from the starting index of the passed array
  12087. * @param array defines the source array
  12088. * @param offset defines an offset in the source array
  12089. * @returns a new Color3 object
  12090. */
  12091. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  12092. /**
  12093. * Creates a new Color3 from integer values (< 256)
  12094. * @param r defines the red component to read from (value between 0 and 255)
  12095. * @param g defines the green component to read from (value between 0 and 255)
  12096. * @param b defines the blue component to read from (value between 0 and 255)
  12097. * @returns a new Color3 object
  12098. */
  12099. static FromInts(r: number, g: number, b: number): Color3;
  12100. /**
  12101. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  12102. * @param start defines the start Color3 value
  12103. * @param end defines the end Color3 value
  12104. * @param amount defines the gradient value between start and end
  12105. * @returns a new Color3 object
  12106. */
  12107. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  12108. /**
  12109. * Returns a Color3 value containing a red color
  12110. * @returns a new Color3 object
  12111. */
  12112. static Red(): Color3;
  12113. /**
  12114. * Returns a Color3 value containing a green color
  12115. * @returns a new Color3 object
  12116. */
  12117. static Green(): Color3;
  12118. /**
  12119. * Returns a Color3 value containing a blue color
  12120. * @returns a new Color3 object
  12121. */
  12122. static Blue(): Color3;
  12123. /**
  12124. * Returns a Color3 value containing a black color
  12125. * @returns a new Color3 object
  12126. */
  12127. static Black(): Color3;
  12128. /**
  12129. * Returns a Color3 value containing a white color
  12130. * @returns a new Color3 object
  12131. */
  12132. static White(): Color3;
  12133. /**
  12134. * Returns a Color3 value containing a purple color
  12135. * @returns a new Color3 object
  12136. */
  12137. static Purple(): Color3;
  12138. /**
  12139. * Returns a Color3 value containing a magenta color
  12140. * @returns a new Color3 object
  12141. */
  12142. static Magenta(): Color3;
  12143. /**
  12144. * Returns a Color3 value containing a yellow color
  12145. * @returns a new Color3 object
  12146. */
  12147. static Yellow(): Color3;
  12148. /**
  12149. * Returns a Color3 value containing a gray color
  12150. * @returns a new Color3 object
  12151. */
  12152. static Gray(): Color3;
  12153. /**
  12154. * Returns a Color3 value containing a teal color
  12155. * @returns a new Color3 object
  12156. */
  12157. static Teal(): Color3;
  12158. /**
  12159. * Returns a Color3 value containing a random color
  12160. * @returns a new Color3 object
  12161. */
  12162. static Random(): Color3;
  12163. }
  12164. /**
  12165. * Class used to hold a RBGA color
  12166. */
  12167. class Color4 {
  12168. /**
  12169. * Defines the red component (between 0 and 1, default is 0)
  12170. */
  12171. r: number;
  12172. /**
  12173. * Defines the green component (between 0 and 1, default is 0)
  12174. */
  12175. g: number;
  12176. /**
  12177. * Defines the blue component (between 0 and 1, default is 0)
  12178. */
  12179. b: number;
  12180. /**
  12181. * Defines the alpha component (between 0 and 1, default is 1)
  12182. */
  12183. a: number;
  12184. /**
  12185. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12186. * @param r defines the red component (between 0 and 1, default is 0)
  12187. * @param g defines the green component (between 0 and 1, default is 0)
  12188. * @param b defines the blue component (between 0 and 1, default is 0)
  12189. * @param a defines the alpha component (between 0 and 1, default is 1)
  12190. */
  12191. constructor(
  12192. /**
  12193. * Defines the red component (between 0 and 1, default is 0)
  12194. */
  12195. r?: number,
  12196. /**
  12197. * Defines the green component (between 0 and 1, default is 0)
  12198. */
  12199. g?: number,
  12200. /**
  12201. * Defines the blue component (between 0 and 1, default is 0)
  12202. */
  12203. b?: number,
  12204. /**
  12205. * Defines the alpha component (between 0 and 1, default is 1)
  12206. */
  12207. a?: number);
  12208. /**
  12209. * Adds in place the passed Color4 values to the current Color4 object
  12210. * @param right defines the second operand
  12211. * @returns the current updated Color4 object
  12212. */
  12213. addInPlace(right: Color4): Color4;
  12214. /**
  12215. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12216. * @returns the new array
  12217. */
  12218. asArray(): number[];
  12219. /**
  12220. * Stores from the starting index in the passed array the Color4 successive values
  12221. * @param array defines the array where to store the r,g,b components
  12222. * @param index defines an optional index in the target array to define where to start storing values
  12223. * @returns the current Color4 object
  12224. */
  12225. toArray(array: number[], index?: number): Color4;
  12226. /**
  12227. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  12228. * @param right defines the second operand
  12229. * @returns a new Color4 object
  12230. */
  12231. add(right: Color4): Color4;
  12232. /**
  12233. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  12234. * @param right defines the second operand
  12235. * @returns a new Color4 object
  12236. */
  12237. subtract(right: Color4): Color4;
  12238. /**
  12239. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  12240. * @param right defines the second operand
  12241. * @param result defines the Color4 object where to store the result
  12242. * @returns the current Color4 object
  12243. */
  12244. subtractToRef(right: Color4, result: Color4): Color4;
  12245. /**
  12246. * Creates a new Color4 with the current Color4 values multiplied by scale
  12247. * @param scale defines the scaling factor to apply
  12248. * @returns a new Color4 object
  12249. */
  12250. scale(scale: number): Color4;
  12251. /**
  12252. * Multiplies the current Color4 values by scale and stores the result in "result"
  12253. * @param scale defines the scaling factor to apply
  12254. * @param result defines the Color4 object where to store the result
  12255. * @returns the current unmodified Color4
  12256. */
  12257. scaleToRef(scale: number, result: Color4): Color4;
  12258. /**
  12259. * Scale the current Color4 values by a factor and add the result to a given Color4
  12260. * @param scale defines the scale factor
  12261. * @param result defines the Color4 object where to store the result
  12262. * @returns the unmodified current Color4
  12263. */
  12264. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12265. /**
  12266. * Clamps the rgb values by the min and max values and stores the result into "result"
  12267. * @param min defines minimum clamping value (default is 0)
  12268. * @param max defines maximum clamping value (default is 1)
  12269. * @param result defines color to store the result into.
  12270. * @returns the cuurent Color4
  12271. */
  12272. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12273. /**
  12274. * Multipy an Color4 value by another and return a new Color4 object
  12275. * @param color defines the Color4 value to multiply by
  12276. * @returns a new Color4 object
  12277. */
  12278. multiply(color: Color4): Color4;
  12279. /**
  12280. * Multipy a Color4 value by another and push the result in a reference value
  12281. * @param color defines the Color4 value to multiply by
  12282. * @param result defines the Color4 to fill the result in
  12283. * @returns the result Color4
  12284. */
  12285. multiplyToRef(color: Color4, result: Color4): Color4;
  12286. /**
  12287. * Creates a string with the Color4 current values
  12288. * @returns the string representation of the Color4 object
  12289. */
  12290. toString(): string;
  12291. /**
  12292. * Returns the string "Color4"
  12293. * @returns "Color4"
  12294. */
  12295. getClassName(): string;
  12296. /**
  12297. * Compute the Color4 hash code
  12298. * @returns an unique number that can be used to hash Color4 objects
  12299. */
  12300. getHashCode(): number;
  12301. /**
  12302. * Creates a new Color4 copied from the current one
  12303. * @returns a new Color4 object
  12304. */
  12305. clone(): Color4;
  12306. /**
  12307. * Copies the passed Color4 values into the current one
  12308. * @param source defines the source Color4 object
  12309. * @returns the current updated Color4 object
  12310. */
  12311. copyFrom(source: Color4): Color4;
  12312. /**
  12313. * Copies the passed float values into the current one
  12314. * @param r defines the red component to read from
  12315. * @param g defines the green component to read from
  12316. * @param b defines the blue component to read from
  12317. * @param a defines the alpha component to read from
  12318. * @returns the current updated Color4 object
  12319. */
  12320. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12321. /**
  12322. * Copies the passed float values into the current one
  12323. * @param r defines the red component to read from
  12324. * @param g defines the green component to read from
  12325. * @param b defines the blue component to read from
  12326. * @param a defines the alpha component to read from
  12327. * @returns the current updated Color4 object
  12328. */
  12329. set(r: number, g: number, b: number, a: number): Color4;
  12330. /**
  12331. * Compute the Color4 hexadecimal code as a string
  12332. * @returns a string containing the hexadecimal representation of the Color4 object
  12333. */
  12334. toHexString(): string;
  12335. /**
  12336. * Computes a new Color4 converted from the current one to linear space
  12337. * @returns a new Color4 object
  12338. */
  12339. toLinearSpace(): Color4;
  12340. /**
  12341. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12342. * @param convertedColor defines the Color4 object where to store the linear space version
  12343. * @returns the unmodified Color4
  12344. */
  12345. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12346. /**
  12347. * Computes a new Color4 converted from the current one to gamma space
  12348. * @returns a new Color4 object
  12349. */
  12350. toGammaSpace(): Color4;
  12351. /**
  12352. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12353. * @param convertedColor defines the Color4 object where to store the gamma space version
  12354. * @returns the unmodified Color4
  12355. */
  12356. toGammaSpaceToRef(convertedColor: Color4): Color4;
  12357. /**
  12358. * Creates a new Color4 from the string containing valid hexadecimal values
  12359. * @param hex defines a string containing valid hexadecimal values
  12360. * @returns a new Color4 object
  12361. */
  12362. static FromHexString(hex: string): Color4;
  12363. /**
  12364. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12365. * @param left defines the start value
  12366. * @param right defines the end value
  12367. * @param amount defines the gradient factor
  12368. * @returns a new Color4 object
  12369. */
  12370. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  12371. /**
  12372. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12373. * @param left defines the start value
  12374. * @param right defines the end value
  12375. * @param amount defines the gradient factor
  12376. * @param result defines the Color4 object where to store data
  12377. */
  12378. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  12379. /**
  12380. * Creates a new Color4 from the starting index element of the passed array
  12381. * @param array defines the source array to read from
  12382. * @param offset defines the offset in the source array
  12383. * @returns a new Color4 object
  12384. */
  12385. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  12386. /**
  12387. * Creates a new Color3 from integer values (< 256)
  12388. * @param r defines the red component to read from (value between 0 and 255)
  12389. * @param g defines the green component to read from (value between 0 and 255)
  12390. * @param b defines the blue component to read from (value between 0 and 255)
  12391. * @param a defines the alpha component to read from (value between 0 and 255)
  12392. * @returns a new Color3 object
  12393. */
  12394. static FromInts(r: number, g: number, b: number, a: number): Color4;
  12395. /**
  12396. * Check the content of a given array and convert it to an array containing RGBA data
  12397. * If the original array was already containing count * 4 values then it is returned directly
  12398. * @param colors defines the array to check
  12399. * @param count defines the number of RGBA data to expect
  12400. * @returns an array containing count * 4 values (RGBA)
  12401. */
  12402. static CheckColors4(colors: number[], count: number): number[];
  12403. }
  12404. class Vector2 {
  12405. x: number;
  12406. y: number;
  12407. /**
  12408. * Creates a new Vector2 from the passed x and y coordinates.
  12409. */
  12410. constructor(x: number, y: number);
  12411. /**
  12412. * Returns a string with the Vector2 coordinates.
  12413. */
  12414. toString(): string;
  12415. /**
  12416. * Returns the string "Vector2"
  12417. */
  12418. getClassName(): string;
  12419. /**
  12420. * Returns the Vector2 hash code as a number.
  12421. */
  12422. getHashCode(): number;
  12423. /**
  12424. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  12425. * Returns the Vector2.
  12426. */
  12427. toArray(array: FloatArray, index?: number): Vector2;
  12428. /**
  12429. * Returns a new array with 2 elements : the Vector2 coordinates.
  12430. */
  12431. asArray(): number[];
  12432. /**
  12433. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  12434. * Returns the updated Vector2.
  12435. */
  12436. copyFrom(source: Vector2): Vector2;
  12437. /**
  12438. * Sets the Vector2 coordinates with the passed floats.
  12439. * Returns the updated Vector2.
  12440. */
  12441. copyFromFloats(x: number, y: number): Vector2;
  12442. /**
  12443. * Sets the Vector2 coordinates with the passed floats.
  12444. * Returns the updated Vector2.
  12445. */
  12446. set(x: number, y: number): Vector2;
  12447. /**
  12448. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  12449. */
  12450. add(otherVector: Vector2): Vector2;
  12451. /**
  12452. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  12453. * Returns the Vector2.
  12454. */
  12455. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  12456. /**
  12457. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  12458. * Returns the updated Vector2.
  12459. */
  12460. addInPlace(otherVector: Vector2): Vector2;
  12461. /**
  12462. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  12463. */
  12464. addVector3(otherVector: Vector3): Vector2;
  12465. /**
  12466. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  12467. */
  12468. subtract(otherVector: Vector2): Vector2;
  12469. /**
  12470. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  12471. * Returns the Vector2.
  12472. */
  12473. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  12474. /**
  12475. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  12476. * Returns the updated Vector2.
  12477. */
  12478. subtractInPlace(otherVector: Vector2): Vector2;
  12479. /**
  12480. * Multiplies in place the current Vector2 coordinates by the passed ones.
  12481. * Returns the updated Vector2.
  12482. */
  12483. multiplyInPlace(otherVector: Vector2): Vector2;
  12484. /**
  12485. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  12486. */
  12487. multiply(otherVector: Vector2): Vector2;
  12488. /**
  12489. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  12490. * Returns the Vector2.
  12491. */
  12492. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  12493. /**
  12494. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  12495. */
  12496. multiplyByFloats(x: number, y: number): Vector2;
  12497. /**
  12498. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  12499. */
  12500. divide(otherVector: Vector2): Vector2;
  12501. /**
  12502. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  12503. * Returns the Vector2.
  12504. */
  12505. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  12506. /**
  12507. * Divides the current Vector3 coordinates by the passed ones.
  12508. * Returns the updated Vector3.
  12509. */
  12510. divideInPlace(otherVector: Vector2): Vector2;
  12511. /**
  12512. * Returns a new Vector2 with current Vector2 negated coordinates.
  12513. */
  12514. negate(): Vector2;
  12515. /**
  12516. * Multiply the Vector2 coordinates by scale.
  12517. * Returns the updated Vector2.
  12518. */
  12519. scaleInPlace(scale: number): Vector2;
  12520. /**
  12521. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  12522. */
  12523. scale(scale: number): Vector2;
  12524. /**
  12525. * Scale the current Vector2 values by a factor to a given Vector2
  12526. * @param scale defines the scale factor
  12527. * @param result defines the Vector2 object where to store the result
  12528. * @returns the unmodified current Vector2
  12529. */
  12530. scaleToRef(scale: number, result: Vector2): Vector2;
  12531. /**
  12532. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  12533. * @param scale defines the scale factor
  12534. * @param result defines the Vector2 object where to store the result
  12535. * @returns the unmodified current Vector2
  12536. */
  12537. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  12538. /**
  12539. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  12540. */
  12541. equals(otherVector: Vector2): boolean;
  12542. /**
  12543. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  12544. */
  12545. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  12546. /**
  12547. * Returns the vector length (float).
  12548. */
  12549. length(): number;
  12550. /**
  12551. * Returns the vector squared length (float);
  12552. */
  12553. lengthSquared(): number;
  12554. /**
  12555. * Normalize the vector.
  12556. * Returns the updated Vector2.
  12557. */
  12558. normalize(): Vector2;
  12559. /**
  12560. * Returns a new Vector2 copied from the Vector2.
  12561. */
  12562. clone(): Vector2;
  12563. /**
  12564. * Returns a new Vector2(0, 0)
  12565. */
  12566. static Zero(): Vector2;
  12567. /**
  12568. * Returns a new Vector2(1, 1)
  12569. */
  12570. static One(): Vector2;
  12571. /**
  12572. * Returns a new Vector2 set from the passed index element of the passed array.
  12573. */
  12574. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  12575. /**
  12576. * Sets "result" from the passed index element of the passed array.
  12577. */
  12578. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  12579. /**
  12580. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  12581. */
  12582. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  12583. /**
  12584. * 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".
  12585. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  12586. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  12587. */
  12588. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  12589. /**
  12590. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  12591. */
  12592. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  12593. /**
  12594. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  12595. */
  12596. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  12597. /**
  12598. * Returns the dot product (float) of the vector "left" and the vector "right".
  12599. */
  12600. static Dot(left: Vector2, right: Vector2): number;
  12601. /**
  12602. * Returns a new Vector2 equal to the normalized passed vector.
  12603. */
  12604. static Normalize(vector: Vector2): Vector2;
  12605. /**
  12606. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  12607. */
  12608. static Minimize(left: Vector2, right: Vector2): Vector2;
  12609. /**
  12610. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  12611. */
  12612. static Maximize(left: Vector2, right: Vector2): Vector2;
  12613. /**
  12614. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  12615. */
  12616. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  12617. /**
  12618. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  12619. */
  12620. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  12621. /**
  12622. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  12623. */
  12624. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  12625. /**
  12626. * Returns the distance (float) between the vectors "value1" and "value2".
  12627. */
  12628. static Distance(value1: Vector2, value2: Vector2): number;
  12629. /**
  12630. * Returns the squared distance (float) between the vectors "value1" and "value2".
  12631. */
  12632. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  12633. /**
  12634. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  12635. */
  12636. static Center(value1: Vector2, value2: Vector2): Vector2;
  12637. /**
  12638. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  12639. */
  12640. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  12641. }
  12642. /**
  12643. * Classed used to store (x,y,z) vector representation
  12644. * A Vector3 is the main object used in 3D geometry
  12645. * It can represent etiher the coordinates of a point the space, either a direction
  12646. * Reminder: Babylon.js uses a left handed forward facing system
  12647. */
  12648. class Vector3 {
  12649. /**
  12650. * Defines the first coordinates (on X axis)
  12651. */
  12652. x: number;
  12653. /**
  12654. * Defines the second coordinates (on Y axis)
  12655. */
  12656. y: number;
  12657. /**
  12658. * Defines the third coordinates (on Z axis)
  12659. */
  12660. z: number;
  12661. /**
  12662. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  12663. * @param x defines the first coordinates (on X axis)
  12664. * @param y defines the second coordinates (on Y axis)
  12665. * @param z defines the third coordinates (on Z axis)
  12666. */
  12667. constructor(
  12668. /**
  12669. * Defines the first coordinates (on X axis)
  12670. */
  12671. x: number,
  12672. /**
  12673. * Defines the second coordinates (on Y axis)
  12674. */
  12675. y: number,
  12676. /**
  12677. * Defines the third coordinates (on Z axis)
  12678. */
  12679. z: number);
  12680. /**
  12681. * Creates a string representation of the Vector3
  12682. * @returns a string with the Vector3 coordinates.
  12683. */
  12684. toString(): string;
  12685. /**
  12686. * Gets the class name
  12687. * @returns the string "Vector3"
  12688. */
  12689. getClassName(): string;
  12690. /**
  12691. * Creates the Vector3 hash code
  12692. * @returns a number which tends to be unique between Vector3 instances
  12693. */
  12694. getHashCode(): number;
  12695. /**
  12696. * Creates an array containing three elements : the coordinates of the Vector3
  12697. * @returns a new array of numbers
  12698. */
  12699. asArray(): number[];
  12700. /**
  12701. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  12702. * @param array defines the destination array
  12703. * @param index defines the offset in the destination array
  12704. * @returns the current Vector3
  12705. */
  12706. toArray(array: FloatArray, index?: number): Vector3;
  12707. /**
  12708. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  12709. * @returns a new Quaternion object, computed from the Vector3 coordinates
  12710. */
  12711. toQuaternion(): Quaternion;
  12712. /**
  12713. * Adds the passed vector to the current Vector3
  12714. * @param otherVector defines the second operand
  12715. * @returns the current updated Vector3
  12716. */
  12717. addInPlace(otherVector: Vector3): Vector3;
  12718. /**
  12719. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  12720. * @param otherVector defines the second operand
  12721. * @returns the resulting Vector3
  12722. */
  12723. add(otherVector: Vector3): Vector3;
  12724. /**
  12725. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  12726. * @param otherVector defines the second operand
  12727. * @param result defines the Vector3 object where to store the result
  12728. * @returns the current Vector3
  12729. */
  12730. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  12731. /**
  12732. * Subtract the passed vector from the current Vector3
  12733. * @param otherVector defines the second operand
  12734. * @returns the current updated Vector3
  12735. */
  12736. subtractInPlace(otherVector: Vector3): Vector3;
  12737. /**
  12738. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  12739. * @param otherVector defines the second operand
  12740. * @returns the resulting Vector3
  12741. */
  12742. subtract(otherVector: Vector3): Vector3;
  12743. /**
  12744. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  12745. * @param otherVector defines the second operand
  12746. * @param result defines the Vector3 object where to store the result
  12747. * @returns the current Vector3
  12748. */
  12749. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  12750. /**
  12751. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  12752. * @param x defines the x coordinate of the operand
  12753. * @param y defines the y coordinate of the operand
  12754. * @param z defines the z coordinate of the operand
  12755. * @returns the resulting Vector3
  12756. */
  12757. subtractFromFloats(x: number, y: number, z: number): Vector3;
  12758. /**
  12759. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  12760. * @param x defines the x coordinate of the operand
  12761. * @param y defines the y coordinate of the operand
  12762. * @param z defines the z coordinate of the operand
  12763. * @param result defines the Vector3 object where to store the result
  12764. * @returns the current Vector3
  12765. */
  12766. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  12767. /**
  12768. * Gets a new Vector3 set with the current Vector3 negated coordinates
  12769. * @returns a new Vector3
  12770. */
  12771. negate(): Vector3;
  12772. /**
  12773. * Multiplies the Vector3 coordinates by the float "scale"
  12774. * @param scale defines the multiplier factor
  12775. * @returns the current updated Vector3
  12776. */
  12777. scaleInPlace(scale: number): Vector3;
  12778. /**
  12779. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  12780. * @param scale defines the multiplier factor
  12781. * @returns a new Vector3
  12782. */
  12783. scale(scale: number): Vector3;
  12784. /**
  12785. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  12786. * @param scale defines the multiplier factor
  12787. * @param result defines the Vector3 object where to store the result
  12788. * @returns the current Vector3
  12789. */
  12790. scaleToRef(scale: number, result: Vector3): Vector3;
  12791. /**
  12792. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  12793. * @param scale defines the scale factor
  12794. * @param result defines the Vector3 object where to store the result
  12795. * @returns the unmodified current Vector3
  12796. */
  12797. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  12798. /**
  12799. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  12800. * @param otherVector defines the second operand
  12801. * @returns true if both vectors are equals
  12802. */
  12803. equals(otherVector: Vector3): boolean;
  12804. /**
  12805. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  12806. * @param otherVector defines the second operand
  12807. * @param epsilon defines the minimal distance to define values as equals
  12808. * @returns true if both vectors are distant less than epsilon
  12809. */
  12810. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  12811. /**
  12812. * Returns true if the current Vector3 coordinates equals the passed floats
  12813. * @param x defines the x coordinate of the operand
  12814. * @param y defines the y coordinate of the operand
  12815. * @param z defines the z coordinate of the operand
  12816. * @returns true if both vectors are equals
  12817. */
  12818. equalsToFloats(x: number, y: number, z: number): boolean;
  12819. /**
  12820. * Multiplies the current Vector3 coordinates by the passed ones
  12821. * @param otherVector defines the second operand
  12822. * @returns the current updated Vector3
  12823. */
  12824. multiplyInPlace(otherVector: Vector3): Vector3;
  12825. /**
  12826. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  12827. * @param otherVector defines the second operand
  12828. * @returns the new Vector3
  12829. */
  12830. multiply(otherVector: Vector3): Vector3;
  12831. /**
  12832. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  12833. * @param otherVector defines the second operand
  12834. * @param result defines the Vector3 object where to store the result
  12835. * @returns the current Vector3
  12836. */
  12837. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  12838. /**
  12839. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  12840. * @param x defines the x coordinate of the operand
  12841. * @param y defines the y coordinate of the operand
  12842. * @param z defines the z coordinate of the operand
  12843. * @returns the new Vector3
  12844. */
  12845. multiplyByFloats(x: number, y: number, z: number): Vector3;
  12846. /**
  12847. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  12848. * @param otherVector defines the second operand
  12849. * @returns the new Vector3
  12850. */
  12851. divide(otherVector: Vector3): Vector3;
  12852. /**
  12853. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  12854. * @param otherVector defines the second operand
  12855. * @param result defines the Vector3 object where to store the result
  12856. * @returns the current Vector3
  12857. */
  12858. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  12859. /**
  12860. * Divides the current Vector3 coordinates by the passed ones.
  12861. * @param otherVector defines the second operand
  12862. * @returns the current updated Vector3
  12863. */
  12864. divideInPlace(otherVector: Vector3): Vector3;
  12865. /**
  12866. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  12867. * @param other defines the second operand
  12868. * @returns the current updated Vector3
  12869. */
  12870. minimizeInPlace(other: Vector3): Vector3;
  12871. /**
  12872. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  12873. * @param other defines the second operand
  12874. * @returns the current updated Vector3
  12875. */
  12876. maximizeInPlace(other: Vector3): Vector3;
  12877. /**
  12878. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  12879. */
  12880. readonly isNonUniform: boolean;
  12881. /**
  12882. * Gets the length of the Vector3
  12883. * @returns the length of the Vecto3
  12884. */
  12885. length(): number;
  12886. /**
  12887. * Gets the squared length of the Vector3
  12888. * @returns squared length of the Vector3
  12889. */
  12890. lengthSquared(): number;
  12891. /**
  12892. * Normalize the current Vector3.
  12893. * Please note that this is an in place operation.
  12894. * @returns the current updated Vector3
  12895. */
  12896. normalize(): Vector3;
  12897. /**
  12898. * Normalize the current Vector3 to a new vector
  12899. * @returns the new Vector3
  12900. */
  12901. normalizeToNew(): Vector3;
  12902. /**
  12903. * Normalize the current Vector3 to the reference
  12904. * @param reference define the Vector3 to update
  12905. * @returns the updated Vector3
  12906. */
  12907. normalizeToRef(reference: Vector3): Vector3;
  12908. /**
  12909. * Creates a new Vector3 copied from the current Vector3
  12910. * @returns the new Vector3
  12911. */
  12912. clone(): Vector3;
  12913. /**
  12914. * Copies the passed vector coordinates to the current Vector3 ones
  12915. * @param source defines the source Vector3
  12916. * @returns the current updated Vector3
  12917. */
  12918. copyFrom(source: Vector3): Vector3;
  12919. /**
  12920. * Copies the passed floats to the current Vector3 coordinates
  12921. * @param x defines the x coordinate of the operand
  12922. * @param y defines the y coordinate of the operand
  12923. * @param z defines the z coordinate of the operand
  12924. * @returns the current updated Vector3
  12925. */
  12926. copyFromFloats(x: number, y: number, z: number): Vector3;
  12927. /**
  12928. * Copies the passed floats to the current Vector3 coordinates
  12929. * @param x defines the x coordinate of the operand
  12930. * @param y defines the y coordinate of the operand
  12931. * @param z defines the z coordinate of the operand
  12932. * @returns the current updated Vector3
  12933. */
  12934. set(x: number, y: number, z: number): Vector3;
  12935. /**
  12936. * Get the clip factor between two vectors
  12937. * @param vector0 defines the first operand
  12938. * @param vector1 defines the second operand
  12939. * @param axis defines the axis to use
  12940. * @param size defines the size along the axis
  12941. * @returns the clip factor
  12942. */
  12943. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  12944. /**
  12945. * Get angle between two vectors
  12946. * @param vector0 angle between vector0 and vector1
  12947. * @param vector1 angle between vector0 and vector1
  12948. * @param normal direction of the normal
  12949. * @return the angle between vector0 and vector1
  12950. */
  12951. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  12952. /**
  12953. * Returns a new Vector3 set from the index "offset" of the passed array
  12954. * @param array defines the source array
  12955. * @param offset defines the offset in the source array
  12956. * @returns the new Vector3
  12957. */
  12958. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  12959. /**
  12960. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  12961. * This function is deprecated. Use FromArray instead
  12962. * @param array defines the source array
  12963. * @param offset defines the offset in the source array
  12964. * @returns the new Vector3
  12965. */
  12966. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  12967. /**
  12968. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  12969. * @param array defines the source array
  12970. * @param offset defines the offset in the source array
  12971. * @param result defines the Vector3 where to store the result
  12972. */
  12973. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  12974. /**
  12975. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  12976. * This function is deprecated. Use FromArrayToRef instead.
  12977. * @param array defines the source array
  12978. * @param offset defines the offset in the source array
  12979. * @param result defines the Vector3 where to store the result
  12980. */
  12981. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  12982. /**
  12983. * Sets the passed vector "result" with the passed floats.
  12984. * @param x defines the x coordinate of the source
  12985. * @param y defines the y coordinate of the source
  12986. * @param z defines the z coordinate of the source
  12987. * @param result defines the Vector3 where to store the result
  12988. */
  12989. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  12990. /**
  12991. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  12992. * @returns a new empty Vector3
  12993. */
  12994. static Zero(): Vector3;
  12995. /**
  12996. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  12997. * @returns a new unit Vector3
  12998. */
  12999. static One(): Vector3;
  13000. /**
  13001. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13002. * @returns a new up Vector3
  13003. */
  13004. static Up(): Vector3;
  13005. /**
  13006. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13007. * @returns a new forward Vector3
  13008. */
  13009. static Forward(): Vector3;
  13010. /**
  13011. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13012. * @returns a new right Vector3
  13013. */
  13014. static Right(): Vector3;
  13015. /**
  13016. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13017. * @returns a new left Vector3
  13018. */
  13019. static Left(): Vector3;
  13020. /**
  13021. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  13022. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13023. * @param vector defines the Vector3 to transform
  13024. * @param transformation defines the transformation matrix
  13025. * @returns the transformed Vector3
  13026. */
  13027. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13028. /**
  13029. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  13030. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13031. * @param vector defines the Vector3 to transform
  13032. * @param transformation defines the transformation matrix
  13033. * @param result defines the Vector3 where to store the result
  13034. */
  13035. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13036. /**
  13037. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  13038. * This method computes tranformed coordinates only, not transformed direction vectors
  13039. * @param x define the x coordinate of the source vector
  13040. * @param y define the y coordinate of the source vector
  13041. * @param z define the z coordinate of the source vector
  13042. * @param transformation defines the transformation matrix
  13043. * @param result defines the Vector3 where to store the result
  13044. */
  13045. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13046. /**
  13047. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  13048. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13049. * @param vector defines the Vector3 to transform
  13050. * @param transformation defines the transformation matrix
  13051. * @returns the new Vector3
  13052. */
  13053. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13054. /**
  13055. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  13056. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13057. * @param vector defines the Vector3 to transform
  13058. * @param transformation defines the transformation matrix
  13059. * @param result defines the Vector3 where to store the result
  13060. */
  13061. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13062. /**
  13063. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  13064. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13065. * @param x define the x coordinate of the source vector
  13066. * @param y define the y coordinate of the source vector
  13067. * @param z define the z coordinate of the source vector
  13068. * @param transformation defines the transformation matrix
  13069. * @param result defines the Vector3 where to store the result
  13070. */
  13071. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13072. /**
  13073. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13074. * @param value1 defines the first control point
  13075. * @param value2 defines the second control point
  13076. * @param value3 defines the third control point
  13077. * @param value4 defines the fourth control point
  13078. * @param amount defines the amount on the spline to use
  13079. * @returns the new Vector3
  13080. */
  13081. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13082. /**
  13083. * 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"
  13084. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13085. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13086. * @param value defines the current value
  13087. * @param min defines the lower range value
  13088. * @param max defines the upper range value
  13089. * @returns the new Vector3
  13090. */
  13091. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13092. /**
  13093. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13094. * @param value1 defines the first control point
  13095. * @param tangent1 defines the first tangent vector
  13096. * @param value2 defines the second control point
  13097. * @param tangent2 defines the second tangent vector
  13098. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13099. * @returns the new Vector3
  13100. */
  13101. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13102. /**
  13103. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13104. * @param start defines the start value
  13105. * @param end defines the end value
  13106. * @param amount max defines amount between both (between 0 and 1)
  13107. * @returns the new Vector3
  13108. */
  13109. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13110. /**
  13111. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13112. * @param start defines the start value
  13113. * @param end defines the end value
  13114. * @param amount max defines amount between both (between 0 and 1)
  13115. * @param result defines the Vector3 where to store the result
  13116. */
  13117. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13118. /**
  13119. * Returns the dot product (float) between the vectors "left" and "right"
  13120. * @param left defines the left operand
  13121. * @param right defines the right operand
  13122. * @returns the dot product
  13123. */
  13124. static Dot(left: Vector3, right: Vector3): number;
  13125. /**
  13126. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13127. * The cross product is then orthogonal to both "left" and "right"
  13128. * @param left defines the left operand
  13129. * @param right defines the right operand
  13130. * @returns the cross product
  13131. */
  13132. static Cross(left: Vector3, right: Vector3): Vector3;
  13133. /**
  13134. * Sets the passed vector "result" with the cross product of "left" and "right"
  13135. * The cross product is then orthogonal to both "left" and "right"
  13136. * @param left defines the left operand
  13137. * @param right defines the right operand
  13138. * @param result defines the Vector3 where to store the result
  13139. */
  13140. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13141. /**
  13142. * Returns a new Vector3 as the normalization of the passed vector
  13143. * @param vector defines the Vector3 to normalize
  13144. * @returns the new Vector3
  13145. */
  13146. static Normalize(vector: Vector3): Vector3;
  13147. /**
  13148. * Sets the passed vector "result" with the normalization of the passed first vector
  13149. * @param vector defines the Vector3 to normalize
  13150. * @param result defines the Vector3 where to store the result
  13151. */
  13152. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13153. private static _viewportMatrixCache;
  13154. /**
  13155. * Project a Vector3 onto screen space
  13156. * @param vector defines the Vector3 to project
  13157. * @param world defines the world matrix to use
  13158. * @param transform defines the transform (view x projection) matrix to use
  13159. * @param viewport defines the screen viewport to use
  13160. * @returns the new Vector3
  13161. */
  13162. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13163. /**
  13164. * Unproject from screen space to object space
  13165. * @param source defines the screen space Vector3 to use
  13166. * @param viewportWidth defines the current width of the viewport
  13167. * @param viewportHeight defines the current height of the viewport
  13168. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13169. * @param transform defines the transform (view x projection) matrix to use
  13170. * @returns the new Vector3
  13171. */
  13172. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13173. /**
  13174. * Unproject from screen space to object space
  13175. * @param source defines the screen space Vector3 to use
  13176. * @param viewportWidth defines the current width of the viewport
  13177. * @param viewportHeight defines the current height of the viewport
  13178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13179. * @param view defines the view matrix to use
  13180. * @param projection defines the projection matrix to use
  13181. * @returns the new Vector3
  13182. */
  13183. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13184. /**
  13185. * Unproject from screen space to object space
  13186. * @param source defines the screen space Vector3 to use
  13187. * @param viewportWidth defines the current width of the viewport
  13188. * @param viewportHeight defines the current height of the viewport
  13189. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13190. * @param view defines the view matrix to use
  13191. * @param projection defines the projection matrix to use
  13192. * @param result defines the Vector3 where to store the result
  13193. */
  13194. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13195. /**
  13196. * Unproject from screen space to object space
  13197. * @param sourceX defines the screen space x coordinate to use
  13198. * @param sourceY defines the screen space y coordinate to use
  13199. * @param sourceZ defines the screen space z coordinate to use
  13200. * @param viewportWidth defines the current width of the viewport
  13201. * @param viewportHeight defines the current height of the viewport
  13202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13203. * @param view defines the view matrix to use
  13204. * @param projection defines the projection matrix to use
  13205. * @param result defines the Vector3 where to store the result
  13206. */
  13207. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13208. /**
  13209. * Gets the minimal coordinate values between two Vector3
  13210. * @param left defines the first operand
  13211. * @param right defines the second operand
  13212. * @returns the new Vector3
  13213. */
  13214. static Minimize(left: Vector3, right: Vector3): Vector3;
  13215. /**
  13216. * Gets the maximal coordinate values between two Vector3
  13217. * @param left defines the first operand
  13218. * @param right defines the second operand
  13219. * @returns the new Vector3
  13220. */
  13221. static Maximize(left: Vector3, right: Vector3): Vector3;
  13222. /**
  13223. * Returns the distance between the vectors "value1" and "value2"
  13224. * @param value1 defines the first operand
  13225. * @param value2 defines the second operand
  13226. * @returns the distance
  13227. */
  13228. static Distance(value1: Vector3, value2: Vector3): number;
  13229. /**
  13230. * Returns the squared distance between the vectors "value1" and "value2"
  13231. * @param value1 defines the first operand
  13232. * @param value2 defines the second operand
  13233. * @returns the squared distance
  13234. */
  13235. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  13236. /**
  13237. * Returns a new Vector3 located at the center between "value1" and "value2"
  13238. * @param value1 defines the first operand
  13239. * @param value2 defines the second operand
  13240. * @returns the new Vector3
  13241. */
  13242. static Center(value1: Vector3, value2: Vector3): Vector3;
  13243. /**
  13244. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  13245. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  13246. * to something in order to rotate it from its local system to the given target system
  13247. * Note: axis1, axis2 and axis3 are normalized during this operation
  13248. * @param axis1 defines the first axis
  13249. * @param axis2 defines the second axis
  13250. * @param axis3 defines the third axis
  13251. * @returns a new Vector3
  13252. */
  13253. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  13254. /**
  13255. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  13256. * @param axis1 defines the first axis
  13257. * @param axis2 defines the second axis
  13258. * @param axis3 defines the third axis
  13259. * @param ref defines the Vector3 where to store the result
  13260. */
  13261. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  13262. }
  13263. class Vector4 {
  13264. x: number;
  13265. y: number;
  13266. z: number;
  13267. w: number;
  13268. /**
  13269. * Creates a Vector4 object from the passed floats.
  13270. */
  13271. constructor(x: number, y: number, z: number, w: number);
  13272. /**
  13273. * Returns the string with the Vector4 coordinates.
  13274. */
  13275. toString(): string;
  13276. /**
  13277. * Returns the string "Vector4".
  13278. */
  13279. getClassName(): string;
  13280. /**
  13281. * Returns the Vector4 hash code.
  13282. */
  13283. getHashCode(): number;
  13284. /**
  13285. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  13286. */
  13287. asArray(): number[];
  13288. /**
  13289. * Populates the passed array from the passed index with the Vector4 coordinates.
  13290. * Returns the Vector4.
  13291. */
  13292. toArray(array: FloatArray, index?: number): Vector4;
  13293. /**
  13294. * Adds the passed vector to the current Vector4.
  13295. * Returns the updated Vector4.
  13296. */
  13297. addInPlace(otherVector: Vector4): Vector4;
  13298. /**
  13299. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  13300. */
  13301. add(otherVector: Vector4): Vector4;
  13302. /**
  13303. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  13304. * Returns the current Vector4.
  13305. */
  13306. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  13307. /**
  13308. * Subtract in place the passed vector from the current Vector4.
  13309. * Returns the updated Vector4.
  13310. */
  13311. subtractInPlace(otherVector: Vector4): Vector4;
  13312. /**
  13313. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  13314. */
  13315. subtract(otherVector: Vector4): Vector4;
  13316. /**
  13317. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  13318. * Returns the current Vector4.
  13319. */
  13320. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  13321. /**
  13322. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  13323. */
  13324. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13325. /**
  13326. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  13327. * Returns the current Vector4.
  13328. */
  13329. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  13330. /**
  13331. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  13332. */
  13333. negate(): Vector4;
  13334. /**
  13335. * Multiplies the current Vector4 coordinates by scale (float).
  13336. * Returns the updated Vector4.
  13337. */
  13338. scaleInPlace(scale: number): Vector4;
  13339. /**
  13340. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  13341. */
  13342. scale(scale: number): Vector4;
  13343. /**
  13344. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  13345. * Returns the current Vector4.
  13346. */
  13347. scaleToRef(scale: number, result: Vector4): Vector4;
  13348. /**
  13349. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  13350. * @param scale defines the scale factor
  13351. * @param result defines the Vector4 object where to store the result
  13352. * @returns the unmodified current Vector4
  13353. */
  13354. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  13355. /**
  13356. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  13357. */
  13358. equals(otherVector: Vector4): boolean;
  13359. /**
  13360. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  13361. */
  13362. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  13363. /**
  13364. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  13365. */
  13366. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  13367. /**
  13368. * Multiplies in place the current Vector4 by the passed one.
  13369. * Returns the updated Vector4.
  13370. */
  13371. multiplyInPlace(otherVector: Vector4): Vector4;
  13372. /**
  13373. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  13374. */
  13375. multiply(otherVector: Vector4): Vector4;
  13376. /**
  13377. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  13378. * Returns the current Vector4.
  13379. */
  13380. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  13381. /**
  13382. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  13383. */
  13384. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  13385. /**
  13386. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  13387. */
  13388. divide(otherVector: Vector4): Vector4;
  13389. /**
  13390. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  13391. * Returns the current Vector4.
  13392. */
  13393. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  13394. /**
  13395. * Divides the current Vector3 coordinates by the passed ones.
  13396. * @returns the updated Vector3.
  13397. */
  13398. divideInPlace(otherVector: Vector4): Vector4;
  13399. /**
  13400. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  13401. * @param other defines the second operand
  13402. * @returns the current updated Vector4
  13403. */
  13404. minimizeInPlace(other: Vector4): Vector4;
  13405. /**
  13406. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  13407. * @param other defines the second operand
  13408. * @returns the current updated Vector4
  13409. */
  13410. maximizeInPlace(other: Vector4): Vector4;
  13411. /**
  13412. * Returns the Vector4 length (float).
  13413. */
  13414. length(): number;
  13415. /**
  13416. * Returns the Vector4 squared length (float).
  13417. */
  13418. lengthSquared(): number;
  13419. /**
  13420. * Normalizes in place the Vector4.
  13421. * Returns the updated Vector4.
  13422. */
  13423. normalize(): Vector4;
  13424. /**
  13425. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  13426. */
  13427. toVector3(): Vector3;
  13428. /**
  13429. * Returns a new Vector4 copied from the current one.
  13430. */
  13431. clone(): Vector4;
  13432. /**
  13433. * Updates the current Vector4 with the passed one coordinates.
  13434. * Returns the updated Vector4.
  13435. */
  13436. copyFrom(source: Vector4): Vector4;
  13437. /**
  13438. * Updates the current Vector4 coordinates with the passed floats.
  13439. * Returns the updated Vector4.
  13440. */
  13441. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13442. /**
  13443. * Updates the current Vector4 coordinates with the passed floats.
  13444. * Returns the updated Vector4.
  13445. */
  13446. set(x: number, y: number, z: number, w: number): Vector4;
  13447. /**
  13448. * Returns a new Vector4 set from the starting index of the passed array.
  13449. */
  13450. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  13451. /**
  13452. * Updates the passed vector "result" from the starting index of the passed array.
  13453. */
  13454. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  13455. /**
  13456. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  13457. */
  13458. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  13459. /**
  13460. * Updates the passed vector "result" coordinates from the passed floats.
  13461. */
  13462. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  13463. /**
  13464. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  13465. */
  13466. static Zero(): Vector4;
  13467. /**
  13468. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  13469. */
  13470. static One(): Vector4;
  13471. /**
  13472. * Returns a new normalized Vector4 from the passed one.
  13473. */
  13474. static Normalize(vector: Vector4): Vector4;
  13475. /**
  13476. * Updates the passed vector "result" from the normalization of the passed one.
  13477. */
  13478. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  13479. static Minimize(left: Vector4, right: Vector4): Vector4;
  13480. static Maximize(left: Vector4, right: Vector4): Vector4;
  13481. /**
  13482. * Returns the distance (float) between the vectors "value1" and "value2".
  13483. */
  13484. static Distance(value1: Vector4, value2: Vector4): number;
  13485. /**
  13486. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13487. */
  13488. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  13489. /**
  13490. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  13491. */
  13492. static Center(value1: Vector4, value2: Vector4): Vector4;
  13493. /**
  13494. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  13495. * This methods computes transformed normalized direction vectors only.
  13496. */
  13497. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  13498. /**
  13499. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  13500. * This methods computes transformed normalized direction vectors only.
  13501. */
  13502. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  13503. /**
  13504. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  13505. * This methods computes transformed normalized direction vectors only.
  13506. */
  13507. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  13508. }
  13509. interface ISize {
  13510. width: number;
  13511. height: number;
  13512. }
  13513. class Size implements ISize {
  13514. width: number;
  13515. height: number;
  13516. /**
  13517. * Creates a Size object from the passed width and height (floats).
  13518. */
  13519. constructor(width: number, height: number);
  13520. toString(): string;
  13521. /**
  13522. * Returns the string "Size"
  13523. */
  13524. getClassName(): string;
  13525. /**
  13526. * Returns the Size hash code.
  13527. */
  13528. getHashCode(): number;
  13529. /**
  13530. * Updates the current size from the passed one.
  13531. * Returns the updated Size.
  13532. */
  13533. copyFrom(src: Size): void;
  13534. /**
  13535. * Updates in place the current Size from the passed floats.
  13536. * Returns the updated Size.
  13537. */
  13538. copyFromFloats(width: number, height: number): Size;
  13539. /**
  13540. * Updates in place the current Size from the passed floats.
  13541. * Returns the updated Size.
  13542. */
  13543. set(width: number, height: number): Size;
  13544. /**
  13545. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  13546. */
  13547. multiplyByFloats(w: number, h: number): Size;
  13548. /**
  13549. * Returns a new Size copied from the passed one.
  13550. */
  13551. clone(): Size;
  13552. /**
  13553. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  13554. */
  13555. equals(other: Size): boolean;
  13556. /**
  13557. * Returns the surface of the Size : width * height (float).
  13558. */
  13559. readonly surface: number;
  13560. /**
  13561. * Returns a new Size set to (0.0, 0.0)
  13562. */
  13563. static Zero(): Size;
  13564. /**
  13565. * Returns a new Size set as the addition result of the current Size and the passed one.
  13566. */
  13567. add(otherSize: Size): Size;
  13568. /**
  13569. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  13570. */
  13571. subtract(otherSize: Size): Size;
  13572. /**
  13573. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  13574. */
  13575. static Lerp(start: Size, end: Size, amount: number): Size;
  13576. }
  13577. class Quaternion {
  13578. x: number;
  13579. y: number;
  13580. z: number;
  13581. w: number;
  13582. /**
  13583. * Creates a new Quaternion from the passed floats.
  13584. */
  13585. constructor(x?: number, y?: number, z?: number, w?: number);
  13586. /**
  13587. * Returns a string with the Quaternion coordinates.
  13588. */
  13589. toString(): string;
  13590. /**
  13591. * Returns the string "Quaternion".
  13592. */
  13593. getClassName(): string;
  13594. /**
  13595. * Returns the Quaternion hash code.
  13596. */
  13597. getHashCode(): number;
  13598. /**
  13599. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  13600. */
  13601. asArray(): number[];
  13602. /**
  13603. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  13604. */
  13605. equals(otherQuaternion: Quaternion): boolean;
  13606. /**
  13607. * Returns a new Quaternion copied from the current one.
  13608. */
  13609. clone(): Quaternion;
  13610. /**
  13611. * Updates the current Quaternion from the passed one coordinates.
  13612. * Returns the updated Quaterion.
  13613. */
  13614. copyFrom(other: Quaternion): Quaternion;
  13615. /**
  13616. * Updates the current Quaternion from the passed float coordinates.
  13617. * Returns the updated Quaterion.
  13618. */
  13619. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  13620. /**
  13621. * Updates the current Quaternion from the passed float coordinates.
  13622. * Returns the updated Quaterion.
  13623. */
  13624. set(x: number, y: number, z: number, w: number): Quaternion;
  13625. /**
  13626. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  13627. */
  13628. add(other: Quaternion): Quaternion;
  13629. /**
  13630. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  13631. */
  13632. subtract(other: Quaternion): Quaternion;
  13633. /**
  13634. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  13635. */
  13636. scale(value: number): Quaternion;
  13637. /**
  13638. * Scale the current Quaternion values by a factor to a given Quaternion
  13639. * @param scale defines the scale factor
  13640. * @param result defines the Quaternion object where to store the result
  13641. * @returns the unmodified current Quaternion
  13642. */
  13643. scaleToRef(scale: number, result: Quaternion): Quaternion;
  13644. /**
  13645. * Scale the current Quaternion values by a factor and add the result to a given Quaternion
  13646. * @param scale defines the scale factor
  13647. * @param result defines the Quaternion object where to store the result
  13648. * @returns the unmodified current Quaternion
  13649. */
  13650. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  13651. /**
  13652. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  13653. */
  13654. multiply(q1: Quaternion): Quaternion;
  13655. /**
  13656. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  13657. * Returns the current Quaternion.
  13658. */
  13659. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  13660. /**
  13661. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  13662. * Returns the updated Quaternion.
  13663. */
  13664. multiplyInPlace(q1: Quaternion): Quaternion;
  13665. /**
  13666. * Sets the passed "ref" with the conjugation of the current Quaternion.
  13667. * Returns the current Quaternion.
  13668. */
  13669. conjugateToRef(ref: Quaternion): Quaternion;
  13670. /**
  13671. * Conjugates in place the current Quaternion.
  13672. * Returns the updated Quaternion.
  13673. */
  13674. conjugateInPlace(): Quaternion;
  13675. /**
  13676. * Returns a new Quaternion as the conjugate of the current Quaternion.
  13677. */
  13678. conjugate(): Quaternion;
  13679. /**
  13680. * Returns the Quaternion length (float).
  13681. */
  13682. length(): number;
  13683. /**
  13684. * Normalize in place the current Quaternion.
  13685. * Returns the updated Quaternion.
  13686. */
  13687. normalize(): Quaternion;
  13688. /**
  13689. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion
  13690. * @param order is a reserved parameter and is ignore for now
  13691. * @returns the new Vector3
  13692. */
  13693. toEulerAngles(order?: string): Vector3;
  13694. /**
  13695. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion
  13696. * @param result defines the vector which will be filled with the Euler angles
  13697. * @param order is a reserved parameter and is ignore for now
  13698. * @returns the current Quaternion
  13699. */
  13700. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  13701. /**
  13702. * Updates the passed rotation matrix with the current Quaternion values.
  13703. * Returns the current Quaternion.
  13704. */
  13705. toRotationMatrix(result: Matrix): Quaternion;
  13706. /**
  13707. * Updates the current Quaternion from the passed rotation matrix values.
  13708. * Returns the updated Quaternion.
  13709. */
  13710. fromRotationMatrix(matrix: Matrix): Quaternion;
  13711. /**
  13712. * Returns a new Quaternion set from the passed rotation matrix values.
  13713. */
  13714. static FromRotationMatrix(matrix: Matrix): Quaternion;
  13715. /**
  13716. * Updates the passed quaternion "result" with the passed rotation matrix values.
  13717. */
  13718. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  13719. /**
  13720. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  13721. */
  13722. static Zero(): Quaternion;
  13723. /**
  13724. * Returns a new Quaternion as the inverted current Quaternion.
  13725. */
  13726. static Inverse(q: Quaternion): Quaternion;
  13727. /**
  13728. * Returns the identity Quaternion.
  13729. */
  13730. static Identity(): Quaternion;
  13731. static IsIdentity(quaternion: Quaternion): boolean;
  13732. /**
  13733. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  13734. */
  13735. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  13736. /**
  13737. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  13738. */
  13739. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  13740. /**
  13741. * Retuns a new Quaternion set from the starting index of the passed array.
  13742. */
  13743. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  13744. /**
  13745. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  13746. */
  13747. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  13748. /**
  13749. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  13750. */
  13751. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  13752. /**
  13753. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  13754. */
  13755. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  13756. /**
  13757. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  13758. */
  13759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  13760. /**
  13761. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  13762. * cf to Vector3.RotationFromAxis() documentation.
  13763. * Note : axis1, axis2 and axis3 are normalized during this operation.
  13764. */
  13765. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  13766. /**
  13767. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  13768. * cf to Vector3.RotationFromAxis() documentation.
  13769. * Note : axis1, axis2 and axis3 are normalized during this operation.
  13770. */
  13771. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  13772. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  13773. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  13774. /**
  13775. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  13776. */
  13777. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  13778. }
  13779. class Matrix {
  13780. private static _tempQuaternion;
  13781. private static _xAxis;
  13782. private static _yAxis;
  13783. private static _zAxis;
  13784. private static _updateFlagSeed;
  13785. private static _identityReadOnly;
  13786. private _isIdentity;
  13787. private _isIdentityDirty;
  13788. updateFlag: number;
  13789. m: Float32Array;
  13790. _markAsUpdated(): void;
  13791. constructor();
  13792. /**
  13793. * Boolean : True is the matrix is the identity matrix
  13794. */
  13795. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  13796. /**
  13797. * Returns the matrix determinant (float).
  13798. */
  13799. determinant(): number;
  13800. /**
  13801. * Returns the matrix underlying array.
  13802. */
  13803. toArray(): Float32Array;
  13804. /**
  13805. * Returns the matrix underlying array.
  13806. */
  13807. asArray(): Float32Array;
  13808. /**
  13809. * Inverts in place the Matrix.
  13810. * Returns the Matrix inverted.
  13811. */
  13812. invert(): Matrix;
  13813. /**
  13814. * Sets all the matrix elements to zero.
  13815. * Returns the Matrix.
  13816. */
  13817. reset(): Matrix;
  13818. /**
  13819. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  13820. */
  13821. add(other: Matrix): Matrix;
  13822. /**
  13823. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  13824. * Returns the Matrix.
  13825. */
  13826. addToRef(other: Matrix, result: Matrix): Matrix;
  13827. /**
  13828. * Adds in place the passed matrix to the current Matrix.
  13829. * Returns the updated Matrix.
  13830. */
  13831. addToSelf(other: Matrix): Matrix;
  13832. /**
  13833. * Sets the passed matrix with the current inverted Matrix.
  13834. * Returns the unmodified current Matrix.
  13835. */
  13836. invertToRef(other: Matrix): Matrix;
  13837. /**
  13838. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  13839. * Returns the updated Matrix.
  13840. */
  13841. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  13842. /**
  13843. * Inserts the translation vector in the current Matrix.
  13844. * Returns the updated Matrix.
  13845. */
  13846. setTranslation(vector3: Vector3): Matrix;
  13847. /**
  13848. * Returns a new Vector3 as the extracted translation from the Matrix.
  13849. */
  13850. getTranslation(): Vector3;
  13851. /**
  13852. * Fill a Vector3 with the extracted translation from the Matrix.
  13853. */
  13854. getTranslationToRef(result: Vector3): Matrix;
  13855. /**
  13856. * Remove rotation and scaling part from the Matrix.
  13857. * Returns the updated Matrix.
  13858. */
  13859. removeRotationAndScaling(): Matrix;
  13860. /**
  13861. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  13862. */
  13863. multiply(other: Matrix): Matrix;
  13864. /**
  13865. * Updates the current Matrix from the passed one values.
  13866. * Returns the updated Matrix.
  13867. */
  13868. copyFrom(other: Matrix): Matrix;
  13869. /**
  13870. * Populates the passed array from the starting index with the Matrix values.
  13871. * Returns the Matrix.
  13872. */
  13873. copyToArray(array: Float32Array, offset?: number): Matrix;
  13874. /**
  13875. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  13876. */
  13877. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  13878. /**
  13879. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  13880. */
  13881. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  13882. /**
  13883. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  13884. */
  13885. equals(value: Matrix): boolean;
  13886. /**
  13887. * Returns a new Matrix from the current Matrix.
  13888. */
  13889. clone(): Matrix;
  13890. /**
  13891. * Returns the string "Matrix"
  13892. */
  13893. getClassName(): string;
  13894. /**
  13895. * Returns the Matrix hash code.
  13896. */
  13897. getHashCode(): number;
  13898. /**
  13899. * Decomposes the current Matrix into :
  13900. * - a scale vector3 passed as a reference to update,
  13901. * - a rotation quaternion passed as a reference to update,
  13902. * - a translation vector3 passed as a reference to update.
  13903. * Returns the true if operation was successful.
  13904. */
  13905. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  13906. /**
  13907. * Returns the index-th row of the current matrix as a new Vector4.
  13908. */
  13909. getRow(index: number): Nullable<Vector4>;
  13910. /**
  13911. * Sets the index-th row of the current matrix with the passed Vector4 values.
  13912. * Returns the updated Matrix.
  13913. */
  13914. setRow(index: number, row: Vector4): Matrix;
  13915. /**
  13916. * Compute the transpose of the matrix.
  13917. * Returns a new Matrix.
  13918. */
  13919. transpose(): Matrix;
  13920. /**
  13921. * Compute the transpose of the matrix.
  13922. * Returns the current matrix.
  13923. */
  13924. transposeToRef(result: Matrix): Matrix;
  13925. /**
  13926. * Sets the index-th row of the current matrix with the passed 4 x float values.
  13927. * Returns the updated Matrix.
  13928. */
  13929. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  13930. /**
  13931. * Compute a new Matrix set with the current Matrix values multiplied by scale (float)
  13932. * @param scale defines the scale factor
  13933. * @returns a new Matrix
  13934. */
  13935. scale(scale: number): Matrix;
  13936. /**
  13937. * Scale the current Matrix values by a factor to a given result Matrix
  13938. * @param scale defines the scale factor
  13939. * @param result defines the Matrix to store the result
  13940. * @returns the current Matrix
  13941. */
  13942. scaleToRef(scale: number, result: Matrix): Matrix;
  13943. /**
  13944. * Scale the current Matrix values by a factor and add the result to a given Matrix
  13945. * @param scale defines the scale factor
  13946. * @param result defines the Matrix to store the result
  13947. * @returns the current Matrix
  13948. */
  13949. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  13950. /**
  13951. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  13952. * @param ref matrix to store the result
  13953. */
  13954. toNormalMatrix(ref: Matrix): void;
  13955. /**
  13956. * Returns a new Matrix as the extracted rotation matrix from the current one.
  13957. */
  13958. getRotationMatrix(): Matrix;
  13959. /**
  13960. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  13961. * Returns the current Matrix.
  13962. */
  13963. getRotationMatrixToRef(result: Matrix): Matrix;
  13964. /**
  13965. * Returns a new Matrix set from the starting index of the passed array.
  13966. */
  13967. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  13968. /**
  13969. * Sets the passed "result" matrix from the starting index of the passed array.
  13970. */
  13971. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  13972. /**
  13973. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  13974. */
  13975. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  13976. /**
  13977. * Sets the passed matrix "result" with the 16 passed floats.
  13978. */
  13979. 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;
  13980. /**
  13981. * Static identity matrix to be used as readonly matrix
  13982. * Must not be updated.
  13983. */
  13984. static readonly IdentityReadOnly: Matrix;
  13985. /**
  13986. * Returns a new Matrix set from the 16 passed floats.
  13987. */
  13988. 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;
  13989. /**
  13990. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  13991. */
  13992. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  13993. /**
  13994. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  13995. */
  13996. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  13997. /**
  13998. * Returns a new indentity Matrix.
  13999. */
  14000. static Identity(): Matrix;
  14001. /**
  14002. * Sets the passed "result" as an identity matrix.
  14003. */
  14004. static IdentityToRef(result: Matrix): void;
  14005. /**
  14006. * Returns a new zero Matrix.
  14007. */
  14008. static Zero(): Matrix;
  14009. /**
  14010. * Returns a new rotation matrix for "angle" radians around the X axis.
  14011. */
  14012. static RotationX(angle: number): Matrix;
  14013. /**
  14014. * Returns a new Matrix as the passed inverted one.
  14015. */
  14016. static Invert(source: Matrix): Matrix;
  14017. /**
  14018. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  14019. */
  14020. static RotationXToRef(angle: number, result: Matrix): void;
  14021. /**
  14022. * Returns a new rotation matrix for "angle" radians around the Y axis.
  14023. */
  14024. static RotationY(angle: number): Matrix;
  14025. /**
  14026. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  14027. */
  14028. static RotationYToRef(angle: number, result: Matrix): void;
  14029. /**
  14030. * Returns a new rotation matrix for "angle" radians around the Z axis.
  14031. */
  14032. static RotationZ(angle: number): Matrix;
  14033. /**
  14034. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  14035. */
  14036. static RotationZToRef(angle: number, result: Matrix): void;
  14037. /**
  14038. * Returns a new rotation matrix for "angle" radians around the passed axis.
  14039. */
  14040. static RotationAxis(axis: Vector3, angle: number): Matrix;
  14041. /**
  14042. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  14043. */
  14044. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  14045. /**
  14046. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  14047. */
  14048. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  14049. /**
  14050. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  14051. */
  14052. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  14053. /**
  14054. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  14055. */
  14056. static Scaling(x: number, y: number, z: number): Matrix;
  14057. /**
  14058. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  14059. */
  14060. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  14061. /**
  14062. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  14063. */
  14064. static Translation(x: number, y: number, z: number): Matrix;
  14065. /**
  14066. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  14067. */
  14068. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  14069. /**
  14070. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14071. * @param startValue defines the start value
  14072. * @param endValue defines the end value
  14073. * @param gradient defines the gradient factor
  14074. * @returns the new matrix
  14075. */
  14076. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14077. /**
  14078. * Set the passed matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14079. * @param startValue defines the start value
  14080. * @param endValue defines the end value
  14081. * @param gradient defines the gradient factor
  14082. * @param result defines the Matrix object where to store data
  14083. */
  14084. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14085. /**
  14086. * Returns a new Matrix whose values are computed by :
  14087. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  14088. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  14089. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  14090. */
  14091. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14092. /**
  14093. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  14094. * This methods works for a Left-Handed system.
  14095. */
  14096. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14097. /**
  14098. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  14099. * This methods works for a Left-Handed system.
  14100. */
  14101. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14102. /**
  14103. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  14104. * This methods works for a Right-Handed system.
  14105. */
  14106. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14107. /**
  14108. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  14109. * This methods works for a Left-Handed system.
  14110. */
  14111. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14112. /**
  14113. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  14114. */
  14115. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14116. /**
  14117. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  14118. */
  14119. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  14120. /**
  14121. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  14122. */
  14123. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14124. /**
  14125. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  14126. */
  14127. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14128. /**
  14129. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  14130. */
  14131. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14132. /**
  14133. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  14134. */
  14135. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14136. /**
  14137. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  14138. */
  14139. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14140. /**
  14141. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  14142. */
  14143. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14144. /**
  14145. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  14146. */
  14147. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14148. /**
  14149. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  14150. */
  14151. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14152. /**
  14153. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  14154. */
  14155. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14156. /**
  14157. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  14158. */
  14159. static PerspectiveFovWebVRToRef(fov: {
  14160. upDegrees: number;
  14161. downDegrees: number;
  14162. leftDegrees: number;
  14163. rightDegrees: number;
  14164. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  14165. /**
  14166. * Returns the final transformation matrix : world * view * projection * viewport
  14167. */
  14168. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  14169. /**
  14170. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  14171. */
  14172. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  14173. /**
  14174. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  14175. */
  14176. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  14177. /**
  14178. * Compute the transpose of the passed Matrix.
  14179. * Returns a new Matrix.
  14180. */
  14181. static Transpose(matrix: Matrix): Matrix;
  14182. /**
  14183. * Compute the transpose of the passed Matrix and store it in the result matrix.
  14184. */
  14185. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  14186. /**
  14187. * Returns a new Matrix as the reflection matrix across the passed plane.
  14188. */
  14189. static Reflection(plane: Plane): Matrix;
  14190. /**
  14191. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  14192. */
  14193. static ReflectionToRef(plane: Plane, result: Matrix): void;
  14194. /**
  14195. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  14196. */
  14197. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  14198. /**
  14199. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  14200. */
  14201. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  14202. }
  14203. class Plane {
  14204. normal: Vector3;
  14205. d: number;
  14206. /**
  14207. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  14208. */
  14209. constructor(a: number, b: number, c: number, d: number);
  14210. /**
  14211. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  14212. */
  14213. asArray(): number[];
  14214. /**
  14215. * Returns a new plane copied from the current Plane.
  14216. */
  14217. clone(): Plane;
  14218. /**
  14219. * Returns the string "Plane".
  14220. */
  14221. getClassName(): string;
  14222. /**
  14223. * Returns the Plane hash code.
  14224. */
  14225. getHashCode(): number;
  14226. /**
  14227. * Normalize the current Plane in place.
  14228. * Returns the updated Plane.
  14229. */
  14230. normalize(): Plane;
  14231. /**
  14232. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  14233. */
  14234. transform(transformation: Matrix): Plane;
  14235. /**
  14236. * Returns the dot product (float) of the point coordinates and the plane normal.
  14237. */
  14238. dotCoordinate(point: Vector3): number;
  14239. /**
  14240. * Updates the current Plane from the plane defined by the three passed points.
  14241. * Returns the updated Plane.
  14242. */
  14243. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14244. /**
  14245. * Boolean : True is the vector "direction" is the same side than the plane normal.
  14246. */
  14247. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  14248. /**
  14249. * Returns the signed distance (float) from the passed point to the Plane.
  14250. */
  14251. signedDistanceTo(point: Vector3): number;
  14252. /**
  14253. * Returns a new Plane from the passed array.
  14254. */
  14255. static FromArray(array: ArrayLike<number>): Plane;
  14256. /**
  14257. * Returns a new Plane defined by the three passed points.
  14258. */
  14259. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14260. /**
  14261. * Returns a new Plane the normal vector to this plane at the passed origin point.
  14262. * Note : the vector "normal" is updated because normalized.
  14263. */
  14264. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  14265. /**
  14266. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  14267. */
  14268. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  14269. }
  14270. class Viewport {
  14271. x: number;
  14272. y: number;
  14273. width: number;
  14274. height: number;
  14275. /**
  14276. * Creates a Viewport object located at (x, y) and sized (width, height).
  14277. */
  14278. constructor(x: number, y: number, width: number, height: number);
  14279. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  14280. /**
  14281. * Returns a new Viewport copied from the current one.
  14282. */
  14283. clone(): Viewport;
  14284. }
  14285. class Frustum {
  14286. /**
  14287. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  14288. */
  14289. static GetPlanes(transform: Matrix): Plane[];
  14290. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14291. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14292. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14293. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14294. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14295. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14296. /**
  14297. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  14298. */
  14299. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  14300. }
  14301. enum Space {
  14302. LOCAL = 0,
  14303. WORLD = 1,
  14304. BONE = 2,
  14305. }
  14306. class Axis {
  14307. static X: Vector3;
  14308. static Y: Vector3;
  14309. static Z: Vector3;
  14310. }
  14311. class BezierCurve {
  14312. /**
  14313. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  14314. */
  14315. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  14316. }
  14317. enum Orientation {
  14318. CW = 0,
  14319. CCW = 1,
  14320. }
  14321. class Angle {
  14322. private _radians;
  14323. /**
  14324. * Creates an Angle object of "radians" radians (float).
  14325. */
  14326. constructor(radians: number);
  14327. /**
  14328. * Returns the Angle value in degrees (float).
  14329. */
  14330. degrees: () => number;
  14331. /**
  14332. * Returns the Angle value in radians (float).
  14333. */
  14334. radians: () => number;
  14335. /**
  14336. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  14337. */
  14338. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  14339. /**
  14340. * Returns a new Angle object from the passed float in radians.
  14341. */
  14342. static FromRadians(radians: number): Angle;
  14343. /**
  14344. * Returns a new Angle object from the passed float in degrees.
  14345. */
  14346. static FromDegrees(degrees: number): Angle;
  14347. }
  14348. class Arc2 {
  14349. startPoint: Vector2;
  14350. midPoint: Vector2;
  14351. endPoint: Vector2;
  14352. centerPoint: Vector2;
  14353. radius: number;
  14354. angle: Angle;
  14355. startAngle: Angle;
  14356. orientation: Orientation;
  14357. /**
  14358. * Creates an Arc object from the three passed points : start, middle and end.
  14359. */
  14360. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  14361. }
  14362. class Path2 {
  14363. private _points;
  14364. private _length;
  14365. closed: boolean;
  14366. /**
  14367. * Creates a Path2 object from the starting 2D coordinates x and y.
  14368. */
  14369. constructor(x: number, y: number);
  14370. /**
  14371. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  14372. * Returns the updated Path2.
  14373. */
  14374. addLineTo(x: number, y: number): Path2;
  14375. /**
  14376. * 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.
  14377. * Returns the updated Path2.
  14378. */
  14379. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  14380. /**
  14381. * Closes the Path2.
  14382. * Returns the Path2.
  14383. */
  14384. close(): Path2;
  14385. /**
  14386. * Returns the Path2 total length (float).
  14387. */
  14388. length(): number;
  14389. /**
  14390. * Returns the Path2 internal array of points.
  14391. */
  14392. getPoints(): Vector2[];
  14393. /**
  14394. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  14395. */
  14396. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  14397. /**
  14398. * Returns a new Path2 starting at the coordinates (x, y).
  14399. */
  14400. static StartingAt(x: number, y: number): Path2;
  14401. }
  14402. class Path3D {
  14403. path: Vector3[];
  14404. private _curve;
  14405. private _distances;
  14406. private _tangents;
  14407. private _normals;
  14408. private _binormals;
  14409. private _raw;
  14410. /**
  14411. * new Path3D(path, normal, raw)
  14412. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  14413. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  14414. * path : an array of Vector3, the curve axis of the Path3D
  14415. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  14416. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  14417. */
  14418. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  14419. /**
  14420. * Returns the Path3D array of successive Vector3 designing its curve.
  14421. */
  14422. getCurve(): Vector3[];
  14423. /**
  14424. * Returns an array populated with tangent vectors on each Path3D curve point.
  14425. */
  14426. getTangents(): Vector3[];
  14427. /**
  14428. * Returns an array populated with normal vectors on each Path3D curve point.
  14429. */
  14430. getNormals(): Vector3[];
  14431. /**
  14432. * Returns an array populated with binormal vectors on each Path3D curve point.
  14433. */
  14434. getBinormals(): Vector3[];
  14435. /**
  14436. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  14437. */
  14438. getDistances(): number[];
  14439. /**
  14440. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  14441. * Returns the same object updated.
  14442. */
  14443. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  14444. private _compute(firstNormal);
  14445. private _getFirstNonNullVector(index);
  14446. private _getLastNonNullVector(index);
  14447. private _normalVector(v0, vt, va);
  14448. }
  14449. class Curve3 {
  14450. private _points;
  14451. private _length;
  14452. /**
  14453. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  14454. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  14455. * @param v1 (Vector3) the control point
  14456. * @param v2 (Vector3) the end point of the Quadratic Bezier
  14457. * @param nbPoints (integer) the wanted number of points in the curve
  14458. */
  14459. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  14460. /**
  14461. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  14462. * @param v0 (Vector3) the origin point of the Cubic Bezier
  14463. * @param v1 (Vector3) the first control point
  14464. * @param v2 (Vector3) the second control point
  14465. * @param v3 (Vector3) the end point of the Cubic Bezier
  14466. * @param nbPoints (integer) the wanted number of points in the curve
  14467. */
  14468. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  14469. /**
  14470. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  14471. * @param p1 (Vector3) the origin point of the Hermite Spline
  14472. * @param t1 (Vector3) the tangent vector at the origin point
  14473. * @param p2 (Vector3) the end point of the Hermite Spline
  14474. * @param t2 (Vector3) the tangent vector at the end point
  14475. * @param nbPoints (integer) the wanted number of points in the curve
  14476. */
  14477. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  14478. /**
  14479. * Returns a Curve3 object along a CatmullRom Spline curve :
  14480. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  14481. * @param nbPoints (integer) the wanted number of points between each curve control points.
  14482. */
  14483. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  14484. /**
  14485. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  14486. * A Curve3 is designed from a series of successive Vector3.
  14487. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  14488. */
  14489. constructor(points: Vector3[]);
  14490. /**
  14491. * Returns the Curve3 stored array of successive Vector3
  14492. */
  14493. getPoints(): Vector3[];
  14494. /**
  14495. * Returns the computed length (float) of the curve.
  14496. */
  14497. length(): number;
  14498. /**
  14499. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  14500. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  14501. * curveA and curveB keep unchanged.
  14502. */
  14503. continue(curve: Curve3): Curve3;
  14504. private _computeLength(path);
  14505. }
  14506. class PositionNormalVertex {
  14507. position: Vector3;
  14508. normal: Vector3;
  14509. constructor(position?: Vector3, normal?: Vector3);
  14510. clone(): PositionNormalVertex;
  14511. }
  14512. class PositionNormalTextureVertex {
  14513. position: Vector3;
  14514. normal: Vector3;
  14515. uv: Vector2;
  14516. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  14517. clone(): PositionNormalTextureVertex;
  14518. }
  14519. class Tmp {
  14520. static Color3: Color3[];
  14521. static Vector2: Vector2[];
  14522. static Vector3: Vector3[];
  14523. static Vector4: Vector4[];
  14524. static Quaternion: Quaternion[];
  14525. static Matrix: Matrix[];
  14526. }
  14527. }
  14528. declare module BABYLON {
  14529. class SphericalPolynomial {
  14530. x: Vector3;
  14531. y: Vector3;
  14532. z: Vector3;
  14533. xx: Vector3;
  14534. yy: Vector3;
  14535. zz: Vector3;
  14536. xy: Vector3;
  14537. yz: Vector3;
  14538. zx: Vector3;
  14539. addAmbient(color: Color3): void;
  14540. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  14541. scale(scale: number): void;
  14542. }
  14543. class SphericalHarmonics {
  14544. L00: Vector3;
  14545. L1_1: Vector3;
  14546. L10: Vector3;
  14547. L11: Vector3;
  14548. L2_2: Vector3;
  14549. L2_1: Vector3;
  14550. L20: Vector3;
  14551. L21: Vector3;
  14552. L22: Vector3;
  14553. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  14554. scale(scale: number): void;
  14555. convertIncidentRadianceToIrradiance(): void;
  14556. convertIrradianceToLambertianRadiance(): void;
  14557. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  14558. }
  14559. }
  14560. declare module BABYLON {
  14561. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  14562. static OCCLUSION_TYPE_NONE: number;
  14563. static OCCLUSION_TYPE_OPTIMISTIC: number;
  14564. static OCCLUSION_TYPE_STRICT: number;
  14565. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  14566. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  14567. static readonly BILLBOARDMODE_NONE: number;
  14568. static readonly BILLBOARDMODE_X: number;
  14569. static readonly BILLBOARDMODE_Y: number;
  14570. static readonly BILLBOARDMODE_Z: number;
  14571. static readonly BILLBOARDMODE_ALL: number;
  14572. private _facetPositions;
  14573. private _facetNormals;
  14574. private _facetPartitioning;
  14575. private _facetNb;
  14576. private _partitioningSubdivisions;
  14577. private _partitioningBBoxRatio;
  14578. private _facetDataEnabled;
  14579. private _facetParameters;
  14580. private _bbSize;
  14581. private _subDiv;
  14582. private _facetDepthSort;
  14583. private _facetDepthSortEnabled;
  14584. private _depthSortedIndices;
  14585. private _depthSortedFacets;
  14586. private _facetDepthSortFunction;
  14587. private _facetDepthSortFrom;
  14588. private _facetDepthSortOrigin;
  14589. private _invertedMatrix;
  14590. /**
  14591. * Read-only : the number of facets in the mesh
  14592. */
  14593. readonly facetNb: number;
  14594. /**
  14595. * The number (integer) of subdivisions per axis in the partioning space
  14596. */
  14597. partitioningSubdivisions: number;
  14598. /**
  14599. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  14600. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  14601. */
  14602. partitioningBBoxRatio: number;
  14603. /**
  14604. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  14605. * Works only for updatable meshes.
  14606. * Doesn't work with multi-materials.
  14607. */
  14608. mustDepthSortFacets: boolean;
  14609. /**
  14610. * The location (Vector3) where the facet depth sort must be computed from.
  14611. * By default, the active camera position.
  14612. * Used only when facet depth sort is enabled.
  14613. */
  14614. facetDepthSortFrom: Vector3;
  14615. /**
  14616. * Read-only boolean : is the feature facetData enabled ?
  14617. */
  14618. readonly isFacetDataEnabled: boolean;
  14619. _updateNonUniformScalingState(value: boolean): boolean;
  14620. /**
  14621. * An event triggered when this mesh collides with another one
  14622. */
  14623. onCollideObservable: Observable<AbstractMesh>;
  14624. private _onCollideObserver;
  14625. onCollide: () => void;
  14626. /**
  14627. * An event triggered when the collision's position changes
  14628. */
  14629. onCollisionPositionChangeObservable: Observable<Vector3>;
  14630. private _onCollisionPositionChangeObserver;
  14631. onCollisionPositionChange: () => void;
  14632. /**
  14633. * An event triggered when material is changed
  14634. */
  14635. onMaterialChangedObservable: Observable<AbstractMesh>;
  14636. definedFacingForward: boolean;
  14637. /**
  14638. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  14639. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  14640. * or
  14641. * 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.
  14642. * for more info check WebGl documentations
  14643. */
  14644. occlusionQueryAlgorithmType: number;
  14645. /**
  14646. * 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:
  14647. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  14648. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  14649. * 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.
  14650. */
  14651. occlusionType: number;
  14652. /**
  14653. * 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.
  14654. * The default value is -1 which means don't break the query and wait till the result.
  14655. */
  14656. occlusionRetryCount: number;
  14657. private _occlusionInternalRetryCounter;
  14658. protected _isOccluded: boolean;
  14659. /**
  14660. * Property isOccluded : 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.
  14661. */
  14662. isOccluded: boolean;
  14663. private _isOcclusionQueryInProgress;
  14664. /**
  14665. * Flag to check the progress status of the query
  14666. */
  14667. readonly isOcclusionQueryInProgress: boolean;
  14668. private _occlusionQuery;
  14669. private _visibility;
  14670. /**
  14671. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  14672. */
  14673. /**
  14674. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  14675. */
  14676. visibility: number;
  14677. alphaIndex: number;
  14678. isVisible: boolean;
  14679. isPickable: boolean;
  14680. showBoundingBox: boolean;
  14681. showSubMeshesBoundingBox: boolean;
  14682. isBlocker: boolean;
  14683. enablePointerMoveEvents: boolean;
  14684. renderingGroupId: number;
  14685. private _material;
  14686. material: Nullable<Material>;
  14687. private _receiveShadows;
  14688. receiveShadows: boolean;
  14689. renderOutline: boolean;
  14690. outlineColor: Color3;
  14691. outlineWidth: number;
  14692. renderOverlay: boolean;
  14693. overlayColor: Color3;
  14694. overlayAlpha: number;
  14695. private _hasVertexAlpha;
  14696. hasVertexAlpha: boolean;
  14697. private _useVertexColors;
  14698. useVertexColors: boolean;
  14699. private _computeBonesUsingShaders;
  14700. computeBonesUsingShaders: boolean;
  14701. private _numBoneInfluencers;
  14702. numBoneInfluencers: number;
  14703. private _applyFog;
  14704. applyFog: boolean;
  14705. useOctreeForRenderingSelection: boolean;
  14706. useOctreeForPicking: boolean;
  14707. useOctreeForCollisions: boolean;
  14708. private _layerMask;
  14709. layerMask: number;
  14710. /**
  14711. * True if the mesh must be rendered in any case.
  14712. */
  14713. alwaysSelectAsActiveMesh: boolean;
  14714. /**
  14715. * This scene's action manager
  14716. */
  14717. actionManager: Nullable<ActionManager>;
  14718. physicsImpostor: Nullable<PhysicsImpostor>;
  14719. private _checkCollisions;
  14720. private _collisionMask;
  14721. private _collisionGroup;
  14722. ellipsoid: Vector3;
  14723. ellipsoidOffset: Vector3;
  14724. private _collider;
  14725. private _oldPositionForCollisions;
  14726. private _diffPositionForCollisions;
  14727. collisionMask: number;
  14728. collisionGroup: number;
  14729. edgesWidth: number;
  14730. edgesColor: Color4;
  14731. _edgesRenderer: Nullable<EdgesRenderer>;
  14732. private _collisionsTransformMatrix;
  14733. private _collisionsScalingMatrix;
  14734. _masterMesh: Nullable<AbstractMesh>;
  14735. _boundingInfo: Nullable<BoundingInfo>;
  14736. _renderId: number;
  14737. subMeshes: SubMesh[];
  14738. _submeshesOctree: Octree<SubMesh>;
  14739. _intersectionsInProgress: AbstractMesh[];
  14740. _unIndexed: boolean;
  14741. _lightSources: Light[];
  14742. readonly _positions: Nullable<Vector3[]>;
  14743. _waitingActions: any;
  14744. _waitingFreezeWorldMatrix: Nullable<boolean>;
  14745. private _skeleton;
  14746. _bonesTransformMatrices: Nullable<Float32Array>;
  14747. skeleton: Nullable<Skeleton>;
  14748. constructor(name: string, scene?: Nullable<Scene>);
  14749. /**
  14750. * Returns the string "AbstractMesh"
  14751. */
  14752. getClassName(): string;
  14753. /**
  14754. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  14755. */
  14756. toString(fullDetails?: boolean): string;
  14757. _rebuild(): void;
  14758. _resyncLightSources(): void;
  14759. _resyncLighSource(light: Light): void;
  14760. _removeLightSource(light: Light): void;
  14761. private _markSubMeshesAsDirty(func);
  14762. _markSubMeshesAsLightDirty(): void;
  14763. _markSubMeshesAsAttributesDirty(): void;
  14764. _markSubMeshesAsMiscDirty(): void;
  14765. /**
  14766. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  14767. * Default : (1.0, 1.0, 1.0)
  14768. */
  14769. /**
  14770. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  14771. * Default : (1.0, 1.0, 1.0)
  14772. */
  14773. scaling: Vector3;
  14774. /**
  14775. * Disables the mesh edger rendering mode.
  14776. * Returns the AbstractMesh.
  14777. */
  14778. disableEdgesRendering(): AbstractMesh;
  14779. /**
  14780. * Enables the edge rendering mode on the mesh.
  14781. * This mode makes the mesh edges visible.
  14782. * Returns the AbstractMesh.
  14783. */
  14784. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  14785. /**
  14786. * Returns true if the mesh is blocked. Used by the class Mesh.
  14787. * Returns the boolean `false` by default.
  14788. */
  14789. readonly isBlocked: boolean;
  14790. /**
  14791. * Returns the mesh itself by default, used by the class Mesh.
  14792. * Returned type : AbstractMesh
  14793. */
  14794. getLOD(camera: Camera): AbstractMesh;
  14795. /**
  14796. * Returns 0 by default, used by the class Mesh.
  14797. * Returns an integer.
  14798. */
  14799. getTotalVertices(): number;
  14800. /**
  14801. * Returns null by default, used by the class Mesh.
  14802. * Returned type : integer array
  14803. */
  14804. getIndices(): Nullable<IndicesArray>;
  14805. /**
  14806. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  14807. * Returned type : float array or Float32Array
  14808. */
  14809. getVerticesData(kind: string): Nullable<FloatArray>;
  14810. /**
  14811. * Sets the vertex data of the mesh geometry for the requested `kind`.
  14812. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  14813. * The `data` are either a numeric array either a Float32Array.
  14814. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  14815. * 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).
  14816. * Note that a new underlying VertexBuffer object is created each call.
  14817. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14818. *
  14819. * Possible `kind` values :
  14820. * - BABYLON.VertexBuffer.PositionKind
  14821. * - BABYLON.VertexBuffer.UVKind
  14822. * - BABYLON.VertexBuffer.UV2Kind
  14823. * - BABYLON.VertexBuffer.UV3Kind
  14824. * - BABYLON.VertexBuffer.UV4Kind
  14825. * - BABYLON.VertexBuffer.UV5Kind
  14826. * - BABYLON.VertexBuffer.UV6Kind
  14827. * - BABYLON.VertexBuffer.ColorKind
  14828. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14829. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14830. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14831. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14832. *
  14833. * Returns the Mesh.
  14834. */
  14835. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  14836. /**
  14837. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  14838. * If the mesh has no geometry, it is simply returned as it is.
  14839. * The `data` are either a numeric array either a Float32Array.
  14840. * No new underlying VertexBuffer object is created.
  14841. * 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.
  14842. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  14843. *
  14844. * Possible `kind` values :
  14845. * - BABYLON.VertexBuffer.PositionKind
  14846. * - BABYLON.VertexBuffer.UVKind
  14847. * - BABYLON.VertexBuffer.UV2Kind
  14848. * - BABYLON.VertexBuffer.UV3Kind
  14849. * - BABYLON.VertexBuffer.UV4Kind
  14850. * - BABYLON.VertexBuffer.UV5Kind
  14851. * - BABYLON.VertexBuffer.UV6Kind
  14852. * - BABYLON.VertexBuffer.ColorKind
  14853. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14854. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14855. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14856. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14857. *
  14858. * Returns the Mesh.
  14859. */
  14860. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  14861. /**
  14862. * Sets the mesh indices.
  14863. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  14864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  14865. * This method creates a new index buffer each call.
  14866. * Returns the Mesh.
  14867. */
  14868. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  14869. /** Returns false by default, used by the class Mesh.
  14870. * Returns a boolean
  14871. */
  14872. isVerticesDataPresent(kind: string): boolean;
  14873. /**
  14874. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  14875. * Returns a BoundingInfo
  14876. */
  14877. getBoundingInfo(): BoundingInfo;
  14878. /**
  14879. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  14880. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  14881. */
  14882. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  14883. /**
  14884. * Sets a mesh new object BoundingInfo.
  14885. * Returns the AbstractMesh.
  14886. */
  14887. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  14888. readonly useBones: boolean;
  14889. _preActivate(): void;
  14890. _preActivateForIntermediateRendering(renderId: number): void;
  14891. _activate(renderId: number): void;
  14892. /**
  14893. * Returns the latest update of the World matrix
  14894. * Returns a Matrix.
  14895. */
  14896. getWorldMatrix(): Matrix;
  14897. /**
  14898. * Returns the latest update of the World matrix determinant.
  14899. */
  14900. protected _getWorldMatrixDeterminant(): number;
  14901. /**
  14902. * Perform relative position change from the point of view of behind the front of the mesh.
  14903. * This is performed taking into account the meshes current rotation, so you do not have to care.
  14904. * Supports definition of mesh facing forward or backward.
  14905. * @param {number} amountRight
  14906. * @param {number} amountUp
  14907. * @param {number} amountForward
  14908. *
  14909. * Returns the AbstractMesh.
  14910. */
  14911. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  14912. /**
  14913. * Calculate relative position change from the point of view of behind the front of the mesh.
  14914. * This is performed taking into account the meshes current rotation, so you do not have to care.
  14915. * Supports definition of mesh facing forward or backward.
  14916. * @param {number} amountRight
  14917. * @param {number} amountUp
  14918. * @param {number} amountForward
  14919. *
  14920. * Returns a new Vector3.
  14921. */
  14922. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  14923. /**
  14924. * Perform relative rotation change from the point of view of behind the front of the mesh.
  14925. * Supports definition of mesh facing forward or backward.
  14926. * @param {number} flipBack
  14927. * @param {number} twirlClockwise
  14928. * @param {number} tiltRight
  14929. *
  14930. * Returns the AbstractMesh.
  14931. */
  14932. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  14933. /**
  14934. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  14935. * Supports definition of mesh facing forward or backward.
  14936. * @param {number} flipBack
  14937. * @param {number} twirlClockwise
  14938. * @param {number} tiltRight
  14939. *
  14940. * Returns a new Vector3.
  14941. */
  14942. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  14943. /**
  14944. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  14945. * @param includeDescendants Include bounding info from descendants as well (true by default).
  14946. */
  14947. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  14948. min: Vector3;
  14949. max: Vector3;
  14950. };
  14951. /**
  14952. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  14953. * Returns the AbstractMesh.
  14954. */
  14955. _updateBoundingInfo(): AbstractMesh;
  14956. /**
  14957. * Update a mesh's children BoundingInfo objects only.
  14958. * Returns the AbstractMesh.
  14959. */
  14960. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  14961. protected _afterComputeWorldMatrix(): void;
  14962. /**
  14963. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14964. * A mesh is in the frustum if its bounding box intersects the frustum.
  14965. * Boolean returned.
  14966. */
  14967. isInFrustum(frustumPlanes: Plane[]): boolean;
  14968. /**
  14969. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  14970. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  14971. * Boolean returned.
  14972. */
  14973. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  14974. /**
  14975. * True if the mesh intersects another mesh or a SolidParticle object.
  14976. * 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)
  14977. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  14978. * Returns a boolean.
  14979. */
  14980. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  14981. /**
  14982. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  14983. * Returns a boolean.
  14984. */
  14985. intersectsPoint(point: Vector3): boolean;
  14986. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  14987. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14988. /**
  14989. * Returns the distance from the mesh to the active camera.
  14990. * Returns a float.
  14991. */
  14992. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14993. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  14994. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  14995. /**
  14996. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  14997. * Default `false`.
  14998. */
  14999. checkCollisions: boolean;
  15000. /**
  15001. * Gets Collider object used to compute collisions (not physics)
  15002. */
  15003. readonly collider: Collider;
  15004. moveWithCollisions(displacement: Vector3): AbstractMesh;
  15005. private _onCollisionPositionChange;
  15006. /**
  15007. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  15008. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  15009. * Returns an Octree of submeshes.
  15010. */
  15011. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  15012. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  15013. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  15014. _checkCollision(collider: Collider): AbstractMesh;
  15015. _generatePointsArray(): boolean;
  15016. /**
  15017. * Checks if the passed Ray intersects with the mesh.
  15018. * Returns an object PickingInfo.
  15019. */
  15020. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  15021. /**
  15022. * Clones the mesh, used by the class Mesh.
  15023. * Just returns `null` for an AbstractMesh.
  15024. */
  15025. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  15026. /**
  15027. * Disposes all the mesh submeshes.
  15028. * Returns the AbstractMesh.
  15029. */
  15030. releaseSubMeshes(): AbstractMesh;
  15031. /**
  15032. * Releases resources associated with this abstract mesh.
  15033. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15034. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15035. */
  15036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15037. /**
  15038. * Adds the passed mesh as a child to the current mesh.
  15039. * Returns the AbstractMesh.
  15040. */
  15041. addChild(mesh: AbstractMesh): AbstractMesh;
  15042. /**
  15043. * Removes the passed mesh from the current mesh children list.
  15044. * Returns the AbstractMesh.
  15045. */
  15046. removeChild(mesh: AbstractMesh): AbstractMesh;
  15047. /**
  15048. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  15049. * Returns the AbstractMesh.
  15050. */
  15051. private _initFacetData();
  15052. /**
  15053. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  15054. * This method can be called within the render loop.
  15055. * 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.
  15056. * Returns the AbstractMesh.
  15057. */
  15058. updateFacetData(): AbstractMesh;
  15059. /**
  15060. * Returns the facetLocalNormals array.
  15061. * The normals are expressed in the mesh local space.
  15062. */
  15063. getFacetLocalNormals(): Vector3[];
  15064. /**
  15065. * Returns the facetLocalPositions array.
  15066. * The facet positions are expressed in the mesh local space.
  15067. */
  15068. getFacetLocalPositions(): Vector3[];
  15069. /**
  15070. * Returns the facetLocalPartioning array.
  15071. */
  15072. getFacetLocalPartitioning(): number[][];
  15073. /**
  15074. * Returns the i-th facet position in the world system.
  15075. * This method allocates a new Vector3 per call.
  15076. */
  15077. getFacetPosition(i: number): Vector3;
  15078. /**
  15079. * Sets the reference Vector3 with the i-th facet position in the world system.
  15080. * Returns the AbstractMesh.
  15081. */
  15082. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  15083. /**
  15084. * Returns the i-th facet normal in the world system.
  15085. * This method allocates a new Vector3 per call.
  15086. */
  15087. getFacetNormal(i: number): Vector3;
  15088. /**
  15089. * Sets the reference Vector3 with the i-th facet normal in the world system.
  15090. * Returns the AbstractMesh.
  15091. */
  15092. getFacetNormalToRef(i: number, ref: Vector3): this;
  15093. /**
  15094. * 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).
  15095. */
  15096. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  15097. /**
  15098. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  15099. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  15100. * If checkFace is 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.
  15101. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  15102. * 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.
  15103. */
  15104. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  15105. /**
  15106. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  15107. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  15108. * If checkFace is 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.
  15109. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  15110. * 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.
  15111. */
  15112. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  15113. /**
  15114. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  15115. */
  15116. getFacetDataParameters(): any;
  15117. /**
  15118. * Disables the feature FacetData and frees the related memory.
  15119. * Returns the AbstractMesh.
  15120. */
  15121. disableFacetData(): AbstractMesh;
  15122. /**
  15123. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  15124. * Returns the mesh.
  15125. */
  15126. updateIndices(indices: IndicesArray): AbstractMesh;
  15127. /**
  15128. * The mesh Geometry. Actually used by the Mesh object.
  15129. * Returns a blank geometry object.
  15130. */
  15131. /**
  15132. * Creates new normals data for the mesh.
  15133. * @param updatable.
  15134. */
  15135. createNormals(updatable: boolean): void;
  15136. /**
  15137. * Align the mesh with a normal.
  15138. * Returns the mesh.
  15139. */
  15140. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  15141. protected checkOcclusionQuery(): void;
  15142. }
  15143. }
  15144. declare module BABYLON {
  15145. class Buffer {
  15146. private _engine;
  15147. private _buffer;
  15148. private _data;
  15149. private _updatable;
  15150. private _instanced;
  15151. /**
  15152. * Gets the byte stride.
  15153. */
  15154. readonly byteStride: number;
  15155. /**
  15156. * Constructor
  15157. * @param engine the engine
  15158. * @param data the data to use for this buffer
  15159. * @param updatable whether the data is updatable
  15160. * @param stride the stride (optional)
  15161. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  15162. * @param instanced whether the buffer is instanced (optional)
  15163. * @param useBytes set to true if the stride in in bytes (optional)
  15164. */
  15165. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  15166. /**
  15167. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  15168. * @param kind defines the vertex buffer kind (position, normal, etc.)
  15169. * @param offset defines offset in the buffer (0 by default)
  15170. * @param size defines the size in floats of attributes (position is 3 for instance)
  15171. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  15172. * @param instanced defines if the vertex buffer contains indexed data
  15173. * @param useBytes defines if the offset and stride are in bytes
  15174. * @returns the new vertex buffer
  15175. */
  15176. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  15177. isUpdatable(): boolean;
  15178. getData(): Nullable<DataArray>;
  15179. getBuffer(): Nullable<WebGLBuffer>;
  15180. /**
  15181. * Gets the stride in float32 units (i.e. byte stride / 4).
  15182. * May not be an integer if the byte stride is not divisible by 4.
  15183. * DEPRECATED. Use byteStride instead.
  15184. * @returns the stride in float32 units
  15185. */
  15186. getStrideSize(): number;
  15187. create(data?: Nullable<DataArray>): void;
  15188. _rebuild(): void;
  15189. update(data: DataArray): void;
  15190. /**
  15191. * Updates the data directly.
  15192. * @param data the new data
  15193. * @param offset the new offset
  15194. * @param vertexCount the vertex count (optional)
  15195. * @param useBytes set to true if the offset is in bytes
  15196. */
  15197. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  15198. dispose(): void;
  15199. }
  15200. }
  15201. declare module BABYLON {
  15202. class CSG {
  15203. private polygons;
  15204. matrix: Matrix;
  15205. position: Vector3;
  15206. rotation: Vector3;
  15207. rotationQuaternion: Nullable<Quaternion>;
  15208. scaling: Vector3;
  15209. static FromMesh(mesh: Mesh): CSG;
  15210. private static FromPolygons(polygons);
  15211. clone(): CSG;
  15212. union(csg: CSG): CSG;
  15213. unionInPlace(csg: CSG): void;
  15214. subtract(csg: CSG): CSG;
  15215. subtractInPlace(csg: CSG): void;
  15216. intersect(csg: CSG): CSG;
  15217. intersectInPlace(csg: CSG): void;
  15218. inverse(): CSG;
  15219. inverseInPlace(): void;
  15220. copyTransformAttributes(csg: CSG): CSG;
  15221. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  15222. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  15223. }
  15224. }
  15225. declare module BABYLON {
  15226. /**
  15227. * Class used to store geometry data (vertex buffers + index buffer)
  15228. */
  15229. class Geometry implements IGetSetVerticesData {
  15230. /**
  15231. * Gets or sets the unique ID of the geometry
  15232. */
  15233. id: string;
  15234. /**
  15235. * Gets the delay loading state of the geometry (none by default which means not delayed)
  15236. */
  15237. delayLoadState: number;
  15238. /**
  15239. * Gets the file containing the data to load when running in delay load state
  15240. */
  15241. delayLoadingFile: Nullable<string>;
  15242. /**
  15243. * Callback called when the geometry is updated
  15244. */
  15245. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  15246. private _scene;
  15247. private _engine;
  15248. private _meshes;
  15249. private _totalVertices;
  15250. private _indices;
  15251. private _vertexBuffers;
  15252. private _isDisposed;
  15253. private _extend;
  15254. private _boundingBias;
  15255. /** @ignore */
  15256. _delayInfo: Array<string>;
  15257. private _indexBuffer;
  15258. private _indexBufferIsUpdatable;
  15259. /** @ignore */
  15260. _boundingInfo: Nullable<BoundingInfo>;
  15261. /** @ignore */
  15262. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  15263. /** @ignore */
  15264. _softwareSkinningRenderId: number;
  15265. private _vertexArrayObjects;
  15266. private _updatable;
  15267. /** @ignore */
  15268. _positions: Nullable<Vector3[]>;
  15269. /**
  15270. * 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
  15271. */
  15272. /**
  15273. * 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
  15274. */
  15275. boundingBias: Vector2;
  15276. /**
  15277. * Static function used to attach a new empty geometry to a mesh
  15278. * @param mesh defines the mesh to attach the geometry to
  15279. * @returns the new {BABYLON.Geometry}
  15280. */
  15281. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  15282. /**
  15283. * Creates a new geometry
  15284. * @param id defines the unique ID
  15285. * @param scene defines the hosting scene
  15286. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  15287. * @param updatable defines if geometry must be updatable (false by default)
  15288. * @param mesh defines the mesh that will be associated with the geometry
  15289. */
  15290. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  15291. /**
  15292. * Gets the current extend of the geometry
  15293. */
  15294. readonly extend: {
  15295. minimum: Vector3;
  15296. maximum: Vector3;
  15297. };
  15298. /**
  15299. * Gets the hosting scene
  15300. * @returns the hosting {BABYLON.Scene}
  15301. */
  15302. getScene(): Scene;
  15303. /**
  15304. * Gets the hosting engine
  15305. * @returns the hosting {BABYLON.Engine}
  15306. */
  15307. getEngine(): Engine;
  15308. /**
  15309. * Defines if the geometry is ready to use
  15310. * @returns true if the geometry is ready to be used
  15311. */
  15312. isReady(): boolean;
  15313. /**
  15314. * Gets a value indicating that the geometry should not be serialized
  15315. */
  15316. readonly doNotSerialize: boolean;
  15317. /** @ignore */
  15318. _rebuild(): void;
  15319. /**
  15320. * Affects all gemetry data in one call
  15321. * @param vertexData defines the geometry data
  15322. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  15323. */
  15324. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  15325. /**
  15326. * Set specific vertex data
  15327. * @param kind defines the data kind (Position, normal, etc...)
  15328. * @param data defines the vertex data to use
  15329. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  15330. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  15331. */
  15332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  15333. /**
  15334. * Removes a specific vertex data
  15335. * @param kind defines the data kind (Position, normal, etc...)
  15336. */
  15337. removeVerticesData(kind: string): void;
  15338. /**
  15339. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  15340. * @param buffer defines the vertex buffer to use
  15341. * @param totalVertices defines the total number of vertices for position kind (could be null)
  15342. */
  15343. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  15344. /**
  15345. * Update a specific vertex buffer
  15346. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  15347. * It will do nothing if the buffer is not updatable
  15348. * @param kind defines the data kind (Position, normal, etc...)
  15349. * @param data defines the data to use
  15350. * @param offset defines the offset in the target buffer where to store the data
  15351. */
  15352. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  15353. /**
  15354. * Update a specific vertex buffer
  15355. * This function will create a new buffer if the current one is not updatable
  15356. * @param kind defines the data kind (Position, normal, etc...)
  15357. * @param data defines the data to use
  15358. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  15359. */
  15360. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  15361. private _updateBoundingInfo(updateExtends, data);
  15362. /** @ignore */
  15363. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  15364. /**
  15365. * Gets total number of vertices
  15366. * @returns the total number of vertices
  15367. */
  15368. getTotalVertices(): number;
  15369. /**
  15370. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  15371. * @param kind defines the data kind (Position, normal, etc...)
  15372. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  15373. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  15374. * @returns a float array containing vertex data
  15375. */
  15376. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15377. /**
  15378. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  15379. * @param kind defines the data kind (Position, normal, etc...)
  15380. * @returns true if the vertex buffer with the specified kind is updatable
  15381. */
  15382. isVertexBufferUpdatable(kind: string): boolean;
  15383. /**
  15384. * Gets a specific vertex buffer
  15385. * @param kind defines the data kind (Position, normal, etc...)
  15386. * @returns a {BABYLON.VertexBuffer}
  15387. */
  15388. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  15389. /**
  15390. * Returns all vertex buffers
  15391. * @return an object holding all vertex buffers indexed by kind
  15392. */
  15393. getVertexBuffers(): Nullable<{
  15394. [key: string]: VertexBuffer;
  15395. }>;
  15396. /**
  15397. * Gets a boolean indicating if specific vertex buffer is present
  15398. * @param kind defines the data kind (Position, normal, etc...)
  15399. * @returns true if data is present
  15400. */
  15401. isVerticesDataPresent(kind: string): boolean;
  15402. /**
  15403. * Gets a list of all attached data kinds (Position, normal, etc...)
  15404. * @returns a list of string containing all kinds
  15405. */
  15406. getVerticesDataKinds(): string[];
  15407. /**
  15408. * Update index buffer
  15409. * @param indices defines the indices to store in the index buffer
  15410. * @param offset defines the offset in the target buffer where to store the data
  15411. */
  15412. updateIndices(indices: IndicesArray, offset?: number): void;
  15413. /**
  15414. * Creates a new index buffer
  15415. * @param indices defines the indices to store in the index buffer
  15416. * @param totalVertices defines the total number of vertices (could be null)
  15417. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  15418. */
  15419. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  15420. /**
  15421. * Return the total number of indices
  15422. * @returns the total number of indices
  15423. */
  15424. getTotalIndices(): number;
  15425. /**
  15426. * Gets the index buffer array
  15427. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  15428. * @returns the index buffer array
  15429. */
  15430. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  15431. /**
  15432. * Gets the index buffer
  15433. * @return the index buffer
  15434. */
  15435. getIndexBuffer(): Nullable<WebGLBuffer>;
  15436. /** @ignore */
  15437. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  15438. /**
  15439. * Release the associated resources for a specific mesh
  15440. * @param mesh defines the source mesh
  15441. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  15442. */
  15443. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  15444. /**
  15445. * Apply current geometry to a given mesh
  15446. * @param mesh defines the mesh to apply geometry to
  15447. */
  15448. applyToMesh(mesh: Mesh): void;
  15449. private _updateExtend(data?);
  15450. private _applyToMesh(mesh);
  15451. private notifyUpdate(kind?);
  15452. /**
  15453. * Load the geometry if it was flagged as delay loaded
  15454. * @param scene defines the hosting scene
  15455. * @param onLoaded defines a callback called when the geometry is loaded
  15456. */
  15457. load(scene: Scene, onLoaded?: () => void): void;
  15458. private _queueLoad(scene, onLoaded?);
  15459. /**
  15460. * Invert the geometry to move from a right handed system to a left handed one.
  15461. */
  15462. toLeftHanded(): void;
  15463. /** @ignore */
  15464. _resetPointsArrayCache(): void;
  15465. /** @ignore */
  15466. _generatePointsArray(): boolean;
  15467. /**
  15468. * Gets a value indicating if the geometry is disposed
  15469. * @returns true if the geometry was disposed
  15470. */
  15471. isDisposed(): boolean;
  15472. private _disposeVertexArrayObjects();
  15473. /**
  15474. * Free all associated resources
  15475. */
  15476. dispose(): void;
  15477. /**
  15478. * Clone the current geometry into a new geometry
  15479. * @param id defines the unique ID of the new geometry
  15480. * @returns a new geometry object
  15481. */
  15482. copy(id: string): Geometry;
  15483. /**
  15484. * Serialize the current geometry info (and not the vertices data) into a JSON object
  15485. * @return a JSON representation of the current geometry data (without the vertices data)
  15486. */
  15487. serialize(): any;
  15488. private toNumberArray(origin);
  15489. /**
  15490. * Serialize all vertices data into a JSON oject
  15491. * @returns a JSON representation of the current geometry data
  15492. */
  15493. serializeVerticeData(): any;
  15494. /**
  15495. * Extracts a clone of a mesh geometry
  15496. * @param mesh defines the source mesh
  15497. * @param id defines the unique ID of the new geometry object
  15498. * @returns the new geometry object
  15499. */
  15500. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  15501. /**
  15502. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  15503. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  15504. * Be aware Math.random() could cause collisions, but:
  15505. * "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"
  15506. * @returns a string containing a new GUID
  15507. */
  15508. static RandomId(): string;
  15509. /** @ignore */
  15510. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  15511. private static _CleanMatricesWeights(parsedGeometry, mesh);
  15512. /**
  15513. * Create a new geometry from persisted data (Using .babylon file format)
  15514. * @param parsedVertexData defines the persisted data
  15515. * @param scene defines the hosting scene
  15516. * @param rootUrl defines the root url to use to load assets (like delayed data)
  15517. * @returns the new geometry object
  15518. */
  15519. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  15520. }
  15521. /**
  15522. * Abstract class used to provide common services for all typed geometries
  15523. */
  15524. class _PrimitiveGeometry extends Geometry {
  15525. private _canBeRegenerated;
  15526. private _beingRegenerated;
  15527. /**
  15528. * Creates a new typed geometry
  15529. * @param id defines the unique ID of the geometry
  15530. * @param scene defines the hosting scene
  15531. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15532. * @param mesh defines the hosting mesh (can be null)
  15533. */
  15534. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  15535. /**
  15536. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  15537. * @returns true if the geometry can be regenerated
  15538. */
  15539. canBeRegenerated(): boolean;
  15540. /**
  15541. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  15542. */
  15543. regenerate(): void;
  15544. /**
  15545. * Clone the geometry
  15546. * @param id defines the unique ID of the new geometry
  15547. * @returns the new geometry
  15548. */
  15549. asNewGeometry(id: string): Geometry;
  15550. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  15551. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  15552. /** @ignore */
  15553. _regenerateVertexData(): VertexData;
  15554. copy(id: string): Geometry;
  15555. serialize(): any;
  15556. }
  15557. /**
  15558. * Creates a ribbon geometry
  15559. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  15560. */
  15561. class RibbonGeometry extends _PrimitiveGeometry {
  15562. /**
  15563. * Defines the array of paths to use
  15564. */
  15565. pathArray: Vector3[][];
  15566. /**
  15567. * Defines if the last and first points of each path in your pathArray must be joined
  15568. */
  15569. closeArray: boolean;
  15570. /**
  15571. * Defines if the last and first points of each path in your pathArray must be joined
  15572. */
  15573. closePath: boolean;
  15574. /**
  15575. * Defines the offset between points
  15576. */
  15577. offset: number;
  15578. /**
  15579. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15580. */
  15581. side: number;
  15582. /**
  15583. * Creates a ribbon geometry
  15584. * @param id defines the unique ID of the geometry
  15585. * @param scene defines the hosting scene
  15586. * @param pathArray defines the array of paths to use
  15587. * @param closeArray defines if the last path and the first path must be joined
  15588. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  15589. * @param offset defines the offset between points
  15590. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15591. * @param mesh defines the hosting mesh (can be null)
  15592. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15593. */
  15594. constructor(id: string, scene: Scene,
  15595. /**
  15596. * Defines the array of paths to use
  15597. */
  15598. pathArray: Vector3[][],
  15599. /**
  15600. * Defines if the last and first points of each path in your pathArray must be joined
  15601. */
  15602. closeArray: boolean,
  15603. /**
  15604. * Defines if the last and first points of each path in your pathArray must be joined
  15605. */
  15606. closePath: boolean,
  15607. /**
  15608. * Defines the offset between points
  15609. */
  15610. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  15611. /**
  15612. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15613. */
  15614. side?: number);
  15615. /** @ignore */
  15616. _regenerateVertexData(): VertexData;
  15617. copy(id: string): Geometry;
  15618. }
  15619. /**
  15620. * Creates a box geometry
  15621. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  15622. */
  15623. class BoxGeometry extends _PrimitiveGeometry {
  15624. /**
  15625. * Defines the zise of the box (width, height and depth are the same)
  15626. */
  15627. size: number;
  15628. /**
  15629. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15630. */
  15631. side: number;
  15632. /**
  15633. * Creates a box geometry
  15634. * @param id defines the unique ID of the geometry
  15635. * @param scene defines the hosting scene
  15636. * @param size defines the zise of the box (width, height and depth are the same)
  15637. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15638. * @param mesh defines the hosting mesh (can be null)
  15639. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15640. */
  15641. constructor(id: string, scene: Scene,
  15642. /**
  15643. * Defines the zise of the box (width, height and depth are the same)
  15644. */
  15645. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15646. /**
  15647. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15648. */
  15649. side?: number);
  15650. _regenerateVertexData(): VertexData;
  15651. copy(id: string): Geometry;
  15652. serialize(): any;
  15653. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  15654. }
  15655. /**
  15656. * Creates a sphere geometry
  15657. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  15658. */
  15659. class SphereGeometry extends _PrimitiveGeometry {
  15660. /**
  15661. * Defines the number of segments to use to create the sphere
  15662. */
  15663. segments: number;
  15664. /**
  15665. * Defines the diameter of the sphere
  15666. */
  15667. diameter: number;
  15668. /**
  15669. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15670. */
  15671. side: number;
  15672. /**
  15673. * Create a new sphere geometry
  15674. * @param id defines the unique ID of the geometry
  15675. * @param scene defines the hosting scene
  15676. * @param segments defines the number of segments to use to create the sphere
  15677. * @param diameter defines the diameter of the sphere
  15678. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15679. * @param mesh defines the hosting mesh (can be null)
  15680. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15681. */
  15682. constructor(id: string, scene: Scene,
  15683. /**
  15684. * Defines the number of segments to use to create the sphere
  15685. */
  15686. segments: number,
  15687. /**
  15688. * Defines the diameter of the sphere
  15689. */
  15690. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15691. /**
  15692. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15693. */
  15694. side?: number);
  15695. _regenerateVertexData(): VertexData;
  15696. copy(id: string): Geometry;
  15697. serialize(): any;
  15698. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  15699. }
  15700. /**
  15701. * Creates a disc geometry
  15702. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  15703. */
  15704. class DiscGeometry extends _PrimitiveGeometry {
  15705. /**
  15706. * Defines the radius of the disc
  15707. */
  15708. radius: number;
  15709. /**
  15710. * Defines the tesselation factor to apply to the disc
  15711. */
  15712. tessellation: number;
  15713. /**
  15714. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15715. */
  15716. side: number;
  15717. /**
  15718. * Creates a new disc geometry
  15719. * @param id defines the unique ID of the geometry
  15720. * @param scene defines the hosting scene
  15721. * @param radius defines the radius of the disc
  15722. * @param tessellation defines the tesselation factor to apply to the disc
  15723. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15724. * @param mesh defines the hosting mesh (can be null)
  15725. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15726. */
  15727. constructor(id: string, scene: Scene,
  15728. /**
  15729. * Defines the radius of the disc
  15730. */
  15731. radius: number,
  15732. /**
  15733. * Defines the tesselation factor to apply to the disc
  15734. */
  15735. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15736. /**
  15737. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15738. */
  15739. side?: number);
  15740. _regenerateVertexData(): VertexData;
  15741. copy(id: string): Geometry;
  15742. }
  15743. /**
  15744. * Creates a new cylinder geometry
  15745. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  15746. */
  15747. class CylinderGeometry extends _PrimitiveGeometry {
  15748. /**
  15749. * Defines the height of the cylinder
  15750. */
  15751. height: number;
  15752. /**
  15753. * Defines the diameter of the cylinder's top cap
  15754. */
  15755. diameterTop: number;
  15756. /**
  15757. * Defines the diameter of the cylinder's bottom cap
  15758. */
  15759. diameterBottom: number;
  15760. /**
  15761. * Defines the tessellation factor to apply to the cylinder
  15762. */
  15763. tessellation: number;
  15764. /**
  15765. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  15766. */
  15767. subdivisions: number;
  15768. /**
  15769. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15770. */
  15771. side: number;
  15772. /**
  15773. * Creates a new cylinder geometry
  15774. * @param id defines the unique ID of the geometry
  15775. * @param scene defines the hosting scene
  15776. * @param height defines the height of the cylinder
  15777. * @param diameterTop defines the diameter of the cylinder's top cap
  15778. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  15779. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  15780. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  15781. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15782. * @param mesh defines the hosting mesh (can be null)
  15783. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15784. */
  15785. constructor(id: string, scene: Scene,
  15786. /**
  15787. * Defines the height of the cylinder
  15788. */
  15789. height: number,
  15790. /**
  15791. * Defines the diameter of the cylinder's top cap
  15792. */
  15793. diameterTop: number,
  15794. /**
  15795. * Defines the diameter of the cylinder's bottom cap
  15796. */
  15797. diameterBottom: number,
  15798. /**
  15799. * Defines the tessellation factor to apply to the cylinder
  15800. */
  15801. tessellation: number,
  15802. /**
  15803. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  15804. */
  15805. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15806. /**
  15807. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15808. */
  15809. side?: number);
  15810. _regenerateVertexData(): VertexData;
  15811. copy(id: string): Geometry;
  15812. serialize(): any;
  15813. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  15814. }
  15815. /**
  15816. * Creates a new torus geometry
  15817. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  15818. */
  15819. class TorusGeometry extends _PrimitiveGeometry {
  15820. /**
  15821. * Defines the diameter of the torus
  15822. */
  15823. diameter: number;
  15824. /**
  15825. * Defines the thickness of the torus (ie. internal diameter)
  15826. */
  15827. thickness: number;
  15828. /**
  15829. * Defines the tesselation factor to apply to the torus
  15830. */
  15831. tessellation: number;
  15832. /**
  15833. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15834. */
  15835. side: number;
  15836. /**
  15837. * Creates a new torus geometry
  15838. * @param id defines the unique ID of the geometry
  15839. * @param scene defines the hosting scene
  15840. * @param diameter defines the diameter of the torus
  15841. * @param thickness defines the thickness of the torus (ie. internal diameter)
  15842. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  15843. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15844. * @param mesh defines the hosting mesh (can be null)
  15845. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15846. */
  15847. constructor(id: string, scene: Scene,
  15848. /**
  15849. * Defines the diameter of the torus
  15850. */
  15851. diameter: number,
  15852. /**
  15853. * Defines the thickness of the torus (ie. internal diameter)
  15854. */
  15855. thickness: number,
  15856. /**
  15857. * Defines the tesselation factor to apply to the torus
  15858. */
  15859. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15860. /**
  15861. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15862. */
  15863. side?: number);
  15864. _regenerateVertexData(): VertexData;
  15865. copy(id: string): Geometry;
  15866. serialize(): any;
  15867. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  15868. }
  15869. /**
  15870. * Creates a new ground geometry
  15871. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  15872. */
  15873. class GroundGeometry extends _PrimitiveGeometry {
  15874. /**
  15875. * Defines the width of the ground
  15876. */
  15877. width: number;
  15878. /**
  15879. * Defines the height of the ground
  15880. */
  15881. height: number;
  15882. /**
  15883. * Defines the subdivisions to apply to the ground
  15884. */
  15885. subdivisions: number;
  15886. /**
  15887. * Creates a new ground geometry
  15888. * @param id defines the unique ID of the geometry
  15889. * @param scene defines the hosting scene
  15890. * @param width defines the width of the ground
  15891. * @param height defines the height of the ground
  15892. * @param subdivisions defines the subdivisions to apply to the ground
  15893. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15894. * @param mesh defines the hosting mesh (can be null)
  15895. */
  15896. constructor(id: string, scene: Scene,
  15897. /**
  15898. * Defines the width of the ground
  15899. */
  15900. width: number,
  15901. /**
  15902. * Defines the height of the ground
  15903. */
  15904. height: number,
  15905. /**
  15906. * Defines the subdivisions to apply to the ground
  15907. */
  15908. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  15909. _regenerateVertexData(): VertexData;
  15910. copy(id: string): Geometry;
  15911. serialize(): any;
  15912. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  15913. }
  15914. /**
  15915. * Creates a tiled ground geometry
  15916. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  15917. */
  15918. class TiledGroundGeometry extends _PrimitiveGeometry {
  15919. /**
  15920. * Defines the minimum value on X axis
  15921. */
  15922. xmin: number;
  15923. /**
  15924. * Defines the minimum value on Z axis
  15925. */
  15926. zmin: number;
  15927. /**
  15928. * Defines the maximum value on X axis
  15929. */
  15930. xmax: number;
  15931. /**
  15932. * Defines the maximum value on Z axis
  15933. */
  15934. zmax: number;
  15935. /**
  15936. * Defines the subdivisions to apply to the ground
  15937. */
  15938. subdivisions: {
  15939. w: number;
  15940. h: number;
  15941. };
  15942. /**
  15943. * Defines the precision to use when computing the tiles
  15944. */
  15945. precision: {
  15946. w: number;
  15947. h: number;
  15948. };
  15949. /**
  15950. * Creates a tiled ground geometry
  15951. * @param id defines the unique ID of the geometry
  15952. * @param scene defines the hosting scene
  15953. * @param xmin defines the minimum value on X axis
  15954. * @param zmin defines the minimum value on Z axis
  15955. * @param xmax defines the maximum value on X axis
  15956. * @param zmax defines the maximum value on Z axis
  15957. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  15958. * @param precision defines the precision to use when computing the tiles
  15959. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15960. * @param mesh defines the hosting mesh (can be null)
  15961. */
  15962. constructor(id: string, scene: Scene,
  15963. /**
  15964. * Defines the minimum value on X axis
  15965. */
  15966. xmin: number,
  15967. /**
  15968. * Defines the minimum value on Z axis
  15969. */
  15970. zmin: number,
  15971. /**
  15972. * Defines the maximum value on X axis
  15973. */
  15974. xmax: number,
  15975. /**
  15976. * Defines the maximum value on Z axis
  15977. */
  15978. zmax: number,
  15979. /**
  15980. * Defines the subdivisions to apply to the ground
  15981. */
  15982. subdivisions: {
  15983. w: number;
  15984. h: number;
  15985. },
  15986. /**
  15987. * Defines the precision to use when computing the tiles
  15988. */
  15989. precision: {
  15990. w: number;
  15991. h: number;
  15992. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  15993. _regenerateVertexData(): VertexData;
  15994. copy(id: string): Geometry;
  15995. }
  15996. /**
  15997. * Creates a plane geometry
  15998. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  15999. */
  16000. class PlaneGeometry extends _PrimitiveGeometry {
  16001. /**
  16002. * Defines the size of the plane (width === height)
  16003. */
  16004. size: number;
  16005. /**
  16006. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16007. */
  16008. side: number;
  16009. /**
  16010. * Creates a plane geometry
  16011. * @param id defines the unique ID of the geometry
  16012. * @param scene defines the hosting scene
  16013. * @param size defines the size of the plane (width === height)
  16014. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16015. * @param mesh defines the hosting mesh (can be null)
  16016. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16017. */
  16018. constructor(id: string, scene: Scene,
  16019. /**
  16020. * Defines the size of the plane (width === height)
  16021. */
  16022. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16023. /**
  16024. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16025. */
  16026. side?: number);
  16027. _regenerateVertexData(): VertexData;
  16028. copy(id: string): Geometry;
  16029. serialize(): any;
  16030. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  16031. }
  16032. /**
  16033. * Creates a torus knot geometry
  16034. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  16035. */
  16036. class TorusKnotGeometry extends _PrimitiveGeometry {
  16037. /**
  16038. * Defines the radius of the torus knot
  16039. */
  16040. radius: number;
  16041. /**
  16042. * Defines the thickness of the torus knot tube
  16043. */
  16044. tube: number;
  16045. /**
  16046. * Defines the number of radial segments
  16047. */
  16048. radialSegments: number;
  16049. /**
  16050. * Defines the number of tubular segments
  16051. */
  16052. tubularSegments: number;
  16053. /**
  16054. * Defines the first number of windings
  16055. */
  16056. p: number;
  16057. /**
  16058. * Defines the second number of windings
  16059. */
  16060. q: number;
  16061. /**
  16062. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16063. */
  16064. side: number;
  16065. /**
  16066. * Creates a torus knot geometry
  16067. * @param id defines the unique ID of the geometry
  16068. * @param scene defines the hosting scene
  16069. * @param radius defines the radius of the torus knot
  16070. * @param tube defines the thickness of the torus knot tube
  16071. * @param radialSegments defines the number of radial segments
  16072. * @param tubularSegments defines the number of tubular segments
  16073. * @param p defines the first number of windings
  16074. * @param q defines the second number of windings
  16075. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16076. * @param mesh defines the hosting mesh (can be null)
  16077. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16078. */
  16079. constructor(id: string, scene: Scene,
  16080. /**
  16081. * Defines the radius of the torus knot
  16082. */
  16083. radius: number,
  16084. /**
  16085. * Defines the thickness of the torus knot tube
  16086. */
  16087. tube: number,
  16088. /**
  16089. * Defines the number of radial segments
  16090. */
  16091. radialSegments: number,
  16092. /**
  16093. * Defines the number of tubular segments
  16094. */
  16095. tubularSegments: number,
  16096. /**
  16097. * Defines the first number of windings
  16098. */
  16099. p: number,
  16100. /**
  16101. * Defines the second number of windings
  16102. */
  16103. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16104. /**
  16105. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16106. */
  16107. side?: number);
  16108. _regenerateVertexData(): VertexData;
  16109. copy(id: string): Geometry;
  16110. serialize(): any;
  16111. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  16112. }
  16113. }
  16114. declare module BABYLON {
  16115. class GroundMesh extends Mesh {
  16116. generateOctree: boolean;
  16117. private _heightQuads;
  16118. _subdivisionsX: number;
  16119. _subdivisionsY: number;
  16120. _width: number;
  16121. _height: number;
  16122. _minX: number;
  16123. _maxX: number;
  16124. _minZ: number;
  16125. _maxZ: number;
  16126. constructor(name: string, scene: Scene);
  16127. getClassName(): string;
  16128. readonly subdivisions: number;
  16129. readonly subdivisionsX: number;
  16130. readonly subdivisionsY: number;
  16131. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  16132. /**
  16133. * Returns a height (y) value in the Worl system :
  16134. * the ground altitude at the coordinates (x, z) expressed in the World system.
  16135. * Returns the ground y position if (x, z) are outside the ground surface.
  16136. */
  16137. getHeightAtCoordinates(x: number, z: number): number;
  16138. /**
  16139. * Returns a normalized vector (Vector3) orthogonal to the ground
  16140. * at the ground coordinates (x, z) expressed in the World system.
  16141. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  16142. */
  16143. getNormalAtCoordinates(x: number, z: number): Vector3;
  16144. /**
  16145. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  16146. * at the ground coordinates (x, z) expressed in the World system.
  16147. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  16148. * Returns the GroundMesh.
  16149. */
  16150. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  16151. /**
  16152. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  16153. * if the ground has been updated.
  16154. * This can be used in the render loop.
  16155. * Returns the GroundMesh.
  16156. */
  16157. updateCoordinateHeights(): GroundMesh;
  16158. private _getFacetAt(x, z);
  16159. private _initHeightQuads();
  16160. private _computeHeightQuads();
  16161. serialize(serializationObject: any): void;
  16162. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  16163. }
  16164. }
  16165. declare module BABYLON {
  16166. /**
  16167. * Creates an instance based on a source mesh.
  16168. */
  16169. class InstancedMesh extends AbstractMesh {
  16170. private _sourceMesh;
  16171. private _currentLOD;
  16172. constructor(name: string, source: Mesh);
  16173. /**
  16174. * Returns the string "InstancedMesh".
  16175. */
  16176. getClassName(): string;
  16177. readonly receiveShadows: boolean;
  16178. readonly material: Nullable<Material>;
  16179. readonly visibility: number;
  16180. readonly skeleton: Nullable<Skeleton>;
  16181. renderingGroupId: number;
  16182. /**
  16183. * Returns the total number of vertices (integer).
  16184. */
  16185. getTotalVertices(): number;
  16186. readonly sourceMesh: Mesh;
  16187. /**
  16188. * Is this node ready to be used/rendered
  16189. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16190. * @return {boolean} is it ready
  16191. */
  16192. isReady(completeCheck?: boolean): boolean;
  16193. /**
  16194. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16195. */
  16196. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16197. /**
  16198. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16199. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16200. * The `data` are either a numeric array either a Float32Array.
  16201. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16202. * 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).
  16203. * Note that a new underlying VertexBuffer object is created each call.
  16204. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16205. *
  16206. * Possible `kind` values :
  16207. * - BABYLON.VertexBuffer.PositionKind
  16208. * - BABYLON.VertexBuffer.UVKind
  16209. * - BABYLON.VertexBuffer.UV2Kind
  16210. * - BABYLON.VertexBuffer.UV3Kind
  16211. * - BABYLON.VertexBuffer.UV4Kind
  16212. * - BABYLON.VertexBuffer.UV5Kind
  16213. * - BABYLON.VertexBuffer.UV6Kind
  16214. * - BABYLON.VertexBuffer.ColorKind
  16215. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16216. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16217. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16218. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16219. *
  16220. * Returns the Mesh.
  16221. */
  16222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16223. /**
  16224. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16225. * If the mesh has no geometry, it is simply returned as it is.
  16226. * The `data` are either a numeric array either a Float32Array.
  16227. * No new underlying VertexBuffer object is created.
  16228. * 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.
  16229. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16230. *
  16231. * Possible `kind` values :
  16232. * - BABYLON.VertexBuffer.PositionKind
  16233. * - BABYLON.VertexBuffer.UVKind
  16234. * - BABYLON.VertexBuffer.UV2Kind
  16235. * - BABYLON.VertexBuffer.UV3Kind
  16236. * - BABYLON.VertexBuffer.UV4Kind
  16237. * - BABYLON.VertexBuffer.UV5Kind
  16238. * - BABYLON.VertexBuffer.UV6Kind
  16239. * - BABYLON.VertexBuffer.ColorKind
  16240. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16241. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16242. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16243. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16244. *
  16245. * Returns the Mesh.
  16246. */
  16247. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16248. /**
  16249. * Sets the mesh indices.
  16250. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16251. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16252. * This method creates a new index buffer each call.
  16253. * Returns the Mesh.
  16254. */
  16255. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16256. /**
  16257. * Boolean : True if the mesh owns the requested kind of data.
  16258. */
  16259. isVerticesDataPresent(kind: string): boolean;
  16260. /**
  16261. * Returns an array of indices (IndicesArray).
  16262. */
  16263. getIndices(): Nullable<IndicesArray>;
  16264. readonly _positions: Nullable<Vector3[]>;
  16265. /**
  16266. * Sets a new updated BoundingInfo to the mesh.
  16267. * Returns the mesh.
  16268. */
  16269. refreshBoundingInfo(): InstancedMesh;
  16270. _preActivate(): InstancedMesh;
  16271. _activate(renderId: number): InstancedMesh;
  16272. /**
  16273. * Returns the current associated LOD AbstractMesh.
  16274. */
  16275. getLOD(camera: Camera): AbstractMesh;
  16276. _syncSubMeshes(): InstancedMesh;
  16277. _generatePointsArray(): boolean;
  16278. /**
  16279. * Creates a new InstancedMesh from the current mesh.
  16280. * - name (string) : the cloned mesh name
  16281. * - newParent (optional Node) : the optional Node to parent the clone to.
  16282. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16283. *
  16284. * Returns the clone.
  16285. */
  16286. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16287. /**
  16288. * Disposes the InstancedMesh.
  16289. * Returns nothing.
  16290. */
  16291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16292. }
  16293. }
  16294. declare module BABYLON {
  16295. class LinesMesh extends Mesh {
  16296. useVertexColor: boolean | undefined;
  16297. useVertexAlpha: boolean | undefined;
  16298. color: Color3;
  16299. alpha: number;
  16300. /**
  16301. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16302. * This margin is expressed in world space coordinates, so its value may vary.
  16303. * Default value is 0.1
  16304. * @returns the intersection Threshold value.
  16305. */
  16306. /**
  16307. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16308. * This margin is expressed in world space coordinates, so its value may vary.
  16309. * @param value the new threshold to apply
  16310. */
  16311. intersectionThreshold: number;
  16312. private _intersectionThreshold;
  16313. private _colorShader;
  16314. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  16315. /**
  16316. * Returns the string "LineMesh"
  16317. */
  16318. getClassName(): string;
  16319. material: Material;
  16320. readonly checkCollisions: boolean;
  16321. createInstance(name: string): InstancedMesh;
  16322. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16323. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16324. dispose(doNotRecurse?: boolean): void;
  16325. /**
  16326. * Returns a new LineMesh object cloned from the current one.
  16327. */
  16328. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16329. }
  16330. }
  16331. declare module BABYLON {
  16332. class _InstancesBatch {
  16333. mustReturn: boolean;
  16334. visibleInstances: Nullable<InstancedMesh[]>[];
  16335. renderSelf: boolean[];
  16336. }
  16337. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  16338. static _FRONTSIDE: number;
  16339. static _BACKSIDE: number;
  16340. static _DOUBLESIDE: number;
  16341. static _DEFAULTSIDE: number;
  16342. static _NO_CAP: number;
  16343. static _CAP_START: number;
  16344. static _CAP_END: number;
  16345. static _CAP_ALL: number;
  16346. /**
  16347. * Mesh side orientation : usually the external or front surface
  16348. */
  16349. static readonly FRONTSIDE: number;
  16350. /**
  16351. * Mesh side orientation : usually the internal or back surface
  16352. */
  16353. static readonly BACKSIDE: number;
  16354. /**
  16355. * Mesh side orientation : both internal and external or front and back surfaces
  16356. */
  16357. static readonly DOUBLESIDE: number;
  16358. /**
  16359. * Mesh side orientation : by default, `FRONTSIDE`
  16360. */
  16361. static readonly DEFAULTSIDE: number;
  16362. /**
  16363. * Mesh cap setting : no cap
  16364. */
  16365. static readonly NO_CAP: number;
  16366. /**
  16367. * Mesh cap setting : one cap at the beginning of the mesh
  16368. */
  16369. static readonly CAP_START: number;
  16370. /**
  16371. * Mesh cap setting : one cap at the end of the mesh
  16372. */
  16373. static readonly CAP_END: number;
  16374. /**
  16375. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  16376. */
  16377. static readonly CAP_ALL: number;
  16378. /**
  16379. * An event triggered before rendering the mesh
  16380. */
  16381. onBeforeRenderObservable: Observable<Mesh>;
  16382. /**
  16383. * An event triggered after rendering the mesh
  16384. */
  16385. onAfterRenderObservable: Observable<Mesh>;
  16386. /**
  16387. * An event triggered before drawing the mesh
  16388. */
  16389. onBeforeDrawObservable: Observable<Mesh>;
  16390. private _onBeforeDrawObserver;
  16391. onBeforeDraw: () => void;
  16392. delayLoadState: number;
  16393. instances: InstancedMesh[];
  16394. delayLoadingFile: string;
  16395. _binaryInfo: any;
  16396. private _LODLevels;
  16397. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  16398. private _morphTargetManager;
  16399. morphTargetManager: Nullable<MorphTargetManager>;
  16400. _geometry: Nullable<Geometry>;
  16401. _delayInfo: Array<string>;
  16402. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  16403. _visibleInstances: any;
  16404. private _renderIdForInstances;
  16405. private _batchCache;
  16406. private _instancesBufferSize;
  16407. private _instancesBuffer;
  16408. private _instancesData;
  16409. private _overridenInstanceCount;
  16410. private _effectiveMaterial;
  16411. _shouldGenerateFlatShading: boolean;
  16412. private _preActivateId;
  16413. _originalBuilderSideOrientation: number;
  16414. overrideMaterialSideOrientation: Nullable<number>;
  16415. private _areNormalsFrozen;
  16416. private _sourcePositions;
  16417. private _sourceNormals;
  16418. private _source;
  16419. readonly source: Nullable<Mesh>;
  16420. isUnIndexed: boolean;
  16421. /**
  16422. * @constructor
  16423. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  16424. * @param {Scene} scene The scene to add this mesh to.
  16425. * @param {Node} parent The parent of this mesh, if it has one
  16426. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  16427. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16428. * When false, achieved by calling a clone(), also passing False.
  16429. * This will make creation of children, recursive.
  16430. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  16431. */
  16432. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  16433. /**
  16434. * Returns the string "Mesh".
  16435. */
  16436. getClassName(): string;
  16437. /**
  16438. * Returns a string.
  16439. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  16440. */
  16441. toString(fullDetails?: boolean): string;
  16442. /**
  16443. * True if the mesh has some Levels Of Details (LOD).
  16444. * Returns a boolean.
  16445. */
  16446. readonly hasLODLevels: boolean;
  16447. /**
  16448. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  16449. * @returns an array of {BABYLON.MeshLODLevel}
  16450. */
  16451. getLODLevels(): MeshLODLevel[];
  16452. private _sortLODLevels();
  16453. /**
  16454. * Add a mesh as LOD level triggered at the given distance.
  16455. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16456. * @param {number} distance The distance from the center of the object to show this level
  16457. * @param {Mesh} mesh The mesh to be added as LOD level
  16458. * @return {Mesh} This mesh (for chaining)
  16459. */
  16460. addLODLevel(distance: number, mesh: Mesh): Mesh;
  16461. /**
  16462. * Returns the LOD level mesh at the passed distance or null if not found.
  16463. * It is related to the method `addLODLevel(distance, mesh)`.
  16464. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16465. * Returns an object Mesh or `null`.
  16466. */
  16467. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  16468. /**
  16469. * Remove a mesh from the LOD array
  16470. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16471. * @param {Mesh} mesh The mesh to be removed.
  16472. * @return {Mesh} This mesh (for chaining)
  16473. */
  16474. removeLODLevel(mesh: Mesh): Mesh;
  16475. /**
  16476. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  16477. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16478. */
  16479. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  16480. /**
  16481. * Returns the mesh internal Geometry object.
  16482. */
  16483. readonly geometry: Nullable<Geometry>;
  16484. /**
  16485. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  16486. */
  16487. getTotalVertices(): number;
  16488. /**
  16489. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  16490. * 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.
  16491. * You can force the copy with forceCopy === true
  16492. * Returns null if the mesh has no geometry or no vertex buffer.
  16493. * Possible `kind` values :
  16494. * - BABYLON.VertexBuffer.PositionKind
  16495. * - BABYLON.VertexBuffer.UVKind
  16496. * - BABYLON.VertexBuffer.UV2Kind
  16497. * - BABYLON.VertexBuffer.UV3Kind
  16498. * - BABYLON.VertexBuffer.UV4Kind
  16499. * - BABYLON.VertexBuffer.UV5Kind
  16500. * - BABYLON.VertexBuffer.UV6Kind
  16501. * - BABYLON.VertexBuffer.ColorKind
  16502. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16503. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16504. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16505. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16506. */
  16507. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  16508. /**
  16509. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  16510. * Returns `null` if the mesh has no geometry.
  16511. * Possible `kind` values :
  16512. * - BABYLON.VertexBuffer.PositionKind
  16513. * - BABYLON.VertexBuffer.UVKind
  16514. * - BABYLON.VertexBuffer.UV2Kind
  16515. * - BABYLON.VertexBuffer.UV3Kind
  16516. * - BABYLON.VertexBuffer.UV4Kind
  16517. * - BABYLON.VertexBuffer.UV5Kind
  16518. * - BABYLON.VertexBuffer.UV6Kind
  16519. * - BABYLON.VertexBuffer.ColorKind
  16520. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16521. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16522. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16523. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16524. */
  16525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  16526. /**
  16527. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  16528. * Possible `kind` values :
  16529. * - BABYLON.VertexBuffer.PositionKind
  16530. * - BABYLON.VertexBuffer.UVKind
  16531. * - BABYLON.VertexBuffer.UV2Kind
  16532. * - BABYLON.VertexBuffer.UV3Kind
  16533. * - BABYLON.VertexBuffer.UV4Kind
  16534. * - BABYLON.VertexBuffer.UV5Kind
  16535. * - BABYLON.VertexBuffer.UV6Kind
  16536. * - BABYLON.VertexBuffer.ColorKind
  16537. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16538. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16539. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16540. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16541. */
  16542. isVerticesDataPresent(kind: string): boolean;
  16543. /**
  16544. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  16545. * Possible `kind` values :
  16546. * - BABYLON.VertexBuffer.PositionKind
  16547. * - BABYLON.VertexBuffer.UVKind
  16548. * - BABYLON.VertexBuffer.UV2Kind
  16549. * - BABYLON.VertexBuffer.UV3Kind
  16550. * - BABYLON.VertexBuffer.UV4Kind
  16551. * - BABYLON.VertexBuffer.UV5Kind
  16552. * - BABYLON.VertexBuffer.UV6Kind
  16553. * - BABYLON.VertexBuffer.ColorKind
  16554. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16555. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16556. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16557. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16558. */
  16559. isVertexBufferUpdatable(kind: string): boolean;
  16560. /**
  16561. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  16562. * Possible `kind` values :
  16563. * - BABYLON.VertexBuffer.PositionKind
  16564. * - BABYLON.VertexBuffer.UVKind
  16565. * - BABYLON.VertexBuffer.UV2Kind
  16566. * - BABYLON.VertexBuffer.UV3Kind
  16567. * - BABYLON.VertexBuffer.UV4Kind
  16568. * - BABYLON.VertexBuffer.UV5Kind
  16569. * - BABYLON.VertexBuffer.UV6Kind
  16570. * - BABYLON.VertexBuffer.ColorKind
  16571. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16572. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16573. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16574. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16575. */
  16576. getVerticesDataKinds(): string[];
  16577. /**
  16578. * Returns a positive integer : the total number of indices in this mesh geometry.
  16579. * Returns zero if the mesh has no geometry.
  16580. */
  16581. getTotalIndices(): number;
  16582. /**
  16583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16584. * 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.
  16585. * Returns an empty array if the mesh has no geometry.
  16586. */
  16587. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16588. readonly isBlocked: boolean;
  16589. /**
  16590. * Determine if the current mesh is ready to be rendered
  16591. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16592. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  16593. * @returns true if all associated assets are ready (material, textures, shaders)
  16594. */
  16595. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  16596. /**
  16597. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  16598. * This property is pertinent only for updatable parametric shapes.
  16599. */
  16600. readonly areNormalsFrozen: boolean;
  16601. /**
  16602. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  16603. * It has no effect at all on other shapes.
  16604. * It prevents the mesh normals from being recomputed on next `positions` array update.
  16605. * Returns the Mesh.
  16606. */
  16607. freezeNormals(): Mesh;
  16608. /**
  16609. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  16610. * It has no effect at all on other shapes.
  16611. * It reactivates the mesh normals computation if it was previously frozen.
  16612. * Returns the Mesh.
  16613. */
  16614. unfreezeNormals(): Mesh;
  16615. /**
  16616. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  16617. */
  16618. overridenInstanceCount: number;
  16619. _preActivate(): Mesh;
  16620. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16621. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  16622. /**
  16623. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16624. * This means the mesh underlying bounding box and sphere are recomputed.
  16625. * Returns the Mesh.
  16626. */
  16627. refreshBoundingInfo(): Mesh;
  16628. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  16629. private _getPositionData(applySkeleton);
  16630. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  16631. subdivide(count: number): void;
  16632. /**
  16633. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16634. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16635. * The `data` are either a numeric array either a Float32Array.
  16636. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16637. * 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).
  16638. * Note that a new underlying VertexBuffer object is created each call.
  16639. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16640. *
  16641. * Possible `kind` values :
  16642. * - BABYLON.VertexBuffer.PositionKind
  16643. * - BABYLON.VertexBuffer.UVKind
  16644. * - BABYLON.VertexBuffer.UV2Kind
  16645. * - BABYLON.VertexBuffer.UV3Kind
  16646. * - BABYLON.VertexBuffer.UV4Kind
  16647. * - BABYLON.VertexBuffer.UV5Kind
  16648. * - BABYLON.VertexBuffer.UV6Kind
  16649. * - BABYLON.VertexBuffer.ColorKind
  16650. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16651. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16652. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16653. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16654. *
  16655. * Returns the Mesh.
  16656. */
  16657. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  16659. /**
  16660. * Sets the mesh VertexBuffer.
  16661. * Returns the Mesh.
  16662. */
  16663. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  16664. /**
  16665. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16666. * If the mesh has no geometry, it is simply returned as it is.
  16667. * The `data` are either a numeric array either a Float32Array.
  16668. * No new underlying VertexBuffer object is created.
  16669. * 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.
  16670. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16671. *
  16672. * Possible `kind` values :
  16673. * - BABYLON.VertexBuffer.PositionKind
  16674. * - BABYLON.VertexBuffer.UVKind
  16675. * - BABYLON.VertexBuffer.UV2Kind
  16676. * - BABYLON.VertexBuffer.UV3Kind
  16677. * - BABYLON.VertexBuffer.UV4Kind
  16678. * - BABYLON.VertexBuffer.UV5Kind
  16679. * - BABYLON.VertexBuffer.UV6Kind
  16680. * - BABYLON.VertexBuffer.ColorKind
  16681. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16682. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16683. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16684. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16685. *
  16686. * Returns the Mesh.
  16687. */
  16688. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16689. /**
  16690. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  16691. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  16692. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  16693. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  16694. * Returns the Mesh.
  16695. */
  16696. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  16697. /**
  16698. * Creates a un-shared specific occurence of the geometry for the mesh.
  16699. * Returns the Mesh.
  16700. */
  16701. makeGeometryUnique(): Mesh;
  16702. /**
  16703. * Sets the mesh indices.
  16704. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16705. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  16706. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16707. * This method creates a new index buffer each call.
  16708. * Returns the Mesh.
  16709. */
  16710. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  16711. /**
  16712. * Update the current index buffer
  16713. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  16714. * Returns the Mesh.
  16715. */
  16716. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  16717. /**
  16718. * Invert the geometry to move from a right handed system to a left handed one.
  16719. * Returns the Mesh.
  16720. */
  16721. toLeftHanded(): Mesh;
  16722. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  16724. /**
  16725. * Registers for this mesh a javascript function called just before the rendering process.
  16726. * This function is passed the current mesh.
  16727. * Return the Mesh.
  16728. */
  16729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  16730. /**
  16731. * Disposes a previously registered javascript function called before the rendering.
  16732. * This function is passed the current mesh.
  16733. * Returns the Mesh.
  16734. */
  16735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  16736. /**
  16737. * Registers for this mesh a javascript function called just after the rendering is complete.
  16738. * This function is passed the current mesh.
  16739. * Returns the Mesh.
  16740. */
  16741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  16742. /**
  16743. * Disposes a previously registered javascript function called after the rendering.
  16744. * This function is passed the current mesh.
  16745. * Return the Mesh.
  16746. */
  16747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  16748. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  16749. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  16750. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  16751. /**
  16752. * Triggers the draw call for the mesh.
  16753. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  16754. * Returns the Mesh.
  16755. */
  16756. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  16757. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  16758. /**
  16759. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  16760. */
  16761. getEmittedParticleSystems(): IParticleSystem[];
  16762. /**
  16763. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  16764. */
  16765. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  16766. _checkDelayState(): Mesh;
  16767. private _queueLoad(scene);
  16768. /**
  16769. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  16770. */
  16771. isInFrustum(frustumPlanes: Plane[]): boolean;
  16772. /**
  16773. * Sets the mesh material by the material or multiMaterial `id` property.
  16774. * The material `id` is a string identifying the material or the multiMaterial.
  16775. * This method returns the Mesh.
  16776. */
  16777. setMaterialByID(id: string): Mesh;
  16778. /**
  16779. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  16780. */
  16781. getAnimatables(): IAnimatable[];
  16782. /**
  16783. * Modifies the mesh geometry according to the passed transformation matrix.
  16784. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  16785. * The mesh normals are modified accordingly the same transformation.
  16786. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  16787. * Note that, under the hood, this method sets a new VertexBuffer each call.
  16788. * Returns the Mesh.
  16789. */
  16790. bakeTransformIntoVertices(transform: Matrix): Mesh;
  16791. /**
  16792. * Modifies the mesh geometry according to its own current World Matrix.
  16793. * The mesh World Matrix is then reset.
  16794. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  16795. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  16796. * Note that, under the hood, this method sets a new VertexBuffer each call.
  16797. * Returns the Mesh.
  16798. */
  16799. bakeCurrentTransformIntoVertices(): Mesh;
  16800. readonly _positions: Nullable<Vector3[]>;
  16801. _resetPointsArrayCache(): Mesh;
  16802. _generatePointsArray(): boolean;
  16803. /**
  16804. * Returns a new Mesh object generated from the current mesh properties.
  16805. * This method must not get confused with createInstance().
  16806. * The parameter `name` is a string, the name given to the new mesh.
  16807. * The optional parameter `newParent` can be any Node object (default `null`).
  16808. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  16809. * 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.
  16810. */
  16811. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  16812. /**
  16813. * Releases resources associated with this mesh.
  16814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16816. */
  16817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16818. /**
  16819. * Modifies the mesh geometry according to a displacement map.
  16820. * 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.
  16821. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  16822. * This method returns nothing.
  16823. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  16824. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  16825. * 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.
  16826. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  16827. * The parameter `uvScale` is an optional vector2 used to scale UV.
  16828. *
  16829. * Returns the Mesh.
  16830. */
  16831. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  16832. /**
  16833. * Modifies the mesh geometry according to a displacementMap buffer.
  16834. * 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.
  16835. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  16836. * This method returns nothing.
  16837. * 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.
  16838. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  16839. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  16840. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  16841. * The parameter `uvScale` is an optional vector2 used to scale UV.
  16842. *
  16843. * Returns the Mesh.
  16844. */
  16845. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  16846. /**
  16847. * Modify the mesh to get a flat shading rendering.
  16848. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  16849. * This method returns the Mesh.
  16850. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  16851. */
  16852. convertToFlatShadedMesh(): Mesh;
  16853. /**
  16854. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  16855. * In other words, more vertices, no more indices and a single bigger VBO.
  16856. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  16857. * Returns the Mesh.
  16858. */
  16859. convertToUnIndexedMesh(): Mesh;
  16860. /**
  16861. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  16862. * This method returns the Mesh.
  16863. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  16864. */
  16865. flipFaces(flipNormals?: boolean): Mesh;
  16866. /**
  16867. * Creates a new InstancedMesh object from the mesh model.
  16868. * An instance shares the same properties and the same material than its model.
  16869. * Only these properties of each instance can then be set individually :
  16870. * - position
  16871. * - rotation
  16872. * - rotationQuaternion
  16873. * - setPivotMatrix
  16874. * - scaling
  16875. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  16876. * Warning : this method is not supported for Line mesh and LineSystem
  16877. */
  16878. createInstance(name: string): InstancedMesh;
  16879. /**
  16880. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  16881. * After this call, all the mesh instances have the same submeshes than the current mesh.
  16882. * This method returns the Mesh.
  16883. */
  16884. synchronizeInstances(): Mesh;
  16885. /**
  16886. * Simplify the mesh according to the given array of settings.
  16887. * Function will return immediately and will simplify async. It returns the Mesh.
  16888. * @param settings a collection of simplification settings.
  16889. * @param parallelProcessing should all levels calculate parallel or one after the other.
  16890. * @param type the type of simplification to run.
  16891. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  16892. */
  16893. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  16894. /**
  16895. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  16896. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  16897. * This should be used together with the simplification to avoid disappearing triangles.
  16898. * Returns the Mesh.
  16899. * @param successCallback an optional success callback to be called after the optimization finished.
  16900. */
  16901. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  16902. serialize(serializationObject: any): void;
  16903. _syncGeometryWithMorphTargetManager(): void;
  16904. /**
  16905. * Returns a new Mesh object parsed from the source provided.
  16906. * The parameter `parsedMesh` is the source.
  16907. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  16908. */
  16909. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  16910. /**
  16911. * Creates a ribbon mesh.
  16912. * Please consider using the same method from the MeshBuilder class instead.
  16913. * 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.
  16914. *
  16915. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  16916. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  16917. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  16918. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  16919. * 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.
  16920. * 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.
  16921. * 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
  16922. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16923. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16924. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16925. */
  16926. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  16927. /**
  16928. * Creates a plane polygonal mesh. By default, this is a disc.
  16929. * Please consider using the same method from the MeshBuilder class instead.
  16930. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  16931. * 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.
  16932. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16933. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16934. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16935. */
  16936. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  16937. /**
  16938. * Creates a box mesh.
  16939. * Please consider using the same method from the MeshBuilder class instead.
  16940. * The parameter `size` sets the size (float) of each box side (default 1).
  16941. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16942. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16943. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16944. */
  16945. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  16946. /**
  16947. * Creates a sphere mesh.
  16948. * Please consider using the same method from the MeshBuilder class instead.
  16949. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  16950. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  16951. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16952. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16953. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16954. */
  16955. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  16956. /**
  16957. * Creates a cylinder or a cone mesh.
  16958. * Please consider using the same method from the MeshBuilder class instead.
  16959. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  16960. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  16961. * 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.
  16962. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  16963. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  16964. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16965. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16966. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16967. */
  16968. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  16969. /**
  16970. * Creates a torus mesh.
  16971. * Please consider using the same method from the MeshBuilder class instead.
  16972. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  16973. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  16974. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  16975. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16976. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16977. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16978. */
  16979. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  16980. /**
  16981. * Creates a torus knot mesh.
  16982. * Please consider using the same method from the MeshBuilder class instead.
  16983. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  16984. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  16985. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  16986. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  16987. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16988. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16989. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16990. */
  16991. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  16992. /**
  16993. * Creates a line mesh.
  16994. * Please consider using the same method from the MeshBuilder class instead.
  16995. * 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.
  16996. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16997. * The parameter `points` is an array successive Vector3.
  16998. * 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
  16999. * When updating an instance, remember that only point positions can change, not the number of points.
  17000. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17001. */
  17002. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  17003. /**
  17004. * Creates a dashed line mesh.
  17005. * Please consider using the same method from the MeshBuilder class instead.
  17006. * 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.
  17007. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17008. * The parameter `points` is an array successive Vector3.
  17009. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  17010. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  17011. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  17012. * 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
  17013. * When updating an instance, remember that only point positions can change, not the number of points.
  17014. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17015. */
  17016. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  17017. /**
  17018. * Creates a polygon mesh.
  17019. * Please consider using the same method from the MeshBuilder class instead.
  17020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  17021. * 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.
  17022. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17023. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17024. * Remember you can only change the shape positions, not their number when updating a polygon.
  17025. */
  17026. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  17027. /**
  17028. * Creates an extruded polygon mesh, with depth in the Y direction.
  17029. * Please consider using the same method from the MeshBuilder class instead.
  17030. */
  17031. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  17032. /**
  17033. * Creates an extruded shape mesh.
  17034. * 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.
  17035. * Please consider using the same method from the MeshBuilder class instead.
  17036. *
  17037. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17038. * 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
  17039. * extruded along the Z axis.
  17040. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17041. * 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.
  17042. * The parameter `scale` (float, default 1) is the value to scale the shape.
  17043. * 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
  17044. * 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
  17045. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17046. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17047. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17048. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17049. */
  17050. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  17051. /**
  17052. * Creates an custom extruded shape mesh.
  17053. * 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.
  17054. * Please consider using the same method from the MeshBuilder class instead.
  17055. *
  17056. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17057. * 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
  17058. * extruded along the Z axis.
  17059. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17060. * 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
  17061. * and the distance of this point from the begining of the path :
  17062. * ```javascript
  17063. * var rotationFunction = function(i, distance) {
  17064. * // do things
  17065. * return rotationValue; }
  17066. * ```
  17067. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  17068. * 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
  17069. * and the distance of this point from the begining of the path :
  17070. * ```javascript
  17071. * var scaleFunction = function(i, distance) {
  17072. * // do things
  17073. * return scaleValue;}
  17074. * ```
  17075. * It must returns a float value that will be the scale value applied to the shape on each path point.
  17076. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  17077. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  17078. * 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
  17079. * 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
  17080. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17081. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17082. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17083. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17084. */
  17085. 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;
  17086. /**
  17087. * Creates lathe mesh.
  17088. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  17089. * Please consider using the same method from the MeshBuilder class instead.
  17090. * 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
  17091. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  17092. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  17093. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  17094. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17095. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17096. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17097. */
  17098. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17099. /**
  17100. * Creates a plane mesh.
  17101. * Please consider using the same method from the MeshBuilder class instead.
  17102. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  17103. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17104. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17105. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17106. */
  17107. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17108. /**
  17109. * Creates a ground mesh.
  17110. * Please consider using the same method from the MeshBuilder class instead.
  17111. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  17112. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  17113. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17114. */
  17115. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  17116. /**
  17117. * Creates a tiled ground mesh.
  17118. * Please consider using the same method from the MeshBuilder class instead.
  17119. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  17120. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  17121. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  17122. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  17123. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  17124. * numbers of subdivisions on the ground width and height of each tile.
  17125. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17126. */
  17127. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  17128. w: number;
  17129. h: number;
  17130. }, precision: {
  17131. w: number;
  17132. h: number;
  17133. }, scene: Scene, updatable?: boolean): Mesh;
  17134. /**
  17135. * Creates a ground mesh from a height map.
  17136. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  17137. * Please consider using the same method from the MeshBuilder class instead.
  17138. * The parameter `url` sets the URL of the height map image resource.
  17139. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  17140. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  17141. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  17142. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  17143. * 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).
  17144. * This function is passed the newly built mesh :
  17145. * ```javascript
  17146. * function(mesh) { // do things
  17147. * return; }
  17148. * ```
  17149. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17150. */
  17151. 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;
  17152. /**
  17153. * Creates a tube mesh.
  17154. * 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.
  17155. * Please consider using the same method from the MeshBuilder class instead.
  17156. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  17157. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  17158. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  17159. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  17160. * 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.
  17161. * It must return a radius value (positive float) :
  17162. * ```javascript
  17163. * var radiusFunction = function(i, distance) {
  17164. * // do things
  17165. * return radius; }
  17166. * ```
  17167. * 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
  17168. * 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
  17169. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17170. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17171. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17172. */
  17173. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  17174. (i: number, distance: number): number;
  17175. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  17176. /**
  17177. * Creates a polyhedron mesh.
  17178. * Please consider using the same method from the MeshBuilder class instead.
  17179. * 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
  17180. * to choose the wanted type.
  17181. * The parameter `size` (positive float, default 1) sets the polygon size.
  17182. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  17183. * 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`.
  17184. * 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
  17185. * 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)`).
  17186. * 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
  17187. * 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.
  17188. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17189. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17190. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17191. */
  17192. static CreatePolyhedron(name: string, options: {
  17193. type?: number;
  17194. size?: number;
  17195. sizeX?: number;
  17196. sizeY?: number;
  17197. sizeZ?: number;
  17198. custom?: any;
  17199. faceUV?: Vector4[];
  17200. faceColors?: Color4[];
  17201. updatable?: boolean;
  17202. sideOrientation?: number;
  17203. }, scene: Scene): Mesh;
  17204. /**
  17205. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  17206. * Please consider using the same method from the MeshBuilder class instead.
  17207. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  17208. * 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`).
  17209. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  17210. * 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.
  17211. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17212. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17213. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17214. */
  17215. static CreateIcoSphere(name: string, options: {
  17216. radius?: number;
  17217. flat?: boolean;
  17218. subdivisions?: number;
  17219. sideOrientation?: number;
  17220. updatable?: boolean;
  17221. }, scene: Scene): Mesh;
  17222. /**
  17223. * Creates a decal mesh.
  17224. * Please consider using the same method from the MeshBuilder class instead.
  17225. * 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.
  17226. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  17227. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  17228. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  17229. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  17230. */
  17231. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  17232. /**
  17233. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  17234. */
  17235. setPositionsForCPUSkinning(): Float32Array;
  17236. /**
  17237. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  17238. */
  17239. setNormalsForCPUSkinning(): Float32Array;
  17240. /**
  17241. * Updates the vertex buffer by applying transformation from the bones.
  17242. * Returns the Mesh.
  17243. *
  17244. * @param {skeleton} skeleton to apply
  17245. */
  17246. applySkeleton(skeleton: Skeleton): Mesh;
  17247. /**
  17248. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  17249. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  17250. */
  17251. static MinMax(meshes: AbstractMesh[]): {
  17252. min: Vector3;
  17253. max: Vector3;
  17254. };
  17255. /**
  17256. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  17257. */
  17258. static Center(meshesOrMinMaxVector: {
  17259. min: Vector3;
  17260. max: Vector3;
  17261. } | AbstractMesh[]): Vector3;
  17262. /**
  17263. * Merge the array of meshes into a single mesh for performance reasons.
  17264. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  17265. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  17266. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  17267. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  17268. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  17269. */
  17270. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  17271. }
  17272. }
  17273. declare module BABYLON {
  17274. interface IGetSetVerticesData {
  17275. isVerticesDataPresent(kind: string): boolean;
  17276. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17277. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17278. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  17279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  17280. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  17281. }
  17282. class VertexData {
  17283. positions: Nullable<FloatArray>;
  17284. normals: Nullable<FloatArray>;
  17285. tangents: Nullable<FloatArray>;
  17286. uvs: Nullable<FloatArray>;
  17287. uvs2: Nullable<FloatArray>;
  17288. uvs3: Nullable<FloatArray>;
  17289. uvs4: Nullable<FloatArray>;
  17290. uvs5: Nullable<FloatArray>;
  17291. uvs6: Nullable<FloatArray>;
  17292. colors: Nullable<FloatArray>;
  17293. matricesIndices: Nullable<FloatArray>;
  17294. matricesWeights: Nullable<FloatArray>;
  17295. matricesIndicesExtra: Nullable<FloatArray>;
  17296. matricesWeightsExtra: Nullable<FloatArray>;
  17297. indices: Nullable<IndicesArray>;
  17298. set(data: FloatArray, kind: string): void;
  17299. /**
  17300. * Associates the vertexData to the passed Mesh.
  17301. * Sets it as updatable or not (default `false`).
  17302. * Returns the VertexData.
  17303. */
  17304. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  17305. /**
  17306. * Associates the vertexData to the passed Geometry.
  17307. * Sets it as updatable or not (default `false`).
  17308. * Returns the VertexData.
  17309. */
  17310. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  17311. /**
  17312. * Updates the associated mesh.
  17313. * Returns the VertexData.
  17314. */
  17315. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  17316. /**
  17317. * Updates the associated geometry.
  17318. * Returns the VertexData.
  17319. */
  17320. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  17321. private _applyTo(meshOrGeometry, updatable?);
  17322. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  17323. /**
  17324. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  17325. * Returns the VertexData.
  17326. */
  17327. transform(matrix: Matrix): VertexData;
  17328. /**
  17329. * Merges the passed VertexData into the current one.
  17330. * Returns the modified VertexData.
  17331. */
  17332. merge(other: VertexData): VertexData;
  17333. private _mergeElement(source, other);
  17334. private _validate();
  17335. /**
  17336. * Serializes the VertexData.
  17337. * Returns a serialized object.
  17338. */
  17339. serialize(): any;
  17340. /**
  17341. * Returns the object VertexData associated to the passed mesh.
  17342. */
  17343. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  17344. /**
  17345. * Returns the object VertexData associated to the passed geometry.
  17346. */
  17347. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  17348. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  17349. /**
  17350. * Creates the vertexData of the Ribbon.
  17351. */
  17352. static CreateRibbon(options: {
  17353. pathArray: Vector3[][];
  17354. closeArray?: boolean;
  17355. closePath?: boolean;
  17356. offset?: number;
  17357. sideOrientation?: number;
  17358. frontUVs?: Vector4;
  17359. backUVs?: Vector4;
  17360. invertUV?: boolean;
  17361. uvs?: Vector2[];
  17362. colors?: Color4[];
  17363. }): VertexData;
  17364. /**
  17365. * Creates the VertexData of the Box.
  17366. */
  17367. static CreateBox(options: {
  17368. size?: number;
  17369. width?: number;
  17370. height?: number;
  17371. depth?: number;
  17372. faceUV?: Vector4[];
  17373. faceColors?: Color4[];
  17374. sideOrientation?: number;
  17375. frontUVs?: Vector4;
  17376. backUVs?: Vector4;
  17377. }): VertexData;
  17378. /**
  17379. * Creates the VertexData of the Sphere.
  17380. */
  17381. static CreateSphere(options: {
  17382. segments?: number;
  17383. diameter?: number;
  17384. diameterX?: number;
  17385. diameterY?: number;
  17386. diameterZ?: number;
  17387. arc?: number;
  17388. slice?: number;
  17389. sideOrientation?: number;
  17390. frontUVs?: Vector4;
  17391. backUVs?: Vector4;
  17392. }): VertexData;
  17393. /**
  17394. * Creates the VertexData of the Cylinder or Cone.
  17395. */
  17396. static CreateCylinder(options: {
  17397. height?: number;
  17398. diameterTop?: number;
  17399. diameterBottom?: number;
  17400. diameter?: number;
  17401. tessellation?: number;
  17402. subdivisions?: number;
  17403. arc?: number;
  17404. faceColors?: Color4[];
  17405. faceUV?: Vector4[];
  17406. hasRings?: boolean;
  17407. enclose?: boolean;
  17408. sideOrientation?: number;
  17409. frontUVs?: Vector4;
  17410. backUVs?: Vector4;
  17411. }): VertexData;
  17412. /**
  17413. * Creates the VertexData of the Torus.
  17414. */
  17415. static CreateTorus(options: {
  17416. diameter?: number;
  17417. thickness?: number;
  17418. tessellation?: number;
  17419. sideOrientation?: number;
  17420. frontUVs?: Vector4;
  17421. backUVs?: Vector4;
  17422. }): VertexData;
  17423. /**
  17424. * Creates the VertexData of the LineSystem.
  17425. */
  17426. static CreateLineSystem(options: {
  17427. lines: Vector3[][];
  17428. colors?: Nullable<Color4[][]>;
  17429. }): VertexData;
  17430. /**
  17431. * Create the VertexData of the DashedLines.
  17432. */
  17433. static CreateDashedLines(options: {
  17434. points: Vector3[];
  17435. dashSize?: number;
  17436. gapSize?: number;
  17437. dashNb?: number;
  17438. }): VertexData;
  17439. /**
  17440. * Creates the VertexData of the Ground.
  17441. */
  17442. static CreateGround(options: {
  17443. width?: number;
  17444. height?: number;
  17445. subdivisions?: number;
  17446. subdivisionsX?: number;
  17447. subdivisionsY?: number;
  17448. }): VertexData;
  17449. /**
  17450. * Creates the VertexData of the TiledGround.
  17451. */
  17452. static CreateTiledGround(options: {
  17453. xmin: number;
  17454. zmin: number;
  17455. xmax: number;
  17456. zmax: number;
  17457. subdivisions?: {
  17458. w: number;
  17459. h: number;
  17460. };
  17461. precision?: {
  17462. w: number;
  17463. h: number;
  17464. };
  17465. }): VertexData;
  17466. /**
  17467. * Creates the VertexData of the Ground designed from a heightmap.
  17468. */
  17469. static CreateGroundFromHeightMap(options: {
  17470. width: number;
  17471. height: number;
  17472. subdivisions: number;
  17473. minHeight: number;
  17474. maxHeight: number;
  17475. colorFilter: Color3;
  17476. buffer: Uint8Array;
  17477. bufferWidth: number;
  17478. bufferHeight: number;
  17479. }): VertexData;
  17480. /**
  17481. * Creates the VertexData of the Plane.
  17482. */
  17483. static CreatePlane(options: {
  17484. size?: number;
  17485. width?: number;
  17486. height?: number;
  17487. sideOrientation?: number;
  17488. frontUVs?: Vector4;
  17489. backUVs?: Vector4;
  17490. }): VertexData;
  17491. /**
  17492. * Creates the VertexData of the Disc or regular Polygon.
  17493. */
  17494. static CreateDisc(options: {
  17495. radius?: number;
  17496. tessellation?: number;
  17497. arc?: number;
  17498. sideOrientation?: number;
  17499. frontUVs?: Vector4;
  17500. backUVs?: Vector4;
  17501. }): VertexData;
  17502. /**
  17503. * Re-creates the VertexData of the Polygon for sideOrientation.
  17504. */
  17505. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  17506. /**
  17507. * Creates the VertexData of the IcoSphere.
  17508. */
  17509. static CreateIcoSphere(options: {
  17510. radius?: number;
  17511. radiusX?: number;
  17512. radiusY?: number;
  17513. radiusZ?: number;
  17514. flat?: boolean;
  17515. subdivisions?: number;
  17516. sideOrientation?: number;
  17517. frontUVs?: Vector4;
  17518. backUVs?: Vector4;
  17519. }): VertexData;
  17520. /**
  17521. * Creates the VertexData of the Polyhedron.
  17522. */
  17523. static CreatePolyhedron(options: {
  17524. type?: number;
  17525. size?: number;
  17526. sizeX?: number;
  17527. sizeY?: number;
  17528. sizeZ?: number;
  17529. custom?: any;
  17530. faceUV?: Vector4[];
  17531. faceColors?: Color4[];
  17532. flat?: boolean;
  17533. sideOrientation?: number;
  17534. frontUVs?: Vector4;
  17535. backUVs?: Vector4;
  17536. }): VertexData;
  17537. /**
  17538. * Creates the VertexData of the Torus Knot.
  17539. */
  17540. static CreateTorusKnot(options: {
  17541. radius?: number;
  17542. tube?: number;
  17543. radialSegments?: number;
  17544. tubularSegments?: number;
  17545. p?: number;
  17546. q?: number;
  17547. sideOrientation?: number;
  17548. frontUVs?: Vector4;
  17549. backUVs?: Vector4;
  17550. }): VertexData;
  17551. /**
  17552. * @param {any} - positions (number[] or Float32Array)
  17553. * @param {any} - indices (number[] or Uint16Array)
  17554. * @param {any} - normals (number[] or Float32Array)
  17555. * options (optional) :
  17556. * facetPositions : optional array of facet positions (vector3)
  17557. * facetNormals : optional array of facet normals (vector3)
  17558. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  17559. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  17560. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  17561. * bbSize : optional bounding box size data, required for facetPartitioning computation
  17562. * bInfo : optional bounding info, required for facetPartitioning computation
  17563. * useRightHandedSystem: optional boolean to for right handed system computation
  17564. * depthSort : optional boolean to enable the facet depth sort computation
  17565. * distanceTo : optional Vector3 to compute the facet depth from this location
  17566. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  17567. */
  17568. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  17569. facetNormals?: any;
  17570. facetPositions?: any;
  17571. facetPartitioning?: any;
  17572. ratio?: number;
  17573. bInfo?: any;
  17574. bbSize?: Vector3;
  17575. subDiv?: any;
  17576. useRightHandedSystem?: boolean;
  17577. depthSort?: boolean;
  17578. distanceTo?: Vector3;
  17579. depthSortedFacets?: any;
  17580. }): void;
  17581. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  17582. /**
  17583. * Creates a new VertexData from the imported parameters.
  17584. */
  17585. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  17586. }
  17587. }
  17588. declare module BABYLON {
  17589. class MeshBuilder {
  17590. private static updateSideOrientation(orientation?);
  17591. /**
  17592. * Creates a box mesh.
  17593. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  17594. * The parameter `size` sets the size (float) of each box side (default 1).
  17595. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  17596. * 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).
  17597. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  17598. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17599. * 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).
  17600. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17601. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17602. */
  17603. static CreateBox(name: string, options: {
  17604. size?: number;
  17605. width?: number;
  17606. height?: number;
  17607. depth?: number;
  17608. faceUV?: Vector4[];
  17609. faceColors?: Color4[];
  17610. sideOrientation?: number;
  17611. frontUVs?: Vector4;
  17612. backUVs?: Vector4;
  17613. updatable?: boolean;
  17614. }, scene?: Nullable<Scene>): Mesh;
  17615. /**
  17616. * Creates a sphere mesh.
  17617. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  17618. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  17619. * 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`).
  17620. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  17621. * 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
  17622. * 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).
  17623. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17624. * 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).
  17625. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17626. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17627. */
  17628. static CreateSphere(name: string, options: {
  17629. segments?: number;
  17630. diameter?: number;
  17631. diameterX?: number;
  17632. diameterY?: number;
  17633. diameterZ?: number;
  17634. arc?: number;
  17635. slice?: number;
  17636. sideOrientation?: number;
  17637. frontUVs?: Vector4;
  17638. backUVs?: Vector4;
  17639. updatable?: boolean;
  17640. }, scene: any): Mesh;
  17641. /**
  17642. * Creates a plane polygonal mesh. By default, this is a disc.
  17643. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  17644. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  17645. * 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.
  17646. * 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
  17647. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17648. * 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).
  17649. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17650. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17651. */
  17652. static CreateDisc(name: string, options: {
  17653. radius?: number;
  17654. tessellation?: number;
  17655. arc?: number;
  17656. updatable?: boolean;
  17657. sideOrientation?: number;
  17658. frontUVs?: Vector4;
  17659. backUVs?: Vector4;
  17660. }, scene?: Nullable<Scene>): Mesh;
  17661. /**
  17662. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  17663. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  17664. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  17665. * 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`).
  17666. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  17667. * 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.
  17668. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17669. * 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).
  17670. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17671. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17672. */
  17673. static CreateIcoSphere(name: string, options: {
  17674. radius?: number;
  17675. radiusX?: number;
  17676. radiusY?: number;
  17677. radiusZ?: number;
  17678. flat?: boolean;
  17679. subdivisions?: number;
  17680. sideOrientation?: number;
  17681. frontUVs?: Vector4;
  17682. backUVs?: Vector4;
  17683. updatable?: boolean;
  17684. }, scene: Scene): Mesh;
  17685. /**
  17686. * Creates a ribbon mesh.
  17687. * 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.
  17688. *
  17689. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  17690. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  17691. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  17692. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  17693. * 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.
  17694. * 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.
  17695. * 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
  17696. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17697. * 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).
  17698. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17699. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17700. * 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.
  17701. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  17702. * 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
  17703. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  17704. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  17705. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17706. */
  17707. static CreateRibbon(name: string, options: {
  17708. pathArray: Vector3[][];
  17709. closeArray?: boolean;
  17710. closePath?: boolean;
  17711. offset?: number;
  17712. updatable?: boolean;
  17713. sideOrientation?: number;
  17714. frontUVs?: Vector4;
  17715. backUVs?: Vector4;
  17716. instance?: Mesh;
  17717. invertUV?: boolean;
  17718. uvs?: Vector2[];
  17719. colors?: Color4[];
  17720. }, scene?: Nullable<Scene>): Mesh;
  17721. /**
  17722. * Creates a cylinder or a cone mesh.
  17723. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  17724. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  17725. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  17726. * 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.
  17727. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  17728. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  17729. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  17730. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  17731. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  17732. * 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).
  17733. * 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
  17734. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  17735. * 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
  17736. * 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.
  17737. * If `enclose` is false, a ring surface is one element.
  17738. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  17739. * 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
  17740. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17741. * 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).
  17742. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17743. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17744. */
  17745. static CreateCylinder(name: string, options: {
  17746. height?: number;
  17747. diameterTop?: number;
  17748. diameterBottom?: number;
  17749. diameter?: number;
  17750. tessellation?: number;
  17751. subdivisions?: number;
  17752. arc?: number;
  17753. faceColors?: Color4[];
  17754. faceUV?: Vector4[];
  17755. updatable?: boolean;
  17756. hasRings?: boolean;
  17757. enclose?: boolean;
  17758. sideOrientation?: number;
  17759. frontUVs?: Vector4;
  17760. backUVs?: Vector4;
  17761. }, scene: any): Mesh;
  17762. /**
  17763. * Creates a torus mesh.
  17764. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  17765. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  17766. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  17767. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  17768. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17769. * 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).
  17770. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17771. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17772. */
  17773. static CreateTorus(name: string, options: {
  17774. diameter?: number;
  17775. thickness?: number;
  17776. tessellation?: number;
  17777. updatable?: boolean;
  17778. sideOrientation?: number;
  17779. frontUVs?: Vector4;
  17780. backUVs?: Vector4;
  17781. }, scene: any): Mesh;
  17782. /**
  17783. * Creates a torus knot mesh.
  17784. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  17785. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  17786. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  17787. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  17788. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  17789. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17790. * 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).
  17791. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17792. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17793. */
  17794. static CreateTorusKnot(name: string, options: {
  17795. radius?: number;
  17796. tube?: number;
  17797. radialSegments?: number;
  17798. tubularSegments?: number;
  17799. p?: number;
  17800. q?: number;
  17801. updatable?: boolean;
  17802. sideOrientation?: number;
  17803. frontUVs?: Vector4;
  17804. backUVs?: Vector4;
  17805. }, scene: any): Mesh;
  17806. /**
  17807. * Creates a line system mesh.
  17808. * A line system is a pool of many lines gathered in a single mesh.
  17809. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  17810. * 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.
  17811. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  17812. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  17813. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  17814. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  17815. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  17816. * 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
  17817. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  17818. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17819. */
  17820. static CreateLineSystem(name: string, options: {
  17821. lines: Vector3[][];
  17822. updatable: boolean;
  17823. instance: Nullable<LinesMesh>;
  17824. colors?: Nullable<Color4[][]>;
  17825. useVertexAlpha?: boolean;
  17826. }, scene: Nullable<Scene>): LinesMesh;
  17827. /**
  17828. * Creates a line mesh.
  17829. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  17830. * 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.
  17831. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17832. * The parameter `points` is an array successive Vector3.
  17833. * 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
  17834. * The optional parameter `colors` is an array of successive Color4, one per line point.
  17835. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  17836. * When updating an instance, remember that only point positions can change, not the number of points.
  17837. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17838. */
  17839. static CreateLines(name: string, options: {
  17840. points: Vector3[];
  17841. updatable: boolean;
  17842. instance: Nullable<LinesMesh>;
  17843. colors?: Color4[];
  17844. useVertexAlpha?: boolean;
  17845. }, scene?: Nullable<Scene>): LinesMesh;
  17846. /**
  17847. * Creates a dashed line mesh.
  17848. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  17849. * 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.
  17850. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17851. * The parameter `points` is an array successive Vector3.
  17852. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  17853. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  17854. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  17855. * 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
  17856. * When updating an instance, remember that only point positions can change, not the number of points.
  17857. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17858. */
  17859. static CreateDashedLines(name: string, options: {
  17860. points: Vector3[];
  17861. dashSize?: number;
  17862. gapSize?: number;
  17863. dashNb?: number;
  17864. updatable?: boolean;
  17865. instance?: LinesMesh;
  17866. }, scene?: Nullable<Scene>): LinesMesh;
  17867. /**
  17868. * Creates an extruded shape mesh.
  17869. * 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.
  17870. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  17871. *
  17872. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17873. * 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
  17874. * extruded along the Z axis.
  17875. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17876. * 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.
  17877. * The parameter `scale` (float, default 1) is the value to scale the shape.
  17878. * 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
  17879. * 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
  17880. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17881. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17882. * 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).
  17883. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17884. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17885. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17886. */
  17887. static ExtrudeShape(name: string, options: {
  17888. shape: Vector3[];
  17889. path: Vector3[];
  17890. scale?: number;
  17891. rotation?: number;
  17892. cap?: number;
  17893. updatable?: boolean;
  17894. sideOrientation?: number;
  17895. frontUVs?: Vector4;
  17896. backUVs?: Vector4;
  17897. instance?: Mesh;
  17898. invertUV?: boolean;
  17899. }, scene?: Nullable<Scene>): Mesh;
  17900. /**
  17901. * Creates an custom extruded shape mesh.
  17902. * 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.
  17903. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  17904. *
  17905. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17906. * 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
  17907. * extruded along the Z axis.
  17908. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17909. * 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
  17910. * and the distance of this point from the begining of the path :
  17911. * ```javascript
  17912. * var rotationFunction = function(i, distance) {
  17913. * // do things
  17914. * return rotationValue; }
  17915. * ```
  17916. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  17917. * 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
  17918. * and the distance of this point from the begining of the path :
  17919. * ```javascript
  17920. * var scaleFunction = function(i, distance) {
  17921. * // do things
  17922. * return scaleValue;}
  17923. * ```
  17924. * It must returns a float value that will be the scale value applied to the shape on each path point.
  17925. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  17926. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  17927. * 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
  17928. * 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
  17929. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17930. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17931. * 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).
  17932. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17933. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17934. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17935. */
  17936. static ExtrudeShapeCustom(name: string, options: {
  17937. shape: Vector3[];
  17938. path: Vector3[];
  17939. scaleFunction?: any;
  17940. rotationFunction?: any;
  17941. ribbonCloseArray?: boolean;
  17942. ribbonClosePath?: boolean;
  17943. cap?: number;
  17944. updatable?: boolean;
  17945. sideOrientation?: number;
  17946. frontUVs?: Vector4;
  17947. backUVs?: Vector4;
  17948. instance?: Mesh;
  17949. invertUV?: boolean;
  17950. }, scene: Scene): Mesh;
  17951. /**
  17952. * Creates lathe mesh.
  17953. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  17954. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  17955. *
  17956. * 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
  17957. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  17958. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  17959. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  17960. * 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.
  17961. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  17962. * 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
  17963. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17964. * 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).
  17965. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17966. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17967. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17968. */
  17969. static CreateLathe(name: string, options: {
  17970. shape: Vector3[];
  17971. radius?: number;
  17972. tessellation?: number;
  17973. arc?: number;
  17974. closed?: boolean;
  17975. updatable?: boolean;
  17976. sideOrientation?: number;
  17977. frontUVs?: Vector4;
  17978. backUVs?: Vector4;
  17979. cap?: number;
  17980. invertUV?: boolean;
  17981. }, scene: Scene): Mesh;
  17982. /**
  17983. * Creates a plane mesh.
  17984. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  17985. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  17986. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  17987. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  17988. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17989. * 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).
  17990. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17991. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17992. */
  17993. static CreatePlane(name: string, options: {
  17994. size?: number;
  17995. width?: number;
  17996. height?: number;
  17997. sideOrientation?: number;
  17998. frontUVs?: Vector4;
  17999. backUVs?: Vector4;
  18000. updatable?: boolean;
  18001. sourcePlane?: Plane;
  18002. }, scene: Scene): Mesh;
  18003. /**
  18004. * Creates a ground mesh.
  18005. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  18006. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  18007. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  18008. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18009. */
  18010. static CreateGround(name: string, options: {
  18011. width?: number;
  18012. height?: number;
  18013. subdivisions?: number;
  18014. subdivisionsX?: number;
  18015. subdivisionsY?: number;
  18016. updatable?: boolean;
  18017. }, scene: any): Mesh;
  18018. /**
  18019. * Creates a tiled ground mesh.
  18020. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  18021. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  18022. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  18023. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  18024. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  18025. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  18026. * numbers of subdivisions on the ground width and height of each tile.
  18027. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18028. */
  18029. static CreateTiledGround(name: string, options: {
  18030. xmin: number;
  18031. zmin: number;
  18032. xmax: number;
  18033. zmax: number;
  18034. subdivisions?: {
  18035. w: number;
  18036. h: number;
  18037. };
  18038. precision?: {
  18039. w: number;
  18040. h: number;
  18041. };
  18042. updatable?: boolean;
  18043. }, scene: Scene): Mesh;
  18044. /**
  18045. * Creates a ground mesh from a height map.
  18046. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  18047. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  18048. * The parameter `url` sets the URL of the height map image resource.
  18049. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  18050. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  18051. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  18052. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  18053. * 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.
  18054. * 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).
  18055. * This function is passed the newly built mesh :
  18056. * ```javascript
  18057. * function(mesh) { // do things
  18058. * return; }
  18059. * ```
  18060. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18061. */
  18062. static CreateGroundFromHeightMap(name: string, url: string, options: {
  18063. width?: number;
  18064. height?: number;
  18065. subdivisions?: number;
  18066. minHeight?: number;
  18067. maxHeight?: number;
  18068. colorFilter?: Color3;
  18069. updatable?: boolean;
  18070. onReady?: (mesh: GroundMesh) => void;
  18071. }, scene: Scene): GroundMesh;
  18072. /**
  18073. * Creates a polygon mesh.
  18074. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  18075. * 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.
  18076. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18077. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18078. * 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).
  18079. * Remember you can only change the shape positions, not their number when updating a polygon.
  18080. */
  18081. static CreatePolygon(name: string, options: {
  18082. shape: Vector3[];
  18083. holes?: Vector3[][];
  18084. depth?: number;
  18085. faceUV?: Vector4[];
  18086. faceColors?: Color4[];
  18087. updatable?: boolean;
  18088. sideOrientation?: number;
  18089. frontUVs?: Vector4;
  18090. backUVs?: Vector4;
  18091. }, scene: Scene): Mesh;
  18092. /**
  18093. * Creates an extruded polygon mesh, with depth in the Y direction.
  18094. * 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).
  18095. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  18096. */
  18097. static ExtrudePolygon(name: string, options: {
  18098. shape: Vector3[];
  18099. holes?: Vector3[][];
  18100. depth?: number;
  18101. faceUV?: Vector4[];
  18102. faceColors?: Color4[];
  18103. updatable?: boolean;
  18104. sideOrientation?: number;
  18105. frontUVs?: Vector4;
  18106. backUVs?: Vector4;
  18107. }, scene: Scene): Mesh;
  18108. /**
  18109. * Creates a tube mesh.
  18110. * 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.
  18111. *
  18112. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  18113. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  18114. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  18115. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  18116. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  18117. * 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.
  18118. * It must return a radius value (positive float) :
  18119. * ```javascript
  18120. * var radiusFunction = function(i, distance) {
  18121. * // do things
  18122. * return radius; }
  18123. * ```
  18124. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  18125. * 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
  18126. * 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
  18127. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18128. * 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).
  18129. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18130. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18131. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18132. */
  18133. static CreateTube(name: string, options: {
  18134. path: Vector3[];
  18135. radius?: number;
  18136. tessellation?: number;
  18137. radiusFunction?: {
  18138. (i: number, distance: number): number;
  18139. };
  18140. cap?: number;
  18141. arc?: number;
  18142. updatable?: boolean;
  18143. sideOrientation?: number;
  18144. frontUVs?: Vector4;
  18145. backUVs?: Vector4;
  18146. instance?: Mesh;
  18147. invertUV?: boolean;
  18148. }, scene: Scene): Mesh;
  18149. /**
  18150. * Creates a polyhedron mesh.
  18151. *
  18152. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  18153. * 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
  18154. * to choose the wanted type.
  18155. * The parameter `size` (positive float, default 1) sets the polygon size.
  18156. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  18157. * 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`.
  18158. * 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
  18159. * 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)`).
  18160. * 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
  18161. * 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.
  18162. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18163. * 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).
  18164. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18165. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18166. */
  18167. static CreatePolyhedron(name: string, options: {
  18168. type?: number;
  18169. size?: number;
  18170. sizeX?: number;
  18171. sizeY?: number;
  18172. sizeZ?: number;
  18173. custom?: any;
  18174. faceUV?: Vector4[];
  18175. faceColors?: Color4[];
  18176. flat?: boolean;
  18177. updatable?: boolean;
  18178. sideOrientation?: number;
  18179. frontUVs?: Vector4;
  18180. backUVs?: Vector4;
  18181. }, scene: Scene): Mesh;
  18182. /**
  18183. * Creates a decal mesh.
  18184. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  18185. * 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.
  18186. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  18187. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  18188. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  18189. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  18190. */
  18191. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  18192. position?: Vector3;
  18193. normal?: Vector3;
  18194. size?: Vector3;
  18195. angle?: number;
  18196. }): Mesh;
  18197. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  18198. }
  18199. }
  18200. declare module BABYLON {
  18201. class MeshLODLevel {
  18202. distance: number;
  18203. mesh: Mesh;
  18204. constructor(distance: number, mesh: Mesh);
  18205. }
  18206. }
  18207. declare module BABYLON {
  18208. /**
  18209. * A simplifier interface for future simplification implementations.
  18210. */
  18211. interface ISimplifier {
  18212. /**
  18213. * Simplification of a given mesh according to the given settings.
  18214. * Since this requires computation, it is assumed that the function runs async.
  18215. * @param settings The settings of the simplification, including quality and distance
  18216. * @param successCallback A callback that will be called after the mesh was simplified.
  18217. * @param errorCallback in case of an error, this callback will be called. optional.
  18218. */
  18219. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  18220. }
  18221. /**
  18222. * Expected simplification settings.
  18223. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  18224. */
  18225. interface ISimplificationSettings {
  18226. quality: number;
  18227. distance: number;
  18228. optimizeMesh?: boolean;
  18229. }
  18230. class SimplificationSettings implements ISimplificationSettings {
  18231. quality: number;
  18232. distance: number;
  18233. optimizeMesh: boolean | undefined;
  18234. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  18235. }
  18236. interface ISimplificationTask {
  18237. settings: Array<ISimplificationSettings>;
  18238. simplificationType: SimplificationType;
  18239. mesh: Mesh;
  18240. successCallback?: () => void;
  18241. parallelProcessing: boolean;
  18242. }
  18243. class SimplificationQueue {
  18244. private _simplificationArray;
  18245. running: boolean;
  18246. constructor();
  18247. addTask(task: ISimplificationTask): void;
  18248. executeNext(): void;
  18249. runSimplification(task: ISimplificationTask): void;
  18250. private getSimplifier(task);
  18251. }
  18252. /**
  18253. * The implemented types of simplification.
  18254. * At the moment only Quadratic Error Decimation is implemented.
  18255. */
  18256. enum SimplificationType {
  18257. QUADRATIC = 0,
  18258. }
  18259. class DecimationTriangle {
  18260. vertices: Array<DecimationVertex>;
  18261. normal: Vector3;
  18262. error: Array<number>;
  18263. deleted: boolean;
  18264. isDirty: boolean;
  18265. borderFactor: number;
  18266. deletePending: boolean;
  18267. originalOffset: number;
  18268. constructor(vertices: Array<DecimationVertex>);
  18269. }
  18270. class DecimationVertex {
  18271. position: Vector3;
  18272. id: number;
  18273. q: QuadraticMatrix;
  18274. isBorder: boolean;
  18275. triangleStart: number;
  18276. triangleCount: number;
  18277. originalOffsets: Array<number>;
  18278. constructor(position: Vector3, id: number);
  18279. updatePosition(newPosition: Vector3): void;
  18280. }
  18281. class QuadraticMatrix {
  18282. data: Array<number>;
  18283. constructor(data?: Array<number>);
  18284. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  18285. addInPlace(matrix: QuadraticMatrix): void;
  18286. addArrayInPlace(data: Array<number>): void;
  18287. add(matrix: QuadraticMatrix): QuadraticMatrix;
  18288. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  18289. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  18290. }
  18291. class Reference {
  18292. vertexId: number;
  18293. triangleId: number;
  18294. constructor(vertexId: number, triangleId: number);
  18295. }
  18296. /**
  18297. * An implementation of the Quadratic Error simplification algorithm.
  18298. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  18299. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  18300. * @author RaananW
  18301. */
  18302. class QuadraticErrorSimplification implements ISimplifier {
  18303. private _mesh;
  18304. private triangles;
  18305. private vertices;
  18306. private references;
  18307. private _reconstructedMesh;
  18308. syncIterations: number;
  18309. aggressiveness: number;
  18310. decimationIterations: number;
  18311. boundingBoxEpsilon: number;
  18312. constructor(_mesh: Mesh);
  18313. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  18314. private runDecimation(settings, submeshIndex, successCallback);
  18315. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  18316. private init(callback);
  18317. private reconstructMesh(submeshIndex);
  18318. private initDecimatedMesh();
  18319. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  18320. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  18321. private identifyBorder();
  18322. private updateMesh(identifyBorders?);
  18323. private vertexError(q, point);
  18324. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  18325. }
  18326. }
  18327. declare module BABYLON {
  18328. class Polygon {
  18329. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  18330. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  18331. static Parse(input: string): Vector2[];
  18332. static StartingAt(x: number, y: number): Path2;
  18333. }
  18334. class PolygonMeshBuilder {
  18335. private _points;
  18336. private _outlinepoints;
  18337. private _holes;
  18338. private _name;
  18339. private _scene;
  18340. private _epoints;
  18341. private _eholes;
  18342. private _addToepoint(points);
  18343. constructor(name: string, contours: Path2, scene: Scene);
  18344. constructor(name: string, contours: Vector2[], scene: Scene);
  18345. addHole(hole: Vector2[]): PolygonMeshBuilder;
  18346. build(updatable?: boolean, depth?: number): Mesh;
  18347. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  18348. }
  18349. }
  18350. declare module BABYLON {
  18351. class BaseSubMesh {
  18352. _materialDefines: Nullable<MaterialDefines>;
  18353. _materialEffect: Nullable<Effect>;
  18354. readonly effect: Nullable<Effect>;
  18355. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  18356. }
  18357. class SubMesh extends BaseSubMesh implements ICullable {
  18358. materialIndex: number;
  18359. verticesStart: number;
  18360. verticesCount: number;
  18361. indexStart: number;
  18362. indexCount: number;
  18363. linesIndexCount: number;
  18364. private _mesh;
  18365. private _renderingMesh;
  18366. private _boundingInfo;
  18367. private _linesIndexBuffer;
  18368. _lastColliderWorldVertices: Nullable<Vector3[]>;
  18369. _trianglePlanes: Plane[];
  18370. _lastColliderTransformMatrix: Matrix;
  18371. _renderId: number;
  18372. _alphaIndex: number;
  18373. _distanceToCamera: number;
  18374. _id: number;
  18375. private _currentMaterial;
  18376. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  18377. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  18378. readonly IsGlobal: boolean;
  18379. /**
  18380. * Returns the submesh BoudingInfo object.
  18381. */
  18382. getBoundingInfo(): BoundingInfo;
  18383. /**
  18384. * Sets the submesh BoundingInfo.
  18385. * Return the SubMesh.
  18386. */
  18387. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  18388. /**
  18389. * Returns the mesh of the current submesh.
  18390. */
  18391. getMesh(): AbstractMesh;
  18392. /**
  18393. * Returns the rendering mesh of the submesh.
  18394. */
  18395. getRenderingMesh(): Mesh;
  18396. /**
  18397. * Returns the submesh material.
  18398. */
  18399. getMaterial(): Nullable<Material>;
  18400. /**
  18401. * Sets a new updated BoundingInfo object to the submesh.
  18402. * Returns the SubMesh.
  18403. */
  18404. refreshBoundingInfo(): SubMesh;
  18405. _checkCollision(collider: Collider): boolean;
  18406. /**
  18407. * Updates the submesh BoundingInfo.
  18408. * Returns the Submesh.
  18409. */
  18410. updateBoundingInfo(world: Matrix): SubMesh;
  18411. /**
  18412. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  18413. * Boolean returned.
  18414. */
  18415. isInFrustum(frustumPlanes: Plane[]): boolean;
  18416. /**
  18417. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  18418. * Boolean returned.
  18419. */
  18420. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18421. /**
  18422. * Renders the submesh.
  18423. * Returns it.
  18424. */
  18425. render(enableAlphaMode: boolean): SubMesh;
  18426. /**
  18427. * Returns a new Index Buffer.
  18428. * Type returned : WebGLBuffer.
  18429. */
  18430. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  18431. /**
  18432. * True is the passed Ray intersects the submesh bounding box.
  18433. * Boolean returned.
  18434. */
  18435. canIntersects(ray: Ray): boolean;
  18436. /**
  18437. * Returns an object IntersectionInfo.
  18438. */
  18439. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  18440. _rebuild(): void;
  18441. /**
  18442. * Creates a new Submesh from the passed Mesh.
  18443. */
  18444. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  18445. /**
  18446. * Disposes the Submesh.
  18447. * Returns nothing.
  18448. */
  18449. dispose(): void;
  18450. /**
  18451. * Creates a new Submesh from the passed parameters :
  18452. * - materialIndex (integer) : the index of the main mesh material.
  18453. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  18454. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  18455. * - mesh (Mesh) : the main mesh to create the submesh from.
  18456. * - renderingMesh (optional Mesh) : rendering mesh.
  18457. */
  18458. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  18459. }
  18460. }
  18461. declare module BABYLON {
  18462. class TransformNode extends Node {
  18463. static BILLBOARDMODE_NONE: number;
  18464. static BILLBOARDMODE_X: number;
  18465. static BILLBOARDMODE_Y: number;
  18466. static BILLBOARDMODE_Z: number;
  18467. static BILLBOARDMODE_ALL: number;
  18468. private _forward;
  18469. private _forwardInverted;
  18470. private _up;
  18471. private _right;
  18472. private _rightInverted;
  18473. private _rotation;
  18474. private _rotationQuaternion;
  18475. protected _scaling: Vector3;
  18476. protected _isDirty: boolean;
  18477. private _transformToBoneReferal;
  18478. billboardMode: number;
  18479. scalingDeterminant: number;
  18480. infiniteDistance: boolean;
  18481. position: Vector3;
  18482. _poseMatrix: Matrix;
  18483. private _localWorld;
  18484. _worldMatrix: Matrix;
  18485. _worldMatrixDeterminant: number;
  18486. private _absolutePosition;
  18487. private _pivotMatrix;
  18488. private _pivotMatrixInverse;
  18489. private _postMultiplyPivotMatrix;
  18490. protected _isWorldMatrixFrozen: boolean;
  18491. /**
  18492. * An event triggered after the world matrix is updated
  18493. */
  18494. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  18495. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  18496. /**
  18497. * Gets a string idenfifying the name of the class
  18498. * @returns "TransformNode" string
  18499. */
  18500. getClassName(): string;
  18501. /**
  18502. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  18503. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  18504. * Default : (0.0, 0.0, 0.0)
  18505. */
  18506. rotation: Vector3;
  18507. /**
  18508. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  18509. * Default : (1.0, 1.0, 1.0)
  18510. */
  18511. /**
  18512. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  18513. * Default : (1.0, 1.0, 1.0)
  18514. */
  18515. scaling: Vector3;
  18516. /**
  18517. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  18518. * It's null by default.
  18519. * 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)
  18520. */
  18521. rotationQuaternion: Nullable<Quaternion>;
  18522. /**
  18523. * The forward direction of that transform in world space.
  18524. */
  18525. readonly forward: Vector3;
  18526. /**
  18527. * The up direction of that transform in world space.
  18528. */
  18529. readonly up: Vector3;
  18530. /**
  18531. * The right direction of that transform in world space.
  18532. */
  18533. readonly right: Vector3;
  18534. /**
  18535. * Returns the latest update of the World matrix
  18536. * Returns a Matrix.
  18537. */
  18538. getWorldMatrix(): Matrix;
  18539. /**
  18540. * Returns the latest update of the World matrix determinant.
  18541. */
  18542. protected _getWorldMatrixDeterminant(): number;
  18543. /**
  18544. * Returns directly the latest state of the mesh World matrix.
  18545. * A Matrix is returned.
  18546. */
  18547. readonly worldMatrixFromCache: Matrix;
  18548. /**
  18549. * Copies the paramater passed Matrix into the mesh Pose matrix.
  18550. * Returns the TransformNode.
  18551. */
  18552. updatePoseMatrix(matrix: Matrix): TransformNode;
  18553. /**
  18554. * Returns the mesh Pose matrix.
  18555. * Returned object : Matrix
  18556. */
  18557. getPoseMatrix(): Matrix;
  18558. _isSynchronized(): boolean;
  18559. _initCache(): void;
  18560. markAsDirty(property: string): TransformNode;
  18561. /**
  18562. * Returns the current mesh absolute position.
  18563. * Retuns a Vector3.
  18564. */
  18565. readonly absolutePosition: Vector3;
  18566. /**
  18567. * Sets a new matrix to apply before all other transformation
  18568. * @param matrix defines the transform matrix
  18569. * @returns the current TransformNode
  18570. */
  18571. setPreTransformMatrix(matrix: Matrix): TransformNode;
  18572. /**
  18573. * Sets a new pivot matrix to the current node
  18574. * @param matrix defines the new pivot matrix to use
  18575. * @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
  18576. * @returns the current TransformNode
  18577. */
  18578. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  18579. /**
  18580. * Returns the mesh pivot matrix.
  18581. * Default : Identity.
  18582. * A Matrix is returned.
  18583. */
  18584. getPivotMatrix(): Matrix;
  18585. /**
  18586. * Prevents the World matrix to be computed any longer.
  18587. * Returns the TransformNode.
  18588. */
  18589. freezeWorldMatrix(): TransformNode;
  18590. /**
  18591. * Allows back the World matrix computation.
  18592. * Returns the TransformNode.
  18593. */
  18594. unfreezeWorldMatrix(): this;
  18595. /**
  18596. * True if the World matrix has been frozen.
  18597. * Returns a boolean.
  18598. */
  18599. readonly isWorldMatrixFrozen: boolean;
  18600. /**
  18601. * Retuns the mesh absolute position in the World.
  18602. * Returns a Vector3.
  18603. */
  18604. getAbsolutePosition(): Vector3;
  18605. /**
  18606. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  18607. * Returns the TransformNode.
  18608. */
  18609. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18610. /**
  18611. * Sets the mesh position in its local space.
  18612. * Returns the TransformNode.
  18613. */
  18614. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  18615. /**
  18616. * Returns the mesh position in the local space from the current World matrix values.
  18617. * Returns a new Vector3.
  18618. */
  18619. getPositionExpressedInLocalSpace(): Vector3;
  18620. /**
  18621. * Translates the mesh along the passed Vector3 in its local space.
  18622. * Returns the TransformNode.
  18623. */
  18624. locallyTranslate(vector3: Vector3): TransformNode;
  18625. private static _lookAtVectorCache;
  18626. /**
  18627. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  18628. * @param targetPoint the position (must be in same space as current mesh) to look at
  18629. * @param yawCor optional yaw (y-axis) correction in radians
  18630. * @param pitchCor optional pitch (x-axis) correction in radians
  18631. * @param rollCor optional roll (z-axis) correction in radians
  18632. * @param space the choosen space of the target
  18633. * @returns the TransformNode.
  18634. */
  18635. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  18636. /**
  18637. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  18638. * This Vector3 is expressed in the World space.
  18639. */
  18640. getDirection(localAxis: Vector3): Vector3;
  18641. /**
  18642. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  18643. * localAxis is expressed in the mesh local space.
  18644. * result is computed in the Wordl space from the mesh World matrix.
  18645. * Returns the TransformNode.
  18646. */
  18647. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  18648. /**
  18649. * Sets a new pivot point to the current node
  18650. * @param point defines the new pivot point to use
  18651. * @param space defines if the point is in world or local space (local by default)
  18652. * @returns the current TransformNode
  18653. */
  18654. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  18655. /**
  18656. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  18657. */
  18658. getPivotPoint(): Vector3;
  18659. /**
  18660. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  18661. * Returns the TransformNode.
  18662. */
  18663. getPivotPointToRef(result: Vector3): TransformNode;
  18664. /**
  18665. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  18666. */
  18667. getAbsolutePivotPoint(): Vector3;
  18668. /**
  18669. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  18670. * Returns the TransformNode.
  18671. */
  18672. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  18673. /**
  18674. * Defines the passed node as the parent of the current node.
  18675. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  18676. * Returns the TransformNode.
  18677. */
  18678. setParent(node: Nullable<Node>): TransformNode;
  18679. private _nonUniformScaling;
  18680. readonly nonUniformScaling: boolean;
  18681. _updateNonUniformScalingState(value: boolean): boolean;
  18682. /**
  18683. * Attach the current TransformNode to another TransformNode associated with a bone
  18684. * @param bone Bone affecting the TransformNode
  18685. * @param affectedTransformNode TransformNode associated with the bone
  18686. */
  18687. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  18688. detachFromBone(): TransformNode;
  18689. private static _rotationAxisCache;
  18690. /**
  18691. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  18692. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  18693. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  18694. * The passed axis is also normalized.
  18695. * Returns the TransformNode.
  18696. */
  18697. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18698. /**
  18699. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  18700. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  18701. * The passed axis is also normalized.
  18702. * Returns the TransformNode.
  18703. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  18704. */
  18705. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  18706. /**
  18707. * Translates the mesh along the axis vector for the passed distance in the given space.
  18708. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  18709. * Returns the TransformNode.
  18710. */
  18711. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18712. /**
  18713. * Adds a rotation step to the mesh current rotation.
  18714. * x, y, z are Euler angles expressed in radians.
  18715. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  18716. * This means this rotation is made in the mesh local space only.
  18717. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  18718. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  18719. * ```javascript
  18720. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  18721. * ```
  18722. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  18723. * 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.
  18724. * Returns the TransformNode.
  18725. */
  18726. addRotation(x: number, y: number, z: number): TransformNode;
  18727. /**
  18728. * Computes the mesh World matrix and returns it.
  18729. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  18730. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  18731. * If the parameter `force`is set to `true`, the actual computation is done.
  18732. * Returns the mesh World Matrix.
  18733. */
  18734. computeWorldMatrix(force?: boolean): Matrix;
  18735. protected _afterComputeWorldMatrix(): void;
  18736. /**
  18737. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  18738. * @param func: callback function to add
  18739. *
  18740. * Returns the TransformNode.
  18741. */
  18742. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  18743. /**
  18744. * Removes a registered callback function.
  18745. * Returns the TransformNode.
  18746. */
  18747. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  18748. /**
  18749. * Clone the current transform node
  18750. * Returns the new transform node
  18751. * @param name Name of the new clone
  18752. * @param newParent New parent for the clone
  18753. * @param doNotCloneChildren Do not clone children hierarchy
  18754. */
  18755. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  18756. serialize(currentSerializationObject?: any): any;
  18757. /**
  18758. * Returns a new TransformNode object parsed from the source provided.
  18759. * The parameter `parsedMesh` is the source.
  18760. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  18761. */
  18762. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  18763. /**
  18764. * Releases resources associated with this transform node.
  18765. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18766. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18767. */
  18768. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18769. }
  18770. }
  18771. declare module BABYLON {
  18772. class VertexBuffer {
  18773. private _buffer;
  18774. private _kind;
  18775. private _size;
  18776. private _ownsBuffer;
  18777. private _instanced;
  18778. private _instanceDivisor;
  18779. /**
  18780. * The byte type.
  18781. */
  18782. static readonly BYTE: number;
  18783. /**
  18784. * The unsigned byte type.
  18785. */
  18786. static readonly UNSIGNED_BYTE: number;
  18787. /**
  18788. * The short type.
  18789. */
  18790. static readonly SHORT: number;
  18791. /**
  18792. * The unsigned short type.
  18793. */
  18794. static readonly UNSIGNED_SHORT: number;
  18795. /**
  18796. * The integer type.
  18797. */
  18798. static readonly INT: number;
  18799. /**
  18800. * The unsigned integer type.
  18801. */
  18802. static readonly UNSIGNED_INT: number;
  18803. /**
  18804. * The float type.
  18805. */
  18806. static readonly FLOAT: number;
  18807. /**
  18808. * Gets or sets the instance divisor when in instanced mode
  18809. */
  18810. instanceDivisor: number;
  18811. /**
  18812. * Gets the byte stride.
  18813. */
  18814. readonly byteStride: number;
  18815. /**
  18816. * Gets the byte offset.
  18817. */
  18818. readonly byteOffset: number;
  18819. /**
  18820. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  18821. */
  18822. readonly normalized: boolean;
  18823. /**
  18824. * Gets the data type of each component in the array.
  18825. */
  18826. readonly type: number;
  18827. /**
  18828. * Constructor
  18829. * @param engine the engine
  18830. * @param data the data to use for this vertex buffer
  18831. * @param kind the vertex buffer kind
  18832. * @param updatable whether the data is updatable
  18833. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  18834. * @param stride the stride (optional)
  18835. * @param instanced whether the buffer is instanced (optional)
  18836. * @param offset the offset of the data (optional)
  18837. * @param size the number of components (optional)
  18838. * @param type the type of the component (optional)
  18839. * @param normalized whether the data contains normalized data (optional)
  18840. * @param useBytes set to true if stride and offset are in bytes (optional)
  18841. */
  18842. 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);
  18843. _rebuild(): void;
  18844. /**
  18845. * Returns the kind of the VertexBuffer (string).
  18846. */
  18847. getKind(): string;
  18848. /**
  18849. * Boolean : is the VertexBuffer updatable ?
  18850. */
  18851. isUpdatable(): boolean;
  18852. /**
  18853. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  18854. */
  18855. getData(): Nullable<DataArray>;
  18856. /**
  18857. * Returns the WebGLBuffer associated to the VertexBuffer.
  18858. */
  18859. getBuffer(): Nullable<WebGLBuffer>;
  18860. /**
  18861. * Returns the stride as a multiple of the type byte length.
  18862. * DEPRECATED. Use byteStride instead.
  18863. */
  18864. getStrideSize(): number;
  18865. /**
  18866. * Returns the offset as a multiple of the type byte length.
  18867. * DEPRECATED. Use byteOffset instead.
  18868. */
  18869. getOffset(): number;
  18870. /**
  18871. * Returns the number of components per vertex attribute (integer).
  18872. */
  18873. getSize(): number;
  18874. /**
  18875. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  18876. */
  18877. getIsInstanced(): boolean;
  18878. /**
  18879. * Returns the instancing divisor, zero for non-instanced (integer).
  18880. */
  18881. getInstanceDivisor(): number;
  18882. /**
  18883. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  18884. * Returns the created WebGLBuffer.
  18885. */
  18886. create(data?: DataArray): void;
  18887. /**
  18888. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  18889. * This function will create a new buffer if the current one is not updatable
  18890. * Returns the updated WebGLBuffer.
  18891. */
  18892. update(data: DataArray): void;
  18893. /**
  18894. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  18895. * Returns the directly updated WebGLBuffer.
  18896. */
  18897. updateDirectly(data: DataArray, offset: number): void;
  18898. /**
  18899. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  18900. */
  18901. dispose(): void;
  18902. /**
  18903. * Enumerates each value of this vertex buffer as numbers.
  18904. * @param count the number of values to enumerate
  18905. * @param callback the callback function called for each value
  18906. */
  18907. forEach(count: number, callback: (value: number, index: number) => void): void;
  18908. private static _PositionKind;
  18909. private static _NormalKind;
  18910. private static _TangentKind;
  18911. private static _UVKind;
  18912. private static _UV2Kind;
  18913. private static _UV3Kind;
  18914. private static _UV4Kind;
  18915. private static _UV5Kind;
  18916. private static _UV6Kind;
  18917. private static _ColorKind;
  18918. private static _MatricesIndicesKind;
  18919. private static _MatricesWeightsKind;
  18920. private static _MatricesIndicesExtraKind;
  18921. private static _MatricesWeightsExtraKind;
  18922. static readonly PositionKind: string;
  18923. static readonly NormalKind: string;
  18924. static readonly TangentKind: string;
  18925. static readonly UVKind: string;
  18926. static readonly UV2Kind: string;
  18927. static readonly UV3Kind: string;
  18928. static readonly UV4Kind: string;
  18929. static readonly UV5Kind: string;
  18930. static readonly UV6Kind: string;
  18931. static readonly ColorKind: string;
  18932. static readonly MatricesIndicesKind: string;
  18933. static readonly MatricesWeightsKind: string;
  18934. static readonly MatricesIndicesExtraKind: string;
  18935. static readonly MatricesWeightsExtraKind: string;
  18936. /**
  18937. * Deduces the stride given a kind.
  18938. * @param kind The kind string to deduce
  18939. * @returns The deduced stride
  18940. */
  18941. static DeduceStride(kind: string): number;
  18942. /**
  18943. * Gets the byte length of the given type.
  18944. * @param type the type
  18945. * @returns the number of bytes
  18946. */
  18947. static GetTypeByteLength(type: number): number;
  18948. /**
  18949. * Enumerates each value of the given parameters as numbers.
  18950. * @param data the data to enumerate
  18951. * @param byteOffset the byte offset of the data
  18952. * @param byteStride the byte stride of the data
  18953. * @param componentCount the number of components per element
  18954. * @param componentType the type of the component
  18955. * @param count the total number of components
  18956. * @param normalized whether the data is normalized
  18957. * @param callback the callback function called for each value
  18958. */
  18959. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  18960. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  18961. }
  18962. }
  18963. declare module BABYLON {
  18964. class MorphTarget {
  18965. name: string;
  18966. animations: Animation[];
  18967. private _positions;
  18968. private _normals;
  18969. private _tangents;
  18970. private _influence;
  18971. onInfluenceChanged: Observable<boolean>;
  18972. influence: number;
  18973. constructor(name: string, influence?: number);
  18974. readonly hasPositions: boolean;
  18975. readonly hasNormals: boolean;
  18976. readonly hasTangents: boolean;
  18977. setPositions(data: Nullable<FloatArray>): void;
  18978. getPositions(): Nullable<FloatArray>;
  18979. setNormals(data: Nullable<FloatArray>): void;
  18980. getNormals(): Nullable<FloatArray>;
  18981. setTangents(data: Nullable<FloatArray>): void;
  18982. getTangents(): Nullable<FloatArray>;
  18983. /**
  18984. * Serializes the current target into a Serialization object.
  18985. * Returns the serialized object.
  18986. */
  18987. serialize(): any;
  18988. static Parse(serializationObject: any): MorphTarget;
  18989. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18990. }
  18991. }
  18992. declare module BABYLON {
  18993. class MorphTargetManager {
  18994. private _targets;
  18995. private _targetObservable;
  18996. private _activeTargets;
  18997. private _scene;
  18998. private _influences;
  18999. private _supportsNormals;
  19000. private _supportsTangents;
  19001. private _vertexCount;
  19002. private _uniqueId;
  19003. private _tempInfluences;
  19004. constructor(scene?: Nullable<Scene>);
  19005. readonly uniqueId: number;
  19006. readonly vertexCount: number;
  19007. readonly supportsNormals: boolean;
  19008. readonly supportsTangents: boolean;
  19009. readonly numTargets: number;
  19010. readonly numInfluencers: number;
  19011. readonly influences: Float32Array;
  19012. getActiveTarget(index: number): MorphTarget;
  19013. getTarget(index: number): MorphTarget;
  19014. addTarget(target: MorphTarget): void;
  19015. removeTarget(target: MorphTarget): void;
  19016. /**
  19017. * Serializes the current manager into a Serialization object.
  19018. * Returns the serialized object.
  19019. */
  19020. serialize(): any;
  19021. private _syncActiveTargets(needUpdate);
  19022. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19023. }
  19024. }
  19025. declare module BABYLON {
  19026. /**
  19027. * This represents a GPU particle system in Babylon
  19028. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  19029. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  19030. */
  19031. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  19032. /**
  19033. * The id of the Particle system.
  19034. */
  19035. id: string;
  19036. /**
  19037. * The friendly name of the Particle system.
  19038. */
  19039. name: string;
  19040. /**
  19041. * The emitter represents the Mesh or position we are attaching the particle system to.
  19042. */
  19043. emitter: Nullable<AbstractMesh | Vector3>;
  19044. /**
  19045. * The rendering group used by the Particle system to chose when to render.
  19046. */
  19047. renderingGroupId: number;
  19048. /**
  19049. * The layer mask we are rendering the particles through.
  19050. */
  19051. layerMask: number;
  19052. private _capacity;
  19053. private _activeCount;
  19054. private _currentActiveCount;
  19055. private _renderEffect;
  19056. private _updateEffect;
  19057. private _buffer0;
  19058. private _buffer1;
  19059. private _spriteBuffer;
  19060. private _updateVAO;
  19061. private _renderVAO;
  19062. private _targetIndex;
  19063. private _sourceBuffer;
  19064. private _targetBuffer;
  19065. private _scene;
  19066. private _engine;
  19067. private _currentRenderId;
  19068. private _started;
  19069. private _stopped;
  19070. private _timeDelta;
  19071. private _randomTexture;
  19072. private readonly _attributesStrideSize;
  19073. private _updateEffectOptions;
  19074. private _randomTextureSize;
  19075. private _actualFrame;
  19076. /**
  19077. * List of animations used by the particle system.
  19078. */
  19079. animations: Animation[];
  19080. /**
  19081. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  19082. */
  19083. static readonly IsSupported: boolean;
  19084. /**
  19085. * An event triggered when the system is disposed.
  19086. */
  19087. onDisposeObservable: Observable<GPUParticleSystem>;
  19088. /**
  19089. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19090. */
  19091. updateSpeed: number;
  19092. /**
  19093. * The amount of time the particle system is running (depends of the overall update speed).
  19094. */
  19095. targetStopDuration: number;
  19096. /**
  19097. * The texture used to render each particle. (this can be a spritesheet)
  19098. */
  19099. particleTexture: Nullable<Texture>;
  19100. /**
  19101. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19102. */
  19103. blendMode: number;
  19104. /**
  19105. * Minimum life time of emitting particles.
  19106. */
  19107. minLifeTime: number;
  19108. /**
  19109. * Maximum life time of emitting particles.
  19110. */
  19111. maxLifeTime: number;
  19112. /**
  19113. * Minimum Size of emitting particles.
  19114. */
  19115. minSize: number;
  19116. /**
  19117. * Maximum Size of emitting particles.
  19118. */
  19119. maxSize: number;
  19120. /**
  19121. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19122. */
  19123. color1: Color4;
  19124. /**
  19125. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19126. */
  19127. color2: Color4;
  19128. /**
  19129. * Color the particle will have at the end of its lifetime.
  19130. */
  19131. colorDead: Color4;
  19132. /**
  19133. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19134. */
  19135. emitRate: number;
  19136. /**
  19137. * You can use gravity if you want to give an orientation to your particles.
  19138. */
  19139. gravity: Vector3;
  19140. /**
  19141. * Minimum power of emitting particles.
  19142. */
  19143. minEmitPower: number;
  19144. /**
  19145. * Maximum power of emitting particles.
  19146. */
  19147. maxEmitPower: number;
  19148. /**
  19149. * The particle emitter type defines the emitter used by the particle system.
  19150. * It can be for example box, sphere, or cone...
  19151. */
  19152. particleEmitterType: Nullable<IParticleEmitterType>;
  19153. /**
  19154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19155. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19156. */
  19157. direction1: Vector3;
  19158. /**
  19159. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19160. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19161. */
  19162. direction2: Vector3;
  19163. /**
  19164. * 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.
  19165. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19166. */
  19167. minEmitBox: Vector3;
  19168. /**
  19169. * 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.
  19170. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19171. */
  19172. maxEmitBox: Vector3;
  19173. /**
  19174. * Gets the maximum number of particles active at the same time.
  19175. * @returns The max number of active particles.
  19176. */
  19177. getCapacity(): number;
  19178. /**
  19179. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19180. * to override the particles.
  19181. */
  19182. forceDepthWrite: boolean;
  19183. /**
  19184. * Gets or set the number of active particles
  19185. */
  19186. activeParticleCount: number;
  19187. /**
  19188. * Is this system ready to be used/rendered
  19189. * @return true if the system is ready
  19190. */
  19191. isReady(): boolean;
  19192. /**
  19193. * Gets Wether the system has been started.
  19194. * @returns True if it has been started, otherwise false.
  19195. */
  19196. isStarted(): boolean;
  19197. /**
  19198. * Starts the particle system and begins to emit.
  19199. */
  19200. start(): void;
  19201. /**
  19202. * Stops the particle system.
  19203. */
  19204. stop(): void;
  19205. /**
  19206. * Remove all active particles
  19207. */
  19208. reset(): void;
  19209. /**
  19210. * Returns the string "GPUParticleSystem"
  19211. * @returns a string containing the class name
  19212. */
  19213. getClassName(): string;
  19214. /**
  19215. * Instantiates a GPU particle system.
  19216. * 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.
  19217. * @param name The name of the particle system
  19218. * @param capacity The max number of particles alive at the same time
  19219. * @param scene The scene the particle system belongs to
  19220. */
  19221. constructor(name: string, options: Partial<{
  19222. capacity: number;
  19223. randomTextureSize: number;
  19224. }>, scene: Scene);
  19225. private _createUpdateVAO(source);
  19226. private _createRenderVAO(source, spriteSource);
  19227. private _initialize(force?);
  19228. /** @ignore */
  19229. _recreateUpdateEffect(): void;
  19230. /** @ignore */
  19231. _recreateRenderEffect(): void;
  19232. /**
  19233. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19234. */
  19235. animate(): void;
  19236. /**
  19237. * Renders the particle system in its current state.
  19238. * @returns the current number of particles
  19239. */
  19240. render(): number;
  19241. /**
  19242. * Rebuilds the particle system
  19243. */
  19244. rebuild(): void;
  19245. private _releaseBuffers();
  19246. private _releaseVAOs();
  19247. /**
  19248. * Disposes the particle system and free the associated resources
  19249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19250. */
  19251. dispose(disposeTexture?: boolean): void;
  19252. /**
  19253. * Clones the particle system.
  19254. * @param name The name of the cloned object
  19255. * @param newEmitter The new emitter to use
  19256. * @returns the cloned particle system
  19257. */
  19258. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  19259. /**
  19260. * Serializes the particle system to a JSON object.
  19261. * @returns the JSON object
  19262. */
  19263. serialize(): any;
  19264. /**
  19265. * Parses a JSON object to create a GPU particle system.
  19266. * @param parsedParticleSystem The JSON object to parse
  19267. * @param scene The scene to create the particle system in
  19268. * @param rootUrl The root url to use to load external dependencies like texture
  19269. * @returns the parsed GPU particle system
  19270. */
  19271. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  19272. }
  19273. }
  19274. declare module BABYLON {
  19275. /**
  19276. * Interface representing a particle system in Babylon.
  19277. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19278. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19279. */
  19280. interface IParticleSystem {
  19281. /**
  19282. * The id of the Particle system.
  19283. */
  19284. id: string;
  19285. /**
  19286. * The name of the Particle system.
  19287. */
  19288. name: string;
  19289. /**
  19290. * The emitter represents the Mesh or position we are attaching the particle system to.
  19291. */
  19292. emitter: Nullable<AbstractMesh | Vector3>;
  19293. /**
  19294. * The rendering group used by the Particle system to chose when to render.
  19295. */
  19296. renderingGroupId: number;
  19297. /**
  19298. * The layer mask we are rendering the particles through.
  19299. */
  19300. layerMask: number;
  19301. /**
  19302. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19303. */
  19304. updateSpeed: number;
  19305. /**
  19306. * The amount of time the particle system is running (depends of the overall update speed).
  19307. */
  19308. targetStopDuration: number;
  19309. /**
  19310. * The texture used to render each particle. (this can be a spritesheet)
  19311. */
  19312. particleTexture: Nullable<Texture>;
  19313. /**
  19314. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19315. */
  19316. blendMode: number;
  19317. /**
  19318. * Minimum life time of emitting particles.
  19319. */
  19320. minLifeTime: number;
  19321. /**
  19322. * Maximum life time of emitting particles.
  19323. */
  19324. maxLifeTime: number;
  19325. /**
  19326. * Minimum Size of emitting particles.
  19327. */
  19328. minSize: number;
  19329. /**
  19330. * Maximum Size of emitting particles.
  19331. */
  19332. maxSize: number;
  19333. /**
  19334. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19335. */
  19336. color1: Color4;
  19337. /**
  19338. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19339. */
  19340. color2: Color4;
  19341. /**
  19342. * Color the particle will have at the end of its lifetime.
  19343. */
  19344. colorDead: Color4;
  19345. /**
  19346. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19347. */
  19348. emitRate: number;
  19349. /**
  19350. * You can use gravity if you want to give an orientation to your particles.
  19351. */
  19352. gravity: Vector3;
  19353. /**
  19354. * Minimum power of emitting particles.
  19355. */
  19356. minEmitPower: number;
  19357. /**
  19358. * Maximum power of emitting particles.
  19359. */
  19360. maxEmitPower: number;
  19361. /**
  19362. * The particle emitter type defines the emitter used by the particle system.
  19363. * It can be for example box, sphere, or cone...
  19364. */
  19365. particleEmitterType: Nullable<IParticleEmitterType>;
  19366. /**
  19367. * Gets the maximum number of particles active at the same time.
  19368. * @returns The max number of active particles.
  19369. */
  19370. getCapacity(): number;
  19371. /**
  19372. * Gets Wether the system has been started.
  19373. * @returns True if it has been started, otherwise false.
  19374. */
  19375. isStarted(): boolean;
  19376. /**
  19377. * Gets if the particle system has been started.
  19378. * @return true if the system has been started, otherwise false.
  19379. */
  19380. isStarted(): boolean;
  19381. /**
  19382. * Animates the particle system for this frame.
  19383. */
  19384. animate(): void;
  19385. /**
  19386. * Renders the particle system in its current state.
  19387. * @returns the current number of particles
  19388. */
  19389. render(): number;
  19390. /**
  19391. * Dispose the particle system and frees its associated resources.
  19392. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19393. */
  19394. dispose(disposeTexture?: boolean): void;
  19395. /**
  19396. * Clones the particle system.
  19397. * @param name The name of the cloned object
  19398. * @param newEmitter The new emitter to use
  19399. * @returns the cloned particle system
  19400. */
  19401. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19402. /**
  19403. * Serializes the particle system to a JSON object.
  19404. * @returns the JSON object
  19405. */
  19406. serialize(): any;
  19407. /**
  19408. * Rebuild the particle system
  19409. */
  19410. rebuild(): void;
  19411. /**
  19412. * Starts the particle system and begins to emit.
  19413. */
  19414. start(): void;
  19415. /**
  19416. * Stops the particle system.
  19417. */
  19418. stop(): void;
  19419. /**
  19420. * Remove all active particles
  19421. */
  19422. reset(): void;
  19423. /**
  19424. * Is this system ready to be used/rendered
  19425. * @return true if the system is ready
  19426. */
  19427. isReady(): boolean;
  19428. }
  19429. }
  19430. declare module BABYLON {
  19431. /**
  19432. * A particle represents one of the element emitted by a particle system.
  19433. * This is mainly define by its coordinates, direction, velocity and age.
  19434. */
  19435. class Particle {
  19436. /**
  19437. * particleSystem the particle system the particle belongs to.
  19438. */
  19439. particleSystem: ParticleSystem;
  19440. /**
  19441. * The world position of the particle in the scene.
  19442. */
  19443. position: Vector3;
  19444. /**
  19445. * The world direction of the particle in the scene.
  19446. */
  19447. direction: Vector3;
  19448. /**
  19449. * The color of the particle.
  19450. */
  19451. color: Color4;
  19452. /**
  19453. * The color change of the particle per step.
  19454. */
  19455. colorStep: Color4;
  19456. /**
  19457. * Defines how long will the life of the particle be.
  19458. */
  19459. lifeTime: number;
  19460. /**
  19461. * The current age of the particle.
  19462. */
  19463. age: number;
  19464. /**
  19465. * The current size of the particle.
  19466. */
  19467. size: number;
  19468. /**
  19469. * The current angle of the particle.
  19470. */
  19471. angle: number;
  19472. /**
  19473. * Defines how fast is the angle changing.
  19474. */
  19475. angularSpeed: number;
  19476. /**
  19477. * Defines the cell index used by the particle to be rendered from a sprite.
  19478. */
  19479. cellIndex: number;
  19480. private _currentFrameCounter;
  19481. /**
  19482. * Creates a new instance Particle
  19483. * @param particleSystem the particle system the particle belongs to
  19484. */
  19485. constructor(
  19486. /**
  19487. * particleSystem the particle system the particle belongs to.
  19488. */
  19489. particleSystem: ParticleSystem);
  19490. private updateCellInfoFromSystem();
  19491. /**
  19492. * Defines how the sprite cell index is updated for the particle. This is
  19493. * defined as a callback.
  19494. */
  19495. updateCellIndex: (scaledUpdateSpeed: number) => void;
  19496. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  19497. private _updateCellIndexWithCustomSpeed();
  19498. /**
  19499. * Copy the properties of particle to another one.
  19500. * @param other the particle to copy the information to.
  19501. */
  19502. copyTo(other: Particle): void;
  19503. }
  19504. }
  19505. declare module BABYLON {
  19506. /**
  19507. * This represents a particle system in Babylon.
  19508. * 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.
  19509. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19510. * @example https://doc.babylonjs.com/babylon101/particles
  19511. */
  19512. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19513. /**
  19514. * Source color is added to the destination color without alpha affecting the result.
  19515. */
  19516. static BLENDMODE_ONEONE: number;
  19517. /**
  19518. * Blend current color and particle color using particle’s alpha.
  19519. */
  19520. static BLENDMODE_STANDARD: number;
  19521. /**
  19522. * List of animations used by the particle system.
  19523. */
  19524. animations: Animation[];
  19525. /**
  19526. * The id of the Particle system.
  19527. */
  19528. id: string;
  19529. /**
  19530. * The friendly name of the Particle system.
  19531. */
  19532. name: string;
  19533. /**
  19534. * The rendering group used by the Particle system to chose when to render.
  19535. */
  19536. renderingGroupId: number;
  19537. /**
  19538. * The emitter represents the Mesh or position we are attaching the particle system to.
  19539. */
  19540. emitter: Nullable<AbstractMesh | Vector3>;
  19541. /**
  19542. * The maximum number of particles to emit per frame
  19543. */
  19544. emitRate: number;
  19545. /**
  19546. * If you want to launch only a few particles at once, that can be done, as well.
  19547. */
  19548. manualEmitCount: number;
  19549. /**
  19550. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19551. */
  19552. updateSpeed: number;
  19553. /**
  19554. * The amount of time the particle system is running (depends of the overall update speed).
  19555. */
  19556. targetStopDuration: number;
  19557. /**
  19558. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19559. */
  19560. disposeOnStop: boolean;
  19561. /**
  19562. * Minimum power of emitting particles.
  19563. */
  19564. minEmitPower: number;
  19565. /**
  19566. * Maximum power of emitting particles.
  19567. */
  19568. maxEmitPower: number;
  19569. /**
  19570. * Minimum life time of emitting particles.
  19571. */
  19572. minLifeTime: number;
  19573. /**
  19574. * Maximum life time of emitting particles.
  19575. */
  19576. maxLifeTime: number;
  19577. /**
  19578. * Minimum Size of emitting particles.
  19579. */
  19580. minSize: number;
  19581. /**
  19582. * Maximum Size of emitting particles.
  19583. */
  19584. maxSize: number;
  19585. /**
  19586. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19587. */
  19588. minAngularSpeed: number;
  19589. /**
  19590. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19591. */
  19592. maxAngularSpeed: number;
  19593. /**
  19594. * The texture used to render each particle. (this can be a spritesheet)
  19595. */
  19596. particleTexture: Nullable<Texture>;
  19597. /**
  19598. * The layer mask we are rendering the particles through.
  19599. */
  19600. layerMask: number;
  19601. /**
  19602. * This can help using your own shader to render the particle system.
  19603. * The according effect will be created
  19604. */
  19605. customShader: any;
  19606. /**
  19607. * By default particle system starts as soon as they are created. This prevents the
  19608. * automatic start to happen and let you decide when to start emitting particles.
  19609. */
  19610. preventAutoStart: boolean;
  19611. /**
  19612. * This function can be defined to provide custom update for active particles.
  19613. * This function will be called instead of regular update (age, position, color, etc.).
  19614. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19615. */
  19616. updateFunction: (particles: Particle[]) => void;
  19617. /**
  19618. * Callback triggered when the particle animation is ending.
  19619. */
  19620. onAnimationEnd: Nullable<() => void>;
  19621. /**
  19622. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19623. */
  19624. blendMode: number;
  19625. /**
  19626. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19627. * to override the particles.
  19628. */
  19629. forceDepthWrite: boolean;
  19630. /**
  19631. * You can use gravity if you want to give an orientation to your particles.
  19632. */
  19633. gravity: Vector3;
  19634. /**
  19635. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19636. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19637. */
  19638. direction1: Vector3;
  19639. /**
  19640. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19641. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19642. */
  19643. direction2: Vector3;
  19644. /**
  19645. * 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.
  19646. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19647. */
  19648. minEmitBox: Vector3;
  19649. /**
  19650. * 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.
  19651. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19652. */
  19653. maxEmitBox: Vector3;
  19654. /**
  19655. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19656. */
  19657. color1: Color4;
  19658. /**
  19659. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19660. */
  19661. color2: Color4;
  19662. /**
  19663. * Color the particle will have at the end of its lifetime.
  19664. */
  19665. colorDead: Color4;
  19666. /**
  19667. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  19668. */
  19669. textureMask: Color4;
  19670. /**
  19671. * The particle emitter type defines the emitter used by the particle system.
  19672. * It can be for example box, sphere, or cone...
  19673. */
  19674. particleEmitterType: IParticleEmitterType;
  19675. /**
  19676. * This function can be defined to specify initial direction for every new particle.
  19677. * It by default use the emitterType defined function.
  19678. */
  19679. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19680. /**
  19681. * This function can be defined to specify initial position for every new particle.
  19682. * It by default use the emitterType defined function.
  19683. */
  19684. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19685. /**
  19686. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  19687. */
  19688. spriteCellLoop: boolean;
  19689. /**
  19690. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  19691. */
  19692. spriteCellChangeSpeed: number;
  19693. /**
  19694. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  19695. */
  19696. startSpriteCellID: number;
  19697. /**
  19698. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  19699. */
  19700. endSpriteCellID: number;
  19701. /**
  19702. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  19703. */
  19704. spriteCellWidth: number;
  19705. /**
  19706. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  19707. */
  19708. spriteCellHeight: number;
  19709. /**
  19710. * An event triggered when the system is disposed.
  19711. */
  19712. onDisposeObservable: Observable<ParticleSystem>;
  19713. private _onDisposeObserver;
  19714. /**
  19715. * Sets a callback that will be triggered when the system is disposed.
  19716. */
  19717. onDispose: () => void;
  19718. /**
  19719. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  19720. */
  19721. readonly isAnimationSheetEnabled: Boolean;
  19722. private _particles;
  19723. private _epsilon;
  19724. private _capacity;
  19725. private _scene;
  19726. private _stockParticles;
  19727. private _newPartsExcess;
  19728. private _vertexData;
  19729. private _vertexBuffer;
  19730. private _vertexBuffers;
  19731. private _indexBuffer;
  19732. private _effect;
  19733. private _customEffect;
  19734. private _cachedDefines;
  19735. private _scaledColorStep;
  19736. private _colorDiff;
  19737. private _scaledDirection;
  19738. private _scaledGravity;
  19739. private _currentRenderId;
  19740. private _alive;
  19741. private _started;
  19742. private _stopped;
  19743. private _actualFrame;
  19744. private _scaledUpdateSpeed;
  19745. private _vertexBufferSize;
  19746. private _isAnimationSheetEnabled;
  19747. /**
  19748. * 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.
  19749. */
  19750. subEmitters: ParticleSystem[];
  19751. /**
  19752. * The current active Sub-systems, this property is used by the root particle system only.
  19753. */
  19754. activeSubSystems: Array<ParticleSystem>;
  19755. private _rootParticleSystem;
  19756. /**
  19757. * Gets the current list of active particles
  19758. */
  19759. readonly particles: Particle[];
  19760. /**
  19761. * Returns the string "ParticleSystem"
  19762. * @returns a string containing the class name
  19763. */
  19764. getClassName(): string;
  19765. /**
  19766. * Instantiates a particle system.
  19767. * 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.
  19768. * @param name The name of the particle system
  19769. * @param capacity The max number of particles alive at the same time
  19770. * @param scene The scene the particle system belongs to
  19771. * @param customEffect a custom effect used to change the way particles are rendered by default
  19772. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19773. * @param epsilon Offset used to render the particles
  19774. */
  19775. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19776. private _createIndexBuffer();
  19777. /**
  19778. * Gets the maximum number of particles active at the same time.
  19779. * @returns The max number of active particles.
  19780. */
  19781. getCapacity(): number;
  19782. /**
  19783. * Gets Wether there are still active particles in the system.
  19784. * @returns True if it is alive, otherwise false.
  19785. */
  19786. isAlive(): boolean;
  19787. /**
  19788. * Gets Wether the system has been started.
  19789. * @returns True if it has been started, otherwise false.
  19790. */
  19791. isStarted(): boolean;
  19792. /**
  19793. * Starts the particle system and begins to emit.
  19794. */
  19795. start(): void;
  19796. /**
  19797. * Stops the particle system.
  19798. * @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.
  19799. */
  19800. stop(stopSubEmitters?: boolean): void;
  19801. /**
  19802. * Remove all active particles
  19803. */
  19804. reset(): void;
  19805. /**
  19806. * @ignore (for internal use only)
  19807. */
  19808. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19809. /**
  19810. * @ignore (for internal use only)
  19811. */
  19812. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19813. /**
  19814. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19815. * Its lifetime will start back at 0.
  19816. */
  19817. recycleParticle: (particle: Particle) => void;
  19818. private _stopSubEmitters();
  19819. private _createParticle;
  19820. private _removeFromRoot();
  19821. private _emitFromParticle;
  19822. private _update(newParticles);
  19823. private _getEffect();
  19824. /**
  19825. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19826. */
  19827. animate(): void;
  19828. private _appendParticleVertexes;
  19829. private _appenedParticleVertexesWithSheet(offset, particle);
  19830. private _appenedParticleVertexesNoSheet(offset, particle);
  19831. /**
  19832. * Rebuilds the particle system.
  19833. */
  19834. rebuild(): void;
  19835. /**
  19836. * Is this system ready to be used/rendered
  19837. * @return true if the system is ready
  19838. */
  19839. isReady(): boolean;
  19840. /**
  19841. * Renders the particle system in its current state.
  19842. * @returns the current number of particles
  19843. */
  19844. render(): number;
  19845. /**
  19846. * Disposes the particle system and free the associated resources
  19847. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19848. */
  19849. dispose(disposeTexture?: boolean): void;
  19850. /**
  19851. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  19852. * @param radius The radius of the sphere to emit from
  19853. * @returns the emitter
  19854. */
  19855. createSphereEmitter(radius?: number): SphereParticleEmitter;
  19856. /**
  19857. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  19858. * @param radius The radius of the sphere to emit from
  19859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19861. * @returns the emitter
  19862. */
  19863. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19864. /**
  19865. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  19866. * @param radius The radius of the cone to emit from
  19867. * @param angle The base angle of the cone
  19868. * @returns the emitter
  19869. */
  19870. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19871. /**
  19872. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19873. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19874. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19875. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19876. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19877. * @returns the emitter
  19878. */
  19879. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19880. /**
  19881. * Clones the particle system.
  19882. * @param name The name of the cloned object
  19883. * @param newEmitter The new emitter to use
  19884. * @returns the cloned particle system
  19885. */
  19886. clone(name: string, newEmitter: any): ParticleSystem;
  19887. /**
  19888. * Serializes the particle system to a JSON object.
  19889. * @returns the JSON object
  19890. */
  19891. serialize(): any;
  19892. /**
  19893. * Parses a JSON object to create a particle system.
  19894. * @param parsedParticleSystem The JSON object to parse
  19895. * @param scene The scene to create the particle system in
  19896. * @param rootUrl The root url to use to load external dependencies like texture
  19897. * @returns the Parsed particle system
  19898. */
  19899. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  19900. }
  19901. }
  19902. declare module BABYLON {
  19903. /**
  19904. * Represents one particle of a solid particle system.
  19905. */
  19906. class SolidParticle {
  19907. /**
  19908. * particle global index
  19909. */
  19910. idx: number;
  19911. /**
  19912. * The color of the particle
  19913. */
  19914. color: Nullable<Color4>;
  19915. /**
  19916. * The world space position of the particle.
  19917. */
  19918. position: Vector3;
  19919. /**
  19920. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  19921. */
  19922. rotation: Vector3;
  19923. /**
  19924. * The world space rotation quaternion of the particle.
  19925. */
  19926. rotationQuaternion: Nullable<Quaternion>;
  19927. /**
  19928. * The scaling of the particle.
  19929. */
  19930. scaling: Vector3;
  19931. /**
  19932. * The uvs of the particle.
  19933. */
  19934. uvs: Vector4;
  19935. /**
  19936. * The current speed of the particle.
  19937. */
  19938. velocity: Vector3;
  19939. /**
  19940. * The pivot point in the particle local space.
  19941. */
  19942. pivot: Vector3;
  19943. /**
  19944. * Must the particle be translated from its pivot point in its local space ?
  19945. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  19946. * Default : false
  19947. */
  19948. translateFromPivot: boolean;
  19949. /**
  19950. * Is the particle active or not ?
  19951. */
  19952. alive: boolean;
  19953. /**
  19954. * Is the particle visible or not ?
  19955. */
  19956. isVisible: boolean;
  19957. /**
  19958. * Index of this particle in the global "positions" array (Internal use)
  19959. */
  19960. _pos: number;
  19961. /**
  19962. * Index of this particle in the global "indices" array (Internal use)
  19963. */
  19964. _ind: number;
  19965. /**
  19966. * ModelShape of this particle (Internal use)
  19967. */
  19968. _model: ModelShape;
  19969. /**
  19970. * ModelShape id of this particle
  19971. */
  19972. shapeId: number;
  19973. /**
  19974. * Index of the particle in its shape id (Internal use)
  19975. */
  19976. idxInShape: number;
  19977. /**
  19978. * Reference to the shape model BoundingInfo object (Internal use)
  19979. */
  19980. _modelBoundingInfo: BoundingInfo;
  19981. /**
  19982. * Particle BoundingInfo object (Internal use)
  19983. */
  19984. _boundingInfo: BoundingInfo;
  19985. /**
  19986. * Reference to the SPS what the particle belongs to (Internal use)
  19987. */
  19988. _sps: SolidParticleSystem;
  19989. /**
  19990. * Still set as invisible in order to skip useless computations (Internal use)
  19991. */
  19992. _stillInvisible: boolean;
  19993. /**
  19994. * Last computed particle rotation matrix
  19995. */
  19996. _rotationMatrix: number[];
  19997. /**
  19998. * Parent particle Id, if any.
  19999. * Default null.
  20000. */
  20001. parentId: Nullable<number>;
  20002. /**
  20003. * Internal global position in the SPS.
  20004. */
  20005. _globalPosition: Vector3;
  20006. /**
  20007. * Creates a Solid Particle object.
  20008. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  20009. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  20010. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  20011. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  20012. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  20013. * @param shapeId (integer) is the model shape identifier in the SPS.
  20014. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  20015. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  20016. */
  20017. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  20018. /**
  20019. * Legacy support, changed scale to scaling
  20020. */
  20021. /**
  20022. * Legacy support, changed scale to scaling
  20023. */
  20024. scale: Vector3;
  20025. /**
  20026. * Legacy support, changed quaternion to rotationQuaternion
  20027. */
  20028. /**
  20029. * Legacy support, changed quaternion to rotationQuaternion
  20030. */
  20031. quaternion: Nullable<Quaternion>;
  20032. /**
  20033. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  20034. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  20035. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  20036. * @returns true if it intersects
  20037. */
  20038. intersectsMesh(target: Mesh | SolidParticle): boolean;
  20039. }
  20040. /**
  20041. * Represents the shape of the model used by one particle of a solid particle system.
  20042. * SPS internal tool, don't use it manually.
  20043. */
  20044. class ModelShape {
  20045. /**
  20046. * The shape id.
  20047. */
  20048. shapeID: number;
  20049. /**
  20050. * flat array of model positions (internal use)
  20051. */
  20052. _shape: Vector3[];
  20053. /**
  20054. * flat array of model UVs (internal use)
  20055. */
  20056. _shapeUV: number[];
  20057. /**
  20058. * length of the shape in the model indices array (internal use)
  20059. */
  20060. _indicesLength: number;
  20061. /**
  20062. * Custom position function (internal use)
  20063. */
  20064. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  20065. /**
  20066. * Custom vertex function (internal use)
  20067. */
  20068. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  20069. /**
  20070. * 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.
  20071. * SPS internal tool, don't use it manually.
  20072. * @ignore
  20073. */
  20074. 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>);
  20075. }
  20076. /**
  20077. * Represents a Depth Sorted Particle in the solid particle system.
  20078. */
  20079. class DepthSortedParticle {
  20080. /**
  20081. * Index of the particle in the "indices" array
  20082. */
  20083. ind: number;
  20084. /**
  20085. * Length of the particle shape in the "indices" array
  20086. */
  20087. indicesLength: number;
  20088. /**
  20089. * Squared distance from the particle to the camera
  20090. */
  20091. sqDistance: number;
  20092. }
  20093. }
  20094. declare module BABYLON {
  20095. /**
  20096. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  20097. *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.
  20098. * The SPS is also a particle system. It provides some methods to manage the particles.
  20099. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  20100. *
  20101. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  20102. */
  20103. class SolidParticleSystem implements IDisposable {
  20104. /**
  20105. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  20106. * Example : var p = SPS.particles[i];
  20107. */
  20108. particles: SolidParticle[];
  20109. /**
  20110. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  20111. */
  20112. nbParticles: number;
  20113. /**
  20114. * If the particles must ever face the camera (default false). Useful for planar particles.
  20115. */
  20116. billboard: boolean;
  20117. /**
  20118. * Recompute normals when adding a shape
  20119. */
  20120. recomputeNormals: boolean;
  20121. /**
  20122. * This a counter ofr your own usage. It's not set by any SPS functions.
  20123. */
  20124. counter: number;
  20125. /**
  20126. * The SPS name. This name is also given to the underlying mesh.
  20127. */
  20128. name: string;
  20129. /**
  20130. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  20131. */
  20132. mesh: Mesh;
  20133. /**
  20134. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  20135. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  20136. */
  20137. vars: any;
  20138. /**
  20139. * This array is populated when the SPS is set as 'pickable'.
  20140. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  20141. * Each element of this array is an object `{idx: int, faceId: int}`.
  20142. * `idx` is the picked particle index in the `SPS.particles` array
  20143. * `faceId` is the picked face index counted within this particle.
  20144. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  20145. */
  20146. pickedParticles: {
  20147. idx: number;
  20148. faceId: number;
  20149. }[];
  20150. /**
  20151. * This array is populated when `enableDepthSort` is set to true.
  20152. * Each element of this array is an instance of the class DepthSortedParticle.
  20153. */
  20154. depthSortedParticles: DepthSortedParticle[];
  20155. /**
  20156. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  20157. */
  20158. _bSphereOnly: boolean;
  20159. /**
  20160. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  20161. */
  20162. _bSphereRadiusFactor: number;
  20163. private _scene;
  20164. private _positions;
  20165. private _indices;
  20166. private _normals;
  20167. private _colors;
  20168. private _uvs;
  20169. private _indices32;
  20170. private _positions32;
  20171. private _normals32;
  20172. private _fixedNormal32;
  20173. private _colors32;
  20174. private _uvs32;
  20175. private _index;
  20176. private _updatable;
  20177. private _pickable;
  20178. private _isVisibilityBoxLocked;
  20179. private _alwaysVisible;
  20180. private _depthSort;
  20181. private _shapeCounter;
  20182. private _copy;
  20183. private _shape;
  20184. private _shapeUV;
  20185. private _color;
  20186. private _computeParticleColor;
  20187. private _computeParticleTexture;
  20188. private _computeParticleRotation;
  20189. private _computeParticleVertex;
  20190. private _computeBoundingBox;
  20191. private _depthSortParticles;
  20192. private _cam_axisZ;
  20193. private _cam_axisY;
  20194. private _cam_axisX;
  20195. private _axisZ;
  20196. private _camera;
  20197. private _particle;
  20198. private _camDir;
  20199. private _camInvertedPosition;
  20200. private _rotMatrix;
  20201. private _invertMatrix;
  20202. private _rotated;
  20203. private _quaternion;
  20204. private _vertex;
  20205. private _normal;
  20206. private _yaw;
  20207. private _pitch;
  20208. private _roll;
  20209. private _halfroll;
  20210. private _halfpitch;
  20211. private _halfyaw;
  20212. private _sinRoll;
  20213. private _cosRoll;
  20214. private _sinPitch;
  20215. private _cosPitch;
  20216. private _sinYaw;
  20217. private _cosYaw;
  20218. private _mustUnrotateFixedNormals;
  20219. private _minimum;
  20220. private _maximum;
  20221. private _minBbox;
  20222. private _maxBbox;
  20223. private _particlesIntersect;
  20224. private _depthSortFunction;
  20225. private _needs32Bits;
  20226. private _pivotBackTranslation;
  20227. private _scaledPivot;
  20228. private _particleHasParent;
  20229. private _parent;
  20230. /**
  20231. * Creates a SPS (Solid Particle System) object.
  20232. * @param name (String) is the SPS name, this will be the underlying mesh name.
  20233. * @param scene (Scene) is the scene in which the SPS is added.
  20234. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  20235. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  20236. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  20237. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  20238. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  20239. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  20240. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  20241. */
  20242. constructor(name: string, scene: Scene, options?: {
  20243. updatable?: boolean;
  20244. isPickable?: boolean;
  20245. enableDepthSort?: boolean;
  20246. particleIntersection?: boolean;
  20247. boundingSphereOnly?: boolean;
  20248. bSphereRadiusFactor?: number;
  20249. });
  20250. /**
  20251. * Builds the SPS underlying mesh. Returns a standard Mesh.
  20252. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  20253. * @returns the created mesh
  20254. */
  20255. buildMesh(): Mesh;
  20256. /**
  20257. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  20258. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  20259. * Thus the particles generated from `digest()` have their property `position` set yet.
  20260. * @param mesh ( Mesh ) is the mesh to be digested
  20261. * @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
  20262. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  20263. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  20264. * @returns the current SPS
  20265. */
  20266. digest(mesh: Mesh, options?: {
  20267. facetNb?: number;
  20268. number?: number;
  20269. delta?: number;
  20270. }): SolidParticleSystem;
  20271. private _unrotateFixedNormals();
  20272. private _resetCopy();
  20273. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  20274. private _posToShape(positions);
  20275. private _uvsToShapeUV(uvs);
  20276. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  20277. /**
  20278. * Adds some particles to the SPS from the model shape. Returns the shape id.
  20279. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  20280. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  20281. * @param nb (positive integer) the number of particles to be created from this model
  20282. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  20283. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  20284. * @returns the number of shapes in the system
  20285. */
  20286. addShape(mesh: Mesh, nb: number, options?: {
  20287. positionFunction?: any;
  20288. vertexFunction?: any;
  20289. }): number;
  20290. private _rebuildParticle(particle);
  20291. /**
  20292. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  20293. * @returns the SPS.
  20294. */
  20295. rebuildMesh(): SolidParticleSystem;
  20296. /**
  20297. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  20298. * This method calls `updateParticle()` for each particle of the SPS.
  20299. * For an animated SPS, it is usually called within the render loop.
  20300. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  20301. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  20302. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  20303. * @returns the SPS.
  20304. */
  20305. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  20306. private _quaternionRotationYPR();
  20307. private _quaternionToRotationMatrix();
  20308. /**
  20309. * Disposes the SPS.
  20310. */
  20311. dispose(): void;
  20312. /**
  20313. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  20314. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20315. * @returns the SPS.
  20316. */
  20317. refreshVisibleSize(): SolidParticleSystem;
  20318. /**
  20319. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  20320. * @param size the size (float) of the visibility box
  20321. * note : this doesn't lock the SPS mesh bounding box.
  20322. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20323. */
  20324. setVisibilityBox(size: number): void;
  20325. /**
  20326. * Gets whether the SPS as always visible or not
  20327. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20328. */
  20329. /**
  20330. * Sets the SPS as always visible or not
  20331. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20332. */
  20333. isAlwaysVisible: boolean;
  20334. /**
  20335. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  20336. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20337. */
  20338. /**
  20339. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  20340. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20341. */
  20342. isVisibilityBoxLocked: boolean;
  20343. /**
  20344. * Gets if `setParticles()` computes the particle rotations or not.
  20345. * Default value : true. The SPS is faster when it's set to false.
  20346. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  20347. */
  20348. /**
  20349. * Tells to `setParticles()` to compute the particle rotations or not.
  20350. * Default value : true. The SPS is faster when it's set to false.
  20351. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  20352. */
  20353. computeParticleRotation: boolean;
  20354. /**
  20355. * Gets if `setParticles()` computes the particle colors or not.
  20356. * Default value : true. The SPS is faster when it's set to false.
  20357. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  20358. */
  20359. /**
  20360. * Tells to `setParticles()` to compute the particle colors or not.
  20361. * Default value : true. The SPS is faster when it's set to false.
  20362. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  20363. */
  20364. computeParticleColor: boolean;
  20365. /**
  20366. * Gets if `setParticles()` computes the particle textures or not.
  20367. * Default value : true. The SPS is faster when it's set to false.
  20368. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  20369. */
  20370. computeParticleTexture: boolean;
  20371. /**
  20372. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  20373. * Default value : false. The SPS is faster when it's set to false.
  20374. * Note : the particle custom vertex positions aren't stored values.
  20375. */
  20376. /**
  20377. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  20378. * Default value : false. The SPS is faster when it's set to false.
  20379. * Note : the particle custom vertex positions aren't stored values.
  20380. */
  20381. computeParticleVertex: boolean;
  20382. /**
  20383. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  20384. */
  20385. /**
  20386. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  20387. */
  20388. computeBoundingBox: boolean;
  20389. /**
  20390. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  20391. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  20392. * Default : `true`
  20393. */
  20394. /**
  20395. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  20396. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  20397. * Default : `true`
  20398. */
  20399. depthSortParticles: boolean;
  20400. /**
  20401. * This function does nothing. It may be overwritten to set all the particle first values.
  20402. * The SPS doesn't call this function, you may have to call it by your own.
  20403. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20404. */
  20405. initParticles(): void;
  20406. /**
  20407. * This function does nothing. It may be overwritten to recycle a particle.
  20408. * The SPS doesn't call this function, you may have to call it by your own.
  20409. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20410. * @param particle The particle to recycle
  20411. * @returns the recycled particle
  20412. */
  20413. recycleParticle(particle: SolidParticle): SolidParticle;
  20414. /**
  20415. * Updates a particle : this function should be overwritten by the user.
  20416. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  20417. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20418. * @example : just set a particle position or velocity and recycle conditions
  20419. * @param particle The particle to update
  20420. * @returns the updated particle
  20421. */
  20422. updateParticle(particle: SolidParticle): SolidParticle;
  20423. /**
  20424. * Updates a vertex of a particle : it can be overwritten by the user.
  20425. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  20426. * @param particle the current particle
  20427. * @param vertex the current index of the current particle
  20428. * @param pt the index of the current vertex in the particle shape
  20429. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  20430. * @example : just set a vertex particle position
  20431. * @returns the updated vertex
  20432. */
  20433. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  20434. /**
  20435. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  20436. * This does nothing and may be overwritten by the user.
  20437. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20438. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20439. * @param update the boolean update value actually passed to setParticles()
  20440. */
  20441. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  20442. /**
  20443. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  20444. * This will be passed three parameters.
  20445. * This does nothing and may be overwritten by the user.
  20446. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20447. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20448. * @param update the boolean update value actually passed to setParticles()
  20449. */
  20450. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  20451. }
  20452. }
  20453. declare module BABYLON {
  20454. interface PhysicsImpostorJoint {
  20455. mainImpostor: PhysicsImpostor;
  20456. connectedImpostor: PhysicsImpostor;
  20457. joint: PhysicsJoint;
  20458. }
  20459. class PhysicsEngine {
  20460. private _physicsPlugin;
  20461. gravity: Vector3;
  20462. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  20463. setGravity(gravity: Vector3): void;
  20464. /**
  20465. * Set the time step of the physics engine.
  20466. * default is 1/60.
  20467. * To slow it down, enter 1/600 for example.
  20468. * To speed it up, 1/30
  20469. * @param {number} newTimeStep the new timestep to apply to this world.
  20470. */
  20471. setTimeStep(newTimeStep?: number): void;
  20472. /**
  20473. * Get the time step of the physics engine.
  20474. */
  20475. getTimeStep(): number;
  20476. dispose(): void;
  20477. getPhysicsPluginName(): string;
  20478. static Epsilon: number;
  20479. private _impostors;
  20480. private _joints;
  20481. /**
  20482. * Adding a new impostor for the impostor tracking.
  20483. * This will be done by the impostor itself.
  20484. * @param {PhysicsImpostor} impostor the impostor to add
  20485. */
  20486. addImpostor(impostor: PhysicsImpostor): void;
  20487. /**
  20488. * Remove an impostor from the engine.
  20489. * This impostor and its mesh will not longer be updated by the physics engine.
  20490. * @param {PhysicsImpostor} impostor the impostor to remove
  20491. */
  20492. removeImpostor(impostor: PhysicsImpostor): void;
  20493. /**
  20494. * Add a joint to the physics engine
  20495. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  20496. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  20497. * @param {PhysicsJoint} the joint that will connect both impostors.
  20498. */
  20499. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20500. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20501. /**
  20502. * Called by the scene. no need to call it.
  20503. */
  20504. _step(delta: number): void;
  20505. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20506. getImpostors(): Array<PhysicsImpostor>;
  20507. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20508. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20509. }
  20510. interface IPhysicsEnginePlugin {
  20511. world: any;
  20512. name: string;
  20513. setGravity(gravity: Vector3): void;
  20514. setTimeStep(timeStep: number): void;
  20515. getTimeStep(): number;
  20516. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20517. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20518. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20519. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20520. removePhysicsBody(impostor: PhysicsImpostor): void;
  20521. generateJoint(joint: PhysicsImpostorJoint): void;
  20522. removeJoint(joint: PhysicsImpostorJoint): void;
  20523. isSupported(): boolean;
  20524. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20525. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20526. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20527. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20528. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20529. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20530. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20531. getBodyMass(impostor: PhysicsImpostor): number;
  20532. getBodyFriction(impostor: PhysicsImpostor): number;
  20533. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20534. getBodyRestitution(impostor: PhysicsImpostor): number;
  20535. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20536. sleepBody(impostor: PhysicsImpostor): void;
  20537. wakeUpBody(impostor: PhysicsImpostor): void;
  20538. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20539. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20540. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20541. getRadius(impostor: PhysicsImpostor): number;
  20542. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20543. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20544. dispose(): void;
  20545. }
  20546. }
  20547. declare module BABYLON {
  20548. class PhysicsHelper {
  20549. private _scene;
  20550. private _physicsEngine;
  20551. constructor(scene: Scene);
  20552. /**
  20553. * @param {Vector3} origin the origin of the explosion
  20554. * @param {number} radius the explosion radius
  20555. * @param {number} strength the explosion strength
  20556. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  20557. */
  20558. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  20559. /**
  20560. * @param {Vector3} origin the origin of the explosion
  20561. * @param {number} radius the explosion radius
  20562. * @param {number} strength the explosion strength
  20563. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  20564. */
  20565. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  20566. /**
  20567. * @param {Vector3} origin the origin of the explosion
  20568. * @param {number} radius the explosion radius
  20569. * @param {number} strength the explosion strength
  20570. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  20571. */
  20572. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  20573. /**
  20574. * @param {Vector3} origin the origin of the updraft
  20575. * @param {number} radius the radius of the updraft
  20576. * @param {number} strength the strength of the updraft
  20577. * @param {number} height the height of the updraft
  20578. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  20579. */
  20580. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  20581. /**
  20582. * @param {Vector3} origin the of the vortex
  20583. * @param {number} radius the radius of the vortex
  20584. * @param {number} strength the strength of the vortex
  20585. * @param {number} height the height of the vortex
  20586. */
  20587. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  20588. }
  20589. /***** Radial explosion *****/
  20590. class PhysicsRadialExplosionEvent {
  20591. private _scene;
  20592. private _sphere;
  20593. private _sphereOptions;
  20594. private _rays;
  20595. private _dataFetched;
  20596. constructor(scene: Scene);
  20597. /**
  20598. * Returns the data related to the radial explosion event (sphere & rays).
  20599. * @returns {PhysicsRadialExplosionEventData}
  20600. */
  20601. getData(): PhysicsRadialExplosionEventData;
  20602. /**
  20603. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  20604. * @param impostor
  20605. * @param {Vector3} origin the origin of the explosion
  20606. * @param {number} radius the explosion radius
  20607. * @param {number} strength the explosion strength
  20608. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  20609. * @returns {Nullable<PhysicsForceAndContactPoint>}
  20610. */
  20611. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  20612. /**
  20613. * Disposes the sphere.
  20614. * @param {bolean} force
  20615. */
  20616. dispose(force?: boolean): void;
  20617. /*** Helpers ***/
  20618. private _prepareSphere();
  20619. private _intersectsWithSphere(impostor, origin, radius);
  20620. }
  20621. /***** Gravitational Field *****/
  20622. class PhysicsGravitationalFieldEvent {
  20623. private _physicsHelper;
  20624. private _scene;
  20625. private _origin;
  20626. private _radius;
  20627. private _strength;
  20628. private _falloff;
  20629. private _tickCallback;
  20630. private _sphere;
  20631. private _dataFetched;
  20632. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  20633. /**
  20634. * Returns the data related to the gravitational field event (sphere).
  20635. * @returns {PhysicsGravitationalFieldEventData}
  20636. */
  20637. getData(): PhysicsGravitationalFieldEventData;
  20638. /**
  20639. * Enables the gravitational field.
  20640. */
  20641. enable(): void;
  20642. /**
  20643. * Disables the gravitational field.
  20644. */
  20645. disable(): void;
  20646. /**
  20647. * Disposes the sphere.
  20648. * @param {bolean} force
  20649. */
  20650. dispose(force?: boolean): void;
  20651. private _tick();
  20652. }
  20653. /***** Updraft *****/
  20654. class PhysicsUpdraftEvent {
  20655. private _scene;
  20656. private _origin;
  20657. private _radius;
  20658. private _strength;
  20659. private _height;
  20660. private _updraftMode;
  20661. private _physicsEngine;
  20662. private _originTop;
  20663. private _originDirection;
  20664. private _tickCallback;
  20665. private _cylinder;
  20666. private _cylinderPosition;
  20667. private _dataFetched;
  20668. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  20669. /**
  20670. * Returns the data related to the updraft event (cylinder).
  20671. * @returns {PhysicsUpdraftEventData}
  20672. */
  20673. getData(): PhysicsUpdraftEventData;
  20674. /**
  20675. * Enables the updraft.
  20676. */
  20677. enable(): void;
  20678. /**
  20679. * Disables the cortex.
  20680. */
  20681. disable(): void;
  20682. /**
  20683. * Disposes the sphere.
  20684. * @param {bolean} force
  20685. */
  20686. dispose(force?: boolean): void;
  20687. private getImpostorForceAndContactPoint(impostor);
  20688. private _tick();
  20689. /*** Helpers ***/
  20690. private _prepareCylinder();
  20691. private _intersectsWithCylinder(impostor);
  20692. }
  20693. /***** Vortex *****/
  20694. class PhysicsVortexEvent {
  20695. private _scene;
  20696. private _origin;
  20697. private _radius;
  20698. private _strength;
  20699. private _height;
  20700. private _physicsEngine;
  20701. private _originTop;
  20702. private _centripetalForceThreshold;
  20703. private _updraftMultiplier;
  20704. private _tickCallback;
  20705. private _cylinder;
  20706. private _cylinderPosition;
  20707. private _dataFetched;
  20708. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  20709. /**
  20710. * Returns the data related to the vortex event (cylinder).
  20711. * @returns {PhysicsVortexEventData}
  20712. */
  20713. getData(): PhysicsVortexEventData;
  20714. /**
  20715. * Enables the vortex.
  20716. */
  20717. enable(): void;
  20718. /**
  20719. * Disables the cortex.
  20720. */
  20721. disable(): void;
  20722. /**
  20723. * Disposes the sphere.
  20724. * @param {bolean} force
  20725. */
  20726. dispose(force?: boolean): void;
  20727. private getImpostorForceAndContactPoint(impostor);
  20728. private _tick();
  20729. /*** Helpers ***/
  20730. private _prepareCylinder();
  20731. private _intersectsWithCylinder(impostor);
  20732. }
  20733. /***** Enums *****/
  20734. /**
  20735. * The strenght of the force in correspondence to the distance of the affected object
  20736. */
  20737. enum PhysicsRadialImpulseFalloff {
  20738. Constant = 0,
  20739. Linear = 1,
  20740. }
  20741. /**
  20742. * The strenght of the force in correspondence to the distance of the affected object
  20743. */
  20744. enum PhysicsUpdraftMode {
  20745. Center = 0,
  20746. Perpendicular = 1,
  20747. }
  20748. /***** Data interfaces *****/
  20749. interface PhysicsForceAndContactPoint {
  20750. force: Vector3;
  20751. contactPoint: Vector3;
  20752. }
  20753. interface PhysicsRadialExplosionEventData {
  20754. sphere: Mesh;
  20755. rays: Array<Ray>;
  20756. }
  20757. interface PhysicsGravitationalFieldEventData {
  20758. sphere: Mesh;
  20759. }
  20760. interface PhysicsUpdraftEventData {
  20761. cylinder: Mesh;
  20762. }
  20763. interface PhysicsVortexEventData {
  20764. cylinder: Mesh;
  20765. }
  20766. }
  20767. declare module BABYLON {
  20768. interface PhysicsImpostorParameters {
  20769. mass: number;
  20770. friction?: number;
  20771. restitution?: number;
  20772. nativeOptions?: any;
  20773. ignoreParent?: boolean;
  20774. disableBidirectionalTransformation?: boolean;
  20775. }
  20776. interface IPhysicsEnabledObject {
  20777. position: Vector3;
  20778. rotationQuaternion: Nullable<Quaternion>;
  20779. scaling: Vector3;
  20780. rotation?: Vector3;
  20781. parent?: any;
  20782. getBoundingInfo(): BoundingInfo;
  20783. computeWorldMatrix(force: boolean): Matrix;
  20784. getWorldMatrix?(): Matrix;
  20785. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20786. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20787. getIndices?(): Nullable<IndicesArray>;
  20788. getScene?(): Scene;
  20789. getAbsolutePosition(): Vector3;
  20790. getAbsolutePivotPoint(): Vector3;
  20791. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20792. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20793. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20794. getClassName(): string;
  20795. }
  20796. class PhysicsImpostor {
  20797. object: IPhysicsEnabledObject;
  20798. type: number;
  20799. private _options;
  20800. private _scene;
  20801. static DEFAULT_OBJECT_SIZE: Vector3;
  20802. static IDENTITY_QUATERNION: Quaternion;
  20803. private _physicsEngine;
  20804. private _physicsBody;
  20805. private _bodyUpdateRequired;
  20806. private _onBeforePhysicsStepCallbacks;
  20807. private _onAfterPhysicsStepCallbacks;
  20808. private _onPhysicsCollideCallbacks;
  20809. private _deltaPosition;
  20810. private _deltaRotation;
  20811. private _deltaRotationConjugated;
  20812. private _parent;
  20813. private _isDisposed;
  20814. private static _tmpVecs;
  20815. private static _tmpQuat;
  20816. readonly isDisposed: boolean;
  20817. mass: number;
  20818. friction: number;
  20819. restitution: number;
  20820. uniqueId: number;
  20821. private _joints;
  20822. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20823. /**
  20824. * This function will completly initialize this impostor.
  20825. * It will create a new body - but only if this mesh has no parent.
  20826. * If it has, this impostor will not be used other than to define the impostor
  20827. * of the child mesh.
  20828. */
  20829. _init(): void;
  20830. private _getPhysicsParent();
  20831. /**
  20832. * Should a new body be generated.
  20833. */
  20834. isBodyInitRequired(): boolean;
  20835. setScalingUpdated(updated: boolean): void;
  20836. /**
  20837. * Force a regeneration of this or the parent's impostor's body.
  20838. * Use under cautious - This will remove all joints already implemented.
  20839. */
  20840. forceUpdate(): void;
  20841. /**
  20842. * Gets the body that holds this impostor. Either its own, or its parent.
  20843. */
  20844. /**
  20845. * Set the physics body. Used mainly by the physics engine/plugin
  20846. */
  20847. physicsBody: any;
  20848. parent: Nullable<PhysicsImpostor>;
  20849. resetUpdateFlags(): void;
  20850. getObjectExtendSize(): Vector3;
  20851. getObjectCenter(): Vector3;
  20852. /**
  20853. * Get a specific parametes from the options parameter.
  20854. */
  20855. getParam(paramName: string): any;
  20856. /**
  20857. * Sets a specific parameter in the options given to the physics plugin
  20858. */
  20859. setParam(paramName: string, value: number): void;
  20860. /**
  20861. * Specifically change the body's mass option. Won't recreate the physics body object
  20862. */
  20863. setMass(mass: number): void;
  20864. getLinearVelocity(): Nullable<Vector3>;
  20865. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20866. getAngularVelocity(): Nullable<Vector3>;
  20867. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20868. /**
  20869. * Execute a function with the physics plugin native code.
  20870. * Provide a function the will have two variables - the world object and the physics body object.
  20871. */
  20872. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20873. /**
  20874. * Register a function that will be executed before the physics world is stepping forward.
  20875. */
  20876. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20877. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20878. /**
  20879. * Register a function that will be executed after the physics step
  20880. */
  20881. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20882. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20883. /**
  20884. * register a function that will be executed when this impostor collides against a different body.
  20885. */
  20886. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20887. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20888. private _tmpQuat;
  20889. private _tmpQuat2;
  20890. getParentsRotation(): Quaternion;
  20891. /**
  20892. * this function is executed by the physics engine.
  20893. */
  20894. beforeStep: () => void;
  20895. /**
  20896. * this function is executed by the physics engine.
  20897. */
  20898. afterStep: () => void;
  20899. /**
  20900. * Legacy collision detection event support
  20901. */
  20902. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20903. onCollide: (e: {
  20904. body: any;
  20905. }) => void;
  20906. /**
  20907. * Apply a force
  20908. */
  20909. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20910. /**
  20911. * Apply an impulse
  20912. */
  20913. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20914. /**
  20915. * A help function to create a joint.
  20916. */
  20917. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20918. /**
  20919. * Add a joint to this impostor with a different impostor.
  20920. */
  20921. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20922. /**
  20923. * Will keep this body still, in a sleep mode.
  20924. */
  20925. sleep(): PhysicsImpostor;
  20926. /**
  20927. * Wake the body up.
  20928. */
  20929. wakeUp(): PhysicsImpostor;
  20930. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20931. dispose(): void;
  20932. setDeltaPosition(position: Vector3): void;
  20933. setDeltaRotation(rotation: Quaternion): void;
  20934. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20935. getRadius(): number;
  20936. /**
  20937. * Sync a bone with this impostor
  20938. * @param bone The bone to sync to the impostor.
  20939. * @param boneMesh The mesh that the bone is influencing.
  20940. * @param jointPivot The pivot of the joint / bone in local space.
  20941. * @param distToJoint Optional distance from the impostor to the joint.
  20942. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20943. */
  20944. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20945. /**
  20946. * Sync impostor to a bone
  20947. * @param bone The bone that the impostor will be synced to.
  20948. * @param boneMesh The mesh that the bone is influencing.
  20949. * @param jointPivot The pivot of the joint / bone in local space.
  20950. * @param distToJoint Optional distance from the impostor to the joint.
  20951. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20952. * @param boneAxis Optional vector3 axis the bone is aligned with
  20953. */
  20954. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20955. static NoImpostor: number;
  20956. static SphereImpostor: number;
  20957. static BoxImpostor: number;
  20958. static PlaneImpostor: number;
  20959. static MeshImpostor: number;
  20960. static CylinderImpostor: number;
  20961. static ParticleImpostor: number;
  20962. static HeightmapImpostor: number;
  20963. }
  20964. }
  20965. declare module BABYLON {
  20966. interface PhysicsJointData {
  20967. mainPivot?: Vector3;
  20968. connectedPivot?: Vector3;
  20969. mainAxis?: Vector3;
  20970. connectedAxis?: Vector3;
  20971. collision?: boolean;
  20972. nativeParams?: any;
  20973. }
  20974. /**
  20975. * This is a holder class for the physics joint created by the physics plugin.
  20976. * It holds a set of functions to control the underlying joint.
  20977. */
  20978. class PhysicsJoint {
  20979. type: number;
  20980. jointData: PhysicsJointData;
  20981. private _physicsJoint;
  20982. protected _physicsPlugin: IPhysicsEnginePlugin;
  20983. constructor(type: number, jointData: PhysicsJointData);
  20984. physicsJoint: any;
  20985. physicsPlugin: IPhysicsEnginePlugin;
  20986. /**
  20987. * Execute a function that is physics-plugin specific.
  20988. * @param {Function} func the function that will be executed.
  20989. * It accepts two parameters: the physics world and the physics joint.
  20990. */
  20991. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20992. static DistanceJoint: number;
  20993. static HingeJoint: number;
  20994. static BallAndSocketJoint: number;
  20995. static WheelJoint: number;
  20996. static SliderJoint: number;
  20997. static PrismaticJoint: number;
  20998. static UniversalJoint: number;
  20999. static Hinge2Joint: number;
  21000. static PointToPointJoint: number;
  21001. static SpringJoint: number;
  21002. static LockJoint: number;
  21003. }
  21004. /**
  21005. * A class representing a physics distance joint.
  21006. */
  21007. class DistanceJoint extends PhysicsJoint {
  21008. constructor(jointData: DistanceJointData);
  21009. /**
  21010. * Update the predefined distance.
  21011. */
  21012. updateDistance(maxDistance: number, minDistance?: number): void;
  21013. }
  21014. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  21015. constructor(type: number, jointData: PhysicsJointData);
  21016. /**
  21017. * Set the motor values.
  21018. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21019. * @param {number} force the force to apply
  21020. * @param {number} maxForce max force for this motor.
  21021. */
  21022. setMotor(force?: number, maxForce?: number): void;
  21023. /**
  21024. * Set the motor's limits.
  21025. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21026. */
  21027. setLimit(upperLimit: number, lowerLimit?: number): void;
  21028. }
  21029. /**
  21030. * This class represents a single hinge physics joint
  21031. */
  21032. class HingeJoint extends MotorEnabledJoint {
  21033. constructor(jointData: PhysicsJointData);
  21034. /**
  21035. * Set the motor values.
  21036. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21037. * @param {number} force the force to apply
  21038. * @param {number} maxForce max force for this motor.
  21039. */
  21040. setMotor(force?: number, maxForce?: number): void;
  21041. /**
  21042. * Set the motor's limits.
  21043. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21044. */
  21045. setLimit(upperLimit: number, lowerLimit?: number): void;
  21046. }
  21047. /**
  21048. * This class represents a dual hinge physics joint (same as wheel joint)
  21049. */
  21050. class Hinge2Joint extends MotorEnabledJoint {
  21051. constructor(jointData: PhysicsJointData);
  21052. /**
  21053. * Set the motor values.
  21054. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21055. * @param {number} force the force to apply
  21056. * @param {number} maxForce max force for this motor.
  21057. * @param {motorIndex} the motor's index, 0 or 1.
  21058. */
  21059. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  21060. /**
  21061. * Set the motor limits.
  21062. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21063. * @param {number} upperLimit the upper limit
  21064. * @param {number} lowerLimit lower limit
  21065. * @param {motorIndex} the motor's index, 0 or 1.
  21066. */
  21067. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  21068. }
  21069. interface IMotorEnabledJoint {
  21070. physicsJoint: any;
  21071. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  21072. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  21073. }
  21074. interface DistanceJointData extends PhysicsJointData {
  21075. maxDistance: number;
  21076. }
  21077. interface SpringJointData extends PhysicsJointData {
  21078. length: number;
  21079. stiffness: number;
  21080. damping: number;
  21081. }
  21082. }
  21083. declare module BABYLON {
  21084. class ReflectionProbe {
  21085. name: string;
  21086. private _scene;
  21087. private _renderTargetTexture;
  21088. private _projectionMatrix;
  21089. private _viewMatrix;
  21090. private _target;
  21091. private _add;
  21092. private _attachedMesh;
  21093. private _invertYAxis;
  21094. position: Vector3;
  21095. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  21096. samples: number;
  21097. refreshRate: number;
  21098. getScene(): Scene;
  21099. readonly cubeTexture: RenderTargetTexture;
  21100. readonly renderList: Nullable<AbstractMesh[]>;
  21101. attachToMesh(mesh: AbstractMesh): void;
  21102. /**
  21103. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21104. *
  21105. * @param renderingGroupId The rendering group id corresponding to its index
  21106. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21107. */
  21108. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21109. dispose(): void;
  21110. }
  21111. }
  21112. declare module BABYLON {
  21113. class BoundingBoxRenderer {
  21114. frontColor: Color3;
  21115. backColor: Color3;
  21116. showBackLines: boolean;
  21117. renderList: SmartArray<BoundingBox>;
  21118. private _scene;
  21119. private _colorShader;
  21120. private _vertexBuffers;
  21121. private _indexBuffer;
  21122. constructor(scene: Scene);
  21123. private _prepareRessources();
  21124. private _createIndexBuffer();
  21125. _rebuild(): void;
  21126. reset(): void;
  21127. render(): void;
  21128. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  21129. dispose(): void;
  21130. }
  21131. }
  21132. declare module BABYLON {
  21133. /**
  21134. * This represents a depth renderer in Babylon.
  21135. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  21136. */
  21137. class DepthRenderer {
  21138. private _scene;
  21139. private _depthMap;
  21140. private _effect;
  21141. private _cachedDefines;
  21142. private _camera;
  21143. /**
  21144. * Instantiates a depth renderer
  21145. * @param scene The scene the renderer belongs to
  21146. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  21147. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  21148. */
  21149. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  21150. /**
  21151. * Creates the depth rendering effect and checks if the effect is ready.
  21152. * @param subMesh The submesh to be used to render the depth map of
  21153. * @param useInstances If multiple world instances should be used
  21154. * @returns if the depth renderer is ready to render the depth map
  21155. */
  21156. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  21157. /**
  21158. * Gets the texture which the depth map will be written to.
  21159. * @returns The depth map texture
  21160. */
  21161. getDepthMap(): RenderTargetTexture;
  21162. /**
  21163. * Disposes of the depth renderer.
  21164. */
  21165. dispose(): void;
  21166. }
  21167. }
  21168. declare module BABYLON {
  21169. class EdgesRenderer {
  21170. edgesWidthScalerForOrthographic: number;
  21171. edgesWidthScalerForPerspective: number;
  21172. private _source;
  21173. private _linesPositions;
  21174. private _linesNormals;
  21175. private _linesIndices;
  21176. private _epsilon;
  21177. private _indicesCount;
  21178. private _lineShader;
  21179. private _ib;
  21180. private _buffers;
  21181. private _checkVerticesInsteadOfIndices;
  21182. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21183. private _prepareRessources();
  21184. _rebuild(): void;
  21185. dispose(): void;
  21186. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  21187. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  21188. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  21189. _generateEdgesLines(): void;
  21190. render(): void;
  21191. }
  21192. }
  21193. declare module BABYLON {
  21194. /**
  21195. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  21196. */
  21197. class GeometryBufferRenderer {
  21198. private _scene;
  21199. private _multiRenderTarget;
  21200. private _ratio;
  21201. private _enablePosition;
  21202. protected _effect: Effect;
  21203. protected _cachedDefines: string;
  21204. /**
  21205. * Set the render list (meshes to be rendered) used in the G buffer.
  21206. */
  21207. renderList: Mesh[];
  21208. /**
  21209. * Gets wether or not G buffer are supported by the running hardware.
  21210. * This requires draw buffer supports
  21211. */
  21212. readonly isSupported: boolean;
  21213. /**
  21214. * Gets wether or not position are enabled for the G buffer.
  21215. */
  21216. /**
  21217. * Sets wether or not position are enabled for the G buffer.
  21218. */
  21219. enablePosition: boolean;
  21220. /**
  21221. * Gets the scene associated with the buffer.
  21222. */
  21223. readonly scene: Scene;
  21224. /**
  21225. * Gets the ratio used by the buffer during its creation.
  21226. * How big is the buffer related to the main canvas.
  21227. */
  21228. readonly ratio: number;
  21229. /**
  21230. * Creates a new G Buffer for the scene
  21231. * @param scene The scene the buffer belongs to
  21232. * @param ratio How big is the buffer related to the main canvas.
  21233. */
  21234. constructor(scene: Scene, ratio?: number);
  21235. /**
  21236. * Checks wether everything is ready to render a submesh to the G buffer.
  21237. * @param subMesh the submesh to check readiness for
  21238. * @param useInstances is the mesh drawn using instance or not
  21239. * @returns true if ready otherwise false
  21240. */
  21241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  21242. /**
  21243. * Gets the current underlying G Buffer.
  21244. * @returns the buffer
  21245. */
  21246. getGBuffer(): MultiRenderTarget;
  21247. /**
  21248. * Gets the number of samples used to render the buffer (anti aliasing).
  21249. */
  21250. /**
  21251. * Sets the number of samples used to render the buffer (anti aliasing).
  21252. */
  21253. samples: number;
  21254. /**
  21255. * Disposes the renderer and frees up associated resources.
  21256. */
  21257. dispose(): void;
  21258. protected _createRenderTargets(): void;
  21259. }
  21260. }
  21261. declare module BABYLON {
  21262. class OutlineRenderer {
  21263. private _scene;
  21264. private _effect;
  21265. private _cachedDefines;
  21266. zOffset: number;
  21267. constructor(scene: Scene);
  21268. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  21269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  21270. }
  21271. }
  21272. declare module BABYLON {
  21273. class RenderingGroup {
  21274. index: number;
  21275. private _scene;
  21276. private _opaqueSubMeshes;
  21277. private _transparentSubMeshes;
  21278. private _alphaTestSubMeshes;
  21279. private _depthOnlySubMeshes;
  21280. private _particleSystems;
  21281. private _spriteManagers;
  21282. private _opaqueSortCompareFn;
  21283. private _alphaTestSortCompareFn;
  21284. private _transparentSortCompareFn;
  21285. private _renderOpaque;
  21286. private _renderAlphaTest;
  21287. private _renderTransparent;
  21288. private _edgesRenderers;
  21289. onBeforeTransparentRendering: () => void;
  21290. /**
  21291. * Set the opaque sort comparison function.
  21292. * If null the sub meshes will be render in the order they were created
  21293. */
  21294. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21295. /**
  21296. * Set the alpha test sort comparison function.
  21297. * If null the sub meshes will be render in the order they were created
  21298. */
  21299. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21300. /**
  21301. * Set the transparent sort comparison function.
  21302. * If null the sub meshes will be render in the order they were created
  21303. */
  21304. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21305. /**
  21306. * Creates a new rendering group.
  21307. * @param index The rendering group index
  21308. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21309. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21310. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21311. */
  21312. 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>);
  21313. /**
  21314. * Render all the sub meshes contained in the group.
  21315. * @param customRenderFunction Used to override the default render behaviour of the group.
  21316. * @returns true if rendered some submeshes.
  21317. */
  21318. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21319. /**
  21320. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21321. * @param subMeshes The submeshes to render
  21322. */
  21323. private renderOpaqueSorted(subMeshes);
  21324. /**
  21325. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21326. * @param subMeshes The submeshes to render
  21327. */
  21328. private renderAlphaTestSorted(subMeshes);
  21329. /**
  21330. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21331. * @param subMeshes The submeshes to render
  21332. */
  21333. private renderTransparentSorted(subMeshes);
  21334. /**
  21335. * Renders the submeshes in a specified order.
  21336. * @param subMeshes The submeshes to sort before render
  21337. * @param sortCompareFn The comparison function use to sort
  21338. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21339. * @param transparent Specifies to activate blending if true
  21340. */
  21341. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  21342. /**
  21343. * Renders the submeshes in the order they were dispatched (no sort applied).
  21344. * @param subMeshes The submeshes to render
  21345. */
  21346. private static renderUnsorted(subMeshes);
  21347. /**
  21348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21349. * are rendered back to front if in the same alpha index.
  21350. *
  21351. * @param a The first submesh
  21352. * @param b The second submesh
  21353. * @returns The result of the comparison
  21354. */
  21355. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21356. /**
  21357. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21358. * are rendered back to front.
  21359. *
  21360. * @param a The first submesh
  21361. * @param b The second submesh
  21362. * @returns The result of the comparison
  21363. */
  21364. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21365. /**
  21366. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21367. * are rendered front to back (prevent overdraw).
  21368. *
  21369. * @param a The first submesh
  21370. * @param b The second submesh
  21371. * @returns The result of the comparison
  21372. */
  21373. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21374. /**
  21375. * Resets the different lists of submeshes to prepare a new frame.
  21376. */
  21377. prepare(): void;
  21378. dispose(): void;
  21379. /**
  21380. * Inserts the submesh in its correct queue depending on its material.
  21381. * @param subMesh The submesh to dispatch
  21382. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21383. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21384. */
  21385. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21386. dispatchSprites(spriteManager: SpriteManager): void;
  21387. dispatchParticles(particleSystem: IParticleSystem): void;
  21388. private _renderParticles(activeMeshes);
  21389. private _renderSprites();
  21390. }
  21391. }
  21392. declare module BABYLON {
  21393. class RenderingManager {
  21394. /**
  21395. * The max id used for rendering groups (not included)
  21396. */
  21397. static MAX_RENDERINGGROUPS: number;
  21398. /**
  21399. * The min id used for rendering groups (included)
  21400. */
  21401. static MIN_RENDERINGGROUPS: number;
  21402. /**
  21403. * Used to globally prevent autoclearing scenes.
  21404. */
  21405. static AUTOCLEAR: boolean;
  21406. private _scene;
  21407. private _renderingGroups;
  21408. private _depthStencilBufferAlreadyCleaned;
  21409. private _autoClearDepthStencil;
  21410. private _customOpaqueSortCompareFn;
  21411. private _customAlphaTestSortCompareFn;
  21412. private _customTransparentSortCompareFn;
  21413. private _renderinGroupInfo;
  21414. constructor(scene: Scene);
  21415. private _clearDepthStencilBuffer(depth?, stencil?);
  21416. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21417. reset(): void;
  21418. dispose(): void;
  21419. /**
  21420. * Clear the info related to rendering groups preventing retention points during dispose.
  21421. */
  21422. freeRenderingGroups(): void;
  21423. private _prepareRenderingGroup(renderingGroupId);
  21424. dispatchSprites(spriteManager: SpriteManager): void;
  21425. dispatchParticles(particleSystem: IParticleSystem): void;
  21426. /**
  21427. * @param subMesh The submesh to dispatch
  21428. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21429. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21430. */
  21431. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21432. /**
  21433. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21434. * This allowed control for front to back rendering or reversly depending of the special needs.
  21435. *
  21436. * @param renderingGroupId The rendering group id corresponding to its index
  21437. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21438. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21439. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21440. */
  21441. 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;
  21442. /**
  21443. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21444. *
  21445. * @param renderingGroupId The rendering group id corresponding to its index
  21446. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21447. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21448. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21449. */
  21450. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21451. }
  21452. }
  21453. declare module BABYLON {
  21454. class AnaglyphPostProcess extends PostProcess {
  21455. private _passedProcess;
  21456. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  21457. }
  21458. }
  21459. declare module BABYLON {
  21460. class BlackAndWhitePostProcess extends PostProcess {
  21461. degree: number;
  21462. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21463. }
  21464. }
  21465. declare module BABYLON {
  21466. /**
  21467. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  21468. */
  21469. class BloomEffect extends PostProcessRenderEffect {
  21470. private bloomScale;
  21471. /**
  21472. * Internal
  21473. */
  21474. _effects: Array<PostProcess>;
  21475. /**
  21476. * Internal
  21477. */
  21478. _downscale: ExtractHighlightsPostProcess;
  21479. private _blurX;
  21480. private _blurY;
  21481. private _merge;
  21482. /**
  21483. * The luminance threshold to find bright areas of the image to bloom.
  21484. */
  21485. threshold: number;
  21486. /**
  21487. * The strength of the bloom.
  21488. */
  21489. weight: number;
  21490. /**
  21491. * Specifies the size of the bloom blur kernel, relative to the final output size
  21492. */
  21493. kernel: number;
  21494. /**
  21495. * Creates a new instance of @see BloomEffect
  21496. * @param scene The scene the effect belongs to.
  21497. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  21498. * @param bloomKernel The size of the kernel to be used when applying the blur.
  21499. * @param bloomWeight The the strength of bloom.
  21500. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  21501. * @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)
  21502. */
  21503. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  21504. /**
  21505. * Disposes each of the internal effects for a given camera.
  21506. * @param camera The camera to dispose the effect on.
  21507. */
  21508. disposeEffects(camera: Camera): void;
  21509. /**
  21510. * Internal
  21511. */
  21512. _updateEffects(): void;
  21513. /**
  21514. * Internal
  21515. * @returns if all the contained post processes are ready.
  21516. */
  21517. _isReady(): boolean;
  21518. }
  21519. }
  21520. declare module BABYLON {
  21521. /**
  21522. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  21523. */
  21524. class BloomMergePostProcess extends PostProcess {
  21525. /** Weight of the bloom to be added to the original input. */ weight: number;
  21526. /**
  21527. * Creates a new instance of @see BloomMergePostProcess
  21528. * @param name The name of the effect.
  21529. * @param originalFromInput Post process which's input will be used for the merge.
  21530. * @param blurred Blurred highlights post process which's output will be used.
  21531. * @param weight Weight of the bloom to be added to the original input.
  21532. * @param options The required width/height ratio to downsize to before computing the render pass.
  21533. * @param camera The camera to apply the render pass to.
  21534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21535. * @param engine The engine which the post process will be applied. (default: current engine)
  21536. * @param reusable If the post process can be reused on the same frame. (default: false)
  21537. * @param textureType Type of textures used when performing the post process. (default: 0)
  21538. * @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)
  21539. */
  21540. 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);
  21541. }
  21542. }
  21543. declare module BABYLON {
  21544. /**
  21545. * The Blur Post Process which blurs an image based on a kernel and direction.
  21546. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  21547. */
  21548. class BlurPostProcess extends PostProcess {
  21549. /** The direction in which to blur the image. */ direction: Vector2;
  21550. private blockCompilation;
  21551. protected _kernel: number;
  21552. protected _idealKernel: number;
  21553. protected _packedFloat: boolean;
  21554. private _staticDefines;
  21555. /**
  21556. * Gets the length in pixels of the blur sample region
  21557. */
  21558. /**
  21559. * Sets the length in pixels of the blur sample region
  21560. */
  21561. kernel: number;
  21562. /**
  21563. * Gets wether or not the blur is unpacking/repacking floats
  21564. */
  21565. /**
  21566. * Sets wether or not the blur needs to unpack/repack floats
  21567. */
  21568. packedFloat: boolean;
  21569. /**
  21570. * Creates a new instance BlurPostProcess
  21571. * @param name The name of the effect.
  21572. * @param direction The direction in which to blur the image.
  21573. * @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.
  21574. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  21575. * @param camera The camera to apply the render pass to.
  21576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21577. * @param engine The engine which the post process will be applied. (default: current engine)
  21578. * @param reusable If the post process can be reused on the same frame. (default: false)
  21579. * @param textureType Type of textures used when performing the post process. (default: 0)
  21580. * @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)
  21581. */
  21582. 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);
  21583. /**
  21584. * Updates the effect with the current post process compile time values and recompiles the shader.
  21585. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  21586. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  21587. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  21588. * @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
  21589. * @param onCompiled Called when the shader has been compiled.
  21590. * @param onError Called if there is an error when compiling a shader.
  21591. */
  21592. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  21593. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  21594. /**
  21595. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  21596. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  21597. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  21598. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  21599. * The gaps between physical kernels are compensated for in the weighting of the samples
  21600. * @param idealKernel Ideal blur kernel.
  21601. * @return Nearest best kernel.
  21602. */
  21603. protected _nearestBestKernel(idealKernel: number): number;
  21604. /**
  21605. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  21606. * @param x The point on the Gaussian distribution to sample.
  21607. * @return the value of the Gaussian function at x.
  21608. */
  21609. protected _gaussianWeight(x: number): number;
  21610. /**
  21611. * Generates a string that can be used as a floating point number in GLSL.
  21612. * @param x Value to print.
  21613. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  21614. * @return GLSL float string.
  21615. */
  21616. protected _glslFloat(x: number, decimalFigures?: number): string;
  21617. }
  21618. }
  21619. declare module BABYLON {
  21620. /**
  21621. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  21622. */
  21623. class ChromaticAberrationPostProcess extends PostProcess {
  21624. /**
  21625. * The amount of seperation of rgb channels (default: 30)
  21626. */
  21627. aberrationAmount: number;
  21628. /**
  21629. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  21630. */
  21631. radialIntensity: number;
  21632. /**
  21633. * 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))
  21634. */
  21635. direction: Vector2;
  21636. /**
  21637. * 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))
  21638. */
  21639. centerPosition: Vector2;
  21640. /**
  21641. * Creates a new instance ChromaticAberrationPostProcess
  21642. * @param name The name of the effect.
  21643. * @param screenWidth The width of the screen to apply the effect on.
  21644. * @param screenHeight The height of the screen to apply the effect on.
  21645. * @param options The required width/height ratio to downsize to before computing the render pass.
  21646. * @param camera The camera to apply the render pass to.
  21647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21648. * @param engine The engine which the post process will be applied. (default: current engine)
  21649. * @param reusable If the post process can be reused on the same frame. (default: false)
  21650. * @param textureType Type of textures used when performing the post process. (default: 0)
  21651. * @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)
  21652. */
  21653. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21654. }
  21655. }
  21656. declare module BABYLON {
  21657. /**
  21658. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  21659. */
  21660. class CircleOfConfusionPostProcess extends PostProcess {
  21661. /**
  21662. * 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.
  21663. */
  21664. lensSize: number;
  21665. /**
  21666. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  21667. */
  21668. fStop: number;
  21669. /**
  21670. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  21671. */
  21672. focusDistance: number;
  21673. /**
  21674. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  21675. */
  21676. focalLength: number;
  21677. private _depthTexture;
  21678. /**
  21679. * Creates a new instance CircleOfConfusionPostProcess
  21680. * @param name The name of the effect.
  21681. * @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.
  21682. * @param options The required width/height ratio to downsize to before computing the render pass.
  21683. * @param camera The camera to apply the render pass to.
  21684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21685. * @param engine The engine which the post process will be applied. (default: current engine)
  21686. * @param reusable If the post process can be reused on the same frame. (default: false)
  21687. * @param textureType Type of textures used when performing the post process. (default: 0)
  21688. * @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)
  21689. */
  21690. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21691. /**
  21692. * 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.
  21693. */
  21694. depthTexture: RenderTargetTexture;
  21695. }
  21696. }
  21697. declare module BABYLON {
  21698. class ColorCorrectionPostProcess extends PostProcess {
  21699. private _colorTableTexture;
  21700. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21701. }
  21702. }
  21703. declare module BABYLON {
  21704. /**
  21705. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  21706. * input texture to perform effects such as edge detection or sharpening
  21707. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  21708. */
  21709. class ConvolutionPostProcess extends PostProcess {
  21710. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  21711. /**
  21712. * Creates a new instance ConvolutionPostProcess
  21713. * @param name The name of the effect.
  21714. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  21715. * @param options The required width/height ratio to downsize to before computing the render pass.
  21716. * @param camera The camera to apply the render pass to.
  21717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21718. * @param engine The engine which the post process will be applied. (default: current engine)
  21719. * @param reusable If the post process can be reused on the same frame. (default: false)
  21720. * @param textureType Type of textures used when performing the post process. (default: 0)
  21721. */
  21722. 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);
  21723. /**
  21724. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  21725. */
  21726. static EdgeDetect0Kernel: number[];
  21727. /**
  21728. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  21729. */
  21730. static EdgeDetect1Kernel: number[];
  21731. /**
  21732. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  21733. */
  21734. static EdgeDetect2Kernel: number[];
  21735. /**
  21736. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  21737. */
  21738. static SharpenKernel: number[];
  21739. /**
  21740. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  21741. */
  21742. static EmbossKernel: number[];
  21743. /**
  21744. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  21745. */
  21746. static GaussianKernel: number[];
  21747. }
  21748. }
  21749. declare module BABYLON {
  21750. /**
  21751. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  21752. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  21753. * based on samples that have a large difference in distance than the center pixel.
  21754. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  21755. */
  21756. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  21757. direction: Vector2;
  21758. /**
  21759. * Creates a new instance CircleOfConfusionPostProcess
  21760. * @param name The name of the effect.
  21761. * @param scene The scene the effect belongs to.
  21762. * @param direction The direction the blur should be applied.
  21763. * @param kernel The size of the kernel used to blur.
  21764. * @param options The required width/height ratio to downsize to before computing the render pass.
  21765. * @param camera The camera to apply the render pass to.
  21766. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  21767. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  21768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21769. * @param engine The engine which the post process will be applied. (default: current engine)
  21770. * @param reusable If the post process can be reused on the same frame. (default: false)
  21771. * @param textureType Type of textures used when performing the post process. (default: 0)
  21772. * @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)
  21773. */
  21774. 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);
  21775. }
  21776. }
  21777. declare module BABYLON {
  21778. /**
  21779. * Specifies the level of max blur that should be applied when using the depth of field effect
  21780. */
  21781. enum DepthOfFieldEffectBlurLevel {
  21782. /**
  21783. * Subtle blur
  21784. */
  21785. Low = 0,
  21786. /**
  21787. * Medium blur
  21788. */
  21789. Medium = 1,
  21790. /**
  21791. * Large blur
  21792. */
  21793. High = 2,
  21794. }
  21795. /**
  21796. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  21797. */
  21798. class DepthOfFieldEffect extends PostProcessRenderEffect {
  21799. private _circleOfConfusion;
  21800. /**
  21801. * Internal, blurs from high to low
  21802. */
  21803. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  21804. private _depthOfFieldBlurY;
  21805. private _dofMerge;
  21806. /**
  21807. * Internal post processes in depth of field effect
  21808. */
  21809. _effects: Array<PostProcess>;
  21810. /**
  21811. * The focal the length of the camera used in the effect
  21812. */
  21813. focalLength: number;
  21814. /**
  21815. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  21816. */
  21817. fStop: number;
  21818. /**
  21819. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  21820. */
  21821. focusDistance: number;
  21822. /**
  21823. * 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.
  21824. */
  21825. lensSize: number;
  21826. /**
  21827. * Creates a new instance DepthOfFieldEffect
  21828. * @param scene The scene the effect belongs to.
  21829. * @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.
  21830. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  21831. * @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)
  21832. */
  21833. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  21834. /**
  21835. * 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.
  21836. */
  21837. depthTexture: RenderTargetTexture;
  21838. /**
  21839. * Disposes each of the internal effects for a given camera.
  21840. * @param camera The camera to dispose the effect on.
  21841. */
  21842. disposeEffects(camera: Camera): void;
  21843. /**
  21844. * Internal
  21845. */
  21846. _updateEffects(): void;
  21847. /**
  21848. * Internal
  21849. * @returns if all the contained post processes are ready.
  21850. */
  21851. _isReady(): boolean;
  21852. }
  21853. }
  21854. declare module BABYLON {
  21855. /**
  21856. * Options to be set when merging outputs from the default pipeline.
  21857. */
  21858. class DepthOfFieldMergePostProcessOptions {
  21859. /**
  21860. * The original image to merge on top of
  21861. */
  21862. originalFromInput: PostProcess;
  21863. /**
  21864. * Parameters to perform the merge of the depth of field effect
  21865. */
  21866. depthOfField?: {
  21867. circleOfConfusion: PostProcess;
  21868. blurSteps: Array<PostProcess>;
  21869. };
  21870. /**
  21871. * Parameters to perform the merge of bloom effect
  21872. */
  21873. bloom?: {
  21874. blurred: PostProcess;
  21875. weight: number;
  21876. };
  21877. }
  21878. /**
  21879. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  21880. */
  21881. class DepthOfFieldMergePostProcess extends PostProcess {
  21882. private blurSteps;
  21883. /**
  21884. * Creates a new instance of DepthOfFieldMergePostProcess
  21885. * @param name The name of the effect.
  21886. * @param originalFromInput Post process which's input will be used for the merge.
  21887. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  21888. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  21889. * @param options The required width/height ratio to downsize to before computing the render pass.
  21890. * @param camera The camera to apply the render pass to.
  21891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21892. * @param engine The engine which the post process will be applied. (default: current engine)
  21893. * @param reusable If the post process can be reused on the same frame. (default: false)
  21894. * @param textureType Type of textures used when performing the post process. (default: 0)
  21895. * @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)
  21896. */
  21897. 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);
  21898. /**
  21899. * Updates the effect with the current post process compile time values and recompiles the shader.
  21900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  21901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  21902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  21903. * @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
  21904. * @param onCompiled Called when the shader has been compiled.
  21905. * @param onError Called if there is an error when compiling a shader.
  21906. */
  21907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  21908. }
  21909. }
  21910. declare module BABYLON {
  21911. class DisplayPassPostProcess extends PostProcess {
  21912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21913. }
  21914. }
  21915. declare module BABYLON {
  21916. /**
  21917. * 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.
  21918. */
  21919. class ExtractHighlightsPostProcess extends PostProcess {
  21920. /**
  21921. * The luminance threshold, pixels below this value will be set to black.
  21922. */
  21923. threshold: number;
  21924. /**
  21925. * Internal
  21926. */
  21927. _exposure: number;
  21928. /**
  21929. * Post process which has the input texture to be used when performing highlight extraction
  21930. */
  21931. _inputPostProcess: Nullable<PostProcess>;
  21932. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21933. }
  21934. }
  21935. declare module BABYLON {
  21936. class FilterPostProcess extends PostProcess {
  21937. kernelMatrix: Matrix;
  21938. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21939. }
  21940. }
  21941. declare module BABYLON {
  21942. class FxaaPostProcess extends PostProcess {
  21943. texelWidth: number;
  21944. texelHeight: number;
  21945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  21946. }
  21947. }
  21948. declare module BABYLON {
  21949. /**
  21950. * The GrainPostProcess adds noise to the image at mid luminance levels
  21951. */
  21952. class GrainPostProcess extends PostProcess {
  21953. /**
  21954. * The intensity of the grain added (default: 30)
  21955. */
  21956. intensity: number;
  21957. /**
  21958. * If the grain should be randomized on every frame
  21959. */
  21960. animated: boolean;
  21961. /**
  21962. * Creates a new instance of @see GrainPostProcess
  21963. * @param name The name of the effect.
  21964. * @param options The required width/height ratio to downsize to before computing the render pass.
  21965. * @param camera The camera to apply the render pass to.
  21966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21967. * @param engine The engine which the post process will be applied. (default: current engine)
  21968. * @param reusable If the post process can be reused on the same frame. (default: false)
  21969. * @param textureType Type of textures used when performing the post process. (default: 0)
  21970. * @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)
  21971. */
  21972. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21973. }
  21974. }
  21975. declare module BABYLON {
  21976. class HighlightsPostProcess extends PostProcess {
  21977. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  21978. }
  21979. }
  21980. declare module BABYLON {
  21981. class ImageProcessingPostProcess extends PostProcess {
  21982. /**
  21983. * Default configuration related to image processing available in the PBR Material.
  21984. */
  21985. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21986. /**
  21987. * Gets the image processing configuration used either in this material.
  21988. */
  21989. /**
  21990. * Sets the Default image processing configuration used either in the this material.
  21991. *
  21992. * If sets to null, the scene one is in use.
  21993. */
  21994. imageProcessingConfiguration: ImageProcessingConfiguration;
  21995. /**
  21996. * Keep track of the image processing observer to allow dispose and replace.
  21997. */
  21998. private _imageProcessingObserver;
  21999. /**
  22000. * Attaches a new image processing configuration to the PBR Material.
  22001. * @param configuration
  22002. */
  22003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  22004. /**
  22005. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  22006. */
  22007. /**
  22008. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  22009. */
  22010. colorCurves: Nullable<ColorCurves>;
  22011. /**
  22012. * Gets wether the color curves effect is enabled.
  22013. */
  22014. /**
  22015. * Sets wether the color curves effect is enabled.
  22016. */
  22017. colorCurvesEnabled: boolean;
  22018. /**
  22019. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  22020. */
  22021. /**
  22022. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  22023. */
  22024. colorGradingTexture: Nullable<BaseTexture>;
  22025. /**
  22026. * Gets wether the color grading effect is enabled.
  22027. */
  22028. /**
  22029. * Gets wether the color grading effect is enabled.
  22030. */
  22031. colorGradingEnabled: boolean;
  22032. /**
  22033. * Gets exposure used in the effect.
  22034. */
  22035. /**
  22036. * Sets exposure used in the effect.
  22037. */
  22038. exposure: number;
  22039. /**
  22040. * Gets wether tonemapping is enabled or not.
  22041. */
  22042. /**
  22043. * Sets wether tonemapping is enabled or not
  22044. */
  22045. toneMappingEnabled: boolean;
  22046. /**
  22047. * Gets contrast used in the effect.
  22048. */
  22049. /**
  22050. * Sets contrast used in the effect.
  22051. */
  22052. contrast: number;
  22053. /**
  22054. * Gets Vignette stretch size.
  22055. */
  22056. /**
  22057. * Sets Vignette stretch size.
  22058. */
  22059. vignetteStretch: number;
  22060. /**
  22061. * Gets Vignette centre X Offset.
  22062. */
  22063. /**
  22064. * Sets Vignette centre X Offset.
  22065. */
  22066. vignetteCentreX: number;
  22067. /**
  22068. * Gets Vignette centre Y Offset.
  22069. */
  22070. /**
  22071. * Sets Vignette centre Y Offset.
  22072. */
  22073. vignetteCentreY: number;
  22074. /**
  22075. * Gets Vignette weight or intensity of the vignette effect.
  22076. */
  22077. /**
  22078. * Sets Vignette weight or intensity of the vignette effect.
  22079. */
  22080. vignetteWeight: number;
  22081. /**
  22082. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22083. * if vignetteEnabled is set to true.
  22084. */
  22085. /**
  22086. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22087. * if vignetteEnabled is set to true.
  22088. */
  22089. vignetteColor: Color4;
  22090. /**
  22091. * Gets Camera field of view used by the Vignette effect.
  22092. */
  22093. /**
  22094. * Sets Camera field of view used by the Vignette effect.
  22095. */
  22096. vignetteCameraFov: number;
  22097. /**
  22098. * Gets the vignette blend mode allowing different kind of effect.
  22099. */
  22100. /**
  22101. * Sets the vignette blend mode allowing different kind of effect.
  22102. */
  22103. vignetteBlendMode: number;
  22104. /**
  22105. * Gets wether the vignette effect is enabled.
  22106. */
  22107. /**
  22108. * Sets wether the vignette effect is enabled.
  22109. */
  22110. vignetteEnabled: boolean;
  22111. private _fromLinearSpace;
  22112. /**
  22113. * Gets wether the input of the processing is in Gamma or Linear Space.
  22114. */
  22115. /**
  22116. * Sets wether the input of the processing is in Gamma or Linear Space.
  22117. */
  22118. fromLinearSpace: boolean;
  22119. /**
  22120. * Defines cache preventing GC.
  22121. */
  22122. private _defines;
  22123. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  22124. getClassName(): string;
  22125. protected _updateParameters(): void;
  22126. dispose(camera?: Camera): void;
  22127. }
  22128. }
  22129. declare module BABYLON {
  22130. class PassPostProcess extends PostProcess {
  22131. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22132. }
  22133. }
  22134. declare module BABYLON {
  22135. type PostProcessOptions = {
  22136. width: number;
  22137. height: number;
  22138. };
  22139. /**
  22140. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22141. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22142. */
  22143. class PostProcess {
  22144. /** Name of the PostProcess. */ name: string;
  22145. /**
  22146. * Width of the texture to apply the post process on
  22147. */
  22148. width: number;
  22149. /**
  22150. * Height of the texture to apply the post process on
  22151. */
  22152. height: number;
  22153. /**
  22154. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22155. */
  22156. _outputTexture: Nullable<InternalTexture>;
  22157. /**
  22158. * Sampling mode used by the shader
  22159. * See https://doc.babylonjs.com/classes/3.1/texture
  22160. */
  22161. renderTargetSamplingMode: number;
  22162. /**
  22163. * Clear color to use when screen clearing
  22164. */
  22165. clearColor: Color4;
  22166. /**
  22167. * If the buffer needs to be cleared before applying the post process. (default: true)
  22168. * Should be set to false if shader will overwrite all previous pixels.
  22169. */
  22170. autoClear: boolean;
  22171. /**
  22172. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22173. */
  22174. alphaMode: number;
  22175. /**
  22176. * Sets the setAlphaBlendConstants of the babylon engine
  22177. */
  22178. alphaConstants: Color4;
  22179. /**
  22180. * Animations to be used for the post processing
  22181. */
  22182. animations: Animation[];
  22183. /**
  22184. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22185. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22186. */
  22187. enablePixelPerfectMode: boolean;
  22188. /**
  22189. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22190. */
  22191. scaleMode: number;
  22192. /**
  22193. * Force textures to be a power of two (default: false)
  22194. */
  22195. alwaysForcePOT: boolean;
  22196. /**
  22197. * Number of sample textures (default: 1)
  22198. */
  22199. samples: number;
  22200. /**
  22201. * Modify the scale of the post process to be the same as the viewport (default: false)
  22202. */
  22203. adaptScaleToCurrentViewport: boolean;
  22204. private _camera;
  22205. private _scene;
  22206. private _engine;
  22207. private _options;
  22208. private _reusable;
  22209. private _textureType;
  22210. /**
  22211. * Smart array of input and output textures for the post process.
  22212. */
  22213. _textures: SmartArray<InternalTexture>;
  22214. /**
  22215. * The index in _textures that corresponds to the output texture.
  22216. */
  22217. _currentRenderTextureInd: number;
  22218. private _effect;
  22219. private _samplers;
  22220. private _fragmentUrl;
  22221. private _vertexUrl;
  22222. private _parameters;
  22223. private _scaleRatio;
  22224. protected _indexParameters: any;
  22225. private _shareOutputWithPostProcess;
  22226. private _texelSize;
  22227. private _forcedOutputTexture;
  22228. /**
  22229. * An event triggered when the postprocess is activated.
  22230. */
  22231. onActivateObservable: Observable<Camera>;
  22232. private _onActivateObserver;
  22233. /**
  22234. * A function that is added to the onActivateObservable
  22235. */
  22236. onActivate: Nullable<(camera: Camera) => void>;
  22237. /**
  22238. * An event triggered when the postprocess changes its size.
  22239. */
  22240. onSizeChangedObservable: Observable<PostProcess>;
  22241. private _onSizeChangedObserver;
  22242. /**
  22243. * A function that is added to the onSizeChangedObservable
  22244. */
  22245. onSizeChanged: (postProcess: PostProcess) => void;
  22246. /**
  22247. * An event triggered when the postprocess applies its effect.
  22248. */
  22249. onApplyObservable: Observable<Effect>;
  22250. private _onApplyObserver;
  22251. /**
  22252. * A function that is added to the onApplyObservable
  22253. */
  22254. onApply: (effect: Effect) => void;
  22255. /**
  22256. * An event triggered before rendering the postprocess
  22257. */
  22258. onBeforeRenderObservable: Observable<Effect>;
  22259. private _onBeforeRenderObserver;
  22260. /**
  22261. * A function that is added to the onBeforeRenderObservable
  22262. */
  22263. onBeforeRender: (effect: Effect) => void;
  22264. /**
  22265. * An event triggered after rendering the postprocess
  22266. */
  22267. onAfterRenderObservable: Observable<Effect>;
  22268. private _onAfterRenderObserver;
  22269. /**
  22270. * A function that is added to the onAfterRenderObservable
  22271. */
  22272. onAfterRender: (efect: Effect) => void;
  22273. /**
  22274. * 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
  22275. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22276. */
  22277. inputTexture: InternalTexture;
  22278. /**
  22279. * Gets the camera which post process is applied to.
  22280. * @returns The camera the post process is applied to.
  22281. */
  22282. getCamera(): Camera;
  22283. /**
  22284. * Gets the texel size of the postprocess.
  22285. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22286. */
  22287. readonly texelSize: Vector2;
  22288. /**
  22289. * Creates a new instance PostProcess
  22290. * @param name The name of the PostProcess.
  22291. * @param fragmentUrl The url of the fragment shader to be used.
  22292. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22293. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22294. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22295. * @param camera The camera to apply the render pass to.
  22296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22297. * @param engine The engine which the post process will be applied. (default: current engine)
  22298. * @param reusable If the post process can be reused on the same frame. (default: false)
  22299. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22300. * @param textureType Type of textures used when performing the post process. (default: 0)
  22301. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22302. * @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
  22303. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22304. */
  22305. 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);
  22306. /**
  22307. * Gets the engine which this post process belongs to.
  22308. * @returns The engine the post process was enabled with.
  22309. */
  22310. getEngine(): Engine;
  22311. /**
  22312. * The effect that is created when initializing the post process.
  22313. * @returns The created effect corrisponding the the postprocess.
  22314. */
  22315. getEffect(): Effect;
  22316. /**
  22317. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22318. * @param postProcess The post process to share the output with.
  22319. * @returns This post process.
  22320. */
  22321. shareOutputWith(postProcess: PostProcess): PostProcess;
  22322. /**
  22323. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22324. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22325. */
  22326. useOwnOutput(): void;
  22327. /**
  22328. * Updates the effect with the current post process compile time values and recompiles the shader.
  22329. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22330. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22331. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22332. * @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
  22333. * @param onCompiled Called when the shader has been compiled.
  22334. * @param onError Called if there is an error when compiling a shader.
  22335. */
  22336. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22337. /**
  22338. * The post process is reusable if it can be used multiple times within one frame.
  22339. * @returns If the post process is reusable
  22340. */
  22341. isReusable(): boolean;
  22342. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22343. markTextureDirty(): void;
  22344. /**
  22345. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22346. * 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.
  22347. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22348. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22349. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22350. * @returns The target texture that was bound to be written to.
  22351. */
  22352. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22353. /**
  22354. * If the post process is supported.
  22355. */
  22356. readonly isSupported: boolean;
  22357. /**
  22358. * The aspect ratio of the output texture.
  22359. */
  22360. readonly aspectRatio: number;
  22361. /**
  22362. * Get a value indicating if the post-process is ready to be used
  22363. * @returns true if the post-process is ready (shader is compiled)
  22364. */
  22365. isReady(): boolean;
  22366. /**
  22367. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22368. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  22369. */
  22370. apply(): Nullable<Effect>;
  22371. private _disposeTextures();
  22372. /**
  22373. * Disposes the post process.
  22374. * @param camera The camera to dispose the post process on.
  22375. */
  22376. dispose(camera?: Camera): void;
  22377. }
  22378. }
  22379. declare module BABYLON {
  22380. /**
  22381. * PostProcessManager is used to manage one or more post processes or post process pipelines
  22382. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22383. */
  22384. class PostProcessManager {
  22385. private _scene;
  22386. private _indexBuffer;
  22387. private _vertexBuffers;
  22388. /**
  22389. * Creates a new instance PostProcess
  22390. * @param scene The scene that the post process is associated with.
  22391. */
  22392. constructor(scene: Scene);
  22393. private _prepareBuffers();
  22394. private _buildIndexBuffer();
  22395. /**
  22396. * Rebuilds the vertex buffers of the manager.
  22397. */
  22398. _rebuild(): void;
  22399. /**
  22400. * Prepares a frame to be run through a post process.
  22401. * @param sourceTexture The input texture to the post procesess. (default: null)
  22402. * @param postProcesses An array of post processes to be run. (default: null)
  22403. * @returns True if the post processes were able to be run.
  22404. */
  22405. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  22406. /**
  22407. * Manually render a set of post processes to a texture.
  22408. * @param postProcesses An array of post processes to be run.
  22409. * @param targetTexture The target texture to render to.
  22410. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  22411. */
  22412. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  22413. /**
  22414. * Finalize the result of the output of the postprocesses.
  22415. * @param doNotPresent If true the result will not be displayed to the screen.
  22416. * @param targetTexture The target texture to render to.
  22417. * @param faceIndex The index of the face to bind the target texture to.
  22418. * @param postProcesses The array of post processes to render.
  22419. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  22420. */
  22421. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  22422. /**
  22423. * Disposes of the post process manager.
  22424. */
  22425. dispose(): void;
  22426. }
  22427. }
  22428. declare module BABYLON {
  22429. class RefractionPostProcess extends PostProcess {
  22430. color: Color3;
  22431. depth: number;
  22432. colorLevel: number;
  22433. private _refTexture;
  22434. private _ownRefractionTexture;
  22435. /**
  22436. * Gets or sets the refraction texture
  22437. * Please note that you are responsible for disposing the texture if you set it manually
  22438. */
  22439. refractionTexture: Texture;
  22440. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  22441. dispose(camera: Camera): void;
  22442. }
  22443. }
  22444. declare module BABYLON {
  22445. /**
  22446. * The SharpenPostProcess applies a sharpen kernel to every pixel
  22447. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  22448. */
  22449. class SharpenPostProcess extends PostProcess {
  22450. /**
  22451. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  22452. */
  22453. colorAmount: number;
  22454. /**
  22455. * How much sharpness should be applied (default: 0.3)
  22456. */
  22457. edgeAmount: number;
  22458. /**
  22459. * Creates a new instance ConvolutionPostProcess
  22460. * @param name The name of the effect.
  22461. * @param options The required width/height ratio to downsize to before computing the render pass.
  22462. * @param camera The camera to apply the render pass to.
  22463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22464. * @param engine The engine which the post process will be applied. (default: current engine)
  22465. * @param reusable If the post process can be reused on the same frame. (default: false)
  22466. * @param textureType Type of textures used when performing the post process. (default: 0)
  22467. * @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)
  22468. */
  22469. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22470. }
  22471. }
  22472. declare module BABYLON {
  22473. class StereoscopicInterlacePostProcess extends PostProcess {
  22474. private _stepSize;
  22475. private _passedProcess;
  22476. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  22477. }
  22478. }
  22479. declare module BABYLON {
  22480. enum TonemappingOperator {
  22481. Hable = 0,
  22482. Reinhard = 1,
  22483. HejiDawson = 2,
  22484. Photographic = 3,
  22485. }
  22486. class TonemapPostProcess extends PostProcess {
  22487. private _operator;
  22488. exposureAdjustment: number;
  22489. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  22490. }
  22491. }
  22492. declare module BABYLON {
  22493. class VolumetricLightScatteringPostProcess extends PostProcess {
  22494. private _volumetricLightScatteringPass;
  22495. private _volumetricLightScatteringRTT;
  22496. private _viewPort;
  22497. private _screenCoordinates;
  22498. private _cachedDefines;
  22499. /**
  22500. * If not undefined, the mesh position is computed from the attached node position
  22501. */
  22502. attachedNode: {
  22503. position: Vector3;
  22504. };
  22505. /**
  22506. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  22507. */
  22508. customMeshPosition: Vector3;
  22509. /**
  22510. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  22511. */
  22512. useCustomMeshPosition: boolean;
  22513. /**
  22514. * If the post-process should inverse the light scattering direction
  22515. */
  22516. invert: boolean;
  22517. /**
  22518. * The internal mesh used by the post-process
  22519. */
  22520. mesh: Mesh;
  22521. useDiffuseColor: boolean;
  22522. /**
  22523. * Array containing the excluded meshes not rendered in the internal pass
  22524. */
  22525. excludedMeshes: AbstractMesh[];
  22526. /**
  22527. * Controls the overall intensity of the post-process
  22528. */
  22529. exposure: number;
  22530. /**
  22531. * Dissipates each sample's contribution in range [0, 1]
  22532. */
  22533. decay: number;
  22534. /**
  22535. * Controls the overall intensity of each sample
  22536. */
  22537. weight: number;
  22538. /**
  22539. * Controls the density of each sample
  22540. */
  22541. density: number;
  22542. /**
  22543. * @constructor
  22544. * @param {string} name - The post-process name
  22545. * @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)
  22546. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  22547. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  22548. * @param {number} samples - The post-process quality, default 100
  22549. * @param {number} samplingMode - The post-process filtering mode
  22550. * @param {BABYLON.Engine} engine - The babylon engine
  22551. * @param {boolean} reusable - If the post-process is reusable
  22552. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  22553. */
  22554. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  22555. getClassName(): string;
  22556. private _isReady(subMesh, useInstances);
  22557. /**
  22558. * Sets the new light position for light scattering effect
  22559. * @param {BABYLON.Vector3} The new custom light position
  22560. */
  22561. setCustomMeshPosition(position: Vector3): void;
  22562. /**
  22563. * Returns the light position for light scattering effect
  22564. * @return {BABYLON.Vector3} The custom light position
  22565. */
  22566. getCustomMeshPosition(): Vector3;
  22567. /**
  22568. * Disposes the internal assets and detaches the post-process from the camera
  22569. */
  22570. dispose(camera: Camera): void;
  22571. /**
  22572. * Returns the render target texture used by the post-process
  22573. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  22574. */
  22575. getPass(): RenderTargetTexture;
  22576. private _meshExcluded(mesh);
  22577. private _createPass(scene, ratio);
  22578. private _updateMeshScreenCoordinates(scene);
  22579. /**
  22580. * Creates a default mesh for the Volumeric Light Scattering post-process
  22581. * @param {string} The mesh name
  22582. * @param {BABYLON.Scene} The scene where to create the mesh
  22583. * @return {BABYLON.Mesh} the default mesh
  22584. */
  22585. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  22586. }
  22587. }
  22588. declare module BABYLON {
  22589. class VRDistortionCorrectionPostProcess extends PostProcess {
  22590. private _isRightEye;
  22591. private _distortionFactors;
  22592. private _postProcessScaleFactor;
  22593. private _lensCenterOffset;
  22594. private _scaleIn;
  22595. private _scaleFactor;
  22596. private _lensCenter;
  22597. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  22598. }
  22599. }
  22600. declare module BABYLON {
  22601. class _AlphaState {
  22602. private _isAlphaBlendDirty;
  22603. private _isBlendFunctionParametersDirty;
  22604. private _isBlendEquationParametersDirty;
  22605. private _isBlendConstantsDirty;
  22606. private _alphaBlend;
  22607. private _blendFunctionParameters;
  22608. private _blendEquationParameters;
  22609. private _blendConstants;
  22610. /**
  22611. * Initializes the state.
  22612. */
  22613. constructor();
  22614. readonly isDirty: boolean;
  22615. alphaBlend: boolean;
  22616. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  22617. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  22618. setAlphaEquationParameters(rgb: number, alpha: number): void;
  22619. reset(): void;
  22620. apply(gl: WebGLRenderingContext): void;
  22621. }
  22622. }
  22623. declare module BABYLON {
  22624. class _DepthCullingState {
  22625. private _isDepthTestDirty;
  22626. private _isDepthMaskDirty;
  22627. private _isDepthFuncDirty;
  22628. private _isCullFaceDirty;
  22629. private _isCullDirty;
  22630. private _isZOffsetDirty;
  22631. private _isFrontFaceDirty;
  22632. private _depthTest;
  22633. private _depthMask;
  22634. private _depthFunc;
  22635. private _cull;
  22636. private _cullFace;
  22637. private _zOffset;
  22638. private _frontFace;
  22639. /**
  22640. * Initializes the state.
  22641. */
  22642. constructor();
  22643. readonly isDirty: boolean;
  22644. zOffset: number;
  22645. cullFace: Nullable<number>;
  22646. cull: Nullable<boolean>;
  22647. depthFunc: Nullable<number>;
  22648. depthMask: boolean;
  22649. depthTest: boolean;
  22650. frontFace: Nullable<number>;
  22651. reset(): void;
  22652. apply(gl: WebGLRenderingContext): void;
  22653. }
  22654. }
  22655. declare module BABYLON {
  22656. class _StencilState {
  22657. private _isStencilTestDirty;
  22658. private _isStencilMaskDirty;
  22659. private _isStencilFuncDirty;
  22660. private _isStencilOpDirty;
  22661. private _stencilTest;
  22662. private _stencilMask;
  22663. private _stencilFunc;
  22664. private _stencilFuncRef;
  22665. private _stencilFuncMask;
  22666. private _stencilOpStencilFail;
  22667. private _stencilOpDepthFail;
  22668. private _stencilOpStencilDepthPass;
  22669. readonly isDirty: boolean;
  22670. stencilFunc: number;
  22671. stencilFuncRef: number;
  22672. stencilFuncMask: number;
  22673. stencilOpStencilFail: number;
  22674. stencilOpDepthFail: number;
  22675. stencilOpStencilDepthPass: number;
  22676. stencilMask: number;
  22677. stencilTest: boolean;
  22678. constructor();
  22679. reset(): void;
  22680. apply(gl: WebGLRenderingContext): void;
  22681. }
  22682. }
  22683. declare module BABYLON {
  22684. class Sprite {
  22685. name: string;
  22686. position: Vector3;
  22687. color: Color4;
  22688. width: number;
  22689. height: number;
  22690. angle: number;
  22691. cellIndex: number;
  22692. invertU: number;
  22693. invertV: number;
  22694. disposeWhenFinishedAnimating: boolean;
  22695. animations: Animation[];
  22696. isPickable: boolean;
  22697. actionManager: ActionManager;
  22698. private _animationStarted;
  22699. private _loopAnimation;
  22700. private _fromIndex;
  22701. private _toIndex;
  22702. private _delay;
  22703. private _direction;
  22704. private _manager;
  22705. private _time;
  22706. private _onAnimationEnd;
  22707. size: number;
  22708. constructor(name: string, manager: SpriteManager);
  22709. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  22710. stopAnimation(): void;
  22711. _animate(deltaTime: number): void;
  22712. dispose(): void;
  22713. }
  22714. }
  22715. declare module BABYLON {
  22716. class SpriteManager {
  22717. name: string;
  22718. sprites: Sprite[];
  22719. renderingGroupId: number;
  22720. layerMask: number;
  22721. fogEnabled: boolean;
  22722. isPickable: boolean;
  22723. cellWidth: number;
  22724. cellHeight: number;
  22725. /**
  22726. * An event triggered when the manager is disposed.
  22727. */
  22728. onDisposeObservable: Observable<SpriteManager>;
  22729. private _onDisposeObserver;
  22730. onDispose: () => void;
  22731. private _capacity;
  22732. private _spriteTexture;
  22733. private _epsilon;
  22734. private _scene;
  22735. private _vertexData;
  22736. private _buffer;
  22737. private _vertexBuffers;
  22738. private _indexBuffer;
  22739. private _effectBase;
  22740. private _effectFog;
  22741. texture: Texture;
  22742. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  22743. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  22744. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  22745. render(): void;
  22746. dispose(): void;
  22747. }
  22748. }
  22749. declare module BABYLON {
  22750. class AndOrNotEvaluator {
  22751. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  22752. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  22753. private static _SimplifyNegation(booleanString);
  22754. }
  22755. }
  22756. declare module BABYLON {
  22757. /**
  22758. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  22759. */
  22760. enum AssetTaskState {
  22761. /**
  22762. * Initialization
  22763. */
  22764. INIT = 0,
  22765. /**
  22766. * Running
  22767. */
  22768. RUNNING = 1,
  22769. /**
  22770. * Done
  22771. */
  22772. DONE = 2,
  22773. /**
  22774. * Error
  22775. */
  22776. ERROR = 3,
  22777. }
  22778. /**
  22779. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  22780. */
  22781. abstract class AbstractAssetTask {
  22782. /**
  22783. * Task name
  22784. */ name: string;
  22785. /**
  22786. * Callback called when the task is successful
  22787. */
  22788. onSuccess: (task: any) => void;
  22789. /**
  22790. * Callback called when the task is not successful
  22791. */
  22792. onError: (task: any, message?: string, exception?: any) => void;
  22793. /**
  22794. * Creates a new {BABYLON.AssetsManager}
  22795. * @param name defines the name of the task
  22796. */
  22797. constructor(
  22798. /**
  22799. * Task name
  22800. */ name: string);
  22801. private _isCompleted;
  22802. private _taskState;
  22803. private _errorObject;
  22804. /**
  22805. * Get if the task is completed
  22806. */
  22807. readonly isCompleted: boolean;
  22808. /**
  22809. * Gets the current state of the task
  22810. */
  22811. readonly taskState: AssetTaskState;
  22812. /**
  22813. * Gets the current error object (if task is in error)
  22814. */
  22815. readonly errorObject: {
  22816. message?: string;
  22817. exception?: any;
  22818. };
  22819. /**
  22820. * Internal only
  22821. * @ignore
  22822. */
  22823. _setErrorObject(message?: string, exception?: any): void;
  22824. /**
  22825. * Execute the current task
  22826. * @param scene defines the scene where you want your assets to be loaded
  22827. * @param onSuccess is a callback called when the task is successfully executed
  22828. * @param onError is a callback called if an error occurs
  22829. */
  22830. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22831. /**
  22832. * Execute the current task
  22833. * @param scene defines the scene where you want your assets to be loaded
  22834. * @param onSuccess is a callback called when the task is successfully executed
  22835. * @param onError is a callback called if an error occurs
  22836. */
  22837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22838. private onErrorCallback(onError, message?, exception?);
  22839. private onDoneCallback(onSuccess, onError);
  22840. }
  22841. /**
  22842. * Define the interface used by progress events raised during assets loading
  22843. */
  22844. interface IAssetsProgressEvent {
  22845. /**
  22846. * Defines the number of remaining tasks to process
  22847. */
  22848. remainingCount: number;
  22849. /**
  22850. * Defines the total number of tasks
  22851. */
  22852. totalCount: number;
  22853. /**
  22854. * Defines the task that was just processed
  22855. */
  22856. task: AbstractAssetTask;
  22857. }
  22858. /**
  22859. * Class used to share progress information about assets loading
  22860. */
  22861. class AssetsProgressEvent implements IAssetsProgressEvent {
  22862. /**
  22863. * Defines the number of remaining tasks to process
  22864. */
  22865. remainingCount: number;
  22866. /**
  22867. * Defines the total number of tasks
  22868. */
  22869. totalCount: number;
  22870. /**
  22871. * Defines the task that was just processed
  22872. */
  22873. task: AbstractAssetTask;
  22874. /**
  22875. * Creates a {BABYLON.AssetsProgressEvent}
  22876. * @param remainingCount defines the number of remaining tasks to process
  22877. * @param totalCount defines the total number of tasks
  22878. * @param task defines the task that was just processed
  22879. */
  22880. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  22881. }
  22882. /**
  22883. * Define a task used by {BABYLON.AssetsManager} to load meshes
  22884. */
  22885. class MeshAssetTask extends AbstractAssetTask {
  22886. /**
  22887. * Defines the name of the task
  22888. */
  22889. name: string;
  22890. /**
  22891. * Defines the list of mesh's names you want to load
  22892. */
  22893. meshesNames: any;
  22894. /**
  22895. * Defines the root url to use as a base to load your meshes and associated resources
  22896. */
  22897. rootUrl: string;
  22898. /**
  22899. * Defines the filename of the scene to load from
  22900. */
  22901. sceneFilename: string;
  22902. /**
  22903. * Gets the list of loaded meshes
  22904. */
  22905. loadedMeshes: Array<AbstractMesh>;
  22906. /**
  22907. * Gets the list of loaded particle systems
  22908. */
  22909. loadedParticleSystems: Array<ParticleSystem>;
  22910. /**
  22911. * Gets the list of loaded skeletons
  22912. */
  22913. loadedSkeletons: Array<Skeleton>;
  22914. /**
  22915. * Callback called when the task is successful
  22916. */
  22917. onSuccess: (task: MeshAssetTask) => void;
  22918. /**
  22919. * Callback called when the task is successful
  22920. */
  22921. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  22922. /**
  22923. * Creates a new {BABYLON.MeshAssetTask}
  22924. * @param name defines the name of the task
  22925. * @param meshesNames defines the list of mesh's names you want to load
  22926. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  22927. * @param sceneFilename defines the filename of the scene to load from
  22928. */
  22929. constructor(
  22930. /**
  22931. * Defines the name of the task
  22932. */
  22933. name: string,
  22934. /**
  22935. * Defines the list of mesh's names you want to load
  22936. */
  22937. meshesNames: any,
  22938. /**
  22939. * Defines the root url to use as a base to load your meshes and associated resources
  22940. */
  22941. rootUrl: string,
  22942. /**
  22943. * Defines the filename of the scene to load from
  22944. */
  22945. sceneFilename: string);
  22946. /**
  22947. * Execute the current task
  22948. * @param scene defines the scene where you want your assets to be loaded
  22949. * @param onSuccess is a callback called when the task is successfully executed
  22950. * @param onError is a callback called if an error occurs
  22951. */
  22952. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22953. }
  22954. /**
  22955. * Define a task used by {BABYLON.AssetsManager} to load text content
  22956. */
  22957. class TextFileAssetTask extends AbstractAssetTask {
  22958. /**
  22959. * Defines the name of the task
  22960. */
  22961. name: string;
  22962. /**
  22963. * Defines the location of the file to load
  22964. */
  22965. url: string;
  22966. /**
  22967. * Gets the loaded text string
  22968. */
  22969. text: string;
  22970. /**
  22971. * Callback called when the task is successful
  22972. */
  22973. onSuccess: (task: TextFileAssetTask) => void;
  22974. /**
  22975. * Callback called when the task is successful
  22976. */
  22977. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  22978. /**
  22979. * Creates a new TextFileAssetTask object
  22980. * @param name defines the name of the task
  22981. * @param url defines the location of the file to load
  22982. */
  22983. constructor(
  22984. /**
  22985. * Defines the name of the task
  22986. */
  22987. name: string,
  22988. /**
  22989. * Defines the location of the file to load
  22990. */
  22991. url: string);
  22992. /**
  22993. * Execute the current task
  22994. * @param scene defines the scene where you want your assets to be loaded
  22995. * @param onSuccess is a callback called when the task is successfully executed
  22996. * @param onError is a callback called if an error occurs
  22997. */
  22998. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22999. }
  23000. /**
  23001. * Define a task used by {BABYLON.AssetsManager} to load binary data
  23002. */
  23003. class BinaryFileAssetTask extends AbstractAssetTask {
  23004. /**
  23005. * Defines the name of the task
  23006. */
  23007. name: string;
  23008. /**
  23009. * Defines the location of the file to load
  23010. */
  23011. url: string;
  23012. /**
  23013. * Gets the lodaded data (as an array buffer)
  23014. */
  23015. data: ArrayBuffer;
  23016. /**
  23017. * Callback called when the task is successful
  23018. */
  23019. onSuccess: (task: BinaryFileAssetTask) => void;
  23020. /**
  23021. * Callback called when the task is successful
  23022. */
  23023. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  23024. /**
  23025. * Creates a new BinaryFileAssetTask object
  23026. * @param name defines the name of the new task
  23027. * @param url defines the location of the file to load
  23028. */
  23029. constructor(
  23030. /**
  23031. * Defines the name of the task
  23032. */
  23033. name: string,
  23034. /**
  23035. * Defines the location of the file to load
  23036. */
  23037. url: string);
  23038. /**
  23039. * Execute the current task
  23040. * @param scene defines the scene where you want your assets to be loaded
  23041. * @param onSuccess is a callback called when the task is successfully executed
  23042. * @param onError is a callback called if an error occurs
  23043. */
  23044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  23045. }
  23046. /**
  23047. * Define a task used by {BABYLON.AssetsManager} to load images
  23048. */
  23049. class ImageAssetTask extends AbstractAssetTask {
  23050. /**
  23051. * Defines the name of the task
  23052. */
  23053. name: string;
  23054. /**
  23055. * Defines the location of the image to load
  23056. */
  23057. url: string;
  23058. /**
  23059. * Gets the loaded images
  23060. */
  23061. image: HTMLImageElement;
  23062. /**
  23063. * Callback called when the task is successful
  23064. */
  23065. onSuccess: (task: ImageAssetTask) => void;
  23066. /**
  23067. * Callback called when the task is successful
  23068. */
  23069. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  23070. /**
  23071. * Creates a new ImageAssetTask
  23072. * @param name defines the name of the task
  23073. * @param url defines the location of the image to load
  23074. */
  23075. constructor(
  23076. /**
  23077. * Defines the name of the task
  23078. */
  23079. name: string,
  23080. /**
  23081. * Defines the location of the image to load
  23082. */
  23083. url: string);
  23084. /**
  23085. * Execute the current task
  23086. * @param scene defines the scene where you want your assets to be loaded
  23087. * @param onSuccess is a callback called when the task is successfully executed
  23088. * @param onError is a callback called if an error occurs
  23089. */
  23090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  23091. }
  23092. /**
  23093. * Defines the interface used by texture loading tasks
  23094. */
  23095. interface ITextureAssetTask<TEX extends BaseTexture> {
  23096. /**
  23097. * Gets the loaded texture
  23098. */
  23099. texture: TEX;
  23100. }
  23101. /**
  23102. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  23103. */
  23104. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  23105. /**
  23106. * Defines the name of the task
  23107. */
  23108. name: string;
  23109. /**
  23110. * Defines the location of the file to load
  23111. */
  23112. url: string;
  23113. /**
  23114. * Defines if mipmap should not be generated (default is false)
  23115. */
  23116. noMipmap: boolean | undefined;
  23117. /**
  23118. * Defines if texture must be inverted on Y axis (default is false)
  23119. */
  23120. invertY: boolean | undefined;
  23121. /**
  23122. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  23123. */
  23124. samplingMode: number;
  23125. /**
  23126. * Gets the loaded texture
  23127. */
  23128. texture: Texture;
  23129. /**
  23130. * Callback called when the task is successful
  23131. */
  23132. onSuccess: (task: TextureAssetTask) => void;
  23133. /**
  23134. * Callback called when the task is successful
  23135. */
  23136. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  23137. /**
  23138. * Creates a new TextureAssetTask object
  23139. * @param name defines the name of the task
  23140. * @param url defines the location of the file to load
  23141. * @param noMipmap defines if mipmap should not be generated (default is false)
  23142. * @param invertY defines if texture must be inverted on Y axis (default is false)
  23143. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  23144. */
  23145. constructor(
  23146. /**
  23147. * Defines the name of the task
  23148. */
  23149. name: string,
  23150. /**
  23151. * Defines the location of the file to load
  23152. */
  23153. url: string,
  23154. /**
  23155. * Defines if mipmap should not be generated (default is false)
  23156. */
  23157. noMipmap?: boolean | undefined,
  23158. /**
  23159. * Defines if texture must be inverted on Y axis (default is false)
  23160. */
  23161. invertY?: boolean | undefined,
  23162. /**
  23163. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  23164. */
  23165. samplingMode?: number);
  23166. /**
  23167. * Execute the current task
  23168. * @param scene defines the scene where you want your assets to be loaded
  23169. * @param onSuccess is a callback called when the task is successfully executed
  23170. * @param onError is a callback called if an error occurs
  23171. */
  23172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  23173. }
  23174. /**
  23175. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  23176. */
  23177. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  23178. /**
  23179. * Defines the name of the task
  23180. */
  23181. name: string;
  23182. /**
  23183. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  23184. */
  23185. url: string;
  23186. /**
  23187. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  23188. */
  23189. extensions: string[] | undefined;
  23190. /**
  23191. * Defines if mipmaps should not be generated (default is false)
  23192. */
  23193. noMipmap: boolean | undefined;
  23194. /**
  23195. * Defines the explicit list of files (undefined by default)
  23196. */
  23197. files: string[] | undefined;
  23198. /**
  23199. * Gets the loaded texture
  23200. */
  23201. texture: CubeTexture;
  23202. /**
  23203. * Callback called when the task is successful
  23204. */
  23205. onSuccess: (task: CubeTextureAssetTask) => void;
  23206. /**
  23207. * Callback called when the task is successful
  23208. */
  23209. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  23210. /**
  23211. * Creates a new CubeTextureAssetTask
  23212. * @param name defines the name of the task
  23213. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  23214. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  23215. * @param noMipmap defines if mipmaps should not be generated (default is false)
  23216. * @param files defines the explicit list of files (undefined by default)
  23217. */
  23218. constructor(
  23219. /**
  23220. * Defines the name of the task
  23221. */
  23222. name: string,
  23223. /**
  23224. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  23225. */
  23226. url: string,
  23227. /**
  23228. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  23229. */
  23230. extensions?: string[] | undefined,
  23231. /**
  23232. * Defines if mipmaps should not be generated (default is false)
  23233. */
  23234. noMipmap?: boolean | undefined,
  23235. /**
  23236. * Defines the explicit list of files (undefined by default)
  23237. */
  23238. files?: string[] | undefined);
  23239. /**
  23240. * Execute the current task
  23241. * @param scene defines the scene where you want your assets to be loaded
  23242. * @param onSuccess is a callback called when the task is successfully executed
  23243. * @param onError is a callback called if an error occurs
  23244. */
  23245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  23246. }
  23247. /**
  23248. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  23249. */
  23250. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  23251. /**
  23252. * Defines the name of the task
  23253. */
  23254. name: string;
  23255. /**
  23256. * Defines the location of the file to load
  23257. */
  23258. url: string;
  23259. /**
  23260. * 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.
  23261. */
  23262. size: number | undefined;
  23263. /**
  23264. * Defines if mipmaps should not be generated (default is false)
  23265. */
  23266. noMipmap: boolean;
  23267. /**
  23268. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  23269. */
  23270. generateHarmonics: boolean;
  23271. /**
  23272. * 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)
  23273. */
  23274. useInGammaSpace: boolean;
  23275. /**
  23276. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  23277. */
  23278. usePMREMGenerator: boolean;
  23279. /**
  23280. * Gets the loaded texture
  23281. */
  23282. texture: HDRCubeTexture;
  23283. /**
  23284. * Callback called when the task is successful
  23285. */
  23286. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  23287. /**
  23288. * Callback called when the task is successful
  23289. */
  23290. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  23291. /**
  23292. * Creates a new HDRCubeTextureAssetTask object
  23293. * @param name defines the name of the task
  23294. * @param url defines the location of the file to load
  23295. * @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.
  23296. * @param noMipmap defines if mipmaps should not be generated (default is false)
  23297. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  23298. * @param useInGammaSpace 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)
  23299. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  23300. */
  23301. constructor(
  23302. /**
  23303. * Defines the name of the task
  23304. */
  23305. name: string,
  23306. /**
  23307. * Defines the location of the file to load
  23308. */
  23309. url: string,
  23310. /**
  23311. * 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.
  23312. */
  23313. size?: number | undefined,
  23314. /**
  23315. * Defines if mipmaps should not be generated (default is false)
  23316. */
  23317. noMipmap?: boolean,
  23318. /**
  23319. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  23320. */
  23321. generateHarmonics?: boolean,
  23322. /**
  23323. * 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)
  23324. */
  23325. useInGammaSpace?: boolean,
  23326. /**
  23327. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  23328. */
  23329. usePMREMGenerator?: boolean);
  23330. /**
  23331. * Execute the current task
  23332. * @param scene defines the scene where you want your assets to be loaded
  23333. * @param onSuccess is a callback called when the task is successfully executed
  23334. * @param onError is a callback called if an error occurs
  23335. */
  23336. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  23337. }
  23338. /**
  23339. * This class can be used to easily import assets into a scene
  23340. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  23341. */
  23342. class AssetsManager {
  23343. private _scene;
  23344. private _isLoading;
  23345. protected _tasks: AbstractAssetTask[];
  23346. protected _waitingTasksCount: number;
  23347. protected _totalTasksCount: number;
  23348. /**
  23349. * Callback called when all tasks are processed
  23350. */
  23351. onFinish: (tasks: AbstractAssetTask[]) => void;
  23352. /**
  23353. * Callback called when a task is successful
  23354. */
  23355. onTaskSuccess: (task: AbstractAssetTask) => void;
  23356. /**
  23357. * Callback called when a task had an error
  23358. */
  23359. onTaskError: (task: AbstractAssetTask) => void;
  23360. /**
  23361. * Callback called when a task is done (whatever the result is)
  23362. */
  23363. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  23364. /**
  23365. * Observable called when all tasks are processed
  23366. */
  23367. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  23368. /**
  23369. * Observable called when a task had an error
  23370. */
  23371. onTaskErrorObservable: Observable<AbstractAssetTask>;
  23372. /**
  23373. * Observable called when a task is successful
  23374. */
  23375. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  23376. /**
  23377. * Observable called when a task is done (whatever the result is)
  23378. */
  23379. onProgressObservable: Observable<IAssetsProgressEvent>;
  23380. /**
  23381. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  23382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  23383. */
  23384. useDefaultLoadingScreen: boolean;
  23385. /**
  23386. * Creates a new AssetsManager
  23387. * @param scene defines the scene to work on
  23388. */
  23389. constructor(scene: Scene);
  23390. /**
  23391. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  23392. * @param taskName defines the name of the new task
  23393. * @param meshesNames defines the name of meshes to load
  23394. * @param rootUrl defines the root url to use to locate files
  23395. * @param sceneFilename defines the filename of the scene file
  23396. * @returns a new {BABYLON.MeshAssetTask} object
  23397. */
  23398. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  23399. /**
  23400. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  23401. * @param taskName defines the name of the new task
  23402. * @param url defines the url of the file to load
  23403. * @returns a new {BABYLON.TextFileAssetTask} object
  23404. */
  23405. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  23406. /**
  23407. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  23408. * @param taskName defines the name of the new task
  23409. * @param url defines the url of the file to load
  23410. * @returns a new {BABYLON.BinaryFileAssetTask} object
  23411. */
  23412. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  23413. /**
  23414. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  23415. * @param taskName defines the name of the new task
  23416. * @param url defines the url of the file to load
  23417. * @returns a new {BABYLON.ImageAssetTask} object
  23418. */
  23419. addImageTask(taskName: string, url: string): ImageAssetTask;
  23420. /**
  23421. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  23422. * @param taskName defines the name of the new task
  23423. * @param url defines the url of the file to load
  23424. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  23425. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  23426. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  23427. * @returns a new {BABYLON.TextureAssetTask} object
  23428. */
  23429. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  23430. /**
  23431. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  23432. * @param taskName defines the name of the new task
  23433. * @param url defines the url of the file to load
  23434. * @param extensions defines the extension to use to load the cube map (can be null)
  23435. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  23436. * @param files defines the list of files to load (can be null)
  23437. * @returns a new {BABYLON.CubeTextureAssetTask} object
  23438. */
  23439. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  23440. /**
  23441. *
  23442. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  23443. * @param taskName defines the name of the new task
  23444. * @param url defines the url of the file to load
  23445. * @param size defines the size you want for the cubemap (can be null)
  23446. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  23447. * @param generateHarmonics defines if you want to automatically generate (true by default)
  23448. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  23449. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  23450. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  23451. */
  23452. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  23453. private _decreaseWaitingTasksCount(task);
  23454. private _runTask(task);
  23455. /**
  23456. * Reset the {BABYLON.AssetsManager} and remove all tasks
  23457. * @return the current instance of the {BABYLON.AssetsManager}
  23458. */
  23459. reset(): AssetsManager;
  23460. /**
  23461. * Start the loading process
  23462. * @return the current instance of the {BABYLON.AssetsManager}
  23463. */
  23464. load(): AssetsManager;
  23465. }
  23466. }
  23467. declare module BABYLON {
  23468. class Database {
  23469. private callbackManifestChecked;
  23470. private currentSceneUrl;
  23471. private db;
  23472. private _enableSceneOffline;
  23473. private _enableTexturesOffline;
  23474. private manifestVersionFound;
  23475. private mustUpdateRessources;
  23476. private hasReachedQuota;
  23477. private isSupported;
  23478. private idbFactory;
  23479. static IsUASupportingBlobStorage: boolean;
  23480. static IDBStorageEnabled: boolean;
  23481. readonly enableSceneOffline: boolean;
  23482. readonly enableTexturesOffline: boolean;
  23483. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  23484. static parseURL: (url: string) => string;
  23485. static ReturnFullUrlLocation: (url: string) => string;
  23486. checkManifestFile(): void;
  23487. openAsync(successCallback: () => void, errorCallback: () => void): void;
  23488. loadImageFromDB(url: string, image: HTMLImageElement): void;
  23489. private _loadImageFromDBAsync(url, image, notInDBCallback);
  23490. private _saveImageIntoDBAsync(url, image);
  23491. private _checkVersionFromDB(url, versionLoaded);
  23492. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  23493. private _saveVersionIntoDBAsync(url, callback);
  23494. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  23495. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  23496. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  23497. }
  23498. }
  23499. declare module BABYLON {
  23500. interface DDSInfo {
  23501. width: number;
  23502. height: number;
  23503. mipmapCount: number;
  23504. isFourCC: boolean;
  23505. isRGB: boolean;
  23506. isLuminance: boolean;
  23507. isCube: boolean;
  23508. isCompressed: boolean;
  23509. dxgiFormat: number;
  23510. textureType: number;
  23511. }
  23512. class DDSTools {
  23513. static StoreLODInAlphaChannel: boolean;
  23514. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  23515. private static _FloatView;
  23516. private static _Int32View;
  23517. private static _ToHalfFloat(value);
  23518. private static _FromHalfFloat(value);
  23519. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  23520. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  23521. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  23522. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  23523. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  23524. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  23525. private static _ExtractLongWordOrder(value);
  23526. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  23527. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  23528. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  23533. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23534. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23535. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23536. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23537. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23538. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23539. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23540. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23541. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23542. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23543. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  23544. class SerializationHelper {
  23545. static Serialize<T>(entity: T, serializationObject?: any): any;
  23546. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  23547. static Clone<T>(creationFunction: () => T, source: T): T;
  23548. static Instanciate<T>(creationFunction: () => T, source: T): T;
  23549. }
  23550. }
  23551. declare module BABYLON {
  23552. /**
  23553. * Wrapper class for promise with external resolve and reject.
  23554. */
  23555. class Deferred<T> {
  23556. /**
  23557. * The promise associated with this deferred object.
  23558. */
  23559. readonly promise: Promise<T>;
  23560. private _resolve;
  23561. private _reject;
  23562. /**
  23563. * The resolve method of the promise associated with this deferred object.
  23564. */
  23565. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  23566. /**
  23567. * The reject method of the promise associated with this deferred object.
  23568. */
  23569. readonly reject: (reason?: any) => void;
  23570. /**
  23571. * Constructor for this deferred object.
  23572. */
  23573. constructor();
  23574. }
  23575. }
  23576. declare module BABYLON {
  23577. class FilesInput {
  23578. static FilesToLoad: {
  23579. [key: string]: File;
  23580. };
  23581. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  23582. private _engine;
  23583. private _currentScene;
  23584. private _sceneLoadedCallback;
  23585. private _progressCallback;
  23586. private _additionalRenderLoopLogicCallback;
  23587. private _textureLoadingCallback;
  23588. private _startingProcessingFilesCallback;
  23589. private _onReloadCallback;
  23590. private _errorCallback;
  23591. private _elementToMonitor;
  23592. private _sceneFileToLoad;
  23593. private _filesToLoad;
  23594. 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);
  23595. private _dragEnterHandler;
  23596. private _dragOverHandler;
  23597. private _dropHandler;
  23598. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  23599. dispose(): void;
  23600. private renderFunction();
  23601. private drag(e);
  23602. private drop(eventDrop);
  23603. private _traverseFolder(folder, files, remaining, callback);
  23604. private _processFiles(files);
  23605. loadFiles(event: any): void;
  23606. private _processReload();
  23607. reload(): void;
  23608. }
  23609. }
  23610. declare module BABYLON {
  23611. /**
  23612. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  23613. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  23614. */
  23615. class KhronosTextureContainer {
  23616. arrayBuffer: any;
  23617. static HEADER_LEN: number;
  23618. static COMPRESSED_2D: number;
  23619. static COMPRESSED_3D: number;
  23620. static TEX_2D: number;
  23621. static TEX_3D: number;
  23622. glType: number;
  23623. glTypeSize: number;
  23624. glFormat: number;
  23625. glInternalFormat: number;
  23626. glBaseInternalFormat: number;
  23627. pixelWidth: number;
  23628. pixelHeight: number;
  23629. pixelDepth: number;
  23630. numberOfArrayElements: number;
  23631. numberOfFaces: number;
  23632. numberOfMipmapLevels: number;
  23633. bytesOfKeyValueData: number;
  23634. loadType: number;
  23635. /**
  23636. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  23637. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  23638. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  23639. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  23640. */
  23641. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  23642. switchEndainness(val: number): number;
  23643. /**
  23644. * It is assumed that the texture has already been created & is currently bound
  23645. */
  23646. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  23647. private _upload2DCompressedLevels(gl, loadMipmaps);
  23648. }
  23649. }
  23650. declare module BABYLON {
  23651. /**
  23652. * A class serves as a medium between the observable and its observers
  23653. */
  23654. class EventState {
  23655. /**
  23656. * Create a new EventState
  23657. * @param mask defines the mask associated with this state
  23658. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  23659. * @param target defines the original target of the state
  23660. * @param currentTarget defines the current target of the state
  23661. */
  23662. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  23663. /**
  23664. * Initialize the current event state
  23665. * @param mask defines the mask associated with this state
  23666. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  23667. * @param target defines the original target of the state
  23668. * @param currentTarget defines the current target of the state
  23669. * @returns the current event state
  23670. */
  23671. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  23672. /**
  23673. * An Observer can set this property to true to prevent subsequent observers of being notified
  23674. */
  23675. skipNextObservers: boolean;
  23676. /**
  23677. * Get the mask value that were used to trigger the event corresponding to this EventState object
  23678. */
  23679. mask: number;
  23680. /**
  23681. * The object that originally notified the event
  23682. */
  23683. target?: any;
  23684. /**
  23685. * The current object in the bubbling phase
  23686. */
  23687. currentTarget?: any;
  23688. /**
  23689. * This will be populated with the return value of the last function that was executed.
  23690. * If it is the first function in the callback chain it will be the event data.
  23691. */
  23692. lastReturnValue?: any;
  23693. }
  23694. /**
  23695. * Represent an Observer registered to a given Observable object.
  23696. */
  23697. class Observer<T> {
  23698. /**
  23699. * Defines the callback to call when the observer is notified
  23700. */
  23701. callback: (eventData: T, eventState: EventState) => void;
  23702. /**
  23703. * Defines the mask of the observer (used to filter notifications)
  23704. */
  23705. mask: number;
  23706. /**
  23707. * Defines the current scope used to restore the JS context
  23708. */
  23709. scope: any;
  23710. /** @ignore */
  23711. _willBeUnregistered: boolean;
  23712. /**
  23713. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  23714. */
  23715. unregisterOnNextCall: boolean;
  23716. /**
  23717. * Creates a new observer
  23718. * @param callback defines the callback to call when the observer is notified
  23719. * @param mask defines the mask of the observer (used to filter notifications)
  23720. * @param scope defines the current scope used to restore the JS context
  23721. */
  23722. constructor(
  23723. /**
  23724. * Defines the callback to call when the observer is notified
  23725. */
  23726. callback: (eventData: T, eventState: EventState) => void,
  23727. /**
  23728. * Defines the mask of the observer (used to filter notifications)
  23729. */
  23730. mask: number,
  23731. /**
  23732. * Defines the current scope used to restore the JS context
  23733. */
  23734. scope?: any);
  23735. }
  23736. /**
  23737. * Represent a list of observers registered to multiple Observables object.
  23738. */
  23739. class MultiObserver<T> {
  23740. private _observers;
  23741. private _observables;
  23742. /**
  23743. * Release associated resources
  23744. */
  23745. dispose(): void;
  23746. /**
  23747. * Raise a callback when one of the observable will notify
  23748. * @param observables defines a list of observables to watch
  23749. * @param callback defines the callback to call on notification
  23750. * @param mask defines the mask used to filter notifications
  23751. * @param scope defines the current scope used to restore the JS context
  23752. * @returns the new MultiObserver
  23753. */
  23754. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  23755. }
  23756. /**
  23757. * The Observable class is a simple implementation of the Observable pattern.
  23758. *
  23759. * 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.
  23760. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  23761. * 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).
  23762. * 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.
  23763. */
  23764. class Observable<T> {
  23765. private _observers;
  23766. private _eventState;
  23767. private _onObserverAdded;
  23768. /**
  23769. * Creates a new observable
  23770. * @param onObserverAdded defines a callback to call when a new observer is added
  23771. */
  23772. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  23773. /**
  23774. * Create a new Observer with the specified callback
  23775. * @param callback the callback that will be executed for that Observer
  23776. * @param mask the mask used to filter observers
  23777. * @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.
  23778. * @param scope optional scope for the callback to be called from
  23779. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  23780. * @returns the new observer created for the callback
  23781. */
  23782. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  23783. /**
  23784. * Remove an Observer from the Observable object
  23785. * @param observer the instance of the Observer to remove
  23786. * @returns false if it doesn't belong to this Observable
  23787. */
  23788. remove(observer: Nullable<Observer<T>>): boolean;
  23789. /**
  23790. * Remove a callback from the Observable object
  23791. * @param callback the callback to remove
  23792. * @param scope optional scope. If used only the callbacks with this scope will be removed
  23793. * @returns false if it doesn't belong to this Observable
  23794. */
  23795. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  23796. private _deferUnregister(observer);
  23797. /**
  23798. * Notify all Observers by calling their respective callback with the given data
  23799. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  23800. * @param eventData defines the data to send to all observers
  23801. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  23802. * @param target defines the original target of the state
  23803. * @param currentTarget defines the current target of the state
  23804. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  23805. */
  23806. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  23807. /**
  23808. * Calling this will execute each callback, expecting it to be a promise or return a value.
  23809. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  23810. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  23811. * and it is crucial that all callbacks will be executed.
  23812. * The order of the callbacks is kept, callbacks are not executed parallel.
  23813. *
  23814. * @param eventData The data to be sent to each callback
  23815. * @param mask is used to filter observers defaults to -1
  23816. * @param target defines the callback target (see EventState)
  23817. * @param currentTarget defines he current object in the bubbling phase
  23818. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  23819. */
  23820. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  23821. /**
  23822. * Notify a specific observer
  23823. * @param observer defines the observer to notify
  23824. * @param eventData defines the data to be sent to each callback
  23825. * @param mask is used to filter observers defaults to -1
  23826. */
  23827. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  23828. /**
  23829. * Gets a boolean indicating if the observable has at least one observer
  23830. * @returns true is the Observable has at least one Observer registered
  23831. */
  23832. hasObservers(): boolean;
  23833. /**
  23834. * Clear the list of observers
  23835. */
  23836. clear(): void;
  23837. /**
  23838. * Clone the current observable
  23839. * @returns a new observable
  23840. */
  23841. clone(): Observable<T>;
  23842. /**
  23843. * Does this observable handles observer registered with a given mask
  23844. * @param mask defines the mask to be tested
  23845. * @return whether or not one observer registered with the given mask is handeled
  23846. **/
  23847. hasSpecificMask(mask?: number): boolean;
  23848. }
  23849. }
  23850. declare module BABYLON {
  23851. /**
  23852. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  23853. */
  23854. class PerformanceMonitor {
  23855. private _enabled;
  23856. private _rollingFrameTime;
  23857. private _lastFrameTimeMs;
  23858. /**
  23859. * constructor
  23860. * @param frameSampleSize The number of samples required to saturate the sliding window
  23861. */
  23862. constructor(frameSampleSize?: number);
  23863. /**
  23864. * Samples current frame
  23865. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  23866. */
  23867. sampleFrame(timeMs?: number): void;
  23868. /**
  23869. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  23870. * @return Average frame time in milliseconds
  23871. */
  23872. readonly averageFrameTime: number;
  23873. /**
  23874. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  23875. * @return Frame time variance in milliseconds squared
  23876. */
  23877. readonly averageFrameTimeVariance: number;
  23878. /**
  23879. * Returns the frame time of the most recent frame
  23880. * @return Frame time in milliseconds
  23881. */
  23882. readonly instantaneousFrameTime: number;
  23883. /**
  23884. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  23885. * @return Framerate in frames per second
  23886. */
  23887. readonly averageFPS: number;
  23888. /**
  23889. * Returns the average framerate in frames per second using the most recent frame time
  23890. * @return Framerate in frames per second
  23891. */
  23892. readonly instantaneousFPS: number;
  23893. /**
  23894. * Returns true if enough samples have been taken to completely fill the sliding window
  23895. * @return true if saturated
  23896. */
  23897. readonly isSaturated: boolean;
  23898. /**
  23899. * Enables contributions to the sliding window sample set
  23900. */
  23901. enable(): void;
  23902. /**
  23903. * Disables contributions to the sliding window sample set
  23904. * Samples will not be interpolated over the disabled period
  23905. */
  23906. disable(): void;
  23907. /**
  23908. * Returns true if sampling is enabled
  23909. * @return true if enabled
  23910. */
  23911. readonly isEnabled: boolean;
  23912. /**
  23913. * Resets performance monitor
  23914. */
  23915. reset(): void;
  23916. }
  23917. /**
  23918. * RollingAverage
  23919. *
  23920. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  23921. */
  23922. class RollingAverage {
  23923. /**
  23924. * Current average
  23925. */
  23926. average: number;
  23927. /**
  23928. * Current variance
  23929. */
  23930. variance: number;
  23931. protected _samples: Array<number>;
  23932. protected _sampleCount: number;
  23933. protected _pos: number;
  23934. protected _m2: number;
  23935. /**
  23936. * constructor
  23937. * @param length The number of samples required to saturate the sliding window
  23938. */
  23939. constructor(length: number);
  23940. /**
  23941. * Adds a sample to the sample set
  23942. * @param v The sample value
  23943. */
  23944. add(v: number): void;
  23945. /**
  23946. * Returns previously added values or null if outside of history or outside the sliding window domain
  23947. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  23948. * @return Value previously recorded with add() or null if outside of range
  23949. */
  23950. history(i: number): number;
  23951. /**
  23952. * Returns true if enough samples have been taken to completely fill the sliding window
  23953. * @return true if sample-set saturated
  23954. */
  23955. isSaturated(): boolean;
  23956. /**
  23957. * Resets the rolling average (equivalent to 0 samples taken so far)
  23958. */
  23959. reset(): void;
  23960. /**
  23961. * Wraps a value around the sample range boundaries
  23962. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  23963. * @return Wrapped position in sample range
  23964. */
  23965. protected _wrapPosition(i: number): number;
  23966. }
  23967. }
  23968. declare module BABYLON {
  23969. /**
  23970. * Helper class that provides a small promise polyfill
  23971. */
  23972. class PromisePolyfill {
  23973. /**
  23974. * Static function used to check if the polyfill is required
  23975. * If this is the case then the function will inject the polyfill to window.Promise
  23976. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  23977. */
  23978. static Apply(force?: boolean): void;
  23979. }
  23980. }
  23981. declare module BABYLON {
  23982. /**
  23983. * Defines the root class used to create scene optimization to use with SceneOptimizer
  23984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23985. */
  23986. class SceneOptimization {
  23987. /**
  23988. * Defines the priority of this optimization (0 by default which means first in the list)
  23989. */
  23990. priority: number;
  23991. /**
  23992. * Gets a string describing the action executed by the current optimization
  23993. * @returns description string
  23994. */
  23995. getDescription(): string;
  23996. /**
  23997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23998. * @param scene defines the current scene where to apply this optimization
  23999. * @param optimizer defines the current optimizer
  24000. * @returns true if everything that can be done was applied
  24001. */
  24002. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24003. /**
  24004. * Creates the SceneOptimization object
  24005. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  24006. * @param desc defines the description associated with the optimization
  24007. */
  24008. constructor(
  24009. /**
  24010. * Defines the priority of this optimization (0 by default which means first in the list)
  24011. */
  24012. priority?: number);
  24013. }
  24014. /**
  24015. * Defines an optimization used to reduce the size of render target textures
  24016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24017. */
  24018. class TextureOptimization extends SceneOptimization {
  24019. /**
  24020. * Defines the priority of this optimization (0 by default which means first in the list)
  24021. */
  24022. priority: number;
  24023. /**
  24024. * 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
  24025. */
  24026. maximumSize: number;
  24027. /**
  24028. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  24029. */
  24030. step: number;
  24031. /**
  24032. * Gets a string describing the action executed by the current optimization
  24033. * @returns description string
  24034. */
  24035. getDescription(): string;
  24036. /**
  24037. * Creates the TextureOptimization object
  24038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  24039. * @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
  24040. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  24041. */
  24042. constructor(
  24043. /**
  24044. * Defines the priority of this optimization (0 by default which means first in the list)
  24045. */
  24046. priority?: number,
  24047. /**
  24048. * 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
  24049. */
  24050. maximumSize?: number,
  24051. /**
  24052. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  24053. */
  24054. step?: number);
  24055. /**
  24056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24057. * @param scene defines the current scene where to apply this optimization
  24058. * @param optimizer defines the current optimizer
  24059. * @returns true if everything that can be done was applied
  24060. */
  24061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24062. }
  24063. /**
  24064. * Defines an optimization used to increase or decrease the rendering resolution
  24065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24066. */
  24067. class HardwareScalingOptimization extends SceneOptimization {
  24068. /**
  24069. * Defines the priority of this optimization (0 by default which means first in the list)
  24070. */
  24071. priority: number;
  24072. /**
  24073. * Defines the maximum scale to use (2 by default)
  24074. */
  24075. maximumScale: number;
  24076. /**
  24077. * Defines the step to use between two passes (0.5 by default)
  24078. */
  24079. step: number;
  24080. private _currentScale;
  24081. private _directionOffset;
  24082. /**
  24083. * Gets a string describing the action executed by the current optimization
  24084. * @return description string
  24085. */
  24086. getDescription(): string;
  24087. /**
  24088. * Creates the HardwareScalingOptimization object
  24089. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  24090. * @param maximumScale defines the maximum scale to use (2 by default)
  24091. * @param step defines the step to use between two passes (0.5 by default)
  24092. */
  24093. constructor(
  24094. /**
  24095. * Defines the priority of this optimization (0 by default which means first in the list)
  24096. */
  24097. priority?: number,
  24098. /**
  24099. * Defines the maximum scale to use (2 by default)
  24100. */
  24101. maximumScale?: number,
  24102. /**
  24103. * Defines the step to use between two passes (0.5 by default)
  24104. */
  24105. step?: number);
  24106. /**
  24107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24108. * @param scene defines the current scene where to apply this optimization
  24109. * @param optimizer defines the current optimizer
  24110. * @returns true if everything that can be done was applied
  24111. */
  24112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24113. }
  24114. /**
  24115. * Defines an optimization used to remove shadows
  24116. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24117. */
  24118. class ShadowsOptimization extends SceneOptimization {
  24119. /**
  24120. * Gets a string describing the action executed by the current optimization
  24121. * @return description string
  24122. */
  24123. getDescription(): string;
  24124. /**
  24125. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24126. * @param scene defines the current scene where to apply this optimization
  24127. * @param optimizer defines the current optimizer
  24128. * @returns true if everything that can be done was applied
  24129. */
  24130. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24131. }
  24132. /**
  24133. * Defines an optimization used to turn post-processes off
  24134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24135. */
  24136. class PostProcessesOptimization extends SceneOptimization {
  24137. /**
  24138. * Gets a string describing the action executed by the current optimization
  24139. * @return description string
  24140. */
  24141. getDescription(): string;
  24142. /**
  24143. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24144. * @param scene defines the current scene where to apply this optimization
  24145. * @param optimizer defines the current optimizer
  24146. * @returns true if everything that can be done was applied
  24147. */
  24148. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24149. }
  24150. /**
  24151. * Defines an optimization used to turn lens flares off
  24152. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24153. */
  24154. class LensFlaresOptimization extends SceneOptimization {
  24155. /**
  24156. * Gets a string describing the action executed by the current optimization
  24157. * @return description string
  24158. */
  24159. getDescription(): string;
  24160. /**
  24161. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24162. * @param scene defines the current scene where to apply this optimization
  24163. * @param optimizer defines the current optimizer
  24164. * @returns true if everything that can be done was applied
  24165. */
  24166. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24167. }
  24168. /**
  24169. * Defines an optimization based on user defined callback.
  24170. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24171. */
  24172. class CustomOptimization extends SceneOptimization {
  24173. /**
  24174. * Callback called to apply the custom optimization.
  24175. */
  24176. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  24177. /**
  24178. * Callback called to get custom description
  24179. */
  24180. onGetDescription: () => string;
  24181. /**
  24182. * Gets a string describing the action executed by the current optimization
  24183. * @returns description string
  24184. */
  24185. getDescription(): string;
  24186. /**
  24187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24188. * @param scene defines the current scene where to apply this optimization
  24189. * @param optimizer defines the current optimizer
  24190. * @returns true if everything that can be done was applied
  24191. */
  24192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24193. }
  24194. /**
  24195. * Defines an optimization used to turn particles off
  24196. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24197. */
  24198. class ParticlesOptimization extends SceneOptimization {
  24199. /**
  24200. * Gets a string describing the action executed by the current optimization
  24201. * @return description string
  24202. */
  24203. getDescription(): string;
  24204. /**
  24205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24206. * @param scene defines the current scene where to apply this optimization
  24207. * @param optimizer defines the current optimizer
  24208. * @returns true if everything that can be done was applied
  24209. */
  24210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24211. }
  24212. /**
  24213. * Defines an optimization used to turn render targets off
  24214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24215. */
  24216. class RenderTargetsOptimization extends SceneOptimization {
  24217. /**
  24218. * Gets a string describing the action executed by the current optimization
  24219. * @return description string
  24220. */
  24221. getDescription(): string;
  24222. /**
  24223. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24224. * @param scene defines the current scene where to apply this optimization
  24225. * @param optimizer defines the current optimizer
  24226. * @returns true if everything that can be done was applied
  24227. */
  24228. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  24229. }
  24230. /**
  24231. * Defines an optimization used to merge meshes with compatible materials
  24232. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24233. */
  24234. class MergeMeshesOptimization extends SceneOptimization {
  24235. private static _UpdateSelectionTree;
  24236. /**
  24237. * Gets or sets a boolean which defines if optimization octree has to be updated
  24238. */
  24239. /**
  24240. * Gets or sets a boolean which defines if optimization octree has to be updated
  24241. */
  24242. static UpdateSelectionTree: boolean;
  24243. /**
  24244. * Gets a string describing the action executed by the current optimization
  24245. * @return description string
  24246. */
  24247. getDescription(): string;
  24248. private _canBeMerged;
  24249. /**
  24250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  24251. * @param scene defines the current scene where to apply this optimization
  24252. * @param optimizer defines the current optimizer
  24253. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  24254. * @returns true if everything that can be done was applied
  24255. */
  24256. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  24257. }
  24258. /**
  24259. * Defines a list of options used by SceneOptimizer
  24260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24261. */
  24262. class SceneOptimizerOptions {
  24263. /**
  24264. * Defines the target frame rate to reach (60 by default)
  24265. */
  24266. targetFrameRate: number;
  24267. /**
  24268. * Defines the interval between two checkes (2000ms by default)
  24269. */
  24270. trackerDuration: number;
  24271. /**
  24272. * Gets the list of optimizations to apply
  24273. */
  24274. optimizations: SceneOptimization[];
  24275. /**
  24276. * Creates a new list of options used by SceneOptimizer
  24277. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  24278. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  24279. */
  24280. constructor(
  24281. /**
  24282. * Defines the target frame rate to reach (60 by default)
  24283. */
  24284. targetFrameRate?: number,
  24285. /**
  24286. * Defines the interval between two checkes (2000ms by default)
  24287. */
  24288. trackerDuration?: number);
  24289. /**
  24290. * Add a new optimization
  24291. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  24292. * @returns the current SceneOptimizerOptions
  24293. */
  24294. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  24295. /**
  24296. * Add a new custom optimization
  24297. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  24298. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  24299. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  24300. * @returns the current SceneOptimizerOptions
  24301. */
  24302. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  24303. /**
  24304. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  24305. * @param targetFrameRate defines the target frame rate (60 by default)
  24306. * @returns a SceneOptimizerOptions object
  24307. */
  24308. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  24309. /**
  24310. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  24311. * @param targetFrameRate defines the target frame rate (60 by default)
  24312. * @returns a SceneOptimizerOptions object
  24313. */
  24314. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  24315. /**
  24316. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  24317. * @param targetFrameRate defines the target frame rate (60 by default)
  24318. * @returns a SceneOptimizerOptions object
  24319. */
  24320. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  24321. }
  24322. /**
  24323. * Class used to run optimizations in order to reach a target frame rate
  24324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  24325. */
  24326. class SceneOptimizer implements IDisposable {
  24327. private _isRunning;
  24328. private _options;
  24329. private _scene;
  24330. private _currentPriorityLevel;
  24331. private _targetFrameRate;
  24332. private _trackerDuration;
  24333. private _currentFrameRate;
  24334. private _sceneDisposeObserver;
  24335. private _improvementMode;
  24336. /**
  24337. * Defines an observable called when the optimizer reaches the target frame rate
  24338. */
  24339. onSuccessObservable: Observable<SceneOptimizer>;
  24340. /**
  24341. * Defines an observable called when the optimizer enables an optimization
  24342. */
  24343. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  24344. /**
  24345. * Defines an observable called when the optimizer is not able to reach the target frame rate
  24346. */
  24347. onFailureObservable: Observable<SceneOptimizer>;
  24348. /**
  24349. * Gets a boolean indicating if the optimizer is in improvement mode
  24350. */
  24351. readonly isInImprovementMode: boolean;
  24352. /**
  24353. * Gets the current priority level (0 at start)
  24354. */
  24355. readonly currentPriorityLevel: number;
  24356. /**
  24357. * Gets the current frame rate checked by the SceneOptimizer
  24358. */
  24359. readonly currentFrameRate: number;
  24360. /**
  24361. * Gets or sets the current target frame rate (60 by default)
  24362. */
  24363. /**
  24364. * Gets or sets the current target frame rate (60 by default)
  24365. */
  24366. targetFrameRate: number;
  24367. /**
  24368. * Gets or sets the current interval between two checks (every 2000ms by default)
  24369. */
  24370. /**
  24371. * Gets or sets the current interval between two checks (every 2000ms by default)
  24372. */
  24373. trackerDuration: number;
  24374. /**
  24375. * Gets the list of active optimizations
  24376. */
  24377. readonly optimizations: SceneOptimization[];
  24378. /**
  24379. * Creates a new SceneOptimizer
  24380. * @param scene defines the scene to work on
  24381. * @param options defines the options to use with the SceneOptimizer
  24382. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  24383. * @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)
  24384. */
  24385. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  24386. /**
  24387. * Stops the current optimizer
  24388. */
  24389. stop(): void;
  24390. /**
  24391. * Reset the optimizer to initial step (current priority level = 0)
  24392. */
  24393. reset(): void;
  24394. /**
  24395. * Start the optimizer. By default it will try to reach a specific framerate
  24396. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  24397. */
  24398. start(): void;
  24399. private _checkCurrentState();
  24400. /**
  24401. * Release all resources
  24402. */
  24403. dispose(): void;
  24404. /**
  24405. * Helper function to create a SceneOptimizer with one single line of code
  24406. * @param scene defines the scene to work on
  24407. * @param options defines the options to use with the SceneOptimizer
  24408. * @param onSuccess defines a callback to call on success
  24409. * @param onFailure defines a callback to call on failure
  24410. * @returns the new SceneOptimizer object
  24411. */
  24412. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  24413. }
  24414. }
  24415. declare module BABYLON {
  24416. class SceneSerializer {
  24417. static ClearCache(): void;
  24418. static Serialize(scene: Scene): any;
  24419. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  24420. }
  24421. }
  24422. declare module BABYLON {
  24423. class SmartArray<T> {
  24424. data: Array<T>;
  24425. length: number;
  24426. protected _id: number;
  24427. [index: number]: T;
  24428. constructor(capacity: number);
  24429. push(value: T): void;
  24430. forEach(func: (content: T) => void): void;
  24431. sort(compareFn: (a: T, b: T) => number): void;
  24432. reset(): void;
  24433. dispose(): void;
  24434. concat(array: any): void;
  24435. indexOf(value: T): number;
  24436. contains(value: T): boolean;
  24437. private static _GlobalId;
  24438. }
  24439. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  24440. private _duplicateId;
  24441. [index: number]: T;
  24442. push(value: T): void;
  24443. pushNoDuplicate(value: T): boolean;
  24444. reset(): void;
  24445. concatWithNoDuplicate(array: any): void;
  24446. }
  24447. }
  24448. declare module BABYLON {
  24449. /**
  24450. * This class implement a typical dictionary using a string as key and the generic type T as value.
  24451. * The underlying implementation relies on an associative array to ensure the best performances.
  24452. * The value can be anything including 'null' but except 'undefined'
  24453. */
  24454. class StringDictionary<T> {
  24455. /**
  24456. * This will clear this dictionary and copy the content from the 'source' one.
  24457. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  24458. * @param source the dictionary to take the content from and copy to this dictionary
  24459. */
  24460. copyFrom(source: StringDictionary<T>): void;
  24461. /**
  24462. * Get a value based from its key
  24463. * @param key the given key to get the matching value from
  24464. * @return the value if found, otherwise undefined is returned
  24465. */
  24466. get(key: string): T | undefined;
  24467. /**
  24468. * Get a value from its key or add it if it doesn't exist.
  24469. * This method will ensure you that a given key/data will be present in the dictionary.
  24470. * @param key the given key to get the matching value from
  24471. * @param factory the factory that will create the value if the key is not present in the dictionary.
  24472. * The factory will only be invoked if there's no data for the given key.
  24473. * @return the value corresponding to the key.
  24474. */
  24475. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  24476. /**
  24477. * Get a value from its key if present in the dictionary otherwise add it
  24478. * @param key the key to get the value from
  24479. * @param val if there's no such key/value pair in the dictionary add it with this value
  24480. * @return the value corresponding to the key
  24481. */
  24482. getOrAdd(key: string, val: T): T;
  24483. /**
  24484. * Check if there's a given key in the dictionary
  24485. * @param key the key to check for
  24486. * @return true if the key is present, false otherwise
  24487. */
  24488. contains(key: string): boolean;
  24489. /**
  24490. * Add a new key and its corresponding value
  24491. * @param key the key to add
  24492. * @param value the value corresponding to the key
  24493. * @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
  24494. */
  24495. add(key: string, value: T): boolean;
  24496. set(key: string, value: T): boolean;
  24497. /**
  24498. * Get the element of the given key and remove it from the dictionary
  24499. * @param key
  24500. */
  24501. getAndRemove(key: string): Nullable<T>;
  24502. /**
  24503. * Remove a key/value from the dictionary.
  24504. * @param key the key to remove
  24505. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  24506. */
  24507. remove(key: string): boolean;
  24508. /**
  24509. * Clear the whole content of the dictionary
  24510. */
  24511. clear(): void;
  24512. readonly count: number;
  24513. /**
  24514. * Execute a callback on each key/val of the dictionary.
  24515. * Note that you can remove any element in this dictionary in the callback implementation
  24516. * @param callback the callback to execute on a given key/value pair
  24517. */
  24518. forEach(callback: (key: string, val: T) => void): void;
  24519. /**
  24520. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  24521. * If the callback returns null or undefined the method will iterate to the next key/value pair
  24522. * Note that you can remove any element in this dictionary in the callback implementation
  24523. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  24524. */
  24525. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  24526. private _count;
  24527. private _data;
  24528. }
  24529. }
  24530. declare module BABYLON {
  24531. class Tags {
  24532. static EnableFor(obj: any): void;
  24533. static DisableFor(obj: any): void;
  24534. static HasTags(obj: any): boolean;
  24535. static GetTags(obj: any, asString?: boolean): any;
  24536. static AddTagsTo(obj: any, tagsString: string): void;
  24537. static _AddTagTo(obj: any, tag: string): void;
  24538. static RemoveTagsFrom(obj: any, tagsString: string): void;
  24539. static _RemoveTagFrom(obj: any, tag: string): void;
  24540. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  24541. }
  24542. }
  24543. declare module BABYLON {
  24544. class TextureTools {
  24545. /**
  24546. * Uses the GPU to create a copy texture rescaled at a given size
  24547. * @param texture Texture to copy from
  24548. * @param width Desired width
  24549. * @param height Desired height
  24550. * @return Generated texture
  24551. */
  24552. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  24553. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24554. private static _environmentBRDFBase64Texture;
  24555. }
  24556. }
  24557. declare module BABYLON {
  24558. class TGATools {
  24559. private static _TYPE_INDEXED;
  24560. private static _TYPE_RGB;
  24561. private static _TYPE_GREY;
  24562. private static _TYPE_RLE_INDEXED;
  24563. private static _TYPE_RLE_RGB;
  24564. private static _TYPE_RLE_GREY;
  24565. private static _ORIGIN_MASK;
  24566. private static _ORIGIN_SHIFT;
  24567. private static _ORIGIN_BL;
  24568. private static _ORIGIN_BR;
  24569. private static _ORIGIN_UL;
  24570. private static _ORIGIN_UR;
  24571. static GetTGAHeader(data: Uint8Array): any;
  24572. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  24573. 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;
  24574. 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;
  24575. 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;
  24576. 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;
  24577. 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;
  24578. 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;
  24579. }
  24580. }
  24581. declare module BABYLON {
  24582. interface IAnimatable {
  24583. animations: Array<Animation>;
  24584. }
  24585. class LoadFileError extends Error {
  24586. request: XMLHttpRequest | undefined;
  24587. private static _setPrototypeOf;
  24588. constructor(message: string, request?: XMLHttpRequest | undefined);
  24589. }
  24590. class RetryStrategy {
  24591. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  24592. }
  24593. interface IFileRequest {
  24594. /**
  24595. * Raised when the request is complete (success or error).
  24596. */
  24597. onCompleteObservable: Observable<IFileRequest>;
  24598. /**
  24599. * Aborts the request for a file.
  24600. */
  24601. abort: () => void;
  24602. }
  24603. class Tools {
  24604. static BaseUrl: string;
  24605. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  24606. /**
  24607. * Default behaviour for cors in the application.
  24608. * It can be a string if the expected behavior is identical in the entire app.
  24609. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  24610. */
  24611. static CorsBehavior: string | ((url: string | string[]) => string);
  24612. static UseFallbackTexture: boolean;
  24613. /**
  24614. * Use this object to register external classes like custom textures or material
  24615. * to allow the laoders to instantiate them
  24616. */
  24617. static RegisteredExternalClasses: {
  24618. [key: string]: Object;
  24619. };
  24620. static fallbackTexture: string;
  24621. /**
  24622. * Interpolates between a and b via alpha
  24623. * @param a The lower value (returned when alpha = 0)
  24624. * @param b The upper value (returned when alpha = 1)
  24625. * @param alpha The interpolation-factor
  24626. * @return The mixed value
  24627. */
  24628. static Mix(a: number, b: number, alpha: number): number;
  24629. static Instantiate(className: string): any;
  24630. /**
  24631. * Provides a slice function that will work even on IE
  24632. * @param data defines the array to slice
  24633. * @param start defines the start of the data (optional)
  24634. * @param end defines the end of the data (optional)
  24635. * @returns the new sliced array
  24636. */
  24637. static Slice<T>(data: T, start?: number, end?: number): T;
  24638. static SetImmediate(action: () => void): void;
  24639. static IsExponentOfTwo(value: number): boolean;
  24640. /**
  24641. * Find the next highest power of two.
  24642. * @param x Number to start search from.
  24643. * @return Next highest power of two.
  24644. */
  24645. static CeilingPOT(x: number): number;
  24646. /**
  24647. * Find the next lowest power of two.
  24648. * @param x Number to start search from.
  24649. * @return Next lowest power of two.
  24650. */
  24651. static FloorPOT(x: number): number;
  24652. /**
  24653. * Find the nearest power of two.
  24654. * @param x Number to start search from.
  24655. * @return Next nearest power of two.
  24656. */
  24657. static NearestPOT(x: number): number;
  24658. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  24659. static GetFilename(path: string): string;
  24660. /**
  24661. * Extracts the "folder" part of a path (everything before the filename).
  24662. * @param uri The URI to extract the info from
  24663. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  24664. * @returns The "folder" part of the path
  24665. */
  24666. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  24667. static GetDOMTextContent(element: HTMLElement): string;
  24668. static ToDegrees(angle: number): number;
  24669. static ToRadians(angle: number): number;
  24670. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  24671. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  24672. minimum: Vector3;
  24673. maximum: Vector3;
  24674. };
  24675. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  24676. minimum: Vector3;
  24677. maximum: Vector3;
  24678. };
  24679. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  24680. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  24681. minimum: Vector2;
  24682. maximum: Vector2;
  24683. };
  24684. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  24685. static GetPointerPrefix(): string;
  24686. /**
  24687. * @param func - the function to be called
  24688. * @param requester - the object that will request the next frame. Falls back to window.
  24689. */
  24690. static QueueNewFrame(func: () => void, requester?: any): number;
  24691. static RequestFullscreen(element: HTMLElement): void;
  24692. static ExitFullscreen(): void;
  24693. static SetCorsBehavior(url: string | string[], element: {
  24694. crossOrigin: string | null;
  24695. }): void;
  24696. static CleanUrl(url: string): string;
  24697. static PreprocessUrl: (url: string) => string;
  24698. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  24699. 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;
  24700. /**
  24701. * Load a script (identified by an url). When the url returns, the
  24702. * content of this file is added into a new script element, attached to the DOM (body element)
  24703. */
  24704. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  24705. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  24706. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  24707. static FileAsURL(content: string): string;
  24708. static Format(value: number, decimals?: number): string;
  24709. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  24710. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  24711. static IsEmpty(obj: any): boolean;
  24712. static RegisterTopRootEvents(events: {
  24713. name: string;
  24714. handler: Nullable<(e: FocusEvent) => any>;
  24715. }[]): void;
  24716. static UnregisterTopRootEvents(events: {
  24717. name: string;
  24718. handler: Nullable<(e: FocusEvent) => any>;
  24719. }[]): void;
  24720. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  24721. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  24722. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  24723. /**
  24724. * Generates an image screenshot from the specified camera.
  24725. *
  24726. * @param engine The engine to use for rendering
  24727. * @param camera The camera to use for rendering
  24728. * @param size This parameter can be set to a single number or to an object with the
  24729. * following (optional) properties: precision, width, height. If a single number is passed,
  24730. * it will be used for both width and height. If an object is passed, the screenshot size
  24731. * will be derived from the parameters. The precision property is a multiplier allowing
  24732. * rendering at a higher or lower resolution.
  24733. * @param successCallback The callback receives a single parameter which contains the
  24734. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  24735. * src parameter of an <img> to display it.
  24736. * @param mimeType The MIME type of the screenshot image (default: image/png).
  24737. * Check your browser for supported MIME types.
  24738. * @param samples Texture samples (default: 1)
  24739. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  24740. * @param fileName A name for for the downloaded file.
  24741. * @constructor
  24742. */
  24743. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  24744. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  24745. /**
  24746. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24747. * Be aware Math.random() could cause collisions, but:
  24748. * "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"
  24749. */
  24750. static RandomId(): string;
  24751. /**
  24752. * Test if the given uri is a base64 string.
  24753. * @param uri The uri to test
  24754. * @return True if the uri is a base64 string or false otherwise.
  24755. */
  24756. static IsBase64(uri: string): boolean;
  24757. /**
  24758. * Decode the given base64 uri.
  24759. * @param uri The uri to decode
  24760. * @return The decoded base64 data.
  24761. */
  24762. static DecodeBase64(uri: string): ArrayBuffer;
  24763. private static _NoneLogLevel;
  24764. private static _MessageLogLevel;
  24765. private static _WarningLogLevel;
  24766. private static _ErrorLogLevel;
  24767. private static _LogCache;
  24768. static errorsCount: number;
  24769. static OnNewCacheEntry: (entry: string) => void;
  24770. static readonly NoneLogLevel: number;
  24771. static readonly MessageLogLevel: number;
  24772. static readonly WarningLogLevel: number;
  24773. static readonly ErrorLogLevel: number;
  24774. static readonly AllLogLevel: number;
  24775. private static _AddLogEntry(entry);
  24776. private static _FormatMessage(message);
  24777. private static _LogDisabled(message);
  24778. private static _LogEnabled(message);
  24779. private static _WarnDisabled(message);
  24780. private static _WarnEnabled(message);
  24781. private static _ErrorDisabled(message);
  24782. private static _ErrorEnabled(message);
  24783. static Log: (message: string) => void;
  24784. static Warn: (message: string) => void;
  24785. static Error: (message: string) => void;
  24786. static readonly LogCache: string;
  24787. static ClearLogCache(): void;
  24788. static LogLevels: number;
  24789. static IsWindowObjectExist(): boolean;
  24790. private static _PerformanceNoneLogLevel;
  24791. private static _PerformanceUserMarkLogLevel;
  24792. private static _PerformanceConsoleLogLevel;
  24793. private static _performance;
  24794. static readonly PerformanceNoneLogLevel: number;
  24795. static readonly PerformanceUserMarkLogLevel: number;
  24796. static readonly PerformanceConsoleLogLevel: number;
  24797. static PerformanceLogLevel: number;
  24798. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  24799. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  24800. static _StartUserMark(counterName: string, condition?: boolean): void;
  24801. static _EndUserMark(counterName: string, condition?: boolean): void;
  24802. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  24803. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  24804. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  24805. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  24806. static readonly Now: number;
  24807. /**
  24808. * This method will return the name of the class used to create the instance of the given object.
  24809. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  24810. * @param object the object to get the class name from
  24811. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  24812. */
  24813. static GetClassName(object: any, isType?: boolean): string;
  24814. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  24815. /**
  24816. * This method will return the name of the full name of the class, including its owning module (if any).
  24817. * 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).
  24818. * @param object the object to get the class name from
  24819. * @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.
  24820. */
  24821. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  24822. /**
  24823. * 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.
  24824. * @param array
  24825. */
  24826. static arrayOrStringFeeder(array: any): (i: number) => number;
  24827. /**
  24828. * Compute the hashCode of a stream of number
  24829. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  24830. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  24831. * @return the hash code computed
  24832. */
  24833. static hashCodeFromStream(feeder: (index: number) => number): number;
  24834. /**
  24835. * Returns a promise that resolves after the given amount of time.
  24836. * @param delay Number of milliseconds to delay
  24837. * @returns Promise that resolves after the given amount of time
  24838. */
  24839. static DelayAsync(delay: number): Promise<void>;
  24840. }
  24841. /**
  24842. * This class is used to track a performance counter which is number based.
  24843. * The user has access to many properties which give statistics of different nature
  24844. *
  24845. * The implementer can track two kinds of Performance Counter: time and count
  24846. * 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.
  24847. * 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.
  24848. */
  24849. class PerfCounter {
  24850. static Enabled: boolean;
  24851. /**
  24852. * Returns the smallest value ever
  24853. */
  24854. readonly min: number;
  24855. /**
  24856. * Returns the biggest value ever
  24857. */
  24858. readonly max: number;
  24859. /**
  24860. * Returns the average value since the performance counter is running
  24861. */
  24862. readonly average: number;
  24863. /**
  24864. * Returns the average value of the last second the counter was monitored
  24865. */
  24866. readonly lastSecAverage: number;
  24867. /**
  24868. * Returns the current value
  24869. */
  24870. readonly current: number;
  24871. readonly total: number;
  24872. readonly count: number;
  24873. constructor();
  24874. /**
  24875. * Call this method to start monitoring a new frame.
  24876. * 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.
  24877. */
  24878. fetchNewFrame(): void;
  24879. /**
  24880. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  24881. * @param newCount the count value to add to the monitored count
  24882. * @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.
  24883. */
  24884. addCount(newCount: number, fetchResult: boolean): void;
  24885. /**
  24886. * Start monitoring this performance counter
  24887. */
  24888. beginMonitoring(): void;
  24889. /**
  24890. * Compute the time lapsed since the previous beginMonitoring() call.
  24891. * @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
  24892. */
  24893. endMonitoring(newFrame?: boolean): void;
  24894. private _fetchResult();
  24895. private _startMonitoringTime;
  24896. private _min;
  24897. private _max;
  24898. private _average;
  24899. private _current;
  24900. private _totalValueCount;
  24901. private _totalAccumulated;
  24902. private _lastSecAverage;
  24903. private _lastSecAccumulated;
  24904. private _lastSecTime;
  24905. private _lastSecValueCount;
  24906. }
  24907. /**
  24908. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  24909. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  24910. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  24911. * @param name The name of the class, case should be preserved
  24912. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  24913. */
  24914. function className(name: string, module?: string): (target: Object) => void;
  24915. /**
  24916. * An implementation of a loop for asynchronous functions.
  24917. */
  24918. class AsyncLoop {
  24919. iterations: number;
  24920. private _fn;
  24921. private _successCallback;
  24922. index: number;
  24923. private _done;
  24924. /**
  24925. * Constroctor.
  24926. * @param iterations the number of iterations.
  24927. * @param _fn the function to run each iteration
  24928. * @param _successCallback the callback that will be called upon succesful execution
  24929. * @param offset starting offset.
  24930. */
  24931. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  24932. /**
  24933. * Execute the next iteration. Must be called after the last iteration was finished.
  24934. */
  24935. executeNext(): void;
  24936. /**
  24937. * Break the loop and run the success callback.
  24938. */
  24939. breakLoop(): void;
  24940. /**
  24941. * Helper function
  24942. */
  24943. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  24944. /**
  24945. * A for-loop that will run a given number of iterations synchronous and the rest async.
  24946. * @param iterations total number of iterations
  24947. * @param syncedIterations number of synchronous iterations in each async iteration.
  24948. * @param fn the function to call each iteration.
  24949. * @param callback a success call back that will be called when iterating stops.
  24950. * @param breakFunction a break condition (optional)
  24951. * @param timeout timeout settings for the setTimeout function. default - 0.
  24952. * @constructor
  24953. */
  24954. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  24955. }
  24956. }
  24957. declare module BABYLON {
  24958. enum JoystickAxis {
  24959. X = 0,
  24960. Y = 1,
  24961. Z = 2,
  24962. }
  24963. class VirtualJoystick {
  24964. reverseLeftRight: boolean;
  24965. reverseUpDown: boolean;
  24966. deltaPosition: Vector3;
  24967. pressed: boolean;
  24968. private static _globalJoystickIndex;
  24969. private static vjCanvas;
  24970. private static vjCanvasContext;
  24971. private static vjCanvasWidth;
  24972. private static vjCanvasHeight;
  24973. private static halfWidth;
  24974. private _action;
  24975. private _axisTargetedByLeftAndRight;
  24976. private _axisTargetedByUpAndDown;
  24977. private _joystickSensibility;
  24978. private _inversedSensibility;
  24979. private _joystickPointerID;
  24980. private _joystickColor;
  24981. private _joystickPointerPos;
  24982. private _joystickPreviousPointerPos;
  24983. private _joystickPointerStartPos;
  24984. private _deltaJoystickVector;
  24985. private _leftJoystick;
  24986. private _touches;
  24987. private _onPointerDownHandlerRef;
  24988. private _onPointerMoveHandlerRef;
  24989. private _onPointerUpHandlerRef;
  24990. private _onResize;
  24991. constructor(leftJoystick?: boolean);
  24992. setJoystickSensibility(newJoystickSensibility: number): void;
  24993. private _onPointerDown(e);
  24994. private _onPointerMove(e);
  24995. private _onPointerUp(e);
  24996. /**
  24997. * Change the color of the virtual joystick
  24998. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  24999. */
  25000. setJoystickColor(newColor: string): void;
  25001. setActionOnTouch(action: () => any): void;
  25002. setAxisForLeftRight(axis: JoystickAxis): void;
  25003. setAxisForUpDown(axis: JoystickAxis): void;
  25004. private _drawVirtualJoystick();
  25005. releaseCanvas(): void;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * Helper class to push actions to a pool of workers.
  25011. */
  25012. class WorkerPool implements IDisposable {
  25013. private _workerInfos;
  25014. private _pendingActions;
  25015. /**
  25016. * Constructor
  25017. * @param workers Array of workers to use for actions
  25018. */
  25019. constructor(workers: Array<Worker>);
  25020. /**
  25021. * Terminates all workers and clears any pending actions.
  25022. */
  25023. dispose(): void;
  25024. /**
  25025. * Pushes an action to the worker pool. If all the workers are active, the action will be
  25026. * pended until a worker has completed its action.
  25027. * @param action The action to perform. Call onComplete when the action is complete.
  25028. */
  25029. push(action: (worker: Worker, onComplete: () => void) => void): void;
  25030. private _execute(workerInfo, action);
  25031. }
  25032. }
  25033. declare module BABYLON {
  25034. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  25035. readonly name: string;
  25036. private _zoomStopsAnimation;
  25037. private _idleRotationSpeed;
  25038. private _idleRotationWaitTime;
  25039. private _idleRotationSpinupTime;
  25040. /**
  25041. * Gets the flag that indicates if user zooming should stop animation.
  25042. */
  25043. /**
  25044. * Sets the flag that indicates if user zooming should stop animation.
  25045. */
  25046. zoomStopsAnimation: boolean;
  25047. /**
  25048. * Gets the default speed at which the camera rotates around the model.
  25049. */
  25050. /**
  25051. * Sets the default speed at which the camera rotates around the model.
  25052. */
  25053. idleRotationSpeed: number;
  25054. /**
  25055. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  25056. */
  25057. /**
  25058. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  25059. */
  25060. idleRotationWaitTime: number;
  25061. /**
  25062. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  25063. */
  25064. /**
  25065. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  25066. */
  25067. idleRotationSpinupTime: number;
  25068. /**
  25069. * Gets a value indicating if the camera is currently rotating because of this behavior
  25070. */
  25071. readonly rotationInProgress: boolean;
  25072. private _onPrePointerObservableObserver;
  25073. private _onAfterCheckInputsObserver;
  25074. private _attachedCamera;
  25075. private _isPointerDown;
  25076. private _lastFrameTime;
  25077. private _lastInteractionTime;
  25078. private _cameraRotationSpeed;
  25079. init(): void;
  25080. attach(camera: ArcRotateCamera): void;
  25081. detach(): void;
  25082. /**
  25083. * Returns true if user is scrolling.
  25084. * @return true if user is scrolling.
  25085. */
  25086. private _userIsZooming();
  25087. private _lastFrameRadius;
  25088. private _shouldAnimationStopForInteraction();
  25089. /**
  25090. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  25091. */
  25092. private _applyUserInteraction();
  25093. private _userIsMoving();
  25094. }
  25095. }
  25096. declare module BABYLON {
  25097. /**
  25098. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  25099. */
  25100. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  25101. readonly name: string;
  25102. /**
  25103. * The easing function used by animations
  25104. */
  25105. static EasingFunction: BackEase;
  25106. /**
  25107. * The easing mode used by animations
  25108. */
  25109. static EasingMode: number;
  25110. /**
  25111. * The duration of the animation, in milliseconds
  25112. */
  25113. transitionDuration: number;
  25114. /**
  25115. * Length of the distance animated by the transition when lower radius is reached
  25116. */
  25117. lowerRadiusTransitionRange: number;
  25118. /**
  25119. * Length of the distance animated by the transition when upper radius is reached
  25120. */
  25121. upperRadiusTransitionRange: number;
  25122. private _autoTransitionRange;
  25123. /**
  25124. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  25125. */
  25126. /**
  25127. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  25128. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  25129. */
  25130. autoTransitionRange: boolean;
  25131. private _attachedCamera;
  25132. private _onAfterCheckInputsObserver;
  25133. private _onMeshTargetChangedObserver;
  25134. init(): void;
  25135. attach(camera: ArcRotateCamera): void;
  25136. detach(): void;
  25137. private _radiusIsAnimating;
  25138. private _radiusBounceTransition;
  25139. private _animatables;
  25140. private _cachedWheelPrecision;
  25141. /**
  25142. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  25143. * @param radiusLimit The limit to check against.
  25144. * @return Bool to indicate if at limit.
  25145. */
  25146. private _isRadiusAtLimit(radiusLimit);
  25147. /**
  25148. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  25149. * @param radiusDelta The delta by which to animate to. Can be negative.
  25150. */
  25151. private _applyBoundRadiusAnimation(radiusDelta);
  25152. /**
  25153. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  25154. */
  25155. protected _clearAnimationLocks(): void;
  25156. /**
  25157. * Stops and removes all animations that have been applied to the camera
  25158. */
  25159. stopAllAnimations(): void;
  25160. }
  25161. }
  25162. declare module BABYLON {
  25163. class FramingBehavior implements Behavior<ArcRotateCamera> {
  25164. readonly name: string;
  25165. private _mode;
  25166. private _radiusScale;
  25167. private _positionScale;
  25168. private _defaultElevation;
  25169. private _elevationReturnTime;
  25170. private _elevationReturnWaitTime;
  25171. private _zoomStopsAnimation;
  25172. private _framingTime;
  25173. /**
  25174. * The easing function used by animations
  25175. */
  25176. static EasingFunction: ExponentialEase;
  25177. /**
  25178. * The easing mode used by animations
  25179. */
  25180. static EasingMode: number;
  25181. /**
  25182. * Gets current mode used by the behavior.
  25183. */
  25184. /**
  25185. * Sets the current mode used by the behavior
  25186. */
  25187. mode: number;
  25188. /**
  25189. * Gets the scale applied to the radius
  25190. */
  25191. /**
  25192. * Sets the scale applied to the radius (1 by default)
  25193. */
  25194. radiusScale: number;
  25195. /**
  25196. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  25197. */
  25198. /**
  25199. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  25200. */
  25201. positionScale: number;
  25202. /**
  25203. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  25204. * behaviour is triggered, in radians.
  25205. */
  25206. /**
  25207. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  25208. * behaviour is triggered, in radians.
  25209. */
  25210. defaultElevation: number;
  25211. /**
  25212. * Gets the time (in milliseconds) taken to return to the default beta position.
  25213. * Negative value indicates camera should not return to default.
  25214. */
  25215. /**
  25216. * Sets the time (in milliseconds) taken to return to the default beta position.
  25217. * Negative value indicates camera should not return to default.
  25218. */
  25219. elevationReturnTime: number;
  25220. /**
  25221. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  25222. */
  25223. /**
  25224. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  25225. */
  25226. elevationReturnWaitTime: number;
  25227. /**
  25228. * Gets the flag that indicates if user zooming should stop animation.
  25229. */
  25230. /**
  25231. * Sets the flag that indicates if user zooming should stop animation.
  25232. */
  25233. zoomStopsAnimation: boolean;
  25234. /**
  25235. * Gets the transition time when framing the mesh, in milliseconds
  25236. */
  25237. /**
  25238. * Sets the transition time when framing the mesh, in milliseconds
  25239. */
  25240. framingTime: number;
  25241. private _onPrePointerObservableObserver;
  25242. private _onAfterCheckInputsObserver;
  25243. private _onMeshTargetChangedObserver;
  25244. private _attachedCamera;
  25245. private _isPointerDown;
  25246. private _lastInteractionTime;
  25247. init(): void;
  25248. attach(camera: ArcRotateCamera): void;
  25249. detach(): void;
  25250. private _animatables;
  25251. private _betaIsAnimating;
  25252. private _betaTransition;
  25253. private _radiusTransition;
  25254. private _vectorTransition;
  25255. /**
  25256. * Targets the given mesh and updates zoom level accordingly.
  25257. * @param mesh The mesh to target.
  25258. * @param radius Optional. If a cached radius position already exists, overrides default.
  25259. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  25260. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  25261. * @param onAnimationEnd Callback triggered at the end of the framing animation
  25262. */
  25263. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  25264. /**
  25265. * Targets the given mesh with its children and updates zoom level accordingly.
  25266. * @param mesh The mesh to target.
  25267. * @param radius Optional. If a cached radius position already exists, overrides default.
  25268. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  25269. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  25270. * @param onAnimationEnd Callback triggered at the end of the framing animation
  25271. */
  25272. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  25273. /**
  25274. * Targets the given meshes with their children and updates zoom level accordingly.
  25275. * @param meshes The mesh to target.
  25276. * @param radius Optional. If a cached radius position already exists, overrides default.
  25277. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  25278. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  25279. * @param onAnimationEnd Callback triggered at the end of the framing animation
  25280. */
  25281. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  25282. /**
  25283. * Targets the given mesh and updates zoom level accordingly.
  25284. * @param mesh The mesh to target.
  25285. * @param radius Optional. If a cached radius position already exists, overrides default.
  25286. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  25287. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  25288. * @param onAnimationEnd Callback triggered at the end of the framing animation
  25289. */
  25290. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  25291. /**
  25292. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  25293. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  25294. * frustum width.
  25295. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  25296. * to fully enclose the mesh in the viewing frustum.
  25297. */
  25298. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  25299. /**
  25300. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  25301. * is automatically returned to its default position (expected to be above ground plane).
  25302. */
  25303. private _maintainCameraAboveGround();
  25304. /**
  25305. * Returns the frustum slope based on the canvas ratio and camera FOV
  25306. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  25307. */
  25308. private _getFrustumSlope();
  25309. /**
  25310. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  25311. */
  25312. private _clearAnimationLocks();
  25313. /**
  25314. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  25315. */
  25316. private _applyUserInteraction();
  25317. /**
  25318. * Stops and removes all animations that have been applied to the camera
  25319. */
  25320. stopAllAnimations(): void;
  25321. /**
  25322. * Gets a value indicating if the user is moving the camera
  25323. */
  25324. readonly isUserIsMoving: boolean;
  25325. /**
  25326. * The camera can move all the way towards the mesh.
  25327. */
  25328. static IgnoreBoundsSizeMode: number;
  25329. /**
  25330. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  25331. */
  25332. static FitFrustumSidesMode: number;
  25333. }
  25334. }
  25335. declare module BABYLON {
  25336. interface IOctreeContainer<T> {
  25337. blocks: Array<OctreeBlock<T>>;
  25338. }
  25339. class Octree<T> {
  25340. maxDepth: number;
  25341. blocks: Array<OctreeBlock<T>>;
  25342. dynamicContent: T[];
  25343. private _maxBlockCapacity;
  25344. private _selectionContent;
  25345. private _creationFunc;
  25346. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  25347. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  25348. addMesh(entry: T): void;
  25349. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  25350. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  25351. intersectsRay(ray: Ray): SmartArray<T>;
  25352. 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;
  25353. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  25354. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  25355. }
  25356. }
  25357. declare module BABYLON {
  25358. class OctreeBlock<T> {
  25359. entries: T[];
  25360. blocks: Array<OctreeBlock<T>>;
  25361. private _depth;
  25362. private _maxDepth;
  25363. private _capacity;
  25364. private _minPoint;
  25365. private _maxPoint;
  25366. private _boundingVectors;
  25367. private _creationFunc;
  25368. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  25369. readonly capacity: number;
  25370. readonly minPoint: Vector3;
  25371. readonly maxPoint: Vector3;
  25372. addEntry(entry: T): void;
  25373. addEntries(entries: T[]): void;
  25374. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  25375. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  25376. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  25377. createInnerBlocks(): void;
  25378. }
  25379. }
  25380. declare module BABYLON {
  25381. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  25382. camera: ArcRotateCamera;
  25383. gamepad: Nullable<Gamepad>;
  25384. private _onGamepadConnectedObserver;
  25385. private _onGamepadDisconnectedObserver;
  25386. gamepadRotationSensibility: number;
  25387. gamepadMoveSensibility: number;
  25388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25389. detachControl(element: Nullable<HTMLElement>): void;
  25390. checkInputs(): void;
  25391. getClassName(): string;
  25392. getSimpleName(): string;
  25393. }
  25394. }
  25395. declare module BABYLON {
  25396. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  25397. camera: ArcRotateCamera;
  25398. private _keys;
  25399. keysUp: number[];
  25400. keysDown: number[];
  25401. keysLeft: number[];
  25402. keysRight: number[];
  25403. keysReset: number[];
  25404. panningSensibility: number;
  25405. zoomingSensibility: number;
  25406. useAltToZoom: boolean;
  25407. private _ctrlPressed;
  25408. private _altPressed;
  25409. private _onCanvasBlurObserver;
  25410. private _onKeyboardObserver;
  25411. private _engine;
  25412. private _scene;
  25413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25414. detachControl(element: Nullable<HTMLElement>): void;
  25415. checkInputs(): void;
  25416. getClassName(): string;
  25417. getSimpleName(): string;
  25418. }
  25419. }
  25420. declare module BABYLON {
  25421. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  25422. camera: ArcRotateCamera;
  25423. private _wheel;
  25424. private _observer;
  25425. wheelPrecision: number;
  25426. /**
  25427. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  25428. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  25429. */
  25430. wheelDeltaPercentage: number;
  25431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25432. detachControl(element: Nullable<HTMLElement>): void;
  25433. getClassName(): string;
  25434. getSimpleName(): string;
  25435. }
  25436. }
  25437. declare module BABYLON {
  25438. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  25439. camera: ArcRotateCamera;
  25440. buttons: number[];
  25441. angularSensibilityX: number;
  25442. angularSensibilityY: number;
  25443. pinchPrecision: number;
  25444. /**
  25445. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  25446. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  25447. */
  25448. pinchDeltaPercentage: number;
  25449. panningSensibility: number;
  25450. multiTouchPanning: boolean;
  25451. multiTouchPanAndZoom: boolean;
  25452. private _isPanClick;
  25453. pinchInwards: boolean;
  25454. private _pointerInput;
  25455. private _observer;
  25456. private _onMouseMove;
  25457. private _onGestureStart;
  25458. private _onGesture;
  25459. private _MSGestureHandler;
  25460. private _onLostFocus;
  25461. private _onContextMenu;
  25462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25463. detachControl(element: Nullable<HTMLElement>): void;
  25464. getClassName(): string;
  25465. getSimpleName(): string;
  25466. }
  25467. }
  25468. declare module BABYLON {
  25469. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  25470. camera: ArcRotateCamera;
  25471. alphaCorrection: number;
  25472. betaCorrection: number;
  25473. gammaCorrection: number;
  25474. private _alpha;
  25475. private _gamma;
  25476. private _dirty;
  25477. private _deviceOrientationHandler;
  25478. constructor();
  25479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25480. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  25481. checkInputs(): void;
  25482. detachControl(element: Nullable<HTMLElement>): void;
  25483. getClassName(): string;
  25484. getSimpleName(): string;
  25485. }
  25486. }
  25487. declare module BABYLON {
  25488. /**
  25489. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  25490. * Screen rotation is taken into account.
  25491. */
  25492. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  25493. private _camera;
  25494. private _screenOrientationAngle;
  25495. private _constantTranform;
  25496. private _screenQuaternion;
  25497. private _alpha;
  25498. private _beta;
  25499. private _gamma;
  25500. constructor();
  25501. camera: FreeCamera;
  25502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25503. private _orientationChanged;
  25504. private _deviceOrientation;
  25505. detachControl(element: Nullable<HTMLElement>): void;
  25506. checkInputs(): void;
  25507. getClassName(): string;
  25508. getSimpleName(): string;
  25509. }
  25510. }
  25511. declare module BABYLON {
  25512. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  25513. camera: FreeCamera;
  25514. gamepad: Nullable<Gamepad>;
  25515. private _onGamepadConnectedObserver;
  25516. private _onGamepadDisconnectedObserver;
  25517. gamepadAngularSensibility: number;
  25518. gamepadMoveSensibility: number;
  25519. private _cameraTransform;
  25520. private _deltaTransform;
  25521. private _vector3;
  25522. private _vector2;
  25523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25524. detachControl(element: Nullable<HTMLElement>): void;
  25525. checkInputs(): void;
  25526. getClassName(): string;
  25527. getSimpleName(): string;
  25528. }
  25529. }
  25530. declare module BABYLON {
  25531. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  25532. camera: FreeCamera;
  25533. private _keys;
  25534. private _onCanvasBlurObserver;
  25535. private _onKeyboardObserver;
  25536. private _engine;
  25537. private _scene;
  25538. keysUp: number[];
  25539. keysDown: number[];
  25540. keysLeft: number[];
  25541. keysRight: number[];
  25542. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25543. detachControl(element: Nullable<HTMLElement>): void;
  25544. checkInputs(): void;
  25545. getClassName(): string;
  25546. _onLostFocus(e: FocusEvent): void;
  25547. getSimpleName(): string;
  25548. }
  25549. }
  25550. declare module BABYLON {
  25551. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25552. touchEnabled: boolean;
  25553. camera: FreeCamera;
  25554. buttons: number[];
  25555. angularSensibility: number;
  25556. private _pointerInput;
  25557. private _onMouseMove;
  25558. private _observer;
  25559. private previousPosition;
  25560. constructor(touchEnabled?: boolean);
  25561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25562. detachControl(element: Nullable<HTMLElement>): void;
  25563. getClassName(): string;
  25564. getSimpleName(): string;
  25565. }
  25566. }
  25567. declare module BABYLON {
  25568. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25569. camera: FreeCamera;
  25570. private _offsetX;
  25571. private _offsetY;
  25572. private _pointerPressed;
  25573. private _pointerInput;
  25574. private _observer;
  25575. private _onLostFocus;
  25576. touchAngularSensibility: number;
  25577. touchMoveSensibility: number;
  25578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25579. detachControl(element: Nullable<HTMLElement>): void;
  25580. checkInputs(): void;
  25581. getClassName(): string;
  25582. getSimpleName(): string;
  25583. }
  25584. }
  25585. declare module BABYLON {
  25586. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  25587. camera: FreeCamera;
  25588. private _leftjoystick;
  25589. private _rightjoystick;
  25590. getLeftJoystick(): VirtualJoystick;
  25591. getRightJoystick(): VirtualJoystick;
  25592. checkInputs(): void;
  25593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25594. detachControl(element: Nullable<HTMLElement>): void;
  25595. getClassName(): string;
  25596. getSimpleName(): string;
  25597. }
  25598. }
  25599. declare module BABYLON {
  25600. class VRCameraMetrics {
  25601. hResolution: number;
  25602. vResolution: number;
  25603. hScreenSize: number;
  25604. vScreenSize: number;
  25605. vScreenCenter: number;
  25606. eyeToScreenDistance: number;
  25607. lensSeparationDistance: number;
  25608. interpupillaryDistance: number;
  25609. distortionK: number[];
  25610. chromaAbCorrection: number[];
  25611. postProcessScaleFactor: number;
  25612. lensCenterOffset: number;
  25613. compensateDistortion: boolean;
  25614. readonly aspectRatio: number;
  25615. readonly aspectRatioFov: number;
  25616. readonly leftHMatrix: Matrix;
  25617. readonly rightHMatrix: Matrix;
  25618. readonly leftPreViewMatrix: Matrix;
  25619. readonly rightPreViewMatrix: Matrix;
  25620. static GetDefault(): VRCameraMetrics;
  25621. }
  25622. }
  25623. declare module BABYLON {
  25624. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  25625. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  25626. getClassName(): string;
  25627. }
  25628. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  25629. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  25630. getClassName(): string;
  25631. }
  25632. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  25633. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  25634. getClassName(): string;
  25635. }
  25636. }
  25637. declare module BABYLON {
  25638. /**
  25639. * Options to modify the vr teleportation behavior.
  25640. */
  25641. interface VRTeleportationOptions {
  25642. /**
  25643. * The name of the mesh which should be used as the teleportation floor. (default: null)
  25644. */
  25645. floorMeshName?: string;
  25646. /**
  25647. * A list of meshes to be used as the teleportation floor. (default: empty)
  25648. */
  25649. floorMeshes?: Mesh[];
  25650. }
  25651. /**
  25652. * Options to modify the vr experience helper's behavior.
  25653. */
  25654. interface VRExperienceHelperOptions extends WebVROptions {
  25655. /**
  25656. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  25657. */
  25658. createDeviceOrientationCamera?: boolean;
  25659. /**
  25660. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  25661. */
  25662. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  25663. }
  25664. /**
  25665. * Helps to quickly add VR support to an existing scene.
  25666. * See http://doc.babylonjs.com/how_to/webvr_helper
  25667. */
  25668. class VRExperienceHelper {
  25669. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  25670. private _scene;
  25671. private _position;
  25672. private _btnVR;
  25673. private _btnVRDisplayed;
  25674. private _webVRsupported;
  25675. private _webVRready;
  25676. private _webVRrequesting;
  25677. private _webVRpresenting;
  25678. private _fullscreenVRpresenting;
  25679. private _canvas;
  25680. private _webVRCamera;
  25681. private _vrDeviceOrientationCamera;
  25682. private _deviceOrientationCamera;
  25683. private _existingCamera;
  25684. private _onKeyDown;
  25685. private _onVrDisplayPresentChange;
  25686. private _onVRDisplayChanged;
  25687. private _onVRRequestPresentStart;
  25688. private _onVRRequestPresentComplete;
  25689. /**
  25690. * Observable raised when entering VR.
  25691. */
  25692. onEnteringVRObservable: Observable<VRExperienceHelper>;
  25693. /**
  25694. * Observable raised when exiting VR.
  25695. */
  25696. onExitingVRObservable: Observable<VRExperienceHelper>;
  25697. /**
  25698. * Observable raised when controller mesh is loaded.
  25699. */
  25700. onControllerMeshLoadedObservable: Observable<WebVRController>;
  25701. /** Return this.onEnteringVRObservable
  25702. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  25703. */
  25704. readonly onEnteringVR: Observable<VRExperienceHelper>;
  25705. /** Return this.onExitingVRObservable
  25706. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  25707. */
  25708. readonly onExitingVR: Observable<VRExperienceHelper>;
  25709. /** Return this.onControllerMeshLoadedObservable
  25710. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  25711. */
  25712. readonly onControllerMeshLoaded: Observable<WebVRController>;
  25713. private _rayLength;
  25714. private _useCustomVRButton;
  25715. private _teleportationRequested;
  25716. private _teleportActive;
  25717. private _floorMeshName;
  25718. private _floorMeshesCollection;
  25719. private _rotationAllowed;
  25720. private _teleportBackwardsVector;
  25721. private _rotationRightAsked;
  25722. private _rotationLeftAsked;
  25723. private _teleportationTarget;
  25724. private _isDefaultTeleportationTarget;
  25725. private _postProcessMove;
  25726. private _teleportationFillColor;
  25727. private _teleportationBorderColor;
  25728. private _rotationAngle;
  25729. private _haloCenter;
  25730. private _cameraGazer;
  25731. private _padSensibilityUp;
  25732. private _padSensibilityDown;
  25733. private leftController;
  25734. private rightController;
  25735. /**
  25736. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  25737. */
  25738. onNewMeshSelected: Observable<AbstractMesh>;
  25739. /**
  25740. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  25741. */
  25742. onNewMeshPicked: Observable<PickingInfo>;
  25743. private _circleEase;
  25744. /**
  25745. * Observable raised before camera teleportation
  25746. */
  25747. onBeforeCameraTeleport: Observable<Vector3>;
  25748. /**
  25749. * Observable raised after camera teleportation
  25750. */
  25751. onAfterCameraTeleport: Observable<Vector3>;
  25752. /**
  25753. * Observable raised when current selected mesh gets unselected
  25754. */
  25755. onSelectedMeshUnselected: Observable<AbstractMesh>;
  25756. private _raySelectionPredicate;
  25757. /**
  25758. * To be optionaly changed by user to define custom ray selection
  25759. */
  25760. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  25761. /**
  25762. * To be optionaly changed by user to define custom selection logic (after ray selection)
  25763. */
  25764. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  25765. /**
  25766. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  25767. */
  25768. teleportationEnabled: boolean;
  25769. private _defaultHeight;
  25770. private _teleportationInitialized;
  25771. private _interactionsEnabled;
  25772. private _interactionsRequested;
  25773. private _displayGaze;
  25774. private _displayLaserPointer;
  25775. /**
  25776. * The mesh used to display where the user is going to teleport.
  25777. */
  25778. /**
  25779. * Sets the mesh to be used to display where the user is going to teleport.
  25780. */
  25781. teleportationTarget: Mesh;
  25782. /**
  25783. * The mesh used to display where the user is selecting,
  25784. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  25785. * See http://doc.babylonjs.com/resources/baking_transformations
  25786. */
  25787. gazeTrackerMesh: Mesh;
  25788. /**
  25789. * If the ray of the gaze should be displayed.
  25790. */
  25791. /**
  25792. * Sets if the ray of the gaze should be displayed.
  25793. */
  25794. displayGaze: boolean;
  25795. /**
  25796. * If the ray of the LaserPointer should be displayed.
  25797. */
  25798. /**
  25799. * Sets if the ray of the LaserPointer should be displayed.
  25800. */
  25801. displayLaserPointer: boolean;
  25802. /**
  25803. * The deviceOrientationCamera used as the camera when not in VR.
  25804. */
  25805. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  25806. /**
  25807. * Based on the current WebVR support, returns the current VR camera used.
  25808. */
  25809. readonly currentVRCamera: Nullable<Camera>;
  25810. /**
  25811. * The webVRCamera which is used when in VR.
  25812. */
  25813. readonly webVRCamera: WebVRFreeCamera;
  25814. /**
  25815. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  25816. */
  25817. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  25818. private readonly _teleportationRequestInitiated;
  25819. /**
  25820. * Instantiates a VRExperienceHelper.
  25821. * Helps to quickly add VR support to an existing scene.
  25822. * @param scene The scene the VRExperienceHelper belongs to.
  25823. * @param webVROptions Options to modify the vr experience helper's behavior.
  25824. */
  25825. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  25826. private _onDefaultMeshLoaded(webVRController);
  25827. private _onResize;
  25828. private _onFullscreenChange;
  25829. /**
  25830. * Gets a value indicating if we are currently in VR mode.
  25831. */
  25832. readonly isInVRMode: boolean;
  25833. private onVrDisplayPresentChange();
  25834. private onVRDisplayChanged(eventArgs);
  25835. private moveButtonToBottomRight();
  25836. private displayVRButton();
  25837. private updateButtonVisibility();
  25838. /**
  25839. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  25840. * Otherwise, will use the fullscreen API.
  25841. */
  25842. enterVR(): void;
  25843. /**
  25844. * Attempt to exit VR, or fullscreen.
  25845. */
  25846. exitVR(): void;
  25847. /**
  25848. * The position of the vr experience helper.
  25849. */
  25850. /**
  25851. * Sets the position of the vr experience helper.
  25852. */
  25853. position: Vector3;
  25854. /**
  25855. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  25856. */
  25857. enableInteractions(): void;
  25858. private beforeRender;
  25859. private _isTeleportationFloor(mesh);
  25860. /**
  25861. * Adds a floor mesh to be used for teleportation.
  25862. * @param floorMesh the mesh to be used for teleportation.
  25863. */
  25864. addFloorMesh(floorMesh: Mesh): void;
  25865. /**
  25866. * Removes a floor mesh from being used for teleportation.
  25867. * @param floorMesh the mesh to be removed.
  25868. */
  25869. removeFloorMesh(floorMesh: Mesh): void;
  25870. /**
  25871. * Enables interactions and teleportation using the VR controllers and gaze.
  25872. * @param vrTeleportationOptions options to modify teleportation behavior.
  25873. */
  25874. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  25875. private _onNewGamepadConnected;
  25876. private _tryEnableInteractionOnController;
  25877. private _onNewGamepadDisconnected;
  25878. private _enableInteractionOnController(controller);
  25879. private _checkTeleportWithRay(stateObject, gazer);
  25880. private _checkRotate(stateObject, gazer);
  25881. private _checkTeleportBackwards(stateObject, gazer);
  25882. private _enableTeleportationOnController(controller);
  25883. private _createTeleportationCircles();
  25884. private _displayTeleportationTarget();
  25885. private _hideTeleportationTarget();
  25886. private _rotateCamera(right);
  25887. private _moveTeleportationSelectorTo(hit, gazer);
  25888. private _workingVector;
  25889. private _workingQuaternion;
  25890. private _workingMatrix;
  25891. private _teleportCamera(location);
  25892. private _castRayAndSelectObject(gazer);
  25893. private _notifySelectedMeshUnselected(mesh);
  25894. /**
  25895. * Sets the color of the laser ray from the vr controllers.
  25896. * @param color new color for the ray.
  25897. */
  25898. changeLaserColor(color: Color3): void;
  25899. /**
  25900. * Sets the color of the ray from the vr headsets gaze.
  25901. * @param color new color for the ray.
  25902. */
  25903. changeGazeColor(color: Color3): void;
  25904. /**
  25905. * Exits VR and disposes of the vr experience helper
  25906. */
  25907. dispose(): void;
  25908. /**
  25909. * Gets the name of the VRExperienceHelper class
  25910. * @returns "VRExperienceHelper"
  25911. */
  25912. getClassName(): string;
  25913. }
  25914. }
  25915. declare var VRFrameData: any;
  25916. declare module BABYLON {
  25917. /**
  25918. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  25919. * IMPORTANT!! The data is right-hand data.
  25920. * @export
  25921. * @interface DevicePose
  25922. */
  25923. interface DevicePose {
  25924. /**
  25925. * The position of the device, values in array are [x,y,z].
  25926. */
  25927. readonly position?: Float32Array;
  25928. /**
  25929. * The linearVelocity of the device, values in array are [x,y,z].
  25930. */
  25931. readonly linearVelocity?: Float32Array;
  25932. /**
  25933. * The linearAcceleration of the device, values in array are [x,y,z].
  25934. */
  25935. readonly linearAcceleration?: Float32Array;
  25936. /**
  25937. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  25938. */
  25939. readonly orientation?: Float32Array;
  25940. /**
  25941. * The angularVelocity of the device, values in array are [x,y,z].
  25942. */
  25943. readonly angularVelocity?: Float32Array;
  25944. /**
  25945. * The angularAcceleration of the device, values in array are [x,y,z].
  25946. */
  25947. readonly angularAcceleration?: Float32Array;
  25948. }
  25949. /**
  25950. * Interface representing a pose controlled object in Babylon.
  25951. * A pose controlled object has both regular pose values as well as pose values
  25952. * from an external device such as a VR head mounted display
  25953. */
  25954. interface PoseControlled {
  25955. /**
  25956. * The position of the object in babylon space.
  25957. */
  25958. position: Vector3;
  25959. /**
  25960. * The rotation quaternion of the object in babylon space.
  25961. */
  25962. rotationQuaternion: Quaternion;
  25963. /**
  25964. * The position of the device in babylon space.
  25965. */
  25966. devicePosition?: Vector3;
  25967. /**
  25968. * The rotation quaternion of the device in babylon space.
  25969. */
  25970. deviceRotationQuaternion: Quaternion;
  25971. /**
  25972. * The raw pose coming from the device.
  25973. */
  25974. rawPose: Nullable<DevicePose>;
  25975. /**
  25976. * The scale of the device to be used when translating from device space to babylon space.
  25977. */
  25978. deviceScaleFactor: number;
  25979. /**
  25980. * Updates the poseControlled values based on the input device pose.
  25981. * @param poseData the pose data to update the object with
  25982. */
  25983. updateFromDevice(poseData: DevicePose): void;
  25984. }
  25985. /**
  25986. * Set of options to customize the webVRCamera
  25987. */
  25988. interface WebVROptions {
  25989. /**
  25990. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  25991. */
  25992. trackPosition?: boolean;
  25993. /**
  25994. * Sets the scale of the vrDevice in babylon space. (default: 1)
  25995. */
  25996. positionScale?: number;
  25997. /**
  25998. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  25999. */
  26000. displayName?: string;
  26001. /**
  26002. * Should the native controller meshes be initialized. (default: true)
  26003. */
  26004. controllerMeshes?: boolean;
  26005. /**
  26006. * Creating a default HemiLight only on controllers. (default: true)
  26007. */
  26008. defaultLightingOnControllers?: boolean;
  26009. /**
  26010. * If you don't want to use the default VR button of the helper. (default: false)
  26011. */
  26012. useCustomVRButton?: boolean;
  26013. /**
  26014. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26015. */
  26016. customVRButton?: HTMLButtonElement;
  26017. /**
  26018. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26019. */
  26020. rayLength?: number;
  26021. /**
  26022. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26023. */
  26024. defaultHeight?: number;
  26025. }
  26026. /**
  26027. * This represents a WebVR camera.
  26028. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26029. * @example http://doc.babylonjs.com/how_to/webvr_camera
  26030. */
  26031. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26032. private webVROptions;
  26033. /**
  26034. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26035. */
  26036. _vrDevice: any;
  26037. /**
  26038. * The rawPose of the vrDevice.
  26039. */
  26040. rawPose: Nullable<DevicePose>;
  26041. private _onVREnabled;
  26042. private _specsVersion;
  26043. private _attached;
  26044. private _frameData;
  26045. protected _descendants: Array<Node>;
  26046. private _deviceRoomPosition;
  26047. private _deviceRoomRotationQuaternion;
  26048. private _standingMatrix;
  26049. /**
  26050. * Represents device position in babylon space.
  26051. */
  26052. devicePosition: Vector3;
  26053. /**
  26054. * Represents device rotation in babylon space.
  26055. */
  26056. deviceRotationQuaternion: Quaternion;
  26057. /**
  26058. * The scale of the device to be used when translating from device space to babylon space.
  26059. */
  26060. deviceScaleFactor: number;
  26061. private _deviceToWorld;
  26062. private _worldToDevice;
  26063. /**
  26064. * References to the webVR controllers for the vrDevice.
  26065. */
  26066. controllers: Array<WebVRController>;
  26067. /**
  26068. * Emits an event when a controller is attached.
  26069. */
  26070. onControllersAttachedObservable: Observable<WebVRController[]>;
  26071. /**
  26072. * Emits an event when a controller's mesh has been loaded;
  26073. */
  26074. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26075. /**
  26076. * If the rig cameras be used as parent instead of this camera.
  26077. */
  26078. rigParenting: boolean;
  26079. private _lightOnControllers;
  26080. private _defaultHeight?;
  26081. /**
  26082. * Instantiates a WebVRFreeCamera.
  26083. * @param name The name of the WebVRFreeCamera
  26084. * @param position The starting anchor position for the camera
  26085. * @param scene The scene the camera belongs to
  26086. * @param webVROptions a set of customizable options for the webVRCamera
  26087. */
  26088. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  26089. /**
  26090. * Gets the device distance from the ground in meters.
  26091. * @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.
  26092. */
  26093. deviceDistanceToRoomGround(): number;
  26094. /**
  26095. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26096. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  26097. */
  26098. useStandingMatrix(callback?: (bool: boolean) => void): void;
  26099. /**
  26100. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26101. * @returns A promise with a boolean set to if the standing matrix is supported.
  26102. */
  26103. useStandingMatrixAsync(): Promise<boolean>;
  26104. /**
  26105. * Disposes the camera
  26106. */
  26107. dispose(): void;
  26108. /**
  26109. * Gets a vrController by name.
  26110. * @param name The name of the controller to retreive
  26111. * @returns the controller matching the name specified or null if not found
  26112. */
  26113. getControllerByName(name: string): Nullable<WebVRController>;
  26114. private _leftController;
  26115. /**
  26116. * The controller corrisponding to the users left hand.
  26117. */
  26118. readonly leftController: Nullable<WebVRController>;
  26119. private _rightController;
  26120. /**
  26121. * The controller corrisponding to the users right hand.
  26122. */
  26123. readonly rightController: Nullable<WebVRController>;
  26124. /**
  26125. * Casts a ray forward from the vrCamera's gaze.
  26126. * @param length Length of the ray (default: 100)
  26127. * @returns the ray corrisponding to the gaze
  26128. */
  26129. getForwardRay(length?: number): Ray;
  26130. /**
  26131. * Updates the camera based on device's frame data
  26132. */
  26133. _checkInputs(): void;
  26134. /**
  26135. * Updates the poseControlled values based on the input device pose.
  26136. * @param poseData Pose coming from the device
  26137. */
  26138. updateFromDevice(poseData: DevicePose): void;
  26139. /**
  26140. * WebVR's attach control will start broadcasting frames to the device.
  26141. * Note that in certain browsers (chrome for example) this function must be called
  26142. * within a user-interaction callback. Example:
  26143. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  26144. *
  26145. * @param element html element to attach the vrDevice to
  26146. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  26147. */
  26148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26149. /**
  26150. * Detaches the camera from the html element and disables VR
  26151. *
  26152. * @param element html element to detach from
  26153. */
  26154. detachControl(element: HTMLElement): void;
  26155. /**
  26156. * @returns the name of this class
  26157. */
  26158. getClassName(): string;
  26159. /**
  26160. * Calls resetPose on the vrDisplay
  26161. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  26162. */
  26163. resetToCurrentRotation(): void;
  26164. /**
  26165. * Updates the rig cameras (left and right eye)
  26166. */
  26167. _updateRigCameras(): void;
  26168. private _workingVector;
  26169. private _oneVector;
  26170. private _workingMatrix;
  26171. private updateCacheCalled;
  26172. /**
  26173. * Updates the cached values of the camera
  26174. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  26175. */
  26176. _updateCache(ignoreParentClass?: boolean): void;
  26177. /**
  26178. * Updates the current device position and rotation in the babylon world
  26179. */
  26180. update(): void;
  26181. /**
  26182. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  26183. * @returns an identity matrix
  26184. */
  26185. _getViewMatrix(): Matrix;
  26186. /**
  26187. * This function is called by the two RIG cameras.
  26188. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  26189. */
  26190. protected _getWebVRViewMatrix(): Matrix;
  26191. protected _getWebVRProjectionMatrix(): Matrix;
  26192. private _onGamepadConnectedObserver;
  26193. private _onGamepadDisconnectedObserver;
  26194. /**
  26195. * Initializes the controllers and their meshes
  26196. */
  26197. initControllers(): void;
  26198. }
  26199. }
  26200. declare module BABYLON {
  26201. /**
  26202. * Google Daydream controller
  26203. */
  26204. class DaydreamController extends WebVRController {
  26205. /**
  26206. * Base Url for the controller model.
  26207. */
  26208. static MODEL_BASE_URL: string;
  26209. /**
  26210. * File name for the controller model.
  26211. */
  26212. static MODEL_FILENAME: string;
  26213. /**
  26214. * Gamepad Id prefix used to identify Daydream Controller.
  26215. */
  26216. static readonly GAMEPAD_ID_PREFIX: string;
  26217. constructor(vrGamepad: any);
  26218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26219. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26220. }
  26221. }
  26222. declare module BABYLON {
  26223. class GearVRController extends WebVRController {
  26224. static MODEL_BASE_URL: string;
  26225. static MODEL_FILENAME: string;
  26226. static readonly GAMEPAD_ID_PREFIX: string;
  26227. private readonly _buttonIndexToObservableNameMap;
  26228. constructor(vrGamepad: any);
  26229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26230. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26231. }
  26232. }
  26233. declare module BABYLON {
  26234. class GenericController extends WebVRController {
  26235. static readonly MODEL_BASE_URL: string;
  26236. static readonly MODEL_FILENAME: string;
  26237. constructor(vrGamepad: any);
  26238. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26239. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26240. }
  26241. }
  26242. declare module BABYLON {
  26243. class OculusTouchController extends WebVRController {
  26244. static MODEL_BASE_URL: string;
  26245. static MODEL_LEFT_FILENAME: string;
  26246. static MODEL_RIGHT_FILENAME: string;
  26247. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26248. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  26249. constructor(vrGamepad: any);
  26250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26251. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26252. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26253. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26254. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26255. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26256. }
  26257. }
  26258. declare module BABYLON {
  26259. enum PoseEnabledControllerType {
  26260. VIVE = 0,
  26261. OCULUS = 1,
  26262. WINDOWS = 2,
  26263. GEAR_VR = 3,
  26264. /**
  26265. * Google Daydream
  26266. */
  26267. DAYDREAM = 4,
  26268. GENERIC = 5,
  26269. }
  26270. interface MutableGamepadButton {
  26271. value: number;
  26272. touched: boolean;
  26273. pressed: boolean;
  26274. }
  26275. interface ExtendedGamepadButton extends GamepadButton {
  26276. readonly pressed: boolean;
  26277. readonly touched: boolean;
  26278. readonly value: number;
  26279. }
  26280. class PoseEnabledControllerHelper {
  26281. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  26282. }
  26283. class PoseEnabledController extends Gamepad implements PoseControlled {
  26284. private _deviceRoomPosition;
  26285. private _deviceRoomRotationQuaternion;
  26286. devicePosition: Vector3;
  26287. deviceRotationQuaternion: Quaternion;
  26288. deviceScaleFactor: number;
  26289. position: Vector3;
  26290. rotationQuaternion: Quaternion;
  26291. controllerType: PoseEnabledControllerType;
  26292. private _calculatedPosition;
  26293. private _calculatedRotation;
  26294. rawPose: DevicePose;
  26295. _mesh: Nullable<AbstractMesh>;
  26296. private _poseControlledCamera;
  26297. private _leftHandSystemQuaternion;
  26298. _deviceToWorld: Matrix;
  26299. /**
  26300. * Node to be used when casting a ray from the controller
  26301. */
  26302. _pointingPoseNode: Nullable<AbstractMesh>;
  26303. /**
  26304. * Name of the child mesh that can be used to cast a ray from the controller
  26305. */
  26306. static readonly POINTING_POSE: string;
  26307. constructor(browserGamepad: any);
  26308. private _workingMatrix;
  26309. update(): void;
  26310. updateFromDevice(poseData: DevicePose): void;
  26311. attachToMesh(mesh: AbstractMesh): void;
  26312. attachToPoseControlledCamera(camera: TargetCamera): void;
  26313. dispose(): void;
  26314. readonly mesh: Nullable<AbstractMesh>;
  26315. getForwardRay(length?: number): Ray;
  26316. }
  26317. }
  26318. declare module BABYLON {
  26319. class ViveController extends WebVRController {
  26320. static MODEL_BASE_URL: string;
  26321. static MODEL_FILENAME: string;
  26322. constructor(vrGamepad: any);
  26323. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26324. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26325. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26326. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26327. /**
  26328. * Vive mapping:
  26329. * 0: touchpad
  26330. * 1: trigger
  26331. * 2: left AND right buttons
  26332. * 3: menu button
  26333. */
  26334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26335. }
  26336. }
  26337. declare module BABYLON {
  26338. abstract class WebVRController extends PoseEnabledController {
  26339. protected _defaultModel: AbstractMesh;
  26340. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26341. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26342. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26343. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26344. onPadValuesChangedObservable: Observable<StickValues>;
  26345. protected _buttons: Array<MutableGamepadButton>;
  26346. private _onButtonStateChange;
  26347. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26348. pad: StickValues;
  26349. hand: string;
  26350. readonly defaultModel: AbstractMesh;
  26351. constructor(vrGamepad: any);
  26352. update(): void;
  26353. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26354. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26355. private _setButtonValue(newState, currentState, buttonIndex);
  26356. private _changes;
  26357. private _checkChanges(newState, currentState);
  26358. dispose(): void;
  26359. }
  26360. }
  26361. declare module BABYLON {
  26362. class WindowsMotionController extends WebVRController {
  26363. static MODEL_BASE_URL: string;
  26364. static MODEL_LEFT_FILENAME: string;
  26365. static MODEL_RIGHT_FILENAME: string;
  26366. static readonly GAMEPAD_ID_PREFIX: string;
  26367. private static readonly GAMEPAD_ID_PATTERN;
  26368. private _loadedMeshInfo;
  26369. private readonly _mapping;
  26370. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  26371. onTrackpadValuesChangedObservable: Observable<StickValues>;
  26372. trackpad: StickValues;
  26373. constructor(vrGamepad: any);
  26374. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26375. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26376. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26377. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26378. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26379. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  26380. /**
  26381. * Called once per frame by the engine.
  26382. */
  26383. update(): void;
  26384. /**
  26385. * Called once for each button that changed state since the last frame
  26386. * @param buttonIdx Which button index changed
  26387. * @param state New state of the button
  26388. * @param changes Which properties on the state changed since last frame
  26389. */
  26390. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26391. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  26392. protected lerpAxisTransform(axis: number, axisValue: number): void;
  26393. /**
  26394. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  26395. * @param scene scene in which to add meshes
  26396. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  26397. */
  26398. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  26399. /**
  26400. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  26401. * can be transformed by button presses and axes values, based on this._mapping.
  26402. *
  26403. * @param scene scene in which the meshes exist
  26404. * @param meshes list of meshes that make up the controller model to process
  26405. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  26406. */
  26407. private processModel(scene, meshes);
  26408. private createMeshInfo(rootNode);
  26409. getForwardRay(length?: number): Ray;
  26410. dispose(): void;
  26411. }
  26412. }
  26413. declare module BABYLON {
  26414. }
  26415. declare module BABYLON {
  26416. /**
  26417. * Interface to implement to create a shadow generator compatible with BJS.
  26418. */
  26419. interface IShadowGenerator {
  26420. /**
  26421. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  26422. * @returns The render target texture if present otherwise, null
  26423. */
  26424. getShadowMap(): Nullable<RenderTargetTexture>;
  26425. /**
  26426. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  26427. * @returns The render target texture if the shadow map is present otherwise, null
  26428. */
  26429. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  26430. /**
  26431. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  26432. * @param subMesh The submesh we want to render in the shadow map
  26433. * @param useInstances Defines wether will draw in the map using instances
  26434. * @returns true if ready otherwise, false
  26435. */
  26436. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26437. /**
  26438. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  26439. * @param defines Defines of the material we want to update
  26440. * @param lightIndex Index of the light in the enabled light list of the material
  26441. */
  26442. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  26443. /**
  26444. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  26445. * defined in the generator but impacting the effect).
  26446. * It implies the unifroms available on the materials are the standard BJS ones.
  26447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  26448. * @param effect The effect we are binfing the information for
  26449. */
  26450. bindShadowLight(lightIndex: string, effect: Effect): void;
  26451. /**
  26452. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  26453. * (eq to shadow prjection matrix * light transform matrix)
  26454. * @returns The transform matrix used to create the shadow map
  26455. */
  26456. getTransformMatrix(): Matrix;
  26457. /**
  26458. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  26459. * Cube and 2D textures for instance.
  26460. */
  26461. recreateShadowMap(): void;
  26462. /**
  26463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  26464. * @param onCompiled Callback triggered at the and of the effects compilation
  26465. * @param options Sets of optional options forcing the compilation with different modes
  26466. */
  26467. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  26468. useInstances: boolean;
  26469. }>): void;
  26470. /**
  26471. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  26472. * @param options Sets of optional options forcing the compilation with different modes
  26473. * @returns A promise that resolves when the compilation completes
  26474. */
  26475. forceCompilationAsync(options?: Partial<{
  26476. useInstances: boolean;
  26477. }>): Promise<void>;
  26478. /**
  26479. * Serializes the shadow generator setup to a json object.
  26480. * @returns The serialized JSON object
  26481. */
  26482. serialize(): any;
  26483. /**
  26484. * Disposes the Shadow map and related Textures and effects.
  26485. */
  26486. dispose(): void;
  26487. }
  26488. /**
  26489. * Default implementation IShadowGenerator.
  26490. * This is the main object responsible of generating shadows in the framework.
  26491. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  26492. */
  26493. class ShadowGenerator implements IShadowGenerator {
  26494. /**
  26495. * Shadow generator mode None: no filtering applied.
  26496. */
  26497. static readonly FILTER_NONE: number;
  26498. /**
  26499. * Shadow generator mode ESM: Exponential Shadow Mapping.
  26500. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  26501. */
  26502. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  26503. /**
  26504. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  26505. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  26506. */
  26507. static readonly FILTER_POISSONSAMPLING: number;
  26508. /**
  26509. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  26510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  26511. */
  26512. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  26513. /**
  26514. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  26515. * edge artifacts on steep falloff.
  26516. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  26517. */
  26518. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  26519. /**
  26520. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  26521. * edge artifacts on steep falloff.
  26522. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  26523. */
  26524. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  26525. /**
  26526. * Shadow generator mode PCF: Percentage Closer Filtering
  26527. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  26528. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  26529. */
  26530. static readonly FILTER_PCF: number;
  26531. /**
  26532. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  26533. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  26534. * Contact Hardening
  26535. */
  26536. static readonly FILTER_PCSS: number;
  26537. /**
  26538. * Reserved for PCF and PCSS
  26539. * Highest Quality.
  26540. *
  26541. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  26542. *
  26543. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  26544. */
  26545. static readonly QUALITY_HIGH: number;
  26546. /**
  26547. * Reserved for PCF and PCSS
  26548. * Good tradeoff for quality/perf cross devices
  26549. *
  26550. * Execute PCF on a 3*3 kernel.
  26551. *
  26552. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  26553. */
  26554. static readonly QUALITY_MEDIUM: number;
  26555. /**
  26556. * Reserved for PCF and PCSS
  26557. * The lowest quality but the fastest.
  26558. *
  26559. * Execute PCF on a 1*1 kernel.
  26560. *
  26561. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  26562. */
  26563. static readonly QUALITY_LOW: number;
  26564. private _bias;
  26565. /**
  26566. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  26567. */
  26568. /**
  26569. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  26570. */
  26571. bias: number;
  26572. private _normalBias;
  26573. /**
  26574. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  26575. */
  26576. /**
  26577. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  26578. */
  26579. normalBias: number;
  26580. private _blurBoxOffset;
  26581. /**
  26582. * Gets the blur box offset: offset applied during the blur pass.
  26583. * Only usefull if useKernelBlur = false
  26584. */
  26585. /**
  26586. * Sets the blur box offset: offset applied during the blur pass.
  26587. * Only usefull if useKernelBlur = false
  26588. */
  26589. blurBoxOffset: number;
  26590. private _blurScale;
  26591. /**
  26592. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  26593. * 2 means half of the size.
  26594. */
  26595. /**
  26596. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  26597. * 2 means half of the size.
  26598. */
  26599. blurScale: number;
  26600. private _blurKernel;
  26601. /**
  26602. * Gets the blur kernel: kernel size of the blur pass.
  26603. * Only usefull if useKernelBlur = true
  26604. */
  26605. /**
  26606. * Sets the blur kernel: kernel size of the blur pass.
  26607. * Only usefull if useKernelBlur = true
  26608. */
  26609. blurKernel: number;
  26610. private _useKernelBlur;
  26611. /**
  26612. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  26613. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  26614. */
  26615. /**
  26616. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  26617. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  26618. */
  26619. useKernelBlur: boolean;
  26620. private _depthScale;
  26621. /**
  26622. * Gets the depth scale used in ESM mode.
  26623. */
  26624. /**
  26625. * Sets the depth scale used in ESM mode.
  26626. * This can override the scale stored on the light.
  26627. */
  26628. depthScale: number;
  26629. private _filter;
  26630. /**
  26631. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  26632. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  26633. */
  26634. /**
  26635. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  26636. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  26637. */
  26638. filter: number;
  26639. /**
  26640. * Gets if the current filter is set to Poisson Sampling.
  26641. */
  26642. /**
  26643. * Sets the current filter to Poisson Sampling.
  26644. */
  26645. usePoissonSampling: boolean;
  26646. /**
  26647. * Gets if the current filter is set to VSM.
  26648. * DEPRECATED. Should use useExponentialShadowMap instead.
  26649. */
  26650. /**
  26651. * Sets the current filter is to VSM.
  26652. * DEPRECATED. Should use useExponentialShadowMap instead.
  26653. */
  26654. useVarianceShadowMap: boolean;
  26655. /**
  26656. * Gets if the current filter is set to blurred VSM.
  26657. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  26658. */
  26659. /**
  26660. * Sets the current filter is to blurred VSM.
  26661. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  26662. */
  26663. useBlurVarianceShadowMap: boolean;
  26664. /**
  26665. * Gets if the current filter is set to ESM.
  26666. */
  26667. /**
  26668. * Sets the current filter is to ESM.
  26669. */
  26670. useExponentialShadowMap: boolean;
  26671. /**
  26672. * Gets if the current filter is set to filtered ESM.
  26673. */
  26674. /**
  26675. * Gets if the current filter is set to filtered ESM.
  26676. */
  26677. useBlurExponentialShadowMap: boolean;
  26678. /**
  26679. * Gets if the current filter is set to "close ESM" (using the inverse of the
  26680. * exponential to prevent steep falloff artifacts).
  26681. */
  26682. /**
  26683. * Sets the current filter to "close ESM" (using the inverse of the
  26684. * exponential to prevent steep falloff artifacts).
  26685. */
  26686. useCloseExponentialShadowMap: boolean;
  26687. /**
  26688. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  26689. * exponential to prevent steep falloff artifacts).
  26690. */
  26691. /**
  26692. * Sets the current filter to filtered "close ESM" (using the inverse of the
  26693. * exponential to prevent steep falloff artifacts).
  26694. */
  26695. useBlurCloseExponentialShadowMap: boolean;
  26696. /**
  26697. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  26698. */
  26699. /**
  26700. * Sets the current filter to "PCF" (percentage closer filtering).
  26701. */
  26702. usePercentageCloserFiltering: boolean;
  26703. private _filteringQuality;
  26704. /**
  26705. * Gets the PCF or PCSS Quality.
  26706. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  26707. */
  26708. /**
  26709. * Sets the PCF or PCSS Quality.
  26710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  26711. */
  26712. filteringQuality: number;
  26713. /**
  26714. * Gets if the current filter is set to "PCSS" (contact hardening).
  26715. */
  26716. /**
  26717. * Sets the current filter to "PCSS" (contact hardening).
  26718. */
  26719. useContactHardeningShadow: boolean;
  26720. private _contactHardeningLightSizeUVRatio;
  26721. /**
  26722. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  26723. * Using a ratio helps keeping shape stability independently of the map size.
  26724. *
  26725. * It does not account for the light projection as it was having too much
  26726. * instability during the light setup or during light position changes.
  26727. *
  26728. * Only valid if useContactHardeningShadow is true.
  26729. */
  26730. /**
  26731. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  26732. * Using a ratio helps keeping shape stability independently of the map size.
  26733. *
  26734. * It does not account for the light projection as it was having too much
  26735. * instability during the light setup or during light position changes.
  26736. *
  26737. * Only valid if useContactHardeningShadow is true.
  26738. */
  26739. contactHardeningLightSizeUVRatio: number;
  26740. private _darkness;
  26741. /**
  26742. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  26743. * 0 means strongest and 1 would means no shadow.
  26744. * @returns the darkness.
  26745. */
  26746. getDarkness(): number;
  26747. /**
  26748. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  26749. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  26750. * @returns the shadow generator allowing fluent coding.
  26751. */
  26752. setDarkness(darkness: number): ShadowGenerator;
  26753. private _transparencyShadow;
  26754. /**
  26755. * Sets the ability to have transparent shadow (boolean).
  26756. * @param transparent True if transparent else False
  26757. * @returns the shadow generator allowing fluent coding
  26758. */
  26759. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  26760. private _shadowMap;
  26761. private _shadowMap2;
  26762. /**
  26763. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  26764. * @returns The render target texture if present otherwise, null
  26765. */
  26766. getShadowMap(): Nullable<RenderTargetTexture>;
  26767. /**
  26768. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  26769. * @returns The render target texture if the shadow map is present otherwise, null
  26770. */
  26771. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  26772. /**
  26773. * Helper function to add a mesh and its descendants to the list of shadow casters.
  26774. * @param mesh Mesh to add
  26775. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  26776. * @returns the Shadow Generator itself
  26777. */
  26778. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  26779. /**
  26780. * Helper function to remove a mesh and its descendants from the list of shadow casters
  26781. * @param mesh Mesh to remove
  26782. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  26783. * @returns the Shadow Generator itself
  26784. */
  26785. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  26786. /**
  26787. * Controls the extent to which the shadows fade out at the edge of the frustum
  26788. * Used only by directionals and spots
  26789. */
  26790. frustumEdgeFalloff: number;
  26791. private _light;
  26792. /**
  26793. * Returns the associated light object.
  26794. * @returns the light generating the shadow
  26795. */
  26796. getLight(): IShadowLight;
  26797. /**
  26798. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  26799. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  26800. * It might on the other hand introduce peter panning.
  26801. */
  26802. forceBackFacesOnly: boolean;
  26803. private _scene;
  26804. private _lightDirection;
  26805. private _effect;
  26806. private _viewMatrix;
  26807. private _projectionMatrix;
  26808. private _transformMatrix;
  26809. private _cachedPosition;
  26810. private _cachedDirection;
  26811. private _cachedDefines;
  26812. private _currentRenderID;
  26813. private _boxBlurPostprocess;
  26814. private _kernelBlurXPostprocess;
  26815. private _kernelBlurYPostprocess;
  26816. private _blurPostProcesses;
  26817. private _mapSize;
  26818. private _currentFaceIndex;
  26819. private _currentFaceIndexCache;
  26820. private _textureType;
  26821. private _defaultTextureMatrix;
  26822. /**
  26823. * Creates a ShadowGenerator object.
  26824. * A ShadowGenerator is the required tool to use the shadows.
  26825. * Each light casting shadows needs to use its own ShadowGenerator.
  26826. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  26827. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  26828. * @param light The light object generating the shadows.
  26829. * @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.
  26830. */
  26831. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  26832. private _initializeGenerator();
  26833. private _initializeShadowMap();
  26834. private _initializeBlurRTTAndPostProcesses();
  26835. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  26836. private _renderSubMeshForShadowMap(subMesh);
  26837. private _applyFilterValues();
  26838. /**
  26839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  26840. * @param onCompiled Callback triggered at the and of the effects compilation
  26841. * @param options Sets of optional options forcing the compilation with different modes
  26842. */
  26843. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  26844. useInstances: boolean;
  26845. }>): void;
  26846. /**
  26847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  26848. * @param options Sets of optional options forcing the compilation with different modes
  26849. * @returns A promise that resolves when the compilation completes
  26850. */
  26851. forceCompilationAsync(options?: Partial<{
  26852. useInstances: boolean;
  26853. }>): Promise<void>;
  26854. /**
  26855. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  26856. * @param subMesh The submesh we want to render in the shadow map
  26857. * @param useInstances Defines wether will draw in the map using instances
  26858. * @returns true if ready otherwise, false
  26859. */
  26860. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26861. /**
  26862. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  26863. * @param defines Defines of the material we want to update
  26864. * @param lightIndex Index of the light in the enabled light list of the material
  26865. */
  26866. prepareDefines(defines: any, lightIndex: number): void;
  26867. /**
  26868. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  26869. * defined in the generator but impacting the effect).
  26870. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  26871. * @param effect The effect we are binfing the information for
  26872. */
  26873. bindShadowLight(lightIndex: string, effect: Effect): void;
  26874. /**
  26875. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  26876. * (eq to shadow prjection matrix * light transform matrix)
  26877. * @returns The transform matrix used to create the shadow map
  26878. */
  26879. getTransformMatrix(): Matrix;
  26880. /**
  26881. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  26882. * Cube and 2D textures for instance.
  26883. */
  26884. recreateShadowMap(): void;
  26885. private _disposeBlurPostProcesses();
  26886. private _disposeRTTandPostProcesses();
  26887. /**
  26888. * Disposes the ShadowGenerator.
  26889. * Returns nothing.
  26890. */
  26891. dispose(): void;
  26892. /**
  26893. * Serializes the shadow generator setup to a json object.
  26894. * @returns The serialized JSON object
  26895. */
  26896. serialize(): any;
  26897. /**
  26898. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  26899. * @param parsedShadowGenerator The JSON object to parse
  26900. * @param scene The scene to create the shadow map for
  26901. * @returns The parsed shadow generator
  26902. */
  26903. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  26904. }
  26905. }
  26906. declare module BABYLON {
  26907. /**
  26908. * Background material used to create an efficient environement around your scene.
  26909. */
  26910. class BackgroundMaterial extends PushMaterial {
  26911. /**
  26912. * Standard reflectance value at parallel view angle.
  26913. */
  26914. static StandardReflectance0: number;
  26915. /**
  26916. * Standard reflectance value at grazing angle.
  26917. */
  26918. static StandardReflectance90: number;
  26919. protected _primaryColor: Color3;
  26920. /**
  26921. * Key light Color (multiply against the R channel of the environement texture)
  26922. */
  26923. primaryColor: Color3;
  26924. protected _primaryLevel: float;
  26925. /**
  26926. * Key light Level (allowing HDR output of the background)
  26927. */
  26928. primaryLevel: float;
  26929. protected _secondaryColor: Color3;
  26930. /**
  26931. * Secondary light Color (multiply against the G channel of the environement texture)
  26932. */
  26933. secondaryColor: Color3;
  26934. protected _secondaryLevel: float;
  26935. /**
  26936. * Secondary light Level (allowing HDR output of the background)
  26937. */
  26938. secondaryLevel: float;
  26939. protected _tertiaryColor: Color3;
  26940. /**
  26941. * Tertiary light Color (multiply against the B channel of the environement texture)
  26942. */
  26943. tertiaryColor: Color3;
  26944. protected _tertiaryLevel: float;
  26945. /**
  26946. * Tertiary light Level (allowing HDR output of the background)
  26947. */
  26948. tertiaryLevel: float;
  26949. protected _reflectionTexture: Nullable<BaseTexture>;
  26950. /**
  26951. * Reflection Texture used in the material.
  26952. * Should be author in a specific way for the best result (refer to the documentation).
  26953. */
  26954. reflectionTexture: Nullable<BaseTexture>;
  26955. protected _reflectionBlur: float;
  26956. /**
  26957. * Reflection Texture level of blur.
  26958. *
  26959. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  26960. * texture twice.
  26961. */
  26962. reflectionBlur: float;
  26963. protected _diffuseTexture: Nullable<BaseTexture>;
  26964. /**
  26965. * Diffuse Texture used in the material.
  26966. * Should be author in a specific way for the best result (refer to the documentation).
  26967. */
  26968. diffuseTexture: Nullable<BaseTexture>;
  26969. protected _shadowLights: Nullable<IShadowLight[]>;
  26970. /**
  26971. * Specify the list of lights casting shadow on the material.
  26972. * All scene shadow lights will be included if null.
  26973. */
  26974. shadowLights: Nullable<IShadowLight[]>;
  26975. protected _shadowBlurScale: int;
  26976. /**
  26977. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  26978. * soft lighting on the background.
  26979. */
  26980. shadowBlurScale: int;
  26981. protected _shadowLevel: float;
  26982. /**
  26983. * Helps adjusting the shadow to a softer level if required.
  26984. * 0 means black shadows and 1 means no shadows.
  26985. */
  26986. shadowLevel: float;
  26987. protected _sceneCenter: Vector3;
  26988. /**
  26989. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  26990. * It is usually zero but might be interesting to modify according to your setup.
  26991. */
  26992. sceneCenter: Vector3;
  26993. protected _opacityFresnel: boolean;
  26994. /**
  26995. * This helps specifying that the material is falling off to the sky box at grazing angle.
  26996. * This helps ensuring a nice transition when the camera goes under the ground.
  26997. */
  26998. opacityFresnel: boolean;
  26999. protected _reflectionFresnel: boolean;
  27000. /**
  27001. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  27002. * This helps adding a mirror texture on the ground.
  27003. */
  27004. reflectionFresnel: boolean;
  27005. protected _reflectionFalloffDistance: number;
  27006. /**
  27007. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  27008. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  27009. */
  27010. reflectionFalloffDistance: number;
  27011. protected _reflectionAmount: number;
  27012. /**
  27013. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  27014. */
  27015. reflectionAmount: number;
  27016. protected _reflectionReflectance0: number;
  27017. /**
  27018. * This specifies the weight of the reflection at grazing angle.
  27019. */
  27020. reflectionReflectance0: number;
  27021. protected _reflectionReflectance90: number;
  27022. /**
  27023. * This specifies the weight of the reflection at a perpendicular point of view.
  27024. */
  27025. reflectionReflectance90: number;
  27026. /**
  27027. * Sets the reflection reflectance fresnel values according to the default standard
  27028. * empirically know to work well :-)
  27029. */
  27030. reflectionStandardFresnelWeight: number;
  27031. protected _useRGBColor: boolean;
  27032. /**
  27033. * Helps to directly use the maps channels instead of their level.
  27034. */
  27035. useRGBColor: boolean;
  27036. protected _enableNoise: boolean;
  27037. /**
  27038. * This helps reducing the banding effect that could occur on the background.
  27039. */
  27040. enableNoise: boolean;
  27041. /**
  27042. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  27043. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  27044. * Recommended to be keep at 1.0 except for special cases.
  27045. */
  27046. fovMultiplier: number;
  27047. private _fovMultiplier;
  27048. /**
  27049. * Enable the FOV adjustment feature controlled by fovMultiplier.
  27050. */
  27051. useEquirectangularFOV: boolean;
  27052. private _maxSimultaneousLights;
  27053. /**
  27054. * Number of Simultaneous lights allowed on the material.
  27055. */
  27056. maxSimultaneousLights: int;
  27057. /**
  27058. * Default configuration related to image processing available in the Background Material.
  27059. */
  27060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27061. /**
  27062. * Keep track of the image processing observer to allow dispose and replace.
  27063. */
  27064. private _imageProcessingObserver;
  27065. /**
  27066. * Attaches a new image processing configuration to the PBR Material.
  27067. * @param configuration (if null the scene configuration will be use)
  27068. */
  27069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27070. /**
  27071. * Gets the image processing configuration used either in this material.
  27072. */
  27073. /**
  27074. * Sets the Default image processing configuration used either in the this material.
  27075. *
  27076. * If sets to null, the scene one is in use.
  27077. */
  27078. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  27079. /**
  27080. * Gets wether the color curves effect is enabled.
  27081. */
  27082. /**
  27083. * Sets wether the color curves effect is enabled.
  27084. */
  27085. cameraColorCurvesEnabled: boolean;
  27086. /**
  27087. * Gets wether the color grading effect is enabled.
  27088. */
  27089. /**
  27090. * Gets wether the color grading effect is enabled.
  27091. */
  27092. cameraColorGradingEnabled: boolean;
  27093. /**
  27094. * Gets wether tonemapping is enabled or not.
  27095. */
  27096. /**
  27097. * Sets wether tonemapping is enabled or not
  27098. */
  27099. cameraToneMappingEnabled: boolean;
  27100. /**
  27101. * The camera exposure used on this material.
  27102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27103. * This corresponds to a photographic exposure.
  27104. */
  27105. /**
  27106. * The camera exposure used on this material.
  27107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27108. * This corresponds to a photographic exposure.
  27109. */
  27110. cameraExposure: float;
  27111. /**
  27112. * Gets The camera contrast used on this material.
  27113. */
  27114. /**
  27115. * Sets The camera contrast used on this material.
  27116. */
  27117. cameraContrast: float;
  27118. /**
  27119. * Gets the Color Grading 2D Lookup Texture.
  27120. */
  27121. /**
  27122. * Sets the Color Grading 2D Lookup Texture.
  27123. */
  27124. cameraColorGradingTexture: Nullable<BaseTexture>;
  27125. /**
  27126. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27128. * 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;
  27129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27130. */
  27131. /**
  27132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27134. * 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;
  27135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27136. */
  27137. cameraColorCurves: Nullable<ColorCurves>;
  27138. /**
  27139. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  27140. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  27141. */
  27142. switchToBGR: boolean;
  27143. private _renderTargets;
  27144. private _reflectionControls;
  27145. /**
  27146. * Instantiates a Background Material in the given scene
  27147. * @param name The friendly name of the material
  27148. * @param scene The scene to add the material to
  27149. */
  27150. constructor(name: string, scene: Scene);
  27151. /**
  27152. * The entire material has been created in order to prevent overdraw.
  27153. * @returns false
  27154. */
  27155. needAlphaTesting(): boolean;
  27156. /**
  27157. * The entire material has been created in order to prevent overdraw.
  27158. * @returns true if blending is enable
  27159. */
  27160. needAlphaBlending(): boolean;
  27161. /**
  27162. * Checks wether the material is ready to be rendered for a given mesh.
  27163. * @param mesh The mesh to render
  27164. * @param subMesh The submesh to check against
  27165. * @param useInstances Specify wether or not the material is used with instances
  27166. * @returns true if all the dependencies are ready (Textures, Effects...)
  27167. */
  27168. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27169. /**
  27170. * Build the uniform buffer used in the material.
  27171. */
  27172. buildUniformLayout(): void;
  27173. /**
  27174. * Unbind the material.
  27175. */
  27176. unbind(): void;
  27177. /**
  27178. * Bind only the world matrix to the material.
  27179. * @param world The world matrix to bind.
  27180. */
  27181. bindOnlyWorldMatrix(world: Matrix): void;
  27182. /**
  27183. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  27184. * @param world The world matrix to bind.
  27185. * @param subMesh The submesh to bind for.
  27186. */
  27187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27188. /**
  27189. * Dispose the material.
  27190. * @param forceDisposeEffect Force disposal of the associated effect.
  27191. * @param forceDisposeTextures Force disposal of the associated textures.
  27192. */
  27193. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27194. /**
  27195. * Clones the material.
  27196. * @param name The cloned name.
  27197. * @returns The cloned material.
  27198. */
  27199. clone(name: string): BackgroundMaterial;
  27200. /**
  27201. * Serializes the current material to its JSON representation.
  27202. * @returns The JSON representation.
  27203. */
  27204. serialize(): any;
  27205. /**
  27206. * Gets the class name of the material
  27207. * @returns "BackgroundMaterial"
  27208. */
  27209. getClassName(): string;
  27210. /**
  27211. * Parse a JSON input to create back a background material.
  27212. * @param source The JSON data to parse
  27213. * @param scene The scene to create the parsed material in
  27214. * @param rootUrl The root url of the assets the material depends upon
  27215. * @returns the instantiated BackgroundMaterial.
  27216. */
  27217. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  27218. }
  27219. }
  27220. declare module BABYLON {
  27221. /**
  27222. * The Physically based material base class of BJS.
  27223. *
  27224. * This offers the main features of a standard PBR material.
  27225. * For more information, please refer to the documentation :
  27226. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  27227. */
  27228. abstract class PBRBaseMaterial extends PushMaterial {
  27229. /**
  27230. * Intensity of the direct lights e.g. the four lights available in your scene.
  27231. * This impacts both the direct diffuse and specular highlights.
  27232. */
  27233. protected _directIntensity: number;
  27234. /**
  27235. * Intensity of the emissive part of the material.
  27236. * This helps controlling the emissive effect without modifying the emissive color.
  27237. */
  27238. protected _emissiveIntensity: number;
  27239. /**
  27240. * Intensity of the environment e.g. how much the environment will light the object
  27241. * either through harmonics for rough material or through the refelction for shiny ones.
  27242. */
  27243. protected _environmentIntensity: number;
  27244. /**
  27245. * This is a special control allowing the reduction of the specular highlights coming from the
  27246. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27247. */
  27248. protected _specularIntensity: number;
  27249. /**
  27250. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27251. */
  27252. private _lightingInfos;
  27253. /**
  27254. * Debug Control allowing disabling the bump map on this material.
  27255. */
  27256. protected _disableBumpMap: boolean;
  27257. /**
  27258. * AKA Diffuse Texture in standard nomenclature.
  27259. */
  27260. protected _albedoTexture: BaseTexture;
  27261. /**
  27262. * AKA Occlusion Texture in other nomenclature.
  27263. */
  27264. protected _ambientTexture: BaseTexture;
  27265. /**
  27266. * AKA Occlusion Texture Intensity in other nomenclature.
  27267. */
  27268. protected _ambientTextureStrength: number;
  27269. /**
  27270. * Stores the alpha values in a texture.
  27271. */
  27272. protected _opacityTexture: BaseTexture;
  27273. /**
  27274. * Stores the reflection values in a texture.
  27275. */
  27276. protected _reflectionTexture: BaseTexture;
  27277. /**
  27278. * Stores the refraction values in a texture.
  27279. */
  27280. protected _refractionTexture: BaseTexture;
  27281. /**
  27282. * Stores the emissive values in a texture.
  27283. */
  27284. protected _emissiveTexture: BaseTexture;
  27285. /**
  27286. * AKA Specular texture in other nomenclature.
  27287. */
  27288. protected _reflectivityTexture: BaseTexture;
  27289. /**
  27290. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27291. */
  27292. protected _metallicTexture: BaseTexture;
  27293. /**
  27294. * Specifies the metallic scalar of the metallic/roughness workflow.
  27295. * Can also be used to scale the metalness values of the metallic texture.
  27296. */
  27297. protected _metallic: number;
  27298. /**
  27299. * Specifies the roughness scalar of the metallic/roughness workflow.
  27300. * Can also be used to scale the roughness values of the metallic texture.
  27301. */
  27302. protected _roughness: number;
  27303. /**
  27304. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  27305. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27306. */
  27307. protected _microSurfaceTexture: BaseTexture;
  27308. /**
  27309. * Stores surface normal data used to displace a mesh in a texture.
  27310. */
  27311. protected _bumpTexture: BaseTexture;
  27312. /**
  27313. * Stores the pre-calculated light information of a mesh in a texture.
  27314. */
  27315. protected _lightmapTexture: BaseTexture;
  27316. /**
  27317. * The color of a material in ambient lighting.
  27318. */
  27319. protected _ambientColor: Color3;
  27320. /**
  27321. * AKA Diffuse Color in other nomenclature.
  27322. */
  27323. protected _albedoColor: Color3;
  27324. /**
  27325. * AKA Specular Color in other nomenclature.
  27326. */
  27327. protected _reflectivityColor: Color3;
  27328. /**
  27329. * The color applied when light is reflected from a material.
  27330. */
  27331. protected _reflectionColor: Color3;
  27332. /**
  27333. * The color applied when light is emitted from a material.
  27334. */
  27335. protected _emissiveColor: Color3;
  27336. /**
  27337. * AKA Glossiness in other nomenclature.
  27338. */
  27339. protected _microSurface: number;
  27340. /**
  27341. * source material index of refraction (IOR)' / 'destination material IOR.
  27342. */
  27343. protected _indexOfRefraction: number;
  27344. /**
  27345. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  27346. */
  27347. protected _invertRefractionY: boolean;
  27348. /**
  27349. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27350. * Materials half opaque for instance using refraction could benefit from this control.
  27351. */
  27352. protected _linkRefractionWithTransparency: boolean;
  27353. /**
  27354. * Specifies that the material will use the light map as a show map.
  27355. */
  27356. protected _useLightmapAsShadowmap: boolean;
  27357. /**
  27358. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27359. * makes the reflect vector face the model (under horizon).
  27360. */
  27361. protected _useHorizonOcclusion: boolean;
  27362. /**
  27363. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27364. * too much the area relying on ambient texture to define their ambient occlusion.
  27365. */
  27366. protected _useRadianceOcclusion: boolean;
  27367. /**
  27368. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27369. */
  27370. protected _useAlphaFromAlbedoTexture: boolean;
  27371. /**
  27372. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27373. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27374. */
  27375. protected _useSpecularOverAlpha: boolean;
  27376. /**
  27377. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27378. */
  27379. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27380. /**
  27381. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27382. */
  27383. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27384. /**
  27385. * Specifies if the metallic texture contains the roughness information in its green channel.
  27386. */
  27387. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27388. /**
  27389. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27390. */
  27391. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27392. /**
  27393. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27394. */
  27395. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27396. /**
  27397. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27398. */
  27399. protected _useAmbientInGrayScale: boolean;
  27400. /**
  27401. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27402. * The material will try to infer what glossiness each pixel should be.
  27403. */
  27404. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27405. /**
  27406. * BJS is using an harcoded light falloff based on a manually sets up range.
  27407. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27408. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27409. */
  27410. protected _usePhysicalLightFalloff: boolean;
  27411. /**
  27412. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27413. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27414. */
  27415. protected _useRadianceOverAlpha: boolean;
  27416. /**
  27417. * Allows using an object space normal map (instead of tangent space).
  27418. */
  27419. protected _useObjectSpaceNormalMap: boolean;
  27420. /**
  27421. * Allows using the bump map in parallax mode.
  27422. */
  27423. protected _useParallax: boolean;
  27424. /**
  27425. * Allows using the bump map in parallax occlusion mode.
  27426. */
  27427. protected _useParallaxOcclusion: boolean;
  27428. /**
  27429. * Controls the scale bias of the parallax mode.
  27430. */
  27431. protected _parallaxScaleBias: number;
  27432. /**
  27433. * If sets to true, disables all the lights affecting the material.
  27434. */
  27435. protected _disableLighting: boolean;
  27436. /**
  27437. * Number of Simultaneous lights allowed on the material.
  27438. */
  27439. protected _maxSimultaneousLights: number;
  27440. /**
  27441. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27442. */
  27443. protected _invertNormalMapX: boolean;
  27444. /**
  27445. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27446. */
  27447. protected _invertNormalMapY: boolean;
  27448. /**
  27449. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27450. */
  27451. protected _twoSidedLighting: boolean;
  27452. /**
  27453. * Defines the alpha limits in alpha test mode.
  27454. */
  27455. protected _alphaCutOff: number;
  27456. /**
  27457. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27458. */
  27459. protected _forceAlphaTest: boolean;
  27460. /**
  27461. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27462. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27463. */
  27464. protected _useAlphaFresnel: boolean;
  27465. /**
  27466. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27467. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27468. */
  27469. protected _useLinearAlphaFresnel: boolean;
  27470. /**
  27471. * The transparency mode of the material.
  27472. */
  27473. protected _transparencyMode: Nullable<number>;
  27474. /**
  27475. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27476. * from cos thetav and roughness:
  27477. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27478. */
  27479. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27480. /**
  27481. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27482. */
  27483. protected _forceIrradianceInFragment: boolean;
  27484. /**
  27485. * Force normal to face away from face.
  27486. */
  27487. protected _forceNormalForward: boolean;
  27488. /**
  27489. * Default configuration related to image processing available in the PBR Material.
  27490. */
  27491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27492. /**
  27493. * Keep track of the image processing observer to allow dispose and replace.
  27494. */
  27495. private _imageProcessingObserver;
  27496. /**
  27497. * Attaches a new image processing configuration to the PBR Material.
  27498. * @param configuration
  27499. */
  27500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27501. /**
  27502. * Stores the available render targets.
  27503. */
  27504. private _renderTargets;
  27505. /**
  27506. * Sets the global ambient color for the material used in lighting calculations.
  27507. */
  27508. private _globalAmbientColor;
  27509. /**
  27510. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27511. */
  27512. private _useLogarithmicDepth;
  27513. /**
  27514. * If set to true, no lighting calculations will be applied.
  27515. */
  27516. private _unlit;
  27517. /**
  27518. * Instantiates a new PBRMaterial instance.
  27519. *
  27520. * @param name The material name
  27521. * @param scene The scene the material will be use in.
  27522. */
  27523. constructor(name: string, scene: Scene);
  27524. /**
  27525. * Gets the name of the material class.
  27526. */
  27527. getClassName(): string;
  27528. /**
  27529. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27530. */
  27531. /**
  27532. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27533. */
  27534. useLogarithmicDepth: boolean;
  27535. /**
  27536. * Gets the current transparency mode.
  27537. */
  27538. /**
  27539. * Sets the transparency mode of the material.
  27540. */
  27541. transparencyMode: Nullable<number>;
  27542. /**
  27543. * Returns true if alpha blending should be disabled.
  27544. */
  27545. private readonly _disableAlphaBlending;
  27546. /**
  27547. * Specifies whether or not this material should be rendered in alpha blend mode.
  27548. */
  27549. needAlphaBlending(): boolean;
  27550. /**
  27551. * Specifies if the mesh will require alpha blending.
  27552. * @param mesh - BJS mesh.
  27553. */
  27554. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  27555. /**
  27556. * Specifies whether or not this material should be rendered in alpha test mode.
  27557. */
  27558. needAlphaTesting(): boolean;
  27559. /**
  27560. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27561. */
  27562. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27563. /**
  27564. * Gets the texture used for the alpha test.
  27565. */
  27566. getAlphaTestTexture(): BaseTexture;
  27567. /**
  27568. * Stores the reflectivity values based on metallic roughness workflow.
  27569. */
  27570. private static _scaledReflectivity;
  27571. /**
  27572. * Specifies that the submesh is ready to be used.
  27573. * @param mesh - BJS mesh.
  27574. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27575. * @param useInstances - Specifies that instances should be used.
  27576. * @returns - boolean indicating that the submesh is ready or not.
  27577. */
  27578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27579. /**
  27580. * Specifies if the material uses metallic roughness workflow.
  27581. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27582. */
  27583. isMetallicWorkflow(): boolean;
  27584. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  27585. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  27586. /**
  27587. * Force shader compilation
  27588. */
  27589. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  27590. clipPlane: boolean;
  27591. }>): void;
  27592. /**
  27593. * Initializes the uniform buffer layout for the shader.
  27594. */
  27595. buildUniformLayout(): void;
  27596. /**
  27597. * Unbinds the textures.
  27598. */
  27599. unbind(): void;
  27600. /**
  27601. * Binds the submesh data.
  27602. * @param world - The world matrix.
  27603. * @param mesh - The BJS mesh.
  27604. * @param subMesh - A submesh of the BJS mesh.
  27605. */
  27606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27607. /**
  27608. * Returns the animatable textures.
  27609. * @returns - Array of animatable textures.
  27610. */
  27611. getAnimatables(): IAnimatable[];
  27612. /**
  27613. * Returns the texture used for reflections.
  27614. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27615. */
  27616. private _getReflectionTexture();
  27617. /**
  27618. * Returns the texture used for refraction or null if none is used.
  27619. * @returns - Refection texture if present. If no refraction texture and refraction
  27620. * is linked with transparency, returns environment texture. Otherwise, returns null.
  27621. */
  27622. private _getRefractionTexture();
  27623. /**
  27624. * Disposes the resources of the material.
  27625. * @param forceDisposeEffect - Forces the disposal of effects.
  27626. * @param forceDisposeTextures - Forces the disposal of all textures.
  27627. */
  27628. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27629. }
  27630. }
  27631. declare module BABYLON {
  27632. /**
  27633. * The Physically based simple base material of BJS.
  27634. *
  27635. * This enables better naming and convention enforcements on top of the pbrMaterial.
  27636. * It is used as the base class for both the specGloss and metalRough conventions.
  27637. */
  27638. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  27639. /**
  27640. * Number of Simultaneous lights allowed on the material.
  27641. */
  27642. maxSimultaneousLights: number;
  27643. /**
  27644. * If sets to true, disables all the lights affecting the material.
  27645. */
  27646. disableLighting: boolean;
  27647. /**
  27648. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  27649. */
  27650. environmentTexture: BaseTexture;
  27651. /**
  27652. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27653. */
  27654. invertNormalMapX: boolean;
  27655. /**
  27656. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27657. */
  27658. invertNormalMapY: boolean;
  27659. /**
  27660. * Normal map used in the model.
  27661. */
  27662. normalTexture: BaseTexture;
  27663. /**
  27664. * Emissivie color used to self-illuminate the model.
  27665. */
  27666. emissiveColor: Color3;
  27667. /**
  27668. * Emissivie texture used to self-illuminate the model.
  27669. */
  27670. emissiveTexture: BaseTexture;
  27671. /**
  27672. * Occlusion Channel Strenght.
  27673. */
  27674. occlusionStrength: number;
  27675. /**
  27676. * Occlusion Texture of the material (adding extra occlusion effects).
  27677. */
  27678. occlusionTexture: BaseTexture;
  27679. /**
  27680. * Defines the alpha limits in alpha test mode.
  27681. */
  27682. alphaCutOff: number;
  27683. /**
  27684. * Gets the current double sided mode.
  27685. */
  27686. /**
  27687. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27688. */
  27689. doubleSided: boolean;
  27690. lightmapTexture: BaseTexture;
  27691. useLightmapAsShadowmap: boolean;
  27692. /**
  27693. * Return the active textures of the material.
  27694. */
  27695. getActiveTextures(): BaseTexture[];
  27696. hasTexture(texture: BaseTexture): boolean;
  27697. /**
  27698. * Instantiates a new PBRMaterial instance.
  27699. *
  27700. * @param name The material name
  27701. * @param scene The scene the material will be use in.
  27702. */
  27703. constructor(name: string, scene: Scene);
  27704. getClassName(): string;
  27705. }
  27706. }
  27707. declare module BABYLON {
  27708. /**
  27709. * The Physically based material of BJS.
  27710. *
  27711. * This offers the main features of a standard PBR material.
  27712. * For more information, please refer to the documentation :
  27713. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  27714. */
  27715. class PBRMaterial extends PBRBaseMaterial {
  27716. private static _PBRMATERIAL_OPAQUE;
  27717. /**
  27718. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27719. */
  27720. static readonly PBRMATERIAL_OPAQUE: number;
  27721. /**
  27722. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27723. */
  27724. private static _PBRMATERIAL_ALPHATEST;
  27725. /**
  27726. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27727. */
  27728. static readonly PBRMATERIAL_ALPHATEST: number;
  27729. /**
  27730. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27731. */
  27732. private static _PBRMATERIAL_ALPHABLEND;
  27733. /**
  27734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27735. */
  27736. static readonly PBRMATERIAL_ALPHABLEND: number;
  27737. /**
  27738. * 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.
  27739. * They are also discarded below the alpha cutoff threshold to improve performances.
  27740. */
  27741. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  27742. /**
  27743. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27744. * They are also discarded below the alpha cutoff threshold to improve performances.
  27745. */
  27746. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27747. /**
  27748. * Intensity of the direct lights e.g. the four lights available in your scene.
  27749. * This impacts both the direct diffuse and specular highlights.
  27750. */
  27751. directIntensity: number;
  27752. /**
  27753. * Intensity of the emissive part of the material.
  27754. * This helps controlling the emissive effect without modifying the emissive color.
  27755. */
  27756. emissiveIntensity: number;
  27757. /**
  27758. * Intensity of the environment e.g. how much the environment will light the object
  27759. * either through harmonics for rough material or through the refelction for shiny ones.
  27760. */
  27761. environmentIntensity: number;
  27762. /**
  27763. * This is a special control allowing the reduction of the specular highlights coming from the
  27764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27765. */
  27766. specularIntensity: number;
  27767. /**
  27768. * Debug Control allowing disabling the bump map on this material.
  27769. */
  27770. disableBumpMap: boolean;
  27771. /**
  27772. * AKA Diffuse Texture in standard nomenclature.
  27773. */
  27774. albedoTexture: BaseTexture;
  27775. /**
  27776. * AKA Occlusion Texture in other nomenclature.
  27777. */
  27778. ambientTexture: BaseTexture;
  27779. /**
  27780. * AKA Occlusion Texture Intensity in other nomenclature.
  27781. */
  27782. ambientTextureStrength: number;
  27783. /**
  27784. * Stores the alpha values in a texture.
  27785. */
  27786. opacityTexture: BaseTexture;
  27787. /**
  27788. * Stores the reflection values in a texture.
  27789. */
  27790. reflectionTexture: Nullable<BaseTexture>;
  27791. /**
  27792. * Stores the emissive values in a texture.
  27793. */
  27794. emissiveTexture: BaseTexture;
  27795. /**
  27796. * AKA Specular texture in other nomenclature.
  27797. */
  27798. reflectivityTexture: BaseTexture;
  27799. /**
  27800. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27801. */
  27802. metallicTexture: BaseTexture;
  27803. /**
  27804. * Specifies the metallic scalar of the metallic/roughness workflow.
  27805. * Can also be used to scale the metalness values of the metallic texture.
  27806. */
  27807. metallic: number;
  27808. /**
  27809. * Specifies the roughness scalar of the metallic/roughness workflow.
  27810. * Can also be used to scale the roughness values of the metallic texture.
  27811. */
  27812. roughness: number;
  27813. /**
  27814. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  27815. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27816. */
  27817. microSurfaceTexture: BaseTexture;
  27818. /**
  27819. * Stores surface normal data used to displace a mesh in a texture.
  27820. */
  27821. bumpTexture: BaseTexture;
  27822. /**
  27823. * Stores the pre-calculated light information of a mesh in a texture.
  27824. */
  27825. lightmapTexture: BaseTexture;
  27826. /**
  27827. * Stores the refracted light information in a texture.
  27828. */
  27829. refractionTexture: BaseTexture;
  27830. /**
  27831. * The color of a material in ambient lighting.
  27832. */
  27833. ambientColor: Color3;
  27834. /**
  27835. * AKA Diffuse Color in other nomenclature.
  27836. */
  27837. albedoColor: Color3;
  27838. /**
  27839. * AKA Specular Color in other nomenclature.
  27840. */
  27841. reflectivityColor: Color3;
  27842. /**
  27843. * The color reflected from the material.
  27844. */
  27845. reflectionColor: Color3;
  27846. /**
  27847. * The color emitted from the material.
  27848. */
  27849. emissiveColor: Color3;
  27850. /**
  27851. * AKA Glossiness in other nomenclature.
  27852. */
  27853. microSurface: number;
  27854. /**
  27855. * source material index of refraction (IOR)' / 'destination material IOR.
  27856. */
  27857. indexOfRefraction: number;
  27858. /**
  27859. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  27860. */
  27861. invertRefractionY: boolean;
  27862. /**
  27863. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27864. * Materials half opaque for instance using refraction could benefit from this control.
  27865. */
  27866. linkRefractionWithTransparency: boolean;
  27867. useLightmapAsShadowmap: boolean;
  27868. /**
  27869. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27870. */
  27871. useAlphaFromAlbedoTexture: boolean;
  27872. /**
  27873. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27874. */
  27875. forceAlphaTest: boolean;
  27876. /**
  27877. * Defines the alpha limits in alpha test mode.
  27878. */
  27879. alphaCutOff: number;
  27880. /**
  27881. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27882. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27883. */
  27884. useSpecularOverAlpha: boolean;
  27885. /**
  27886. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27887. */
  27888. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27889. /**
  27890. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27891. */
  27892. useRoughnessFromMetallicTextureAlpha: boolean;
  27893. /**
  27894. * Specifies if the metallic texture contains the roughness information in its green channel.
  27895. */
  27896. useRoughnessFromMetallicTextureGreen: boolean;
  27897. /**
  27898. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27899. */
  27900. useMetallnessFromMetallicTextureBlue: boolean;
  27901. /**
  27902. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27903. */
  27904. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27905. /**
  27906. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27907. */
  27908. useAmbientInGrayScale: boolean;
  27909. /**
  27910. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27911. * The material will try to infer what glossiness each pixel should be.
  27912. */
  27913. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27914. /**
  27915. * BJS is using an harcoded light falloff based on a manually sets up range.
  27916. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27917. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27918. */
  27919. usePhysicalLightFalloff: boolean;
  27920. /**
  27921. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27922. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27923. */
  27924. useRadianceOverAlpha: boolean;
  27925. /**
  27926. * Allows using an object space normal map (instead of tangent space).
  27927. */
  27928. useObjectSpaceNormalMap: boolean;
  27929. /**
  27930. * Allows using the bump map in parallax mode.
  27931. */
  27932. useParallax: boolean;
  27933. /**
  27934. * Allows using the bump map in parallax occlusion mode.
  27935. */
  27936. useParallaxOcclusion: boolean;
  27937. /**
  27938. * Controls the scale bias of the parallax mode.
  27939. */
  27940. parallaxScaleBias: number;
  27941. /**
  27942. * If sets to true, disables all the lights affecting the material.
  27943. */
  27944. disableLighting: boolean;
  27945. /**
  27946. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27947. */
  27948. forceIrradianceInFragment: boolean;
  27949. /**
  27950. * Number of Simultaneous lights allowed on the material.
  27951. */
  27952. maxSimultaneousLights: number;
  27953. /**
  27954. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27955. */
  27956. invertNormalMapX: boolean;
  27957. /**
  27958. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27959. */
  27960. invertNormalMapY: boolean;
  27961. /**
  27962. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27963. */
  27964. twoSidedLighting: boolean;
  27965. /**
  27966. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27967. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27968. */
  27969. useAlphaFresnel: boolean;
  27970. /**
  27971. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27972. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27973. */
  27974. useLinearAlphaFresnel: boolean;
  27975. /**
  27976. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27977. * And/Or occlude the blended part.
  27978. */
  27979. environmentBRDFTexture: Nullable<BaseTexture>;
  27980. /**
  27981. * Force normal to face away from face.
  27982. */
  27983. forceNormalForward: boolean;
  27984. /**
  27985. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27986. * makes the reflect vector face the model (under horizon).
  27987. */
  27988. useHorizonOcclusion: boolean;
  27989. /**
  27990. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27991. * too much the area relying on ambient texture to define their ambient occlusion.
  27992. */
  27993. useRadianceOcclusion: boolean;
  27994. /**
  27995. * If set to true, no lighting calculations will be applied.
  27996. */
  27997. unlit: boolean;
  27998. /**
  27999. * Gets the image processing configuration used either in this material.
  28000. */
  28001. /**
  28002. * Sets the Default image processing configuration used either in the this material.
  28003. *
  28004. * If sets to null, the scene one is in use.
  28005. */
  28006. imageProcessingConfiguration: ImageProcessingConfiguration;
  28007. /**
  28008. * Gets wether the color curves effect is enabled.
  28009. */
  28010. /**
  28011. * Sets wether the color curves effect is enabled.
  28012. */
  28013. cameraColorCurvesEnabled: boolean;
  28014. /**
  28015. * Gets wether the color grading effect is enabled.
  28016. */
  28017. /**
  28018. * Gets wether the color grading effect is enabled.
  28019. */
  28020. cameraColorGradingEnabled: boolean;
  28021. /**
  28022. * Gets wether tonemapping is enabled or not.
  28023. */
  28024. /**
  28025. * Sets wether tonemapping is enabled or not
  28026. */
  28027. cameraToneMappingEnabled: boolean;
  28028. /**
  28029. * The camera exposure used on this material.
  28030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28031. * This corresponds to a photographic exposure.
  28032. */
  28033. /**
  28034. * The camera exposure used on this material.
  28035. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28036. * This corresponds to a photographic exposure.
  28037. */
  28038. cameraExposure: number;
  28039. /**
  28040. * Gets The camera contrast used on this material.
  28041. */
  28042. /**
  28043. * Sets The camera contrast used on this material.
  28044. */
  28045. cameraContrast: number;
  28046. /**
  28047. * Gets the Color Grading 2D Lookup Texture.
  28048. */
  28049. /**
  28050. * Sets the Color Grading 2D Lookup Texture.
  28051. */
  28052. cameraColorGradingTexture: Nullable<BaseTexture>;
  28053. /**
  28054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28056. * 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;
  28057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28058. */
  28059. /**
  28060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28062. * 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;
  28063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28064. */
  28065. cameraColorCurves: Nullable<ColorCurves>;
  28066. /**
  28067. * Instantiates a new PBRMaterial instance.
  28068. *
  28069. * @param name The material name
  28070. * @param scene The scene the material will be use in.
  28071. */
  28072. constructor(name: string, scene: Scene);
  28073. /**
  28074. * Returns the name of this material class.
  28075. */
  28076. getClassName(): string;
  28077. /**
  28078. * Returns an array of the actively used textures.
  28079. * @returns - Array of BaseTextures
  28080. */
  28081. getActiveTextures(): BaseTexture[];
  28082. /**
  28083. * Checks to see if a texture is used in the material.
  28084. * @param texture - Base texture to use.
  28085. * @returns - Boolean specifying if a texture is used in the material.
  28086. */
  28087. hasTexture(texture: BaseTexture): boolean;
  28088. /**
  28089. * Makes a duplicate of the current material.
  28090. * @param name - name to use for the new material.
  28091. */
  28092. clone(name: string): PBRMaterial;
  28093. /**
  28094. * Serializes this PBR Material.
  28095. * @returns - An object with the serialized material.
  28096. */
  28097. serialize(): any;
  28098. /**
  28099. * Parses a PBR Material from a serialized object.
  28100. * @param source - Serialized object.
  28101. * @param scene - BJS scene instance.
  28102. * @param rootUrl - url for the scene object
  28103. * @returns - PBRMaterial
  28104. */
  28105. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28106. }
  28107. }
  28108. declare module BABYLON {
  28109. /**
  28110. * The PBR material of BJS following the metal roughness convention.
  28111. *
  28112. * This fits to the PBR convention in the GLTF definition:
  28113. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  28114. */
  28115. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  28116. /**
  28117. * The base color has two different interpretations depending on the value of metalness.
  28118. * When the material is a metal, the base color is the specific measured reflectance value
  28119. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  28120. * of the material.
  28121. */
  28122. baseColor: Color3;
  28123. /**
  28124. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  28125. * well as opacity information in the alpha channel.
  28126. */
  28127. baseTexture: BaseTexture;
  28128. /**
  28129. * Specifies the metallic scalar value of the material.
  28130. * Can also be used to scale the metalness values of the metallic texture.
  28131. */
  28132. metallic: number;
  28133. /**
  28134. * Specifies the roughness scalar value of the material.
  28135. * Can also be used to scale the roughness values of the metallic texture.
  28136. */
  28137. roughness: number;
  28138. /**
  28139. * Texture containing both the metallic value in the B channel and the
  28140. * roughness value in the G channel to keep better precision.
  28141. */
  28142. metallicRoughnessTexture: BaseTexture;
  28143. /**
  28144. * Instantiates a new PBRMetalRoughnessMaterial instance.
  28145. *
  28146. * @param name The material name
  28147. * @param scene The scene the material will be use in.
  28148. */
  28149. constructor(name: string, scene: Scene);
  28150. /**
  28151. * Return the currrent class name of the material.
  28152. */
  28153. getClassName(): string;
  28154. /**
  28155. * Return the active textures of the material.
  28156. */
  28157. getActiveTextures(): BaseTexture[];
  28158. /**
  28159. * Checks to see if a texture is used in the material.
  28160. * @param texture - Base texture to use.
  28161. * @returns - Boolean specifying if a texture is used in the material.
  28162. */
  28163. hasTexture(texture: BaseTexture): boolean;
  28164. /**
  28165. * Makes a duplicate of the current material.
  28166. * @param name - name to use for the new material.
  28167. */
  28168. clone(name: string): PBRMetallicRoughnessMaterial;
  28169. /**
  28170. * Serialize the material to a parsable JSON object.
  28171. */
  28172. serialize(): any;
  28173. /**
  28174. * Parses a JSON object correponding to the serialize function.
  28175. */
  28176. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  28177. }
  28178. }
  28179. declare module BABYLON {
  28180. /**
  28181. * The PBR material of BJS following the specular glossiness convention.
  28182. *
  28183. * This fits to the PBR convention in the GLTF definition:
  28184. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  28185. */
  28186. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  28187. /**
  28188. * Specifies the diffuse color of the material.
  28189. */
  28190. diffuseColor: Color3;
  28191. /**
  28192. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  28193. * channel.
  28194. */
  28195. diffuseTexture: BaseTexture;
  28196. /**
  28197. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  28198. */
  28199. specularColor: Color3;
  28200. /**
  28201. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  28202. */
  28203. glossiness: number;
  28204. /**
  28205. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  28206. */
  28207. specularGlossinessTexture: BaseTexture;
  28208. /**
  28209. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  28210. *
  28211. * @param name The material name
  28212. * @param scene The scene the material will be use in.
  28213. */
  28214. constructor(name: string, scene: Scene);
  28215. /**
  28216. * Return the currrent class name of the material.
  28217. */
  28218. getClassName(): string;
  28219. /**
  28220. * Return the active textures of the material.
  28221. */
  28222. getActiveTextures(): BaseTexture[];
  28223. /**
  28224. * Checks to see if a texture is used in the material.
  28225. * @param texture - Base texture to use.
  28226. * @returns - Boolean specifying if a texture is used in the material.
  28227. */
  28228. hasTexture(texture: BaseTexture): boolean;
  28229. /**
  28230. * Makes a duplicate of the current material.
  28231. * @param name - name to use for the new material.
  28232. */
  28233. clone(name: string): PBRSpecularGlossinessMaterial;
  28234. /**
  28235. * Serialize the material to a parsable JSON object.
  28236. */
  28237. serialize(): any;
  28238. /**
  28239. * Parses a JSON object correponding to the serialize function.
  28240. */
  28241. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  28242. }
  28243. }
  28244. declare module BABYLON {
  28245. class BaseTexture {
  28246. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28247. name: string;
  28248. private _hasAlpha;
  28249. hasAlpha: boolean;
  28250. getAlphaFromRGB: boolean;
  28251. level: number;
  28252. coordinatesIndex: number;
  28253. private _coordinatesMode;
  28254. /**
  28255. * How a texture is mapped.
  28256. *
  28257. * | Value | Type | Description |
  28258. * | ----- | ----------------------------------- | ----------- |
  28259. * | 0 | EXPLICIT_MODE | |
  28260. * | 1 | SPHERICAL_MODE | |
  28261. * | 2 | PLANAR_MODE | |
  28262. * | 3 | CUBIC_MODE | |
  28263. * | 4 | PROJECTION_MODE | |
  28264. * | 5 | SKYBOX_MODE | |
  28265. * | 6 | INVCUBIC_MODE | |
  28266. * | 7 | EQUIRECTANGULAR_MODE | |
  28267. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28268. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28269. */
  28270. coordinatesMode: number;
  28271. /**
  28272. * | Value | Type | Description |
  28273. * | ----- | ------------------ | ----------- |
  28274. * | 0 | CLAMP_ADDRESSMODE | |
  28275. * | 1 | WRAP_ADDRESSMODE | |
  28276. * | 2 | MIRROR_ADDRESSMODE | |
  28277. */
  28278. wrapU: number;
  28279. /**
  28280. * | Value | Type | Description |
  28281. * | ----- | ------------------ | ----------- |
  28282. * | 0 | CLAMP_ADDRESSMODE | |
  28283. * | 1 | WRAP_ADDRESSMODE | |
  28284. * | 2 | MIRROR_ADDRESSMODE | |
  28285. */
  28286. wrapV: number;
  28287. /**
  28288. * | Value | Type | Description |
  28289. * | ----- | ------------------ | ----------- |
  28290. * | 0 | CLAMP_ADDRESSMODE | |
  28291. * | 1 | WRAP_ADDRESSMODE | |
  28292. * | 2 | MIRROR_ADDRESSMODE | |
  28293. */
  28294. wrapR: number;
  28295. anisotropicFilteringLevel: number;
  28296. isCube: boolean;
  28297. is3D: boolean;
  28298. gammaSpace: boolean;
  28299. invertZ: boolean;
  28300. lodLevelInAlpha: boolean;
  28301. lodGenerationOffset: number;
  28302. lodGenerationScale: number;
  28303. isRenderTarget: boolean;
  28304. readonly uid: string;
  28305. toString(): string;
  28306. getClassName(): string;
  28307. animations: Animation[];
  28308. /**
  28309. * An event triggered when the texture is disposed.
  28310. */
  28311. onDisposeObservable: Observable<BaseTexture>;
  28312. private _onDisposeObserver;
  28313. onDispose: () => void;
  28314. delayLoadState: number;
  28315. private _scene;
  28316. _texture: Nullable<InternalTexture>;
  28317. private _uid;
  28318. readonly isBlocking: boolean;
  28319. constructor(scene: Nullable<Scene>);
  28320. getScene(): Nullable<Scene>;
  28321. getTextureMatrix(): Matrix;
  28322. getReflectionTextureMatrix(): Matrix;
  28323. getInternalTexture(): Nullable<InternalTexture>;
  28324. isReadyOrNotBlocking(): boolean;
  28325. isReady(): boolean;
  28326. getSize(): ISize;
  28327. getBaseSize(): ISize;
  28328. scale(ratio: number): void;
  28329. readonly canRescale: boolean;
  28330. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  28331. _rebuild(): void;
  28332. delayLoad(): void;
  28333. clone(): Nullable<BaseTexture>;
  28334. readonly textureType: number;
  28335. readonly textureFormat: number;
  28336. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  28337. releaseInternalTexture(): void;
  28338. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28339. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28340. readonly _lodTextureMid: Nullable<BaseTexture>;
  28341. readonly _lodTextureLow: Nullable<BaseTexture>;
  28342. dispose(): void;
  28343. serialize(): any;
  28344. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28345. }
  28346. }
  28347. declare module BABYLON {
  28348. /**
  28349. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  28350. * It can help converting any input color in a desired output one. This can then be used to create effects
  28351. * from sepia, black and white to sixties or futuristic rendering...
  28352. *
  28353. * The only supported format is currently 3dl.
  28354. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  28355. */
  28356. class ColorGradingTexture extends BaseTexture {
  28357. /**
  28358. * The current texture matrix. (will always be identity in color grading texture)
  28359. */
  28360. private _textureMatrix;
  28361. /**
  28362. * The texture URL.
  28363. */
  28364. url: string;
  28365. /**
  28366. * Empty line regex stored for GC.
  28367. */
  28368. private static _noneEmptyLineRegex;
  28369. private _engine;
  28370. /**
  28371. * Instantiates a ColorGradingTexture from the following parameters.
  28372. *
  28373. * @param url The location of the color gradind data (currently only supporting 3dl)
  28374. * @param scene The scene the texture will be used in
  28375. */
  28376. constructor(url: string, scene: Scene);
  28377. /**
  28378. * Returns the texture matrix used in most of the material.
  28379. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  28380. */
  28381. getTextureMatrix(): Matrix;
  28382. /**
  28383. * Occurs when the file being loaded is a .3dl LUT file.
  28384. */
  28385. private load3dlTexture();
  28386. /**
  28387. * Starts the loading process of the texture.
  28388. */
  28389. private loadTexture();
  28390. /**
  28391. * Clones the color gradind texture.
  28392. */
  28393. clone(): ColorGradingTexture;
  28394. /**
  28395. * Called during delayed load for textures.
  28396. */
  28397. delayLoad(): void;
  28398. /**
  28399. * Parses a color grading texture serialized by Babylon.
  28400. * @param parsedTexture The texture information being parsedTexture
  28401. * @param scene The scene to load the texture in
  28402. * @param rootUrl The root url of the data assets to load
  28403. * @return A color gradind texture
  28404. */
  28405. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  28406. /**
  28407. * Serializes the LUT texture to json format.
  28408. */
  28409. serialize(): any;
  28410. }
  28411. }
  28412. declare module BABYLON {
  28413. class CubeTexture extends BaseTexture {
  28414. url: string;
  28415. coordinatesMode: number;
  28416. /**
  28417. * Gets or sets the center of the bounding box associated with the cube texture
  28418. * It must define where the camera used to render the texture was set
  28419. */
  28420. boundingBoxPosition: Vector3;
  28421. private _boundingBoxSize;
  28422. /**
  28423. * Gets or sets the size of the bounding box associated with the cube texture
  28424. * When defined, the cubemap will switch to local mode
  28425. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28426. * @example https://www.babylonjs-playground.com/#RNASML
  28427. */
  28428. boundingBoxSize: Vector3;
  28429. private _noMipmap;
  28430. private _files;
  28431. private _extensions;
  28432. private _textureMatrix;
  28433. private _format;
  28434. private _prefiltered;
  28435. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  28436. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  28437. 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);
  28438. delayLoad(): void;
  28439. getReflectionTextureMatrix(): Matrix;
  28440. setReflectionTextureMatrix(value: Matrix): void;
  28441. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  28442. clone(): CubeTexture;
  28443. }
  28444. }
  28445. declare module BABYLON {
  28446. /**
  28447. * A class extending {BABYLON.Texture} allowing drawing on a texture
  28448. * @see http://doc.babylonjs.com/how_to/dynamictexture
  28449. */
  28450. class DynamicTexture extends Texture {
  28451. private _generateMipMaps;
  28452. private _canvas;
  28453. private _context;
  28454. private _engine;
  28455. /**
  28456. * Creates a {BABYLON.DynamicTexture}
  28457. * @param name defines the name of the texture
  28458. * @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
  28459. * @param scene defines the scene where you want the texture
  28460. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  28461. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28462. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  28463. */
  28464. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  28465. /**
  28466. * Gets the current state of canRescale
  28467. */
  28468. readonly canRescale: boolean;
  28469. private _recreate(textureSize);
  28470. /**
  28471. * Scales the texture
  28472. * @param ratio the scale factor to apply to both width and height
  28473. */
  28474. scale(ratio: number): void;
  28475. /**
  28476. * Resizes the texture
  28477. * @param width the new width
  28478. * @param height the new height
  28479. */
  28480. scaleTo(width: number, height: number): void;
  28481. /**
  28482. * Gets the context of the canvas used by the texture
  28483. * @returns the canvas context of the dynamic texture
  28484. */
  28485. getContext(): CanvasRenderingContext2D;
  28486. /**
  28487. * Clears the texture
  28488. */
  28489. clear(): void;
  28490. /**
  28491. * Updates the texture
  28492. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  28493. */
  28494. update(invertY?: boolean): void;
  28495. /**
  28496. * Draws text onto the texture
  28497. * @param text defines the text to be drawn
  28498. * @param x defines the placement of the text from the left
  28499. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  28500. * @param font defines the font to be used with font-style, font-size, font-name
  28501. * @param color defines the color used for the text
  28502. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  28503. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  28504. * @param update defines whether texture is immediately update (default is true)
  28505. */
  28506. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  28507. /**
  28508. * Clones the texture
  28509. * @returns the clone of the texture.
  28510. */
  28511. clone(): DynamicTexture;
  28512. /** @ignore */
  28513. _rebuild(): void;
  28514. }
  28515. }
  28516. declare module BABYLON {
  28517. /**
  28518. * This represents a texture coming from an HDR input.
  28519. *
  28520. * The only supported format is currently panorama picture stored in RGBE format.
  28521. * Example of such files can be found on HDRLib: http://hdrlib.com/
  28522. */
  28523. class HDRCubeTexture extends BaseTexture {
  28524. private static _facesMapping;
  28525. private _useInGammaSpace;
  28526. private _generateHarmonics;
  28527. private _noMipmap;
  28528. private _textureMatrix;
  28529. private _size;
  28530. private _usePMREMGenerator;
  28531. private _isBABYLONPreprocessed;
  28532. private _onLoad;
  28533. private _onError;
  28534. /**
  28535. * The texture URL.
  28536. */
  28537. url: string;
  28538. /**
  28539. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  28540. */
  28541. coordinatesMode: number;
  28542. /**
  28543. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  28544. * This is usefull at run time to apply the good shader.
  28545. */
  28546. isPMREM: boolean;
  28547. protected _isBlocking: boolean;
  28548. /**
  28549. * Gets wether or not the texture is blocking during loading.
  28550. */
  28551. /**
  28552. * Sets wether or not the texture is blocking during loading.
  28553. */
  28554. isBlocking: boolean;
  28555. /**
  28556. * Gets or sets the center of the bounding box associated with the cube texture
  28557. * It must define where the camera used to render the texture was set
  28558. */
  28559. boundingBoxPosition: Vector3;
  28560. private _boundingBoxSize;
  28561. /**
  28562. * Gets or sets the size of the bounding box associated with the cube texture
  28563. * When defined, the cubemap will switch to local mode
  28564. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28565. * @example https://www.babylonjs-playground.com/#RNASML
  28566. */
  28567. boundingBoxSize: Vector3;
  28568. /**
  28569. * Instantiates an HDRTexture from the following parameters.
  28570. *
  28571. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  28572. * @param scene The scene the texture will be used in
  28573. * @param size The cubemap 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.
  28574. * @param noMipmap Forces to not generate the mipmap if true
  28575. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  28576. * @param useInGammaSpace 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)
  28577. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  28578. */
  28579. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  28580. /**
  28581. * Occurs when the file is a preprocessed .babylon.hdr file.
  28582. */
  28583. private loadBabylonTexture();
  28584. /**
  28585. * Occurs when the file is raw .hdr file.
  28586. */
  28587. private loadHDRTexture();
  28588. /**
  28589. * Starts the loading process of the texture.
  28590. */
  28591. private loadTexture();
  28592. clone(): HDRCubeTexture;
  28593. delayLoad(): void;
  28594. getReflectionTextureMatrix(): Matrix;
  28595. setReflectionTextureMatrix(value: Matrix): void;
  28596. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  28597. serialize(): any;
  28598. /**
  28599. * Saves as a file the data contained in the texture in a binary format.
  28600. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  28601. * as the spherical used in the lighting.
  28602. * @param url The HDR file url.
  28603. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  28604. * @param onError Method called if any error happens during download.
  28605. * @return The packed binary data.
  28606. */
  28607. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  28608. /**
  28609. * Serializes the data contained in the texture in a binary format.
  28610. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  28611. * as the spherical used in the lighting.
  28612. * @param url The HDR file url.
  28613. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  28614. * @param onError Method called if any error happens during download.
  28615. * @return The packed binary data.
  28616. */
  28617. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  28618. }
  28619. }
  28620. declare module BABYLON {
  28621. /**
  28622. * Class used to store data associated with WebGL texture data for the engine
  28623. * This class should not be used directly
  28624. */
  28625. class InternalTexture implements IInternalTextureTracker {
  28626. /**
  28627. * The source of the texture data is unknown
  28628. */
  28629. static DATASOURCE_UNKNOWN: number;
  28630. /**
  28631. * Texture data comes from an URL
  28632. */
  28633. static DATASOURCE_URL: number;
  28634. /**
  28635. * Texture data is only used for temporary storage
  28636. */
  28637. static DATASOURCE_TEMP: number;
  28638. /**
  28639. * Texture data comes from raw data (ArrayBuffer)
  28640. */
  28641. static DATASOURCE_RAW: number;
  28642. /**
  28643. * Texture content is dynamic (video or dynamic texture)
  28644. */
  28645. static DATASOURCE_DYNAMIC: number;
  28646. /**
  28647. * Texture content is generated by rendering to it
  28648. */
  28649. static DATASOURCE_RENDERTARGET: number;
  28650. /**
  28651. * Texture content is part of a multi render target process
  28652. */
  28653. static DATASOURCE_MULTIRENDERTARGET: number;
  28654. /**
  28655. * Texture data comes from a cube data file
  28656. */
  28657. static DATASOURCE_CUBE: number;
  28658. /**
  28659. * Texture data comes from a raw cube data
  28660. */
  28661. static DATASOURCE_CUBERAW: number;
  28662. /**
  28663. * Texture data come from a prefiltered cube data file
  28664. */
  28665. static DATASOURCE_CUBEPREFILTERED: number;
  28666. /**
  28667. * Texture content is raw 3D data
  28668. */
  28669. static DATASOURCE_RAW3D: number;
  28670. /**
  28671. * Texture content is a depth texture
  28672. */
  28673. static DATASOURCE_DEPTHTEXTURE: number;
  28674. /**
  28675. * Defines if the texture is ready
  28676. */
  28677. isReady: boolean;
  28678. /**
  28679. * Defines if the texture is a cube texture
  28680. */
  28681. isCube: boolean;
  28682. /**
  28683. * Defines if the texture contains 3D data
  28684. */
  28685. is3D: boolean;
  28686. /**
  28687. * Gets the URL used to load this texture
  28688. */
  28689. url: string;
  28690. /**
  28691. * Gets the sampling mode of the texture
  28692. */
  28693. samplingMode: number;
  28694. /**
  28695. * Gets a boolean indicating if the texture needs mipmaps generation
  28696. */
  28697. generateMipMaps: boolean;
  28698. /**
  28699. * Gets the number of samples used by the texture (WebGL2+ only)
  28700. */
  28701. samples: number;
  28702. /**
  28703. * Gets the type of the texture
  28704. */
  28705. type: number;
  28706. /**
  28707. * Gets the format of the texture
  28708. */
  28709. format: number;
  28710. /**
  28711. * Observable called when the texture is loaded
  28712. */
  28713. onLoadedObservable: Observable<InternalTexture>;
  28714. /**
  28715. * Gets the width of the texture
  28716. */
  28717. width: number;
  28718. /**
  28719. * Gets the height of the texture
  28720. */
  28721. height: number;
  28722. /**
  28723. * Gets the depth of the texture
  28724. */
  28725. depth: number;
  28726. /**
  28727. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28728. */
  28729. baseWidth: number;
  28730. /**
  28731. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28732. */
  28733. baseHeight: number;
  28734. /**
  28735. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28736. */
  28737. baseDepth: number;
  28738. /**
  28739. * Gets a boolean indicating if the texture is inverted on Y axis
  28740. */
  28741. invertY: boolean;
  28742. /**
  28743. * Gets or set the previous tracker in the list
  28744. */
  28745. previous: Nullable<IInternalTextureTracker>;
  28746. /**
  28747. * Gets or set the next tracker in the list
  28748. */
  28749. next: Nullable<IInternalTextureTracker>;
  28750. /** @ignore */
  28751. _initialSlot: number;
  28752. /** @ignore */
  28753. _designatedSlot: number;
  28754. /** @ignore */
  28755. _dataSource: number;
  28756. /** @ignore */
  28757. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  28758. /** @ignore */
  28759. _bufferView: Nullable<ArrayBufferView>;
  28760. /** @ignore */
  28761. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28762. /** @ignore */
  28763. _size: number;
  28764. /** @ignore */
  28765. _extension: string;
  28766. /** @ignore */
  28767. _files: Nullable<string[]>;
  28768. /** @ignore */
  28769. _workingCanvas: HTMLCanvasElement;
  28770. /** @ignore */
  28771. _workingContext: CanvasRenderingContext2D;
  28772. /** @ignore */
  28773. _framebuffer: Nullable<WebGLFramebuffer>;
  28774. /** @ignore */
  28775. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28776. /** @ignore */
  28777. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28778. /** @ignore */
  28779. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28780. /** @ignore */
  28781. _attachments: Nullable<number[]>;
  28782. /** @ignore */
  28783. _cachedCoordinatesMode: Nullable<number>;
  28784. /** @ignore */
  28785. _cachedWrapU: Nullable<number>;
  28786. /** @ignore */
  28787. _cachedWrapV: Nullable<number>;
  28788. /** @ignore */
  28789. _cachedWrapR: Nullable<number>;
  28790. /** @ignore */
  28791. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28792. /** @ignore */
  28793. _isDisabled: boolean;
  28794. /** @ignore */
  28795. _compression: Nullable<string>;
  28796. /** @ignore */
  28797. _generateStencilBuffer: boolean;
  28798. /** @ignore */
  28799. _generateDepthBuffer: boolean;
  28800. /** @ignore */
  28801. _comparisonFunction: number;
  28802. /** @ignore */
  28803. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28804. /** @ignore */
  28805. _lodGenerationScale: number;
  28806. /** @ignore */
  28807. _lodGenerationOffset: number;
  28808. /** @ignore */
  28809. _lodTextureHigh: BaseTexture;
  28810. /** @ignore */
  28811. _lodTextureMid: BaseTexture;
  28812. /** @ignore */
  28813. _lodTextureLow: BaseTexture;
  28814. /** @ignore */
  28815. _webGLTexture: Nullable<WebGLTexture>;
  28816. /** @ignore */
  28817. _references: number;
  28818. private _engine;
  28819. /**
  28820. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  28821. */
  28822. readonly dataSource: number;
  28823. /**
  28824. * Creates a new InternalTexture
  28825. * @param engine defines the engine to use
  28826. * @param dataSource defines the type of data that will be used
  28827. */
  28828. constructor(engine: Engine, dataSource: number);
  28829. /**
  28830. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  28831. */
  28832. incrementReferences(): void;
  28833. /**
  28834. * Change the size of the texture (not the size of the content)
  28835. * @param width defines the new width
  28836. * @param height defines the new height
  28837. * @param depth defines the new depth (1 by default)
  28838. */
  28839. updateSize(width: int, height: int, depth?: int): void;
  28840. /** @ignore */
  28841. _rebuild(): void;
  28842. private _swapAndDie(target);
  28843. /**
  28844. * Dispose the current allocated resources
  28845. */
  28846. dispose(): void;
  28847. }
  28848. }
  28849. declare module BABYLON {
  28850. /**
  28851. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  28852. */
  28853. interface IInternalTextureTracker {
  28854. /**
  28855. * Gets or set the previous tracker in the list
  28856. */
  28857. previous: Nullable<IInternalTextureTracker>;
  28858. /**
  28859. * Gets or set the next tracker in the list
  28860. */
  28861. next: Nullable<IInternalTextureTracker>;
  28862. }
  28863. /**
  28864. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  28865. */
  28866. class DummyInternalTextureTracker {
  28867. /**
  28868. * Gets or set the previous tracker in the list
  28869. */
  28870. previous: Nullable<IInternalTextureTracker>;
  28871. /**
  28872. * Gets or set the next tracker in the list
  28873. */
  28874. next: Nullable<IInternalTextureTracker>;
  28875. }
  28876. }
  28877. declare module BABYLON {
  28878. class MirrorTexture extends RenderTargetTexture {
  28879. mirrorPlane: Plane;
  28880. private _transformMatrix;
  28881. private _mirrorMatrix;
  28882. private _savedViewMatrix;
  28883. private _blurX;
  28884. private _blurY;
  28885. private _adaptiveBlurKernel;
  28886. private _blurKernelX;
  28887. private _blurKernelY;
  28888. private _blurRatio;
  28889. blurRatio: number;
  28890. adaptiveBlurKernel: number;
  28891. blurKernel: number;
  28892. blurKernelX: number;
  28893. blurKernelY: number;
  28894. private _autoComputeBlurKernel();
  28895. protected _onRatioRescale(): void;
  28896. constructor(name: string, size: number | {
  28897. width: number;
  28898. height: number;
  28899. } | {
  28900. ratio: number;
  28901. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28902. private _preparePostProcesses();
  28903. clone(): MirrorTexture;
  28904. serialize(): any;
  28905. }
  28906. }
  28907. declare module BABYLON {
  28908. interface IMultiRenderTargetOptions {
  28909. generateMipMaps?: boolean;
  28910. types?: number[];
  28911. samplingModes?: number[];
  28912. generateDepthBuffer?: boolean;
  28913. generateStencilBuffer?: boolean;
  28914. generateDepthTexture?: boolean;
  28915. textureCount?: number;
  28916. doNotChangeAspectRatio?: boolean;
  28917. defaultType?: number;
  28918. }
  28919. class MultiRenderTarget extends RenderTargetTexture {
  28920. private _internalTextures;
  28921. private _textures;
  28922. readonly isSupported: boolean;
  28923. private _multiRenderTargetOptions;
  28924. readonly textures: Texture[];
  28925. readonly depthTexture: Texture;
  28926. wrapU: number;
  28927. wrapV: number;
  28928. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  28929. _rebuild(): void;
  28930. private _createInternalTextures();
  28931. private _createTextures();
  28932. samples: number;
  28933. resize(size: any): void;
  28934. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28935. dispose(): void;
  28936. releaseInternalTextures(): void;
  28937. }
  28938. }
  28939. declare module BABYLON {
  28940. class RawTexture extends Texture {
  28941. format: number;
  28942. private _engine;
  28943. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  28944. update(data: ArrayBufferView): void;
  28945. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  28946. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  28947. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  28948. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  28949. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  28950. }
  28951. }
  28952. declare module BABYLON {
  28953. /**
  28954. * Creates a refraction texture used by refraction channel of the standard material.
  28955. * @param name the texture name
  28956. * @param size size of the underlying texture
  28957. * @param scene root scene
  28958. */
  28959. class RefractionTexture extends RenderTargetTexture {
  28960. refractionPlane: Plane;
  28961. depth: number;
  28962. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  28963. clone(): RefractionTexture;
  28964. serialize(): any;
  28965. }
  28966. }
  28967. declare module BABYLON {
  28968. class RenderTargetTexture extends Texture {
  28969. isCube: boolean;
  28970. static _REFRESHRATE_RENDER_ONCE: number;
  28971. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28972. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28973. static readonly REFRESHRATE_RENDER_ONCE: number;
  28974. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28975. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28976. /**
  28977. * Use this predicate to dynamically define the list of mesh you want to render.
  28978. * If set, the renderList property will be overwritten.
  28979. */
  28980. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28981. /**
  28982. * Use this list to define the list of mesh you want to render.
  28983. */
  28984. renderList: Nullable<Array<AbstractMesh>>;
  28985. renderParticles: boolean;
  28986. renderSprites: boolean;
  28987. coordinatesMode: number;
  28988. activeCamera: Nullable<Camera>;
  28989. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28990. useCameraPostProcesses: boolean;
  28991. ignoreCameraViewport: boolean;
  28992. private _postProcessManager;
  28993. private _postProcesses;
  28994. private _resizeObserver;
  28995. /**
  28996. * An event triggered when the texture is unbind.
  28997. */
  28998. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28999. /**
  29000. * An event triggered when the texture is unbind.
  29001. */
  29002. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29003. private _onAfterUnbindObserver;
  29004. onAfterUnbind: () => void;
  29005. /**
  29006. * An event triggered before rendering the texture
  29007. */
  29008. onBeforeRenderObservable: Observable<number>;
  29009. private _onBeforeRenderObserver;
  29010. onBeforeRender: (faceIndex: number) => void;
  29011. /**
  29012. * An event triggered after rendering the texture
  29013. */
  29014. onAfterRenderObservable: Observable<number>;
  29015. private _onAfterRenderObserver;
  29016. onAfterRender: (faceIndex: number) => void;
  29017. /**
  29018. * An event triggered after the texture clear
  29019. */
  29020. onClearObservable: Observable<Engine>;
  29021. private _onClearObserver;
  29022. onClear: (Engine: Engine) => void;
  29023. clearColor: Color4;
  29024. protected _size: number | {
  29025. width: number;
  29026. height: number;
  29027. };
  29028. protected _initialSizeParameter: number | {
  29029. width: number;
  29030. height: number;
  29031. } | {
  29032. ratio: number;
  29033. };
  29034. protected _sizeRatio: Nullable<number>;
  29035. _generateMipMaps: boolean;
  29036. protected _renderingManager: RenderingManager;
  29037. _waitingRenderList: string[];
  29038. protected _doNotChangeAspectRatio: boolean;
  29039. protected _currentRefreshId: number;
  29040. protected _refreshRate: number;
  29041. protected _textureMatrix: Matrix;
  29042. protected _samples: number;
  29043. protected _renderTargetOptions: RenderTargetCreationOptions;
  29044. readonly renderTargetOptions: RenderTargetCreationOptions;
  29045. protected _engine: Engine;
  29046. protected _onRatioRescale(): void;
  29047. /**
  29048. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29049. * It must define where the camera used to render the texture is set
  29050. */
  29051. boundingBoxPosition: Vector3;
  29052. private _boundingBoxSize;
  29053. /**
  29054. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29055. * When defined, the cubemap will switch to local mode
  29056. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29057. * @example https://www.babylonjs-playground.com/#RNASML
  29058. */
  29059. boundingBoxSize: Vector3;
  29060. /**
  29061. * In case the RTT has been created with a depth texture, get the associated
  29062. * depth texture.
  29063. * Otherwise, return null.
  29064. */
  29065. depthStencilTexture: Nullable<InternalTexture>;
  29066. /**
  29067. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  29068. * or used a shadow, depth texture...
  29069. * @param name The friendly name of the texture
  29070. * @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)
  29071. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29072. * @param generateMipMaps True if mip maps need to be generated after render.
  29073. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29074. * @param type The type of the buffer in the RTT (int, half float, float...)
  29075. * @param isCube True if a cube texture needs to be created
  29076. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29077. * @param generateDepthBuffer True to generate a depth buffer
  29078. * @param generateStencilBuffer True to generate a stencil buffer
  29079. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29080. */
  29081. constructor(name: string, size: number | {
  29082. width: number;
  29083. height: number;
  29084. } | {
  29085. ratio: number;
  29086. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  29087. /**
  29088. * Creates a depth stencil texture.
  29089. * This is only available in WebGL 2 or with the depth texture extension available.
  29090. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29091. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29092. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29093. */
  29094. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29095. private _processSizeParameter(size);
  29096. samples: number;
  29097. resetRefreshCounter(): void;
  29098. refreshRate: number;
  29099. addPostProcess(postProcess: PostProcess): void;
  29100. clearPostProcesses(dispose?: boolean): void;
  29101. removePostProcess(postProcess: PostProcess): void;
  29102. _shouldRender(): boolean;
  29103. getRenderSize(): number;
  29104. getRenderWidth(): number;
  29105. getRenderHeight(): number;
  29106. readonly canRescale: boolean;
  29107. scale(ratio: number): void;
  29108. getReflectionTextureMatrix(): Matrix;
  29109. resize(size: number | {
  29110. width: number;
  29111. height: number;
  29112. } | {
  29113. ratio: number;
  29114. }): void;
  29115. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29116. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  29117. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29118. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  29119. /**
  29120. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29121. * This allowed control for front to back rendering or reversly depending of the special needs.
  29122. *
  29123. * @param renderingGroupId The rendering group id corresponding to its index
  29124. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29125. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29126. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29127. */
  29128. 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;
  29129. /**
  29130. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29131. *
  29132. * @param renderingGroupId The rendering group id corresponding to its index
  29133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29134. */
  29135. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29136. clone(): RenderTargetTexture;
  29137. serialize(): any;
  29138. disposeFramebufferObjects(): void;
  29139. dispose(): void;
  29140. _rebuild(): void;
  29141. /**
  29142. * Clear the info related to rendering groups preventing retention point in material dispose.
  29143. */
  29144. freeRenderingGroups(): void;
  29145. }
  29146. }
  29147. declare module BABYLON {
  29148. class Texture extends BaseTexture {
  29149. static NEAREST_SAMPLINGMODE: number;
  29150. static NEAREST_NEAREST_MIPLINEAR: number;
  29151. static BILINEAR_SAMPLINGMODE: number;
  29152. static LINEAR_LINEAR_MIPNEAREST: number;
  29153. static TRILINEAR_SAMPLINGMODE: number;
  29154. static LINEAR_LINEAR_MIPLINEAR: number;
  29155. static NEAREST_NEAREST_MIPNEAREST: number;
  29156. static NEAREST_LINEAR_MIPNEAREST: number;
  29157. static NEAREST_LINEAR_MIPLINEAR: number;
  29158. static NEAREST_LINEAR: number;
  29159. static NEAREST_NEAREST: number;
  29160. static LINEAR_NEAREST_MIPNEAREST: number;
  29161. static LINEAR_NEAREST_MIPLINEAR: number;
  29162. static LINEAR_LINEAR: number;
  29163. static LINEAR_NEAREST: number;
  29164. static EXPLICIT_MODE: number;
  29165. static SPHERICAL_MODE: number;
  29166. static PLANAR_MODE: number;
  29167. static CUBIC_MODE: number;
  29168. static PROJECTION_MODE: number;
  29169. static SKYBOX_MODE: number;
  29170. static INVCUBIC_MODE: number;
  29171. static EQUIRECTANGULAR_MODE: number;
  29172. static FIXED_EQUIRECTANGULAR_MODE: number;
  29173. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29174. static CLAMP_ADDRESSMODE: number;
  29175. static WRAP_ADDRESSMODE: number;
  29176. static MIRROR_ADDRESSMODE: number;
  29177. /**
  29178. * 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
  29179. */
  29180. static UseSerializedUrlIfAny: boolean;
  29181. url: Nullable<string>;
  29182. uOffset: number;
  29183. vOffset: number;
  29184. uScale: number;
  29185. vScale: number;
  29186. uAng: number;
  29187. vAng: number;
  29188. wAng: number;
  29189. readonly noMipmap: boolean;
  29190. private _noMipmap;
  29191. _invertY: boolean;
  29192. private _rowGenerationMatrix;
  29193. private _cachedTextureMatrix;
  29194. private _projectionModeMatrix;
  29195. private _t0;
  29196. private _t1;
  29197. private _t2;
  29198. private _cachedUOffset;
  29199. private _cachedVOffset;
  29200. private _cachedUScale;
  29201. private _cachedVScale;
  29202. private _cachedUAng;
  29203. private _cachedVAng;
  29204. private _cachedWAng;
  29205. private _cachedProjectionMatrixId;
  29206. private _cachedCoordinatesMode;
  29207. _samplingMode: number;
  29208. private _buffer;
  29209. private _deleteBuffer;
  29210. protected _format: Nullable<number>;
  29211. private _delayedOnLoad;
  29212. private _delayedOnError;
  29213. protected _onLoadObservable: Nullable<Observable<Texture>>;
  29214. protected _isBlocking: boolean;
  29215. isBlocking: boolean;
  29216. readonly samplingMode: number;
  29217. 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);
  29218. updateURL(url: string): void;
  29219. delayLoad(): void;
  29220. updateSamplingMode(samplingMode: number): void;
  29221. private _prepareRowForTextureGeneration(x, y, z, t);
  29222. getTextureMatrix(): Matrix;
  29223. getReflectionTextureMatrix(): Matrix;
  29224. clone(): Texture;
  29225. readonly onLoadObservable: Observable<Texture>;
  29226. serialize(): any;
  29227. getClassName(): string;
  29228. dispose(): void;
  29229. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29230. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29231. 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;
  29232. }
  29233. }
  29234. declare module BABYLON {
  29235. /**
  29236. * Settings for finer control over video usage
  29237. */
  29238. interface VideoTextureSettings {
  29239. /**
  29240. * Applies `autoplay` to video, if specified
  29241. */
  29242. autoPlay?: boolean;
  29243. /**
  29244. * Applies `loop` to video, if specified
  29245. */
  29246. loop?: boolean;
  29247. /**
  29248. * Automatically updates internal texture from video at every frame in the render loop
  29249. */
  29250. autoUpdateTexture: boolean;
  29251. }
  29252. class VideoTexture extends Texture {
  29253. /**
  29254. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29255. */
  29256. readonly autoUpdateTexture: boolean;
  29257. /**
  29258. * The video instance used by the texture internally
  29259. */
  29260. readonly video: HTMLVideoElement;
  29261. private _generateMipMaps;
  29262. private _engine;
  29263. /**
  29264. * Creates a video texture.
  29265. * Sample : https://doc.babylonjs.com/how_to/video_texture
  29266. * @param {string | null} name optional name, will detect from video source, if not defined
  29267. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  29268. * @param {BABYLON.Scene} scene is obviously the current scene.
  29269. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29270. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  29271. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29272. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  29273. */
  29274. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29275. private _getName(src);
  29276. private _getVideo(src);
  29277. private _createInternalTexture;
  29278. private reset;
  29279. /**
  29280. * Internal method to initiate `update`.
  29281. */
  29282. _rebuild(): void;
  29283. /**
  29284. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29285. */
  29286. update(): void;
  29287. /**
  29288. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29289. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29290. */
  29291. updateTexture(isVisible: boolean): void;
  29292. protected _updateInternalTexture: (e?: Event | undefined) => void;
  29293. /**
  29294. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29295. * @param url New url.
  29296. */
  29297. updateURL(url: string): void;
  29298. dispose(): void;
  29299. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29300. minWidth: number;
  29301. maxWidth: number;
  29302. minHeight: number;
  29303. maxHeight: number;
  29304. deviceId: string;
  29305. }): void;
  29306. }
  29307. }
  29308. declare var DracoDecoderModule: any;
  29309. declare module BABYLON {
  29310. /**
  29311. * Draco compression (https://google.github.io/draco/)
  29312. */
  29313. class DracoCompression implements IDisposable {
  29314. private _workerPool;
  29315. /**
  29316. * Gets the url to the draco decoder if available.
  29317. */
  29318. static DecoderUrl: Nullable<string>;
  29319. /**
  29320. * Constructor
  29321. * @param numWorkers The number of workers for async operations
  29322. */
  29323. constructor(numWorkers?: number);
  29324. /**
  29325. * Stop all async operations and release resources.
  29326. */
  29327. dispose(): void;
  29328. /**
  29329. * Decode Draco compressed mesh data to vertex data.
  29330. * @param data The array buffer view for the Draco compression data
  29331. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  29332. * @returns A promise that resolves with the decoded vertex data
  29333. */
  29334. decodeMeshAsync(data: ArrayBufferView, attributes: {
  29335. [kind: string]: number;
  29336. }): Promise<VertexData>;
  29337. /**
  29338. * The worker function that gets converted to a blob url to pass into a worker.
  29339. */
  29340. private static _Worker();
  29341. private static _GetDefaultDecoderUrl();
  29342. }
  29343. }
  29344. declare module BABYLON {
  29345. /**
  29346. * Particle emitter emitting particles from the inside of a box.
  29347. * It emits the particles randomly between 2 given directions.
  29348. */
  29349. class BoxParticleEmitter implements IParticleEmitterType {
  29350. /**
  29351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29352. */
  29353. direction1: Vector3;
  29354. /**
  29355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29356. */
  29357. direction2: Vector3;
  29358. /**
  29359. * 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.
  29360. */
  29361. minEmitBox: Vector3;
  29362. /**
  29363. * 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.
  29364. */
  29365. maxEmitBox: Vector3;
  29366. /**
  29367. * Creates a new instance BoxParticleEmitter
  29368. */
  29369. constructor();
  29370. /**
  29371. * Called by the particle System when the direction is computed for the created particle.
  29372. * @param emitPower is the power of the particle (speed)
  29373. * @param worldMatrix is the world matrix of the particle system
  29374. * @param directionToUpdate is the direction vector to update with the result
  29375. * @param particle is the particle we are computed the direction for
  29376. */
  29377. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  29378. /**
  29379. * Called by the particle System when the position is computed for the created particle.
  29380. * @param worldMatrix is the world matrix of the particle system
  29381. * @param positionToUpdate is the position vector to update with the result
  29382. * @param particle is the particle we are computed the position for
  29383. */
  29384. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  29385. /**
  29386. * Clones the current emitter and returns a copy of it
  29387. * @returns the new emitter
  29388. */
  29389. clone(): BoxParticleEmitter;
  29390. /**
  29391. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  29392. * @param effect defines the update shader
  29393. */
  29394. applyToShader(effect: Effect): void;
  29395. /**
  29396. * Returns a string to use to update the GPU particles update shader
  29397. * @returns a string containng the defines string
  29398. */
  29399. getEffectDefines(): string;
  29400. /**
  29401. * Returns the string "BoxEmitter"
  29402. * @returns a string containing the class name
  29403. */
  29404. getClassName(): string;
  29405. /**
  29406. * Serializes the particle system to a JSON object.
  29407. * @returns the JSON object
  29408. */
  29409. serialize(): any;
  29410. /**
  29411. * Parse properties from a JSON object
  29412. * @param serializationObject defines the JSON object
  29413. */
  29414. parse(serializationObject: any): void;
  29415. }
  29416. }
  29417. declare module BABYLON {
  29418. /**
  29419. * Particle emitter emitting particles from the inside of a cone.
  29420. * It emits the particles alongside the cone volume from the base to the particle.
  29421. * The emission direction might be randomized.
  29422. */
  29423. class ConeParticleEmitter implements IParticleEmitterType {
  29424. /**
  29425. * The radius of the emission cone.
  29426. */
  29427. angle: number;
  29428. /**
  29429. * The cone base angle.
  29430. */
  29431. directionRandomizer: number;
  29432. private _radius;
  29433. private _height;
  29434. /**
  29435. * Gets the radius of the emission cone.
  29436. */
  29437. /**
  29438. * Sets the radius of the emission cone.
  29439. */
  29440. radius: number;
  29441. /**
  29442. * Creates a new instance ConeParticleEmitter
  29443. * @param radius the radius of the emission cone (1 by default)
  29444. * @param angles the cone base angle (PI by default)
  29445. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  29446. */
  29447. constructor(radius?: number,
  29448. /**
  29449. * The radius of the emission cone.
  29450. */
  29451. angle?: number,
  29452. /**
  29453. * The cone base angle.
  29454. */
  29455. directionRandomizer?: number);
  29456. /**
  29457. * Called by the particle System when the direction is computed for the created particle.
  29458. * @param emitPower is the power of the particle (speed)
  29459. * @param worldMatrix is the world matrix of the particle system
  29460. * @param directionToUpdate is the direction vector to update with the result
  29461. * @param particle is the particle we are computed the direction for
  29462. */
  29463. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  29464. /**
  29465. * Called by the particle System when the position is computed for the created particle.
  29466. * @param worldMatrix is the world matrix of the particle system
  29467. * @param positionToUpdate is the position vector to update with the result
  29468. * @param particle is the particle we are computed the position for
  29469. */
  29470. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  29471. /**
  29472. * Clones the current emitter and returns a copy of it
  29473. * @returns the new emitter
  29474. */
  29475. clone(): ConeParticleEmitter;
  29476. /**
  29477. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  29478. * @param effect defines the update shader
  29479. */
  29480. applyToShader(effect: Effect): void;
  29481. /**
  29482. * Returns a string to use to update the GPU particles update shader
  29483. * @returns a string containng the defines string
  29484. */
  29485. getEffectDefines(): string;
  29486. /**
  29487. * Returns the string "BoxEmitter"
  29488. * @returns a string containing the class name
  29489. */
  29490. getClassName(): string;
  29491. /**
  29492. * Serializes the particle system to a JSON object.
  29493. * @returns the JSON object
  29494. */
  29495. serialize(): any;
  29496. /**
  29497. * Parse properties from a JSON object
  29498. * @param serializationObject defines the JSON object
  29499. */
  29500. parse(serializationObject: any): void;
  29501. }
  29502. }
  29503. declare module BABYLON {
  29504. /**
  29505. * Particle emitter represents a volume emitting particles.
  29506. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  29507. */
  29508. interface IParticleEmitterType {
  29509. /**
  29510. * Called by the particle System when the direction is computed for the created particle.
  29511. * @param emitPower is the power of the particle (speed)
  29512. * @param worldMatrix is the world matrix of the particle system
  29513. * @param directionToUpdate is the direction vector to update with the result
  29514. * @param particle is the particle we are computed the direction for
  29515. */
  29516. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  29517. /**
  29518. * Called by the particle System when the position is computed for the created particle.
  29519. * @param worldMatrix is the world matrix of the particle system
  29520. * @param positionToUpdate is the position vector to update with the result
  29521. * @param particle is the particle we are computed the position for
  29522. */
  29523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  29524. /**
  29525. * Clones the current emitter and returns a copy of it
  29526. * @returns the new emitter
  29527. */
  29528. clone(): IParticleEmitterType;
  29529. /**
  29530. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  29531. * @param effect defines the update shader
  29532. */
  29533. applyToShader(effect: Effect): void;
  29534. /**
  29535. * Returns a string to use to update the GPU particles update shader
  29536. * @returns the effect defines string
  29537. */
  29538. getEffectDefines(): string;
  29539. /**
  29540. * Returns a string representing the class name
  29541. * @returns a string containing the class name
  29542. */
  29543. getClassName(): string;
  29544. /**
  29545. * Serializes the particle system to a JSON object.
  29546. * @returns the JSON object
  29547. */
  29548. serialize(): any;
  29549. /**
  29550. * Parse properties from a JSON object
  29551. * @param serializationObject defines the JSON object
  29552. */
  29553. parse(serializationObject: any): void;
  29554. }
  29555. }
  29556. declare module BABYLON {
  29557. /**
  29558. * Particle emitter emitting particles from the inside of a sphere.
  29559. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  29560. */
  29561. class SphereParticleEmitter implements IParticleEmitterType {
  29562. /**
  29563. * The radius of the emission sphere.
  29564. */
  29565. radius: number;
  29566. /**
  29567. * How much to randomize the particle direction [0-1].
  29568. */
  29569. directionRandomizer: number;
  29570. /**
  29571. * Creates a new instance SphereParticleEmitter
  29572. * @param radius the radius of the emission sphere (1 by default)
  29573. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  29574. */
  29575. constructor(
  29576. /**
  29577. * The radius of the emission sphere.
  29578. */
  29579. radius?: number,
  29580. /**
  29581. * How much to randomize the particle direction [0-1].
  29582. */
  29583. directionRandomizer?: number);
  29584. /**
  29585. * Called by the particle System when the direction is computed for the created particle.
  29586. * @param emitPower is the power of the particle (speed)
  29587. * @param worldMatrix is the world matrix of the particle system
  29588. * @param directionToUpdate is the direction vector to update with the result
  29589. * @param particle is the particle we are computed the direction for
  29590. */
  29591. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  29592. /**
  29593. * Called by the particle System when the position is computed for the created particle.
  29594. * @param worldMatrix is the world matrix of the particle system
  29595. * @param positionToUpdate is the position vector to update with the result
  29596. * @param particle is the particle we are computed the position for
  29597. */
  29598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  29599. /**
  29600. * Clones the current emitter and returns a copy of it
  29601. * @returns the new emitter
  29602. */
  29603. clone(): SphereParticleEmitter;
  29604. /**
  29605. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  29606. * @param effect defines the update shader
  29607. */
  29608. applyToShader(effect: Effect): void;
  29609. /**
  29610. * Returns a string to use to update the GPU particles update shader
  29611. * @returns a string containng the defines string
  29612. */
  29613. getEffectDefines(): string;
  29614. /**
  29615. * Returns the string "SphereParticleEmitter"
  29616. * @returns a string containing the class name
  29617. */
  29618. getClassName(): string;
  29619. /**
  29620. * Serializes the particle system to a JSON object.
  29621. * @returns the JSON object
  29622. */
  29623. serialize(): any;
  29624. /**
  29625. * Parse properties from a JSON object
  29626. * @param serializationObject defines the JSON object
  29627. */
  29628. parse(serializationObject: any): void;
  29629. }
  29630. /**
  29631. * Particle emitter emitting particles from the inside of a sphere.
  29632. * It emits the particles randomly between two vectors.
  29633. */
  29634. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  29635. /**
  29636. * The min limit of the emission direction.
  29637. */
  29638. direction1: Vector3;
  29639. /**
  29640. * The max limit of the emission direction.
  29641. */
  29642. direction2: Vector3;
  29643. /**
  29644. * Creates a new instance SphereDirectedParticleEmitter
  29645. * @param radius the radius of the emission sphere (1 by default)
  29646. * @param direction1 the min limit of the emission direction (up vector by default)
  29647. * @param direction2 the max limit of the emission direction (up vector by default)
  29648. */
  29649. constructor(radius?: number,
  29650. /**
  29651. * The min limit of the emission direction.
  29652. */
  29653. direction1?: Vector3,
  29654. /**
  29655. * The max limit of the emission direction.
  29656. */
  29657. direction2?: Vector3);
  29658. /**
  29659. * Called by the particle System when the direction is computed for the created particle.
  29660. * @param emitPower is the power of the particle (speed)
  29661. * @param worldMatrix is the world matrix of the particle system
  29662. * @param directionToUpdate is the direction vector to update with the result
  29663. * @param particle is the particle we are computed the direction for
  29664. */
  29665. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  29666. /**
  29667. * Clones the current emitter and returns a copy of it
  29668. * @returns the new emitter
  29669. */
  29670. clone(): SphereDirectedParticleEmitter;
  29671. /**
  29672. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  29673. * @param effect defines the update shader
  29674. */
  29675. applyToShader(effect: Effect): void;
  29676. /**
  29677. * Returns a string to use to update the GPU particles update shader
  29678. * @returns a string containng the defines string
  29679. */
  29680. getEffectDefines(): string;
  29681. /**
  29682. * Returns the string "SphereDirectedParticleEmitter"
  29683. * @returns a string containing the class name
  29684. */
  29685. getClassName(): string;
  29686. /**
  29687. * Serializes the particle system to a JSON object.
  29688. * @returns the JSON object
  29689. */
  29690. serialize(): any;
  29691. /**
  29692. * Parse properties from a JSON object
  29693. * @param serializationObject defines the JSON object
  29694. */
  29695. parse(serializationObject: any): void;
  29696. }
  29697. }
  29698. declare module BABYLON {
  29699. class CannonJSPlugin implements IPhysicsEnginePlugin {
  29700. private _useDeltaForWorldStep;
  29701. world: any;
  29702. name: string;
  29703. private _physicsMaterials;
  29704. private _fixedTimeStep;
  29705. BJSCANNON: any;
  29706. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  29707. setGravity(gravity: Vector3): void;
  29708. setTimeStep(timeStep: number): void;
  29709. getTimeStep(): number;
  29710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29712. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29713. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29714. private _processChildMeshes(mainImpostor);
  29715. removePhysicsBody(impostor: PhysicsImpostor): void;
  29716. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  29717. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  29718. private _addMaterial(name, friction, restitution);
  29719. private _checkWithEpsilon(value);
  29720. private _createShape(impostor);
  29721. private _createHeightmap(object, pointDepth?);
  29722. private _minus90X;
  29723. private _plus90X;
  29724. private _tmpPosition;
  29725. private _tmpDeltaPosition;
  29726. private _tmpUnityRotation;
  29727. private _updatePhysicsBodyTransformation(impostor);
  29728. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29729. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29730. isSupported(): boolean;
  29731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  29732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  29733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29736. getBodyMass(impostor: PhysicsImpostor): number;
  29737. getBodyFriction(impostor: PhysicsImpostor): number;
  29738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29739. getBodyRestitution(impostor: PhysicsImpostor): number;
  29740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29741. sleepBody(impostor: PhysicsImpostor): void;
  29742. wakeUpBody(impostor: PhysicsImpostor): void;
  29743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29744. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  29745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  29746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29747. getRadius(impostor: PhysicsImpostor): number;
  29748. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29749. dispose(): void;
  29750. private _extendNamespace();
  29751. }
  29752. }
  29753. declare module BABYLON {
  29754. class OimoJSPlugin implements IPhysicsEnginePlugin {
  29755. world: any;
  29756. name: string;
  29757. BJSOIMO: any;
  29758. constructor(iterations?: number);
  29759. setGravity(gravity: Vector3): void;
  29760. setTimeStep(timeStep: number): void;
  29761. getTimeStep(): number;
  29762. private _tmpImpostorsArray;
  29763. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29764. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29765. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29766. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29767. private _tmpPositionVector;
  29768. removePhysicsBody(impostor: PhysicsImpostor): void;
  29769. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  29770. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  29771. isSupported(): boolean;
  29772. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29773. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29774. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  29775. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  29776. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29777. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29778. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29779. getBodyMass(impostor: PhysicsImpostor): number;
  29780. getBodyFriction(impostor: PhysicsImpostor): number;
  29781. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29782. getBodyRestitution(impostor: PhysicsImpostor): number;
  29783. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29784. sleepBody(impostor: PhysicsImpostor): void;
  29785. wakeUpBody(impostor: PhysicsImpostor): void;
  29786. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29787. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  29788. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  29789. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29790. getRadius(impostor: PhysicsImpostor): number;
  29791. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29792. dispose(): void;
  29793. }
  29794. }
  29795. declare module BABYLON {
  29796. /**
  29797. * This represents a set of one or more post processes in Babylon.
  29798. * A post process can be used to apply a shader to a texture after it is rendered.
  29799. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  29800. */
  29801. class PostProcessRenderEffect {
  29802. private _postProcesses;
  29803. private _getPostProcesses;
  29804. private _singleInstance;
  29805. private _cameras;
  29806. private _indicesForCamera;
  29807. /**
  29808. * Name of the effect
  29809. */
  29810. _name: string;
  29811. /**
  29812. * Instantiates a post process render effect.
  29813. * A post process can be used to apply a shader to a texture after it is rendered.
  29814. * @param engine The engine the effect is tied to
  29815. * @param name The name of the effect
  29816. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  29817. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  29818. */
  29819. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  29820. /**
  29821. * Checks if all the post processes in the effect are supported.
  29822. */
  29823. readonly isSupported: boolean;
  29824. /**
  29825. * Updates the current state of the effect
  29826. */
  29827. _update(): void;
  29828. /**
  29829. * Attaches the effect on cameras
  29830. * @param cameras The camera to attach to.
  29831. */
  29832. _attachCameras(cameras: Camera): void;
  29833. /**
  29834. * Attaches the effect on cameras
  29835. * @param cameras The camera to attach to.
  29836. */
  29837. _attachCameras(cameras: Camera[]): void;
  29838. /**
  29839. * Detatches the effect on cameras
  29840. * @param cameras The camera to detatch from.
  29841. */
  29842. _detachCameras(cameras: Camera): void;
  29843. /**
  29844. * Detatches the effect on cameras
  29845. * @param cameras The camera to detatch from.
  29846. */
  29847. _detachCameras(cameras: Camera[]): void;
  29848. /**
  29849. * Enables the effect on given cameras
  29850. * @param cameras The camera to enable.
  29851. */
  29852. _enable(cameras: Camera): void;
  29853. /**
  29854. * Enables the effect on given cameras
  29855. * @param cameras The camera to enable.
  29856. */
  29857. _enable(cameras: Nullable<Camera[]>): void;
  29858. /**
  29859. * Disables the effect on the given cameras
  29860. * @param cameras The camera to disable.
  29861. */
  29862. _disable(cameras: Camera): void;
  29863. /**
  29864. * Disables the effect on the given cameras
  29865. * @param cameras The camera to disable.
  29866. */
  29867. _disable(cameras: Nullable<Camera[]>): void;
  29868. /**
  29869. * Gets a list of the post processes contained in the effect.
  29870. * @param camera The camera to get the post processes on.
  29871. * @returns The list of the post processes in the effect.
  29872. */
  29873. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  29874. }
  29875. }
  29876. declare module BABYLON {
  29877. class PostProcessRenderPipeline {
  29878. private engine;
  29879. private _renderEffects;
  29880. private _renderEffectsForIsolatedPass;
  29881. protected _cameras: Camera[];
  29882. _name: string;
  29883. constructor(engine: Engine, name: string);
  29884. getClassName(): string;
  29885. readonly isSupported: boolean;
  29886. addEffect(renderEffect: PostProcessRenderEffect): void;
  29887. _rebuild(): void;
  29888. _enableEffect(renderEffectName: string, cameras: Camera): void;
  29889. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  29890. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  29891. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  29892. _attachCameras(cameras: Camera, unique: boolean): void;
  29893. _attachCameras(cameras: Camera[], unique: boolean): void;
  29894. _detachCameras(cameras: Camera): void;
  29895. _detachCameras(cameras: Nullable<Camera[]>): void;
  29896. _update(): void;
  29897. _reset(): void;
  29898. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  29899. dispose(): void;
  29900. }
  29901. }
  29902. declare module BABYLON {
  29903. class PostProcessRenderPipelineManager {
  29904. private _renderPipelines;
  29905. constructor();
  29906. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  29907. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  29908. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  29909. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  29910. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  29911. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  29912. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  29913. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  29914. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  29915. update(): void;
  29916. _rebuild(): void;
  29917. dispose(): void;
  29918. }
  29919. }
  29920. declare module BABYLON {
  29921. /**
  29922. * Helper class dealing with the extraction of spherical polynomial dataArray
  29923. * from a cube map.
  29924. */
  29925. class CubeMapToSphericalPolynomialTools {
  29926. private static FileFaces;
  29927. /**
  29928. * Converts a texture to the according Spherical Polynomial data.
  29929. * This extracts the first 3 orders only as they are the only one used in the lighting.
  29930. *
  29931. * @param texture The texture to extract the information from.
  29932. * @return The Spherical Polynomial data.
  29933. */
  29934. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  29935. /**
  29936. * Converts a cubemap to the according Spherical Polynomial data.
  29937. * This extracts the first 3 orders only as they are the only one used in the lighting.
  29938. *
  29939. * @param cubeInfo The Cube map to extract the information from.
  29940. * @return The Spherical Polynomial data.
  29941. */
  29942. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  29943. }
  29944. }
  29945. declare module BABYLON {
  29946. /**
  29947. * Header information of HDR texture files.
  29948. */
  29949. interface HDRInfo {
  29950. /**
  29951. * The height of the texture in pixels.
  29952. */
  29953. height: number;
  29954. /**
  29955. * The width of the texture in pixels.
  29956. */
  29957. width: number;
  29958. /**
  29959. * The index of the beginning of the data in the binary file.
  29960. */
  29961. dataPosition: number;
  29962. }
  29963. /**
  29964. * This groups tools to convert HDR texture to native colors array.
  29965. */
  29966. class HDRTools {
  29967. private static Ldexp(mantissa, exponent);
  29968. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  29969. private static readStringLine(uint8array, startIndex);
  29970. /**
  29971. * Reads header information from an RGBE texture stored in a native array.
  29972. * More information on this format are available here:
  29973. * https://en.wikipedia.org/wiki/RGBE_image_format
  29974. *
  29975. * @param uint8array The binary file stored in native array.
  29976. * @return The header information.
  29977. */
  29978. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  29979. /**
  29980. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  29981. * This RGBE texture needs to store the information as a panorama.
  29982. *
  29983. * More information on this format are available here:
  29984. * https://en.wikipedia.org/wiki/RGBE_image_format
  29985. *
  29986. * @param buffer The binary file stored in an array buffer.
  29987. * @param size The expected size of the extracted cubemap.
  29988. * @return The Cube Map information.
  29989. */
  29990. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  29991. /**
  29992. * Returns the pixels data extracted from an RGBE texture.
  29993. * This pixels will be stored left to right up to down in the R G B order in one array.
  29994. *
  29995. * More information on this format are available here:
  29996. * https://en.wikipedia.org/wiki/RGBE_image_format
  29997. *
  29998. * @param uint8array The binary file stored in an array buffer.
  29999. * @param hdrInfo The header information of the file.
  30000. * @return The pixels data in RGB right to left up to down order.
  30001. */
  30002. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  30003. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  30004. }
  30005. }
  30006. declare module BABYLON {
  30007. /**
  30008. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  30009. */
  30010. interface CubeMapInfo {
  30011. /**
  30012. * The pixel array for the front face.
  30013. * This is stored in format, left to right, up to down format.
  30014. */
  30015. front: Nullable<ArrayBufferView>;
  30016. /**
  30017. * The pixel array for the back face.
  30018. * This is stored in format, left to right, up to down format.
  30019. */
  30020. back: Nullable<ArrayBufferView>;
  30021. /**
  30022. * The pixel array for the left face.
  30023. * This is stored in format, left to right, up to down format.
  30024. */
  30025. left: Nullable<ArrayBufferView>;
  30026. /**
  30027. * The pixel array for the right face.
  30028. * This is stored in format, left to right, up to down format.
  30029. */
  30030. right: Nullable<ArrayBufferView>;
  30031. /**
  30032. * The pixel array for the up face.
  30033. * This is stored in format, left to right, up to down format.
  30034. */
  30035. up: Nullable<ArrayBufferView>;
  30036. /**
  30037. * The pixel array for the down face.
  30038. * This is stored in format, left to right, up to down format.
  30039. */
  30040. down: Nullable<ArrayBufferView>;
  30041. /**
  30042. * The size of the cubemap stored.
  30043. *
  30044. * Each faces will be size * size pixels.
  30045. */
  30046. size: number;
  30047. /**
  30048. * The format of the texture.
  30049. *
  30050. * RGBA, RGB.
  30051. */
  30052. format: number;
  30053. /**
  30054. * The type of the texture data.
  30055. *
  30056. * UNSIGNED_INT, FLOAT.
  30057. */
  30058. type: number;
  30059. /**
  30060. * Specifies whether the texture is in gamma space.
  30061. */
  30062. gammaSpace: boolean;
  30063. }
  30064. /**
  30065. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  30066. */
  30067. class PanoramaToCubeMapTools {
  30068. private static FACE_FRONT;
  30069. private static FACE_BACK;
  30070. private static FACE_RIGHT;
  30071. private static FACE_LEFT;
  30072. private static FACE_DOWN;
  30073. private static FACE_UP;
  30074. /**
  30075. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  30076. *
  30077. * @param float32Array The source data.
  30078. * @param inputWidth The width of the input panorama.
  30079. * @param inputhHeight The height of the input panorama.
  30080. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  30081. * @return The cubemap data
  30082. */
  30083. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  30084. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  30085. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  30086. }
  30087. }
  30088. declare module BABYLON {
  30089. class CustomProceduralTexture extends ProceduralTexture {
  30090. private _animate;
  30091. private _time;
  30092. private _config;
  30093. private _texturePath;
  30094. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  30095. private loadJson(jsonUrl);
  30096. isReady(): boolean;
  30097. render(useCameraPostProcess?: boolean): void;
  30098. updateTextures(): void;
  30099. updateShaderUniforms(): void;
  30100. animate: boolean;
  30101. }
  30102. }
  30103. declare module BABYLON {
  30104. class ProceduralTexture extends Texture {
  30105. isCube: boolean;
  30106. private _size;
  30107. _generateMipMaps: boolean;
  30108. isEnabled: boolean;
  30109. private _currentRefreshId;
  30110. private _refreshRate;
  30111. onGenerated: () => void;
  30112. private _vertexBuffers;
  30113. private _indexBuffer;
  30114. private _effect;
  30115. private _uniforms;
  30116. private _samplers;
  30117. private _fragment;
  30118. _textures: {
  30119. [key: string]: Texture;
  30120. };
  30121. private _floats;
  30122. private _floatsArrays;
  30123. private _colors3;
  30124. private _colors4;
  30125. private _vectors2;
  30126. private _vectors3;
  30127. private _matrices;
  30128. private _fallbackTexture;
  30129. private _fallbackTextureUsed;
  30130. private _engine;
  30131. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  30132. private _createIndexBuffer();
  30133. _rebuild(): void;
  30134. reset(): void;
  30135. isReady(): boolean;
  30136. resetRefreshCounter(): void;
  30137. setFragment(fragment: any): void;
  30138. refreshRate: number;
  30139. _shouldRender(): boolean;
  30140. getRenderSize(): number;
  30141. resize(size: number, generateMipMaps: boolean): void;
  30142. private _checkUniform(uniformName);
  30143. setTexture(name: string, texture: Texture): ProceduralTexture;
  30144. setFloat(name: string, value: number): ProceduralTexture;
  30145. setFloats(name: string, value: number[]): ProceduralTexture;
  30146. setColor3(name: string, value: Color3): ProceduralTexture;
  30147. setColor4(name: string, value: Color4): ProceduralTexture;
  30148. setVector2(name: string, value: Vector2): ProceduralTexture;
  30149. setVector3(name: string, value: Vector3): ProceduralTexture;
  30150. setMatrix(name: string, value: Matrix): ProceduralTexture;
  30151. render(useCameraPostProcess?: boolean): void;
  30152. clone(): ProceduralTexture;
  30153. dispose(): void;
  30154. }
  30155. }
  30156. declare module BABYLON {
  30157. /**
  30158. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  30159. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  30160. */
  30161. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  30162. private _scene;
  30163. private _originalCameras;
  30164. /**
  30165. * ID of the sharpen post process,
  30166. */
  30167. private readonly SharpenPostProcessId;
  30168. /**
  30169. * ID of the image processing post process;
  30170. */
  30171. readonly ImageProcessingPostProcessId: string;
  30172. /**
  30173. * ID of the Fast Approximate Anti-Aliasing post process;
  30174. */
  30175. readonly FxaaPostProcessId: string;
  30176. /**
  30177. * ID of the chromatic aberration post process,
  30178. */
  30179. private readonly ChromaticAberrationPostProcessId;
  30180. /**
  30181. * ID of the grain post process
  30182. */
  30183. private readonly GrainPostProcessId;
  30184. /**
  30185. * Sharpen post process which will apply a sharpen convolution to enhance edges
  30186. */
  30187. sharpen: SharpenPostProcess;
  30188. private _sharpenEffect;
  30189. private bloom;
  30190. /**
  30191. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  30192. */
  30193. depthOfField: DepthOfFieldEffect;
  30194. /**
  30195. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  30196. */
  30197. fxaa: FxaaPostProcess;
  30198. /**
  30199. * Image post processing pass used to perform operations such as tone mapping or color grading.
  30200. */
  30201. imageProcessing: ImageProcessingPostProcess;
  30202. /**
  30203. * Chromatic aberration post process which will shift rgb colors in the image
  30204. */
  30205. chromaticAberration: ChromaticAberrationPostProcess;
  30206. private _chromaticAberrationEffect;
  30207. /**
  30208. * Grain post process which add noise to the image
  30209. */
  30210. grain: GrainPostProcess;
  30211. private _grainEffect;
  30212. /**
  30213. * Animations which can be used to tweak settings over a period of time
  30214. */
  30215. animations: Animation[];
  30216. private _imageProcessingConfigurationObserver;
  30217. private _sharpenEnabled;
  30218. private _bloomEnabled;
  30219. private _depthOfFieldEnabled;
  30220. private _depthOfFieldBlurLevel;
  30221. private _fxaaEnabled;
  30222. private _imageProcessingEnabled;
  30223. private _defaultPipelineTextureType;
  30224. private _bloomScale;
  30225. private _chromaticAberrationEnabled;
  30226. private _grainEnabled;
  30227. private _buildAllowed;
  30228. /**
  30229. * Enable or disable the sharpen process from the pipeline
  30230. */
  30231. sharpenEnabled: boolean;
  30232. private _resizeObserver;
  30233. private _hardwareScaleLevel;
  30234. private _bloomKernel;
  30235. /**
  30236. * Specifies the size of the bloom blur kernel, relative to the final output size
  30237. */
  30238. bloomKernel: number;
  30239. /**
  30240. * Specifies the weight of the bloom in the final rendering
  30241. */
  30242. private _bloomWeight;
  30243. /**
  30244. * Specifies the luma threshold for the area that will be blurred by the bloom
  30245. */
  30246. private _bloomThreshold;
  30247. private _hdr;
  30248. /**
  30249. * The strength of the bloom.
  30250. */
  30251. bloomWeight: number;
  30252. /**
  30253. * The strength of the bloom.
  30254. */
  30255. bloomThreshold: number;
  30256. /**
  30257. * The scale of the bloom, lower value will provide better performance.
  30258. */
  30259. bloomScale: number;
  30260. /**
  30261. * Enable or disable the bloom from the pipeline
  30262. */
  30263. bloomEnabled: boolean;
  30264. private _rebuildBloom();
  30265. /**
  30266. * If the depth of field is enabled.
  30267. */
  30268. depthOfFieldEnabled: boolean;
  30269. /**
  30270. * Blur level of the depth of field effect. (Higher blur will effect performance)
  30271. */
  30272. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  30273. /**
  30274. * If the anti aliasing is enabled.
  30275. */
  30276. fxaaEnabled: boolean;
  30277. private _samples;
  30278. /**
  30279. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  30280. */
  30281. samples: number;
  30282. /**
  30283. * If image processing is enabled.
  30284. */
  30285. imageProcessingEnabled: boolean;
  30286. /**
  30287. * Enable or disable the chromaticAberration process from the pipeline
  30288. */
  30289. chromaticAberrationEnabled: boolean;
  30290. /**
  30291. * Enable or disable the grain process from the pipeline
  30292. */
  30293. grainEnabled: boolean;
  30294. /**
  30295. * @constructor
  30296. * @param {string} name - The rendering pipeline name
  30297. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  30298. * @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)
  30299. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  30300. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  30301. */
  30302. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  30303. /**
  30304. * Force the compilation of the entire pipeline.
  30305. */
  30306. prepare(): void;
  30307. private _hasCleared;
  30308. private _prevPostProcess;
  30309. private _prevPrevPostProcess;
  30310. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  30311. private _buildPipeline();
  30312. private _disposePostProcesses(disposeNonRecreated?);
  30313. /**
  30314. * Dispose of the pipeline and stop all post processes
  30315. */
  30316. dispose(): void;
  30317. /**
  30318. * Serialize the rendering pipeline (Used when exporting)
  30319. * @returns the serialized object
  30320. */
  30321. serialize(): any;
  30322. /**
  30323. * Parse the serialized pipeline
  30324. * @param source Source pipeline.
  30325. * @param scene The scene to load the pipeline to.
  30326. * @param rootUrl The URL of the serialized pipeline.
  30327. * @returns An instantiated pipeline from the serialized object.
  30328. */
  30329. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  30330. }
  30331. }
  30332. declare module BABYLON {
  30333. class LensRenderingPipeline extends PostProcessRenderPipeline {
  30334. /**
  30335. * The chromatic aberration PostProcess id in the pipeline
  30336. */
  30337. LensChromaticAberrationEffect: string;
  30338. /**
  30339. * The highlights enhancing PostProcess id in the pipeline
  30340. */
  30341. HighlightsEnhancingEffect: string;
  30342. /**
  30343. * The depth-of-field PostProcess id in the pipeline
  30344. */
  30345. LensDepthOfFieldEffect: string;
  30346. private _scene;
  30347. private _depthTexture;
  30348. private _grainTexture;
  30349. private _chromaticAberrationPostProcess;
  30350. private _highlightsPostProcess;
  30351. private _depthOfFieldPostProcess;
  30352. private _edgeBlur;
  30353. private _grainAmount;
  30354. private _chromaticAberration;
  30355. private _distortion;
  30356. private _highlightsGain;
  30357. private _highlightsThreshold;
  30358. private _dofDistance;
  30359. private _dofAperture;
  30360. private _dofDarken;
  30361. private _dofPentagon;
  30362. private _blurNoise;
  30363. /**
  30364. * @constructor
  30365. *
  30366. * Effect parameters are as follow:
  30367. * {
  30368. * chromatic_aberration: number; // from 0 to x (1 for realism)
  30369. * edge_blur: number; // from 0 to x (1 for realism)
  30370. * distortion: number; // from 0 to x (1 for realism)
  30371. * grain_amount: number; // from 0 to 1
  30372. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  30373. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  30374. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  30375. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  30376. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  30377. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  30378. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  30379. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  30380. * }
  30381. * Note: if an effect parameter is unset, effect is disabled
  30382. *
  30383. * @param {string} name - The rendering pipeline name
  30384. * @param {object} parameters - An object containing all parameters (see above)
  30385. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  30386. * @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)
  30387. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  30388. */
  30389. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  30390. setEdgeBlur(amount: number): void;
  30391. disableEdgeBlur(): void;
  30392. setGrainAmount(amount: number): void;
  30393. disableGrain(): void;
  30394. setChromaticAberration(amount: number): void;
  30395. disableChromaticAberration(): void;
  30396. setEdgeDistortion(amount: number): void;
  30397. disableEdgeDistortion(): void;
  30398. setFocusDistance(amount: number): void;
  30399. disableDepthOfField(): void;
  30400. setAperture(amount: number): void;
  30401. setDarkenOutOfFocus(amount: number): void;
  30402. enablePentagonBokeh(): void;
  30403. disablePentagonBokeh(): void;
  30404. enableNoiseBlur(): void;
  30405. disableNoiseBlur(): void;
  30406. setHighlightsGain(amount: number): void;
  30407. setHighlightsThreshold(amount: number): void;
  30408. disableHighlights(): void;
  30409. /**
  30410. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  30411. */
  30412. dispose(disableDepthRender?: boolean): void;
  30413. private _createChromaticAberrationPostProcess(ratio);
  30414. private _createHighlightsPostProcess(ratio);
  30415. private _createDepthOfFieldPostProcess(ratio);
  30416. private _createGrainTexture();
  30417. }
  30418. }
  30419. declare module BABYLON {
  30420. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  30421. /**
  30422. * The PassPostProcess id in the pipeline that contains the original scene color
  30423. */
  30424. SSAOOriginalSceneColorEffect: string;
  30425. /**
  30426. * The SSAO PostProcess id in the pipeline
  30427. */
  30428. SSAORenderEffect: string;
  30429. /**
  30430. * The horizontal blur PostProcess id in the pipeline
  30431. */
  30432. SSAOBlurHRenderEffect: string;
  30433. /**
  30434. * The vertical blur PostProcess id in the pipeline
  30435. */
  30436. SSAOBlurVRenderEffect: string;
  30437. /**
  30438. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  30439. */
  30440. SSAOCombineRenderEffect: string;
  30441. /**
  30442. * The output strength of the SSAO post-process. Default value is 1.0.
  30443. */
  30444. totalStrength: number;
  30445. /**
  30446. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  30447. */
  30448. maxZ: number;
  30449. /**
  30450. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  30451. */
  30452. minZAspect: number;
  30453. /**
  30454. * Number of samples used for the SSAO calculations. Default value is 8
  30455. */
  30456. private _samples;
  30457. /**
  30458. * Dynamically generated sphere sampler.
  30459. */
  30460. private _sampleSphere;
  30461. /**
  30462. * Blur filter offsets
  30463. */
  30464. private _samplerOffsets;
  30465. samples: number;
  30466. /**
  30467. * Are we using bilateral blur ?
  30468. */
  30469. private _expensiveBlur;
  30470. expensiveBlur: boolean;
  30471. /**
  30472. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  30473. */
  30474. radius: number;
  30475. /**
  30476. * The base color of the SSAO post-process
  30477. * The final result is "base + ssao" between [0, 1]
  30478. */
  30479. base: number;
  30480. /**
  30481. * Support test.
  30482. */
  30483. static readonly IsSupported: boolean;
  30484. private _scene;
  30485. private _depthTexture;
  30486. private _normalTexture;
  30487. private _randomTexture;
  30488. private _originalColorPostProcess;
  30489. private _ssaoPostProcess;
  30490. private _blurHPostProcess;
  30491. private _blurVPostProcess;
  30492. private _ssaoCombinePostProcess;
  30493. private _firstUpdate;
  30494. /**
  30495. * @constructor
  30496. * @param {string} name - The rendering pipeline name
  30497. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  30498. * @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 }
  30499. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  30500. */
  30501. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  30502. /**
  30503. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  30504. */
  30505. dispose(disableGeometryBufferRenderer?: boolean): void;
  30506. private _createBlurPostProcess(ssaoRatio, blurRatio);
  30507. _rebuild(): void;
  30508. private _generateHemisphere();
  30509. private _createSSAOPostProcess(ratio);
  30510. private _createSSAOCombinePostProcess(ratio);
  30511. private _createRandomTexture();
  30512. }
  30513. }
  30514. declare module BABYLON {
  30515. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  30516. /**
  30517. * The PassPostProcess id in the pipeline that contains the original scene color
  30518. */
  30519. SSAOOriginalSceneColorEffect: string;
  30520. /**
  30521. * The SSAO PostProcess id in the pipeline
  30522. */
  30523. SSAORenderEffect: string;
  30524. /**
  30525. * The horizontal blur PostProcess id in the pipeline
  30526. */
  30527. SSAOBlurHRenderEffect: string;
  30528. /**
  30529. * The vertical blur PostProcess id in the pipeline
  30530. */
  30531. SSAOBlurVRenderEffect: string;
  30532. /**
  30533. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  30534. */
  30535. SSAOCombineRenderEffect: string;
  30536. /**
  30537. * The output strength of the SSAO post-process. Default value is 1.0.
  30538. */
  30539. totalStrength: number;
  30540. /**
  30541. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  30542. */
  30543. radius: number;
  30544. /**
  30545. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  30546. * Must not be equal to fallOff and superior to fallOff.
  30547. * Default value is 0.975
  30548. */
  30549. area: number;
  30550. /**
  30551. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  30552. * Must not be equal to area and inferior to area.
  30553. * Default value is 0.0
  30554. */
  30555. fallOff: number;
  30556. /**
  30557. * The base color of the SSAO post-process
  30558. * The final result is "base + ssao" between [0, 1]
  30559. */
  30560. base: number;
  30561. private _scene;
  30562. private _depthTexture;
  30563. private _randomTexture;
  30564. private _originalColorPostProcess;
  30565. private _ssaoPostProcess;
  30566. private _blurHPostProcess;
  30567. private _blurVPostProcess;
  30568. private _ssaoCombinePostProcess;
  30569. private _firstUpdate;
  30570. /**
  30571. * @constructor
  30572. * @param {string} name - The rendering pipeline name
  30573. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  30574. * @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 }
  30575. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  30576. */
  30577. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  30578. /**
  30579. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  30580. */
  30581. dispose(disableDepthRender?: boolean): void;
  30582. private _createBlurPostProcess(ratio);
  30583. _rebuild(): void;
  30584. private _createSSAOPostProcess(ratio);
  30585. private _createSSAOCombinePostProcess(ratio);
  30586. private _createRandomTexture();
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  30591. /**
  30592. * Public members
  30593. */
  30594. originalPostProcess: Nullable<PostProcess>;
  30595. downSampleX4PostProcess: Nullable<PostProcess>;
  30596. brightPassPostProcess: Nullable<PostProcess>;
  30597. blurHPostProcesses: PostProcess[];
  30598. blurVPostProcesses: PostProcess[];
  30599. textureAdderPostProcess: Nullable<PostProcess>;
  30600. volumetricLightPostProcess: Nullable<PostProcess>;
  30601. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  30602. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  30603. volumetricLightMergePostProces: Nullable<PostProcess>;
  30604. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  30605. luminancePostProcess: Nullable<PostProcess>;
  30606. luminanceDownSamplePostProcesses: PostProcess[];
  30607. hdrPostProcess: Nullable<PostProcess>;
  30608. textureAdderFinalPostProcess: Nullable<PostProcess>;
  30609. lensFlareFinalPostProcess: Nullable<PostProcess>;
  30610. hdrFinalPostProcess: Nullable<PostProcess>;
  30611. lensFlarePostProcess: Nullable<PostProcess>;
  30612. lensFlareComposePostProcess: Nullable<PostProcess>;
  30613. motionBlurPostProcess: Nullable<PostProcess>;
  30614. depthOfFieldPostProcess: Nullable<PostProcess>;
  30615. brightThreshold: number;
  30616. blurWidth: number;
  30617. horizontalBlur: boolean;
  30618. exposure: number;
  30619. lensTexture: Nullable<Texture>;
  30620. volumetricLightCoefficient: number;
  30621. volumetricLightPower: number;
  30622. volumetricLightBlurScale: number;
  30623. sourceLight: Nullable<SpotLight | DirectionalLight>;
  30624. hdrMinimumLuminance: number;
  30625. hdrDecreaseRate: number;
  30626. hdrIncreaseRate: number;
  30627. lensColorTexture: Nullable<Texture>;
  30628. lensFlareStrength: number;
  30629. lensFlareGhostDispersal: number;
  30630. lensFlareHaloWidth: number;
  30631. lensFlareDistortionStrength: number;
  30632. lensStarTexture: Nullable<Texture>;
  30633. lensFlareDirtTexture: Nullable<Texture>;
  30634. depthOfFieldDistance: number;
  30635. depthOfFieldBlurWidth: number;
  30636. motionStrength: number;
  30637. animations: Animation[];
  30638. /**
  30639. * Private members
  30640. */
  30641. private _scene;
  30642. private _currentDepthOfFieldSource;
  30643. private _basePostProcess;
  30644. private _hdrCurrentLuminance;
  30645. private _floatTextureType;
  30646. private _ratio;
  30647. private _bloomEnabled;
  30648. private _depthOfFieldEnabled;
  30649. private _vlsEnabled;
  30650. private _lensFlareEnabled;
  30651. private _hdrEnabled;
  30652. private _motionBlurEnabled;
  30653. private _motionBlurSamples;
  30654. private _volumetricLightStepsCount;
  30655. BloomEnabled: boolean;
  30656. DepthOfFieldEnabled: boolean;
  30657. LensFlareEnabled: boolean;
  30658. HDREnabled: boolean;
  30659. VLSEnabled: boolean;
  30660. MotionBlurEnabled: boolean;
  30661. volumetricLightStepsCount: number;
  30662. motionBlurSamples: number;
  30663. /**
  30664. * @constructor
  30665. * @param {string} name - The rendering pipeline name
  30666. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  30667. * @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)
  30668. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  30669. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  30670. */
  30671. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  30672. private _buildPipeline();
  30673. private _createDownSampleX4PostProcess(scene, ratio);
  30674. private _createBrightPassPostProcess(scene, ratio);
  30675. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  30676. private _createTextureAdderPostProcess(scene, ratio);
  30677. private _createVolumetricLightPostProcess(scene, ratio);
  30678. private _createLuminancePostProcesses(scene, textureType);
  30679. private _createHdrPostProcess(scene, ratio);
  30680. private _createLensFlarePostProcess(scene, ratio);
  30681. private _createDepthOfFieldPostProcess(scene, ratio);
  30682. private _createMotionBlurPostProcess(scene, ratio);
  30683. private _getDepthTexture();
  30684. private _disposePostProcesses();
  30685. dispose(): void;
  30686. serialize(): any;
  30687. /**
  30688. * Static members
  30689. */
  30690. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  30691. static LuminanceSteps: number;
  30692. }
  30693. }