babylon.d.ts 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. /**
  182. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. R16F: number;
  239. RG16F: number;
  240. RGB16F: number;
  241. RED: number;
  242. RG: number;
  243. R8: number;
  244. RG8: number;
  245. UNSIGNED_INT_24_8: number;
  246. DEPTH24_STENCIL8: number;
  247. drawBuffers(buffers: number[]): void;
  248. readBuffer(src: number): void;
  249. readonly COLOR_ATTACHMENT0: number;
  250. readonly COLOR_ATTACHMENT1: number;
  251. readonly COLOR_ATTACHMENT2: number;
  252. readonly COLOR_ATTACHMENT3: number;
  253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  254. ANY_SAMPLES_PASSED: number;
  255. QUERY_RESULT_AVAILABLE: number;
  256. QUERY_RESULT: number;
  257. }
  258. interface Document {
  259. mozCancelFullScreen(): void;
  260. msCancelFullScreen(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. fullscreen: boolean;
  264. mozPointerLockElement: HTMLElement;
  265. msPointerLockElement: HTMLElement;
  266. webkitPointerLockElement: HTMLElement;
  267. }
  268. interface HTMLCanvasElement {
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  284. }
  285. interface MouseEvent {
  286. mozMovementX: number;
  287. mozMovementY: number;
  288. webkitMovementX: number;
  289. webkitMovementY: number;
  290. msMovementX: number;
  291. msMovementY: number;
  292. }
  293. interface Navigator {
  294. mozGetVRDevices: (any: any) => any;
  295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. webkitGetGamepads(): Gamepad[];
  299. msGetGamepads(): Gamepad[];
  300. webkitGamepads(): Gamepad[];
  301. }
  302. interface HTMLVideoElement {
  303. mozSrcObject: any;
  304. }
  305. interface Screen {
  306. orientation: string;
  307. mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Node is the basic class for all scene objects (Mesh, Light Camera).
  333. */
  334. class Node implements IBehaviorAware<Node> {
  335. /**
  336. * Gets or sets the name of the node
  337. */
  338. name: string;
  339. /**
  340. * Gets or sets the id of the node
  341. */
  342. id: string;
  343. /**
  344. * Gets or sets the unique id of the node
  345. */
  346. uniqueId: number;
  347. /**
  348. * Gets or sets a string used to store user defined state for the node
  349. */
  350. state: string;
  351. /**
  352. * Gets or sets an object used to store user defined information for the node
  353. */
  354. metadata: any;
  355. /**
  356. * Gets or sets a boolean used to define if the node must be serialized
  357. */
  358. doNotSerialize: boolean;
  359. /** @hidden */
  360. _isDisposed: boolean;
  361. /**
  362. * Gets a list of Animations associated with the node
  363. */
  364. animations: Animation[];
  365. private _ranges;
  366. /**
  367. * Callback raised when the node is ready to be used
  368. */
  369. onReady: (node: Node) => void;
  370. private _isEnabled;
  371. private _isReady;
  372. /** @hidden */
  373. _currentRenderId: number;
  374. private _parentRenderId;
  375. protected _childRenderId: number;
  376. /** @hidden */
  377. _waitingParentId: Nullable<string>;
  378. private _scene;
  379. /** @hidden */
  380. _cache: any;
  381. private _parentNode;
  382. private _children;
  383. /**
  384. * Gets a boolean indicating if the node has been disposed
  385. * @returns true if the node was disposed
  386. */
  387. isDisposed(): boolean;
  388. /**
  389. * Gets or sets the parent of the node
  390. */
  391. parent: Nullable<Node>;
  392. private _animationPropertiesOverride;
  393. /**
  394. * Gets or sets the animation properties override
  395. */
  396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  397. /**
  398. * Gets a string idenfifying the name of the class
  399. * @returns "Node" string
  400. */
  401. getClassName(): string;
  402. /**
  403. * An event triggered when the mesh is disposed
  404. */
  405. onDisposeObservable: Observable<Node>;
  406. private _onDisposeObserver;
  407. /**
  408. * Sets a callback that will be raised when the node will be disposed
  409. */
  410. onDispose: () => void;
  411. /**
  412. * Creates a new Node
  413. * @param {string} name - the name and id to be given to this node
  414. * @param {BABYLON.Scene} the scene this node will be added to
  415. */
  416. constructor(name: string, scene?: Nullable<Scene>);
  417. /**
  418. * Gets the scene of the node
  419. * @returns a {BABYLON.Scene}
  420. */
  421. getScene(): Scene;
  422. /**
  423. * Gets the engine of the node
  424. * @returns a {BABYLON.Engine}
  425. */
  426. getEngine(): Engine;
  427. private _behaviors;
  428. /**
  429. * Attach a behavior to the node
  430. * @see http://doc.babylonjs.com/features/behaviour
  431. * @param behavior defines the behavior to attach
  432. * @returns the current Node
  433. */
  434. addBehavior(behavior: Behavior<Node>): Node;
  435. /**
  436. * Remove an attached behavior
  437. * @see http://doc.babylonjs.com/features/behaviour
  438. * @param behavior defines the behavior to attach
  439. * @returns the current Node
  440. */
  441. removeBehavior(behavior: Behavior<Node>): Node;
  442. /**
  443. * Gets the list of attached behaviors
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. */
  446. readonly behaviors: Behavior<Node>[];
  447. /**
  448. * Gets an attached behavior by name
  449. * @param name defines the name of the behavior to look for
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. * @returns null if behavior was not found else the requested behavior
  452. */
  453. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  454. /**
  455. * Returns the world matrix of the node
  456. * @returns a matrix containing the node's world matrix
  457. */
  458. getWorldMatrix(): Matrix;
  459. /** @hidden */
  460. _getWorldMatrixDeterminant(): number;
  461. /** @hidden */
  462. _initCache(): void;
  463. /** @hidden */
  464. updateCache(force?: boolean): void;
  465. /** @hidden */
  466. _updateCache(ignoreParentClass?: boolean): void;
  467. /** @hidden */
  468. _isSynchronized(): boolean;
  469. /** @hidden */
  470. _markSyncedWithParent(): void;
  471. /** @hidden */
  472. isSynchronizedWithParent(): boolean;
  473. /** @hidden */
  474. isSynchronized(updateCache?: boolean): boolean;
  475. /** @hidden */
  476. hasNewParent(update?: boolean): boolean;
  477. /**
  478. * Is this node ready to be used/rendered
  479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  480. * @return true if the node is ready
  481. */
  482. isReady(completeCheck?: boolean): boolean;
  483. /**
  484. * Is this node enabled?
  485. * 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
  486. * @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
  487. * @return whether this node (and its parent) is enabled
  488. */
  489. isEnabled(checkAncestors?: boolean): boolean;
  490. /**
  491. * Set the enabled state of this node
  492. * @param value defines the new enabled state
  493. */
  494. setEnabled(value: boolean): void;
  495. /**
  496. * Is this node a descendant of the given node?
  497. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  498. * @param ancestor defines the parent node to inspect
  499. * @returns a boolean indicating if this node is a descendant of the given node
  500. */
  501. isDescendantOf(ancestor: Node): boolean;
  502. /** @hidden */
  503. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  504. /**
  505. * Will return all nodes that have this node as ascendant
  506. * @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
  507. * @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
  508. * @return all children nodes of all types
  509. */
  510. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  511. /**
  512. * Get all child-meshes of this node
  513. * @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
  514. * @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
  515. * @returns an array of {BABYLON.AbstractMesh}
  516. */
  517. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  518. /**
  519. * Get all child-transformNodes of this node
  520. * @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
  521. * @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
  522. * @returns an array of {BABYLON.TransformNode}
  523. */
  524. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  525. /**
  526. * Get all direct children of this node
  527. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  528. * @returns an array of {BABYLON.Node}
  529. */
  530. getChildren(predicate?: (node: Node) => boolean): Node[];
  531. /** @hidden */
  532. _setReady(state: boolean): void;
  533. /**
  534. * Get an animation by name
  535. * @param name defines the name of the animation to look for
  536. * @returns null if not found else the requested animation
  537. */
  538. getAnimationByName(name: string): Nullable<Animation>;
  539. /**
  540. * Creates an animation range for this node
  541. * @param name defines the name of the range
  542. * @param from defines the starting key
  543. * @param to defines the end key
  544. */
  545. createAnimationRange(name: string, from: number, to: number): void;
  546. /**
  547. * Delete a specific animation range
  548. * @param name defines the name of the range to delete
  549. * @param deleteFrames defines if animation frames from the range must be deleted as well
  550. */
  551. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  552. /**
  553. * Get an animation range by name
  554. * @param name defines the name of the animation range to look for
  555. * @returns null if not found else the requested animation range
  556. */
  557. getAnimationRange(name: string): Nullable<AnimationRange>;
  558. /**
  559. * Will start the animation sequence
  560. * @param name defines the range frames for animation sequence
  561. * @param loop defines if the animation should loop (false by default)
  562. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  563. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  564. * @returns the object created for this animation. If range does not exist, it will return null
  565. */
  566. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  567. /**
  568. * Serialize animation ranges into a JSON compatible object
  569. * @returns serialization object
  570. */
  571. serializeAnimationRanges(): any;
  572. /**
  573. * Computes the world matrix of the node
  574. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  575. * @returns the world matrix
  576. */
  577. computeWorldMatrix(force?: boolean): Matrix;
  578. /**
  579. * Releases resources associated with this node.
  580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  582. */
  583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  584. /**
  585. * Parse animation range data from a serialization object and store them into a given node
  586. * @param node defines where to store the animation ranges
  587. * @param parsedNode defines the serialization object to read data from
  588. * @param scene defines the hosting scene
  589. */
  590. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  591. }
  592. }
  593. declare module BABYLON {
  594. /**
  595. * Define an interface for all classes that will hold resources
  596. */
  597. interface IDisposable {
  598. /**
  599. * Releases all held resources
  600. */
  601. dispose(): void;
  602. }
  603. /**
  604. * Interface used to let developers provide their own mesh selection mechanism
  605. */
  606. interface IActiveMeshCandidateProvider {
  607. /**
  608. * Return the list of active meshes
  609. * @param scene defines the current scene
  610. * @returns the list of active meshes
  611. */
  612. getMeshes(scene: Scene): AbstractMesh[];
  613. /**
  614. * Indicates if the meshes have been checked to make sure they are isEnabled()
  615. */
  616. readonly checksIsEnabled: boolean;
  617. }
  618. /**
  619. * This class is used by the onRenderingGroupObservable
  620. */
  621. class RenderingGroupInfo {
  622. /**
  623. * The Scene that being rendered
  624. */
  625. scene: Scene;
  626. /**
  627. * The camera currently used for the rendering pass
  628. */
  629. camera: Nullable<Camera>;
  630. /**
  631. * The ID of the renderingGroup being processed
  632. */
  633. renderingGroupId: number;
  634. /**
  635. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  636. */
  637. renderStage: number;
  638. /**
  639. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  640. * This stage will be fired no matter what
  641. */
  642. static STAGE_PRECLEAR: number;
  643. /**
  644. * Called before opaque object are rendered.
  645. * This stage will be fired only if there's 3D Opaque content to render
  646. */
  647. static STAGE_PREOPAQUE: number;
  648. /**
  649. * Called after the opaque objects are rendered and before the transparent ones
  650. * This stage will be fired only if there's 3D transparent content to render
  651. */
  652. static STAGE_PRETRANSPARENT: number;
  653. /**
  654. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  655. * This stage will be fired no matter what
  656. */
  657. static STAGE_POSTTRANSPARENT: number;
  658. }
  659. /**
  660. * Represents a scene to be rendered by the engine.
  661. * @see http://doc.babylonjs.com/features/scene
  662. */
  663. class Scene implements IAnimatable {
  664. private static _FOGMODE_NONE;
  665. private static _FOGMODE_EXP;
  666. private static _FOGMODE_EXP2;
  667. private static _FOGMODE_LINEAR;
  668. private static _uniqueIdCounter;
  669. /**
  670. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MinDeltaTime: number;
  674. /**
  675. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  677. */
  678. static MaxDeltaTime: number;
  679. /** The fog is deactivated */
  680. static readonly FOGMODE_NONE: number;
  681. /** The fog density is following an exponential function */
  682. static readonly FOGMODE_EXP: number;
  683. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  684. static readonly FOGMODE_EXP2: number;
  685. /** The fog density is following a linear function. */
  686. static readonly FOGMODE_LINEAR: number;
  687. /**
  688. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  689. */
  690. autoClear: boolean;
  691. /**
  692. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  693. */
  694. autoClearDepthAndStencil: boolean;
  695. /**
  696. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  697. */
  698. clearColor: Color4;
  699. /**
  700. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  701. */
  702. ambientColor: Color3;
  703. /** @hidden */
  704. _environmentBRDFTexture: BaseTexture;
  705. /** @hidden */
  706. protected _environmentTexture: BaseTexture;
  707. /**
  708. * Texture used in all pbr material as the reflection texture.
  709. * As in the majority of the scene they are the same (exception for multi room and so on),
  710. * this is easier to reference from here than from all the materials.
  711. */
  712. /**
  713. * Texture used in all pbr material as the reflection texture.
  714. * As in the majority of the scene they are the same (exception for multi room and so on),
  715. * this is easier to set here than in all the materials.
  716. */
  717. environmentTexture: BaseTexture;
  718. /** @hidden */
  719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  720. /**
  721. * Default image processing configuration used either in the rendering
  722. * Forward main pass or through the imageProcessingPostProcess if present.
  723. * As in the majority of the scene they are the same (exception for multi camera),
  724. * this is easier to reference from here than from all the materials and post process.
  725. *
  726. * No setter as we it is a shared configuration, you can set the values instead.
  727. */
  728. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  729. private _forceWireframe;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  732. */
  733. forceWireframe: boolean;
  734. private _forcePointsCloud;
  735. /**
  736. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  737. */
  738. forcePointsCloud: boolean;
  739. /**
  740. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  741. */
  742. forceShowBoundingBoxes: boolean;
  743. /**
  744. * Gets or sets the active clipplane
  745. */
  746. clipPlane: Nullable<Plane>;
  747. /**
  748. * Gets or sets a boolean indicating if animations are enabled
  749. */
  750. animationsEnabled: boolean;
  751. private _animationPropertiesOverride;
  752. /**
  753. * Gets or sets the animation properties override
  754. */
  755. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  756. /**
  757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  759. */
  760. useConstantAnimationDeltaTime: boolean;
  761. /**
  762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  763. * Please note that it requires to run a ray cast through the scene on every frame
  764. */
  765. constantlyUpdateMeshUnderPointer: boolean;
  766. /**
  767. * Defines the HTML cursor to use when hovering over interactive elements
  768. */
  769. hoverCursor: string;
  770. /**
  771. * Defines the HTML default cursor to use (empty by default)
  772. */
  773. defaultCursor: string;
  774. /**
  775. * This is used to call preventDefault() on pointer down
  776. * in order to block unwanted artifacts like system double clicks
  777. */
  778. preventDefaultOnPointerDown: boolean;
  779. /**
  780. * Gets or sets user defined metadata
  781. */
  782. metadata: any;
  783. /**
  784. * Gets the name of the plugin used to load this scene (null by default)
  785. */
  786. loadingPluginName: string;
  787. /**
  788. * Use this array to add regular expressions used to disable offline support for specific urls
  789. */
  790. disableOfflineSupportExceptionRules: RegExp[];
  791. private _spritePredicate;
  792. /**
  793. * An event triggered when the scene is disposed.
  794. */
  795. onDisposeObservable: Observable<Scene>;
  796. private _onDisposeObserver;
  797. /** Sets a function to be executed when this scene is disposed. */
  798. onDispose: () => void;
  799. /**
  800. * An event triggered before rendering the scene (right after animations and physics)
  801. */
  802. onBeforeRenderObservable: Observable<Scene>;
  803. private _onBeforeRenderObserver;
  804. /** Sets a function to be executed before rendering this scene */
  805. beforeRender: Nullable<() => void>;
  806. /**
  807. * An event triggered after rendering the scene
  808. */
  809. onAfterRenderObservable: Observable<Scene>;
  810. private _onAfterRenderObserver;
  811. /** Sets a function to be executed after rendering this scene */
  812. afterRender: Nullable<() => void>;
  813. /**
  814. * An event triggered before animating the scene
  815. */
  816. onBeforeAnimationsObservable: Observable<Scene>;
  817. /**
  818. * An event triggered after animations processing
  819. */
  820. onAfterAnimationsObservable: Observable<Scene>;
  821. /**
  822. * An event triggered before draw calls are ready to be sent
  823. */
  824. onBeforeDrawPhaseObservable: Observable<Scene>;
  825. /**
  826. * An event triggered after draw calls have been sent
  827. */
  828. onAfterDrawPhaseObservable: Observable<Scene>;
  829. /**
  830. * An event triggered when physic simulation is about to be run
  831. */
  832. onBeforePhysicsObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when physic simulation has been done
  835. */
  836. onAfterPhysicsObservable: Observable<Scene>;
  837. /**
  838. * An event triggered when the scene is ready
  839. */
  840. onReadyObservable: Observable<Scene>;
  841. /**
  842. * An event triggered before rendering a camera
  843. */
  844. onBeforeCameraRenderObservable: Observable<Camera>;
  845. private _onBeforeCameraRenderObserver;
  846. /** Sets a function to be executed before rendering a camera*/
  847. beforeCameraRender: () => void;
  848. /**
  849. * An event triggered after rendering a camera
  850. */
  851. onAfterCameraRenderObservable: Observable<Camera>;
  852. private _onAfterCameraRenderObserver;
  853. /** Sets a function to be executed after rendering a camera*/
  854. afterCameraRender: () => void;
  855. /**
  856. * An event triggered when active meshes evaluation is about to start
  857. */
  858. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when active meshes evaluation is done
  861. */
  862. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  866. */
  867. onBeforeParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when particles rendering is done
  870. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  871. */
  872. onAfterParticlesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is about to start
  875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  876. */
  877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when sprites rendering is done
  880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  881. */
  882. onAfterSpritesRenderingObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  885. */
  886. onDataLoadedObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when a camera is created
  889. */
  890. onNewCameraAddedObservable: Observable<Camera>;
  891. /**
  892. * An event triggered when a camera is removed
  893. */
  894. onCameraRemovedObservable: Observable<Camera>;
  895. /**
  896. * An event triggered when a light is created
  897. */
  898. onNewLightAddedObservable: Observable<Light>;
  899. /**
  900. * An event triggered when a light is removed
  901. */
  902. onLightRemovedObservable: Observable<Light>;
  903. /**
  904. * An event triggered when a geometry is created
  905. */
  906. onNewGeometryAddedObservable: Observable<Geometry>;
  907. /**
  908. * An event triggered when a geometry is removed
  909. */
  910. onGeometryRemovedObservable: Observable<Geometry>;
  911. /**
  912. * An event triggered when a transform node is created
  913. */
  914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  915. /**
  916. * An event triggered when a transform node is removed
  917. */
  918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  919. /**
  920. * An event triggered when a mesh is created
  921. */
  922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  923. /**
  924. * An event triggered when a mesh is removed
  925. */
  926. onMeshRemovedObservable: Observable<AbstractMesh>;
  927. /**
  928. * An event triggered when render targets are about to be rendered
  929. * Can happen multiple times per frame.
  930. */
  931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered when render targets were rendered.
  934. * Can happen multiple times per frame.
  935. */
  936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  937. /**
  938. * An event triggered before calculating deterministic simulation step
  939. */
  940. onBeforeStepObservable: Observable<Scene>;
  941. /**
  942. * An event triggered after calculating deterministic simulation step
  943. */
  944. onAfterStepObservable: Observable<Scene>;
  945. /**
  946. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  948. * 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)
  949. */
  950. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  951. /**
  952. * Gets a list of Animations associated with the scene
  953. */
  954. animations: Animation[];
  955. private _registeredForLateAnimationBindings;
  956. /**
  957. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  958. */
  959. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  960. /**
  961. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  962. */
  963. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  964. /**
  965. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  966. */
  967. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  968. private _onPointerMove;
  969. private _onPointerDown;
  970. private _onPointerUp;
  971. /** Deprecated. Use onPointerObservable instead */
  972. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  973. /** Deprecated. Use onPointerObservable instead */
  974. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  975. /** Deprecated. Use onPointerObservable instead */
  976. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  977. /** Deprecated. Use onPointerObservable instead */
  978. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  979. private _gamepadManager;
  980. /**
  981. * Gets the gamepad manager associated with the scene
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  983. */
  984. readonly gamepadManager: GamepadManager;
  985. /**
  986. * 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).
  987. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  988. */
  989. onPrePointerObservable: Observable<PointerInfoPre>;
  990. /**
  991. * Observable event triggered each time an input event is received from the rendering canvas
  992. */
  993. onPointerObservable: Observable<PointerInfo>;
  994. /**
  995. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  996. */
  997. readonly unTranslatedPointer: Vector2;
  998. /** The distance in pixel that you have to move to prevent some events */
  999. static DragMovementThreshold: number;
  1000. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1001. static LongPressDelay: number;
  1002. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1003. static DoubleClickDelay: number;
  1004. /** If you need to check double click without raising a single click at first click, enable this flag */
  1005. static ExclusiveDoubleClickMode: boolean;
  1006. private _initClickEvent;
  1007. private _initActionManager;
  1008. private _delayedSimpleClick;
  1009. private _delayedSimpleClickTimeout;
  1010. private _previousDelayedSimpleClickTimeout;
  1011. private _meshPickProceed;
  1012. private _previousButtonPressed;
  1013. private _currentPickResult;
  1014. private _previousPickResult;
  1015. private _totalPointersPressed;
  1016. private _doubleClickOccured;
  1017. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1018. cameraToUseForPointers: Nullable<Camera>;
  1019. private _pointerX;
  1020. private _pointerY;
  1021. private _unTranslatedPointerX;
  1022. private _unTranslatedPointerY;
  1023. private _startingPointerPosition;
  1024. private _previousStartingPointerPosition;
  1025. private _startingPointerTime;
  1026. private _previousStartingPointerTime;
  1027. private _pointerCaptures;
  1028. private _timeAccumulator;
  1029. private _currentStepId;
  1030. private _currentInternalStep;
  1031. /** @hidden */
  1032. _mirroredCameraPosition: Nullable<Vector3>;
  1033. /**
  1034. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1035. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1036. */
  1037. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1038. /**
  1039. * Observable event triggered each time an keyboard event is received from the hosting window
  1040. */
  1041. onKeyboardObservable: Observable<KeyboardInfo>;
  1042. private _onKeyDown;
  1043. private _onKeyUp;
  1044. private _onCanvasFocusObserver;
  1045. private _onCanvasBlurObserver;
  1046. private _useRightHandedSystem;
  1047. /**
  1048. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1049. */
  1050. useRightHandedSystem: boolean;
  1051. /**
  1052. * Sets the step Id used by deterministic lock step
  1053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1054. * @param newStepId defines the step Id
  1055. */
  1056. setStepId(newStepId: number): void;
  1057. /**
  1058. * Gets the step Id used by deterministic lock step
  1059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1060. * @returns the step Id
  1061. */
  1062. getStepId(): number;
  1063. /**
  1064. * Gets the internal step used by deterministic lock step
  1065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1066. * @returns the internal step
  1067. */
  1068. getInternalStep(): number;
  1069. private _fogEnabled;
  1070. /**
  1071. * Gets or sets a boolean indicating if fog is enabled on this scene
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogEnabled: boolean;
  1075. private _fogMode;
  1076. /**
  1077. * Gets or sets the fog mode to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogMode: number;
  1081. /**
  1082. * Gets or sets the fog color to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogColor: Color3;
  1086. /**
  1087. * Gets or sets the fog density to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogDensity: number;
  1091. /**
  1092. * Gets or sets the fog start distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogStart: number;
  1096. /**
  1097. * Gets or sets the fog end distance to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. */
  1100. fogEnd: number;
  1101. private _shadowsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1104. */
  1105. shadowsEnabled: boolean;
  1106. private _lightsEnabled;
  1107. /**
  1108. * Gets or sets a boolean indicating if lights are enabled on this scene
  1109. */
  1110. lightsEnabled: boolean;
  1111. /**
  1112. * All of the lights added to this scene
  1113. * @see http://doc.babylonjs.com/babylon101/lights
  1114. */
  1115. lights: Light[];
  1116. /** All of the cameras added to this scene.
  1117. * @see http://doc.babylonjs.com/babylon101/cameras
  1118. */
  1119. cameras: Camera[];
  1120. /** All of the active cameras added to this scene. */
  1121. activeCameras: Camera[];
  1122. /** The current active camera */
  1123. activeCamera: Nullable<Camera>;
  1124. /**
  1125. * All of the tranform nodes added to this scene
  1126. * @see http://doc.babylonjs.com/how_to/transformnode
  1127. */
  1128. transformNodes: TransformNode[];
  1129. /**
  1130. * All of the (abstract) meshes added to this scene
  1131. */
  1132. meshes: AbstractMesh[];
  1133. /**
  1134. * All of the animation groups added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/group
  1136. */
  1137. animationGroups: AnimationGroup[];
  1138. private _geometries;
  1139. /**
  1140. * All of the materials added to this scene
  1141. * @see http://doc.babylonjs.com/babylon101/materials
  1142. */
  1143. materials: Material[];
  1144. /**
  1145. * All of the multi-materials added to this scene
  1146. * @see http://doc.babylonjs.com/how_to/multi_materials
  1147. */
  1148. multiMaterials: MultiMaterial[];
  1149. private _defaultMaterial;
  1150. /** The default material used on meshes when no material is affected */
  1151. /** The default material used on meshes when no material is affected */
  1152. defaultMaterial: Material;
  1153. private _texturesEnabled;
  1154. /**
  1155. * Gets or sets a boolean indicating if textures are enabled on this scene
  1156. */
  1157. texturesEnabled: boolean;
  1158. /**
  1159. * All of the textures added to this scene
  1160. */
  1161. textures: BaseTexture[];
  1162. /**
  1163. * Gets or sets a boolean indicating if particles are enabled on this scene
  1164. */
  1165. particlesEnabled: boolean;
  1166. /**
  1167. * All of the particle systems added to this scene
  1168. * @see http://doc.babylonjs.com/babylon101/particles
  1169. */
  1170. particleSystems: IParticleSystem[];
  1171. /**
  1172. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1173. */
  1174. spritesEnabled: boolean;
  1175. /**
  1176. * All of the sprite managers added to this scene
  1177. * @see http://doc.babylonjs.com/babylon101/sprites
  1178. */
  1179. spriteManagers: SpriteManager[];
  1180. /**
  1181. * The list of layers (background and foreground) of the scene
  1182. */
  1183. layers: Layer[];
  1184. /**
  1185. * The list of effect layers (highlights/glow) added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1187. * @see http://doc.babylonjs.com/how_to/glow_layer
  1188. */
  1189. effectLayers: EffectLayer[];
  1190. private _skeletonsEnabled;
  1191. /**
  1192. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1193. */
  1194. skeletonsEnabled: boolean;
  1195. /**
  1196. * The list of skeletons added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1198. */
  1199. skeletons: Skeleton[];
  1200. /**
  1201. * The list of morph target managers added to the scene
  1202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1203. */
  1204. morphTargetManagers: MorphTargetManager[];
  1205. /**
  1206. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1207. */
  1208. lensFlaresEnabled: boolean;
  1209. /**
  1210. * The list of lens flare system added to the scene
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1212. */
  1213. lensFlareSystems: LensFlareSystem[];
  1214. /**
  1215. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1217. */
  1218. collisionsEnabled: boolean;
  1219. private _workerCollisions;
  1220. /** @hidden */
  1221. collisionCoordinator: ICollisionCoordinator;
  1222. /**
  1223. * Defines the gravity applied to this scene (used only for collisions)
  1224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1225. */
  1226. gravity: Vector3;
  1227. /**
  1228. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1229. */
  1230. postProcessesEnabled: boolean;
  1231. /**
  1232. * The list of postprocesses added to the scene
  1233. */
  1234. postProcesses: PostProcess[];
  1235. /**
  1236. * Gets the current postprocess manager
  1237. */
  1238. postProcessManager: PostProcessManager;
  1239. private _postProcessRenderPipelineManager;
  1240. /**
  1241. * Gets the postprocess render pipeline manager
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1243. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1244. */
  1245. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * The list of reflection probes added to the scene
  1274. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1275. */
  1276. reflectionProbes: ReflectionProbe[];
  1277. /**
  1278. * @hidden
  1279. */
  1280. database: Database;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. /** @hidden */
  1287. _actionManagers: ActionManager[];
  1288. private _meshesForIntersections;
  1289. /**
  1290. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1291. */
  1292. proceduralTexturesEnabled: boolean;
  1293. /**
  1294. * The list of procedural textures added to the scene
  1295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1296. */
  1297. proceduralTextures: ProceduralTexture[];
  1298. private _mainSoundTrack;
  1299. /**
  1300. * The list of sound tracks added to the scene
  1301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1302. */
  1303. soundTracks: SoundTrack[];
  1304. private _audioEnabled;
  1305. private _headphone;
  1306. /**
  1307. * Gets the main soundtrack associated with the scene
  1308. */
  1309. readonly mainSoundTrack: SoundTrack;
  1310. /**
  1311. * Gets or sets the VRExperienceHelper attached to the scene
  1312. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1313. * @ignorenaming
  1314. */
  1315. VRHelper: VRExperienceHelper;
  1316. /**
  1317. * Gets or sets the simplification queue attached to the scene
  1318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1319. */
  1320. simplificationQueue: SimplificationQueue;
  1321. private _engine;
  1322. private _totalVertices;
  1323. /** @hidden */
  1324. _activeIndices: PerfCounter;
  1325. /** @hidden */
  1326. _activeParticles: PerfCounter;
  1327. /** @hidden */
  1328. _activeBones: PerfCounter;
  1329. private _animationRatio;
  1330. private _animationTimeLast;
  1331. private _animationTime;
  1332. /**
  1333. * Gets or sets a general scale for animation speed
  1334. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1335. */
  1336. animationTimeScale: number;
  1337. /** @hidden */
  1338. _cachedMaterial: Nullable<Material>;
  1339. /** @hidden */
  1340. _cachedEffect: Nullable<Effect>;
  1341. /** @hidden */
  1342. _cachedVisibility: Nullable<number>;
  1343. private _renderId;
  1344. private _executeWhenReadyTimeoutId;
  1345. private _intermediateRendering;
  1346. private _viewUpdateFlag;
  1347. private _projectionUpdateFlag;
  1348. private _alternateViewUpdateFlag;
  1349. private _alternateProjectionUpdateFlag;
  1350. /** @hidden */
  1351. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1352. private _activeRequests;
  1353. private _pendingData;
  1354. private _isDisposed;
  1355. /**
  1356. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1357. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1358. */
  1359. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1360. private _activeMeshes;
  1361. private _processedMaterials;
  1362. private _renderTargets;
  1363. /** @hidden */
  1364. _activeParticleSystems: SmartArray<IParticleSystem>;
  1365. private _activeSkeletons;
  1366. private _softwareSkinnedMeshes;
  1367. private _renderingManager;
  1368. private _physicsEngine;
  1369. /** @hidden */
  1370. _activeAnimatables: Animatable[];
  1371. private _transformMatrix;
  1372. private _sceneUbo;
  1373. private _alternateSceneUbo;
  1374. private _pickWithRayInverseMatrix;
  1375. private _boundingBoxRenderer;
  1376. private _outlineRenderer;
  1377. private _viewMatrix;
  1378. private _projectionMatrix;
  1379. private _alternateViewMatrix;
  1380. private _alternateProjectionMatrix;
  1381. private _alternateTransformMatrix;
  1382. private _useAlternateCameraConfiguration;
  1383. private _alternateRendering;
  1384. /** @hidden */
  1385. _forcedViewPosition: Nullable<Vector3>;
  1386. /** @hidden */
  1387. readonly _isAlternateRenderingEnabled: boolean;
  1388. private _frustumPlanes;
  1389. /**
  1390. * Gets the list of frustum planes (built from the active camera)
  1391. */
  1392. readonly frustumPlanes: Plane[];
  1393. /**
  1394. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1395. * This is useful if there are more lights that the maximum simulteanous authorized
  1396. */
  1397. requireLightSorting: boolean;
  1398. private _selectionOctree;
  1399. private _pointerOverMesh;
  1400. private _pointerOverSprite;
  1401. private _debugLayer;
  1402. private _depthRenderer;
  1403. private _geometryBufferRenderer;
  1404. /**
  1405. * Gets the current geometry buffer associated to the scene.
  1406. */
  1407. /**
  1408. * Sets the current geometry buffer for the scene.
  1409. */
  1410. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1411. private _pickedDownMesh;
  1412. private _pickedUpMesh;
  1413. private _pickedDownSprite;
  1414. private _externalData;
  1415. private _uid;
  1416. /**
  1417. * Creates a new Scene
  1418. * @param engine defines the engine to use to render this scene
  1419. */
  1420. constructor(engine: Engine);
  1421. /**
  1422. * Gets the debug layer associated with the scene
  1423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1424. */
  1425. readonly debugLayer: DebugLayer;
  1426. /**
  1427. * Gets a boolean indicating if collisions are processed on a web worker
  1428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1429. */
  1430. workerCollisions: boolean;
  1431. /**
  1432. * Gets the octree used to boost mesh selection (picking)
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1434. */
  1435. readonly selectionOctree: Octree<AbstractMesh>;
  1436. /**
  1437. * Gets the mesh that is currently under the pointer
  1438. */
  1439. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1440. /**
  1441. * Gets the current on-screen X position of the pointer
  1442. */
  1443. readonly pointerX: number;
  1444. /**
  1445. * Gets the current on-screen Y position of the pointer
  1446. */
  1447. readonly pointerY: number;
  1448. /**
  1449. * Gets the cached material (ie. the latest rendered one)
  1450. * @returns the cached material
  1451. */
  1452. getCachedMaterial(): Nullable<Material>;
  1453. /**
  1454. * Gets the cached effect (ie. the latest rendered one)
  1455. * @returns the cached effect
  1456. */
  1457. getCachedEffect(): Nullable<Effect>;
  1458. /**
  1459. * Gets the cached visibility state (ie. the latest rendered one)
  1460. * @returns the cached visibility state
  1461. */
  1462. getCachedVisibility(): Nullable<number>;
  1463. /**
  1464. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1465. * @param material defines the current material
  1466. * @param effect defines the current effect
  1467. * @param visibility defines the current visibility state
  1468. * @returns true if one parameter is not cached
  1469. */
  1470. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1471. /**
  1472. * Gets the bounding box renderer associated with the scene
  1473. * @returns a BoundingBoxRenderer
  1474. */
  1475. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1476. /**
  1477. * Gets the outline renderer associated with the scene
  1478. * @returns a OutlineRenderer
  1479. */
  1480. getOutlineRenderer(): OutlineRenderer;
  1481. /**
  1482. * Gets the engine associated with the scene
  1483. * @returns an Engine
  1484. */
  1485. getEngine(): Engine;
  1486. /**
  1487. * Gets the total number of vertices rendered per frame
  1488. * @returns the total number of vertices rendered per frame
  1489. */
  1490. getTotalVertices(): number;
  1491. /**
  1492. * Gets the performance counter for total vertices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalVerticesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1498. * @returns the total number of active indices rendered per frame
  1499. */
  1500. getActiveIndices(): number;
  1501. /**
  1502. * Gets the performance counter for active indices
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active particles rendered per frame
  1508. * @returns the total number of active particles rendered per frame
  1509. */
  1510. getActiveParticles(): number;
  1511. /**
  1512. * Gets the performance counter for active particles
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeParticlesPerfCounter: PerfCounter;
  1516. /**
  1517. * Gets the total number of active bones rendered per frame
  1518. * @returns the total number of active bones rendered per frame
  1519. */
  1520. getActiveBones(): number;
  1521. /**
  1522. * Gets the performance counter for active bones
  1523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1524. */
  1525. readonly activeBonesPerfCounter: PerfCounter;
  1526. /** @hidden */
  1527. getInterFramePerfCounter(): number;
  1528. /** @hidden */
  1529. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getLastFrameDuration(): number;
  1532. /** @hidden */
  1533. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1534. /** @hidden */
  1535. getEvaluateActiveMeshesDuration(): number;
  1536. /** @hidden */
  1537. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1538. /**
  1539. * Gets the array of active meshes
  1540. * @returns an array of AbstractMesh
  1541. */
  1542. getActiveMeshes(): SmartArray<AbstractMesh>;
  1543. /** @hidden */
  1544. getRenderTargetsDuration(): number;
  1545. /** @hidden */
  1546. getRenderDuration(): number;
  1547. /** @hidden */
  1548. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1549. /** @hidden */
  1550. getParticlesDuration(): number;
  1551. /** @hidden */
  1552. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1553. /** @hidden */
  1554. getSpritesDuration(): number;
  1555. /** @hidden */
  1556. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1557. /**
  1558. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1559. * @returns a number
  1560. */
  1561. getAnimationRatio(): number;
  1562. /**
  1563. * Gets an unique Id for the current frame
  1564. * @returns a number
  1565. */
  1566. getRenderId(): number;
  1567. /** Call this function if you want to manually increment the render Id*/
  1568. incrementRenderId(): void;
  1569. private _updatePointerPosition(evt);
  1570. private _createUbo();
  1571. private _createAlternateUbo();
  1572. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1573. private _setRayOnPointerInfo(pointerInfo);
  1574. /**
  1575. * Use this method to simulate a pointer move 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. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerMove(pickResult, evt);
  1583. private _checkPrePointerObservable(pickResult, evt, type);
  1584. /**
  1585. * Use this method to simulate a pointer down on a mesh
  1586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1589. * @returns the current scene
  1590. */
  1591. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1592. private _processPointerDown(pickResult, evt);
  1593. /**
  1594. * Use this method to simulate a pointer up on a mesh
  1595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1598. * @returns the current scene
  1599. */
  1600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1601. private _processPointerUp(pickResult, evt, clickInfo);
  1602. /**
  1603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1605. * @returns true if the pointer was captured
  1606. */
  1607. isPointerCaptured(pointerId?: number): boolean;
  1608. /**
  1609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1610. * @param attachUp defines if you want to attach events to pointerup
  1611. * @param attachDown defines if you want to attach events to pointerdown
  1612. * @param attachMove defines if you want to attach events to pointermove
  1613. */
  1614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1615. /** Detaches all event handlers*/
  1616. detachControl(): void;
  1617. /**
  1618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1619. * Delay loaded resources are not taking in account
  1620. * @return true if all required resources are ready
  1621. */
  1622. isReady(): boolean;
  1623. /** Resets all cached information relative to material (including effect and visibility) */
  1624. resetCachedMaterial(): void;
  1625. /**
  1626. * Registers a function to be called before every frame render
  1627. * @param func defines the function to register
  1628. */
  1629. registerBeforeRender(func: () => void): void;
  1630. /**
  1631. * Unregisters a function called before every frame render
  1632. * @param func defines the function to unregister
  1633. */
  1634. unregisterBeforeRender(func: () => void): void;
  1635. /**
  1636. * Registers a function to be called after every frame render
  1637. * @param func defines the function to register
  1638. */
  1639. registerAfterRender(func: () => void): void;
  1640. /**
  1641. * Unregisters a function called after every frame render
  1642. * @param func defines the function to unregister
  1643. */
  1644. unregisterAfterRender(func: () => void): void;
  1645. private _executeOnceBeforeRender(func);
  1646. /**
  1647. * The provided function will run before render once and will be disposed afterwards.
  1648. * A timeout delay can be provided so that the function will be executed in N ms.
  1649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1650. * @param func The function to be executed.
  1651. * @param timeout optional delay in ms
  1652. */
  1653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1654. /** @hidden */
  1655. _addPendingData(data: any): void;
  1656. /** @hidden */
  1657. _removePendingData(data: any): void;
  1658. /**
  1659. * Returns the number of items waiting to be loaded
  1660. * @returns the number of items waiting to be loaded
  1661. */
  1662. getWaitingItemsCount(): number;
  1663. /**
  1664. * Returns a boolean indicating if the scene is still loading data
  1665. */
  1666. readonly isLoading: boolean;
  1667. /**
  1668. * Registers a function to be executed when the scene is ready
  1669. * @param {Function} func - the function to be executed
  1670. */
  1671. executeWhenReady(func: () => void): void;
  1672. /**
  1673. * Returns a promise that resolves when the scene is ready
  1674. * @returns A promise that resolves when the scene is ready
  1675. */
  1676. whenReadyAsync(): Promise<void>;
  1677. /** @hidden */
  1678. _checkIsReady(): void;
  1679. /**
  1680. * Will start the animation sequence of a given target
  1681. * @param target defines the target
  1682. * @param from defines from which frame should animation start
  1683. * @param to defines until which frame should animation run.
  1684. * @param weight defines the weight to apply to the animation (1.0 by default)
  1685. * @param loop defines if the animation loops
  1686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1687. * @param onAnimationEnd defines the function to be executed when the animation ends
  1688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1689. * @returns the animatable object created for this animation
  1690. */
  1691. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1692. /**
  1693. * Will start the animation sequence of a given target
  1694. * @param target defines the target
  1695. * @param from defines from which frame should animation start
  1696. * @param to defines until which frame should animation run.
  1697. * @param loop defines if the animation loops
  1698. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1699. * @param onAnimationEnd defines the function to be executed when the animation ends
  1700. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1701. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1702. * @returns the animatable object created for this animation
  1703. */
  1704. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1705. /**
  1706. * Begin a new animation on a given node
  1707. * @param target defines the target where the animation will take place
  1708. * @param animations defines the list of animations to start
  1709. * @param from defines the initial value
  1710. * @param to defines the final value
  1711. * @param loop defines if you want animation to loop (off by default)
  1712. * @param speedRatio defines the speed ratio to apply to all animations
  1713. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1714. * @returns the list of created animatables
  1715. */
  1716. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1717. /**
  1718. * Begin a new animation on a given node and its hierarchy
  1719. * @param target defines the root node where the animation will take place
  1720. * @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.
  1721. * @param animations defines the list of animations to start
  1722. * @param from defines the initial value
  1723. * @param to defines the final value
  1724. * @param loop defines if you want animation to loop (off by default)
  1725. * @param speedRatio defines the speed ratio to apply to all animations
  1726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1727. * @returns the list of animatables created for all nodes
  1728. */
  1729. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1730. /**
  1731. * Gets the animatable associated with a specific target
  1732. * @param target defines the target of the animatable
  1733. * @returns the required animatable if found
  1734. */
  1735. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1736. /**
  1737. * Gets all animatables associated with a given target
  1738. * @param target defines the target to look animatables for
  1739. * @returns an array of Animatables
  1740. */
  1741. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1742. /**
  1743. * Gets all animatable attached to the scene
  1744. */
  1745. readonly animatables: Animatable[];
  1746. /**
  1747. * Will stop the animation of the given target
  1748. * @param target - the target
  1749. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1750. */
  1751. stopAnimation(target: any, animationName?: string): void;
  1752. /**
  1753. * Stops and removes all animations that have been applied to the scene
  1754. */
  1755. stopAllAnimations(): void;
  1756. private _animate();
  1757. /** @hidden */
  1758. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1759. private _processLateAnimationBindingsForMatrices(holder);
  1760. private _processLateAnimationBindingsForQuaternions(holder);
  1761. private _processLateAnimationBindings();
  1762. /** @hidden */
  1763. _switchToAlternateCameraConfiguration(active: boolean): void;
  1764. /**
  1765. * Gets the current view matrix
  1766. * @returns a Matrix
  1767. */
  1768. getViewMatrix(): Matrix;
  1769. /**
  1770. * Gets the current projection matrix
  1771. * @returns a Matrix
  1772. */
  1773. getProjectionMatrix(): Matrix;
  1774. /**
  1775. * Gets the current transform matrix
  1776. * @returns a Matrix made of View * Projection
  1777. */
  1778. getTransformMatrix(): Matrix;
  1779. /**
  1780. * Sets the current transform matrix
  1781. * @param view defines the View matrix to use
  1782. * @param projection defines the Projection matrix to use
  1783. */
  1784. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1785. /** @hidden */
  1786. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1787. /**
  1788. * Gets the uniform buffer used to store scene data
  1789. * @returns a UniformBuffer
  1790. */
  1791. getSceneUniformBuffer(): UniformBuffer;
  1792. /**
  1793. * Gets an unique (relatively to the current scene) Id
  1794. * @returns an unique number for the scene
  1795. */
  1796. getUniqueId(): number;
  1797. /**
  1798. * Add a mesh to the list of scene's meshes
  1799. * @param newMesh defines the mesh to add
  1800. * @param recursive if all child meshes should also be added to the scene
  1801. */
  1802. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1803. /**
  1804. * Remove a mesh for the list of scene's meshes
  1805. * @param toRemove defines the mesh to remove
  1806. * @param recursive if all child meshes should also be removed from the scene
  1807. * @returns the index where the mesh was in the mesh list
  1808. */
  1809. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1810. /**
  1811. * Add a transform node to the list of scene's transform nodes
  1812. * @param newTransformNode defines the transform node to add
  1813. */
  1814. addTransformNode(newTransformNode: TransformNode): void;
  1815. /**
  1816. * Remove a transform node for the list of scene's transform nodes
  1817. * @param toRemove defines the transform node to remove
  1818. * @returns the index where the transform node was in the transform node list
  1819. */
  1820. removeTransformNode(toRemove: TransformNode): number;
  1821. /**
  1822. * Remove a skeleton for the list of scene's skeletons
  1823. * @param toRemove defines the skeleton to remove
  1824. * @returns the index where the skeleton was in the skeleton list
  1825. */
  1826. removeSkeleton(toRemove: Skeleton): number;
  1827. /**
  1828. * Remove a morph target for the list of scene's morph targets
  1829. * @param toRemove defines the morph target to remove
  1830. * @returns the index where the morph target was in the morph target list
  1831. */
  1832. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1833. /**
  1834. * Remove a light for the list of scene's lights
  1835. * @param toRemove defines the light to remove
  1836. * @returns the index where the light was in the light list
  1837. */
  1838. removeLight(toRemove: Light): number;
  1839. /**
  1840. * Remove a camera for the list of scene's cameras
  1841. * @param toRemove defines the camera to remove
  1842. * @returns the index where the camera was in the camera list
  1843. */
  1844. removeCamera(toRemove: Camera): number;
  1845. /**
  1846. * Remove a particle system for the list of scene's particle systems
  1847. * @param toRemove defines the particle system to remove
  1848. * @returns the index where the particle system was in the particle system list
  1849. */
  1850. removeParticleSystem(toRemove: IParticleSystem): number;
  1851. /**
  1852. * Remove a animation for the list of scene's animations
  1853. * @param toRemove defines the animation to remove
  1854. * @returns the index where the animation was in the animation list
  1855. */
  1856. removeAnimation(toRemove: Animation): number;
  1857. /**
  1858. * Removes the given animation group from this scene.
  1859. * @param toRemove The animation group to remove
  1860. * @returns The index of the removed animation group
  1861. */
  1862. removeAnimationGroup(toRemove: AnimationGroup): number;
  1863. /**
  1864. * Removes the given multi-material from this scene.
  1865. * @param toRemove The multi-material to remove
  1866. * @returns The index of the removed multi-material
  1867. */
  1868. removeMultiMaterial(toRemove: MultiMaterial): number;
  1869. /**
  1870. * Removes the given material from this scene.
  1871. * @param toRemove The material to remove
  1872. * @returns The index of the removed material
  1873. */
  1874. removeMaterial(toRemove: Material): number;
  1875. /**
  1876. * Removes the given lens flare system from this scene.
  1877. * @param toRemove The lens flare system to remove
  1878. * @returns The index of the removed lens flare system
  1879. */
  1880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1881. /**
  1882. * Removes the given action manager from this scene.
  1883. * @param toRemove The action manager to remove
  1884. * @returns The index of the removed action manager
  1885. */
  1886. removeActionManager(toRemove: ActionManager): number;
  1887. /**
  1888. * Removes the given effect layer from this scene.
  1889. * @param toRemove defines the effect layer to remove
  1890. * @returns the index of the removed effect layer
  1891. */
  1892. removeEffectLayer(toRemove: EffectLayer): number;
  1893. /**
  1894. * Removes the given texture from this scene.
  1895. * @param toRemove The texture to remove
  1896. * @returns The index of the removed texture
  1897. */
  1898. removeTexture(toRemove: BaseTexture): number;
  1899. /**
  1900. * Adds the given light to this scene
  1901. * @param newLight The light to add
  1902. */
  1903. addLight(newLight: Light): void;
  1904. /**
  1905. * Sorts the list list based on light priorities
  1906. */
  1907. sortLightsByPriority(): void;
  1908. /**
  1909. * Adds the given camera to this scene
  1910. * @param newCamera The camera to add
  1911. */
  1912. addCamera(newCamera: Camera): void;
  1913. /**
  1914. * Adds the given skeleton to this scene
  1915. * @param newSkeleton The skeleton to add
  1916. */
  1917. addSkeleton(newSkeleton: Skeleton): void;
  1918. /**
  1919. * Adds the given particle system to this scene
  1920. * @param newParticleSystem The particle system to add
  1921. */
  1922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1923. /**
  1924. * Adds the given animation to this scene
  1925. * @param newAnimation The animation to add
  1926. */
  1927. addAnimation(newAnimation: Animation): void;
  1928. /**
  1929. * Adds the given animation group to this scene.
  1930. * @param newAnimationGroup The animation group to add
  1931. */
  1932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1933. /**
  1934. * Adds the given multi-material to this scene
  1935. * @param newMultiMaterial The multi-material to add
  1936. */
  1937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1938. /**
  1939. * Adds the given material to this scene
  1940. * @param newMaterial The material to add
  1941. */
  1942. addMaterial(newMaterial: Material): void;
  1943. /**
  1944. * Adds the given morph target to this scene
  1945. * @param newMorphTargetManager The morph target to add
  1946. */
  1947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1948. /**
  1949. * Adds the given geometry to this scene
  1950. * @param newGeometry The geometry to add
  1951. */
  1952. addGeometry(newGeometry: Geometry): void;
  1953. /**
  1954. * Adds the given lens flare system to this scene
  1955. * @param newLensFlareSystem The lens flare system to add
  1956. */
  1957. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1958. /**
  1959. * Adds the given effect layer to this scene
  1960. * @param newEffectLayer defines the effect layer to add
  1961. */
  1962. addEffectLayer(newEffectLayer: EffectLayer): void;
  1963. /**
  1964. * Adds the given action manager to this scene
  1965. * @param newActionManager The action manager to add
  1966. */
  1967. addActionManager(newActionManager: ActionManager): void;
  1968. /**
  1969. * Adds the given texture to this scene.
  1970. * @param newTexture The texture to add
  1971. */
  1972. addTexture(newTexture: BaseTexture): void;
  1973. /**
  1974. * Switch active camera
  1975. * @param newCamera defines the new active camera
  1976. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1977. */
  1978. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1979. /**
  1980. * sets the active camera of the scene using its ID
  1981. * @param id defines the camera's ID
  1982. * @return the new active camera or null if none found.
  1983. */
  1984. setActiveCameraByID(id: string): Nullable<Camera>;
  1985. /**
  1986. * sets the active camera of the scene using its name
  1987. * @param name defines the camera's name
  1988. * @returns the new active camera or null if none found.
  1989. */
  1990. setActiveCameraByName(name: string): Nullable<Camera>;
  1991. /**
  1992. * get an animation group using its name
  1993. * @param name defines the material's name
  1994. * @return the animation group or null if none found.
  1995. */
  1996. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1997. /**
  1998. * get a material using its id
  1999. * @param id defines the material's ID
  2000. * @return the material or null if none found.
  2001. */
  2002. getMaterialByID(id: string): Nullable<Material>;
  2003. /**
  2004. * Gets a material using its name
  2005. * @param name defines the material's name
  2006. * @return the material or null if none found.
  2007. */
  2008. getMaterialByName(name: string): Nullable<Material>;
  2009. /**
  2010. * Gets a lens flare system using its name
  2011. * @param name defines the name to look for
  2012. * @returns the lens flare system or null if not found
  2013. */
  2014. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2015. /**
  2016. * Gets a lens flare system using its id
  2017. * @param id defines the id to look for
  2018. * @returns the lens flare system or null if not found
  2019. */
  2020. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2021. /**
  2022. * Gets a camera using its id
  2023. * @param id defines the id to look for
  2024. * @returns the camera or null if not found
  2025. */
  2026. getCameraByID(id: string): Nullable<Camera>;
  2027. /**
  2028. * Gets a camera using its unique id
  2029. * @param uniqueId defines the unique id to look for
  2030. * @returns the camera or null if not found
  2031. */
  2032. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2033. /**
  2034. * Gets a camera using its name
  2035. * @param name defines the camera's name
  2036. * @return the camera or null if none found.
  2037. */
  2038. getCameraByName(name: string): Nullable<Camera>;
  2039. /**
  2040. * Gets a bone using its id
  2041. * @param id defines the bone's id
  2042. * @return the bone or null if not found
  2043. */
  2044. getBoneByID(id: string): Nullable<Bone>;
  2045. /**
  2046. * Gets a bone using its id
  2047. * @param name defines the bone's name
  2048. * @return the bone or null if not found
  2049. */
  2050. getBoneByName(name: string): Nullable<Bone>;
  2051. /**
  2052. * Gets a light node using its name
  2053. * @param name defines the the light's name
  2054. * @return the light or null if none found.
  2055. */
  2056. getLightByName(name: string): Nullable<Light>;
  2057. /**
  2058. * Gets a light node using its id
  2059. * @param id defines the light's id
  2060. * @return the light or null if none found.
  2061. */
  2062. getLightByID(id: string): Nullable<Light>;
  2063. /**
  2064. * Gets a light node using its scene-generated unique ID
  2065. * @param uniqueId defines the light's unique id
  2066. * @return the light or null if none found.
  2067. */
  2068. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2069. /**
  2070. * Gets a particle system by id
  2071. * @param id defines the particle system id
  2072. * @return the corresponding system or null if none found
  2073. */
  2074. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2075. /**
  2076. * Gets a geometry using its ID
  2077. * @param id defines the geometry's id
  2078. * @return the geometry or null if none found.
  2079. */
  2080. getGeometryByID(id: string): Nullable<Geometry>;
  2081. /**
  2082. * Add a new geometry to this scene
  2083. * @param geometry defines the geometry to be added to the scene.
  2084. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2085. * @return a boolean defining if the geometry was added or not
  2086. */
  2087. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2088. /**
  2089. * Removes an existing geometry
  2090. * @param geometry defines the geometry to be removed from the scene
  2091. * @return a boolean defining if the geometry was removed or not
  2092. */
  2093. removeGeometry(geometry: Geometry): boolean;
  2094. /**
  2095. * Gets the list of geometries attached to the scene
  2096. * @returns an array of Geometry
  2097. */
  2098. getGeometries(): Geometry[];
  2099. /**
  2100. * Gets the first added mesh found of a given ID
  2101. * @param id defines the id to search for
  2102. * @return the mesh found or null if not found at all
  2103. */
  2104. getMeshByID(id: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a list of meshes using their id
  2107. * @param id defines the id to search for
  2108. * @returns a list of meshes
  2109. */
  2110. getMeshesByID(id: string): Array<AbstractMesh>;
  2111. /**
  2112. * Gets the first added transform node found of a given ID
  2113. * @param id defines the id to search for
  2114. * @return the found transform node or null if not found at all.
  2115. */
  2116. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2117. /**
  2118. * Gets a list of transform nodes using their id
  2119. * @param id defines the id to search for
  2120. * @returns a list of transform nodes
  2121. */
  2122. getTransformNodesByID(id: string): Array<TransformNode>;
  2123. /**
  2124. * Gets a mesh with its auto-generated unique id
  2125. * @param uniqueId defines the unique id to search for
  2126. * @return the found mesh or null if not found at all.
  2127. */
  2128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2129. /**
  2130. * Gets a the last added mesh using a given id
  2131. * @param id defines the id to search for
  2132. * @return the found mesh or null if not found at all.
  2133. */
  2134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2135. /**
  2136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2137. * @param id defines the id to search for
  2138. * @return the found node or null if not found at all
  2139. */
  2140. getLastEntryByID(id: string): Nullable<Node>;
  2141. /**
  2142. * Gets a node (Mesh, Camera, Light) using a given id
  2143. * @param id defines the id to search for
  2144. * @return the found node or null if not found at all
  2145. */
  2146. getNodeByID(id: string): Nullable<Node>;
  2147. /**
  2148. * Gets a node (Mesh, Camera, Light) using a given name
  2149. * @param name defines the name to search for
  2150. * @return the found node or null if not found at all.
  2151. */
  2152. getNodeByName(name: string): Nullable<Node>;
  2153. /**
  2154. * Gets a mesh using a given name
  2155. * @param name defines the name to search for
  2156. * @return the found mesh or null if not found at all.
  2157. */
  2158. getMeshByName(name: string): Nullable<AbstractMesh>;
  2159. /**
  2160. * Gets a transform node using a given name
  2161. * @param name defines the name to search for
  2162. * @return the found transform node or null if not found at all.
  2163. */
  2164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2165. /**
  2166. * Gets a sound using a given name
  2167. * @param name defines the name to search for
  2168. * @return the found sound or null if not found at all.
  2169. */
  2170. getSoundByName(name: string): Nullable<Sound>;
  2171. /**
  2172. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2173. * @param id defines the id to search for
  2174. * @return the found skeleton or null if not found at all.
  2175. */
  2176. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2177. /**
  2178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2179. * @param id defines the id to search for
  2180. * @return the found skeleton or null if not found at all.
  2181. */
  2182. getSkeletonById(id: string): Nullable<Skeleton>;
  2183. /**
  2184. * Gets a skeleton using a given name
  2185. * @param name defines the name to search for
  2186. * @return the found skeleton or null if not found at all.
  2187. */
  2188. getSkeletonByName(name: string): Nullable<Skeleton>;
  2189. /**
  2190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2191. * @param id defines the id to search for
  2192. * @return the found morph target manager or null if not found at all.
  2193. */
  2194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2195. /**
  2196. * Gets a boolean indicating if the given mesh is active
  2197. * @param mesh defines the mesh to look for
  2198. * @returns true if the mesh is in the active list
  2199. */
  2200. isActiveMesh(mesh: AbstractMesh): boolean;
  2201. /**
  2202. * Return a the first highlight layer of the scene with a given name.
  2203. * @param name The name of the highlight layer to look for.
  2204. * @return The highlight layer if found otherwise null.
  2205. */
  2206. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2207. /**
  2208. * Return a the first highlight layer of the scene with a given name.
  2209. * @param name The name of the highlight layer to look for.
  2210. * @return The highlight layer if found otherwise null.
  2211. */
  2212. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2213. /**
  2214. * Return a unique id as a string which can serve as an identifier for the scene
  2215. */
  2216. readonly uid: string;
  2217. /**
  2218. * Add an externaly attached data from its key.
  2219. * This method call will fail and return false, if such key already exists.
  2220. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2221. * @param key the unique key that identifies the data
  2222. * @param data the data object to associate to the key for this Engine instance
  2223. * @return true if no such key were already present and the data was added successfully, false otherwise
  2224. */
  2225. addExternalData<T>(key: string, data: T): boolean;
  2226. /**
  2227. * Get an externaly attached data from its key
  2228. * @param key the unique key that identifies the data
  2229. * @return the associated data, if present (can be null), or undefined if not present
  2230. */
  2231. getExternalData<T>(key: string): Nullable<T>;
  2232. /**
  2233. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2234. * @param key the unique key that identifies the data
  2235. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2236. * @return the associated data, can be null if the factory returned null.
  2237. */
  2238. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2239. /**
  2240. * Remove an externaly attached data from the Engine instance
  2241. * @param key the unique key that identifies the data
  2242. * @return true if the data was successfully removed, false if it doesn't exist
  2243. */
  2244. removeExternalData(key: string): boolean;
  2245. private _evaluateSubMesh(subMesh, mesh);
  2246. /**
  2247. * Clear the processed materials smart array preventing retention point in material dispose.
  2248. */
  2249. freeProcessedMaterials(): void;
  2250. /**
  2251. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2252. */
  2253. freeActiveMeshes(): void;
  2254. /**
  2255. * Clear the info related to rendering groups preventing retention points during dispose.
  2256. */
  2257. freeRenderingGroups(): void;
  2258. /** @hidden */
  2259. _isInIntermediateRendering(): boolean;
  2260. private _activeMeshCandidateProvider;
  2261. /**
  2262. * Defines the current active mesh candidate provider
  2263. * @param provider defines the provider to use
  2264. */
  2265. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2266. /**
  2267. * Gets the current active mesh candidate provider
  2268. * @returns the current active mesh candidate provider
  2269. */
  2270. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2271. private _activeMeshesFrozen;
  2272. /**
  2273. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2274. * @returns the current scene
  2275. */
  2276. freezeActiveMeshes(): Scene;
  2277. /**
  2278. * Use this function to restart evaluating active meshes on every frame
  2279. * @returns the current scene
  2280. */
  2281. unfreezeActiveMeshes(): Scene;
  2282. private _evaluateActiveMeshes();
  2283. private _activeMesh(sourceMesh, mesh);
  2284. /**
  2285. * Update the transform matrix to update from the current active camera
  2286. * @param force defines a boolean used to force the update even if cache is up to date
  2287. */
  2288. updateTransformMatrix(force?: boolean): void;
  2289. /**
  2290. * 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)
  2291. * @param alternateCamera defines the camera to use
  2292. */
  2293. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2294. private _renderForCamera(camera, rigParent?);
  2295. private _processSubCameras(camera);
  2296. private _checkIntersections();
  2297. /**
  2298. * Render the scene
  2299. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2300. */
  2301. render(updateCameras?: boolean): void;
  2302. private _updateAudioParameters();
  2303. /**
  2304. * Gets or sets if audio support is enabled
  2305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2306. */
  2307. audioEnabled: boolean;
  2308. private _disableAudio();
  2309. private _enableAudio();
  2310. /**
  2311. * Gets or sets if audio will be output to headphones
  2312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2313. */
  2314. headphone: boolean;
  2315. private _switchAudioModeForHeadphones();
  2316. private _switchAudioModeForNormalSpeakers();
  2317. /**
  2318. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2319. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2320. * @returns the created depth renderer
  2321. */
  2322. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2323. /**
  2324. * Disables a depth renderer for a given camera
  2325. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2326. */
  2327. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2328. /**
  2329. * Enables a GeometryBufferRender and associates it with the scene
  2330. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2331. * @returns the GeometryBufferRenderer
  2332. */
  2333. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2334. /**
  2335. * Disables the GeometryBufferRender associated with the scene
  2336. */
  2337. disableGeometryBufferRenderer(): void;
  2338. /**
  2339. * Freeze all materials
  2340. * A frozen material will not be updatable but should be faster to render
  2341. */
  2342. freezeMaterials(): void;
  2343. /**
  2344. * Unfreeze all materials
  2345. * A frozen material will not be updatable but should be faster to render
  2346. */
  2347. unfreezeMaterials(): void;
  2348. /**
  2349. * Releases all held ressources
  2350. */
  2351. dispose(): void;
  2352. /**
  2353. * Gets if the scene is already disposed
  2354. */
  2355. readonly isDisposed: boolean;
  2356. /**
  2357. * Releases sounds & soundtracks
  2358. */
  2359. disposeSounds(): void;
  2360. /**
  2361. * Call this function to reduce memory footprint of the scene.
  2362. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2363. */
  2364. clearCachedVertexData(): void;
  2365. /**
  2366. * This function will remove the local cached buffer data from texture.
  2367. * It will save memory but will prevent the texture from being rebuilt
  2368. */
  2369. cleanCachedTextureBuffer(): void;
  2370. /**
  2371. * Get the world extend vectors with an optional filter
  2372. *
  2373. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2374. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2375. */
  2376. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2377. min: Vector3;
  2378. max: Vector3;
  2379. };
  2380. /**
  2381. * Creates or updates the octree used to boost selection (picking)
  2382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2383. * @param maxCapacity defines the maximum capacity per leaf
  2384. * @param maxDepth defines the maximum depth of the octree
  2385. * @returns an octree of AbstractMesh
  2386. */
  2387. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2388. /**
  2389. * Creates a ray that can be used to pick in the scene
  2390. * @param x defines the x coordinate of the origin (on-screen)
  2391. * @param y defines the y coordinate of the origin (on-screen)
  2392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2393. * @param camera defines the camera to use for the picking
  2394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2395. * @returns a Ray
  2396. */
  2397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2398. /**
  2399. * Creates a ray that can be used to pick in the scene
  2400. * @param x defines the x coordinate of the origin (on-screen)
  2401. * @param y defines the y coordinate of the origin (on-screen)
  2402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2403. * @param result defines the ray where to store the picking ray
  2404. * @param camera defines the camera to use for the picking
  2405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2406. * @returns the current scene
  2407. */
  2408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2409. /**
  2410. * Creates a ray that can be used to pick in the scene
  2411. * @param x defines the x coordinate of the origin (on-screen)
  2412. * @param y defines the y coordinate of the origin (on-screen)
  2413. * @param camera defines the camera to use for the picking
  2414. * @returns a Ray
  2415. */
  2416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2417. /**
  2418. * Creates a ray that can be used to pick in the scene
  2419. * @param x defines the x coordinate of the origin (on-screen)
  2420. * @param y defines the y coordinate of the origin (on-screen)
  2421. * @param result defines the ray where to store the picking ray
  2422. * @param camera defines the camera to use for the picking
  2423. * @returns the current scene
  2424. */
  2425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2426. private _internalPick(rayFunction, predicate?, fastCheck?);
  2427. private _internalMultiPick(rayFunction, predicate?);
  2428. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2429. private _tempPickingRay;
  2430. /** Launch a ray to try to pick a mesh in the scene
  2431. * @param x position on screen
  2432. * @param y position on screen
  2433. * @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
  2434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2435. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2436. * @returns a PickingInfo
  2437. */
  2438. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2439. /** Launch a ray to try to pick a sprite in the scene
  2440. * @param x position on screen
  2441. * @param y position on screen
  2442. * @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
  2443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2445. * @returns a PickingInfo
  2446. */
  2447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2448. private _cachedRayForTransform;
  2449. /** Use the given ray to pick a mesh in the scene
  2450. * @param ray The ray to use to pick meshes
  2451. * @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
  2452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2453. * @returns a PickingInfo
  2454. */
  2455. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2456. /**
  2457. * Launch a ray to try to pick a mesh in the scene
  2458. * @param x X position on screen
  2459. * @param y Y position on screen
  2460. * @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
  2461. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2462. * @returns an array of PickingInfo
  2463. */
  2464. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2465. /**
  2466. * Launch a ray to try to pick a mesh in the scene
  2467. * @param ray Ray to use
  2468. * @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
  2469. * @returns an array of PickingInfo
  2470. */
  2471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2472. /**
  2473. * Force the value of meshUnderPointer
  2474. * @param mesh defines the mesh to use
  2475. */
  2476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2477. /**
  2478. * Gets the mesh under the pointer
  2479. * @returns a Mesh or null if no mesh is under the pointer
  2480. */
  2481. getPointerOverMesh(): Nullable<AbstractMesh>;
  2482. /**
  2483. * Force the sprite under the pointer
  2484. * @param sprite defines the sprite to use
  2485. */
  2486. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2487. /**
  2488. * Gets the sprite under the pointer
  2489. * @returns a Sprite or null if no sprite is under the pointer
  2490. */
  2491. getPointerOverSprite(): Nullable<Sprite>;
  2492. /**
  2493. * Gets the current physics engine
  2494. * @returns a PhysicsEngine or null if none attached
  2495. */
  2496. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2497. /**
  2498. * Enables physics to the current scene
  2499. * @param gravity defines the scene's gravity for the physics engine
  2500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2501. * @return a boolean indicating if the physics engine was initialized
  2502. */
  2503. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2504. /**
  2505. * Disables and disposes the physics engine associated with the scene
  2506. */
  2507. disablePhysicsEngine(): void;
  2508. /**
  2509. * Gets a boolean indicating if there is an active physics engine
  2510. * @returns a boolean indicating if there is an active physics engine
  2511. */
  2512. isPhysicsEnabled(): boolean;
  2513. /**
  2514. * Deletes a physics compound impostor
  2515. * @param compound defines the compound to delete
  2516. */
  2517. deleteCompoundImpostor(compound: any): void;
  2518. /** @hidden */
  2519. _rebuildGeometries(): void;
  2520. /** @hidden */
  2521. _rebuildTextures(): void;
  2522. /**
  2523. * Creates a default light for the scene.
  2524. * @param replace Whether to replace the existing lights in the scene.
  2525. */
  2526. createDefaultLight(replace?: boolean): void;
  2527. /**
  2528. * Creates a default camera for the scene.
  2529. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2530. * @param replace Whether to replace the existing active camera in the scene.
  2531. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2532. */
  2533. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2534. /**
  2535. * Creates a default camera and a default light
  2536. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2537. * @param replace defines if the camera and/or light will replace the existing ones
  2538. * @param attachCameraControls defines if attachControl will be called on the new camera
  2539. */
  2540. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2541. /**
  2542. * Creates a new sky box
  2543. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2544. * @param environmentTexture defines the texture to use as environment texture
  2545. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2546. * @param scale defines the overall scale of the skybox
  2547. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2548. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2549. * @returns a new mesh holding the sky box
  2550. */
  2551. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2552. /**
  2553. * Creates a new environment
  2554. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2555. * @param options defines the options you can use to configure the environment
  2556. * @returns the new EnvironmentHelper
  2557. */
  2558. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2559. /**
  2560. * Creates a new VREXperienceHelper
  2561. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2562. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2563. * @returns a new VREXperienceHelper
  2564. */
  2565. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2566. private _getByTags(list, tagsQuery, forEach?);
  2567. /**
  2568. * Get a list of meshes by tags
  2569. * @param tagsQuery defines the tags query to use
  2570. * @param forEach defines a predicate used to filter results
  2571. * @returns an array of Mesh
  2572. */
  2573. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2574. /**
  2575. * Get a list of cameras by tags
  2576. * @param tagsQuery defines the tags query to use
  2577. * @param forEach defines a predicate used to filter results
  2578. * @returns an array of Camera
  2579. */
  2580. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2581. /**
  2582. * Get a list of lights by tags
  2583. * @param tagsQuery defines the tags query to use
  2584. * @param forEach defines a predicate used to filter results
  2585. * @returns an array of Light
  2586. */
  2587. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2588. /**
  2589. * Get a list of materials by tags
  2590. * @param tagsQuery defines the tags query to use
  2591. * @param forEach defines a predicate used to filter results
  2592. * @returns an array of Material
  2593. */
  2594. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2595. /**
  2596. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2597. * This allowed control for front to back rendering or reversly depending of the special needs.
  2598. *
  2599. * @param renderingGroupId The rendering group id corresponding to its index
  2600. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2601. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2602. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2603. */
  2604. 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;
  2605. /**
  2606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2607. *
  2608. * @param renderingGroupId The rendering group id corresponding to its index
  2609. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2610. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2611. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2612. */
  2613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2614. /**
  2615. * Will flag all materials as dirty to trigger new shader compilation
  2616. * @param flag defines the flag used to specify which material part must be marked as dirty
  2617. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2618. */
  2619. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2620. /** @hidden */
  2621. _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;
  2622. /** @hidden */
  2623. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2624. }
  2625. }
  2626. declare module BABYLON {
  2627. type Nullable<T> = T | null;
  2628. type float = number;
  2629. type double = number;
  2630. type int = number;
  2631. type FloatArray = number[] | Float32Array;
  2632. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2633. /**
  2634. * Alias for types that can be used by a Buffer or VertexBuffer.
  2635. */
  2636. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2637. }
  2638. declare module BABYLON {
  2639. /**
  2640. * The action to be carried out following a trigger
  2641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2642. */
  2643. class Action {
  2644. /** the trigger, with or without parameters, for the action */
  2645. triggerOptions: any;
  2646. /**
  2647. * Trigger for the action
  2648. */
  2649. trigger: number;
  2650. /**
  2651. * Internal only - manager for action
  2652. * @hidden
  2653. */
  2654. _actionManager: ActionManager;
  2655. private _nextActiveAction;
  2656. private _child;
  2657. private _condition?;
  2658. private _triggerParameter;
  2659. /**
  2660. * An event triggered prior to action being executed.
  2661. */
  2662. onBeforeExecuteObservable: Observable<Action>;
  2663. /**
  2664. * Creates a new Action
  2665. * @param triggerOptions the trigger, with or without parameters, for the action
  2666. * @param condition an optional determinant of action
  2667. */
  2668. constructor(
  2669. /** the trigger, with or without parameters, for the action */
  2670. triggerOptions: any, condition?: Condition);
  2671. /**
  2672. * Internal only
  2673. * @hidden
  2674. */
  2675. _prepare(): void;
  2676. /**
  2677. * Gets the trigger parameters
  2678. * @returns the trigger parameters
  2679. */
  2680. getTriggerParameter(): any;
  2681. /**
  2682. * Internal only - executes current action event
  2683. * @hidden
  2684. */
  2685. _executeCurrent(evt?: ActionEvent): void;
  2686. /**
  2687. * Execute placeholder for child classes
  2688. * @param evt optional action event
  2689. */
  2690. execute(evt?: ActionEvent): void;
  2691. /**
  2692. * Skips to next active action
  2693. */
  2694. skipToNextActiveAction(): void;
  2695. /**
  2696. * Adds action to chain of actions, may be a DoNothingAction
  2697. * @param action defines the next action to execute
  2698. * @returns The action passed in
  2699. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2700. */
  2701. then(action: Action): Action;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getProperty(propertyPath: string): string;
  2707. /**
  2708. * Internal only
  2709. * @hidden
  2710. */
  2711. _getEffectiveTarget(target: any, propertyPath: string): any;
  2712. /**
  2713. * Serialize placeholder for child classes
  2714. * @param parent of child
  2715. * @returns the serialized object
  2716. */
  2717. serialize(parent: any): any;
  2718. /**
  2719. * Internal only called by serialize
  2720. * @hidden
  2721. */
  2722. protected _serialize(serializedAction: any, parent?: any): any;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _SerializeValueAsString: (value: any) => string;
  2728. /**
  2729. * Internal only
  2730. * @hidden
  2731. */
  2732. static _GetTargetProperty: (target: Scene | Node) => {
  2733. name: string;
  2734. targetType: string;
  2735. value: string;
  2736. };
  2737. }
  2738. }
  2739. declare module BABYLON {
  2740. /**
  2741. * ActionEvent is the event being sent when an action is triggered.
  2742. */
  2743. class ActionEvent {
  2744. /** The mesh or sprite that triggered the action */
  2745. source: any;
  2746. /** The X mouse cursor position at the time of the event */
  2747. pointerX: number;
  2748. /** The Y mouse cursor position at the time of the event */
  2749. pointerY: number;
  2750. /** The mesh that is currently pointed at (can be null) */
  2751. meshUnderPointer: Nullable<AbstractMesh>;
  2752. /** the original (browser) event that triggered the ActionEvent */
  2753. sourceEvent: any;
  2754. /** additional data for the event */
  2755. additionalData: any;
  2756. /**
  2757. * Creates a new ActionEvent
  2758. * @param source The mesh or sprite that triggered the action
  2759. * @param pointerX The X mouse cursor position at the time of the event
  2760. * @param pointerY The Y mouse cursor position at the time of the event
  2761. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2762. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2763. * @param additionalData additional data for the event
  2764. */
  2765. constructor(
  2766. /** The mesh or sprite that triggered the action */
  2767. source: any,
  2768. /** The X mouse cursor position at the time of the event */
  2769. pointerX: number,
  2770. /** The Y mouse cursor position at the time of the event */
  2771. pointerY: number,
  2772. /** The mesh that is currently pointed at (can be null) */
  2773. meshUnderPointer: Nullable<AbstractMesh>,
  2774. /** the original (browser) event that triggered the ActionEvent */
  2775. sourceEvent?: any,
  2776. /** additional data for the event */
  2777. additionalData?: any);
  2778. /**
  2779. * Helper function to auto-create an ActionEvent from a source mesh.
  2780. * @param source The source mesh that triggered the event
  2781. * @param evt The original (browser) event
  2782. * @param additionalData additional data for the event
  2783. * @returns the new ActionEvent
  2784. */
  2785. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2786. /**
  2787. * Helper function to auto-create an ActionEvent from a source sprite
  2788. * @param source The source sprite that triggered the event
  2789. * @param scene Scene associated with the sprite
  2790. * @param evt The original (browser) event
  2791. * @param additionalData additional data for the event
  2792. * @returns the new ActionEvent
  2793. */
  2794. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2795. /**
  2796. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2797. * @param scene the scene where the event occurred
  2798. * @param evt The original (browser) event
  2799. * @returns the new ActionEvent
  2800. */
  2801. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2802. /**
  2803. * Helper function to auto-create an ActionEvent from a primitive
  2804. * @param prim defines the target primitive
  2805. * @param pointerPos defines the pointer position
  2806. * @param evt The original (browser) event
  2807. * @param additionalData additional data for the event
  2808. * @returns the new ActionEvent
  2809. */
  2810. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2811. }
  2812. /**
  2813. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2814. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2816. */
  2817. class ActionManager {
  2818. private static _NothingTrigger;
  2819. private static _OnPickTrigger;
  2820. private static _OnLeftPickTrigger;
  2821. private static _OnRightPickTrigger;
  2822. private static _OnCenterPickTrigger;
  2823. private static _OnPickDownTrigger;
  2824. private static _OnDoublePickTrigger;
  2825. private static _OnPickUpTrigger;
  2826. private static _OnLongPressTrigger;
  2827. private static _OnPointerOverTrigger;
  2828. private static _OnPointerOutTrigger;
  2829. private static _OnEveryFrameTrigger;
  2830. private static _OnIntersectionEnterTrigger;
  2831. private static _OnIntersectionExitTrigger;
  2832. private static _OnKeyDownTrigger;
  2833. private static _OnKeyUpTrigger;
  2834. private static _OnPickOutTrigger;
  2835. /**
  2836. * Nothing
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly NothingTrigger: number;
  2840. /**
  2841. * On pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnPickTrigger: number;
  2845. /**
  2846. * On left pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnLeftPickTrigger: number;
  2850. /**
  2851. * On right pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnRightPickTrigger: number;
  2855. /**
  2856. * On center pick
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnCenterPickTrigger: number;
  2860. /**
  2861. * On pick down
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnPickDownTrigger: number;
  2865. /**
  2866. * On double pick
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnDoublePickTrigger: number;
  2870. /**
  2871. * On pick up
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickUpTrigger: number;
  2875. /**
  2876. * On pick out.
  2877. * This trigger will only be raised if you also declared a OnPickDown
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnPickOutTrigger: number;
  2881. /**
  2882. * On long press
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnLongPressTrigger: number;
  2886. /**
  2887. * On pointer over
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOverTrigger: number;
  2891. /**
  2892. * On pointer out
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnPointerOutTrigger: number;
  2896. /**
  2897. * On every frame
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnEveryFrameTrigger: number;
  2901. /**
  2902. * On intersection enter
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionEnterTrigger: number;
  2906. /**
  2907. * On intersection exit
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnIntersectionExitTrigger: number;
  2911. /**
  2912. * On key down
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyDownTrigger: number;
  2916. /**
  2917. * On key up
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnKeyUpTrigger: number;
  2921. /** Gets the list of active triggers */
  2922. static Triggers: {
  2923. [key: string]: number;
  2924. };
  2925. /** Gets the list of actions */
  2926. actions: Action[];
  2927. /** Gets the cursor to use when hovering items */
  2928. hoverCursor: string;
  2929. private _scene;
  2930. /**
  2931. * Creates a new action manager
  2932. * @param scene defines the hosting scene
  2933. */
  2934. constructor(scene: Scene);
  2935. /**
  2936. * Releases all associated resources
  2937. */
  2938. dispose(): void;
  2939. /**
  2940. * Gets hosting scene
  2941. * @returns the hosting scene
  2942. */
  2943. getScene(): Scene;
  2944. /**
  2945. * Does this action manager handles actions of any of the given triggers
  2946. * @param triggers defines the triggers to be tested
  2947. * @return a boolean indicating whether one (or more) of the triggers is handled
  2948. */
  2949. hasSpecificTriggers(triggers: number[]): boolean;
  2950. /**
  2951. * Does this action manager handles actions of a given trigger
  2952. * @param trigger defines the trigger to be tested
  2953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2954. * @return whether the trigger is handled
  2955. */
  2956. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2957. /**
  2958. * Does this action manager has pointer triggers
  2959. */
  2960. readonly hasPointerTriggers: boolean;
  2961. /**
  2962. * Does this action manager has pick triggers
  2963. */
  2964. readonly hasPickTriggers: boolean;
  2965. /**
  2966. * Does exist one action manager with at least one trigger
  2967. **/
  2968. static readonly HasTriggers: boolean;
  2969. /**
  2970. * Does exist one action manager with at least one pick trigger
  2971. **/
  2972. static readonly HasPickTriggers: boolean;
  2973. /**
  2974. * Does exist one action manager that handles actions of a given trigger
  2975. * @param trigger defines the trigger to be tested
  2976. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2977. **/
  2978. static HasSpecificTrigger(trigger: number): boolean;
  2979. /**
  2980. * Registers an action to this action manager
  2981. * @param action defines the action to be registered
  2982. * @return the action amended (prepared) after registration
  2983. */
  2984. registerAction(action: Action): Nullable<Action>;
  2985. /**
  2986. * Unregisters an action to this action manager
  2987. * @param action defines the action to be unregistered
  2988. * @return a boolean indicating whether the action has been unregistered
  2989. */
  2990. unregisterAction(action: Action): Boolean;
  2991. /**
  2992. * Process a specific trigger
  2993. * @param trigger defines the trigger to process
  2994. * @param evt defines the event details to be processed
  2995. */
  2996. processTrigger(trigger: number, evt?: ActionEvent): void;
  2997. /** @hidden */
  2998. _getEffectiveTarget(target: any, propertyPath: string): any;
  2999. /** @hidden */
  3000. _getProperty(propertyPath: string): string;
  3001. /**
  3002. * Serialize this manager to a JSON object
  3003. * @param name defines the property name to store this manager
  3004. * @returns a JSON representation of this manager
  3005. */
  3006. serialize(name: string): any;
  3007. /**
  3008. * Creates a new ActionManager from a JSON data
  3009. * @param parsedActions defines the JSON data to read from
  3010. * @param object defines the hosting mesh
  3011. * @param scene defines the hosting scene
  3012. */
  3013. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3014. /**
  3015. * Get a trigger name by index
  3016. * @param trigger defines the trigger index
  3017. * @returns a trigger name
  3018. */
  3019. static GetTriggerName(trigger: number): string;
  3020. }
  3021. }
  3022. declare module BABYLON {
  3023. /**
  3024. * A Condition applied to an Action
  3025. */
  3026. class Condition {
  3027. /**
  3028. * Internal only - manager for action
  3029. * @hidden
  3030. */
  3031. _actionManager: ActionManager;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _evaluationId: number;
  3037. /**
  3038. * Internal only
  3039. * @hidden
  3040. */
  3041. _currentResult: boolean;
  3042. /**
  3043. * Creates a new Condition
  3044. * @param actionManager the manager of the action the condition is applied to
  3045. */
  3046. constructor(actionManager: ActionManager);
  3047. /**
  3048. * Check if the current condition is valid
  3049. * @returns a boolean
  3050. */
  3051. isValid(): boolean;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getProperty(propertyPath: string): string;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. _getEffectiveTarget(target: any, propertyPath: string): any;
  3062. /**
  3063. * Serialize placeholder for child classes
  3064. * @returns the serialized object
  3065. */
  3066. serialize(): any;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. protected _serialize(serializedCondition: any): any;
  3072. }
  3073. /**
  3074. * Defines specific conditional operators as extensions of Condition
  3075. */
  3076. class ValueCondition extends Condition {
  3077. /** path to specify the property of the target the conditional operator uses */
  3078. propertyPath: string;
  3079. /** the value compared by the conditional operator against the current value of the property */
  3080. value: any;
  3081. /** the conditional operator, default ValueCondition.IsEqual */
  3082. operator: number;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsEqual;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsDifferent;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsGreater;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsLesser;
  3103. /**
  3104. * returns the number for IsEqual
  3105. */
  3106. static readonly IsEqual: number;
  3107. /**
  3108. * Returns the number for IsDifferent
  3109. */
  3110. static readonly IsDifferent: number;
  3111. /**
  3112. * Returns the number for IsGreater
  3113. */
  3114. static readonly IsGreater: number;
  3115. /**
  3116. * Returns the number for IsLesser
  3117. */
  3118. static readonly IsLesser: number;
  3119. /**
  3120. * Internal only The action manager for the condition
  3121. * @hidden
  3122. */
  3123. _actionManager: ActionManager;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _target;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _effectiveTarget;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _property;
  3139. /**
  3140. * Creates a new ValueCondition
  3141. * @param actionManager manager for the action the condition applies to
  3142. * @param target for the action
  3143. * @param propertyPath path to specify the property of the target the conditional operator uses
  3144. * @param value the value compared by the conditional operator against the current value of the property
  3145. * @param operator the conditional operator, default ValueCondition.IsEqual
  3146. */
  3147. constructor(actionManager: ActionManager, target: any,
  3148. /** path to specify the property of the target the conditional operator uses */
  3149. propertyPath: string,
  3150. /** the value compared by the conditional operator against the current value of the property */
  3151. value: any,
  3152. /** the conditional operator, default ValueCondition.IsEqual */
  3153. operator?: number);
  3154. /**
  3155. * Compares the given value with the property value for the specified conditional operator
  3156. * @returns the result of the comparison
  3157. */
  3158. isValid(): boolean;
  3159. /**
  3160. * Serialize the ValueCondition into a JSON compatible object
  3161. * @returns serialization object
  3162. */
  3163. serialize(): any;
  3164. /**
  3165. * Gets the name of the conditional operator for the ValueCondition
  3166. * @param operator the conditional operator
  3167. * @returns the name
  3168. */
  3169. static GetOperatorName(operator: number): string;
  3170. }
  3171. /**
  3172. * Defines a predicate condition as an extension of Condition
  3173. */
  3174. class PredicateCondition extends Condition {
  3175. /** defines the predicate function used to validate the condition */
  3176. predicate: () => boolean;
  3177. /**
  3178. * Internal only - manager for action
  3179. * @hidden
  3180. */
  3181. _actionManager: ActionManager;
  3182. /**
  3183. * Creates a new PredicateCondition
  3184. * @param actionManager manager for the action the condition applies to
  3185. * @param predicate defines the predicate function used to validate the condition
  3186. */
  3187. constructor(actionManager: ActionManager,
  3188. /** defines the predicate function used to validate the condition */
  3189. predicate: () => boolean);
  3190. /**
  3191. * @returns the validity of the predicate condition
  3192. */
  3193. isValid(): boolean;
  3194. }
  3195. /**
  3196. * Defines a state condition as an extension of Condition
  3197. */
  3198. class StateCondition extends Condition {
  3199. value: string;
  3200. /**
  3201. * Internal only - manager for action
  3202. * @hidden
  3203. */
  3204. _actionManager: ActionManager;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _target;
  3210. /**
  3211. * Creates a new StateCondition
  3212. * @param actionManager manager for the action the condition applies to
  3213. * @param target of the condition
  3214. * @param value to compare with target state
  3215. */
  3216. constructor(actionManager: ActionManager, target: any, value: string);
  3217. /**
  3218. * @returns the validity of the state
  3219. */
  3220. isValid(): boolean;
  3221. /**
  3222. * Serialize the StateCondition into a JSON compatible object
  3223. * @returns serialization object
  3224. */
  3225. serialize(): any;
  3226. }
  3227. }
  3228. declare module BABYLON {
  3229. class SwitchBooleanAction extends Action {
  3230. propertyPath: string;
  3231. private _target;
  3232. private _effectiveTarget;
  3233. private _property;
  3234. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3235. _prepare(): void;
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class SetStateAction extends Action {
  3240. value: string;
  3241. private _target;
  3242. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3243. execute(): void;
  3244. serialize(parent: any): any;
  3245. }
  3246. class SetValueAction extends Action {
  3247. propertyPath: string;
  3248. value: any;
  3249. private _target;
  3250. private _effectiveTarget;
  3251. private _property;
  3252. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3253. _prepare(): void;
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class IncrementValueAction extends Action {
  3258. propertyPath: string;
  3259. value: any;
  3260. private _target;
  3261. private _effectiveTarget;
  3262. private _property;
  3263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3264. _prepare(): void;
  3265. execute(): void;
  3266. serialize(parent: any): any;
  3267. }
  3268. class PlayAnimationAction extends Action {
  3269. from: number;
  3270. to: number;
  3271. loop: boolean | undefined;
  3272. private _target;
  3273. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class StopAnimationAction extends Action {
  3279. private _target;
  3280. constructor(triggerOptions: any, target: any, condition?: Condition);
  3281. _prepare(): void;
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class DoNothingAction extends Action {
  3286. constructor(triggerOptions?: any, condition?: Condition);
  3287. execute(): void;
  3288. serialize(parent: any): any;
  3289. }
  3290. class CombineAction extends Action {
  3291. children: Action[];
  3292. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3293. _prepare(): void;
  3294. execute(evt: ActionEvent): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class ExecuteCodeAction extends Action {
  3298. func: (evt: ActionEvent) => void;
  3299. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3300. execute(evt: ActionEvent): void;
  3301. }
  3302. class SetParentAction extends Action {
  3303. private _parent;
  3304. private _target;
  3305. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3306. _prepare(): void;
  3307. execute(): void;
  3308. serialize(parent: any): any;
  3309. }
  3310. class PlaySoundAction extends Action {
  3311. private _sound;
  3312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3313. _prepare(): void;
  3314. execute(): void;
  3315. serialize(parent: any): any;
  3316. }
  3317. class StopSoundAction extends Action {
  3318. private _sound;
  3319. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3320. _prepare(): void;
  3321. execute(): void;
  3322. serialize(parent: any): any;
  3323. }
  3324. }
  3325. declare module BABYLON {
  3326. class InterpolateValueAction extends Action {
  3327. propertyPath: string;
  3328. value: any;
  3329. duration: number;
  3330. stopOtherAnimations: boolean | undefined;
  3331. onInterpolationDone: (() => void) | undefined;
  3332. private _target;
  3333. private _effectiveTarget;
  3334. private _property;
  3335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3337. _prepare(): void;
  3338. execute(): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. }
  3342. declare module BABYLON {
  3343. class Animatable {
  3344. target: any;
  3345. fromFrame: number;
  3346. toFrame: number;
  3347. loopAnimation: boolean;
  3348. onAnimationEnd: (() => void) | null | undefined;
  3349. private _localDelayOffset;
  3350. private _pausedDelay;
  3351. private _runtimeAnimations;
  3352. private _paused;
  3353. private _scene;
  3354. private _speedRatio;
  3355. private _weight;
  3356. private _syncRoot;
  3357. animationStarted: boolean;
  3358. /**
  3359. * Observer raised when the animation ends
  3360. */
  3361. onAnimationEndObservable: Observable<Animatable>;
  3362. /**
  3363. * Gets the root Animatable used to synchronize and normalize animations
  3364. */
  3365. readonly syncRoot: Animatable;
  3366. /**
  3367. * Gets the current frame of the first RuntimeAnimation
  3368. * Used to synchronize Animatables
  3369. */
  3370. readonly masterFrame: number;
  3371. /**
  3372. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3373. */
  3374. weight: number;
  3375. /**
  3376. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3377. */
  3378. speedRatio: number;
  3379. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3380. /**
  3381. * Synchronize and normalize current Animatable with a source Animatable
  3382. * This is useful when using animation weights and when animations are not of the same length
  3383. * @param root defines the root Animatable to synchronize with
  3384. * @returns the current Animatable
  3385. */
  3386. syncWith(root: Animatable): Animatable;
  3387. getAnimations(): RuntimeAnimation[];
  3388. appendAnimations(target: any, animations: Animation[]): void;
  3389. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3390. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3391. reset(): void;
  3392. enableBlending(blendingSpeed: number): void;
  3393. disableBlending(): void;
  3394. goToFrame(frame: number): void;
  3395. pause(): void;
  3396. restart(): void;
  3397. private _raiseOnAnimationEnd();
  3398. stop(animationName?: string): void;
  3399. /**
  3400. * Wait asynchronously for the animation to end
  3401. * @returns a promise which will be fullfilled when the animation ends
  3402. */
  3403. waitAsync(): Promise<Animatable>;
  3404. /** @hidden */
  3405. _animate(delay: number): boolean;
  3406. }
  3407. }
  3408. declare module BABYLON {
  3409. /**
  3410. * Represents the range of an animation
  3411. */
  3412. class AnimationRange {
  3413. /**The name of the animation range**/
  3414. name: string;
  3415. /**The starting frame of the animation */
  3416. from: number;
  3417. /**The ending frame of the animation*/
  3418. to: number;
  3419. /**
  3420. * Initializes the range of an animation
  3421. * @param name The name of the animation range
  3422. * @param from The starting frame of the animation
  3423. * @param to The ending frame of the animation
  3424. */
  3425. constructor(
  3426. /**The name of the animation range**/
  3427. name: string,
  3428. /**The starting frame of the animation */
  3429. from: number,
  3430. /**The ending frame of the animation*/
  3431. to: number);
  3432. /**
  3433. * Makes a copy of the animation range
  3434. * @returns A copy of the animation range
  3435. */
  3436. clone(): AnimationRange;
  3437. }
  3438. /**
  3439. * Composed of a frame, and an action function
  3440. */
  3441. class AnimationEvent {
  3442. /** The frame for which the event is triggered **/
  3443. frame: number;
  3444. /** The event to perform when triggered **/
  3445. action: () => void;
  3446. /** Specifies if the event should be triggered only once**/
  3447. onlyOnce: boolean | undefined;
  3448. /**
  3449. * Specifies if the animation event is done
  3450. */
  3451. isDone: boolean;
  3452. /**
  3453. * Initializes the animation event
  3454. * @param frame The frame for which the event is triggered
  3455. * @param action The event to perform when triggered
  3456. * @param onlyOnce Specifies if the event should be triggered only once
  3457. */
  3458. constructor(
  3459. /** The frame for which the event is triggered **/
  3460. frame: number,
  3461. /** The event to perform when triggered **/
  3462. action: () => void,
  3463. /** Specifies if the event should be triggered only once**/
  3464. onlyOnce?: boolean | undefined);
  3465. /** @hidden */
  3466. _clone(): AnimationEvent;
  3467. }
  3468. /**
  3469. * A cursor which tracks a point on a path
  3470. */
  3471. class PathCursor {
  3472. private path;
  3473. /**
  3474. * Stores path cursor callbacks for when an onchange event is triggered
  3475. */
  3476. private _onchange;
  3477. /**
  3478. * The value of the path cursor
  3479. */
  3480. value: number;
  3481. /**
  3482. * The animation array of the path cursor
  3483. */
  3484. animations: Animation[];
  3485. /**
  3486. * Initializes the path cursor
  3487. * @param path The path to track
  3488. */
  3489. constructor(path: Path2);
  3490. /**
  3491. * Gets the cursor point on the path
  3492. * @returns A point on the path cursor at the cursor location
  3493. */
  3494. getPoint(): Vector3;
  3495. /**
  3496. * Moves the cursor ahead by the step amount
  3497. * @param step The amount to move the cursor forward
  3498. * @returns This path cursor
  3499. */
  3500. moveAhead(step?: number): PathCursor;
  3501. /**
  3502. * Moves the cursor behind by the step amount
  3503. * @param step The amount to move the cursor back
  3504. * @returns This path cursor
  3505. */
  3506. moveBack(step?: number): PathCursor;
  3507. /**
  3508. * Moves the cursor by the step amount
  3509. * If the step amount is greater than one, an exception is thrown
  3510. * @param step The amount to move the cursor
  3511. * @returns This path cursor
  3512. */
  3513. move(step: number): PathCursor;
  3514. /**
  3515. * Ensures that the value is limited between zero and one
  3516. * @returns This path cursor
  3517. */
  3518. private ensureLimits();
  3519. /**
  3520. * Runs onchange callbacks on change (used by the animation engine)
  3521. * @returns This path cursor
  3522. */
  3523. private raiseOnChange();
  3524. /**
  3525. * Executes a function on change
  3526. * @param f A path cursor onchange callback
  3527. * @returns This path cursor
  3528. */
  3529. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3530. }
  3531. /**
  3532. * Defines an interface which represents an animation key frame
  3533. */
  3534. interface IAnimationKey {
  3535. /**
  3536. * Frame of the key frame
  3537. */
  3538. frame: number;
  3539. /**
  3540. * Value at the specifies key frame
  3541. */
  3542. value: any;
  3543. /**
  3544. * The input tangent for the cubic hermite spline
  3545. */
  3546. inTangent?: any;
  3547. /**
  3548. * The output tangent for the cubic hermite spline
  3549. */
  3550. outTangent?: any;
  3551. /**
  3552. * The animation interpolation type
  3553. */
  3554. interpolation?: AnimationKeyInterpolation;
  3555. }
  3556. /**
  3557. * Enum for the animation key frame interpolation type
  3558. */
  3559. enum AnimationKeyInterpolation {
  3560. /**
  3561. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3562. */
  3563. STEP = 1,
  3564. }
  3565. /**
  3566. * Class used to store any kind of animation
  3567. */
  3568. class Animation {
  3569. /**Name of the animation */
  3570. name: string;
  3571. /**Property to animate */
  3572. targetProperty: string;
  3573. /**The frames per second of the animation */
  3574. framePerSecond: number;
  3575. /**The data type of the animation */
  3576. dataType: number;
  3577. /**The loop mode of the animation */
  3578. loopMode: number | undefined;
  3579. /**Specifies if blending should be enabled */
  3580. enableBlending: boolean | undefined;
  3581. /**
  3582. * Use matrix interpolation instead of using direct key value when animating matrices
  3583. */
  3584. static AllowMatricesInterpolation: boolean;
  3585. /**
  3586. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3587. */
  3588. static AllowMatrixDecomposeForInterpolation: boolean;
  3589. /**
  3590. * Stores the key frames of the animation
  3591. */
  3592. private _keys;
  3593. /**
  3594. * Stores the easing function of the animation
  3595. */
  3596. private _easingFunction;
  3597. /**
  3598. * @hidden Internal use only
  3599. */
  3600. _runtimeAnimations: RuntimeAnimation[];
  3601. /**
  3602. * The set of event that will be linked to this animation
  3603. */
  3604. private _events;
  3605. /**
  3606. * Stores an array of target property paths
  3607. */
  3608. targetPropertyPath: string[];
  3609. /**
  3610. * Stores the blending speed of the animation
  3611. */
  3612. blendingSpeed: number;
  3613. /**
  3614. * Stores the animation ranges for the animation
  3615. */
  3616. private _ranges;
  3617. /**
  3618. * @hidden Internal use
  3619. */
  3620. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3621. /**
  3622. * Sets up an animation
  3623. * @param property The property to animate
  3624. * @param animationType The animation type to apply
  3625. * @param framePerSecond The frames per second of the animation
  3626. * @param easingFunction The easing function used in the animation
  3627. * @returns The created animation
  3628. */
  3629. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3630. /**
  3631. * Create and start an animation on a node
  3632. * @param name defines the name of the global animation that will be run on all nodes
  3633. * @param node defines the root node where the animation will take place
  3634. * @param targetProperty defines property to animate
  3635. * @param framePerSecond defines the number of frame per second yo use
  3636. * @param totalFrame defines the number of frames in total
  3637. * @param from defines the initial value
  3638. * @param to defines the final value
  3639. * @param loopMode defines which loop mode you want to use (off by default)
  3640. * @param easingFunction defines the easing function to use (linear by default)
  3641. * @param onAnimationEnd defines the callback to call when animation end
  3642. * @returns the animatable created for this animation
  3643. */
  3644. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3645. /**
  3646. * Create and start an animation on a node and its descendants
  3647. * @param name defines the name of the global animation that will be run on all nodes
  3648. * @param node defines the root node where the animation will take place
  3649. * @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
  3650. * @param targetProperty defines property to animate
  3651. * @param framePerSecond defines the number of frame per second to use
  3652. * @param totalFrame defines the number of frames in total
  3653. * @param from defines the initial value
  3654. * @param to defines the final value
  3655. * @param loopMode defines which loop mode you want to use (off by default)
  3656. * @param easingFunction defines the easing function to use (linear by default)
  3657. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3658. * @returns the list of animatables created for all nodes
  3659. * @example https://www.babylonjs-playground.com/#MH0VLI
  3660. */
  3661. 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[]>;
  3662. /**
  3663. * Creates a new animation, merges it with the existing animations and starts it
  3664. * @param name Name of the animation
  3665. * @param node Node which contains the scene that begins the animations
  3666. * @param targetProperty Specifies which property to animate
  3667. * @param framePerSecond The frames per second of the animation
  3668. * @param totalFrame The total number of frames
  3669. * @param from The frame at the beginning of the animation
  3670. * @param to The frame at the end of the animation
  3671. * @param loopMode Specifies the loop mode of the animation
  3672. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3673. * @param onAnimationEnd Callback to run once the animation is complete
  3674. * @returns Nullable animation
  3675. */
  3676. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3677. /**
  3678. * Transition property of an host to the target Value
  3679. * @param property The property to transition
  3680. * @param targetValue The target Value of the property
  3681. * @param host The object where the property to animate belongs
  3682. * @param scene Scene used to run the animation
  3683. * @param frameRate Framerate (in frame/s) to use
  3684. * @param transition The transition type we want to use
  3685. * @param duration The duration of the animation, in milliseconds
  3686. * @param onAnimationEnd Callback trigger at the end of the animation
  3687. * @returns Nullable animation
  3688. */
  3689. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3690. /**
  3691. * Return the array of runtime animations currently using this animation
  3692. */
  3693. readonly runtimeAnimations: RuntimeAnimation[];
  3694. /**
  3695. * Specifies if any of the runtime animations are currently running
  3696. */
  3697. readonly hasRunningRuntimeAnimations: boolean;
  3698. /**
  3699. * Initializes the animation
  3700. * @param name Name of the animation
  3701. * @param targetProperty Property to animate
  3702. * @param framePerSecond The frames per second of the animation
  3703. * @param dataType The data type of the animation
  3704. * @param loopMode The loop mode of the animation
  3705. * @param enableBlendings Specifies if blending should be enabled
  3706. */
  3707. constructor(
  3708. /**Name of the animation */
  3709. name: string,
  3710. /**Property to animate */
  3711. targetProperty: string,
  3712. /**The frames per second of the animation */
  3713. framePerSecond: number,
  3714. /**The data type of the animation */
  3715. dataType: number,
  3716. /**The loop mode of the animation */
  3717. loopMode?: number | undefined,
  3718. /**Specifies if blending should be enabled */
  3719. enableBlending?: boolean | undefined);
  3720. /**
  3721. * Converts the animation to a string
  3722. * @param fullDetails support for multiple levels of logging within scene loading
  3723. * @returns String form of the animation
  3724. */
  3725. toString(fullDetails?: boolean): string;
  3726. /**
  3727. * Add an event to this animation
  3728. * @param event Event to add
  3729. */
  3730. addEvent(event: AnimationEvent): void;
  3731. /**
  3732. * Remove all events found at the given frame
  3733. * @param frame The frame to remove events from
  3734. */
  3735. removeEvents(frame: number): void;
  3736. /**
  3737. * Retrieves all the events from the animation
  3738. * @returns Events from the animation
  3739. */
  3740. getEvents(): AnimationEvent[];
  3741. /**
  3742. * Creates an animation range
  3743. * @param name Name of the animation range
  3744. * @param from Starting frame of the animation range
  3745. * @param to Ending frame of the animation
  3746. */
  3747. createRange(name: string, from: number, to: number): void;
  3748. /**
  3749. * Deletes an animation range by name
  3750. * @param name Name of the animation range to delete
  3751. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3752. */
  3753. deleteRange(name: string, deleteFrames?: boolean): void;
  3754. /**
  3755. * Gets the animation range by name, or null if not defined
  3756. * @param name Name of the animation range
  3757. * @returns Nullable animation range
  3758. */
  3759. getRange(name: string): Nullable<AnimationRange>;
  3760. /**
  3761. * Gets the key frames from the animation
  3762. * @returns The key frames of the animation
  3763. */
  3764. getKeys(): Array<IAnimationKey>;
  3765. /**
  3766. * Gets the highest frame rate of the animation
  3767. * @returns Highest frame rate of the animation
  3768. */
  3769. getHighestFrame(): number;
  3770. /**
  3771. * Gets the easing function of the animation
  3772. * @returns Easing function of the animation
  3773. */
  3774. getEasingFunction(): IEasingFunction;
  3775. /**
  3776. * Sets the easing function of the animation
  3777. * @param easingFunction A custom mathematical formula for animation
  3778. */
  3779. setEasingFunction(easingFunction: EasingFunction): void;
  3780. /**
  3781. * Interpolates a scalar linearly
  3782. * @param startValue Start value of the animation curve
  3783. * @param endValue End value of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns Interpolated scalar value
  3786. */
  3787. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3788. /**
  3789. * Interpolates a scalar cubically
  3790. * @param startValue Start value of the animation curve
  3791. * @param outTangent End tangent of the animation
  3792. * @param endValue End value of the animation curve
  3793. * @param inTangent Start tangent of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns Interpolated scalar value
  3796. */
  3797. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3798. /**
  3799. * Interpolates a quaternion using a spherical linear interpolation
  3800. * @param startValue Start value of the animation curve
  3801. * @param endValue End value of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated quaternion value
  3804. */
  3805. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3806. /**
  3807. * Interpolates a quaternion cubically
  3808. * @param startValue Start value of the animation curve
  3809. * @param outTangent End tangent of the animation curve
  3810. * @param endValue End value of the animation curve
  3811. * @param inTangent Start tangent of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns Interpolated quaternion value
  3814. */
  3815. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3816. /**
  3817. * Interpolates a Vector3 linearl
  3818. * @param startValue Start value of the animation curve
  3819. * @param endValue End value of the animation curve
  3820. * @param gradient Scalar amount to interpolate
  3821. * @returns Interpolated scalar value
  3822. */
  3823. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3824. /**
  3825. * Interpolates a Vector3 cubically
  3826. * @param startValue Start value of the animation curve
  3827. * @param outTangent End tangent of the animation
  3828. * @param endValue End value of the animation curve
  3829. * @param inTangent Start tangent of the animation curve
  3830. * @param gradient Scalar amount to interpolate
  3831. * @returns InterpolatedVector3 value
  3832. */
  3833. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3834. /**
  3835. * Interpolates a Vector2 linearly
  3836. * @param startValue Start value of the animation curve
  3837. * @param endValue End value of the animation curve
  3838. * @param gradient Scalar amount to interpolate
  3839. * @returns Interpolated Vector2 value
  3840. */
  3841. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3842. /**
  3843. * Interpolates a Vector2 cubically
  3844. * @param startValue Start value of the animation curve
  3845. * @param outTangent End tangent of the animation
  3846. * @param endValue End value of the animation curve
  3847. * @param inTangent Start tangent of the animation curve
  3848. * @param gradient Scalar amount to interpolate
  3849. * @returns Interpolated Vector2 value
  3850. */
  3851. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3852. /**
  3853. * Interpolates a size linearly
  3854. * @param startValue Start value of the animation curve
  3855. * @param endValue End value of the animation curve
  3856. * @param gradient Scalar amount to interpolate
  3857. * @returns Interpolated Size value
  3858. */
  3859. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3860. /**
  3861. * Interpolates a Color3 linearly
  3862. * @param startValue Start value of the animation curve
  3863. * @param endValue End value of the animation curve
  3864. * @param gradient Scalar amount to interpolate
  3865. * @returns Interpolated Color3 value
  3866. */
  3867. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3868. /**
  3869. * @hidden Internal use only
  3870. */
  3871. _getKeyValue(value: any): any;
  3872. /**
  3873. * @hidden Internal use only
  3874. */
  3875. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3876. /**
  3877. * Defines the function to use to interpolate matrices
  3878. * @param startValue defines the start matrix
  3879. * @param endValue defines the end matrix
  3880. * @param gradient defines the gradient between both matrices
  3881. * @param result defines an optional target matrix where to store the interpolation
  3882. * @returns the interpolated matrix
  3883. */
  3884. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3885. /**
  3886. * Makes a copy of the animation
  3887. * @returns Cloned animation
  3888. */
  3889. clone(): Animation;
  3890. /**
  3891. * Sets the key frames of the animation
  3892. * @param values The animation key frames to set
  3893. */
  3894. setKeys(values: Array<IAnimationKey>): void;
  3895. /**
  3896. * Serializes the animation to an object
  3897. * @returns Serialized object
  3898. */
  3899. serialize(): any;
  3900. /**
  3901. * Float animation type
  3902. */
  3903. private static _ANIMATIONTYPE_FLOAT;
  3904. /**
  3905. * Vector3 animation type
  3906. */
  3907. private static _ANIMATIONTYPE_VECTOR3;
  3908. /**
  3909. * Quaternion animation type
  3910. */
  3911. private static _ANIMATIONTYPE_QUATERNION;
  3912. /**
  3913. * Matrix animation type
  3914. */
  3915. private static _ANIMATIONTYPE_MATRIX;
  3916. /**
  3917. * Color3 animation type
  3918. */
  3919. private static _ANIMATIONTYPE_COLOR3;
  3920. /**
  3921. * Vector2 animation type
  3922. */
  3923. private static _ANIMATIONTYPE_VECTOR2;
  3924. /**
  3925. * Size animation type
  3926. */
  3927. private static _ANIMATIONTYPE_SIZE;
  3928. /**
  3929. * Relative Loop Mode
  3930. */
  3931. private static _ANIMATIONLOOPMODE_RELATIVE;
  3932. /**
  3933. * Cycle Loop Mode
  3934. */
  3935. private static _ANIMATIONLOOPMODE_CYCLE;
  3936. /**
  3937. * Constant Loop Mode
  3938. */
  3939. private static _ANIMATIONLOOPMODE_CONSTANT;
  3940. /**
  3941. * Get the float animation type
  3942. */
  3943. static readonly ANIMATIONTYPE_FLOAT: number;
  3944. /**
  3945. * Get the Vector3 animation type
  3946. */
  3947. static readonly ANIMATIONTYPE_VECTOR3: number;
  3948. /**
  3949. * Get the Vectpr2 animation type
  3950. */
  3951. static readonly ANIMATIONTYPE_VECTOR2: number;
  3952. /**
  3953. * Get the Size animation type
  3954. */
  3955. static readonly ANIMATIONTYPE_SIZE: number;
  3956. /**
  3957. * Get the Quaternion animation type
  3958. */
  3959. static readonly ANIMATIONTYPE_QUATERNION: number;
  3960. /**
  3961. * Get the Matrix animation type
  3962. */
  3963. static readonly ANIMATIONTYPE_MATRIX: number;
  3964. /**
  3965. * Get the Color3 animation type
  3966. */
  3967. static readonly ANIMATIONTYPE_COLOR3: number;
  3968. /**
  3969. * Get the Relative Loop Mode
  3970. */
  3971. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3972. /**
  3973. * Get the Cycle Loop Mode
  3974. */
  3975. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3976. /**
  3977. * Get the Constant Loop Mode
  3978. */
  3979. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3980. /** @hidden */
  3981. static _UniversalLerp(left: any, right: any, amount: number): any;
  3982. /**
  3983. * Parses an animation object and creates an animation
  3984. * @param parsedAnimation Parsed animation object
  3985. * @returns Animation object
  3986. */
  3987. static Parse(parsedAnimation: any): Animation;
  3988. /**
  3989. * Appends the serialized animations from the source animations
  3990. * @param source Source containing the animations
  3991. * @param destination Target to store the animations
  3992. */
  3993. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3994. }
  3995. }
  3996. declare module BABYLON {
  3997. /**
  3998. * This class defines the direct association between an animation and a target
  3999. */
  4000. class TargetedAnimation {
  4001. animation: Animation;
  4002. target: any;
  4003. }
  4004. /**
  4005. * Use this class to create coordinated animations on multiple targets
  4006. */
  4007. class AnimationGroup implements IDisposable {
  4008. name: string;
  4009. private _scene;
  4010. private _targetedAnimations;
  4011. private _animatables;
  4012. private _from;
  4013. private _to;
  4014. private _isStarted;
  4015. private _speedRatio;
  4016. onAnimationEndObservable: Observable<TargetedAnimation>;
  4017. /**
  4018. * This observable will notify when all animations have ended.
  4019. */
  4020. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4021. /**
  4022. * Gets the first frame
  4023. */
  4024. readonly from: number;
  4025. /**
  4026. * Gets the last frame
  4027. */
  4028. readonly to: number;
  4029. /**
  4030. * Define if the animations are started
  4031. */
  4032. readonly isStarted: boolean;
  4033. /**
  4034. * Gets or sets the speed ratio to use for all animations
  4035. */
  4036. /**
  4037. * Gets or sets the speed ratio to use for all animations
  4038. */
  4039. speedRatio: number;
  4040. /**
  4041. * Gets the targeted animations for this animation group
  4042. */
  4043. readonly targetedAnimations: Array<TargetedAnimation>;
  4044. /**
  4045. * returning the list of animatables controlled by this animation group.
  4046. */
  4047. readonly animatables: Array<Animatable>;
  4048. constructor(name: string, scene?: Nullable<Scene>);
  4049. /**
  4050. * Add an animation (with its target) in the group
  4051. * @param animation defines the animation we want to add
  4052. * @param target defines the target of the animation
  4053. * @returns the {BABYLON.TargetedAnimation} object
  4054. */
  4055. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4056. /**
  4057. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4058. * It can add constant keys at begin or end
  4059. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4060. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4061. */
  4062. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4063. /**
  4064. * Start all animations on given targets
  4065. * @param loop defines if animations must loop
  4066. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4067. * @param from defines the from key (optional)
  4068. * @param to defines the to key (optional)
  4069. * @returns the current animation group
  4070. */
  4071. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4072. /**
  4073. * Pause all animations
  4074. */
  4075. pause(): AnimationGroup;
  4076. /**
  4077. * Play all animations to initial state
  4078. * This function will start() the animations if they were not started or will restart() them if they were paused
  4079. * @param loop defines if animations must loop
  4080. */
  4081. play(loop?: boolean): AnimationGroup;
  4082. /**
  4083. * Reset all animations to initial state
  4084. */
  4085. reset(): AnimationGroup;
  4086. /**
  4087. * Restart animations from key 0
  4088. */
  4089. restart(): AnimationGroup;
  4090. /**
  4091. * Stop all animations
  4092. */
  4093. stop(): AnimationGroup;
  4094. /**
  4095. * Set animation weight for all animatables
  4096. * @param weight defines the weight to use
  4097. * @return the animationGroup
  4098. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4099. */
  4100. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4101. /**
  4102. * Synchronize and normalize all animatables with a source animatable
  4103. * @param root defines the root animatable to synchronize with
  4104. * @return the animationGroup
  4105. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4106. */
  4107. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4108. /**
  4109. * Goes to a specific frame in this animation group
  4110. * @param frame the frame number to go to
  4111. * @return the animationGroup
  4112. */
  4113. goToFrame(frame: number): AnimationGroup;
  4114. /**
  4115. * Dispose all associated resources
  4116. */
  4117. dispose(): void;
  4118. private _checkAnimationGroupEnded(animatable);
  4119. }
  4120. }
  4121. declare module BABYLON {
  4122. /**
  4123. * Class used to override all child animations of a given target
  4124. */
  4125. class AnimationPropertiesOverride {
  4126. /**
  4127. * Gets or sets a value indicating if animation blending must be used
  4128. */
  4129. enableBlending: boolean;
  4130. /**
  4131. * Gets or sets the blending speed to use when enableBlending is true
  4132. */
  4133. blendingSpeed: number;
  4134. /**
  4135. * Gets or sets the default loop mode to use
  4136. */
  4137. loopMode: number;
  4138. }
  4139. }
  4140. declare module BABYLON {
  4141. interface IEasingFunction {
  4142. ease(gradient: number): number;
  4143. }
  4144. class EasingFunction implements IEasingFunction {
  4145. private static _EASINGMODE_EASEIN;
  4146. private static _EASINGMODE_EASEOUT;
  4147. private static _EASINGMODE_EASEINOUT;
  4148. static readonly EASINGMODE_EASEIN: number;
  4149. static readonly EASINGMODE_EASEOUT: number;
  4150. static readonly EASINGMODE_EASEINOUT: number;
  4151. private _easingMode;
  4152. setEasingMode(easingMode: number): void;
  4153. getEasingMode(): number;
  4154. easeInCore(gradient: number): number;
  4155. ease(gradient: number): number;
  4156. }
  4157. class CircleEase extends EasingFunction implements IEasingFunction {
  4158. easeInCore(gradient: number): number;
  4159. }
  4160. class BackEase extends EasingFunction implements IEasingFunction {
  4161. amplitude: number;
  4162. constructor(amplitude?: number);
  4163. easeInCore(gradient: number): number;
  4164. }
  4165. class BounceEase extends EasingFunction implements IEasingFunction {
  4166. bounces: number;
  4167. bounciness: number;
  4168. constructor(bounces?: number, bounciness?: number);
  4169. easeInCore(gradient: number): number;
  4170. }
  4171. class CubicEase extends EasingFunction implements IEasingFunction {
  4172. easeInCore(gradient: number): number;
  4173. }
  4174. class ElasticEase extends EasingFunction implements IEasingFunction {
  4175. oscillations: number;
  4176. springiness: number;
  4177. constructor(oscillations?: number, springiness?: number);
  4178. easeInCore(gradient: number): number;
  4179. }
  4180. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4181. exponent: number;
  4182. constructor(exponent?: number);
  4183. easeInCore(gradient: number): number;
  4184. }
  4185. class PowerEase extends EasingFunction implements IEasingFunction {
  4186. power: number;
  4187. constructor(power?: number);
  4188. easeInCore(gradient: number): number;
  4189. }
  4190. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4191. easeInCore(gradient: number): number;
  4192. }
  4193. class QuarticEase extends EasingFunction implements IEasingFunction {
  4194. easeInCore(gradient: number): number;
  4195. }
  4196. class QuinticEase extends EasingFunction implements IEasingFunction {
  4197. easeInCore(gradient: number): number;
  4198. }
  4199. class SineEase extends EasingFunction implements IEasingFunction {
  4200. easeInCore(gradient: number): number;
  4201. }
  4202. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4203. x1: number;
  4204. y1: number;
  4205. x2: number;
  4206. y2: number;
  4207. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4208. easeInCore(gradient: number): number;
  4209. }
  4210. }
  4211. declare module BABYLON {
  4212. /**
  4213. * Defines a runtime animation
  4214. */
  4215. class RuntimeAnimation {
  4216. private _events;
  4217. /**
  4218. * The current frame of the runtime animation
  4219. */
  4220. private _currentFrame;
  4221. /**
  4222. * The animation used by the runtime animation
  4223. */
  4224. private _animation;
  4225. /**
  4226. * The target of the runtime animation
  4227. */
  4228. private _target;
  4229. /**
  4230. * The initiating animatable
  4231. */
  4232. private _host;
  4233. /**
  4234. * The original value of the runtime animation
  4235. */
  4236. private _originalValue;
  4237. /**
  4238. * The original blend value of the runtime animation
  4239. */
  4240. private _originalBlendValue;
  4241. /**
  4242. * The offsets cache of the runtime animation
  4243. */
  4244. private _offsetsCache;
  4245. /**
  4246. * The high limits cache of the runtime animation
  4247. */
  4248. private _highLimitsCache;
  4249. /**
  4250. * Specifies if the runtime animation has been stopped
  4251. */
  4252. private _stopped;
  4253. /**
  4254. * The blending factor of the runtime animation
  4255. */
  4256. private _blendingFactor;
  4257. /**
  4258. * The BabylonJS scene
  4259. */
  4260. private _scene;
  4261. /**
  4262. * The current value of the runtime animation
  4263. */
  4264. private _currentValue;
  4265. /** @hidden */
  4266. _workValue: any;
  4267. /**
  4268. * The active target of the runtime animation
  4269. */
  4270. private _activeTarget;
  4271. /**
  4272. * The target path of the runtime animation
  4273. */
  4274. private _targetPath;
  4275. /**
  4276. * The weight of the runtime animation
  4277. */
  4278. private _weight;
  4279. /**
  4280. * The ratio offset of the runtime animation
  4281. */
  4282. private _ratioOffset;
  4283. /**
  4284. * The previous delay of the runtime animation
  4285. */
  4286. private _previousDelay;
  4287. /**
  4288. * The previous ratio of the runtime animation
  4289. */
  4290. private _previousRatio;
  4291. /**
  4292. * Gets the current frame of the runtime animation
  4293. */
  4294. readonly currentFrame: number;
  4295. /**
  4296. * Gets the weight of the runtime animation
  4297. */
  4298. readonly weight: number;
  4299. /**
  4300. * Gets the current value of the runtime animation
  4301. */
  4302. readonly currentValue: any;
  4303. /**
  4304. * Gets the target path of the runtime animation
  4305. */
  4306. readonly targetPath: string;
  4307. /**
  4308. * Gets the actual target of the runtime animation
  4309. */
  4310. readonly target: any;
  4311. /**
  4312. * Create a new RuntimeAnimation object
  4313. * @param target defines the target of the animation
  4314. * @param animation defines the source animation object
  4315. * @param scene defines the hosting scene
  4316. * @param host defines the initiating Animatable
  4317. */
  4318. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4319. /**
  4320. * Gets the animation from the runtime animation
  4321. */
  4322. readonly animation: Animation;
  4323. /**
  4324. * Resets the runtime animation to the beginning
  4325. * @param restoreOriginal defines whether to restore the target property to the original value
  4326. */
  4327. reset(restoreOriginal?: boolean): void;
  4328. /**
  4329. * Specifies if the runtime animation is stopped
  4330. * @returns Boolean specifying if the runtime animation is stopped
  4331. */
  4332. isStopped(): boolean;
  4333. /**
  4334. * Disposes of the runtime animation
  4335. */
  4336. dispose(): void;
  4337. /**
  4338. * Interpolates the animation from the current frame
  4339. * @param currentFrame The frame to interpolate the animation to
  4340. * @param repeatCount The number of times that the animation should loop
  4341. * @param loopMode The type of looping mode to use
  4342. * @param offsetValue Animation offset value
  4343. * @param highLimitValue The high limit value
  4344. * @returns The interpolated value
  4345. */
  4346. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4347. /**
  4348. * Apply the interpolated value to the target
  4349. * @param currentValue defines the value computed by the animation
  4350. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4351. */
  4352. setValue(currentValue: any, weight?: number): void;
  4353. private _setValue(target, currentValue, weight, targetIndex?);
  4354. /**
  4355. * Gets the loop pmode of the runtime animation
  4356. * @returns Loop Mode
  4357. */
  4358. private _getCorrectLoopMode();
  4359. /**
  4360. * Move the current animation to a given frame
  4361. * @param frame defines the frame to move to
  4362. */
  4363. goToFrame(frame: number): void;
  4364. /**
  4365. * @hidden Internal use only
  4366. */
  4367. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4368. /**
  4369. * Execute the current animation
  4370. * @param delay defines the delay to add to the current frame
  4371. * @param from defines the lower bound of the animation range
  4372. * @param to defines the upper bound of the animation range
  4373. * @param loop defines if the current animation must loop
  4374. * @param speedRatio defines the current speed ratio
  4375. * @param weight defines the weight of the animation (default is -1 so no weight)
  4376. * @returns a boolean indicating if the animation has ended
  4377. */
  4378. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4379. }
  4380. }
  4381. declare module BABYLON {
  4382. /**
  4383. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4385. */
  4386. class Analyser {
  4387. /**
  4388. * Gets or sets the smoothing
  4389. * @ignorenaming
  4390. */
  4391. SMOOTHING: number;
  4392. /**
  4393. * Gets or sets the FFT table size
  4394. * @ignorenaming
  4395. */
  4396. FFT_SIZE: number;
  4397. /**
  4398. * Gets or sets the bar graph amplitude
  4399. * @ignorenaming
  4400. */
  4401. BARGRAPHAMPLITUDE: number;
  4402. /**
  4403. * Gets or sets the position of the debug canvas
  4404. * @ignorenaming
  4405. */
  4406. DEBUGCANVASPOS: {
  4407. x: number;
  4408. y: number;
  4409. };
  4410. /**
  4411. * Gets or sets the debug canvas size
  4412. * @ignorenaming
  4413. */
  4414. DEBUGCANVASSIZE: {
  4415. width: number;
  4416. height: number;
  4417. };
  4418. private _byteFreqs;
  4419. private _byteTime;
  4420. private _floatFreqs;
  4421. private _webAudioAnalyser;
  4422. private _debugCanvas;
  4423. private _debugCanvasContext;
  4424. private _scene;
  4425. private _registerFunc;
  4426. private _audioEngine;
  4427. /**
  4428. * Creates a new analyser
  4429. * @param scene defines hosting scene
  4430. */
  4431. constructor(scene: Scene);
  4432. /**
  4433. * Get the number of data values you will have to play with for the visualization
  4434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4435. * @returns a number
  4436. */
  4437. getFrequencyBinCount(): number;
  4438. /**
  4439. * Gets the current frequency data as a byte array
  4440. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4441. * @returns a Uint8Array
  4442. */
  4443. getByteFrequencyData(): Uint8Array;
  4444. /**
  4445. * Gets the current waveform as a byte array
  4446. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4447. * @returns a Uint8Array
  4448. */
  4449. getByteTimeDomainData(): Uint8Array;
  4450. /**
  4451. * Gets the current frequency data as a float array
  4452. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4453. * @returns a Float32Array
  4454. */
  4455. getFloatFrequencyData(): Float32Array;
  4456. /**
  4457. * Renders the debug canvas
  4458. */
  4459. drawDebugCanvas(): void;
  4460. /**
  4461. * Stops rendering the debug canvas and removes it
  4462. */
  4463. stopDebugCanvas(): void;
  4464. /**
  4465. * Connects two audio nodes
  4466. * @param inputAudioNode defines first node to connect
  4467. * @param outputAudioNode defines second node to connect
  4468. */
  4469. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4470. /**
  4471. * Releases all associated resources
  4472. */
  4473. dispose(): void;
  4474. }
  4475. }
  4476. declare module BABYLON {
  4477. class AudioEngine {
  4478. private _audioContext;
  4479. private _audioContextInitialized;
  4480. canUseWebAudio: boolean;
  4481. masterGain: GainNode;
  4482. private _connectedAnalyser;
  4483. WarnedWebAudioUnsupported: boolean;
  4484. unlocked: boolean;
  4485. onAudioUnlocked: () => any;
  4486. isMP3supported: boolean;
  4487. isOGGsupported: boolean;
  4488. readonly audioContext: Nullable<AudioContext>;
  4489. constructor();
  4490. private _unlockiOSaudio();
  4491. private _initializeAudioContext();
  4492. dispose(): void;
  4493. getGlobalVolume(): number;
  4494. setGlobalVolume(newVolume: number): void;
  4495. connectToAnalyser(analyser: Analyser): void;
  4496. }
  4497. }
  4498. declare module BABYLON {
  4499. class Sound {
  4500. name: string;
  4501. autoplay: boolean;
  4502. loop: boolean;
  4503. useCustomAttenuation: boolean;
  4504. soundTrackId: number;
  4505. spatialSound: boolean;
  4506. refDistance: number;
  4507. rolloffFactor: number;
  4508. maxDistance: number;
  4509. distanceModel: string;
  4510. private _panningModel;
  4511. onended: () => any;
  4512. private _playbackRate;
  4513. private _streaming;
  4514. private _startTime;
  4515. private _startOffset;
  4516. private _position;
  4517. private _localDirection;
  4518. private _volume;
  4519. private _isReadyToPlay;
  4520. isPlaying: boolean;
  4521. isPaused: boolean;
  4522. private _isDirectional;
  4523. private _readyToPlayCallback;
  4524. private _audioBuffer;
  4525. private _soundSource;
  4526. private _streamingSource;
  4527. private _soundPanner;
  4528. private _soundGain;
  4529. private _inputAudioNode;
  4530. private _ouputAudioNode;
  4531. private _coneInnerAngle;
  4532. private _coneOuterAngle;
  4533. private _coneOuterGain;
  4534. private _scene;
  4535. private _connectedMesh;
  4536. private _customAttenuationFunction;
  4537. private _registerFunc;
  4538. private _isOutputConnected;
  4539. private _htmlAudioElement;
  4540. private _urlType;
  4541. /**
  4542. * Create a sound and attach it to a scene
  4543. * @param name Name of your sound
  4544. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4545. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4546. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4547. */
  4548. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4549. dispose(): void;
  4550. isReady(): boolean;
  4551. private _soundLoaded(audioData);
  4552. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4553. updateOptions(options: any): void;
  4554. private _createSpatialParameters();
  4555. private _updateSpatialParameters();
  4556. switchPanningModelToHRTF(): void;
  4557. switchPanningModelToEqualPower(): void;
  4558. private _switchPanningModel();
  4559. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4560. /**
  4561. * Transform this sound into a directional source
  4562. * @param coneInnerAngle Size of the inner cone in degree
  4563. * @param coneOuterAngle Size of the outer cone in degree
  4564. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4565. */
  4566. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4567. setPosition(newPosition: Vector3): void;
  4568. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4569. private _updateDirection();
  4570. updateDistanceFromListener(): void;
  4571. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4572. /**
  4573. * Play the sound
  4574. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4575. * @param offset (optional) Start the sound setting it at a specific time
  4576. */
  4577. play(time?: number, offset?: number): void;
  4578. private _onended();
  4579. /**
  4580. * Stop the sound
  4581. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4582. */
  4583. stop(time?: number): void;
  4584. pause(): void;
  4585. setVolume(newVolume: number, time?: number): void;
  4586. setPlaybackRate(newPlaybackRate: number): void;
  4587. getVolume(): number;
  4588. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4589. detachFromMesh(): void;
  4590. private _onRegisterAfterWorldMatrixUpdate(node);
  4591. clone(): Nullable<Sound>;
  4592. getAudioBuffer(): AudioBuffer | null;
  4593. serialize(): any;
  4594. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4595. }
  4596. }
  4597. declare module BABYLON {
  4598. class SoundTrack {
  4599. private _outputAudioNode;
  4600. private _scene;
  4601. id: number;
  4602. soundCollection: Array<Sound>;
  4603. private _isMainTrack;
  4604. private _connectedAnalyser;
  4605. private _options;
  4606. private _isInitialized;
  4607. constructor(scene: Scene, options?: any);
  4608. private _initializeSoundTrackAudioGraph();
  4609. dispose(): void;
  4610. AddSound(sound: Sound): void;
  4611. RemoveSound(sound: Sound): void;
  4612. setVolume(newVolume: number): void;
  4613. switchPanningModelToHRTF(): void;
  4614. switchPanningModelToEqualPower(): void;
  4615. connectToAnalyser(analyser: Analyser): void;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * Interface used to define a behavior
  4621. */
  4622. interface Behavior<T> {
  4623. /** gets or sets behavior's name */
  4624. name: string;
  4625. /**
  4626. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4627. */
  4628. init(): void;
  4629. /**
  4630. * Called when the behavior is attached to a target
  4631. * @param target defines the target where the behavior is attached to
  4632. */
  4633. attach(target: T): void;
  4634. /**
  4635. * Called when the behavior is detached from its target
  4636. */
  4637. detach(): void;
  4638. }
  4639. /**
  4640. * Interface implemented by classes supporting behaviors
  4641. */
  4642. interface IBehaviorAware<T> {
  4643. /**
  4644. * Attach a behavior
  4645. * @param behavior defines the behavior to attach
  4646. * @returns the current host
  4647. */
  4648. addBehavior(behavior: Behavior<T>): T;
  4649. /**
  4650. * Remove a behavior from the current object
  4651. * @param behavior defines the behavior to detach
  4652. * @returns the current host
  4653. */
  4654. removeBehavior(behavior: Behavior<T>): T;
  4655. /**
  4656. * Gets a behavior using its name to search
  4657. * @param name defines the name to search
  4658. * @returns the behavior or null if not found
  4659. */
  4660. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4661. }
  4662. }
  4663. declare module BABYLON {
  4664. /**
  4665. * Class used to store bone information
  4666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4667. */
  4668. class Bone extends Node {
  4669. /**
  4670. * defines the bone name
  4671. */
  4672. name: string;
  4673. private static _tmpVecs;
  4674. private static _tmpQuat;
  4675. private static _tmpMats;
  4676. /**
  4677. * Gets the list of child bones
  4678. */
  4679. children: Bone[];
  4680. /** Gets the animations associated with this bone */
  4681. animations: Animation[];
  4682. /**
  4683. * Gets or sets bone length
  4684. */
  4685. length: number;
  4686. /**
  4687. * @hidden Internal only
  4688. * Set this value to map this bone to a different index in the transform matrices
  4689. * Set this value to -1 to exclude the bone from the transform matrices
  4690. */
  4691. _index: Nullable<number>;
  4692. private _skeleton;
  4693. private _localMatrix;
  4694. private _restPose;
  4695. private _baseMatrix;
  4696. private _absoluteTransform;
  4697. private _invertedAbsoluteTransform;
  4698. private _parent;
  4699. private _scalingDeterminant;
  4700. private _worldTransform;
  4701. private _localScaling;
  4702. private _localRotation;
  4703. private _localPosition;
  4704. private _needToDecompose;
  4705. private _needToCompose;
  4706. /** @hidden */
  4707. /** @hidden */
  4708. _matrix: Matrix;
  4709. /**
  4710. * Create a new bone
  4711. * @param name defines the bone name
  4712. * @param skeleton defines the parent skeleton
  4713. * @param parentBone defines the parent (can be null if the bone is the root)
  4714. * @param localMatrix defines the local matrix
  4715. * @param restPose defines the rest pose matrix
  4716. * @param baseMatrix defines the base matrix
  4717. * @param index defines index of the bone in the hiearchy
  4718. */
  4719. constructor(
  4720. /**
  4721. * defines the bone name
  4722. */
  4723. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4724. /**
  4725. * Gets the parent skeleton
  4726. * @returns a skeleton
  4727. */
  4728. getSkeleton(): Skeleton;
  4729. /**
  4730. * Gets parent bone
  4731. * @returns a bone or null if the bone is the root of the bone hierarchy
  4732. */
  4733. getParent(): Nullable<Bone>;
  4734. /**
  4735. * Sets the parent bone
  4736. * @param parent defines the parent (can be null if the bone is the root)
  4737. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4738. */
  4739. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4740. /**
  4741. * Gets the local matrix
  4742. * @returns a matrix
  4743. */
  4744. getLocalMatrix(): Matrix;
  4745. /**
  4746. * Gets the base matrix (initial matrix which remains unchanged)
  4747. * @returns a matrix
  4748. */
  4749. getBaseMatrix(): Matrix;
  4750. /**
  4751. * Gets the rest pose matrix
  4752. * @returns a matrix
  4753. */
  4754. getRestPose(): Matrix;
  4755. /**
  4756. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4757. */
  4758. getWorldMatrix(): Matrix;
  4759. /**
  4760. * Sets the local matrix to rest pose matrix
  4761. */
  4762. returnToRest(): void;
  4763. /**
  4764. * Gets the inverse of the absolute transform matrix.
  4765. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4766. * @returns a matrix
  4767. */
  4768. getInvertedAbsoluteTransform(): Matrix;
  4769. /**
  4770. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4771. * @returns a matrix
  4772. */
  4773. getAbsoluteTransform(): Matrix;
  4774. /** Gets or sets current position (in local space) */
  4775. position: Vector3;
  4776. /** Gets or sets current rotation (in local space) */
  4777. rotation: Vector3;
  4778. /** Gets or sets current rotation quaternion (in local space) */
  4779. rotationQuaternion: Quaternion;
  4780. /** Gets or sets current scaling (in local space) */
  4781. scaling: Vector3;
  4782. /**
  4783. * Gets the animation properties override
  4784. */
  4785. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4786. private _decompose();
  4787. private _compose();
  4788. /**
  4789. * Update the base and local matrices
  4790. * @param matrix defines the new base or local matrix
  4791. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4792. * @param updateLocalMatrix defines if the local matrix should be updated
  4793. */
  4794. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4795. /** @hidden */
  4796. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4797. /**
  4798. * Flag the bone as dirty (Forcing it to update everything)
  4799. */
  4800. markAsDirty(): void;
  4801. private _markAsDirtyAndCompose();
  4802. private _markAsDirtyAndDecompose();
  4803. /**
  4804. * Copy an animation range from another bone
  4805. * @param source defines the source bone
  4806. * @param rangeName defines the range name to copy
  4807. * @param frameOffset defines the frame offset
  4808. * @param rescaleAsRequired defines if rescaling must be applied if required
  4809. * @param skelDimensionsRatio defines the scaling ratio
  4810. * @returns true if operation was successful
  4811. */
  4812. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4813. /**
  4814. * Translate the bone in local or world space
  4815. * @param vec The amount to translate the bone
  4816. * @param space The space that the translation is in
  4817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4818. */
  4819. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4820. /**
  4821. * Set the postion of the bone in local or world space
  4822. * @param position The position to set the bone
  4823. * @param space The space that the position is in
  4824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4825. */
  4826. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4827. /**
  4828. * Set the absolute position of the bone (world space)
  4829. * @param position The position to set the bone
  4830. * @param mesh The mesh that this bone is attached to
  4831. */
  4832. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4833. /**
  4834. * Scale the bone on the x, y and z axes (in local space)
  4835. * @param x The amount to scale the bone on the x axis
  4836. * @param y The amount to scale the bone on the y axis
  4837. * @param z The amount to scale the bone on the z axis
  4838. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4839. */
  4840. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4841. /**
  4842. * Set the bone scaling in local space
  4843. * @param scale defines the scaling vector
  4844. */
  4845. setScale(scale: Vector3): void;
  4846. /**
  4847. * Gets the current scaling in local space
  4848. * @returns the current scaling vector
  4849. */
  4850. getScale(): Vector3;
  4851. /**
  4852. * Gets the current scaling in local space and stores it in a target vector
  4853. * @param result defines the target vector
  4854. */
  4855. getScaleToRef(result: Vector3): void;
  4856. /**
  4857. * Set the yaw, pitch, and roll of the bone in local or world space
  4858. * @param yaw The rotation of the bone on the y axis
  4859. * @param pitch The rotation of the bone on the x axis
  4860. * @param roll The rotation of the bone on the z axis
  4861. * @param space The space that the axes of rotation are in
  4862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4863. */
  4864. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4865. /**
  4866. * Add a rotation to the bone on an axis in local or world space
  4867. * @param axis The axis to rotate the bone on
  4868. * @param amount The amount to rotate the bone
  4869. * @param space The space that the axis is in
  4870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4871. */
  4872. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4873. /**
  4874. * Set the rotation of the bone to a particular axis angle in local or world space
  4875. * @param axis The axis to rotate the bone on
  4876. * @param angle The angle that the bone should be rotated to
  4877. * @param space The space that the axis is in
  4878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4879. */
  4880. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4881. /**
  4882. * Set the euler rotation of the bone in local of world space
  4883. * @param rotation The euler rotation that the bone should be set to
  4884. * @param space The space that the rotation is in
  4885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4886. */
  4887. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4888. /**
  4889. * Set the quaternion rotation of the bone in local of world space
  4890. * @param quat The quaternion rotation that the bone should be set to
  4891. * @param space The space that the rotation is in
  4892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4893. */
  4894. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4895. /**
  4896. * Set the rotation matrix of the bone in local of world space
  4897. * @param rotMat The rotation matrix that the bone should be set to
  4898. * @param space The space that the rotation is in
  4899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4900. */
  4901. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4902. private _rotateWithMatrix(rmat, space?, mesh?);
  4903. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4904. /**
  4905. * Get the position of the bone in local or world space
  4906. * @param space The space that the returned position is in
  4907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4908. * @returns The position of the bone
  4909. */
  4910. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4911. /**
  4912. * Copy the position of the bone to a vector3 in local or world space
  4913. * @param space The space that the returned position is in
  4914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4915. * @param result The vector3 to copy the position to
  4916. */
  4917. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4918. /**
  4919. * Get the absolute position of the bone (world space)
  4920. * @param mesh The mesh that this bone is attached to
  4921. * @returns The absolute position of the bone
  4922. */
  4923. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4924. /**
  4925. * Copy the absolute position of the bone (world space) to the result param
  4926. * @param mesh The mesh that this bone is attached to
  4927. * @param result The vector3 to copy the absolute position to
  4928. */
  4929. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4930. /**
  4931. * Compute the absolute transforms of this bone and its children
  4932. */
  4933. computeAbsoluteTransforms(): void;
  4934. /**
  4935. * Get the world direction from an axis that is in the local space of the bone
  4936. * @param localAxis The local direction that is used to compute the world direction
  4937. * @param mesh The mesh that this bone is attached to
  4938. * @returns The world direction
  4939. */
  4940. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4941. /**
  4942. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4943. * @param localAxis The local direction that is used to compute the world direction
  4944. * @param mesh The mesh that this bone is attached to
  4945. * @param result The vector3 that the world direction will be copied to
  4946. */
  4947. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4948. /**
  4949. * Get the euler rotation of the bone in local or world space
  4950. * @param space The space that the rotation should be in
  4951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4952. * @returns The euler rotation
  4953. */
  4954. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4955. /**
  4956. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4957. * @param space The space that the rotation should be in
  4958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4959. * @param result The vector3 that the rotation should be copied to
  4960. */
  4961. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4962. /**
  4963. * Get the quaternion rotation of the bone in either local or world space
  4964. * @param space The space that the rotation should be in
  4965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4966. * @returns The quaternion rotation
  4967. */
  4968. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4969. /**
  4970. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4971. * @param space The space that the rotation should be in
  4972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4973. * @param result The quaternion that the rotation should be copied to
  4974. */
  4975. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4976. /**
  4977. * Get the rotation matrix of the bone in local or world space
  4978. * @param space The space that the rotation should be in
  4979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4980. * @returns The rotation matrix
  4981. */
  4982. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4983. /**
  4984. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4985. * @param space The space that the rotation should be in
  4986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4987. * @param result The quaternion that the rotation should be copied to
  4988. */
  4989. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4990. /**
  4991. * Get the world position of a point that is in the local space of the bone
  4992. * @param position The local position
  4993. * @param mesh The mesh that this bone is attached to
  4994. * @returns The world position
  4995. */
  4996. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4997. /**
  4998. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4999. * @param position The local position
  5000. * @param mesh The mesh that this bone is attached to
  5001. * @param result The vector3 that the world position should be copied to
  5002. */
  5003. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5004. /**
  5005. * Get the local position of a point that is in world space
  5006. * @param position The world position
  5007. * @param mesh The mesh that this bone is attached to
  5008. * @returns The local position
  5009. */
  5010. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5011. /**
  5012. * Get the local position of a point that is in world space and copy it to the result param
  5013. * @param position The world position
  5014. * @param mesh The mesh that this bone is attached to
  5015. * @param result The vector3 that the local position should be copied to
  5016. */
  5017. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5018. }
  5019. }
  5020. declare module BABYLON {
  5021. /**
  5022. * Class used to apply inverse kinematics to bones
  5023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5024. */
  5025. class BoneIKController {
  5026. private static _tmpVecs;
  5027. private static _tmpQuat;
  5028. private static _tmpMats;
  5029. /**
  5030. * Gets or sets the target mesh
  5031. */
  5032. targetMesh: AbstractMesh;
  5033. /** Gets or sets the mesh used as pole */
  5034. poleTargetMesh: AbstractMesh;
  5035. /**
  5036. * Gets or sets the bone used as pole
  5037. */
  5038. poleTargetBone: Nullable<Bone>;
  5039. /**
  5040. * Gets or sets the target position
  5041. */
  5042. targetPosition: Vector3;
  5043. /**
  5044. * Gets or sets the pole target position
  5045. */
  5046. poleTargetPosition: Vector3;
  5047. /**
  5048. * Gets or sets the pole target local offset
  5049. */
  5050. poleTargetLocalOffset: Vector3;
  5051. /**
  5052. * Gets or sets the pole angle
  5053. */
  5054. poleAngle: number;
  5055. /**
  5056. * Gets or sets the mesh associated with the controller
  5057. */
  5058. mesh: AbstractMesh;
  5059. /**
  5060. * 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)
  5061. */
  5062. slerpAmount: number;
  5063. private _bone1Quat;
  5064. private _bone1Mat;
  5065. private _bone2Ang;
  5066. private _bone1;
  5067. private _bone2;
  5068. private _bone1Length;
  5069. private _bone2Length;
  5070. private _maxAngle;
  5071. private _maxReach;
  5072. private _rightHandedSystem;
  5073. private _bendAxis;
  5074. private _slerping;
  5075. private _adjustRoll;
  5076. /**
  5077. * Gets or sets maximum allowed angle
  5078. */
  5079. maxAngle: number;
  5080. /**
  5081. * Creates a new BoneIKController
  5082. * @param mesh defines the mesh to control
  5083. * @param bone defines the bone to control
  5084. * @param options defines options to set up the controller
  5085. */
  5086. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5087. targetMesh?: AbstractMesh;
  5088. poleTargetMesh?: AbstractMesh;
  5089. poleTargetBone?: Bone;
  5090. poleTargetLocalOffset?: Vector3;
  5091. poleAngle?: number;
  5092. bendAxis?: Vector3;
  5093. maxAngle?: number;
  5094. slerpAmount?: number;
  5095. });
  5096. private _setMaxAngle(ang);
  5097. /**
  5098. * Force the controller to update the bones
  5099. */
  5100. update(): void;
  5101. }
  5102. }
  5103. declare module BABYLON {
  5104. /**
  5105. * Class used to make a bone look toward a point in space
  5106. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5107. */
  5108. class BoneLookController {
  5109. private static _tmpVecs;
  5110. private static _tmpQuat;
  5111. private static _tmpMats;
  5112. /**
  5113. * The target Vector3 that the bone will look at
  5114. */
  5115. target: Vector3;
  5116. /**
  5117. * The mesh that the bone is attached to
  5118. */
  5119. mesh: AbstractMesh;
  5120. /**
  5121. * The bone that will be looking to the target
  5122. */
  5123. bone: Bone;
  5124. /**
  5125. * The up axis of the coordinate system that is used when the bone is rotated
  5126. */
  5127. upAxis: Vector3;
  5128. /**
  5129. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5130. */
  5131. upAxisSpace: Space;
  5132. /**
  5133. * Used to make an adjustment to the yaw of the bone
  5134. */
  5135. adjustYaw: number;
  5136. /**
  5137. * Used to make an adjustment to the pitch of the bone
  5138. */
  5139. adjustPitch: number;
  5140. /**
  5141. * Used to make an adjustment to the roll of the bone
  5142. */
  5143. adjustRoll: number;
  5144. /**
  5145. * 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)
  5146. */
  5147. slerpAmount: number;
  5148. private _minYaw;
  5149. private _maxYaw;
  5150. private _minPitch;
  5151. private _maxPitch;
  5152. private _minYawSin;
  5153. private _minYawCos;
  5154. private _maxYawSin;
  5155. private _maxYawCos;
  5156. private _midYawConstraint;
  5157. private _minPitchTan;
  5158. private _maxPitchTan;
  5159. private _boneQuat;
  5160. private _slerping;
  5161. private _transformYawPitch;
  5162. private _transformYawPitchInv;
  5163. private _firstFrameSkipped;
  5164. private _yawRange;
  5165. private _fowardAxis;
  5166. /**
  5167. * Gets or sets the minimum yaw angle that the bone can look to
  5168. */
  5169. minYaw: number;
  5170. /**
  5171. * Gets or sets the maximum yaw angle that the bone can look to
  5172. */
  5173. maxYaw: number;
  5174. /**
  5175. * Gets or sets the minimum pitch angle that the bone can look to
  5176. */
  5177. minPitch: number;
  5178. /**
  5179. * Gets or sets the maximum pitch angle that the bone can look to
  5180. */
  5181. maxPitch: number;
  5182. /**
  5183. * Create a BoneLookController
  5184. * @param mesh the mesh that the bone belongs to
  5185. * @param bone the bone that will be looking to the target
  5186. * @param target the target Vector3 to look at
  5187. * @param settings optional settings:
  5188. * * maxYaw: the maximum angle the bone will yaw to
  5189. * * minYaw: the minimum angle the bone will yaw to
  5190. * * maxPitch: the maximum angle the bone will pitch to
  5191. * * minPitch: the minimum angle the bone will yaw to
  5192. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5193. * * upAxis: the up axis of the coordinate system
  5194. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5195. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5196. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5197. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5198. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5199. * * adjustRoll: used to make an adjustment to the roll of the bone
  5200. **/
  5201. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5202. maxYaw?: number;
  5203. minYaw?: number;
  5204. maxPitch?: number;
  5205. minPitch?: number;
  5206. slerpAmount?: number;
  5207. upAxis?: Vector3;
  5208. upAxisSpace?: Space;
  5209. yawAxis?: Vector3;
  5210. pitchAxis?: Vector3;
  5211. adjustYaw?: number;
  5212. adjustPitch?: number;
  5213. adjustRoll?: number;
  5214. });
  5215. /**
  5216. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5217. */
  5218. update(): void;
  5219. private _getAngleDiff(ang1, ang2);
  5220. private _getAngleBetween(ang1, ang2);
  5221. private _isAngleBetween(ang, ang1, ang2);
  5222. }
  5223. }
  5224. declare module BABYLON {
  5225. /**
  5226. * Class used to handle skinning animations
  5227. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5228. */
  5229. class Skeleton implements IAnimatable {
  5230. /** defines the skeleton name */
  5231. name: string;
  5232. /** defines the skeleton Id */
  5233. id: string;
  5234. /**
  5235. * Gets the list of child bones
  5236. */
  5237. bones: Bone[];
  5238. /**
  5239. * Gets an estimate of the dimension of the skeleton at rest
  5240. */
  5241. dimensionsAtRest: Vector3;
  5242. /**
  5243. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5244. */
  5245. needInitialSkinMatrix: boolean;
  5246. /**
  5247. * Gets the list of animations attached to this skeleton
  5248. */
  5249. animations: Array<Animation>;
  5250. private _scene;
  5251. private _isDirty;
  5252. private _transformMatrices;
  5253. private _meshesWithPoseMatrix;
  5254. private _animatables;
  5255. private _identity;
  5256. private _synchronizedWithMesh;
  5257. private _ranges;
  5258. private _lastAbsoluteTransformsUpdateId;
  5259. /**
  5260. * Specifies if the skeleton should be serialized
  5261. */
  5262. doNotSerialize: boolean;
  5263. private _animationPropertiesOverride;
  5264. /**
  5265. * Gets or sets the animation properties override
  5266. */
  5267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5268. /**
  5269. * An observable triggered before computing the skeleton's matrices
  5270. */
  5271. onBeforeComputeObservable: Observable<Skeleton>;
  5272. /**
  5273. * Creates a new skeleton
  5274. * @param name defines the skeleton name
  5275. * @param id defines the skeleton Id
  5276. * @param scene defines the hosting scene
  5277. */
  5278. constructor(
  5279. /** defines the skeleton name */
  5280. name: string,
  5281. /** defines the skeleton Id */
  5282. id: string, scene: Scene);
  5283. /**
  5284. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5285. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5286. * @returns a Float32Array containing matrices data
  5287. */
  5288. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5289. /**
  5290. * Gets the current hosting scene
  5291. * @returns a scene object
  5292. */
  5293. getScene(): Scene;
  5294. /**
  5295. * Gets a string representing the current skeleton data
  5296. * @param fullDetails defines a boolean indicating if we want a verbose version
  5297. * @returns a string representing the current skeleton data
  5298. */
  5299. toString(fullDetails?: boolean): string;
  5300. /**
  5301. * Get bone's index searching by name
  5302. * @param name defines bone's name to search for
  5303. * @return the indice of the bone. Returns -1 if not found
  5304. */
  5305. getBoneIndexByName(name: string): number;
  5306. /**
  5307. * Creater a new animation range
  5308. * @param name defines the name of the range
  5309. * @param from defines the start key
  5310. * @param to defines the end key
  5311. */
  5312. createAnimationRange(name: string, from: number, to: number): void;
  5313. /**
  5314. * Delete a specific animation range
  5315. * @param name defines the name of the range
  5316. * @param deleteFrames defines if frames must be removed as well
  5317. */
  5318. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5319. /**
  5320. * Gets a specific animation range
  5321. * @param name defines the name of the range to look for
  5322. * @returns the requested animation range or null if not found
  5323. */
  5324. getAnimationRange(name: string): Nullable<AnimationRange>;
  5325. /**
  5326. * Gets the list of all animation ranges defined on this skeleton
  5327. * @returns an array
  5328. */
  5329. getAnimationRanges(): Nullable<AnimationRange>[];
  5330. /**
  5331. * Copy animation range from a source skeleton.
  5332. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5333. * @param source defines the source skeleton
  5334. * @param name defines the name of the range to copy
  5335. * @param rescaleAsRequired defines if rescaling must be applied if required
  5336. * @returns true if operation was successful
  5337. */
  5338. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5339. /**
  5340. * Forces the skeleton to go to rest pose
  5341. */
  5342. returnToRest(): void;
  5343. private _getHighestAnimationFrame();
  5344. /**
  5345. * Begin a specific animation range
  5346. * @param name defines the name of the range to start
  5347. * @param loop defines if looping must be turned on (false by default)
  5348. * @param speedRatio defines the speed ratio to apply (1 by default)
  5349. * @param onAnimationEnd defines a callback which will be called when animation will end
  5350. * @returns a new animatable
  5351. */
  5352. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5353. /** @hidden */
  5354. _markAsDirty(): void;
  5355. /** @hidden */
  5356. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5357. /** @hidden */
  5358. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5359. /** @hidden */
  5360. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5361. /**
  5362. * Build all resources required to render a skeleton
  5363. */
  5364. prepare(): void;
  5365. /**
  5366. * Gets the list of animatables currently running for this skeleton
  5367. * @returns an array of animatables
  5368. */
  5369. getAnimatables(): IAnimatable[];
  5370. /**
  5371. * Clone the current skeleton
  5372. * @param name defines the name of the new skeleton
  5373. * @param id defines the id of the enw skeleton
  5374. * @returns the new skeleton
  5375. */
  5376. clone(name: string, id: string): Skeleton;
  5377. /**
  5378. * Enable animation blending for this skeleton
  5379. * @param blendingSpeed defines the blending speed to apply
  5380. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5381. */
  5382. enableBlending(blendingSpeed?: number): void;
  5383. /**
  5384. * Releases all resources associated with the current skeleton
  5385. */
  5386. dispose(): void;
  5387. /**
  5388. * Serialize the skeleton in a JSON object
  5389. * @returns a JSON object
  5390. */
  5391. serialize(): any;
  5392. /**
  5393. * Creates a new skeleton from serialized data
  5394. * @param parsedSkeleton defines the serialized data
  5395. * @param scene defines the hosting scene
  5396. * @returns a new skeleton
  5397. */
  5398. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5399. /**
  5400. * Compute all node absolute transforms
  5401. * @param forceUpdate defines if computation must be done even if cache is up to date
  5402. */
  5403. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5404. /**
  5405. * Gets the root pose matrix
  5406. * @returns a matrix
  5407. */
  5408. getPoseMatrix(): Nullable<Matrix>;
  5409. /**
  5410. * Sorts bones per internal index
  5411. */
  5412. sortBones(): void;
  5413. private _sortBones(index, bones, visited);
  5414. }
  5415. }
  5416. declare module BABYLON {
  5417. class Collider {
  5418. /** Define if a collision was found */
  5419. collisionFound: boolean;
  5420. /**
  5421. * Define last intersection point in local space
  5422. */
  5423. intersectionPoint: Vector3;
  5424. /**
  5425. * Define last collided mesh
  5426. */
  5427. collidedMesh: Nullable<AbstractMesh>;
  5428. private _collisionPoint;
  5429. private _planeIntersectionPoint;
  5430. private _tempVector;
  5431. private _tempVector2;
  5432. private _tempVector3;
  5433. private _tempVector4;
  5434. private _edge;
  5435. private _baseToVertex;
  5436. private _destinationPoint;
  5437. private _slidePlaneNormal;
  5438. private _displacementVector;
  5439. _radius: Vector3;
  5440. _retry: number;
  5441. private _velocity;
  5442. private _basePoint;
  5443. private _epsilon;
  5444. _velocityWorldLength: number;
  5445. _basePointWorld: Vector3;
  5446. private _velocityWorld;
  5447. private _normalizedVelocity;
  5448. _initialVelocity: Vector3;
  5449. _initialPosition: Vector3;
  5450. private _nearestDistance;
  5451. private _collisionMask;
  5452. collisionMask: number;
  5453. /**
  5454. * Gets the plane normal used to compute the sliding response (in local space)
  5455. */
  5456. readonly slidePlaneNormal: Vector3;
  5457. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5458. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5459. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5460. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5461. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5462. _getResponse(pos: Vector3, vel: Vector3): void;
  5463. }
  5464. }
  5465. declare module BABYLON {
  5466. var CollisionWorker: string;
  5467. interface ICollisionCoordinator {
  5468. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5469. init(scene: Scene): void;
  5470. destroy(): void;
  5471. onMeshAdded(mesh: AbstractMesh): void;
  5472. onMeshUpdated(mesh: AbstractMesh): void;
  5473. onMeshRemoved(mesh: AbstractMesh): void;
  5474. onGeometryAdded(geometry: Geometry): void;
  5475. onGeometryUpdated(geometry: Geometry): void;
  5476. onGeometryDeleted(geometry: Geometry): void;
  5477. }
  5478. interface SerializedMesh {
  5479. id: string;
  5480. name: string;
  5481. uniqueId: number;
  5482. geometryId: Nullable<string>;
  5483. sphereCenter: Array<number>;
  5484. sphereRadius: number;
  5485. boxMinimum: Array<number>;
  5486. boxMaximum: Array<number>;
  5487. worldMatrixFromCache: any;
  5488. subMeshes: Array<SerializedSubMesh>;
  5489. checkCollisions: boolean;
  5490. }
  5491. interface SerializedSubMesh {
  5492. position: number;
  5493. verticesStart: number;
  5494. verticesCount: number;
  5495. indexStart: number;
  5496. indexCount: number;
  5497. hasMaterial: boolean;
  5498. sphereCenter: Array<number>;
  5499. sphereRadius: number;
  5500. boxMinimum: Array<number>;
  5501. boxMaximum: Array<number>;
  5502. }
  5503. /**
  5504. * Interface describing the value associated with a geometry
  5505. */
  5506. interface SerializedGeometry {
  5507. /**
  5508. * Defines the unique ID of the geometry
  5509. */
  5510. id: string;
  5511. /**
  5512. * Defines the array containing the positions
  5513. */
  5514. positions: Float32Array;
  5515. /**
  5516. * Defines the array containing the indices
  5517. */
  5518. indices: Uint32Array;
  5519. /**
  5520. * Defines the array containing the normals
  5521. */
  5522. normals: Float32Array;
  5523. }
  5524. interface BabylonMessage {
  5525. taskType: WorkerTaskType;
  5526. payload: InitPayload | CollidePayload | UpdatePayload;
  5527. }
  5528. interface SerializedColliderToWorker {
  5529. position: Array<number>;
  5530. velocity: Array<number>;
  5531. radius: Array<number>;
  5532. }
  5533. /** Defines supported task for worker process */
  5534. enum WorkerTaskType {
  5535. /** Initialization */
  5536. INIT = 0,
  5537. /** Update of geometry */
  5538. UPDATE = 1,
  5539. /** Evaluate collision */
  5540. COLLIDE = 2,
  5541. }
  5542. interface WorkerReply {
  5543. error: WorkerReplyType;
  5544. taskType: WorkerTaskType;
  5545. payload?: any;
  5546. }
  5547. interface CollisionReplyPayload {
  5548. newPosition: Array<number>;
  5549. collisionId: number;
  5550. collidedMeshUniqueId: number;
  5551. }
  5552. interface InitPayload {
  5553. }
  5554. interface CollidePayload {
  5555. collisionId: number;
  5556. collider: SerializedColliderToWorker;
  5557. maximumRetry: number;
  5558. excludedMeshUniqueId: Nullable<number>;
  5559. }
  5560. interface UpdatePayload {
  5561. updatedMeshes: {
  5562. [n: number]: SerializedMesh;
  5563. };
  5564. updatedGeometries: {
  5565. [s: string]: SerializedGeometry;
  5566. };
  5567. removedMeshes: Array<number>;
  5568. removedGeometries: Array<string>;
  5569. }
  5570. /** Defines kind of replies returned by worker */
  5571. enum WorkerReplyType {
  5572. /** Success */
  5573. SUCCESS = 0,
  5574. /** Unkown error */
  5575. UNKNOWN_ERROR = 1,
  5576. }
  5577. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5578. private _scene;
  5579. private _scaledPosition;
  5580. private _scaledVelocity;
  5581. private _collisionsCallbackArray;
  5582. private _init;
  5583. private _runningUpdated;
  5584. private _worker;
  5585. private _addUpdateMeshesList;
  5586. private _addUpdateGeometriesList;
  5587. private _toRemoveMeshesArray;
  5588. private _toRemoveGeometryArray;
  5589. constructor();
  5590. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5591. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5592. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5593. init(scene: Scene): void;
  5594. destroy(): void;
  5595. onMeshAdded(mesh: AbstractMesh): void;
  5596. onMeshUpdated: (transformNode: TransformNode) => void;
  5597. onMeshRemoved(mesh: AbstractMesh): void;
  5598. onGeometryAdded(geometry: Geometry): void;
  5599. onGeometryUpdated: (geometry: Geometry) => void;
  5600. onGeometryDeleted(geometry: Geometry): void;
  5601. private _afterRender;
  5602. private _onMessageFromWorker;
  5603. }
  5604. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5605. private _scene;
  5606. private _scaledPosition;
  5607. private _scaledVelocity;
  5608. private _finalPosition;
  5609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5610. init(scene: Scene): void;
  5611. destroy(): void;
  5612. onMeshAdded(mesh: AbstractMesh): void;
  5613. onMeshUpdated(mesh: AbstractMesh): void;
  5614. onMeshRemoved(mesh: AbstractMesh): void;
  5615. onGeometryAdded(geometry: Geometry): void;
  5616. onGeometryUpdated(geometry: Geometry): void;
  5617. onGeometryDeleted(geometry: Geometry): void;
  5618. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5619. }
  5620. }
  5621. declare function importScripts(...urls: string[]): void;
  5622. declare const safePostMessage: any;
  5623. declare module BABYLON {
  5624. var WorkerIncluded: boolean;
  5625. class CollisionCache {
  5626. private _meshes;
  5627. private _geometries;
  5628. getMeshes(): {
  5629. [n: number]: SerializedMesh;
  5630. };
  5631. getGeometries(): {
  5632. [s: number]: SerializedGeometry;
  5633. };
  5634. getMesh(id: any): SerializedMesh;
  5635. addMesh(mesh: SerializedMesh): void;
  5636. removeMesh(uniqueId: number): void;
  5637. getGeometry(id: string): SerializedGeometry;
  5638. addGeometry(geometry: SerializedGeometry): void;
  5639. removeGeometry(id: string): void;
  5640. }
  5641. class CollideWorker {
  5642. collider: Collider;
  5643. private _collisionCache;
  5644. private finalPosition;
  5645. private collisionsScalingMatrix;
  5646. private collisionTranformationMatrix;
  5647. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5648. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5649. private checkCollision(mesh);
  5650. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5651. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5652. private checkSubmeshCollision(subMesh);
  5653. }
  5654. interface ICollisionDetector {
  5655. onInit(payload: InitPayload): void;
  5656. onUpdate(payload: UpdatePayload): void;
  5657. onCollision(payload: CollidePayload): void;
  5658. }
  5659. class CollisionDetectorTransferable implements ICollisionDetector {
  5660. private _collisionCache;
  5661. onInit(payload: InitPayload): void;
  5662. onUpdate(payload: UpdatePayload): void;
  5663. onCollision(payload: CollidePayload): void;
  5664. }
  5665. }
  5666. declare module BABYLON {
  5667. class IntersectionInfo {
  5668. bu: Nullable<number>;
  5669. bv: Nullable<number>;
  5670. distance: number;
  5671. faceId: number;
  5672. subMeshId: number;
  5673. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5674. }
  5675. /**
  5676. * Information about the result of picking within a scene
  5677. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5678. */
  5679. class PickingInfo {
  5680. /**
  5681. * If the pick collided with an object
  5682. */
  5683. hit: boolean;
  5684. /**
  5685. * Distance away where the pick collided
  5686. */
  5687. distance: number;
  5688. /**
  5689. * The location of pick collision
  5690. */
  5691. pickedPoint: Nullable<Vector3>;
  5692. /**
  5693. * The mesh corrisponding the the pick collision
  5694. */
  5695. pickedMesh: Nullable<AbstractMesh>;
  5696. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5697. bu: number;
  5698. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5699. bv: number;
  5700. /** The id of the face on the mesh that was picked */
  5701. faceId: number;
  5702. /** Id of the the submesh that was picked */
  5703. subMeshId: number;
  5704. /** If a sprite was picked, this will be the sprite the pick collided with */
  5705. pickedSprite: Nullable<Sprite>;
  5706. /**
  5707. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5708. */
  5709. originMesh: Nullable<AbstractMesh>;
  5710. /**
  5711. * The ray that was used to perform the picking.
  5712. */
  5713. ray: Nullable<Ray>;
  5714. /**
  5715. * Gets the normal corrispodning to the face the pick collided with
  5716. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5717. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5718. * @returns The normal corrispodning to the face the pick collided with
  5719. */
  5720. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5721. /**
  5722. * Gets the texture coordinates of where the pick occured
  5723. * @returns the vector containing the coordnates of the texture
  5724. */
  5725. getTextureCoordinates(): Nullable<Vector2>;
  5726. }
  5727. }
  5728. /**
  5729. * Module Debug contains the (visual) components to debug a scene correctly
  5730. */
  5731. declare module BABYLON.Debug {
  5732. /**
  5733. * The Axes viewer will show 3 axes in a specific point in space
  5734. */
  5735. class AxesViewer {
  5736. private _xline;
  5737. private _yline;
  5738. private _zline;
  5739. private _xmesh;
  5740. private _ymesh;
  5741. private _zmesh;
  5742. /**
  5743. * Gets the hosting scene
  5744. */
  5745. scene: Nullable<Scene>;
  5746. /**
  5747. * Gets or sets a number used to scale line length
  5748. */
  5749. scaleLines: number;
  5750. /**
  5751. * Creates a new AxesViewer
  5752. * @param scene defines the hosting scene
  5753. * @param scaleLines defines a number used to scale line length (1 by default)
  5754. */
  5755. constructor(scene: Scene, scaleLines?: number);
  5756. /**
  5757. * Force the viewer to update
  5758. * @param position defines the position of the viewer
  5759. * @param xaxis defines the x axis of the viewer
  5760. * @param yaxis defines the y axis of the viewer
  5761. * @param zaxis defines the z axis of the viewer
  5762. */
  5763. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5764. /** Releases resources */
  5765. dispose(): void;
  5766. }
  5767. }
  5768. declare module BABYLON.Debug {
  5769. /**
  5770. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5771. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  5772. */
  5773. class BoneAxesViewer extends AxesViewer {
  5774. /**
  5775. * Gets or sets the target mesh where to display the axes viewer
  5776. */
  5777. mesh: Nullable<Mesh>;
  5778. /**
  5779. * Gets or sets the target bone where to display the axes viewer
  5780. */
  5781. bone: Nullable<Bone>;
  5782. /** Gets current position */
  5783. pos: Vector3;
  5784. /** Gets direction of X axis */
  5785. xaxis: Vector3;
  5786. /** Gets direction of Y axis */
  5787. yaxis: Vector3;
  5788. /** Gets direction of Z axis */
  5789. zaxis: Vector3;
  5790. /**
  5791. * Creates a new BoneAxesViewer
  5792. * @param scene defines the hosting scene
  5793. * @param bone defines the target bone
  5794. * @param mesh defines the target mesh
  5795. * @param scaleLines defines a scaling factor for line length (1 by default)
  5796. */
  5797. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5798. /**
  5799. * Force the viewer to update
  5800. */
  5801. update(): void;
  5802. /** Releases resources */
  5803. dispose(): void;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. class DebugLayer {
  5808. private _scene;
  5809. static InspectorURL: string;
  5810. private _inspector;
  5811. private BJSINSPECTOR;
  5812. constructor(scene: Scene);
  5813. /** Creates the inspector window. */
  5814. private _createInspector(config?);
  5815. isVisible(): boolean;
  5816. hide(): void;
  5817. show(config?: {
  5818. popup?: boolean;
  5819. initialTab?: number;
  5820. parentElement?: HTMLElement;
  5821. newColors?: {
  5822. backgroundColor?: string;
  5823. backgroundColorLighter?: string;
  5824. backgroundColorLighter2?: string;
  5825. backgroundColorLighter3?: string;
  5826. color?: string;
  5827. colorTop?: string;
  5828. colorBot?: string;
  5829. };
  5830. }): void;
  5831. /**
  5832. * Gets the active tab
  5833. * @return the index of the active tab or -1 if the inspector is hidden
  5834. */
  5835. getActiveTab(): number;
  5836. }
  5837. }
  5838. declare module BABYLON.Debug {
  5839. /**
  5840. * Used to show the physics impostor around the specific mesh
  5841. */
  5842. class PhysicsViewer {
  5843. /** @hidden */
  5844. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5845. /** @hidden */
  5846. protected _meshes: Array<Nullable<AbstractMesh>>;
  5847. /** @hidden */
  5848. protected _scene: Nullable<Scene>;
  5849. /** @hidden */
  5850. protected _numMeshes: number;
  5851. /** @hidden */
  5852. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5853. private _renderFunction;
  5854. private _debugBoxMesh;
  5855. private _debugSphereMesh;
  5856. private _debugMaterial;
  5857. /**
  5858. * Creates a new PhysicsViewer
  5859. * @param scene defines the hosting scene
  5860. */
  5861. constructor(scene: Scene);
  5862. /** @hidden */
  5863. protected _updateDebugMeshes(): void;
  5864. /**
  5865. * Renders a specified physic impostor
  5866. * @param impostor defines the impostor to render
  5867. */
  5868. showImpostor(impostor: PhysicsImpostor): void;
  5869. /**
  5870. * Hides a specified physic impostor
  5871. * @param impostor defines the impostor to hide
  5872. */
  5873. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5874. private _getDebugMaterial(scene);
  5875. private _getDebugBoxMesh(scene);
  5876. private _getDebugSphereMesh(scene);
  5877. private _getDebugMesh(impostor, scene);
  5878. /** Releases all resources */
  5879. dispose(): void;
  5880. }
  5881. }
  5882. declare module BABYLON {
  5883. class RayHelper {
  5884. ray: Nullable<Ray>;
  5885. private _renderPoints;
  5886. private _renderLine;
  5887. private _renderFunction;
  5888. private _scene;
  5889. private _updateToMeshFunction;
  5890. private _attachedToMesh;
  5891. private _meshSpaceDirection;
  5892. private _meshSpaceOrigin;
  5893. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5894. constructor(ray: Ray);
  5895. show(scene: Scene, color: Color3): void;
  5896. hide(): void;
  5897. private _render();
  5898. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5899. detachFromMesh(): void;
  5900. private _updateToMesh();
  5901. dispose(): void;
  5902. }
  5903. }
  5904. declare module BABYLON.Debug {
  5905. /**
  5906. * Class used to render a debug view of a given skeleton
  5907. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  5908. */
  5909. class SkeletonViewer {
  5910. /** defines the skeleton to render */
  5911. skeleton: Skeleton;
  5912. /** defines the mesh attached to the skeleton */
  5913. mesh: AbstractMesh;
  5914. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  5915. autoUpdateBonesMatrices: boolean;
  5916. /** defines the rendering group id to use with the viewer */
  5917. renderingGroupId: number;
  5918. /** Gets or sets the color used to render the skeleton */
  5919. color: Color3;
  5920. private _scene;
  5921. private _debugLines;
  5922. private _debugMesh;
  5923. private _isEnabled;
  5924. private _renderFunction;
  5925. /**
  5926. * Creates a new SkeletonViewer
  5927. * @param skeleton defines the skeleton to render
  5928. * @param mesh defines the mesh attached to the skeleton
  5929. * @param scene defines the hosting scene
  5930. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  5931. * @param renderingGroupId defines the rendering group id to use with the viewer
  5932. */
  5933. constructor(
  5934. /** defines the skeleton to render */
  5935. skeleton: Skeleton,
  5936. /** defines the mesh attached to the skeleton */
  5937. mesh: AbstractMesh, scene: Scene,
  5938. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  5939. autoUpdateBonesMatrices?: boolean,
  5940. /** defines the rendering group id to use with the viewer */
  5941. renderingGroupId?: number);
  5942. /** Gets or sets a boolean indicating if the viewer is enabled */
  5943. isEnabled: boolean;
  5944. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5945. private _getLinesForBonesWithLength(bones, meshMat);
  5946. private _getLinesForBonesNoLength(bones, meshMat);
  5947. /** Update the viewer to sync with current skeleton state */
  5948. update(): void;
  5949. /** Release associated resources */
  5950. dispose(): void;
  5951. }
  5952. }
  5953. declare module BABYLON {
  5954. /**
  5955. * Interface for attribute information associated with buffer instanciation
  5956. */
  5957. class InstancingAttributeInfo {
  5958. /**
  5959. * Index/offset of the attribute in the vertex shader
  5960. */
  5961. index: number;
  5962. /**
  5963. * size of the attribute, 1, 2, 3 or 4
  5964. */
  5965. attributeSize: number;
  5966. /**
  5967. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5968. * default is FLOAT
  5969. */
  5970. attribyteType: number;
  5971. /**
  5972. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5973. */
  5974. normalized: boolean;
  5975. /**
  5976. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5977. */
  5978. offset: number;
  5979. /**
  5980. * Name of the GLSL attribute, for debugging purpose only
  5981. */
  5982. attributeName: string;
  5983. }
  5984. /**
  5985. * Define options used to create a render target texture
  5986. */
  5987. class RenderTargetCreationOptions {
  5988. /**
  5989. * Specifies is mipmaps must be generated
  5990. */
  5991. generateMipMaps?: boolean;
  5992. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5993. generateDepthBuffer?: boolean;
  5994. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5995. generateStencilBuffer?: boolean;
  5996. /** Defines texture type (int by default) */
  5997. type?: number;
  5998. /** Defines sampling mode (trilinear by default) */
  5999. samplingMode?: number;
  6000. /** Defines format (RGBA by default) */
  6001. format?: number;
  6002. }
  6003. /**
  6004. * Define options used to create a depth texture
  6005. */
  6006. class DepthTextureCreationOptions {
  6007. /** Specifies whether or not a stencil should be allocated in the texture */
  6008. generateStencil?: boolean;
  6009. /** Specifies whether or not bilinear filtering is enable on the texture */
  6010. bilinearFiltering?: boolean;
  6011. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6012. comparisonFunction?: number;
  6013. /** Specifies if the created texture is a cube texture */
  6014. isCube?: boolean;
  6015. }
  6016. /**
  6017. * Class used to describe the capabilities of the engine relatively to the current browser
  6018. */
  6019. class EngineCapabilities {
  6020. /** Maximum textures units per fragment shader */
  6021. maxTexturesImageUnits: number;
  6022. /** Maximum texture units per vertex shader */
  6023. maxVertexTextureImageUnits: number;
  6024. /** Maximum textures units in the entire pipeline */
  6025. maxCombinedTexturesImageUnits: number;
  6026. /** Maximum texture size */
  6027. maxTextureSize: number;
  6028. /** Maximum cube texture size */
  6029. maxCubemapTextureSize: number;
  6030. /** Maximum render texture size */
  6031. maxRenderTextureSize: number;
  6032. /** Maximum number of vertex attributes */
  6033. maxVertexAttribs: number;
  6034. /** Maximum number of varyings */
  6035. maxVaryingVectors: number;
  6036. /** Maximum number of uniforms per vertex shader */
  6037. maxVertexUniformVectors: number;
  6038. /** Maximum number of uniforms per fragment shader */
  6039. maxFragmentUniformVectors: number;
  6040. /** Defines if standard derivates (dx/dy) are supported */
  6041. standardDerivatives: boolean;
  6042. /** Defines if s3tc texture compression is supported */
  6043. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6044. /** Defines if pvrtc texture compression is supported */
  6045. pvrtc: any;
  6046. /** Defines if etc1 texture compression is supported */
  6047. etc1: any;
  6048. /** Defines if etc2 texture compression is supported */
  6049. etc2: any;
  6050. /** Defines if astc texture compression is supported */
  6051. astc: any;
  6052. /** Defines if float textures are supported */
  6053. textureFloat: boolean;
  6054. /** Defines if vertex array objects are supported */
  6055. vertexArrayObject: boolean;
  6056. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6057. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6058. /** Gets the maximum level of anisotropy supported */
  6059. maxAnisotropy: number;
  6060. /** Defines if instancing is supported */
  6061. instancedArrays: boolean;
  6062. /** Defines if 32 bits indices are supported */
  6063. uintIndices: boolean;
  6064. /** Defines if high precision shaders are supported */
  6065. highPrecisionShaderSupported: boolean;
  6066. /** Defines if depth reading in the fragment shader is supported */
  6067. fragmentDepthSupported: boolean;
  6068. /** Defines if float texture linear filtering is supported*/
  6069. textureFloatLinearFiltering: boolean;
  6070. /** Defines if rendering to float textures is supported */
  6071. textureFloatRender: boolean;
  6072. /** Defines if half float textures are supported*/
  6073. textureHalfFloat: boolean;
  6074. /** Defines if half float texture linear filtering is supported*/
  6075. textureHalfFloatLinearFiltering: boolean;
  6076. /** Defines if rendering to half float textures is supported */
  6077. textureHalfFloatRender: boolean;
  6078. /** Defines if textureLOD shader command is supported */
  6079. textureLOD: boolean;
  6080. /** Defines if draw buffers extension is supported */
  6081. drawBuffersExtension: boolean;
  6082. /** Defines if depth textures are supported */
  6083. depthTextureExtension: boolean;
  6084. /** Defines if float color buffer are supported */
  6085. colorBufferFloat: boolean;
  6086. /** Gets disjoint timer query extension (null if not supported) */
  6087. timerQuery: EXT_disjoint_timer_query;
  6088. /** Defines if timestamp can be used with timer query */
  6089. canUseTimestampForTimerQuery: boolean;
  6090. }
  6091. /** Interface defining initialization parameters for Engine class */
  6092. interface EngineOptions extends WebGLContextAttributes {
  6093. /**
  6094. * Defines if the engine should no exceed a specified device ratio
  6095. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6096. */
  6097. limitDeviceRatio?: number;
  6098. /**
  6099. * Defines if webvr should be enabled automatically
  6100. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6101. */
  6102. autoEnableWebVR?: boolean;
  6103. /**
  6104. * Defines if webgl2 should be turned off even if supported
  6105. * @see http://doc.babylonjs.com/features/webgl2
  6106. */
  6107. disableWebGL2Support?: boolean;
  6108. /**
  6109. * Defines if webaudio should be initialized as well
  6110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6111. */
  6112. audioEngine?: boolean;
  6113. /**
  6114. * Defines if animations should run using a deterministic lock step
  6115. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6116. */
  6117. deterministicLockstep?: boolean;
  6118. /** Defines the maximum steps to use with deterministic lock step mode */
  6119. lockstepMaxSteps?: number;
  6120. /**
  6121. * Defines that engine should ignore context lost events
  6122. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6123. */
  6124. doNotHandleContextLost?: boolean;
  6125. }
  6126. /**
  6127. * Defines the interface used by display changed events
  6128. */
  6129. interface IDisplayChangedEventArgs {
  6130. /** Gets the vrDisplay object (if any) */
  6131. vrDisplay: Nullable<any>;
  6132. /** Gets a boolean indicating if webVR is supported */
  6133. vrSupported: boolean;
  6134. }
  6135. /**
  6136. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6137. */
  6138. class Engine {
  6139. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6140. static ExceptionList: ({
  6141. key: string;
  6142. capture: string;
  6143. captureConstraint: number;
  6144. targets: string[];
  6145. } | {
  6146. key: string;
  6147. capture: null;
  6148. captureConstraint: null;
  6149. targets: string[];
  6150. })[];
  6151. /** Gets the list of created engines */
  6152. static Instances: Engine[];
  6153. /**
  6154. * Gets the latest created engine
  6155. */
  6156. static readonly LastCreatedEngine: Nullable<Engine>;
  6157. /**
  6158. * Gets the latest created scene
  6159. */
  6160. static readonly LastCreatedScene: Nullable<Scene>;
  6161. /**
  6162. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6163. * @param flag defines which part of the materials must be marked as dirty
  6164. * @param predicate defines a predicate used to filter which materials should be affected
  6165. */
  6166. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6167. private static _ALPHA_DISABLE;
  6168. private static _ALPHA_ADD;
  6169. private static _ALPHA_COMBINE;
  6170. private static _ALPHA_SUBTRACT;
  6171. private static _ALPHA_MULTIPLY;
  6172. private static _ALPHA_MAXIMIZED;
  6173. private static _ALPHA_ONEONE;
  6174. private static _ALPHA_PREMULTIPLIED;
  6175. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6176. private static _ALPHA_INTERPOLATE;
  6177. private static _ALPHA_SCREENMODE;
  6178. private static _DELAYLOADSTATE_NONE;
  6179. private static _DELAYLOADSTATE_LOADED;
  6180. private static _DELAYLOADSTATE_LOADING;
  6181. private static _DELAYLOADSTATE_NOTLOADED;
  6182. private static _TEXTUREFORMAT_ALPHA;
  6183. private static _TEXTUREFORMAT_LUMINANCE;
  6184. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6185. private static _TEXTUREFORMAT_RGB;
  6186. private static _TEXTUREFORMAT_RGBA;
  6187. private static _TEXTUREFORMAT_R;
  6188. private static _TEXTUREFORMAT_RG;
  6189. private static _TEXTURETYPE_UNSIGNED_INT;
  6190. private static _TEXTURETYPE_FLOAT;
  6191. private static _TEXTURETYPE_HALF_FLOAT;
  6192. private static _NEVER;
  6193. private static _ALWAYS;
  6194. private static _LESS;
  6195. private static _EQUAL;
  6196. private static _LEQUAL;
  6197. private static _GREATER;
  6198. private static _GEQUAL;
  6199. private static _NOTEQUAL;
  6200. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6201. static readonly NEVER: number;
  6202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6203. static readonly ALWAYS: number;
  6204. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6205. static readonly LESS: number;
  6206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6207. static readonly EQUAL: number;
  6208. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  6209. static readonly LEQUAL: number;
  6210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6211. static readonly GREATER: number;
  6212. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  6213. static readonly GEQUAL: number;
  6214. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  6215. static readonly NOTEQUAL: number;
  6216. private static _KEEP;
  6217. private static _REPLACE;
  6218. private static _INCR;
  6219. private static _DECR;
  6220. private static _INVERT;
  6221. private static _INCR_WRAP;
  6222. private static _DECR_WRAP;
  6223. /** Passed to stencilOperation to specify that stencil value must be kept */
  6224. static readonly KEEP: number;
  6225. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6226. static readonly REPLACE: number;
  6227. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6228. static readonly INCR: number;
  6229. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6230. static readonly DECR: number;
  6231. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6232. static readonly INVERT: number;
  6233. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6234. static readonly INCR_WRAP: number;
  6235. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6236. static readonly DECR_WRAP: number;
  6237. /** Defines that alpha blending is disabled */
  6238. static readonly ALPHA_DISABLE: number;
  6239. /** Defines that alpha blending to SRC + DEST */
  6240. static readonly ALPHA_ONEONE: number;
  6241. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6242. static readonly ALPHA_ADD: number;
  6243. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6244. static readonly ALPHA_COMBINE: number;
  6245. /** Defines that alpha blending to DEST - SRC * DEST */
  6246. static readonly ALPHA_SUBTRACT: number;
  6247. /** Defines that alpha blending to SRC * DEST */
  6248. static readonly ALPHA_MULTIPLY: number;
  6249. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6250. static readonly ALPHA_MAXIMIZED: number;
  6251. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6252. static readonly ALPHA_PREMULTIPLIED: number;
  6253. /**
  6254. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6255. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6256. */
  6257. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6258. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6259. static readonly ALPHA_INTERPOLATE: number;
  6260. /**
  6261. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6262. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6263. */
  6264. static readonly ALPHA_SCREENMODE: number;
  6265. /** Defines that the ressource is not delayed*/
  6266. static readonly DELAYLOADSTATE_NONE: number;
  6267. /** Defines that the ressource was successfully delay loaded */
  6268. static readonly DELAYLOADSTATE_LOADED: number;
  6269. /** Defines that the ressource is currently delay loading */
  6270. static readonly DELAYLOADSTATE_LOADING: number;
  6271. /** Defines that the ressource is delayed and has not started loading */
  6272. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6273. /** ALPHA */
  6274. static readonly TEXTUREFORMAT_ALPHA: number;
  6275. /** LUMINANCE */
  6276. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6277. /**
  6278. * R
  6279. */
  6280. static readonly TEXTUREFORMAT_R: number;
  6281. /**
  6282. * RG
  6283. */
  6284. static readonly TEXTUREFORMAT_RG: number;
  6285. /** LUMINANCE_ALPHA */
  6286. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6287. /** RGB */
  6288. static readonly TEXTUREFORMAT_RGB: number;
  6289. /** RGBA */
  6290. static readonly TEXTUREFORMAT_RGBA: number;
  6291. /** UNSIGNED_INT */
  6292. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6293. /** FLOAT */
  6294. static readonly TEXTURETYPE_FLOAT: number;
  6295. /** HALF_FLOAT */
  6296. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6297. private static _SCALEMODE_FLOOR;
  6298. private static _SCALEMODE_NEAREST;
  6299. private static _SCALEMODE_CEILING;
  6300. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6301. static readonly SCALEMODE_FLOOR: number;
  6302. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6303. static readonly SCALEMODE_NEAREST: number;
  6304. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6305. static readonly SCALEMODE_CEILING: number;
  6306. /**
  6307. * Returns the current version of the framework
  6308. */
  6309. static readonly Version: string;
  6310. /**
  6311. * Gets or sets the epsilon value used by collision engine
  6312. */
  6313. static CollisionsEpsilon: number;
  6314. /**
  6315. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6316. */
  6317. static CodeRepository: string;
  6318. /**
  6319. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6320. */
  6321. static ShadersRepository: string;
  6322. /**
  6323. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6324. */
  6325. forcePOTTextures: boolean;
  6326. /**
  6327. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6328. */
  6329. isFullscreen: boolean;
  6330. /**
  6331. * Gets a boolean indicating if the pointer is currently locked
  6332. */
  6333. isPointerLock: boolean;
  6334. /**
  6335. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6336. */
  6337. cullBackFaces: boolean;
  6338. /**
  6339. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6340. */
  6341. renderEvenInBackground: boolean;
  6342. /**
  6343. * Gets or sets a boolean indicating that cache can be kept between frames
  6344. */
  6345. preventCacheWipeBetweenFrames: boolean;
  6346. /**
  6347. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6348. **/
  6349. enableOfflineSupport: boolean;
  6350. /**
  6351. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  6352. **/
  6353. disableManifestCheck: boolean;
  6354. /**
  6355. * Gets the list of created scenes
  6356. */
  6357. scenes: Scene[];
  6358. /**
  6359. * Gets the list of created postprocesses
  6360. */
  6361. postProcesses: PostProcess[];
  6362. /**
  6363. * Observable event triggered each time the rendering canvas is resized
  6364. */
  6365. onResizeObservable: Observable<Engine>;
  6366. /**
  6367. * Observable event triggered each time the canvas loses focus
  6368. */
  6369. onCanvasBlurObservable: Observable<Engine>;
  6370. /**
  6371. * Observable event triggered each time the canvas gains focus
  6372. */
  6373. onCanvasFocusObservable: Observable<Engine>;
  6374. /**
  6375. * Observable event triggered each time the canvas receives pointerout event
  6376. */
  6377. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6378. /**
  6379. * Observable event triggered before each texture is initialized
  6380. */
  6381. onBeforeTextureInitObservable: Observable<Texture>;
  6382. private _vrDisplay;
  6383. private _vrSupported;
  6384. private _oldSize;
  6385. private _oldHardwareScaleFactor;
  6386. private _vrExclusivePointerMode;
  6387. private _webVRInitPromise;
  6388. /**
  6389. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6390. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6391. */
  6392. readonly isInVRExclusivePointerMode: boolean;
  6393. /**
  6394. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6395. */
  6396. disableUniformBuffers: boolean;
  6397. /** @hidden */
  6398. _uniformBuffers: UniformBuffer[];
  6399. /**
  6400. * Gets a boolean indicating that the engine supports uniform buffers
  6401. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6402. */
  6403. readonly supportsUniformBuffers: boolean;
  6404. /**
  6405. * Observable raised when the engine begins a new frame
  6406. */
  6407. onBeginFrameObservable: Observable<Engine>;
  6408. /**
  6409. * Observable raised when the engine ends the current frame
  6410. */
  6411. onEndFrameObservable: Observable<Engine>;
  6412. /**
  6413. * Observable raised when the engine is about to compile a shader
  6414. */
  6415. onBeforeShaderCompilationObservable: Observable<Engine>;
  6416. /**
  6417. * Observable raised when the engine has jsut compiled a shader
  6418. */
  6419. onAfterShaderCompilationObservable: Observable<Engine>;
  6420. private _gl;
  6421. private _renderingCanvas;
  6422. private _windowIsBackground;
  6423. private _webGLVersion;
  6424. /**
  6425. * Gets a boolean indicating that only power of 2 textures are supported
  6426. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6427. */
  6428. readonly needPOTTextures: boolean;
  6429. /** @hidden */
  6430. _badOS: boolean;
  6431. /** @hidden */
  6432. _badDesktopOS: boolean;
  6433. /**
  6434. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6435. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6436. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6437. */
  6438. disableTextureBindingOptimization: boolean;
  6439. /**
  6440. * Gets the audio engine
  6441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6442. * @ignorenaming
  6443. */
  6444. static audioEngine: AudioEngine;
  6445. private _onFocus;
  6446. private _onBlur;
  6447. private _onCanvasPointerOut;
  6448. private _onCanvasBlur;
  6449. private _onCanvasFocus;
  6450. private _onFullscreenChange;
  6451. private _onPointerLockChange;
  6452. private _onVRDisplayPointerRestricted;
  6453. private _onVRDisplayPointerUnrestricted;
  6454. private _onVrDisplayConnect;
  6455. private _onVrDisplayDisconnect;
  6456. private _onVrDisplayPresentChange;
  6457. /**
  6458. * Observable signaled when VR display mode changes
  6459. */
  6460. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6461. /**
  6462. * Observable signaled when VR request present is complete
  6463. */
  6464. onVRRequestPresentComplete: Observable<boolean>;
  6465. /**
  6466. * Observable signaled when VR request present starts
  6467. */
  6468. onVRRequestPresentStart: Observable<Engine>;
  6469. private _hardwareScalingLevel;
  6470. /** @hidden */
  6471. protected _caps: EngineCapabilities;
  6472. private _pointerLockRequested;
  6473. private _isStencilEnable;
  6474. private _colorWrite;
  6475. private _loadingScreen;
  6476. /** @hidden */
  6477. _drawCalls: PerfCounter;
  6478. /** @hidden */
  6479. _textureCollisions: PerfCounter;
  6480. private _glVersion;
  6481. private _glRenderer;
  6482. private _glVendor;
  6483. private _videoTextureSupported;
  6484. private _renderingQueueLaunched;
  6485. private _activeRenderLoops;
  6486. private _deterministicLockstep;
  6487. private _lockstepMaxSteps;
  6488. /**
  6489. * Observable signaled when a context lost event is raised
  6490. */
  6491. onContextLostObservable: Observable<Engine>;
  6492. /**
  6493. * Observable signaled when a context restored event is raised
  6494. */
  6495. onContextRestoredObservable: Observable<Engine>;
  6496. private _onContextLost;
  6497. private _onContextRestored;
  6498. private _contextWasLost;
  6499. private _doNotHandleContextLost;
  6500. /**
  6501. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  6502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  6503. */
  6504. doNotHandleContextLost: boolean;
  6505. private _performanceMonitor;
  6506. private _fps;
  6507. private _deltaTime;
  6508. /**
  6509. * Turn this value on if you want to pause FPS computation when in background
  6510. */
  6511. disablePerformanceMonitorInBackground: boolean;
  6512. /**
  6513. * Gets the performance monitor attached to this engine
  6514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6515. */
  6516. readonly performanceMonitor: PerformanceMonitor;
  6517. /** @hidden */
  6518. protected _depthCullingState: _DepthCullingState;
  6519. /** @hidden */
  6520. protected _stencilState: _StencilState;
  6521. /** @hidden */
  6522. protected _alphaState: _AlphaState;
  6523. /** @hidden */
  6524. protected _alphaMode: number;
  6525. protected _internalTexturesCache: InternalTexture[];
  6526. /** @hidden */
  6527. protected _activeChannel: number;
  6528. private _currentTextureChannel;
  6529. /** @hidden */
  6530. protected _boundTexturesCache: {
  6531. [key: string]: Nullable<InternalTexture>;
  6532. };
  6533. /** @hidden */
  6534. protected _currentEffect: Nullable<Effect>;
  6535. /** @hidden */
  6536. protected _currentProgram: Nullable<WebGLProgram>;
  6537. private _compiledEffects;
  6538. private _vertexAttribArraysEnabled;
  6539. /** @hidden */
  6540. protected _cachedViewport: Nullable<Viewport>;
  6541. private _cachedVertexArrayObject;
  6542. /** @hidden */
  6543. protected _cachedVertexBuffers: any;
  6544. /** @hidden */
  6545. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6546. /** @hidden */
  6547. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6548. /** @hidden */
  6549. protected _currentRenderTarget: Nullable<InternalTexture>;
  6550. private _uintIndicesCurrentlySet;
  6551. private _currentBoundBuffer;
  6552. /** @hidden */
  6553. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6554. private _currentBufferPointers;
  6555. private _currentInstanceLocations;
  6556. private _currentInstanceBuffers;
  6557. private _textureUnits;
  6558. private _firstBoundInternalTextureTracker;
  6559. private _lastBoundInternalTextureTracker;
  6560. private _workingCanvas;
  6561. private _workingContext;
  6562. private _rescalePostProcess;
  6563. private _dummyFramebuffer;
  6564. private _externalData;
  6565. private _bindedRenderFunction;
  6566. private _vaoRecordInProgress;
  6567. private _mustWipeVertexAttributes;
  6568. private _emptyTexture;
  6569. private _emptyCubeTexture;
  6570. private _emptyTexture3D;
  6571. private _frameHandler;
  6572. private _nextFreeTextureSlots;
  6573. private _maxSimultaneousTextures;
  6574. private _activeRequests;
  6575. private _texturesSupported;
  6576. private _textureFormatInUse;
  6577. /**
  6578. * Gets the list of texture formats supported
  6579. */
  6580. readonly texturesSupported: Array<string>;
  6581. /**
  6582. * Gets the list of texture formats in use
  6583. */
  6584. readonly textureFormatInUse: Nullable<string>;
  6585. /**
  6586. * Gets the current viewport
  6587. */
  6588. readonly currentViewport: Nullable<Viewport>;
  6589. /**
  6590. * Gets the default empty texture
  6591. */
  6592. readonly emptyTexture: InternalTexture;
  6593. /**
  6594. * Gets the default empty 3D texture
  6595. */
  6596. readonly emptyTexture3D: InternalTexture;
  6597. /**
  6598. * Gets the default empty cube texture
  6599. */
  6600. readonly emptyCubeTexture: InternalTexture;
  6601. /**
  6602. * Creates a new engine
  6603. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6604. * @param antialias defines enable antialiasing (default: false)
  6605. * @param options defines further options to be sent to the getContext() function
  6606. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6607. */
  6608. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6609. private _rebuildInternalTextures();
  6610. private _rebuildEffects();
  6611. private _rebuildBuffers();
  6612. private _initGLContext();
  6613. /**
  6614. * Gets version of the current webGL context
  6615. */
  6616. readonly webGLVersion: number;
  6617. /**
  6618. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6619. */
  6620. readonly isStencilEnable: boolean;
  6621. private _prepareWorkingCanvas();
  6622. /**
  6623. * Reset the texture cache to empty state
  6624. */
  6625. resetTextureCache(): void;
  6626. /**
  6627. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6629. * @returns true if engine is in deterministic lock step mode
  6630. */
  6631. isDeterministicLockStep(): boolean;
  6632. /**
  6633. * Gets the max steps when engine is running in deterministic lock step
  6634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6635. * @returns the max steps
  6636. */
  6637. getLockstepMaxSteps(): number;
  6638. /**
  6639. * Gets an object containing information about the current webGL context
  6640. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6641. */
  6642. getGlInfo(): {
  6643. vendor: string;
  6644. renderer: string;
  6645. version: string;
  6646. };
  6647. /**
  6648. * Gets current aspect ratio
  6649. * @param camera defines the camera to use to get the aspect ratio
  6650. * @param useScreen defines if screen size must be used (or the current render target if any)
  6651. * @returns a number defining the aspect ratio
  6652. */
  6653. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6654. /**
  6655. * Gets current screen aspect ratio
  6656. * @returns a number defining the aspect ratio
  6657. */
  6658. getScreenAspectRatio(): number;
  6659. /**
  6660. * Gets the current render width
  6661. * @param useScreen defines if screen size must be used (or the current render target if any)
  6662. * @returns a number defining the current render width
  6663. */
  6664. getRenderWidth(useScreen?: boolean): number;
  6665. /**
  6666. * Gets the current render height
  6667. * @param useScreen defines if screen size must be used (or the current render target if any)
  6668. * @returns a number defining the current render height
  6669. */
  6670. getRenderHeight(useScreen?: boolean): number;
  6671. /**
  6672. * Gets the HTML canvas attached with the current webGL context
  6673. * @returns a HTML canvas
  6674. */
  6675. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6676. /**
  6677. * Gets the client rect of the HTML canvas attached with the current webGL context
  6678. * @returns a client rectanglee
  6679. */
  6680. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6681. /**
  6682. * Defines the hardware scaling level.
  6683. * By default the hardware scaling level is computed from the window device ratio.
  6684. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  6685. * @param level defines the level to use
  6686. */
  6687. setHardwareScalingLevel(level: number): void;
  6688. /**
  6689. * Gets the current hardware scaling level.
  6690. * By default the hardware scaling level is computed from the window device ratio.
  6691. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  6692. * @returns a number indicating the current hardware scaling level
  6693. */
  6694. getHardwareScalingLevel(): number;
  6695. /**
  6696. * Gets the list of loaded textures
  6697. * @returns an array containing all loaded textures
  6698. */
  6699. getLoadedTexturesCache(): InternalTexture[];
  6700. /**
  6701. * Gets the object containing all engine capabilities
  6702. * @returns the EngineCapabilities object
  6703. */
  6704. getCaps(): EngineCapabilities;
  6705. /** @hidden */
  6706. readonly drawCalls: number;
  6707. /** @hidden */
  6708. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6709. /**
  6710. * Gets the current depth function
  6711. * @returns a number defining the depth function
  6712. */
  6713. getDepthFunction(): Nullable<number>;
  6714. /**
  6715. * Sets the current depth function
  6716. * @param depthFunc defines the function to use
  6717. */
  6718. setDepthFunction(depthFunc: number): void;
  6719. /**
  6720. * Sets the current depth function to GREATER
  6721. */
  6722. setDepthFunctionToGreater(): void;
  6723. /**
  6724. * Sets the current depth function to GEQUAL
  6725. */
  6726. setDepthFunctionToGreaterOrEqual(): void;
  6727. /**
  6728. * Sets the current depth function to LESS
  6729. */
  6730. setDepthFunctionToLess(): void;
  6731. /**
  6732. * Sets the current depth function to LEQUAL
  6733. */
  6734. setDepthFunctionToLessOrEqual(): void;
  6735. /**
  6736. * Gets a boolean indicating if stencil buffer is enabled
  6737. * @returns the current stencil buffer state
  6738. */
  6739. getStencilBuffer(): boolean;
  6740. /**
  6741. * Enable or disable the stencil buffer
  6742. * @param enable defines if the stencil buffer must be enabled or disabled
  6743. */
  6744. setStencilBuffer(enable: boolean): void;
  6745. /**
  6746. * Gets the current stencil mask
  6747. * @returns a number defining the new stencil mask to use
  6748. */
  6749. getStencilMask(): number;
  6750. /**
  6751. * Sets the current stencil mask
  6752. * @param mask defines the new stencil mask to use
  6753. */
  6754. setStencilMask(mask: number): void;
  6755. /**
  6756. * Gets the current stencil function
  6757. * @returns a number defining the stencil function to use
  6758. */
  6759. getStencilFunction(): number;
  6760. /**
  6761. * Gets the current stencil reference value
  6762. * @returns a number defining the stencil reference value to use
  6763. */
  6764. getStencilFunctionReference(): number;
  6765. /**
  6766. * Gets the current stencil mask
  6767. * @returns a number defining the stencil mask to use
  6768. */
  6769. getStencilFunctionMask(): number;
  6770. /**
  6771. * Sets the current stencil function
  6772. * @param stencilFunc defines the new stencil function to use
  6773. */
  6774. setStencilFunction(stencilFunc: number): void;
  6775. /**
  6776. * Sets the current stencil reference
  6777. * @param reference defines the new stencil reference to use
  6778. */
  6779. setStencilFunctionReference(reference: number): void;
  6780. /**
  6781. * Sets the current stencil mask
  6782. * @param mask defines the new stencil mask to use
  6783. */
  6784. setStencilFunctionMask(mask: number): void;
  6785. /**
  6786. * Gets the current stencil operation when stencil fails
  6787. * @returns a number defining stencil operation to use when stencil fails
  6788. */
  6789. getStencilOperationFail(): number;
  6790. /**
  6791. * Gets the current stencil operation when depth fails
  6792. * @returns a number defining stencil operation to use when depth fails
  6793. */
  6794. getStencilOperationDepthFail(): number;
  6795. /**
  6796. * Gets the current stencil operation when stencil passes
  6797. * @returns a number defining stencil operation to use when stencil passes
  6798. */
  6799. getStencilOperationPass(): number;
  6800. /**
  6801. * Sets the stencil operation to use when stencil fails
  6802. * @param operation defines the stencil operation to use when stencil fails
  6803. */
  6804. setStencilOperationFail(operation: number): void;
  6805. /**
  6806. * Sets the stencil operation to use when depth fails
  6807. * @param operation defines the stencil operation to use when depth fails
  6808. */
  6809. setStencilOperationDepthFail(operation: number): void;
  6810. /**
  6811. * Sets the stencil operation to use when stencil passes
  6812. * @param operation defines the stencil operation to use when stencil passes
  6813. */
  6814. setStencilOperationPass(operation: number): void;
  6815. /**
  6816. * Sets a boolean indicating if the dithering state is enabled or disabled
  6817. * @param value defines the dithering state
  6818. */
  6819. setDitheringState(value: boolean): void;
  6820. /**
  6821. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  6822. * @param value defines the rasterizer state
  6823. */
  6824. setRasterizerState(value: boolean): void;
  6825. /**
  6826. * stop executing a render loop function and remove it from the execution array
  6827. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  6828. */
  6829. stopRenderLoop(renderFunction?: () => void): void;
  6830. /** @hidden */
  6831. _renderLoop(): void;
  6832. /**
  6833. * Register and execute a render loop. The engine can have more than one render function
  6834. * @param renderFunction defines the function to continuously execute
  6835. */
  6836. runRenderLoop(renderFunction: () => void): void;
  6837. /**
  6838. * Toggle full screen mode
  6839. * @param requestPointerLock defines if a pointer lock should be requested from the user
  6840. * @param options defines an option object to be sent to the requestFullscreen function
  6841. */
  6842. switchFullscreen(requestPointerLock: boolean): void;
  6843. /**
  6844. * Clear the current render buffer or the current render target (if any is set up)
  6845. * @param color defines the color to use
  6846. * @param backBuffer defines if the back buffer must be cleared
  6847. * @param depth defines if the depth buffer must be cleared
  6848. * @param stencil defines if the stencil buffer must be cleared
  6849. */
  6850. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6851. /**
  6852. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  6853. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  6854. * @param y defines the y-coordinate of the corner of the clear rectangle
  6855. * @param width defines the width of the clear rectangle
  6856. * @param height defines the height of the clear rectangle
  6857. * @param clearColor defines the clear color
  6858. */
  6859. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6860. /**
  6861. * Set the WebGL's viewport
  6862. * @param viewport defines the viewport element to be used
  6863. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  6864. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  6865. */
  6866. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6867. /**
  6868. * Directly set the WebGL Viewport
  6869. * @param x defines the x coordinate of the viewport (in screen space)
  6870. * @param y defines the y coordinate of the viewport (in screen space)
  6871. * @param width defines the width of the viewport (in screen space)
  6872. * @param height defines the height of the viewport (in screen space)
  6873. * @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
  6874. */
  6875. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6876. /**
  6877. * Begin a new frame
  6878. */
  6879. beginFrame(): void;
  6880. /**
  6881. * Enf the current frame
  6882. */
  6883. endFrame(): void;
  6884. /**
  6885. * Resize the view according to the canvas' size
  6886. */
  6887. resize(): void;
  6888. /**
  6889. * Force a specific size of the canvas
  6890. * @param width defines the new canvas' width
  6891. * @param height defines the new canvas' height
  6892. */
  6893. setSize(width: number, height: number): void;
  6894. /**
  6895. * Gets a boolean indicating if a webVR device was detected
  6896. * @returns true if a webVR device was detected
  6897. */
  6898. isVRDevicePresent(): boolean;
  6899. /**
  6900. * Gets the current webVR device
  6901. * @returns the current webVR device (or null)
  6902. */
  6903. getVRDevice(): any;
  6904. /**
  6905. * Initializes a webVR display and starts listening to display change events
  6906. * The onVRDisplayChangedObservable will be notified upon these changes
  6907. * @returns The onVRDisplayChangedObservable
  6908. */
  6909. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6910. /**
  6911. * Initializes a webVR display and starts listening to display change events
  6912. * The onVRDisplayChangedObservable will be notified upon these changes
  6913. * @returns A promise containing a VRDisplay and if vr is supported
  6914. */
  6915. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6916. /**
  6917. * Call this function to switch to webVR mode
  6918. * Will do nothing if webVR is not supported or if there is no webVR device
  6919. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6920. */
  6921. enableVR(): void;
  6922. /**
  6923. * Call this function to leave webVR mode
  6924. * Will do nothing if webVR is not supported or if there is no webVR device
  6925. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6926. */
  6927. disableVR(): void;
  6928. private _onVRFullScreenTriggered;
  6929. private _getVRDisplaysAsync();
  6930. /**
  6931. * Binds the frame buffer to the specified texture.
  6932. * @param texture The texture to render to or null for the default canvas
  6933. * @param faceIndex The face of the texture to render to in case of cube texture
  6934. * @param requiredWidth The width of the target to render to
  6935. * @param requiredHeight The height of the target to render to
  6936. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6937. * @param depthStencilTexture The depth stencil texture to use to render
  6938. */
  6939. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6940. private bindUnboundFramebuffer(framebuffer);
  6941. /**
  6942. * Unbind the current render target texture from the webGL context
  6943. * @param texture defines the render target texture to unbind
  6944. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6945. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6946. */
  6947. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6948. /**
  6949. * Unbind a list of render target textures from the webGL context
  6950. * This is used only when drawBuffer extension or webGL2 are active
  6951. * @param textures defines the render target textures to unbind
  6952. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6953. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6954. */
  6955. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6956. /**
  6957. * Force the mipmap generation for the given render target texture
  6958. * @param texture defines the render target texture to use
  6959. */
  6960. generateMipMapsForCubemap(texture: InternalTexture): void;
  6961. /**
  6962. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  6963. */
  6964. flushFramebuffer(): void;
  6965. /**
  6966. * Unbind the current render target and bind the default framebuffer
  6967. */
  6968. restoreDefaultFramebuffer(): void;
  6969. /**
  6970. * Create an uniform buffer
  6971. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6972. * @param elements defines the content of the uniform buffer
  6973. * @returns the webGL uniform buffer
  6974. */
  6975. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6976. /**
  6977. * Create a dynamic uniform buffer
  6978. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6979. * @param elements defines the content of the uniform buffer
  6980. * @returns the webGL uniform buffer
  6981. */
  6982. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6983. /**
  6984. * Update an existing uniform buffer
  6985. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6986. * @param uniformBuffer defines the target uniform buffer
  6987. * @param elements defines the content to update
  6988. * @param offset defines the offset in the uniform buffer where update should start
  6989. * @param count defines the size of the data to update
  6990. */
  6991. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6992. private _resetVertexBufferBinding();
  6993. /**
  6994. * Creates a vertex buffer
  6995. * @param data the data for the vertex buffer
  6996. * @returns the new WebGL static buffer
  6997. */
  6998. createVertexBuffer(data: DataArray): WebGLBuffer;
  6999. /**
  7000. * Creates a dynamic vertex buffer
  7001. * @param data the data for the dynamic vertex buffer
  7002. * @returns the new WebGL dynamic buffer
  7003. */
  7004. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7005. /**
  7006. * Update a dynamic index buffer
  7007. * @param indexBuffer defines the target index buffer
  7008. * @param indices defines the data to update
  7009. * @param offset defines the offset in the target index buffer where update should start
  7010. */
  7011. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7012. /**
  7013. * Updates a dynamic vertex buffer.
  7014. * @param vertexBuffer the vertex buffer to update
  7015. * @param data the data used to update the vertex buffer
  7016. * @param byteOffset the byte offset of the data
  7017. * @param byteLength the byte length of the data
  7018. */
  7019. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7020. private _resetIndexBufferBinding();
  7021. /**
  7022. * Creates a new index buffer
  7023. * @param indices defines the content of the index buffer
  7024. * @param updatable defines if the index buffer must be updatable
  7025. * @returns a new webGL buffer
  7026. */
  7027. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7028. /**
  7029. * Bind a webGL buffer to the webGL context
  7030. * @param buffer defines the buffer to bind
  7031. */
  7032. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7033. /**
  7034. * Bind an uniform buffer to the current webGL context
  7035. * @param buffer defines the buffer to bind
  7036. */
  7037. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7038. /**
  7039. * Bind a buffer to the current webGL context at a given location
  7040. * @param buffer defines the buffer to bind
  7041. * @param location defines the index where to bind the buffer
  7042. */
  7043. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7044. /**
  7045. * Bind a specific block at a given index in a specific shader program
  7046. * @param shaderProgram defines the shader program
  7047. * @param blockName defines the block name
  7048. * @param index defines the index where to bind the block
  7049. */
  7050. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7051. private bindIndexBuffer(buffer);
  7052. private bindBuffer(buffer, target);
  7053. /**
  7054. * update the bound buffer with the given data
  7055. * @param data defines the data to update
  7056. */
  7057. updateArrayBuffer(data: Float32Array): void;
  7058. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7059. private _bindIndexBufferWithCache(indexBuffer);
  7060. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7061. /**
  7062. * Records a vertex array object
  7063. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7064. * @param vertexBuffers defines the list of vertex buffers to store
  7065. * @param indexBuffer defines the index buffer to store
  7066. * @param effect defines the effect to store
  7067. * @returns the new vertex array object
  7068. */
  7069. recordVertexArrayObject(vertexBuffers: {
  7070. [key: string]: VertexBuffer;
  7071. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7072. /**
  7073. * Bind a specific vertex array object
  7074. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7075. * @param vertexArrayObject defines the vertex array object to bind
  7076. * @param indexBuffer defines the index buffer to bind
  7077. */
  7078. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7079. /**
  7080. * Bind webGl buffers directly to the webGL context
  7081. * @param vertexBuffer defines the vertex buffer to bind
  7082. * @param indexBuffer defines the index buffer to bind
  7083. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7084. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7085. * @param effect defines the effect associated with the vertex buffer
  7086. */
  7087. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7088. private _unbindVertexArrayObject();
  7089. /**
  7090. * Bind a list of vertex buffers to the webGL context
  7091. * @param vertexBuffers defines the list of vertex buffers to bind
  7092. * @param indexBuffer defines the index buffer to bind
  7093. * @param effect defines the effect associated with the vertex buffers
  7094. */
  7095. bindBuffers(vertexBuffers: {
  7096. [key: string]: Nullable<VertexBuffer>;
  7097. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7098. /**
  7099. * Unbind all instance attributes
  7100. */
  7101. unbindInstanceAttributes(): void;
  7102. /**
  7103. * Release and free the memory of a vertex array object
  7104. * @param vao defines the vertex array object to delete
  7105. */
  7106. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7107. /** @hidden */
  7108. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7109. /**
  7110. * Creates a webGL buffer to use with instanciation
  7111. * @param capacity defines the size of the buffer
  7112. * @returns the webGL buffer
  7113. */
  7114. createInstancesBuffer(capacity: number): WebGLBuffer;
  7115. /**
  7116. * Delete a webGL buffer used with instanciation
  7117. * @param buffer defines the webGL buffer to delete
  7118. */
  7119. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7120. /**
  7121. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7122. * @param instancesBuffer defines the webGL buffer to update and bind
  7123. * @param data defines the data to store in the buffer
  7124. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7125. */
  7126. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7127. /**
  7128. * Apply all cached states (depth, culling, stencil and alpha)
  7129. */
  7130. applyStates(): void;
  7131. /**
  7132. * Send a draw order
  7133. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7134. * @param indexStart defines the starting index
  7135. * @param indexCount defines the number of index to draw
  7136. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7137. */
  7138. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7139. /**
  7140. * Draw a list of points
  7141. * @param verticesStart defines the index of first vertex to draw
  7142. * @param verticesCount defines the count of vertices to draw
  7143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7144. */
  7145. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7146. /**
  7147. * Draw a list of unindexed primitives
  7148. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7149. * @param verticesStart defines the index of first vertex to draw
  7150. * @param verticesCount defines the count of vertices to draw
  7151. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7152. */
  7153. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7154. /**
  7155. * Draw a list of indexed primitives
  7156. * @param fillMode defines the primitive to use
  7157. * @param indexStart defines the starting index
  7158. * @param indexCount defines the number of index to draw
  7159. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7160. */
  7161. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7162. /**
  7163. * Draw a list of unindexed primitives
  7164. * @param fillMode defines the primitive to use
  7165. * @param verticesStart defines the index of first vertex to draw
  7166. * @param verticesCount defines the count of vertices to draw
  7167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7168. */
  7169. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7170. private _drawMode(fillMode);
  7171. /** @hidden */
  7172. _releaseEffect(effect: Effect): void;
  7173. /** @hidden */
  7174. _deleteProgram(program: WebGLProgram): void;
  7175. /**
  7176. * Create a new effect (used to store vertex/fragment shaders)
  7177. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7178. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7179. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7180. * @param samplers defines an array of string used to represent textures
  7181. * @param defines defines the string containing the defines to use to compile the shaders
  7182. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7183. * @param onCompiled defines a function to call when the effect creation is successful
  7184. * @param onError defines a function to call when the effect creation has failed
  7185. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7186. * @returns the new Effect
  7187. */
  7188. 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;
  7189. /**
  7190. * Create an effect to use with particle systems
  7191. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7192. * @param uniformsNames defines a list of attribute names
  7193. * @param samplers defines an array of string used to represent textures
  7194. * @param defines defines the string containing the defines to use to compile the shaders
  7195. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7196. * @param onCompiled defines a function to call when the effect creation is successful
  7197. * @param onError defines a function to call when the effect creation has failed
  7198. * @returns the new Effect
  7199. */
  7200. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7201. /**
  7202. * Directly creates a webGL program
  7203. * @param vertexCode defines the vertex shader code to use
  7204. * @param fragmentCode defines the fragment shader code to use
  7205. * @param context defines the webGL context to use (if not set, the current one will be used)
  7206. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7207. * @returns the new webGL program
  7208. */
  7209. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7210. /**
  7211. * Creates a webGL program
  7212. * @param vertexCode defines the vertex shader code to use
  7213. * @param fragmentCode defines the fragment shader code to use
  7214. * @param defines defines the string containing the defines to use to compile the shaders
  7215. * @param context defines the webGL context to use (if not set, the current one will be used)
  7216. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7217. * @returns the new webGL program
  7218. */
  7219. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7220. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7221. /**
  7222. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7223. * @param shaderProgram defines the webGL program to use
  7224. * @param uniformsNames defines the list of uniform names
  7225. * @returns an array of webGL uniform locations
  7226. */
  7227. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7228. /**
  7229. * Gets the lsit of active attributes for a given webGL program
  7230. * @param shaderProgram defines the webGL program to use
  7231. * @param attributesNames defines the list of attribute names to get
  7232. * @returns an array of indices indicating the offset of each attribute
  7233. */
  7234. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7235. /**
  7236. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7237. * @param effect defines the effect to activate
  7238. */
  7239. enableEffect(effect: Nullable<Effect>): void;
  7240. /**
  7241. * Set the value of an uniform to an array of int32
  7242. * @param uniform defines the webGL uniform location where to store the value
  7243. * @param array defines the array of int32 to store
  7244. */
  7245. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7246. /**
  7247. * Set the value of an uniform to an array of int32 (stored as vec2)
  7248. * @param uniform defines the webGL uniform location where to store the value
  7249. * @param array defines the array of int32 to store
  7250. */
  7251. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7252. /**
  7253. * Set the value of an uniform to an array of int32 (stored as vec3)
  7254. * @param uniform defines the webGL uniform location where to store the value
  7255. * @param array defines the array of int32 to store
  7256. */
  7257. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7258. /**
  7259. * Set the value of an uniform to an array of int32 (stored as vec4)
  7260. * @param uniform defines the webGL uniform location where to store the value
  7261. * @param array defines the array of int32 to store
  7262. */
  7263. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7264. /**
  7265. * Set the value of an uniform to an array of float32
  7266. * @param uniform defines the webGL uniform location where to store the value
  7267. * @param array defines the array of float32 to store
  7268. */
  7269. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7270. /**
  7271. * Set the value of an uniform to an array of float32 (stored as vec2)
  7272. * @param uniform defines the webGL uniform location where to store the value
  7273. * @param array defines the array of float32 to store
  7274. */
  7275. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7276. /**
  7277. * Set the value of an uniform to an array of float32 (stored as vec3)
  7278. * @param uniform defines the webGL uniform location where to store the value
  7279. * @param array defines the array of float32 to store
  7280. */
  7281. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7282. /**
  7283. * Set the value of an uniform to an array of float32 (stored as vec4)
  7284. * @param uniform defines the webGL uniform location where to store the value
  7285. * @param array defines the array of float32 to store
  7286. */
  7287. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7288. /**
  7289. * Set the value of an uniform to an array of number
  7290. * @param uniform defines the webGL uniform location where to store the value
  7291. * @param array defines the array of number to store
  7292. */
  7293. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7294. /**
  7295. * Set the value of an uniform to an array of number (stored as vec2)
  7296. * @param uniform defines the webGL uniform location where to store the value
  7297. * @param array defines the array of number to store
  7298. */
  7299. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7300. /**
  7301. * Set the value of an uniform to an array of number (stored as vec3)
  7302. * @param uniform defines the webGL uniform location where to store the value
  7303. * @param array defines the array of number to store
  7304. */
  7305. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7306. /**
  7307. * Set the value of an uniform to an array of number (stored as vec4)
  7308. * @param uniform defines the webGL uniform location where to store the value
  7309. * @param array defines the array of number to store
  7310. */
  7311. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7312. /**
  7313. * Set the value of an uniform to an array of float32 (stored as matrices)
  7314. * @param uniform defines the webGL uniform location where to store the value
  7315. * @param matrices defines the array of float32 to store
  7316. */
  7317. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7318. /**
  7319. * Set the value of an uniform to a matrix
  7320. * @param uniform defines the webGL uniform location where to store the value
  7321. * @param matrix defines the matrix to store
  7322. */
  7323. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7324. /**
  7325. * Set the value of an uniform to a matrix (3x3)
  7326. * @param uniform defines the webGL uniform location where to store the value
  7327. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7328. */
  7329. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7330. /**
  7331. * Set the value of an uniform to a matrix (2x2)
  7332. * @param uniform defines the webGL uniform location where to store the value
  7333. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7334. */
  7335. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7336. /**
  7337. * Set the value of an uniform to a number (int)
  7338. * @param uniform defines the webGL uniform location where to store the value
  7339. * @param value defines the int number to store
  7340. */
  7341. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7342. /**
  7343. * Set the value of an uniform to a number (float)
  7344. * @param uniform defines the webGL uniform location where to store the value
  7345. * @param value defines the float number to store
  7346. */
  7347. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7348. /**
  7349. * Set the value of an uniform to a vec2
  7350. * @param uniform defines the webGL uniform location where to store the value
  7351. * @param x defines the 1st component of the value
  7352. * @param y defines the 2nd component of the value
  7353. */
  7354. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7355. /**
  7356. * Set the value of an uniform to a vec3
  7357. * @param uniform defines the webGL uniform location where to store the value
  7358. * @param x defines the 1st component of the value
  7359. * @param y defines the 2nd component of the value
  7360. * @param z defines the 3rd component of the value
  7361. */
  7362. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7363. /**
  7364. * Set the value of an uniform to a boolean
  7365. * @param uniform defines the webGL uniform location where to store the value
  7366. * @param bool defines the boolean to store
  7367. */
  7368. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7369. /**
  7370. * Set the value of an uniform to a vec4
  7371. * @param uniform defines the webGL uniform location where to store the value
  7372. * @param x defines the 1st component of the value
  7373. * @param y defines the 2nd component of the value
  7374. * @param z defines the 3rd component of the value
  7375. * @param w defines the 4th component of the value
  7376. */
  7377. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7378. /**
  7379. * Set the value of an uniform to a Color3
  7380. * @param uniform defines the webGL uniform location where to store the value
  7381. * @param color3 defines the color to store
  7382. */
  7383. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7384. /**
  7385. * Set the value of an uniform to a Color3 and an alpha value
  7386. * @param uniform defines the webGL uniform location where to store the value
  7387. * @param color3 defines the color to store
  7388. * @param alpha defines the alpha component to store
  7389. */
  7390. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7391. /**
  7392. * Sets a Color4 on a uniform variable
  7393. * @param uniform defines the uniform location
  7394. * @param color4 defines the value to be set
  7395. */
  7396. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7397. /**
  7398. * Set various states to the webGL context
  7399. * @param culling defines backface culling state
  7400. * @param zOffset defines the value to apply to zOffset (0 by default)
  7401. * @param force defines if states must be applied even if cache is up to date
  7402. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7403. */
  7404. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7405. /**
  7406. * Set the z offset to apply to current rendering
  7407. * @param value defines the offset to apply
  7408. */
  7409. setZOffset(value: number): void;
  7410. /**
  7411. * Gets the current value of the zOffset
  7412. * @returns the current zOffset state
  7413. */
  7414. getZOffset(): number;
  7415. /**
  7416. * Enable or disable depth buffering
  7417. * @param enable defines the state to set
  7418. */
  7419. setDepthBuffer(enable: boolean): void;
  7420. /**
  7421. * Gets a boolean indicating if depth writing is enabled
  7422. * @returns the current depth writing state
  7423. */
  7424. getDepthWrite(): boolean;
  7425. /**
  7426. * Enable or disable depth writing
  7427. * @param enable defines the state to set
  7428. */
  7429. setDepthWrite(enable: boolean): void;
  7430. /**
  7431. * Enable or disable color writing
  7432. * @param enable defines the state to set
  7433. */
  7434. setColorWrite(enable: boolean): void;
  7435. /**
  7436. * Gets a boolean indicating if color writing is enabled
  7437. * @returns the current color writing state
  7438. */
  7439. getColorWrite(): boolean;
  7440. /**
  7441. * Sets alpha constants used by some alpha blending modes
  7442. * @param r defines the red component
  7443. * @param g defines the green component
  7444. * @param b defines the blue component
  7445. * @param a defines the alpha component
  7446. */
  7447. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7448. /**
  7449. * Sets the current alpha mode
  7450. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7451. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7453. */
  7454. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7455. /**
  7456. * Gets the current alpha mode
  7457. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7458. * @returns the current alpha mode
  7459. */
  7460. getAlphaMode(): number;
  7461. /**
  7462. * Force the entire cache to be cleared
  7463. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7464. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7465. */
  7466. wipeCaches(bruteForce?: boolean): void;
  7467. /**
  7468. * Set the compressed texture format to use, based on the formats you have, and the formats
  7469. * supported by the hardware / browser.
  7470. *
  7471. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7472. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7473. * to API arguments needed to compressed textures. This puts the burden on the container
  7474. * generator to house the arcane code for determining these for current & future formats.
  7475. *
  7476. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7477. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7478. *
  7479. * Note: The result of this call is not taken into account when a texture is base64.
  7480. *
  7481. * @param formatsAvailable defines the list of those format families you have created
  7482. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7483. *
  7484. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7485. * @returns The extension selected.
  7486. */
  7487. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7488. /** @hidden */
  7489. _createTexture(): WebGLTexture;
  7490. /**
  7491. * Usually called from BABYLON.Texture.ts.
  7492. * Passed information to create a WebGLTexture
  7493. * @param urlArg defines a value which contains one of the following:
  7494. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7495. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7496. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7498. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7499. * @param scene needed for loading to the correct scene
  7500. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7501. * @param onLoad optional callback to be called upon successful completion
  7502. * @param onError optional callback to be called upon failure
  7503. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  7504. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7505. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7506. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7507. */
  7508. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  7509. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7510. /**
  7511. * Update a raw texture
  7512. * @param texture defines the texture to update
  7513. * @param data defines the data to store in the texture
  7514. * @param format defines the format of the data
  7515. * @param invertY defines if data must be stored with Y axis inverted
  7516. * @param compression defines the compression used (null by default)
  7517. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7518. */
  7519. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7520. /**
  7521. * Creates a raw texture
  7522. * @param data defines the data to store in the texture
  7523. * @param width defines the width of the texture
  7524. * @param height defines the height of the texture
  7525. * @param format defines the format of the data
  7526. * @param generateMipMaps defines if the engine should generate the mip levels
  7527. * @param invertY defines if data must be stored with Y axis inverted
  7528. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7529. * @param compression defines the compression used (null by default)
  7530. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7531. * @returns the raw texture inside an InternalTexture
  7532. */
  7533. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7534. /**
  7535. * Creates a dynamic texture
  7536. * @param width defines the width of the texture
  7537. * @param height defines the height of the texture
  7538. * @param generateMipMaps defines if the engine should generate the mip levels
  7539. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7540. * @returns the dynamic texture inside an InternalTexture
  7541. */
  7542. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7543. /**
  7544. * Update the sampling mode of a given texture
  7545. * @param samplingMode defines the required sampling mode
  7546. * @param texture defines the texture to update
  7547. */
  7548. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7549. /**
  7550. * Update the content of a dynamic texture
  7551. * @param texture defines the texture to update
  7552. * @param canvas defines the canvas containing the source
  7553. * @param invertY defines if data must be stored with Y axis inverted
  7554. * @param premulAlpha defines if alpha is stored as premultiplied
  7555. * @param format defines the format of the data
  7556. */
  7557. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7558. /**
  7559. * Update a video texture
  7560. * @param texture defines the texture to update
  7561. * @param video defines the video element to use
  7562. * @param invertY defines if data must be stored with Y axis inverted
  7563. */
  7564. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7565. /**
  7566. * Updates a depth texture Comparison Mode and Function.
  7567. * If the comparison Function is equal to 0, the mode will be set to none.
  7568. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7569. * @param texture The texture to set the comparison function for
  7570. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7571. */
  7572. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7573. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7574. /**
  7575. * Creates a depth stencil texture.
  7576. * This is only available in WebGL 2 or with the depth texture extension available.
  7577. * @param size The size of face edge in the texture.
  7578. * @param options The options defining the texture.
  7579. * @returns The texture
  7580. */
  7581. createDepthStencilTexture(size: number | {
  7582. width: number;
  7583. height: number;
  7584. }, options: DepthTextureCreationOptions): InternalTexture;
  7585. /**
  7586. * Creates a depth stencil texture.
  7587. * This is only available in WebGL 2 or with the depth texture extension available.
  7588. * @param size The size of face edge in the texture.
  7589. * @param options The options defining the texture.
  7590. * @returns The texture
  7591. */
  7592. private _createDepthStencilTexture(size, options);
  7593. /**
  7594. * Creates a depth stencil cube texture.
  7595. * This is only available in WebGL 2.
  7596. * @param size The size of face edge in the cube texture.
  7597. * @param options The options defining the cube texture.
  7598. * @returns The cube texture
  7599. */
  7600. private _createDepthStencilCubeTexture(size, options);
  7601. /**
  7602. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7603. * @param renderTarget The render target to set the frame buffer for
  7604. */
  7605. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7606. /**
  7607. * Creates a new render target texture
  7608. * @param size defines the size of the texture
  7609. * @param options defines the options used to create the texture
  7610. * @returns a new render target texture stored in an InternalTexture
  7611. */
  7612. createRenderTargetTexture(size: number | {
  7613. width: number;
  7614. height: number;
  7615. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7616. /**
  7617. * Create a multi render target texture
  7618. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7619. * @param size defines the size of the texture
  7620. * @param options defines the creation options
  7621. * @returns the cube texture as an InternalTexture
  7622. */
  7623. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7624. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7625. /**
  7626. * Updates the sample count of a render target texture
  7627. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7628. * @param texture defines the texture to update
  7629. * @param samples defines the sample count to set
  7630. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7631. */
  7632. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7633. /**
  7634. * Update the sample count for a given multiple render target texture
  7635. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7636. * @param textures defines the textures to update
  7637. * @param samples defines the sample count to set
  7638. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7639. */
  7640. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7641. /** @hidden */
  7642. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  7643. /** @hidden */
  7644. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  7645. /**
  7646. * Creates a new render target cube texture
  7647. * @param size defines the size of the texture
  7648. * @param options defines the options used to create the texture
  7649. * @returns a new render target cube texture stored in an InternalTexture
  7650. */
  7651. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7652. /**
  7653. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7654. * @param rootUrl defines the url where the file to load is located
  7655. * @param scene defines the current scene
  7656. * @param scale defines scale to apply to the mip map selection
  7657. * @param offset defines offset to apply to the mip map selection
  7658. * @param onLoad defines an optional callback raised when the texture is loaded
  7659. * @param onError defines an optional callback raised if there is an issue to load the texture
  7660. * @param format defines the format of the data
  7661. * @param forcedExtension defines the extension to use to pick the right loader
  7662. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  7663. * @returns the cube texture as an InternalTexture
  7664. */
  7665. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  7666. /**
  7667. * Creates a cube texture
  7668. * @param rootUrl defines the url where the files to load is located
  7669. * @param scene defines the current scene
  7670. * @param files defines the list of files to load (1 per face)
  7671. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7672. * @param onLoad defines an optional callback raised when the texture is loaded
  7673. * @param onError defines an optional callback raised if there is an issue to load the texture
  7674. * @param format defines the format of the data
  7675. * @param forcedExtension defines the extension to use to pick the right loader
  7676. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7677. * @returns the cube texture as an InternalTexture
  7678. */
  7679. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  7680. private setCubeMapTextureParams(gl, loadMipmap);
  7681. /**
  7682. * Update a raw cube texture
  7683. * @param texture defines the texture to udpdate
  7684. * @param data defines the data to store
  7685. * @param format defines the data format
  7686. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7687. * @param invertY defines if data must be stored with Y axis inverted
  7688. * @param compression defines the compression used (null by default)
  7689. * @param level defines which level of the texture to update
  7690. */
  7691. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  7692. /**
  7693. * Creates a new raw cube texture
  7694. * @param data defines the array of data to use to create each face
  7695. * @param size defines the size of the textures
  7696. * @param format defines the format of the data
  7697. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7698. * @param generateMipMaps defines if the engine should generate the mip levels
  7699. * @param invertY defines if data must be stored with Y axis inverted
  7700. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7701. * @param compression defines the compression used (null by default)
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7705. /**
  7706. * Creates a new raw cube texture from a specified url
  7707. * @param url defines the url where the data is located
  7708. * @param scene defines the current scene
  7709. * @param size defines the size of the textures
  7710. * @param format defines the format of the data
  7711. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7712. * @param noMipmap defines if the engine should avoid generating the mip levels
  7713. * @param callback defines a callback used to extract texture data from loaded data
  7714. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  7715. * @param onLoad defines a callback called when texture is loaded
  7716. * @param onError defines a callback called if there is an error
  7717. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7718. * @param invertY defines if data must be stored with Y axis inverted
  7719. * @returns the cube texture as an InternalTexture
  7720. */
  7721. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  7722. /**
  7723. * Update a raw 3D texture
  7724. * @param texture defines the texture to update
  7725. * @param data defines the data to store
  7726. * @param format defines the data format
  7727. * @param invertY defines if data must be stored with Y axis inverted
  7728. * @param compression defines the used compression (can be null)
  7729. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  7730. */
  7731. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  7732. /**
  7733. * Creates a new raw 3D texture
  7734. * @param data defines the data used to create the texture
  7735. * @param width defines the width of the texture
  7736. * @param height defines the height of the texture
  7737. * @param depth defines the depth of the texture
  7738. * @param format defines the format of the texture
  7739. * @param generateMipMaps defines if the engine must generate mip levels
  7740. * @param invertY defines if data must be stored with Y axis inverted
  7741. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7742. * @param compression defines the compressed used (can be null)
  7743. * @param textureType defines the compressed used (can be null)
  7744. * @returns a new raw 3D texture (stored in an InternalTexture)
  7745. */
  7746. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  7747. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  7748. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  7749. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  7750. /** @hidden */
  7751. _releaseFramebufferObjects(texture: InternalTexture): void;
  7752. /** @hidden */
  7753. _releaseTexture(texture: InternalTexture): void;
  7754. private setProgram(program);
  7755. private _boundUniforms;
  7756. /**
  7757. * Binds an effect to the webGL context
  7758. * @param effect defines the effect to bind
  7759. */
  7760. bindSamplers(effect: Effect): void;
  7761. private _moveBoundTextureOnTop(internalTexture);
  7762. private _getCorrectTextureChannel(channel, internalTexture);
  7763. private _linkTrackers(previous, next);
  7764. private _removeDesignatedSlot(internalTexture);
  7765. private _activateCurrentTexture();
  7766. /** @hidden */
  7767. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  7768. /** @hidden */
  7769. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  7770. /**
  7771. * Sets a texture to the webGL context from a postprocess
  7772. * @param channel defines the channel to use
  7773. * @param postProcess defines the source postprocess
  7774. */
  7775. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  7776. /**
  7777. * Binds the output of the passed in post process to the texture channel specified
  7778. * @param channel The channel the texture should be bound to
  7779. * @param postProcess The post process which's output should be bound
  7780. */
  7781. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  7782. /**
  7783. * Unbind all textures from the webGL context
  7784. */
  7785. unbindAllTextures(): void;
  7786. /**
  7787. * Sets a texture to the according uniform.
  7788. * @param channel The texture channel
  7789. * @param uniform The uniform to set
  7790. * @param texture The texture to apply
  7791. */
  7792. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  7793. /**
  7794. * Sets a depth stencil texture from a render target to the according uniform.
  7795. * @param channel The texture channel
  7796. * @param uniform The uniform to set
  7797. * @param texture The render target texture containing the depth stencil texture to apply
  7798. */
  7799. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  7800. private _bindSamplerUniformToChannel(sourceSlot, destination);
  7801. private _getTextureWrapMode(mode);
  7802. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  7803. /**
  7804. * Sets an array of texture to the webGL context
  7805. * @param channel defines the channel where the texture array must be set
  7806. * @param uniform defines the associated uniform location
  7807. * @param textures defines the array of textures to bind
  7808. */
  7809. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  7810. /** @hidden */
  7811. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  7812. private _setTextureParameterFloat(target, parameter, value, texture);
  7813. private _setTextureParameterInteger(target, parameter, value, texture?);
  7814. /**
  7815. * Reads pixels from the current frame buffer. Please note that this function can be slow
  7816. * @param x defines the x coordinate of the rectangle where pixels must be read
  7817. * @param y defines the y coordinate of the rectangle where pixels must be read
  7818. * @param width defines the width of the rectangle where pixels must be read
  7819. * @param height defines the height of the rectangle where pixels must be read
  7820. * @returns a Uint8Array containing RGBA colors
  7821. */
  7822. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  7823. /**
  7824. * Add an externaly attached data from its key.
  7825. * This method call will fail and return false, if such key already exists.
  7826. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  7827. * @param key the unique key that identifies the data
  7828. * @param data the data object to associate to the key for this Engine instance
  7829. * @return true if no such key were already present and the data was added successfully, false otherwise
  7830. */
  7831. addExternalData<T>(key: string, data: T): boolean;
  7832. /**
  7833. * Get an externaly attached data from its key
  7834. * @param key the unique key that identifies the data
  7835. * @return the associated data, if present (can be null), or undefined if not present
  7836. */
  7837. getExternalData<T>(key: string): T;
  7838. /**
  7839. * Get an externaly attached data from its key, create it using a factory if it's not already present
  7840. * @param key the unique key that identifies the data
  7841. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  7842. * @return the associated data, can be null if the factory returned null.
  7843. */
  7844. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  7845. /**
  7846. * Remove an externaly attached data from the Engine instance
  7847. * @param key the unique key that identifies the data
  7848. * @return true if the data was successfully removed, false if it doesn't exist
  7849. */
  7850. removeExternalData(key: string): boolean;
  7851. /**
  7852. * Unbind all vertex attributes from the webGL context
  7853. */
  7854. unbindAllAttributes(): void;
  7855. /**
  7856. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  7857. */
  7858. releaseEffects(): void;
  7859. /**
  7860. * Dispose and release all associated resources
  7861. */
  7862. dispose(): void;
  7863. /**
  7864. * Display the loading screen
  7865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7866. */
  7867. displayLoadingUI(): void;
  7868. /**
  7869. * Hide the loading screen
  7870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7871. */
  7872. hideLoadingUI(): void;
  7873. /**
  7874. * Gets the current loading screen object
  7875. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7876. */
  7877. /**
  7878. * Sets the current loading screen object
  7879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7880. */
  7881. loadingScreen: ILoadingScreen;
  7882. /**
  7883. * Sets the current loading screen text
  7884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7885. */
  7886. loadingUIText: string;
  7887. /**
  7888. * Sets the current loading screen background color
  7889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7890. */
  7891. loadingUIBackgroundColor: string;
  7892. /**
  7893. * Attach a new callback raised when context lost event is fired
  7894. * @param callback defines the callback to call
  7895. */
  7896. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7897. /**
  7898. * Attach a new callback raised when context restored event is fired
  7899. * @param callback defines the callback to call
  7900. */
  7901. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7902. /**
  7903. * Gets the source code of the vertex shader associated with a specific webGL program
  7904. * @param program defines the program to use
  7905. * @returns a string containing the source code of the vertex shader associated with the program
  7906. */
  7907. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  7908. /**
  7909. * Gets the source code of the fragment shader associated with a specific webGL program
  7910. * @param program defines the program to use
  7911. * @returns a string containing the source code of the fragment shader associated with the program
  7912. */
  7913. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  7914. /**
  7915. * Get the current error code of the webGL context
  7916. * @returns the error code
  7917. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  7918. */
  7919. getError(): number;
  7920. /**
  7921. * Gets the current framerate
  7922. * @returns a number representing the framerate
  7923. */
  7924. getFps(): number;
  7925. /**
  7926. * Gets the time spent between current and previous frame
  7927. * @returns a number representing the delta time in ms
  7928. */
  7929. getDeltaTime(): number;
  7930. private _measureFps();
  7931. /** @hidden */
  7932. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  7933. private _canRenderToFloatFramebuffer();
  7934. private _canRenderToHalfFloatFramebuffer();
  7935. private _canRenderToFramebuffer(type);
  7936. /** @hidden */
  7937. _getWebGLTextureType(type: number): number;
  7938. private _getInternalFormat(format);
  7939. /** @hidden */
  7940. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  7941. /** @hidden */
  7942. _getRGBAMultiSampleBufferFormat(type: number): number;
  7943. /**
  7944. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  7945. * @return the new query
  7946. */
  7947. createQuery(): WebGLQuery;
  7948. /**
  7949. * Delete and release a webGL query
  7950. * @param query defines the query to delete
  7951. * @return the current engine
  7952. */
  7953. deleteQuery(query: WebGLQuery): Engine;
  7954. /**
  7955. * Check if a given query has resolved and got its value
  7956. * @param query defines the query to check
  7957. * @returns true if the query got its value
  7958. */
  7959. isQueryResultAvailable(query: WebGLQuery): boolean;
  7960. /**
  7961. * Gets the value of a given query
  7962. * @param query defines the query to check
  7963. * @returns the value of the query
  7964. */
  7965. getQueryResult(query: WebGLQuery): number;
  7966. /**
  7967. * Initiates an occlusion query
  7968. * @param algorithmType defines the algorithm to use
  7969. * @param query defines the query to use
  7970. * @returns the current engine
  7971. * @see http://doc.babylonjs.com/features/occlusionquery
  7972. */
  7973. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  7974. /**
  7975. * Ends an occlusion query
  7976. * @see http://doc.babylonjs.com/features/occlusionquery
  7977. * @param algorithmType defines the algorithm to use
  7978. * @returns the current engine
  7979. */
  7980. endOcclusionQuery(algorithmType: number): Engine;
  7981. private _createTimeQuery();
  7982. private _deleteTimeQuery(query);
  7983. private _getTimeQueryResult(query);
  7984. private _getTimeQueryAvailability(query);
  7985. private _currentNonTimestampToken;
  7986. /**
  7987. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  7988. * Please note that only one query can be issued at a time
  7989. * @returns a time token used to track the time span
  7990. */
  7991. startTimeQuery(): Nullable<_TimeToken>;
  7992. /**
  7993. * Ends a time query
  7994. * @param token defines the token used to measure the time span
  7995. * @returns the time spent (in ns)
  7996. */
  7997. endTimeQuery(token: _TimeToken): int;
  7998. private getGlAlgorithmType(algorithmType);
  7999. /**
  8000. * Creates a webGL transform feedback object
  8001. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8002. * @returns the webGL transform feedback object
  8003. */
  8004. createTransformFeedback(): WebGLTransformFeedback;
  8005. /**
  8006. * Delete a webGL transform feedback object
  8007. * @param value defines the webGL transform feedback object to delete
  8008. */
  8009. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8010. /**
  8011. * Bind a webGL transform feedback object to the webgl context
  8012. * @param value defines the webGL transform feedback object to bind
  8013. */
  8014. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8015. /**
  8016. * Begins a transform feedback operation
  8017. * @param usePoints defines if points or triangles must be used
  8018. */
  8019. beginTransformFeedback(usePoints?: boolean): void;
  8020. /**
  8021. * Ends a transform feedback operation
  8022. */
  8023. endTransformFeedback(): void;
  8024. /**
  8025. * Specify the varyings to use with transform feedback
  8026. * @param program defines the associated webGL program
  8027. * @param value defines the list of strings representing the varying names
  8028. */
  8029. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8030. /**
  8031. * Bind a webGL buffer for a transform feedback operation
  8032. * @param value defines the webGL buffer to bind
  8033. */
  8034. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8035. /** @hidden */
  8036. _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;
  8037. /** @hidden */
  8038. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8039. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8040. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8041. /**
  8042. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8043. * @returns true if the engine can be created
  8044. * @ignorenaming
  8045. */
  8046. static isSupported(): boolean;
  8047. }
  8048. }
  8049. declare module BABYLON {
  8050. class NullEngineOptions {
  8051. renderWidth: number;
  8052. renderHeight: number;
  8053. textureSize: number;
  8054. deterministicLockstep: boolean;
  8055. lockstepMaxSteps: number;
  8056. }
  8057. /**
  8058. * The null engine class provides support for headless version of babylon.js.
  8059. * This can be used in server side scenario or for testing purposes
  8060. */
  8061. class NullEngine extends Engine {
  8062. private _options;
  8063. isDeterministicLockStep(): boolean;
  8064. getLockstepMaxSteps(): number;
  8065. getHardwareScalingLevel(): number;
  8066. constructor(options?: NullEngineOptions);
  8067. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8068. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8069. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8070. getRenderWidth(useScreen?: boolean): number;
  8071. getRenderHeight(useScreen?: boolean): number;
  8072. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8073. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8074. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8075. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8076. bindSamplers(effect: Effect): void;
  8077. enableEffect(effect: Effect): void;
  8078. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8079. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8080. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8081. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8082. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8083. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8084. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8085. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8086. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8087. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8088. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8089. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8090. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8091. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8092. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8093. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8094. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8095. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8096. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8097. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8098. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8099. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8100. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8101. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8102. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8103. bindBuffers(vertexBuffers: {
  8104. [key: string]: VertexBuffer;
  8105. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8106. wipeCaches(bruteForce?: boolean): void;
  8107. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8108. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8110. _createTexture(): WebGLTexture;
  8111. _releaseTexture(texture: InternalTexture): void;
  8112. 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;
  8113. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8114. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8115. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8117. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8118. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8119. /**
  8120. * Updates a dynamic vertex buffer.
  8121. * @param vertexBuffer the vertex buffer to update
  8122. * @param data the data used to update the vertex buffer
  8123. * @param byteOffset the byte offset of the data (optional)
  8124. * @param byteLength the byte length of the data (optional)
  8125. */
  8126. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8127. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8128. _bindTexture(channel: number, texture: InternalTexture): void;
  8129. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8130. releaseEffects(): void;
  8131. }
  8132. }
  8133. interface WebGLRenderingContext {
  8134. readonly RASTERIZER_DISCARD: number;
  8135. readonly DEPTH_COMPONENT24: number;
  8136. readonly TEXTURE_3D: number;
  8137. readonly TEXTURE_2D_ARRAY: number;
  8138. readonly TEXTURE_COMPARE_FUNC: number;
  8139. readonly TEXTURE_COMPARE_MODE: number;
  8140. readonly COMPARE_REF_TO_TEXTURE: number;
  8141. readonly TEXTURE_WRAP_R: number;
  8142. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8143. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8144. 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;
  8145. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8146. readonly TRANSFORM_FEEDBACK: number;
  8147. readonly INTERLEAVED_ATTRIBS: number;
  8148. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8149. createTransformFeedback(): WebGLTransformFeedback;
  8150. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8151. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8152. beginTransformFeedback(primitiveMode: number): void;
  8153. endTransformFeedback(): void;
  8154. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8155. }
  8156. interface ImageBitmap {
  8157. readonly width: number;
  8158. readonly height: number;
  8159. close(): void;
  8160. }
  8161. interface WebGLQuery extends WebGLObject {
  8162. }
  8163. declare var WebGLQuery: {
  8164. prototype: WebGLQuery;
  8165. new (): WebGLQuery;
  8166. };
  8167. interface WebGLSampler extends WebGLObject {
  8168. }
  8169. declare var WebGLSampler: {
  8170. prototype: WebGLSampler;
  8171. new (): WebGLSampler;
  8172. };
  8173. interface WebGLSync extends WebGLObject {
  8174. }
  8175. declare var WebGLSync: {
  8176. prototype: WebGLSync;
  8177. new (): WebGLSync;
  8178. };
  8179. interface WebGLTransformFeedback extends WebGLObject {
  8180. }
  8181. declare var WebGLTransformFeedback: {
  8182. prototype: WebGLTransformFeedback;
  8183. new (): WebGLTransformFeedback;
  8184. };
  8185. interface WebGLVertexArrayObject extends WebGLObject {
  8186. }
  8187. declare var WebGLVertexArrayObject: {
  8188. prototype: WebGLVertexArrayObject;
  8189. new (): WebGLVertexArrayObject;
  8190. };
  8191. declare module BABYLON {
  8192. class ArcRotateCamera extends TargetCamera {
  8193. alpha: number;
  8194. beta: number;
  8195. radius: number;
  8196. protected _target: Vector3;
  8197. protected _targetHost: Nullable<AbstractMesh>;
  8198. target: Vector3;
  8199. inertialAlphaOffset: number;
  8200. inertialBetaOffset: number;
  8201. inertialRadiusOffset: number;
  8202. lowerAlphaLimit: Nullable<number>;
  8203. upperAlphaLimit: Nullable<number>;
  8204. lowerBetaLimit: number;
  8205. upperBetaLimit: number;
  8206. lowerRadiusLimit: Nullable<number>;
  8207. upperRadiusLimit: Nullable<number>;
  8208. inertialPanningX: number;
  8209. inertialPanningY: number;
  8210. pinchToPanMaxDistance: number;
  8211. panningDistanceLimit: Nullable<number>;
  8212. panningOriginTarget: Vector3;
  8213. panningInertia: number;
  8214. angularSensibilityX: number;
  8215. angularSensibilityY: number;
  8216. pinchPrecision: number;
  8217. pinchDeltaPercentage: number;
  8218. panningSensibility: number;
  8219. keysUp: number[];
  8220. keysDown: number[];
  8221. keysLeft: number[];
  8222. keysRight: number[];
  8223. wheelPrecision: number;
  8224. wheelDeltaPercentage: number;
  8225. zoomOnFactor: number;
  8226. targetScreenOffset: Vector2;
  8227. allowUpsideDown: boolean;
  8228. _viewMatrix: Matrix;
  8229. _useCtrlForPanning: boolean;
  8230. _panningMouseButton: number;
  8231. inputs: ArcRotateCameraInputsManager;
  8232. _reset: () => void;
  8233. panningAxis: Vector3;
  8234. protected _localDirection: Vector3;
  8235. protected _transformedDirection: Vector3;
  8236. private _bouncingBehavior;
  8237. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8238. useBouncingBehavior: boolean;
  8239. private _framingBehavior;
  8240. readonly framingBehavior: Nullable<FramingBehavior>;
  8241. useFramingBehavior: boolean;
  8242. private _autoRotationBehavior;
  8243. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8244. useAutoRotationBehavior: boolean;
  8245. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8246. onCollide: (collidedMesh: AbstractMesh) => void;
  8247. checkCollisions: boolean;
  8248. collisionRadius: Vector3;
  8249. protected _collider: Collider;
  8250. protected _previousPosition: Vector3;
  8251. protected _collisionVelocity: Vector3;
  8252. protected _newPosition: Vector3;
  8253. protected _previousAlpha: number;
  8254. protected _previousBeta: number;
  8255. protected _previousRadius: number;
  8256. protected _collisionTriggered: boolean;
  8257. protected _targetBoundingCenter: Nullable<Vector3>;
  8258. private _computationVector;
  8259. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8260. _initCache(): void;
  8261. _updateCache(ignoreParentClass?: boolean): void;
  8262. protected _getTargetPosition(): Vector3;
  8263. /**
  8264. * Store current camera state (fov, position, etc..)
  8265. */
  8266. private _storedAlpha;
  8267. private _storedBeta;
  8268. private _storedRadius;
  8269. private _storedTarget;
  8270. storeState(): Camera;
  8271. /**
  8272. * Restored camera state. You must call storeState() first
  8273. */
  8274. _restoreStateValues(): boolean;
  8275. _isSynchronizedViewMatrix(): boolean;
  8276. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8277. detachControl(element: HTMLElement): void;
  8278. _checkInputs(): void;
  8279. protected _checkLimits(): void;
  8280. rebuildAnglesAndRadius(): void;
  8281. setPosition(position: Vector3): void;
  8282. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8283. _getViewMatrix(): Matrix;
  8284. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8285. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8286. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8287. min: Vector3;
  8288. max: Vector3;
  8289. distance: number;
  8290. }, doNotUpdateMaxZ?: boolean): void;
  8291. /**
  8292. * @override
  8293. * Override Camera.createRigCamera
  8294. */
  8295. createRigCamera(name: string, cameraIndex: number): Camera;
  8296. /**
  8297. * @override
  8298. * Override Camera._updateRigCameras
  8299. */
  8300. _updateRigCameras(): void;
  8301. dispose(): void;
  8302. getClassName(): string;
  8303. }
  8304. }
  8305. declare module BABYLON {
  8306. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8307. constructor(camera: ArcRotateCamera);
  8308. addMouseWheel(): ArcRotateCameraInputsManager;
  8309. addPointers(): ArcRotateCameraInputsManager;
  8310. addKeyboard(): ArcRotateCameraInputsManager;
  8311. addGamepad(): ArcRotateCameraInputsManager;
  8312. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8313. }
  8314. }
  8315. declare module BABYLON {
  8316. class Camera extends Node {
  8317. inputs: CameraInputsManager<Camera>;
  8318. private static _PERSPECTIVE_CAMERA;
  8319. private static _ORTHOGRAPHIC_CAMERA;
  8320. private static _FOVMODE_VERTICAL_FIXED;
  8321. private static _FOVMODE_HORIZONTAL_FIXED;
  8322. private static _RIG_MODE_NONE;
  8323. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  8324. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  8325. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  8326. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  8327. private static _RIG_MODE_VR;
  8328. private static _RIG_MODE_WEBVR;
  8329. static readonly PERSPECTIVE_CAMERA: number;
  8330. static readonly ORTHOGRAPHIC_CAMERA: number;
  8331. /**
  8332. * This is the default FOV mode for perspective cameras.
  8333. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8334. *
  8335. */
  8336. static readonly FOVMODE_VERTICAL_FIXED: number;
  8337. /**
  8338. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8339. *
  8340. */
  8341. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8342. static readonly RIG_MODE_NONE: number;
  8343. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8344. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8345. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8346. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8347. static readonly RIG_MODE_VR: number;
  8348. static readonly RIG_MODE_WEBVR: number;
  8349. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8350. static UseAlternateWebVRRendering: boolean;
  8351. position: Vector3;
  8352. /**
  8353. * The vector the camera should consider as up.
  8354. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8355. */
  8356. upVector: Vector3;
  8357. orthoLeft: Nullable<number>;
  8358. orthoRight: Nullable<number>;
  8359. orthoBottom: Nullable<number>;
  8360. orthoTop: Nullable<number>;
  8361. /**
  8362. * FOV is set in Radians. (default is 0.8)
  8363. */
  8364. fov: number;
  8365. minZ: number;
  8366. maxZ: number;
  8367. inertia: number;
  8368. mode: number;
  8369. isIntermediate: boolean;
  8370. viewport: Viewport;
  8371. /**
  8372. * Restricts the camera to viewing objects with the same layerMask.
  8373. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8374. */
  8375. layerMask: number;
  8376. /**
  8377. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8378. */
  8379. fovMode: number;
  8380. cameraRigMode: number;
  8381. interaxialDistance: number;
  8382. isStereoscopicSideBySide: boolean;
  8383. _cameraRigParams: any;
  8384. _rigCameras: Camera[];
  8385. _rigPostProcess: Nullable<PostProcess>;
  8386. protected _webvrViewMatrix: Matrix;
  8387. _skipRendering: boolean;
  8388. _alternateCamera: Camera;
  8389. customRenderTargets: RenderTargetTexture[];
  8390. onViewMatrixChangedObservable: Observable<Camera>;
  8391. onProjectionMatrixChangedObservable: Observable<Camera>;
  8392. onAfterCheckInputsObservable: Observable<Camera>;
  8393. onRestoreStateObservable: Observable<Camera>;
  8394. private _computedViewMatrix;
  8395. _projectionMatrix: Matrix;
  8396. private _doNotComputeProjectionMatrix;
  8397. private _worldMatrix;
  8398. _postProcesses: Nullable<PostProcess>[];
  8399. private _transformMatrix;
  8400. _activeMeshes: SmartArray<AbstractMesh>;
  8401. protected _globalPosition: Vector3;
  8402. private _frustumPlanes;
  8403. private _refreshFrustumPlanes;
  8404. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8405. private _storedFov;
  8406. private _stateStored;
  8407. /**
  8408. * Store current camera state (fov, position, etc..)
  8409. */
  8410. storeState(): Camera;
  8411. /**
  8412. * Restores the camera state values if it has been stored. You must call storeState() first
  8413. */
  8414. protected _restoreStateValues(): boolean;
  8415. /**
  8416. * Restored camera state. You must call storeState() first
  8417. */
  8418. restoreState(): boolean;
  8419. getClassName(): string;
  8420. /**
  8421. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8422. */
  8423. toString(fullDetails?: boolean): string;
  8424. readonly globalPosition: Vector3;
  8425. getActiveMeshes(): SmartArray<AbstractMesh>;
  8426. isActiveMesh(mesh: Mesh): boolean;
  8427. /**
  8428. * Is this camera ready to be used/rendered
  8429. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8430. * @return true if the camera is ready
  8431. */
  8432. isReady(completeCheck?: boolean): boolean;
  8433. _initCache(): void;
  8434. _updateCache(ignoreParentClass?: boolean): void;
  8435. _isSynchronized(): boolean;
  8436. _isSynchronizedViewMatrix(): boolean;
  8437. _isSynchronizedProjectionMatrix(): boolean;
  8438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8439. detachControl(element: HTMLElement): void;
  8440. update(): void;
  8441. _checkInputs(): void;
  8442. readonly rigCameras: Camera[];
  8443. readonly rigPostProcess: Nullable<PostProcess>;
  8444. /**
  8445. * Internal, gets the first post proces.
  8446. * @returns the first post process to be run on this camera.
  8447. */
  8448. _getFirstPostProcess(): Nullable<PostProcess>;
  8449. private _cascadePostProcessesToRigCams();
  8450. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8451. detachPostProcess(postProcess: PostProcess): void;
  8452. getWorldMatrix(): Matrix;
  8453. _getViewMatrix(): Matrix;
  8454. getViewMatrix(force?: boolean): Matrix;
  8455. freezeProjectionMatrix(projection?: Matrix): void;
  8456. unfreezeProjectionMatrix(): void;
  8457. getProjectionMatrix(force?: boolean): Matrix;
  8458. getTranformationMatrix(): Matrix;
  8459. private updateFrustumPlanes();
  8460. isInFrustum(target: ICullable): boolean;
  8461. isCompletelyInFrustum(target: ICullable): boolean;
  8462. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8463. /**
  8464. * Releases resources associated with this node.
  8465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8467. */
  8468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8469. readonly leftCamera: Nullable<FreeCamera>;
  8470. readonly rightCamera: Nullable<FreeCamera>;
  8471. getLeftTarget(): Nullable<Vector3>;
  8472. getRightTarget(): Nullable<Vector3>;
  8473. setCameraRigMode(mode: number, rigParams: any): void;
  8474. private _getVRProjectionMatrix();
  8475. protected _updateCameraRotationMatrix(): void;
  8476. protected _updateWebVRCameraRotationMatrix(): void;
  8477. /**
  8478. * This function MUST be overwritten by the different WebVR cameras available.
  8479. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8480. */
  8481. protected _getWebVRProjectionMatrix(): Matrix;
  8482. /**
  8483. * This function MUST be overwritten by the different WebVR cameras available.
  8484. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8485. */
  8486. protected _getWebVRViewMatrix(): Matrix;
  8487. setCameraRigParameter(name: string, value: any): void;
  8488. /**
  8489. * needs to be overridden by children so sub has required properties to be copied
  8490. */
  8491. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8492. /**
  8493. * May need to be overridden by children
  8494. */
  8495. _updateRigCameras(): void;
  8496. _setupInputs(): void;
  8497. serialize(): any;
  8498. clone(name: string): Camera;
  8499. getDirection(localAxis: Vector3): Vector3;
  8500. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8501. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8502. computeWorldMatrix(): Matrix;
  8503. static Parse(parsedCamera: any, scene: Scene): Camera;
  8504. }
  8505. }
  8506. declare module BABYLON {
  8507. var CameraInputTypes: {};
  8508. interface ICameraInput<TCamera extends Camera> {
  8509. camera: Nullable<TCamera>;
  8510. getClassName(): string;
  8511. getSimpleName(): string;
  8512. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  8513. detachControl: (element: Nullable<HTMLElement>) => void;
  8514. checkInputs?: () => void;
  8515. }
  8516. interface CameraInputsMap<TCamera extends Camera> {
  8517. [name: string]: ICameraInput<TCamera>;
  8518. [idx: number]: ICameraInput<TCamera>;
  8519. }
  8520. class CameraInputsManager<TCamera extends Camera> {
  8521. attached: CameraInputsMap<TCamera>;
  8522. attachedElement: Nullable<HTMLElement>;
  8523. noPreventDefault: boolean;
  8524. camera: TCamera;
  8525. checkInputs: () => void;
  8526. constructor(camera: TCamera);
  8527. /**
  8528. * Add an input method to a camera.
  8529. * builtin inputs example: camera.inputs.addGamepad();
  8530. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  8531. * @param input camera input method
  8532. */
  8533. add(input: ICameraInput<TCamera>): void;
  8534. /**
  8535. * Remove a specific input method from a camera
  8536. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8537. * @param inputToRemove camera input method
  8538. */
  8539. remove(inputToRemove: ICameraInput<TCamera>): void;
  8540. removeByType(inputType: string): void;
  8541. private _addCheckInputs(fn);
  8542. attachInput(input: ICameraInput<TCamera>): void;
  8543. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8544. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8545. rebuildInputCheck(): void;
  8546. /**
  8547. * Remove all attached input methods from a camera
  8548. */
  8549. clear(): void;
  8550. serialize(serializedCamera: any): void;
  8551. parse(parsedCamera: any): void;
  8552. }
  8553. }
  8554. declare module BABYLON {
  8555. /**
  8556. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8557. * being tilted forward or back and left or right.
  8558. */
  8559. class DeviceOrientationCamera extends FreeCamera {
  8560. private _initialQuaternion;
  8561. private _quaternionCache;
  8562. /**
  8563. * Creates a new device orientation camera
  8564. * @param name The name of the camera
  8565. * @param position The start position camera
  8566. * @param scene The scene the camera belongs to
  8567. */
  8568. constructor(name: string, position: Vector3, scene: Scene);
  8569. /**
  8570. * Gets the current instance class name ("DeviceOrientationCamera").
  8571. * This helps avoiding instanceof at run time.
  8572. * @returns the class name
  8573. */
  8574. getClassName(): string;
  8575. /**
  8576. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8577. */
  8578. _checkInputs(): void;
  8579. /**
  8580. * Reset the camera to its default orientation on the specified axis only.
  8581. * @param axis The axis to reset
  8582. */
  8583. resetToCurrentRotation(axis?: Axis): void;
  8584. }
  8585. }
  8586. declare module BABYLON {
  8587. class FollowCamera extends TargetCamera {
  8588. radius: number;
  8589. rotationOffset: number;
  8590. heightOffset: number;
  8591. cameraAcceleration: number;
  8592. maxCameraSpeed: number;
  8593. lockedTarget: Nullable<AbstractMesh>;
  8594. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8595. private getRadians(degrees);
  8596. private follow(cameraTarget);
  8597. _checkInputs(): void;
  8598. getClassName(): string;
  8599. }
  8600. class ArcFollowCamera extends TargetCamera {
  8601. alpha: number;
  8602. beta: number;
  8603. radius: number;
  8604. target: Nullable<AbstractMesh>;
  8605. private _cartesianCoordinates;
  8606. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  8607. private follow();
  8608. _checkInputs(): void;
  8609. getClassName(): string;
  8610. }
  8611. }
  8612. declare module BABYLON {
  8613. class FreeCamera extends TargetCamera {
  8614. ellipsoid: Vector3;
  8615. ellipsoidOffset: Vector3;
  8616. checkCollisions: boolean;
  8617. applyGravity: boolean;
  8618. inputs: FreeCameraInputsManager;
  8619. /**
  8620. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8621. * Higher values reduce sensitivity.
  8622. */
  8623. /**
  8624. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8625. * Higher values reduce sensitivity.
  8626. */
  8627. angularSensibility: number;
  8628. keysUp: number[];
  8629. keysDown: number[];
  8630. keysLeft: number[];
  8631. keysRight: number[];
  8632. onCollide: (collidedMesh: AbstractMesh) => void;
  8633. private _collider;
  8634. private _needMoveForGravity;
  8635. private _oldPosition;
  8636. private _diffPosition;
  8637. private _newPosition;
  8638. _localDirection: Vector3;
  8639. _transformedDirection: Vector3;
  8640. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8642. detachControl(element: HTMLElement): void;
  8643. private _collisionMask;
  8644. collisionMask: number;
  8645. _collideWithWorld(displacement: Vector3): void;
  8646. private _onCollisionPositionChange;
  8647. _checkInputs(): void;
  8648. _decideIfNeedsToMove(): boolean;
  8649. _updatePosition(): void;
  8650. dispose(): void;
  8651. getClassName(): string;
  8652. }
  8653. }
  8654. declare module BABYLON {
  8655. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8656. constructor(camera: FreeCamera);
  8657. addKeyboard(): FreeCameraInputsManager;
  8658. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8659. addGamepad(): FreeCameraInputsManager;
  8660. addDeviceOrientation(): FreeCameraInputsManager;
  8661. addTouch(): FreeCameraInputsManager;
  8662. addVirtualJoystick(): FreeCameraInputsManager;
  8663. }
  8664. }
  8665. declare module BABYLON {
  8666. class GamepadCamera extends UniversalCamera {
  8667. gamepadAngularSensibility: number;
  8668. gamepadMoveSensibility: number;
  8669. constructor(name: string, position: Vector3, scene: Scene);
  8670. getClassName(): string;
  8671. }
  8672. }
  8673. declare module BABYLON {
  8674. /**
  8675. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  8676. */
  8677. class AnaglyphFreeCamera extends FreeCamera {
  8678. /**
  8679. * Creates a new AnaglyphFreeCamera
  8680. * @param name defines camera name
  8681. * @param position defines initial position
  8682. * @param interaxialDistance defines distance between each color axis
  8683. * @param scene defines the hosting scene
  8684. */
  8685. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8686. /**
  8687. * Gets camera class name
  8688. * @returns AnaglyphFreeCamera
  8689. */
  8690. getClassName(): string;
  8691. }
  8692. /**
  8693. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  8694. */
  8695. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  8696. /**
  8697. * Creates a new AnaglyphArcRotateCamera
  8698. * @param name defines camera name
  8699. * @param alpha defines alpha angle (in radians)
  8700. * @param beta defines beta angle (in radians)
  8701. * @param radius defines radius
  8702. * @param target defines camera target
  8703. * @param interaxialDistance defines distance between each color axis
  8704. * @param scene defines the hosting scene
  8705. */
  8706. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  8707. /**
  8708. * Gets camera class name
  8709. * @returns AnaglyphArcRotateCamera
  8710. */
  8711. getClassName(): string;
  8712. }
  8713. /**
  8714. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  8715. */
  8716. class AnaglyphGamepadCamera extends GamepadCamera {
  8717. /**
  8718. * Creates a new AnaglyphGamepadCamera
  8719. * @param name defines camera name
  8720. * @param position defines initial position
  8721. * @param interaxialDistance defines distance between each color axis
  8722. * @param scene defines the hosting scene
  8723. */
  8724. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8725. /**
  8726. * Gets camera class name
  8727. * @returns AnaglyphGamepadCamera
  8728. */
  8729. getClassName(): string;
  8730. }
  8731. /**
  8732. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  8733. */
  8734. class AnaglyphUniversalCamera extends UniversalCamera {
  8735. /**
  8736. * Creates a new AnaglyphUniversalCamera
  8737. * @param name defines camera name
  8738. * @param position defines initial position
  8739. * @param interaxialDistance defines distance between each color axis
  8740. * @param scene defines the hosting scene
  8741. */
  8742. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8743. /**
  8744. * Gets camera class name
  8745. * @returns AnaglyphUniversalCamera
  8746. */
  8747. getClassName(): string;
  8748. }
  8749. /**
  8750. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  8751. */
  8752. class StereoscopicFreeCamera extends FreeCamera {
  8753. /**
  8754. * Creates a new StereoscopicFreeCamera
  8755. * @param name defines camera name
  8756. * @param position defines initial position
  8757. * @param interaxialDistance defines distance between each color axis
  8758. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8759. * @param scene defines the hosting scene
  8760. */
  8761. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8762. /**
  8763. * Gets camera class name
  8764. * @returns StereoscopicFreeCamera
  8765. */
  8766. getClassName(): string;
  8767. }
  8768. /**
  8769. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  8770. */
  8771. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  8772. /**
  8773. * Creates a new StereoscopicArcRotateCamera
  8774. * @param name defines camera name
  8775. * @param alpha defines alpha angle (in radians)
  8776. * @param beta defines beta angle (in radians)
  8777. * @param radius defines radius
  8778. * @param target defines camera target
  8779. * @param interaxialDistance defines distance between each color axis
  8780. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8781. * @param scene defines the hosting scene
  8782. */
  8783. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8784. /**
  8785. * Gets camera class name
  8786. * @returns StereoscopicArcRotateCamera
  8787. */
  8788. getClassName(): string;
  8789. }
  8790. /**
  8791. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  8792. */
  8793. class StereoscopicGamepadCamera extends GamepadCamera {
  8794. /**
  8795. * Creates a new StereoscopicGamepadCamera
  8796. * @param name defines camera name
  8797. * @param position defines initial position
  8798. * @param interaxialDistance defines distance between each color axis
  8799. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8800. * @param scene defines the hosting scene
  8801. */
  8802. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8803. /**
  8804. * Gets camera class name
  8805. * @returns StereoscopicGamepadCamera
  8806. */
  8807. getClassName(): string;
  8808. }
  8809. /**
  8810. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  8811. */
  8812. class StereoscopicUniversalCamera extends UniversalCamera {
  8813. /**
  8814. * Creates a new StereoscopicUniversalCamera
  8815. * @param name defines camera name
  8816. * @param position defines initial position
  8817. * @param interaxialDistance defines distance between each color axis
  8818. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8819. * @param scene defines the hosting scene
  8820. */
  8821. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8822. /**
  8823. * Gets camera class name
  8824. * @returns StereoscopicUniversalCamera
  8825. */
  8826. getClassName(): string;
  8827. }
  8828. }
  8829. declare module BABYLON {
  8830. class TargetCamera extends Camera {
  8831. cameraDirection: Vector3;
  8832. cameraRotation: Vector2;
  8833. rotation: Vector3;
  8834. rotationQuaternion: Quaternion;
  8835. speed: number;
  8836. noRotationConstraint: boolean;
  8837. lockedTarget: any;
  8838. _currentTarget: Vector3;
  8839. _viewMatrix: Matrix;
  8840. _camMatrix: Matrix;
  8841. _cameraTransformMatrix: Matrix;
  8842. _cameraRotationMatrix: Matrix;
  8843. private _rigCamTransformMatrix;
  8844. _referencePoint: Vector3;
  8845. private _currentUpVector;
  8846. _transformedReferencePoint: Vector3;
  8847. protected _globalCurrentTarget: Vector3;
  8848. protected _globalCurrentUpVector: Vector3;
  8849. _reset: () => void;
  8850. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8851. getFrontPosition(distance: number): Vector3;
  8852. _getLockedTargetPosition(): Nullable<Vector3>;
  8853. /**
  8854. * Store current camera state (fov, position, etc..)
  8855. */
  8856. private _storedPosition;
  8857. private _storedRotation;
  8858. private _storedRotationQuaternion;
  8859. storeState(): Camera;
  8860. /**
  8861. * Restored camera state. You must call storeState() first
  8862. */
  8863. _restoreStateValues(): boolean;
  8864. _initCache(): void;
  8865. _updateCache(ignoreParentClass?: boolean): void;
  8866. _isSynchronizedViewMatrix(): boolean;
  8867. _computeLocalCameraSpeed(): number;
  8868. setTarget(target: Vector3): void;
  8869. /**
  8870. * Return the current target position of the camera. This value is expressed in local space.
  8871. */
  8872. getTarget(): Vector3;
  8873. _decideIfNeedsToMove(): boolean;
  8874. _updatePosition(): void;
  8875. _checkInputs(): void;
  8876. protected _updateCameraRotationMatrix(): void;
  8877. _getViewMatrix(): Matrix;
  8878. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8879. /**
  8880. * @override
  8881. * Override Camera.createRigCamera
  8882. */
  8883. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8884. /**
  8885. * @override
  8886. * Override Camera._updateRigCameras
  8887. */
  8888. _updateRigCameras(): void;
  8889. private _getRigCamPosition(halfSpace, result);
  8890. getClassName(): string;
  8891. }
  8892. }
  8893. declare module BABYLON {
  8894. class TouchCamera extends FreeCamera {
  8895. touchAngularSensibility: number;
  8896. touchMoveSensibility: number;
  8897. constructor(name: string, position: Vector3, scene: Scene);
  8898. getClassName(): string;
  8899. _setupInputs(): void;
  8900. }
  8901. }
  8902. declare module BABYLON {
  8903. class UniversalCamera extends TouchCamera {
  8904. gamepadAngularSensibility: number;
  8905. gamepadMoveSensibility: number;
  8906. constructor(name: string, position: Vector3, scene: Scene);
  8907. getClassName(): string;
  8908. }
  8909. }
  8910. declare module BABYLON {
  8911. class VirtualJoysticksCamera extends FreeCamera {
  8912. constructor(name: string, position: Vector3, scene: Scene);
  8913. getClassName(): string;
  8914. }
  8915. }
  8916. interface VRDisplay extends EventTarget {
  8917. /**
  8918. * Dictionary of capabilities describing the VRDisplay.
  8919. */
  8920. readonly capabilities: VRDisplayCapabilities;
  8921. /**
  8922. * z-depth defining the far plane of the eye view frustum
  8923. * enables mapping of values in the render target depth
  8924. * attachment to scene coordinates. Initially set to 10000.0.
  8925. */
  8926. depthFar: number;
  8927. /**
  8928. * z-depth defining the near plane of the eye view frustum
  8929. * enables mapping of values in the render target depth
  8930. * attachment to scene coordinates. Initially set to 0.01.
  8931. */
  8932. depthNear: number;
  8933. /**
  8934. * An identifier for this distinct VRDisplay. Used as an
  8935. * association point in the Gamepad API.
  8936. */
  8937. readonly displayId: number;
  8938. /**
  8939. * A display name, a user-readable name identifying it.
  8940. */
  8941. readonly displayName: string;
  8942. readonly isConnected: boolean;
  8943. readonly isPresenting: boolean;
  8944. /**
  8945. * If this VRDisplay supports room-scale experiences, the optional
  8946. * stage attribute contains details on the room-scale parameters.
  8947. */
  8948. readonly stageParameters: VRStageParameters | null;
  8949. /**
  8950. * Passing the value returned by `requestAnimationFrame` to
  8951. * `cancelAnimationFrame` will unregister the callback.
  8952. */
  8953. cancelAnimationFrame(handle: number): void;
  8954. /**
  8955. * Stops presenting to the VRDisplay.
  8956. */
  8957. exitPresent(): Promise<void>;
  8958. getEyeParameters(whichEye: string): VREyeParameters;
  8959. /**
  8960. * Populates the passed VRFrameData with the information required to render
  8961. * the current frame.
  8962. */
  8963. getFrameData(frameData: VRFrameData): boolean;
  8964. /**
  8965. * Get the layers currently being presented.
  8966. */
  8967. getLayers(): VRLayer[];
  8968. /**
  8969. * Return a VRPose containing the future predicted pose of the VRDisplay
  8970. * when the current frame will be presented. The value returned will not
  8971. * change until JavaScript has returned control to the browser.
  8972. *
  8973. * The VRPose will contain the position, orientation, velocity,
  8974. * and acceleration of each of these properties.
  8975. */
  8976. getPose(): VRPose;
  8977. /**
  8978. * Return the current instantaneous pose of the VRDisplay, with no
  8979. * prediction applied.
  8980. */
  8981. getImmediatePose(): VRPose;
  8982. /**
  8983. * The callback passed to `requestAnimationFrame` will be called
  8984. * any time a new frame should be rendered. When the VRDisplay is
  8985. * presenting the callback will be called at the native refresh
  8986. * rate of the HMD. When not presenting this function acts
  8987. * identically to how window.requestAnimationFrame acts. Content should
  8988. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8989. * asynchronously from other displays and at differing refresh rates.
  8990. */
  8991. requestAnimationFrame(callback: FrameRequestCallback): number;
  8992. /**
  8993. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8994. * Repeat calls while already presenting will update the VRLayers being displayed.
  8995. */
  8996. requestPresent(layers: VRLayer[]): Promise<void>;
  8997. /**
  8998. * Reset the pose for this display, treating its current position and
  8999. * orientation as the "origin/zero" values. VRPose.position,
  9000. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9001. * updated when calling resetPose(). This should be called in only
  9002. * sitting-space experiences.
  9003. */
  9004. resetPose(): void;
  9005. /**
  9006. * The VRLayer provided to the VRDisplay will be captured and presented
  9007. * in the HMD. Calling this function has the same effect on the source
  9008. * canvas as any other operation that uses its source image, and canvases
  9009. * created without preserveDrawingBuffer set to true will be cleared.
  9010. */
  9011. submitFrame(pose?: VRPose): void;
  9012. }
  9013. declare var VRDisplay: {
  9014. prototype: VRDisplay;
  9015. new (): VRDisplay;
  9016. };
  9017. interface VRLayer {
  9018. leftBounds?: number[] | null;
  9019. rightBounds?: number[] | null;
  9020. source?: HTMLCanvasElement | null;
  9021. }
  9022. interface VRDisplayCapabilities {
  9023. readonly canPresent: boolean;
  9024. readonly hasExternalDisplay: boolean;
  9025. readonly hasOrientation: boolean;
  9026. readonly hasPosition: boolean;
  9027. readonly maxLayers: number;
  9028. }
  9029. interface VREyeParameters {
  9030. /** @deprecated */
  9031. readonly fieldOfView: VRFieldOfView;
  9032. readonly offset: Float32Array;
  9033. readonly renderHeight: number;
  9034. readonly renderWidth: number;
  9035. }
  9036. interface VRFieldOfView {
  9037. readonly downDegrees: number;
  9038. readonly leftDegrees: number;
  9039. readonly rightDegrees: number;
  9040. readonly upDegrees: number;
  9041. }
  9042. interface VRFrameData {
  9043. readonly leftProjectionMatrix: Float32Array;
  9044. readonly leftViewMatrix: Float32Array;
  9045. readonly pose: VRPose;
  9046. readonly rightProjectionMatrix: Float32Array;
  9047. readonly rightViewMatrix: Float32Array;
  9048. readonly timestamp: number;
  9049. }
  9050. interface VRPose {
  9051. readonly angularAcceleration: Float32Array | null;
  9052. readonly angularVelocity: Float32Array | null;
  9053. readonly linearAcceleration: Float32Array | null;
  9054. readonly linearVelocity: Float32Array | null;
  9055. readonly orientation: Float32Array | null;
  9056. readonly position: Float32Array | null;
  9057. readonly timestamp: number;
  9058. }
  9059. interface VRStageParameters {
  9060. sittingToStandingTransform?: Float32Array;
  9061. sizeX?: number;
  9062. sizeY?: number;
  9063. }
  9064. interface Navigator {
  9065. getVRDisplays(): Promise<VRDisplay[]>;
  9066. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9067. }
  9068. interface Window {
  9069. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9070. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9071. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9072. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9073. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9074. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9075. }
  9076. interface Gamepad {
  9077. readonly displayId: number;
  9078. }
  9079. declare module BABYLON {
  9080. class BoundingBox implements ICullable {
  9081. vectors: Vector3[];
  9082. center: Vector3;
  9083. centerWorld: Vector3;
  9084. extendSize: Vector3;
  9085. extendSizeWorld: Vector3;
  9086. directions: Vector3[];
  9087. vectorsWorld: Vector3[];
  9088. minimumWorld: Vector3;
  9089. maximumWorld: Vector3;
  9090. minimum: Vector3;
  9091. maximum: Vector3;
  9092. private _worldMatrix;
  9093. /**
  9094. * Creates a new bounding box
  9095. * @param min defines the minimum vector (in local space)
  9096. * @param max defines the maximum vector (in local space)
  9097. */
  9098. constructor(min: Vector3, max: Vector3);
  9099. /**
  9100. * Recreates the entire bounding box from scratch
  9101. * @param min defines the new minimum vector (in local space)
  9102. * @param max defines the new maximum vector (in local space)
  9103. */
  9104. reConstruct(min: Vector3, max: Vector3): void;
  9105. getWorldMatrix(): Matrix;
  9106. setWorldMatrix(matrix: Matrix): BoundingBox;
  9107. _update(world: Matrix): void;
  9108. isInFrustum(frustumPlanes: Plane[]): boolean;
  9109. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9110. intersectsPoint(point: Vector3): boolean;
  9111. intersectsSphere(sphere: BoundingSphere): boolean;
  9112. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  9113. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  9114. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  9115. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  9116. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  9117. }
  9118. }
  9119. declare module BABYLON {
  9120. interface ICullable {
  9121. isInFrustum(frustumPlanes: Plane[]): boolean;
  9122. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9123. }
  9124. class BoundingInfo implements ICullable {
  9125. minimum: Vector3;
  9126. maximum: Vector3;
  9127. boundingBox: BoundingBox;
  9128. boundingSphere: BoundingSphere;
  9129. private _isLocked;
  9130. constructor(minimum: Vector3, maximum: Vector3);
  9131. isLocked: boolean;
  9132. update(world: Matrix): void;
  9133. /**
  9134. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9135. * @param center New center of the bounding info
  9136. * @param extend New extend of the bounding info
  9137. */
  9138. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  9139. isInFrustum(frustumPlanes: Plane[]): boolean;
  9140. /**
  9141. * Gets the world distance between the min and max points of the bounding box
  9142. */
  9143. readonly diagonalLength: number;
  9144. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9145. _checkCollision(collider: Collider): boolean;
  9146. intersectsPoint(point: Vector3): boolean;
  9147. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  9148. }
  9149. }
  9150. declare module BABYLON {
  9151. class BoundingSphere {
  9152. center: Vector3;
  9153. radius: number;
  9154. centerWorld: Vector3;
  9155. radiusWorld: number;
  9156. minimum: Vector3;
  9157. maximum: Vector3;
  9158. private _tempRadiusVector;
  9159. /**
  9160. * Creates a new bounding sphere
  9161. * @param min defines the minimum vector (in local space)
  9162. * @param max defines the maximum vector (in local space)
  9163. */
  9164. constructor(min: Vector3, max: Vector3);
  9165. /**
  9166. * Recreates the entire bounding sphere from scratch
  9167. * @param min defines the new minimum vector (in local space)
  9168. * @param max defines the new maximum vector (in local space)
  9169. */
  9170. reConstruct(min: Vector3, max: Vector3): void;
  9171. _update(world: Matrix): void;
  9172. isInFrustum(frustumPlanes: Plane[]): boolean;
  9173. intersectsPoint(point: Vector3): boolean;
  9174. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  9175. }
  9176. }
  9177. declare module BABYLON {
  9178. class Ray {
  9179. origin: Vector3;
  9180. direction: Vector3;
  9181. length: number;
  9182. private _edge1;
  9183. private _edge2;
  9184. private _pvec;
  9185. private _tvec;
  9186. private _qvec;
  9187. private _tmpRay;
  9188. constructor(origin: Vector3, direction: Vector3, length?: number);
  9189. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  9190. intersectsBox(box: BoundingBox): boolean;
  9191. intersectsSphere(sphere: BoundingSphere): boolean;
  9192. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  9193. intersectsPlane(plane: Plane): Nullable<number>;
  9194. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  9195. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9196. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  9197. private static smallnum;
  9198. private static rayl;
  9199. /**
  9200. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9201. * @param sega the first point of the segment to test the intersection against
  9202. * @param segb the second point of the segment to test the intersection against
  9203. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9204. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9205. */
  9206. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  9207. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9208. static Zero(): Ray;
  9209. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9210. /**
  9211. * 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
  9212. * transformed to the given world matrix.
  9213. * @param origin The origin point
  9214. * @param end The end point
  9215. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9216. */
  9217. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  9218. static Transform(ray: Ray, matrix: Matrix): Ray;
  9219. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  9220. }
  9221. }
  9222. declare module BABYLON {
  9223. class KeyboardEventTypes {
  9224. static _KEYDOWN: number;
  9225. static _KEYUP: number;
  9226. static readonly KEYDOWN: number;
  9227. static readonly KEYUP: number;
  9228. }
  9229. class KeyboardInfo {
  9230. type: number;
  9231. event: KeyboardEvent;
  9232. constructor(type: number, event: KeyboardEvent);
  9233. }
  9234. /**
  9235. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9236. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9237. */
  9238. class KeyboardInfoPre extends KeyboardInfo {
  9239. constructor(type: number, event: KeyboardEvent);
  9240. skipOnPointerObservable: boolean;
  9241. }
  9242. }
  9243. declare module BABYLON {
  9244. class PointerEventTypes {
  9245. static _POINTERDOWN: number;
  9246. static _POINTERUP: number;
  9247. static _POINTERMOVE: number;
  9248. static _POINTERWHEEL: number;
  9249. static _POINTERPICK: number;
  9250. static _POINTERTAP: number;
  9251. static _POINTERDOUBLETAP: number;
  9252. static readonly POINTERDOWN: number;
  9253. static readonly POINTERUP: number;
  9254. static readonly POINTERMOVE: number;
  9255. static readonly POINTERWHEEL: number;
  9256. static readonly POINTERPICK: number;
  9257. static readonly POINTERTAP: number;
  9258. static readonly POINTERDOUBLETAP: number;
  9259. }
  9260. class PointerInfoBase {
  9261. type: number;
  9262. event: PointerEvent | MouseWheelEvent;
  9263. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9264. }
  9265. /**
  9266. * This class is used to store pointer related info for the onPrePointerObservable event.
  9267. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9268. */
  9269. class PointerInfoPre extends PointerInfoBase {
  9270. /**
  9271. * Ray from a pointer if availible (eg. 6dof controller)
  9272. */
  9273. ray: Nullable<Ray>;
  9274. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9275. localPosition: Vector2;
  9276. skipOnPointerObservable: boolean;
  9277. }
  9278. /**
  9279. * This type contains all the data related to a pointer event in Babylon.js.
  9280. * 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.
  9281. */
  9282. class PointerInfo extends PointerInfoBase {
  9283. pickInfo: Nullable<PickingInfo>;
  9284. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9285. }
  9286. }
  9287. declare module BABYLON {
  9288. class StickValues {
  9289. x: number;
  9290. y: number;
  9291. constructor(x: number, y: number);
  9292. }
  9293. interface GamepadButtonChanges {
  9294. changed: boolean;
  9295. pressChanged: boolean;
  9296. touchChanged: boolean;
  9297. valueChanged: boolean;
  9298. }
  9299. class Gamepad {
  9300. id: string;
  9301. index: number;
  9302. browserGamepad: any;
  9303. type: number;
  9304. private _leftStick;
  9305. private _rightStick;
  9306. _isConnected: boolean;
  9307. private _leftStickAxisX;
  9308. private _leftStickAxisY;
  9309. private _rightStickAxisX;
  9310. private _rightStickAxisY;
  9311. private _onleftstickchanged;
  9312. private _onrightstickchanged;
  9313. static GAMEPAD: number;
  9314. static GENERIC: number;
  9315. static XBOX: number;
  9316. static POSE_ENABLED: number;
  9317. protected _invertLeftStickY: boolean;
  9318. readonly isConnected: boolean;
  9319. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9320. onleftstickchanged(callback: (values: StickValues) => void): void;
  9321. onrightstickchanged(callback: (values: StickValues) => void): void;
  9322. leftStick: StickValues;
  9323. rightStick: StickValues;
  9324. update(): void;
  9325. dispose(): void;
  9326. }
  9327. class GenericPad extends Gamepad {
  9328. private _buttons;
  9329. private _onbuttondown;
  9330. private _onbuttonup;
  9331. onButtonDownObservable: Observable<number>;
  9332. onButtonUpObservable: Observable<number>;
  9333. onbuttondown(callback: (buttonPressed: number) => void): void;
  9334. onbuttonup(callback: (buttonReleased: number) => void): void;
  9335. constructor(id: string, index: number, browserGamepad: any);
  9336. private _setButtonValue(newValue, currentValue, buttonIndex);
  9337. update(): void;
  9338. dispose(): void;
  9339. }
  9340. }
  9341. declare module BABYLON {
  9342. class GamepadManager {
  9343. private _scene;
  9344. private _babylonGamepads;
  9345. private _oneGamepadConnected;
  9346. _isMonitoring: boolean;
  9347. private _gamepadEventSupported;
  9348. private _gamepadSupport;
  9349. onGamepadConnectedObservable: Observable<Gamepad>;
  9350. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9351. private _onGamepadConnectedEvent;
  9352. private _onGamepadDisconnectedEvent;
  9353. constructor(_scene?: Scene | undefined);
  9354. readonly gamepads: Gamepad[];
  9355. getGamepadByType(type?: number): Nullable<Gamepad>;
  9356. dispose(): void;
  9357. private _addNewGamepad(gamepad);
  9358. private _startMonitoringGamepads();
  9359. private _stopMonitoringGamepads();
  9360. _checkGamepadsStatus(): void;
  9361. private _updateGamepadObjects();
  9362. }
  9363. }
  9364. declare module BABYLON {
  9365. /**
  9366. * Defines supported buttons for XBox360 compatible gamepads
  9367. */
  9368. enum Xbox360Button {
  9369. /** A */
  9370. A = 0,
  9371. /** B */
  9372. B = 1,
  9373. /** X */
  9374. X = 2,
  9375. /** Y */
  9376. Y = 3,
  9377. /** Start */
  9378. Start = 4,
  9379. /** Back */
  9380. Back = 5,
  9381. /** Left button */
  9382. LB = 6,
  9383. /** Right button */
  9384. RB = 7,
  9385. /** Left stick */
  9386. LeftStick = 8,
  9387. /** Right stick */
  9388. RightStick = 9,
  9389. }
  9390. /** Defines values for XBox360 DPad */
  9391. enum Xbox360Dpad {
  9392. /** Up */
  9393. Up = 0,
  9394. /** Down */
  9395. Down = 1,
  9396. /** Left */
  9397. Left = 2,
  9398. /** Right */
  9399. Right = 3,
  9400. }
  9401. /**
  9402. * Defines a XBox360 gamepad
  9403. */
  9404. class Xbox360Pad extends Gamepad {
  9405. private _leftTrigger;
  9406. private _rightTrigger;
  9407. private _onlefttriggerchanged;
  9408. private _onrighttriggerchanged;
  9409. private _onbuttondown;
  9410. private _onbuttonup;
  9411. private _ondpaddown;
  9412. private _ondpadup;
  9413. /** Observable raised when a button is pressed */
  9414. onButtonDownObservable: Observable<Xbox360Button>;
  9415. /** Observable raised when a button is released */
  9416. onButtonUpObservable: Observable<Xbox360Button>;
  9417. /** Observable raised when a pad is pressed */
  9418. onPadDownObservable: Observable<Xbox360Dpad>;
  9419. /** Observable raised when a pad is released */
  9420. onPadUpObservable: Observable<Xbox360Dpad>;
  9421. private _buttonA;
  9422. private _buttonB;
  9423. private _buttonX;
  9424. private _buttonY;
  9425. private _buttonBack;
  9426. private _buttonStart;
  9427. private _buttonLB;
  9428. private _buttonRB;
  9429. private _buttonLeftStick;
  9430. private _buttonRightStick;
  9431. private _dPadUp;
  9432. private _dPadDown;
  9433. private _dPadLeft;
  9434. private _dPadRight;
  9435. private _isXboxOnePad;
  9436. /**
  9437. * Creates a new XBox360 gamepad object
  9438. * @param id defines the id of this gamepad
  9439. * @param index defines its index
  9440. * @param gamepad defines the internal HTML gamepad object
  9441. * @param xboxOne defines if it is a XBox One gamepad
  9442. */
  9443. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9444. /**
  9445. * Defines the callback to call when left trigger is pressed
  9446. * @param callback defines the callback to use
  9447. */
  9448. onlefttriggerchanged(callback: (value: number) => void): void;
  9449. /**
  9450. * Defines the callback to call when right trigger is pressed
  9451. * @param callback defines the callback to use
  9452. */
  9453. onrighttriggerchanged(callback: (value: number) => void): void;
  9454. /**
  9455. * Gets or sets left trigger value
  9456. */
  9457. leftTrigger: number;
  9458. /**
  9459. * Gets or sets right trigger value
  9460. */
  9461. rightTrigger: number;
  9462. /**
  9463. * Defines the callback to call when a button is pressed
  9464. * @param callback defines the callback to use
  9465. */
  9466. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9467. /**
  9468. * Defines the callback to call when a button is released
  9469. * @param callback defines the callback to use
  9470. */
  9471. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9472. /**
  9473. * Defines the callback to call when a pad is pressed
  9474. * @param callback defines the callback to use
  9475. */
  9476. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9477. /**
  9478. * Defines the callback to call when a pad is released
  9479. * @param callback defines the callback to use
  9480. */
  9481. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9482. private _setButtonValue(newValue, currentValue, buttonType);
  9483. private _setDPadValue(newValue, currentValue, buttonType);
  9484. /** Gets or sets value of A button */
  9485. buttonA: number;
  9486. /** Gets or sets value of B button */
  9487. buttonB: number;
  9488. /** Gets or sets value of X button */
  9489. buttonX: number;
  9490. /** Gets or sets value of Y button */
  9491. buttonY: number;
  9492. /** Gets or sets value of Start button */
  9493. buttonStart: number;
  9494. /** Gets or sets value of Back button */
  9495. buttonBack: number;
  9496. /** Gets or sets value of Left button */
  9497. buttonLB: number;
  9498. /** Gets or sets value of Right button */
  9499. buttonRB: number;
  9500. /** Gets or sets value of left stick */
  9501. buttonLeftStick: number;
  9502. /** Gets or sets value of right stick */
  9503. buttonRightStick: number;
  9504. /** Gets or sets value of DPad up */
  9505. dPadUp: number;
  9506. /** Gets or sets value of DPad down */
  9507. dPadDown: number;
  9508. /** Gets or sets value of DPad left */
  9509. dPadLeft: number;
  9510. /** Gets or sets value of DPad right */
  9511. dPadRight: number;
  9512. /**
  9513. * Force the gamepad to synchronize with device values
  9514. */
  9515. update(): void;
  9516. dispose(): void;
  9517. }
  9518. }
  9519. declare module BABYLON {
  9520. /**
  9521. * Single axis drag gizmo
  9522. */
  9523. class AxisDragGizmo extends Gizmo {
  9524. private _dragBehavior;
  9525. /**
  9526. * Creates an AxisDragGizmo
  9527. * @param gizmoLayer The utility layer the gizmo will be added to
  9528. * @param dragAxis The axis which the gizmo will be able to drag on
  9529. * @param color The color of the gizmo
  9530. */
  9531. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9532. /**
  9533. * Disposes of the gizmo
  9534. */
  9535. dispose(): void;
  9536. }
  9537. }
  9538. declare module BABYLON {
  9539. /**
  9540. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9541. */
  9542. class Gizmo implements IDisposable {
  9543. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9544. /**
  9545. * The root mesh of the gizmo
  9546. */
  9547. protected _rootMesh: Mesh;
  9548. /**
  9549. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9550. */
  9551. attachedMesh: Nullable<Mesh>;
  9552. private _beforeRenderObserver;
  9553. /**
  9554. * Creates a gizmo
  9555. * @param gizmoLayer The utility layer the gizmo will be added to
  9556. */
  9557. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9558. /**
  9559. * Disposes of the gizmo
  9560. */
  9561. dispose(): void;
  9562. }
  9563. }
  9564. declare module BABYLON {
  9565. /**
  9566. * Gizmo that enables dragging a mesh along 3 axis
  9567. */
  9568. class PositionGizmo extends Gizmo {
  9569. private _xDrag;
  9570. private _yDrag;
  9571. private _zDrag;
  9572. attachedMesh: Nullable<Mesh>;
  9573. /**
  9574. * Creates a PositionGizmo
  9575. * @param gizmoLayer The utility layer the gizmo will be added to
  9576. */
  9577. constructor(gizmoLayer: UtilityLayerRenderer);
  9578. /**
  9579. * Disposes of the gizmo
  9580. */
  9581. dispose(): void;
  9582. }
  9583. }
  9584. declare module BABYLON {
  9585. /**
  9586. * This class can be used to get instrumentation data from a Babylon engine
  9587. */
  9588. class EngineInstrumentation implements IDisposable {
  9589. engine: Engine;
  9590. private _captureGPUFrameTime;
  9591. private _gpuFrameTimeToken;
  9592. private _gpuFrameTime;
  9593. private _captureShaderCompilationTime;
  9594. private _shaderCompilationTime;
  9595. private _onBeginFrameObserver;
  9596. private _onEndFrameObserver;
  9597. private _onBeforeShaderCompilationObserver;
  9598. private _onAfterShaderCompilationObserver;
  9599. /**
  9600. * Gets the perf counter used for GPU frame time
  9601. */
  9602. readonly gpuFrameTimeCounter: PerfCounter;
  9603. /**
  9604. * Gets the GPU frame time capture status
  9605. */
  9606. /**
  9607. * Enable or disable the GPU frame time capture
  9608. */
  9609. captureGPUFrameTime: boolean;
  9610. /**
  9611. * Gets the perf counter used for shader compilation time
  9612. */
  9613. readonly shaderCompilationTimeCounter: PerfCounter;
  9614. /**
  9615. * Gets the shader compilation time capture status
  9616. */
  9617. /**
  9618. * Enable or disable the shader compilation time capture
  9619. */
  9620. captureShaderCompilationTime: boolean;
  9621. constructor(engine: Engine);
  9622. dispose(): void;
  9623. }
  9624. }
  9625. declare module BABYLON {
  9626. /**
  9627. * This class can be used to get instrumentation data from a Babylon engine
  9628. */
  9629. class SceneInstrumentation implements IDisposable {
  9630. scene: Scene;
  9631. private _captureActiveMeshesEvaluationTime;
  9632. private _activeMeshesEvaluationTime;
  9633. private _captureRenderTargetsRenderTime;
  9634. private _renderTargetsRenderTime;
  9635. private _captureFrameTime;
  9636. private _frameTime;
  9637. private _captureRenderTime;
  9638. private _renderTime;
  9639. private _captureInterFrameTime;
  9640. private _interFrameTime;
  9641. private _captureParticlesRenderTime;
  9642. private _particlesRenderTime;
  9643. private _captureSpritesRenderTime;
  9644. private _spritesRenderTime;
  9645. private _capturePhysicsTime;
  9646. private _physicsTime;
  9647. private _captureAnimationsTime;
  9648. private _animationsTime;
  9649. private _onBeforeActiveMeshesEvaluationObserver;
  9650. private _onAfterActiveMeshesEvaluationObserver;
  9651. private _onBeforeRenderTargetsRenderObserver;
  9652. private _onAfterRenderTargetsRenderObserver;
  9653. private _onAfterRenderObserver;
  9654. private _onBeforeDrawPhaseObserver;
  9655. private _onAfterDrawPhaseObserver;
  9656. private _onBeforeAnimationsObserver;
  9657. private _onBeforeParticlesRenderingObserver;
  9658. private _onAfterParticlesRenderingObserver;
  9659. private _onBeforeSpritesRenderingObserver;
  9660. private _onAfterSpritesRenderingObserver;
  9661. private _onBeforePhysicsObserver;
  9662. private _onAfterPhysicsObserver;
  9663. private _onAfterAnimationsObserver;
  9664. /**
  9665. * Gets the perf counter used for active meshes evaluation time
  9666. */
  9667. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9668. /**
  9669. * Gets the active meshes evaluation time capture status
  9670. */
  9671. /**
  9672. * Enable or disable the active meshes evaluation time capture
  9673. */
  9674. captureActiveMeshesEvaluationTime: boolean;
  9675. /**
  9676. * Gets the perf counter used for render targets render time
  9677. */
  9678. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9679. /**
  9680. * Gets the render targets render time capture status
  9681. */
  9682. /**
  9683. * Enable or disable the render targets render time capture
  9684. */
  9685. captureRenderTargetsRenderTime: boolean;
  9686. /**
  9687. * Gets the perf counter used for particles render time
  9688. */
  9689. readonly particlesRenderTimeCounter: PerfCounter;
  9690. /**
  9691. * Gets the particles render time capture status
  9692. */
  9693. /**
  9694. * Enable or disable the particles render time capture
  9695. */
  9696. captureParticlesRenderTime: boolean;
  9697. /**
  9698. * Gets the perf counter used for sprites render time
  9699. */
  9700. readonly spritesRenderTimeCounter: PerfCounter;
  9701. /**
  9702. * Gets the sprites render time capture status
  9703. */
  9704. /**
  9705. * Enable or disable the sprites render time capture
  9706. */
  9707. captureSpritesRenderTime: boolean;
  9708. /**
  9709. * Gets the perf counter used for physics time
  9710. */
  9711. readonly physicsTimeCounter: PerfCounter;
  9712. /**
  9713. * Gets the physics time capture status
  9714. */
  9715. /**
  9716. * Enable or disable the physics time capture
  9717. */
  9718. capturePhysicsTime: boolean;
  9719. /**
  9720. * Gets the perf counter used for animations time
  9721. */
  9722. readonly animationsTimeCounter: PerfCounter;
  9723. /**
  9724. * Gets the animations time capture status
  9725. */
  9726. /**
  9727. * Enable or disable the animations time capture
  9728. */
  9729. captureAnimationsTime: boolean;
  9730. /**
  9731. * Gets the perf counter used for frame time capture
  9732. */
  9733. readonly frameTimeCounter: PerfCounter;
  9734. /**
  9735. * Gets the frame time capture status
  9736. */
  9737. /**
  9738. * Enable or disable the frame time capture
  9739. */
  9740. captureFrameTime: boolean;
  9741. /**
  9742. * Gets the perf counter used for inter-frames time capture
  9743. */
  9744. readonly interFrameTimeCounter: PerfCounter;
  9745. /**
  9746. * Gets the inter-frames time capture status
  9747. */
  9748. /**
  9749. * Enable or disable the inter-frames time capture
  9750. */
  9751. captureInterFrameTime: boolean;
  9752. /**
  9753. * Gets the perf counter used for render time capture
  9754. */
  9755. readonly renderTimeCounter: PerfCounter;
  9756. /**
  9757. * Gets the render time capture status
  9758. */
  9759. /**
  9760. * Enable or disable the render time capture
  9761. */
  9762. captureRenderTime: boolean;
  9763. /**
  9764. * Gets the perf counter used for draw calls
  9765. */
  9766. readonly drawCallsCounter: PerfCounter;
  9767. /**
  9768. * Gets the perf counter used for texture collisions
  9769. */
  9770. readonly textureCollisionsCounter: PerfCounter;
  9771. constructor(scene: Scene);
  9772. dispose(): void;
  9773. }
  9774. }
  9775. declare module BABYLON {
  9776. /**
  9777. * @hidden
  9778. **/
  9779. class _TimeToken {
  9780. _startTimeQuery: Nullable<WebGLQuery>;
  9781. _endTimeQuery: Nullable<WebGLQuery>;
  9782. _timeElapsedQuery: Nullable<WebGLQuery>;
  9783. _timeElapsedQueryEnded: boolean;
  9784. }
  9785. }
  9786. declare module BABYLON {
  9787. /**
  9788. * Represents the different options available during the creation of
  9789. * a Environment helper.
  9790. *
  9791. * This can control the default ground, skybox and image processing setup of your scene.
  9792. */
  9793. interface IEnvironmentHelperOptions {
  9794. /**
  9795. * Specifies wether or not to create a ground.
  9796. * True by default.
  9797. */
  9798. createGround: boolean;
  9799. /**
  9800. * Specifies the ground size.
  9801. * 15 by default.
  9802. */
  9803. groundSize: number;
  9804. /**
  9805. * The texture used on the ground for the main color.
  9806. * Comes from the BabylonJS CDN by default.
  9807. *
  9808. * Remarks: Can be either a texture or a url.
  9809. */
  9810. groundTexture: string | BaseTexture;
  9811. /**
  9812. * The color mixed in the ground texture by default.
  9813. * BabylonJS clearColor by default.
  9814. */
  9815. groundColor: Color3;
  9816. /**
  9817. * Specifies the ground opacity.
  9818. * 1 by default.
  9819. */
  9820. groundOpacity: number;
  9821. /**
  9822. * Enables the ground to receive shadows.
  9823. * True by default.
  9824. */
  9825. enableGroundShadow: boolean;
  9826. /**
  9827. * Helps preventing the shadow to be fully black on the ground.
  9828. * 0.5 by default.
  9829. */
  9830. groundShadowLevel: number;
  9831. /**
  9832. * Creates a mirror texture attach to the ground.
  9833. * false by default.
  9834. */
  9835. enableGroundMirror: boolean;
  9836. /**
  9837. * Specifies the ground mirror size ratio.
  9838. * 0.3 by default as the default kernel is 64.
  9839. */
  9840. groundMirrorSizeRatio: number;
  9841. /**
  9842. * Specifies the ground mirror blur kernel size.
  9843. * 64 by default.
  9844. */
  9845. groundMirrorBlurKernel: number;
  9846. /**
  9847. * Specifies the ground mirror visibility amount.
  9848. * 1 by default
  9849. */
  9850. groundMirrorAmount: number;
  9851. /**
  9852. * Specifies the ground mirror reflectance weight.
  9853. * This uses the standard weight of the background material to setup the fresnel effect
  9854. * of the mirror.
  9855. * 1 by default.
  9856. */
  9857. groundMirrorFresnelWeight: number;
  9858. /**
  9859. * Specifies the ground mirror Falloff distance.
  9860. * This can helps reducing the size of the reflection.
  9861. * 0 by Default.
  9862. */
  9863. groundMirrorFallOffDistance: number;
  9864. /**
  9865. * Specifies the ground mirror texture type.
  9866. * Unsigned Int by Default.
  9867. */
  9868. groundMirrorTextureType: number;
  9869. /**
  9870. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9871. * the shown objects.
  9872. */
  9873. groundYBias: number;
  9874. /**
  9875. * Specifies wether or not to create a skybox.
  9876. * True by default.
  9877. */
  9878. createSkybox: boolean;
  9879. /**
  9880. * Specifies the skybox size.
  9881. * 20 by default.
  9882. */
  9883. skyboxSize: number;
  9884. /**
  9885. * The texture used on the skybox for the main color.
  9886. * Comes from the BabylonJS CDN by default.
  9887. *
  9888. * Remarks: Can be either a texture or a url.
  9889. */
  9890. skyboxTexture: string | BaseTexture;
  9891. /**
  9892. * The color mixed in the skybox texture by default.
  9893. * BabylonJS clearColor by default.
  9894. */
  9895. skyboxColor: Color3;
  9896. /**
  9897. * The background rotation around the Y axis of the scene.
  9898. * This helps aligning the key lights of your scene with the background.
  9899. * 0 by default.
  9900. */
  9901. backgroundYRotation: number;
  9902. /**
  9903. * Compute automatically the size of the elements to best fit with the scene.
  9904. */
  9905. sizeAuto: boolean;
  9906. /**
  9907. * Default position of the rootMesh if autoSize is not true.
  9908. */
  9909. rootPosition: Vector3;
  9910. /**
  9911. * Sets up the image processing in the scene.
  9912. * true by default.
  9913. */
  9914. setupImageProcessing: boolean;
  9915. /**
  9916. * The texture used as your environment texture in the scene.
  9917. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9918. *
  9919. * Remarks: Can be either a texture or a url.
  9920. */
  9921. environmentTexture: string | BaseTexture;
  9922. /**
  9923. * The value of the exposure to apply to the scene.
  9924. * 0.6 by default if setupImageProcessing is true.
  9925. */
  9926. cameraExposure: number;
  9927. /**
  9928. * The value of the contrast to apply to the scene.
  9929. * 1.6 by default if setupImageProcessing is true.
  9930. */
  9931. cameraContrast: number;
  9932. /**
  9933. * Specifies wether or not tonemapping should be enabled in the scene.
  9934. * true by default if setupImageProcessing is true.
  9935. */
  9936. toneMappingEnabled: boolean;
  9937. }
  9938. /**
  9939. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9940. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9941. * It also helps with the default setup of your imageProcessing configuration.
  9942. */
  9943. class EnvironmentHelper {
  9944. /**
  9945. * Default ground texture URL.
  9946. */
  9947. private static _groundTextureCDNUrl;
  9948. /**
  9949. * Default skybox texture URL.
  9950. */
  9951. private static _skyboxTextureCDNUrl;
  9952. /**
  9953. * Default environment texture URL.
  9954. */
  9955. private static _environmentTextureCDNUrl;
  9956. /**
  9957. * Creates the default options for the helper.
  9958. */
  9959. private static _getDefaultOptions();
  9960. private _rootMesh;
  9961. /**
  9962. * Gets the root mesh created by the helper.
  9963. */
  9964. readonly rootMesh: Mesh;
  9965. private _skybox;
  9966. /**
  9967. * Gets the skybox created by the helper.
  9968. */
  9969. readonly skybox: Nullable<Mesh>;
  9970. private _skyboxTexture;
  9971. /**
  9972. * Gets the skybox texture created by the helper.
  9973. */
  9974. readonly skyboxTexture: Nullable<BaseTexture>;
  9975. private _skyboxMaterial;
  9976. /**
  9977. * Gets the skybox material created by the helper.
  9978. */
  9979. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9980. private _ground;
  9981. /**
  9982. * Gets the ground mesh created by the helper.
  9983. */
  9984. readonly ground: Nullable<Mesh>;
  9985. private _groundTexture;
  9986. /**
  9987. * Gets the ground texture created by the helper.
  9988. */
  9989. readonly groundTexture: Nullable<BaseTexture>;
  9990. private _groundMirror;
  9991. /**
  9992. * Gets the ground mirror created by the helper.
  9993. */
  9994. readonly groundMirror: Nullable<MirrorTexture>;
  9995. /**
  9996. * Gets the ground mirror render list to helps pushing the meshes
  9997. * you wish in the ground reflection.
  9998. */
  9999. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10000. private _groundMaterial;
  10001. /**
  10002. * Gets the ground material created by the helper.
  10003. */
  10004. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10005. /**
  10006. * Stores the creation options.
  10007. */
  10008. private readonly _scene;
  10009. private _options;
  10010. /**
  10011. * This observable will be notified with any error during the creation of the environment,
  10012. * mainly texture creation errors.
  10013. */
  10014. onErrorObservable: Observable<{
  10015. message?: string;
  10016. exception?: any;
  10017. }>;
  10018. /**
  10019. * constructor
  10020. * @param options
  10021. * @param scene The scene to add the material to
  10022. */
  10023. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10024. /**
  10025. * Updates the background according to the new options
  10026. * @param options
  10027. */
  10028. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10029. /**
  10030. * Sets the primary color of all the available elements.
  10031. * @param color the main color to affect to the ground and the background
  10032. */
  10033. setMainColor(color: Color3): void;
  10034. /**
  10035. * Setup the image processing according to the specified options.
  10036. */
  10037. private _setupImageProcessing();
  10038. /**
  10039. * Setup the environment texture according to the specified options.
  10040. */
  10041. private _setupEnvironmentTexture();
  10042. /**
  10043. * Setup the background according to the specified options.
  10044. */
  10045. private _setupBackground();
  10046. /**
  10047. * Get the scene sizes according to the setup.
  10048. */
  10049. private _getSceneSize();
  10050. /**
  10051. * Setup the ground according to the specified options.
  10052. */
  10053. private _setupGround(sceneSize);
  10054. /**
  10055. * Setup the ground material according to the specified options.
  10056. */
  10057. private _setupGroundMaterial();
  10058. /**
  10059. * Setup the ground diffuse texture according to the specified options.
  10060. */
  10061. private _setupGroundDiffuseTexture();
  10062. /**
  10063. * Setup the ground mirror texture according to the specified options.
  10064. */
  10065. private _setupGroundMirrorTexture(sceneSize);
  10066. /**
  10067. * Setup the ground to receive the mirror texture.
  10068. */
  10069. private _setupMirrorInGroundMaterial();
  10070. /**
  10071. * Setup the skybox according to the specified options.
  10072. */
  10073. private _setupSkybox(sceneSize);
  10074. /**
  10075. * Setup the skybox material according to the specified options.
  10076. */
  10077. private _setupSkyboxMaterial();
  10078. /**
  10079. * Setup the skybox reflection texture according to the specified options.
  10080. */
  10081. private _setupSkyboxReflectionTexture();
  10082. private _errorHandler;
  10083. /**
  10084. * Dispose all the elements created by the Helper.
  10085. */
  10086. dispose(): void;
  10087. }
  10088. }
  10089. declare module BABYLON {
  10090. /**
  10091. * Represents all the data needed to create a ParticleSystem.
  10092. */
  10093. interface IParticleSystemData {
  10094. /**
  10095. * ParticleSystem type
  10096. */
  10097. type: string;
  10098. /**
  10099. * Shape of the emitter
  10100. */
  10101. emitterType: string;
  10102. /**
  10103. * Maximum number of particles in the system
  10104. */
  10105. capacity: number;
  10106. /**
  10107. * Link for the texture file
  10108. */
  10109. textureFile: string;
  10110. /**
  10111. * minEmitBox Vector3
  10112. */
  10113. minEmitBox?: {
  10114. x: number;
  10115. y: number;
  10116. z: number;
  10117. };
  10118. /**
  10119. * maxEmitBox Vector3
  10120. */
  10121. maxEmitBox?: {
  10122. x: number;
  10123. y: number;
  10124. z: number;
  10125. };
  10126. /**
  10127. * color1 Color4
  10128. */
  10129. color1: {
  10130. r: number;
  10131. g: number;
  10132. b: number;
  10133. a: number;
  10134. };
  10135. /**
  10136. * color2 Color4
  10137. */
  10138. color2: {
  10139. r: number;
  10140. g: number;
  10141. b: number;
  10142. a: number;
  10143. };
  10144. /**
  10145. * colorDead Color4
  10146. */
  10147. colorDead: {
  10148. r: number;
  10149. g: number;
  10150. b: number;
  10151. a: number;
  10152. };
  10153. /**
  10154. * Minimum size of each particle
  10155. */
  10156. minSize: number;
  10157. /**
  10158. * Maximum size of each particle
  10159. */
  10160. maxSize: number;
  10161. /**
  10162. * Minimum lifetime for each particle
  10163. */
  10164. minLifeTime: number;
  10165. /**
  10166. * Maximum lifetime for each particle
  10167. */
  10168. maxLifeTime: number;
  10169. /**
  10170. * Emit rate
  10171. */
  10172. emitRate: number;
  10173. /**
  10174. * Blend Mode
  10175. */
  10176. blendMode: number;
  10177. /**
  10178. * gravity Vector3
  10179. */
  10180. gravity: {
  10181. x: number;
  10182. y: number;
  10183. z: number;
  10184. };
  10185. /**
  10186. * direction1 Vector3
  10187. */
  10188. direction1?: {
  10189. x: number;
  10190. y: number;
  10191. z: number;
  10192. };
  10193. /**
  10194. * direction2 Vector3
  10195. */
  10196. direction2?: {
  10197. x: number;
  10198. y: number;
  10199. z: number;
  10200. };
  10201. /**
  10202. * Minimum Angular Speed
  10203. */
  10204. minAngularSpeed: number;
  10205. /**
  10206. * Maximum Angular Speed
  10207. */
  10208. maxAngularSpeed: number;
  10209. /**
  10210. * Minimum Emit Power
  10211. */
  10212. minEmitPower: number;
  10213. /**
  10214. * Maximum Emit Power
  10215. */
  10216. maxEmitPower: number;
  10217. /**
  10218. * Update Speed
  10219. */
  10220. updateSpeed: number;
  10221. /**
  10222. * Radius
  10223. */
  10224. radius?: number;
  10225. /**
  10226. * Angle
  10227. */
  10228. angle?: number;
  10229. }
  10230. /**
  10231. * This class is made for on one-liner static method to help creating particle systems.
  10232. */
  10233. class ParticleHelper {
  10234. /**
  10235. * Base Assets URL.
  10236. */
  10237. private static _baseAssetsUrl;
  10238. private static _scene;
  10239. private static _emitter;
  10240. /**
  10241. * This is the main static method (one-liner) of this helper to create different particle systems.
  10242. * @param type This string represents the type to the particle system to create
  10243. * @param emitter The object where the particle system will start to emit from.
  10244. * @param scene The scene where the particle system should live.
  10245. * @param gpu If the system will use gpu.
  10246. * @returns the ParticleSystem created.
  10247. */
  10248. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  10249. private static _createSystem(data);
  10250. }
  10251. }
  10252. declare module BABYLON {
  10253. /**
  10254. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10255. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10256. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10257. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10258. */
  10259. class VideoDome extends Node {
  10260. /**
  10261. * The video texture being displayed on the sphere
  10262. */
  10263. protected _videoTexture: VideoTexture;
  10264. /**
  10265. * The skybox material
  10266. */
  10267. protected _material: BackgroundMaterial;
  10268. /**
  10269. * The surface used for the skybox
  10270. */
  10271. protected _mesh: Mesh;
  10272. /**
  10273. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10274. * Also see the options.resolution property.
  10275. */
  10276. fovMultiplier: number;
  10277. /**
  10278. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10279. * @param name Element's name, child elements will append suffixes for their own names.
  10280. * @param urlsOrVideo
  10281. * @param options An object containing optional or exposed sub element properties:
  10282. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  10283. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  10284. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  10285. * @param options **loop=true** Automatically loop video on end.
  10286. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  10287. */
  10288. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10289. resolution?: number;
  10290. clickToPlay?: boolean;
  10291. autoPlay?: boolean;
  10292. loop?: boolean;
  10293. size?: number;
  10294. }, scene: Scene);
  10295. /**
  10296. * Releases resources associated with this node.
  10297. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10298. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10299. */
  10300. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10301. }
  10302. }
  10303. declare module BABYLON {
  10304. /**
  10305. * Effect layer options. This helps customizing the behaviour
  10306. * of the effect layer.
  10307. */
  10308. interface IEffectLayerOptions {
  10309. /**
  10310. * Multiplication factor apply to the canvas size to compute the render target size
  10311. * used to generated the objects (the smaller the faster).
  10312. */
  10313. mainTextureRatio: number;
  10314. /**
  10315. * Enforces a fixed size texture to ensure effect stability across devices.
  10316. */
  10317. mainTextureFixedSize?: number;
  10318. /**
  10319. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10320. */
  10321. alphaBlendingMode: number;
  10322. /**
  10323. * The camera attached to the layer.
  10324. */
  10325. camera: Nullable<Camera>;
  10326. }
  10327. /**
  10328. * The effect layer Helps adding post process effect blended with the main pass.
  10329. *
  10330. * This can be for instance use to generate glow or higlight effects on the scene.
  10331. *
  10332. * The effect layer class can not be used directly and is intented to inherited from to be
  10333. * customized per effects.
  10334. */
  10335. abstract class EffectLayer {
  10336. private _vertexBuffers;
  10337. private _indexBuffer;
  10338. private _cachedDefines;
  10339. private _effectLayerMapGenerationEffect;
  10340. private _effectLayerOptions;
  10341. private _mergeEffect;
  10342. protected _scene: Scene;
  10343. protected _engine: Engine;
  10344. protected _maxSize: number;
  10345. protected _mainTextureDesiredSize: ISize;
  10346. protected _mainTexture: RenderTargetTexture;
  10347. protected _shouldRender: boolean;
  10348. protected _postProcesses: PostProcess[];
  10349. protected _textures: BaseTexture[];
  10350. protected _emissiveTextureAndColor: {
  10351. texture: Nullable<BaseTexture>;
  10352. color: Color4;
  10353. };
  10354. /**
  10355. * The name of the layer
  10356. */
  10357. name: string;
  10358. /**
  10359. * The clear color of the texture used to generate the glow map.
  10360. */
  10361. neutralColor: Color4;
  10362. /**
  10363. * Specifies wether the highlight layer is enabled or not.
  10364. */
  10365. isEnabled: boolean;
  10366. /**
  10367. * Gets the camera attached to the layer.
  10368. */
  10369. readonly camera: Nullable<Camera>;
  10370. /**
  10371. * An event triggered when the effect layer has been disposed.
  10372. */
  10373. onDisposeObservable: Observable<EffectLayer>;
  10374. /**
  10375. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10376. */
  10377. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10378. /**
  10379. * An event triggered when the generated texture is being merged in the scene.
  10380. */
  10381. onBeforeComposeObservable: Observable<EffectLayer>;
  10382. /**
  10383. * An event triggered when the generated texture has been merged in the scene.
  10384. */
  10385. onAfterComposeObservable: Observable<EffectLayer>;
  10386. /**
  10387. * An event triggered when the efffect layer changes its size.
  10388. */
  10389. onSizeChangedObservable: Observable<EffectLayer>;
  10390. /**
  10391. * Instantiates a new effect Layer and references it in the scene.
  10392. * @param name The name of the layer
  10393. * @param scene The scene to use the layer in
  10394. */
  10395. constructor(
  10396. /** The Friendly of the effect in the scene */
  10397. name: string, scene: Scene);
  10398. /**
  10399. * Get the effect name of the layer.
  10400. * @return The effect name
  10401. */
  10402. abstract getEffectName(): string;
  10403. /**
  10404. * Checks for the readiness of the element composing the layer.
  10405. * @param subMesh the mesh to check for
  10406. * @param useInstances specify wether or not to use instances to render the mesh
  10407. * @return true if ready otherwise, false
  10408. */
  10409. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10410. /**
  10411. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10412. * @returns true if the effect requires stencil during the main canvas render pass.
  10413. */
  10414. abstract needStencil(): boolean;
  10415. /**
  10416. * Create the merge effect. This is the shader use to blit the information back
  10417. * to the main canvas at the end of the scene rendering.
  10418. * @returns The effect containing the shader used to merge the effect on the main canvas
  10419. */
  10420. protected abstract _createMergeEffect(): Effect;
  10421. /**
  10422. * Creates the render target textures and post processes used in the effect layer.
  10423. */
  10424. protected abstract _createTextureAndPostProcesses(): void;
  10425. /**
  10426. * Implementation specific of rendering the generating effect on the main canvas.
  10427. * @param effect The effect used to render through
  10428. */
  10429. protected abstract _internalRender(effect: Effect): void;
  10430. /**
  10431. * Sets the required values for both the emissive texture and and the main color.
  10432. */
  10433. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10434. /**
  10435. * Free any resources and references associated to a mesh.
  10436. * Internal use
  10437. * @param mesh The mesh to free.
  10438. */
  10439. abstract _disposeMesh(mesh: Mesh): void;
  10440. /**
  10441. * Serializes this layer (Glow or Highlight for example)
  10442. * @returns a serialized layer object
  10443. */
  10444. abstract serialize?(): any;
  10445. /**
  10446. * Initializes the effect layer with the required options.
  10447. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10448. */
  10449. protected _init(options: Partial<IEffectLayerOptions>): void;
  10450. /**
  10451. * Generates the index buffer of the full screen quad blending to the main canvas.
  10452. */
  10453. private _generateIndexBuffer();
  10454. /**
  10455. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10456. */
  10457. private _genrateVertexBuffer();
  10458. /**
  10459. * Sets the main texture desired size which is the closest power of two
  10460. * of the engine canvas size.
  10461. */
  10462. private _setMainTextureSize();
  10463. /**
  10464. * Creates the main texture for the effect layer.
  10465. */
  10466. protected _createMainTexture(): void;
  10467. /**
  10468. * Checks for the readiness of the element composing the layer.
  10469. * @param subMesh the mesh to check for
  10470. * @param useInstances specify wether or not to use instances to render the mesh
  10471. * @param emissiveTexture the associated emissive texture used to generate the glow
  10472. * @return true if ready otherwise, false
  10473. */
  10474. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10475. /**
  10476. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10477. */
  10478. render(): void;
  10479. /**
  10480. * Determine if a given mesh will be used in the current effect.
  10481. * @param mesh mesh to test
  10482. * @returns true if the mesh will be used
  10483. */
  10484. hasMesh(mesh: AbstractMesh): boolean;
  10485. /**
  10486. * Returns true if the layer contains information to display, otherwise false.
  10487. * @returns true if the glow layer should be rendered
  10488. */
  10489. shouldRender(): boolean;
  10490. /**
  10491. * Returns true if the mesh should render, otherwise false.
  10492. * @param mesh The mesh to render
  10493. * @returns true if it should render otherwise false
  10494. */
  10495. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10496. /**
  10497. * Returns true if the mesh should render, otherwise false.
  10498. * @param mesh The mesh to render
  10499. * @returns true if it should render otherwise false
  10500. */
  10501. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10502. /**
  10503. * Renders the submesh passed in parameter to the generation map.
  10504. */
  10505. protected _renderSubMesh(subMesh: SubMesh): void;
  10506. /**
  10507. * Rebuild the required buffers.
  10508. * @hidden Internal use only.
  10509. */
  10510. _rebuild(): void;
  10511. /**
  10512. * Dispose only the render target textures and post process.
  10513. */
  10514. private _disposeTextureAndPostProcesses();
  10515. /**
  10516. * Dispose the highlight layer and free resources.
  10517. */
  10518. dispose(): void;
  10519. /**
  10520. * Gets the class name of the effect layer
  10521. * @returns the string with the class name of the effect layer
  10522. */
  10523. getClassName(): string;
  10524. /**
  10525. * Creates an effect layer from parsed effect layer data
  10526. * @param parsedEffectLayer defines effect layer data
  10527. * @param scene defines the current scene
  10528. * @param rootUrl defines the root URL containing the effect layer information
  10529. * @returns a parsed effect Layer
  10530. */
  10531. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10532. }
  10533. }
  10534. declare module BABYLON {
  10535. /**
  10536. * Glow layer options. This helps customizing the behaviour
  10537. * of the glow layer.
  10538. */
  10539. interface IGlowLayerOptions {
  10540. /**
  10541. * Multiplication factor apply to the canvas size to compute the render target size
  10542. * used to generated the glowing objects (the smaller the faster).
  10543. */
  10544. mainTextureRatio: number;
  10545. /**
  10546. * Enforces a fixed size texture to ensure resize independant blur.
  10547. */
  10548. mainTextureFixedSize?: number;
  10549. /**
  10550. * How big is the kernel of the blur texture.
  10551. */
  10552. blurKernelSize: number;
  10553. /**
  10554. * The camera attached to the layer.
  10555. */
  10556. camera: Nullable<Camera>;
  10557. /**
  10558. * Enable MSAA by chosing the number of samples.
  10559. */
  10560. mainTextureSamples?: number;
  10561. }
  10562. /**
  10563. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10564. *
  10565. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10566. * glowy meshes to your scene.
  10567. *
  10568. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10569. */
  10570. class GlowLayer extends EffectLayer {
  10571. /**
  10572. * Effect Name of the layer.
  10573. */
  10574. static readonly EffectName: string;
  10575. /**
  10576. * The default blur kernel size used for the glow.
  10577. */
  10578. static DefaultBlurKernelSize: number;
  10579. /**
  10580. * The default texture size ratio used for the glow.
  10581. */
  10582. static DefaultTextureRatio: number;
  10583. /**
  10584. * Gets the kernel size of the blur.
  10585. */
  10586. /**
  10587. * Sets the kernel size of the blur.
  10588. */
  10589. blurKernelSize: number;
  10590. /**
  10591. * Gets the glow intensity.
  10592. */
  10593. /**
  10594. * Sets the glow intensity.
  10595. */
  10596. intensity: number;
  10597. private _options;
  10598. private _intensity;
  10599. private _horizontalBlurPostprocess1;
  10600. private _verticalBlurPostprocess1;
  10601. private _horizontalBlurPostprocess2;
  10602. private _verticalBlurPostprocess2;
  10603. private _blurTexture1;
  10604. private _blurTexture2;
  10605. private _postProcesses1;
  10606. private _postProcesses2;
  10607. private _includedOnlyMeshes;
  10608. private _excludedMeshes;
  10609. /**
  10610. * Callback used to let the user override the color selection on a per mesh basis
  10611. */
  10612. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10613. /**
  10614. * Callback used to let the user override the texture selection on a per mesh basis
  10615. */
  10616. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10617. /**
  10618. * Instantiates a new glow Layer and references it to the scene.
  10619. * @param name The name of the layer
  10620. * @param scene The scene to use the layer in
  10621. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10622. */
  10623. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10624. /**
  10625. * Get the effect name of the layer.
  10626. * @return The effect name
  10627. */
  10628. getEffectName(): string;
  10629. /**
  10630. * Create the merge effect. This is the shader use to blit the information back
  10631. * to the main canvas at the end of the scene rendering.
  10632. */
  10633. protected _createMergeEffect(): Effect;
  10634. /**
  10635. * Creates the render target textures and post processes used in the glow layer.
  10636. */
  10637. protected _createTextureAndPostProcesses(): void;
  10638. /**
  10639. * Checks for the readiness of the element composing the layer.
  10640. * @param subMesh the mesh to check for
  10641. * @param useInstances specify wether or not to use instances to render the mesh
  10642. * @param emissiveTexture the associated emissive texture used to generate the glow
  10643. * @return true if ready otherwise, false
  10644. */
  10645. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10646. /**
  10647. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10648. */
  10649. needStencil(): boolean;
  10650. /**
  10651. * Implementation specific of rendering the generating effect on the main canvas.
  10652. * @param effect The effect used to render through
  10653. */
  10654. protected _internalRender(effect: Effect): void;
  10655. /**
  10656. * Sets the required values for both the emissive texture and and the main color.
  10657. */
  10658. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10659. /**
  10660. * Returns true if the mesh should render, otherwise false.
  10661. * @param mesh The mesh to render
  10662. * @returns true if it should render otherwise false
  10663. */
  10664. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10665. /**
  10666. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10667. * @param mesh The mesh to exclude from the glow layer
  10668. */
  10669. addExcludedMesh(mesh: Mesh): void;
  10670. /**
  10671. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10672. * @param mesh The mesh to remove
  10673. */
  10674. removeExcludedMesh(mesh: Mesh): void;
  10675. /**
  10676. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10677. * @param mesh The mesh to include in the glow layer
  10678. */
  10679. addIncludedOnlyMesh(mesh: Mesh): void;
  10680. /**
  10681. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10682. * @param mesh The mesh to remove
  10683. */
  10684. removeIncludedOnlyMesh(mesh: Mesh): void;
  10685. /**
  10686. * Determine if a given mesh will be used in the glow layer
  10687. * @param mesh The mesh to test
  10688. * @returns true if the mesh will be highlighted by the current glow layer
  10689. */
  10690. hasMesh(mesh: AbstractMesh): boolean;
  10691. /**
  10692. * Free any resources and references associated to a mesh.
  10693. * Internal use
  10694. * @param mesh The mesh to free.
  10695. */
  10696. _disposeMesh(mesh: Mesh): void;
  10697. /**
  10698. * Gets the class name of the effect layer
  10699. * @returns the string with the class name of the effect layer
  10700. */
  10701. getClassName(): string;
  10702. /**
  10703. * Serializes this glow layer
  10704. * @returns a serialized glow layer object
  10705. */
  10706. serialize(): any;
  10707. /**
  10708. * Creates a Glow Layer from parsed glow layer data
  10709. * @param parsedGlowLayer defines glow layer data
  10710. * @param scene defines the current scene
  10711. * @param rootUrl defines the root URL containing the glow layer information
  10712. * @returns a parsed Glow Layer
  10713. */
  10714. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10715. }
  10716. }
  10717. declare module BABYLON {
  10718. /**
  10719. * Highlight layer options. This helps customizing the behaviour
  10720. * of the highlight layer.
  10721. */
  10722. interface IHighlightLayerOptions {
  10723. /**
  10724. * Multiplication factor apply to the canvas size to compute the render target size
  10725. * used to generated the glowing objects (the smaller the faster).
  10726. */
  10727. mainTextureRatio: number;
  10728. /**
  10729. * Enforces a fixed size texture to ensure resize independant blur.
  10730. */
  10731. mainTextureFixedSize?: number;
  10732. /**
  10733. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10734. * of the picture to blur (the smaller the faster).
  10735. */
  10736. blurTextureSizeRatio: number;
  10737. /**
  10738. * How big in texel of the blur texture is the vertical blur.
  10739. */
  10740. blurVerticalSize: number;
  10741. /**
  10742. * How big in texel of the blur texture is the horizontal blur.
  10743. */
  10744. blurHorizontalSize: number;
  10745. /**
  10746. * Alpha blending mode used to apply the blur. Default is combine.
  10747. */
  10748. alphaBlendingMode: number;
  10749. /**
  10750. * The camera attached to the layer.
  10751. */
  10752. camera: Nullable<Camera>;
  10753. /**
  10754. * Should we display highlight as a solid stroke?
  10755. */
  10756. isStroke?: boolean;
  10757. }
  10758. /**
  10759. * The highlight layer Helps adding a glow effect around a mesh.
  10760. *
  10761. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10762. * glowy meshes to your scene.
  10763. *
  10764. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10765. */
  10766. class HighlightLayer extends EffectLayer {
  10767. name: string;
  10768. /**
  10769. * Effect Name of the highlight layer.
  10770. */
  10771. static readonly EffectName: string;
  10772. /**
  10773. * The neutral color used during the preparation of the glow effect.
  10774. * This is black by default as the blend operation is a blend operation.
  10775. */
  10776. static NeutralColor: Color4;
  10777. /**
  10778. * Stencil value used for glowing meshes.
  10779. */
  10780. static GlowingMeshStencilReference: number;
  10781. /**
  10782. * Stencil value used for the other meshes in the scene.
  10783. */
  10784. static NormalMeshStencilReference: number;
  10785. /**
  10786. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10787. */
  10788. innerGlow: boolean;
  10789. /**
  10790. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10791. */
  10792. outerGlow: boolean;
  10793. /**
  10794. * Gets the horizontal size of the blur.
  10795. */
  10796. /**
  10797. * Specifies the horizontal size of the blur.
  10798. */
  10799. blurHorizontalSize: number;
  10800. /**
  10801. * Gets the vertical size of the blur.
  10802. */
  10803. /**
  10804. * Specifies the vertical size of the blur.
  10805. */
  10806. blurVerticalSize: number;
  10807. /**
  10808. * An event triggered when the highlight layer is being blurred.
  10809. */
  10810. onBeforeBlurObservable: Observable<HighlightLayer>;
  10811. /**
  10812. * An event triggered when the highlight layer has been blurred.
  10813. */
  10814. onAfterBlurObservable: Observable<HighlightLayer>;
  10815. private _instanceGlowingMeshStencilReference;
  10816. private _options;
  10817. private _downSamplePostprocess;
  10818. private _horizontalBlurPostprocess;
  10819. private _verticalBlurPostprocess;
  10820. private _blurTexture;
  10821. private _meshes;
  10822. private _excludedMeshes;
  10823. /**
  10824. * Instantiates a new highlight Layer and references it to the scene..
  10825. * @param name The name of the layer
  10826. * @param scene The scene to use the layer in
  10827. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10828. */
  10829. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10830. /**
  10831. * Get the effect name of the layer.
  10832. * @return The effect name
  10833. */
  10834. getEffectName(): string;
  10835. /**
  10836. * Create the merge effect. This is the shader use to blit the information back
  10837. * to the main canvas at the end of the scene rendering.
  10838. */
  10839. protected _createMergeEffect(): Effect;
  10840. /**
  10841. * Creates the render target textures and post processes used in the highlight layer.
  10842. */
  10843. protected _createTextureAndPostProcesses(): void;
  10844. /**
  10845. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10846. */
  10847. needStencil(): boolean;
  10848. /**
  10849. * Checks for the readiness of the element composing the layer.
  10850. * @param subMesh the mesh to check for
  10851. * @param useInstances specify wether or not to use instances to render the mesh
  10852. * @param emissiveTexture the associated emissive texture used to generate the glow
  10853. * @return true if ready otherwise, false
  10854. */
  10855. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10856. /**
  10857. * Implementation specific of rendering the generating effect on the main canvas.
  10858. * @param effect The effect used to render through
  10859. */
  10860. protected _internalRender(effect: Effect): void;
  10861. /**
  10862. * Returns true if the layer contains information to display, otherwise false.
  10863. */
  10864. shouldRender(): boolean;
  10865. /**
  10866. * Returns true if the mesh should render, otherwise false.
  10867. * @param mesh The mesh to render
  10868. * @returns true if it should render otherwise false
  10869. */
  10870. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10871. /**
  10872. * Sets the required values for both the emissive texture and and the main color.
  10873. */
  10874. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10875. /**
  10876. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10877. * @param mesh The mesh to exclude from the highlight layer
  10878. */
  10879. addExcludedMesh(mesh: Mesh): void;
  10880. /**
  10881. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10882. * @param mesh The mesh to highlight
  10883. */
  10884. removeExcludedMesh(mesh: Mesh): void;
  10885. /**
  10886. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10887. * @param mesh mesh to test
  10888. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10889. */
  10890. hasMesh(mesh: AbstractMesh): boolean;
  10891. /**
  10892. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10893. * @param mesh The mesh to highlight
  10894. * @param color The color of the highlight
  10895. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10896. */
  10897. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10898. /**
  10899. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10900. * @param mesh The mesh to highlight
  10901. */
  10902. removeMesh(mesh: Mesh): void;
  10903. /**
  10904. * Force the stencil to the normal expected value for none glowing parts
  10905. */
  10906. private _defaultStencilReference(mesh);
  10907. /**
  10908. * Free any resources and references associated to a mesh.
  10909. * Internal use
  10910. * @param mesh The mesh to free.
  10911. */
  10912. _disposeMesh(mesh: Mesh): void;
  10913. /**
  10914. * Dispose the highlight layer and free resources.
  10915. */
  10916. dispose(): void;
  10917. /**
  10918. * Gets the class name of the effect layer
  10919. * @returns the string with the class name of the effect layer
  10920. */
  10921. getClassName(): string;
  10922. /**
  10923. * Serializes this Highlight layer
  10924. * @returns a serialized Highlight layer object
  10925. */
  10926. serialize(): any;
  10927. /**
  10928. * Creates a Highlight layer from parsed Highlight layer data
  10929. * @param parsedHightlightLayer defines the Highlight layer data
  10930. * @param scene defines the current scene
  10931. * @param rootUrl defines the root URL containing the Highlight layer information
  10932. * @returns a parsed Highlight layer
  10933. */
  10934. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10935. }
  10936. }
  10937. declare module BABYLON {
  10938. class Layer {
  10939. name: string;
  10940. texture: Nullable<Texture>;
  10941. isBackground: boolean;
  10942. color: Color4;
  10943. scale: Vector2;
  10944. offset: Vector2;
  10945. alphaBlendingMode: number;
  10946. alphaTest: boolean;
  10947. layerMask: number;
  10948. private _scene;
  10949. private _vertexBuffers;
  10950. private _indexBuffer;
  10951. private _effect;
  10952. private _alphaTestEffect;
  10953. /**
  10954. * An event triggered when the layer is disposed.
  10955. */
  10956. onDisposeObservable: Observable<Layer>;
  10957. private _onDisposeObserver;
  10958. onDispose: () => void;
  10959. /**
  10960. * An event triggered before rendering the scene
  10961. */
  10962. onBeforeRenderObservable: Observable<Layer>;
  10963. private _onBeforeRenderObserver;
  10964. onBeforeRender: () => void;
  10965. /**
  10966. * An event triggered after rendering the scene
  10967. */
  10968. onAfterRenderObservable: Observable<Layer>;
  10969. private _onAfterRenderObserver;
  10970. onAfterRender: () => void;
  10971. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10972. private _createIndexBuffer();
  10973. _rebuild(): void;
  10974. render(): void;
  10975. dispose(): void;
  10976. }
  10977. }
  10978. declare module BABYLON {
  10979. /**
  10980. * A directional light is defined by a direction (what a surprise!).
  10981. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10982. * 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.
  10983. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10984. */
  10985. class DirectionalLight extends ShadowLight {
  10986. private _shadowFrustumSize;
  10987. /**
  10988. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10989. */
  10990. /**
  10991. * Specifies a fix frustum size for the shadow generation.
  10992. */
  10993. shadowFrustumSize: number;
  10994. private _shadowOrthoScale;
  10995. /**
  10996. * Gets the shadow projection scale against the optimal computed one.
  10997. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10998. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10999. */
  11000. /**
  11001. * Sets the shadow projection scale against the optimal computed one.
  11002. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11003. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11004. */
  11005. shadowOrthoScale: number;
  11006. /**
  11007. * Automatically compute the projection matrix to best fit (including all the casters)
  11008. * on each frame.
  11009. */
  11010. autoUpdateExtends: boolean;
  11011. private _orthoLeft;
  11012. private _orthoRight;
  11013. private _orthoTop;
  11014. private _orthoBottom;
  11015. /**
  11016. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11017. * The directional light is emitted from everywhere in the given direction.
  11018. * It can cast shawdows.
  11019. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11020. * @param name The friendly name of the light
  11021. * @param direction The direction of the light
  11022. * @param scene The scene the light belongs to
  11023. */
  11024. constructor(name: string, direction: Vector3, scene: Scene);
  11025. /**
  11026. * Returns the string "DirectionalLight".
  11027. * @return The class name
  11028. */
  11029. getClassName(): string;
  11030. /**
  11031. * Returns the integer 1.
  11032. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11033. */
  11034. getTypeID(): number;
  11035. /**
  11036. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11037. * Returns the DirectionalLight Shadow projection matrix.
  11038. */
  11039. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11040. /**
  11041. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11042. * Returns the DirectionalLight Shadow projection matrix.
  11043. */
  11044. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11045. /**
  11046. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11047. * Returns the DirectionalLight Shadow projection matrix.
  11048. */
  11049. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11050. protected _buildUniformLayout(): void;
  11051. /**
  11052. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11053. * @param effect The effect to update
  11054. * @param lightIndex The index of the light in the effect to update
  11055. * @returns The directional light
  11056. */
  11057. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11058. /**
  11059. * Gets the minZ used for shadow according to both the scene and the light.
  11060. *
  11061. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11062. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11063. * @param activeCamera The camera we are returning the min for
  11064. * @returns the depth min z
  11065. */
  11066. getDepthMinZ(activeCamera: Camera): number;
  11067. /**
  11068. * Gets the maxZ used for shadow according to both the scene and the light.
  11069. *
  11070. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11071. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11072. * @param activeCamera The camera we are returning the max for
  11073. * @returns the depth max z
  11074. */
  11075. getDepthMaxZ(activeCamera: Camera): number;
  11076. }
  11077. }
  11078. declare module BABYLON {
  11079. /**
  11080. * The HemisphericLight simulates the ambient environment light,
  11081. * so the passed direction is the light reflection direction, not the incoming direction.
  11082. */
  11083. class HemisphericLight extends Light {
  11084. /**
  11085. * The groundColor is the light in the opposite direction to the one specified during creation.
  11086. * 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.
  11087. */
  11088. groundColor: Color3;
  11089. /**
  11090. * The light reflection direction, not the incoming direction.
  11091. */
  11092. direction: Vector3;
  11093. private _worldMatrix;
  11094. /**
  11095. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11096. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11097. * The HemisphericLight can't cast shadows.
  11098. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11099. * @param name The friendly name of the light
  11100. * @param direction The direction of the light reflection
  11101. * @param scene The scene the light belongs to
  11102. */
  11103. constructor(name: string, direction: Vector3, scene: Scene);
  11104. protected _buildUniformLayout(): void;
  11105. /**
  11106. * Returns the string "HemisphericLight".
  11107. * @return The class name
  11108. */
  11109. getClassName(): string;
  11110. /**
  11111. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11112. * Returns the updated direction.
  11113. * @param target The target the direction should point to
  11114. * @return The computed direction
  11115. */
  11116. setDirectionToTarget(target: Vector3): Vector3;
  11117. /**
  11118. * Returns the shadow generator associated to the light.
  11119. * @returns Always null for hemispheric lights because it does not support shadows.
  11120. */
  11121. getShadowGenerator(): Nullable<ShadowGenerator>;
  11122. /**
  11123. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11124. * @param effect The effect to update
  11125. * @param lightIndex The index of the light in the effect to update
  11126. * @returns The hemispheric light
  11127. */
  11128. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11129. /**
  11130. * @hidden internal use only.
  11131. */
  11132. _getWorldMatrix(): Matrix;
  11133. /**
  11134. * Returns the integer 3.
  11135. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11136. */
  11137. getTypeID(): number;
  11138. }
  11139. }
  11140. declare module BABYLON {
  11141. /**
  11142. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11143. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11144. * 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.
  11145. */
  11146. abstract class Light extends Node {
  11147. private static _LIGHTMAP_DEFAULT;
  11148. private static _LIGHTMAP_SPECULAR;
  11149. private static _LIGHTMAP_SHADOWSONLY;
  11150. /**
  11151. * If every light affecting the material is in this lightmapMode,
  11152. * material.lightmapTexture adds or multiplies
  11153. * (depends on material.useLightmapAsShadowmap)
  11154. * after every other light calculations.
  11155. */
  11156. static readonly LIGHTMAP_DEFAULT: number;
  11157. /**
  11158. * material.lightmapTexture as only diffuse lighting from this light
  11159. * adds only specular lighting from this light
  11160. * adds dynamic shadows
  11161. */
  11162. static readonly LIGHTMAP_SPECULAR: number;
  11163. /**
  11164. * material.lightmapTexture as only lighting
  11165. * no light calculation from this light
  11166. * only adds dynamic shadows from this light
  11167. */
  11168. static readonly LIGHTMAP_SHADOWSONLY: number;
  11169. private static _INTENSITYMODE_AUTOMATIC;
  11170. private static _INTENSITYMODE_LUMINOUSPOWER;
  11171. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11172. private static _INTENSITYMODE_ILLUMINANCE;
  11173. private static _INTENSITYMODE_LUMINANCE;
  11174. /**
  11175. * Each light type uses the default quantity according to its type:
  11176. * point/spot lights use luminous intensity
  11177. * directional lights use illuminance
  11178. */
  11179. static readonly INTENSITYMODE_AUTOMATIC: number;
  11180. /**
  11181. * lumen (lm)
  11182. */
  11183. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11184. /**
  11185. * candela (lm/sr)
  11186. */
  11187. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11188. /**
  11189. * lux (lm/m^2)
  11190. */
  11191. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11192. /**
  11193. * nit (cd/m^2)
  11194. */
  11195. static readonly INTENSITYMODE_LUMINANCE: number;
  11196. private static _LIGHTTYPEID_POINTLIGHT;
  11197. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11198. private static _LIGHTTYPEID_SPOTLIGHT;
  11199. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11200. /**
  11201. * Light type const id of the point light.
  11202. */
  11203. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11204. /**
  11205. * Light type const id of the directional light.
  11206. */
  11207. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11208. /**
  11209. * Light type const id of the spot light.
  11210. */
  11211. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11212. /**
  11213. * Light type const id of the hemispheric light.
  11214. */
  11215. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11216. /**
  11217. * Diffuse gives the basic color to an object.
  11218. */
  11219. diffuse: Color3;
  11220. /**
  11221. * Specular produces a highlight color on an object.
  11222. * Note: This is note affecting PBR materials.
  11223. */
  11224. specular: Color3;
  11225. /**
  11226. * Strength of the light.
  11227. * Note: By default it is define in the framework own unit.
  11228. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11229. */
  11230. intensity: number;
  11231. /**
  11232. * Defines how far from the source the light is impacting in scene units.
  11233. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11234. */
  11235. range: number;
  11236. /**
  11237. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11238. * of light.
  11239. */
  11240. private _photometricScale;
  11241. private _intensityMode;
  11242. /**
  11243. * Gets the photometric scale used to interpret the intensity.
  11244. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11245. */
  11246. /**
  11247. * Sets the photometric scale used to interpret the intensity.
  11248. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11249. */
  11250. intensityMode: number;
  11251. private _radius;
  11252. /**
  11253. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11254. */
  11255. /**
  11256. * sets the light radius used by PBR Materials to simulate soft area lights.
  11257. */
  11258. radius: number;
  11259. private _renderPriority;
  11260. /**
  11261. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11262. * exceeding the number allowed of the materials.
  11263. */
  11264. renderPriority: number;
  11265. private _shadowEnabled;
  11266. /**
  11267. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11268. * the current shadow generator.
  11269. */
  11270. /**
  11271. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11272. * the current shadow generator.
  11273. */
  11274. shadowEnabled: boolean;
  11275. private _includedOnlyMeshes;
  11276. /**
  11277. * Gets the only meshes impacted by this light.
  11278. */
  11279. /**
  11280. * Sets the only meshes impacted by this light.
  11281. */
  11282. includedOnlyMeshes: AbstractMesh[];
  11283. private _excludedMeshes;
  11284. /**
  11285. * Gets the meshes not impacted by this light.
  11286. */
  11287. /**
  11288. * Sets the meshes not impacted by this light.
  11289. */
  11290. excludedMeshes: AbstractMesh[];
  11291. private _excludeWithLayerMask;
  11292. /**
  11293. * Gets the layer id use to find what meshes are not impacted by the light.
  11294. * Inactive if 0
  11295. */
  11296. /**
  11297. * Sets the layer id use to find what meshes are not impacted by the light.
  11298. * Inactive if 0
  11299. */
  11300. excludeWithLayerMask: number;
  11301. private _includeOnlyWithLayerMask;
  11302. /**
  11303. * Gets the layer id use to find what meshes are impacted by the light.
  11304. * Inactive if 0
  11305. */
  11306. /**
  11307. * Sets the layer id use to find what meshes are impacted by the light.
  11308. * Inactive if 0
  11309. */
  11310. includeOnlyWithLayerMask: number;
  11311. private _lightmapMode;
  11312. /**
  11313. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11314. */
  11315. /**
  11316. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11317. */
  11318. lightmapMode: number;
  11319. private _parentedWorldMatrix;
  11320. /**
  11321. * Shadow generator associted to the light.
  11322. * Internal use only.
  11323. */
  11324. _shadowGenerator: Nullable<IShadowGenerator>;
  11325. /**
  11326. * @hidden Internal use only.
  11327. */
  11328. _excludedMeshesIds: string[];
  11329. /**
  11330. * @hidden Internal use only.
  11331. */
  11332. _includedOnlyMeshesIds: string[];
  11333. /**
  11334. * The current light unifom buffer.
  11335. * @hidden Internal use only.
  11336. */
  11337. _uniformBuffer: UniformBuffer;
  11338. /**
  11339. * Creates a Light object in the scene.
  11340. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11341. * @param name The firendly name of the light
  11342. * @param scene The scene the light belongs too
  11343. */
  11344. constructor(name: string, scene: Scene);
  11345. protected abstract _buildUniformLayout(): void;
  11346. /**
  11347. * Sets the passed Effect "effect" with the Light information.
  11348. * @param effect The effect to update
  11349. * @param lightIndex The index of the light in the effect to update
  11350. * @returns The light
  11351. */
  11352. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11353. /**
  11354. * @hidden internal use only.
  11355. */
  11356. abstract _getWorldMatrix(): Matrix;
  11357. /**
  11358. * Returns the string "Light".
  11359. * @returns the class name
  11360. */
  11361. getClassName(): string;
  11362. /**
  11363. * Converts the light information to a readable string for debug purpose.
  11364. * @param fullDetails Supports for multiple levels of logging within scene loading
  11365. * @returns the human readable light info
  11366. */
  11367. toString(fullDetails?: boolean): string;
  11368. /**
  11369. * Set the enabled state of this node.
  11370. * @param value - the new enabled state
  11371. */
  11372. setEnabled(value: boolean): void;
  11373. /**
  11374. * Returns the Light associated shadow generator if any.
  11375. * @return the associated shadow generator.
  11376. */
  11377. getShadowGenerator(): Nullable<IShadowGenerator>;
  11378. /**
  11379. * Returns a Vector3, the absolute light position in the World.
  11380. * @returns the world space position of the light
  11381. */
  11382. getAbsolutePosition(): Vector3;
  11383. /**
  11384. * Specifies if the light will affect the passed mesh.
  11385. * @param mesh The mesh to test against the light
  11386. * @return true the mesh is affected otherwise, false.
  11387. */
  11388. canAffectMesh(mesh: AbstractMesh): boolean;
  11389. /**
  11390. * Computes and Returns the light World matrix.
  11391. * @returns the world matrix
  11392. */
  11393. getWorldMatrix(): Matrix;
  11394. /**
  11395. * Sort function to order lights for rendering.
  11396. * @param a First Light object to compare to second.
  11397. * @param b Second Light object to compare first.
  11398. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11399. */
  11400. static CompareLightsPriority(a: Light, b: Light): number;
  11401. /**
  11402. * Releases resources associated with this node.
  11403. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11404. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11405. */
  11406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11407. /**
  11408. * Returns the light type ID (integer).
  11409. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11410. */
  11411. getTypeID(): number;
  11412. /**
  11413. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11414. * @returns the scaled intensity in intensity mode unit
  11415. */
  11416. getScaledIntensity(): number;
  11417. /**
  11418. * Returns a new Light object, named "name", from the current one.
  11419. * @param name The name of the cloned light
  11420. * @returns the new created light
  11421. */
  11422. clone(name: string): Nullable<Light>;
  11423. /**
  11424. * Serializes the current light into a Serialization object.
  11425. * @returns the serialized object.
  11426. */
  11427. serialize(): any;
  11428. /**
  11429. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11430. * This new light is named "name" and added to the passed scene.
  11431. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11432. * @param name The friendly name of the light
  11433. * @param scene The scene the new light will belong to
  11434. * @returns the constructor function
  11435. */
  11436. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11437. /**
  11438. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11439. * @param parsedLight The JSON representation of the light
  11440. * @param scene The scene to create the parsed light in
  11441. * @returns the created light after parsing
  11442. */
  11443. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11444. private _hookArrayForExcluded(array);
  11445. private _hookArrayForIncludedOnly(array);
  11446. private _resyncMeshes();
  11447. /**
  11448. * Forces the meshes to update their light related information in their rendering used effects
  11449. * @hidden Internal Use Only
  11450. */
  11451. _markMeshesAsLightDirty(): void;
  11452. /**
  11453. * Recomputes the cached photometric scale if needed.
  11454. */
  11455. private _computePhotometricScale();
  11456. /**
  11457. * Returns the Photometric Scale according to the light type and intensity mode.
  11458. */
  11459. private _getPhotometricScale();
  11460. /**
  11461. * Reorder the light in the scene according to their defined priority.
  11462. * @hidden Internal Use Only
  11463. */
  11464. _reorderLightsInScene(): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * A point light is a light defined by an unique point in world space.
  11470. * The light is emitted in every direction from this point.
  11471. * A good example of a point light is a standard light bulb.
  11472. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11473. */
  11474. class PointLight extends ShadowLight {
  11475. private _shadowAngle;
  11476. /**
  11477. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11478. * This specifies what angle the shadow will use to be created.
  11479. *
  11480. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11481. */
  11482. /**
  11483. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11484. * This specifies what angle the shadow will use to be created.
  11485. *
  11486. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11487. */
  11488. shadowAngle: number;
  11489. /**
  11490. * Gets the direction if it has been set.
  11491. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11492. */
  11493. /**
  11494. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11495. */
  11496. direction: Vector3;
  11497. /**
  11498. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11499. * A PointLight emits the light in every direction.
  11500. * It can cast shadows.
  11501. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11502. * ```javascript
  11503. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11504. * ```
  11505. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11506. * @param name The light friendly name
  11507. * @param position The position of the point light in the scene
  11508. * @param scene The scene the lights belongs to
  11509. */
  11510. constructor(name: string, position: Vector3, scene: Scene);
  11511. /**
  11512. * Returns the string "PointLight"
  11513. * @returns the class name
  11514. */
  11515. getClassName(): string;
  11516. /**
  11517. * Returns the integer 0.
  11518. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11519. */
  11520. getTypeID(): number;
  11521. /**
  11522. * Specifies wether or not the shadowmap should be a cube texture.
  11523. * @returns true if the shadowmap needs to be a cube texture.
  11524. */
  11525. needCube(): boolean;
  11526. /**
  11527. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11528. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11529. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11530. */
  11531. getShadowDirection(faceIndex?: number): Vector3;
  11532. /**
  11533. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11534. * - fov = PI / 2
  11535. * - aspect ratio : 1.0
  11536. * - z-near and far equal to the active camera minZ and maxZ.
  11537. * Returns the PointLight.
  11538. */
  11539. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11540. protected _buildUniformLayout(): void;
  11541. /**
  11542. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11543. * @param effect The effect to update
  11544. * @param lightIndex The index of the light in the effect to update
  11545. * @returns The point light
  11546. */
  11547. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11548. }
  11549. }
  11550. declare module BABYLON {
  11551. /**
  11552. * Interface describing all the common properties and methods a shadow light needs to implement.
  11553. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11554. * as well as binding the different shadow properties to the effects.
  11555. */
  11556. interface IShadowLight extends Light {
  11557. /**
  11558. * The light id in the scene (used in scene.findLighById for instance)
  11559. */
  11560. id: string;
  11561. /**
  11562. * The position the shdow will be casted from.
  11563. */
  11564. position: Vector3;
  11565. /**
  11566. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11567. */
  11568. direction: Vector3;
  11569. /**
  11570. * The transformed position. Position of the light in world space taking parenting in account.
  11571. */
  11572. transformedPosition: Vector3;
  11573. /**
  11574. * The transformed direction. Direction of the light in world space taking parenting in account.
  11575. */
  11576. transformedDirection: Vector3;
  11577. /**
  11578. * The friendly name of the light in the scene.
  11579. */
  11580. name: string;
  11581. /**
  11582. * Defines the shadow projection clipping minimum z value.
  11583. */
  11584. shadowMinZ: number;
  11585. /**
  11586. * Defines the shadow projection clipping maximum z value.
  11587. */
  11588. shadowMaxZ: number;
  11589. /**
  11590. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11591. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11592. */
  11593. computeTransformedInformation(): boolean;
  11594. /**
  11595. * Gets the scene the light belongs to.
  11596. * @returns The scene
  11597. */
  11598. getScene(): Scene;
  11599. /**
  11600. * Callback defining a custom Projection Matrix Builder.
  11601. * This can be used to override the default projection matrix computation.
  11602. */
  11603. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11604. /**
  11605. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11606. * @param matrix The materix to updated with the projection information
  11607. * @param viewMatrix The transform matrix of the light
  11608. * @param renderList The list of mesh to render in the map
  11609. * @returns The current light
  11610. */
  11611. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11612. /**
  11613. * Gets the current depth scale used in ESM.
  11614. * @returns The scale
  11615. */
  11616. getDepthScale(): number;
  11617. /**
  11618. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11619. * @returns true if a cube texture needs to be use
  11620. */
  11621. needCube(): boolean;
  11622. /**
  11623. * Detects if the projection matrix requires to be recomputed this frame.
  11624. * @returns true if it requires to be recomputed otherwise, false.
  11625. */
  11626. needProjectionMatrixCompute(): boolean;
  11627. /**
  11628. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11629. */
  11630. forceProjectionMatrixCompute(): void;
  11631. /**
  11632. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11633. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11634. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11635. */
  11636. getShadowDirection(faceIndex?: number): Vector3;
  11637. /**
  11638. * Gets the minZ used for shadow according to both the scene and the light.
  11639. * @param activeCamera The camera we are returning the min for
  11640. * @returns the depth min z
  11641. */
  11642. getDepthMinZ(activeCamera: Camera): number;
  11643. /**
  11644. * Gets the maxZ used for shadow according to both the scene and the light.
  11645. * @param activeCamera The camera we are returning the max for
  11646. * @returns the depth max z
  11647. */
  11648. getDepthMaxZ(activeCamera: Camera): number;
  11649. }
  11650. /**
  11651. * Base implementation IShadowLight
  11652. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11653. */
  11654. abstract class ShadowLight extends Light implements IShadowLight {
  11655. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11656. protected _position: Vector3;
  11657. protected _setPosition(value: Vector3): void;
  11658. /**
  11659. * Sets the position the shadow will be casted from. Also use as the light position for both
  11660. * point and spot lights.
  11661. */
  11662. /**
  11663. * Sets the position the shadow will be casted from. Also use as the light position for both
  11664. * point and spot lights.
  11665. */
  11666. position: Vector3;
  11667. protected _direction: Vector3;
  11668. protected _setDirection(value: Vector3): void;
  11669. /**
  11670. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11671. * Also use as the light direction on spot and directional lights.
  11672. */
  11673. /**
  11674. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11675. * Also use as the light direction on spot and directional lights.
  11676. */
  11677. direction: Vector3;
  11678. private _shadowMinZ;
  11679. /**
  11680. * Gets the shadow projection clipping minimum z value.
  11681. */
  11682. /**
  11683. * Sets the shadow projection clipping minimum z value.
  11684. */
  11685. shadowMinZ: number;
  11686. private _shadowMaxZ;
  11687. /**
  11688. * Sets the shadow projection clipping maximum z value.
  11689. */
  11690. /**
  11691. * Gets the shadow projection clipping maximum z value.
  11692. */
  11693. shadowMaxZ: number;
  11694. /**
  11695. * Callback defining a custom Projection Matrix Builder.
  11696. * This can be used to override the default projection matrix computation.
  11697. */
  11698. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11699. /**
  11700. * The transformed position. Position of the light in world space taking parenting in account.
  11701. */
  11702. transformedPosition: Vector3;
  11703. /**
  11704. * The transformed direction. Direction of the light in world space taking parenting in account.
  11705. */
  11706. transformedDirection: Vector3;
  11707. private _worldMatrix;
  11708. private _needProjectionMatrixCompute;
  11709. /**
  11710. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11711. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11712. */
  11713. computeTransformedInformation(): boolean;
  11714. /**
  11715. * Return the depth scale used for the shadow map.
  11716. * @returns the depth scale.
  11717. */
  11718. getDepthScale(): number;
  11719. /**
  11720. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11721. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11722. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11723. */
  11724. getShadowDirection(faceIndex?: number): Vector3;
  11725. /**
  11726. * Returns the ShadowLight absolute position in the World.
  11727. * @returns the position vector in world space
  11728. */
  11729. getAbsolutePosition(): Vector3;
  11730. /**
  11731. * Sets the ShadowLight direction toward the passed target.
  11732. * @param target The point tot target in local space
  11733. * @returns the updated ShadowLight direction
  11734. */
  11735. setDirectionToTarget(target: Vector3): Vector3;
  11736. /**
  11737. * Returns the light rotation in euler definition.
  11738. * @returns the x y z rotation in local space.
  11739. */
  11740. getRotation(): Vector3;
  11741. /**
  11742. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11743. * @returns true if a cube texture needs to be use
  11744. */
  11745. needCube(): boolean;
  11746. /**
  11747. * Detects if the projection matrix requires to be recomputed this frame.
  11748. * @returns true if it requires to be recomputed otherwise, false.
  11749. */
  11750. needProjectionMatrixCompute(): boolean;
  11751. /**
  11752. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11753. */
  11754. forceProjectionMatrixCompute(): void;
  11755. /**
  11756. * Get the world matrix of the sahdow lights.
  11757. * @hidden Internal Use Only
  11758. */
  11759. _getWorldMatrix(): Matrix;
  11760. /**
  11761. * Gets the minZ used for shadow according to both the scene and the light.
  11762. * @param activeCamera The camera we are returning the min for
  11763. * @returns the depth min z
  11764. */
  11765. getDepthMinZ(activeCamera: Camera): number;
  11766. /**
  11767. * Gets the maxZ used for shadow according to both the scene and the light.
  11768. * @param activeCamera The camera we are returning the max for
  11769. * @returns the depth max z
  11770. */
  11771. getDepthMaxZ(activeCamera: Camera): number;
  11772. /**
  11773. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11774. * @param matrix The materix to updated with the projection information
  11775. * @param viewMatrix The transform matrix of the light
  11776. * @param renderList The list of mesh to render in the map
  11777. * @returns The current light
  11778. */
  11779. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11780. }
  11781. }
  11782. declare module BABYLON {
  11783. /**
  11784. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11785. * These values define a cone of light starting from the position, emitting toward the direction.
  11786. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11787. * and the exponent defines the speed of the decay of the light with distance (reach).
  11788. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11789. */
  11790. class SpotLight extends ShadowLight {
  11791. private _angle;
  11792. /**
  11793. * Gets the cone angle of the spot light in Radians.
  11794. */
  11795. /**
  11796. * Sets the cone angle of the spot light in Radians.
  11797. */
  11798. angle: number;
  11799. private _shadowAngleScale;
  11800. /**
  11801. * Allows scaling the angle of the light for shadow generation only.
  11802. */
  11803. /**
  11804. * Allows scaling the angle of the light for shadow generation only.
  11805. */
  11806. shadowAngleScale: number;
  11807. /**
  11808. * The light decay speed with the distance from the emission spot.
  11809. */
  11810. exponent: number;
  11811. private _projectionTextureMatrix;
  11812. /**
  11813. * Allows reading the projecton texture
  11814. */
  11815. readonly projectionTextureMatrix: Matrix;
  11816. protected _projectionTextureLightNear: number;
  11817. /**
  11818. * Gets the near clip of the Spotlight for texture projection.
  11819. */
  11820. /**
  11821. * Sets the near clip of the Spotlight for texture projection.
  11822. */
  11823. projectionTextureLightNear: number;
  11824. protected _projectionTextureLightFar: number;
  11825. /**
  11826. * Gets the far clip of the Spotlight for texture projection.
  11827. */
  11828. /**
  11829. * Sets the far clip of the Spotlight for texture projection.
  11830. */
  11831. projectionTextureLightFar: number;
  11832. protected _projectionTextureUpDirection: Vector3;
  11833. /**
  11834. * Gets the Up vector of the Spotlight for texture projection.
  11835. */
  11836. /**
  11837. * Sets the Up vector of the Spotlight for texture projection.
  11838. */
  11839. projectionTextureUpDirection: Vector3;
  11840. private _projectionTexture;
  11841. /**
  11842. * Gets the projection texture of the light.
  11843. */
  11844. /**
  11845. * Sets the projection texture of the light.
  11846. */
  11847. projectionTexture: Nullable<BaseTexture>;
  11848. private _projectionTextureViewLightDirty;
  11849. private _projectionTextureProjectionLightDirty;
  11850. private _projectionTextureDirty;
  11851. private _projectionTextureViewTargetVector;
  11852. private _projectionTextureViewLightMatrix;
  11853. private _projectionTextureProjectionLightMatrix;
  11854. private _projectionTextureScalingMatrix;
  11855. /**
  11856. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11857. * It can cast shadows.
  11858. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11859. * @param name The light friendly name
  11860. * @param position The position of the spot light in the scene
  11861. * @param direction The direction of the light in the scene
  11862. * @param angle The cone angle of the light in Radians
  11863. * @param exponent The light decay speed with the distance from the emission spot
  11864. * @param scene The scene the lights belongs to
  11865. */
  11866. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11867. /**
  11868. * Returns the string "SpotLight".
  11869. * @returns the class name
  11870. */
  11871. getClassName(): string;
  11872. /**
  11873. * Returns the integer 2.
  11874. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11875. */
  11876. getTypeID(): number;
  11877. /**
  11878. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11879. */
  11880. protected _setDirection(value: Vector3): void;
  11881. /**
  11882. * Overrides the position setter to recompute the projection texture view light Matrix.
  11883. */
  11884. protected _setPosition(value: Vector3): void;
  11885. /**
  11886. * 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.
  11887. * Returns the SpotLight.
  11888. */
  11889. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11890. protected _computeProjectionTextureViewLightMatrix(): void;
  11891. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11892. /**
  11893. * Main function for light texture projection matrix computing.
  11894. */
  11895. protected _computeProjectionTextureMatrix(): void;
  11896. protected _buildUniformLayout(): void;
  11897. /**
  11898. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11899. * @param effect The effect to update
  11900. * @param lightIndex The index of the light in the effect to update
  11901. * @returns The spot light
  11902. */
  11903. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11904. /**
  11905. * Disposes the light and the associated resources.
  11906. */
  11907. dispose(): void;
  11908. }
  11909. }
  11910. declare module BABYLON {
  11911. class LensFlare {
  11912. size: number;
  11913. position: number;
  11914. color: Color3;
  11915. texture: Nullable<Texture>;
  11916. alphaMode: number;
  11917. private _system;
  11918. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11919. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11920. dispose(): void;
  11921. }
  11922. }
  11923. declare module BABYLON {
  11924. class LensFlareSystem {
  11925. name: string;
  11926. lensFlares: LensFlare[];
  11927. borderLimit: number;
  11928. viewportBorder: number;
  11929. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11930. layerMask: number;
  11931. id: string;
  11932. private _scene;
  11933. private _emitter;
  11934. private _vertexBuffers;
  11935. private _indexBuffer;
  11936. private _effect;
  11937. private _positionX;
  11938. private _positionY;
  11939. private _isEnabled;
  11940. constructor(name: string, emitter: any, scene: Scene);
  11941. isEnabled: boolean;
  11942. getScene(): Scene;
  11943. getEmitter(): any;
  11944. setEmitter(newEmitter: any): void;
  11945. getEmitterPosition(): Vector3;
  11946. computeEffectivePosition(globalViewport: Viewport): boolean;
  11947. _isVisible(): boolean;
  11948. render(): boolean;
  11949. dispose(): void;
  11950. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11951. serialize(): any;
  11952. }
  11953. }
  11954. declare module BABYLON {
  11955. /**
  11956. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11957. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11958. * 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;
  11959. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11960. */
  11961. class ColorCurves {
  11962. private _dirty;
  11963. private _tempColor;
  11964. private _globalCurve;
  11965. private _highlightsCurve;
  11966. private _midtonesCurve;
  11967. private _shadowsCurve;
  11968. private _positiveCurve;
  11969. private _negativeCurve;
  11970. private _globalHue;
  11971. private _globalDensity;
  11972. private _globalSaturation;
  11973. private _globalExposure;
  11974. /**
  11975. * Gets the global Hue value.
  11976. * 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).
  11977. */
  11978. /**
  11979. * Sets the global Hue value.
  11980. * 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).
  11981. */
  11982. globalHue: number;
  11983. /**
  11984. * Gets the global Density value.
  11985. * 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.
  11986. * Values less than zero provide a filter of opposite hue.
  11987. */
  11988. /**
  11989. * Sets the global Density value.
  11990. * 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.
  11991. * Values less than zero provide a filter of opposite hue.
  11992. */
  11993. globalDensity: number;
  11994. /**
  11995. * Gets the global Saturation value.
  11996. * 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.
  11997. */
  11998. /**
  11999. * Sets the global Saturation value.
  12000. * 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.
  12001. */
  12002. globalSaturation: number;
  12003. /**
  12004. * Gets the global Exposure value.
  12005. * 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.
  12006. */
  12007. /**
  12008. * Sets the global Exposure value.
  12009. * 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.
  12010. */
  12011. globalExposure: number;
  12012. private _highlightsHue;
  12013. private _highlightsDensity;
  12014. private _highlightsSaturation;
  12015. private _highlightsExposure;
  12016. /**
  12017. * Gets the highlights Hue value.
  12018. * 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).
  12019. */
  12020. /**
  12021. * Sets the highlights Hue value.
  12022. * 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).
  12023. */
  12024. highlightsHue: number;
  12025. /**
  12026. * Gets the highlights Density value.
  12027. * 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.
  12028. * Values less than zero provide a filter of opposite hue.
  12029. */
  12030. /**
  12031. * Sets the highlights Density value.
  12032. * 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.
  12033. * Values less than zero provide a filter of opposite hue.
  12034. */
  12035. highlightsDensity: number;
  12036. /**
  12037. * Gets the highlights Saturation value.
  12038. * 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.
  12039. */
  12040. /**
  12041. * Sets the highlights Saturation value.
  12042. * 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.
  12043. */
  12044. highlightsSaturation: number;
  12045. /**
  12046. * Gets the highlights Exposure value.
  12047. * 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.
  12048. */
  12049. /**
  12050. * Sets the highlights Exposure value.
  12051. * 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.
  12052. */
  12053. highlightsExposure: number;
  12054. private _midtonesHue;
  12055. private _midtonesDensity;
  12056. private _midtonesSaturation;
  12057. private _midtonesExposure;
  12058. /**
  12059. * Gets the midtones Hue value.
  12060. * 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).
  12061. */
  12062. /**
  12063. * Sets the midtones Hue value.
  12064. * 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).
  12065. */
  12066. midtonesHue: number;
  12067. /**
  12068. * Gets the midtones Density value.
  12069. * 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.
  12070. * Values less than zero provide a filter of opposite hue.
  12071. */
  12072. /**
  12073. * Sets the midtones Density value.
  12074. * 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.
  12075. * Values less than zero provide a filter of opposite hue.
  12076. */
  12077. midtonesDensity: number;
  12078. /**
  12079. * Gets the midtones Saturation value.
  12080. * 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.
  12081. */
  12082. /**
  12083. * Sets the midtones Saturation value.
  12084. * 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.
  12085. */
  12086. midtonesSaturation: number;
  12087. /**
  12088. * Gets the midtones Exposure value.
  12089. * 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.
  12090. */
  12091. /**
  12092. * Sets the midtones Exposure value.
  12093. * 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.
  12094. */
  12095. midtonesExposure: number;
  12096. private _shadowsHue;
  12097. private _shadowsDensity;
  12098. private _shadowsSaturation;
  12099. private _shadowsExposure;
  12100. /**
  12101. * Gets the shadows Hue value.
  12102. * 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).
  12103. */
  12104. /**
  12105. * Sets the shadows Hue value.
  12106. * 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).
  12107. */
  12108. shadowsHue: number;
  12109. /**
  12110. * Gets the shadows Density value.
  12111. * 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.
  12112. * Values less than zero provide a filter of opposite hue.
  12113. */
  12114. /**
  12115. * Sets the shadows Density value.
  12116. * 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.
  12117. * Values less than zero provide a filter of opposite hue.
  12118. */
  12119. shadowsDensity: number;
  12120. /**
  12121. * Gets the shadows Saturation value.
  12122. * 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.
  12123. */
  12124. /**
  12125. * Sets the shadows Saturation value.
  12126. * 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.
  12127. */
  12128. shadowsSaturation: number;
  12129. /**
  12130. * Gets the shadows Exposure value.
  12131. * 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.
  12132. */
  12133. /**
  12134. * Sets the shadows Exposure value.
  12135. * 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.
  12136. */
  12137. shadowsExposure: number;
  12138. getClassName(): string;
  12139. /**
  12140. * Binds the color curves to the shader.
  12141. * @param colorCurves The color curve to bind
  12142. * @param effect The effect to bind to
  12143. */
  12144. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12145. /**
  12146. * Prepare the list of uniforms associated with the ColorCurves effects.
  12147. * @param uniformsList The list of uniforms used in the effect
  12148. */
  12149. static PrepareUniforms(uniformsList: string[]): void;
  12150. /**
  12151. * Returns color grading data based on a hue, density, saturation and exposure value.
  12152. * @param filterHue The hue of the color filter.
  12153. * @param filterDensity The density of the color filter.
  12154. * @param saturation The saturation.
  12155. * @param exposure The exposure.
  12156. * @param result The result data container.
  12157. */
  12158. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12159. /**
  12160. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12161. * @param value The input slider value in range [-100,100].
  12162. * @returns Adjusted value.
  12163. */
  12164. private static applyColorGradingSliderNonlinear(value);
  12165. /**
  12166. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12167. * @param hue The hue (H) input.
  12168. * @param saturation The saturation (S) input.
  12169. * @param brightness The brightness (B) input.
  12170. * @result An RGBA color represented as Vector4.
  12171. */
  12172. private static fromHSBToRef(hue, saturation, brightness, result);
  12173. /**
  12174. * Returns a value clamped between min and max
  12175. * @param value The value to clamp
  12176. * @param min The minimum of value
  12177. * @param max The maximum of value
  12178. * @returns The clamped value.
  12179. */
  12180. private static clamp(value, min, max);
  12181. /**
  12182. * Clones the current color curve instance.
  12183. * @return The cloned curves
  12184. */
  12185. clone(): ColorCurves;
  12186. /**
  12187. * Serializes the current color curve instance to a json representation.
  12188. * @return a JSON representation
  12189. */
  12190. serialize(): any;
  12191. /**
  12192. * Parses the color curve from a json representation.
  12193. * @param source the JSON source to parse
  12194. * @return The parsed curves
  12195. */
  12196. static Parse(source: any): ColorCurves;
  12197. }
  12198. }
  12199. declare module BABYLON {
  12200. /**
  12201. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12202. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12203. */
  12204. class EffectFallbacks {
  12205. private _defines;
  12206. private _currentRank;
  12207. private _maxRank;
  12208. private _mesh;
  12209. /**
  12210. * Removes the fallback from the bound mesh.
  12211. */
  12212. unBindMesh(): void;
  12213. /**
  12214. * Adds a fallback on the specified property.
  12215. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12216. * @param define The name of the define in the shader
  12217. */
  12218. addFallback(rank: number, define: string): void;
  12219. /**
  12220. * Sets the mesh to use CPU skinning when needing to fallback.
  12221. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12222. * @param mesh The mesh to use the fallbacks.
  12223. */
  12224. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12225. /**
  12226. * Checks to see if more fallbacks are still availible.
  12227. */
  12228. readonly isMoreFallbacks: boolean;
  12229. /**
  12230. * Removes the defines that shoould be removed when falling back.
  12231. * @param currentDefines defines the current define statements for the shader.
  12232. * @param effect defines the current effect we try to compile
  12233. * @returns The resulting defines with defines of the current rank removed.
  12234. */
  12235. reduce(currentDefines: string, effect: Effect): string;
  12236. }
  12237. /**
  12238. * Options to be used when creating an effect.
  12239. */
  12240. class EffectCreationOptions {
  12241. /**
  12242. * Atrributes that will be used in the shader.
  12243. */
  12244. attributes: string[];
  12245. /**
  12246. * Uniform varible names that will be set in the shader.
  12247. */
  12248. uniformsNames: string[];
  12249. /**
  12250. * Uniform buffer varible names that will be set in the shader.
  12251. */
  12252. uniformBuffersNames: string[];
  12253. /**
  12254. * Sampler texture variable names that will be set in the shader.
  12255. */
  12256. samplers: string[];
  12257. /**
  12258. * Define statements that will be set in the shader.
  12259. */
  12260. defines: any;
  12261. /**
  12262. * Possible fallbacks for this effect to improve performance when needed.
  12263. */
  12264. fallbacks: Nullable<EffectFallbacks>;
  12265. /**
  12266. * Callback that will be called when the shader is compiled.
  12267. */
  12268. onCompiled: Nullable<(effect: Effect) => void>;
  12269. /**
  12270. * Callback that will be called if an error occurs during shader compilation.
  12271. */
  12272. onError: Nullable<(effect: Effect, errors: string) => void>;
  12273. /**
  12274. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12275. */
  12276. indexParameters: any;
  12277. /**
  12278. * Max number of lights that can be used in the shader.
  12279. */
  12280. maxSimultaneousLights: number;
  12281. /**
  12282. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12283. */
  12284. transformFeedbackVaryings: Nullable<string[]>;
  12285. }
  12286. /**
  12287. * Effect containing vertex and fragment shader that can be executed on an object.
  12288. */
  12289. class Effect {
  12290. /**
  12291. * Name of the effect.
  12292. */
  12293. name: any;
  12294. /**
  12295. * String container all the define statements that should be set on the shader.
  12296. */
  12297. defines: string;
  12298. /**
  12299. * Callback that will be called when the shader is compiled.
  12300. */
  12301. onCompiled: Nullable<(effect: Effect) => void>;
  12302. /**
  12303. * Callback that will be called if an error occurs during shader compilation.
  12304. */
  12305. onError: Nullable<(effect: Effect, errors: string) => void>;
  12306. /**
  12307. * Callback that will be called when effect is bound.
  12308. */
  12309. onBind: Nullable<(effect: Effect) => void>;
  12310. /**
  12311. * Unique ID of the effect.
  12312. */
  12313. uniqueId: number;
  12314. /**
  12315. * Observable that will be called when the shader is compiled.
  12316. */
  12317. onCompileObservable: Observable<Effect>;
  12318. /**
  12319. * Observable that will be called if an error occurs during shader compilation.
  12320. */
  12321. onErrorObservable: Observable<Effect>;
  12322. /**
  12323. * Observable that will be called when effect is bound.
  12324. */
  12325. onBindObservable: Observable<Effect>;
  12326. /** @hidden */
  12327. _bonesComputationForcedToCPU: boolean;
  12328. private static _uniqueIdSeed;
  12329. private _engine;
  12330. private _uniformBuffersNames;
  12331. private _uniformsNames;
  12332. private _samplers;
  12333. private _isReady;
  12334. private _compilationError;
  12335. private _attributesNames;
  12336. private _attributes;
  12337. private _uniforms;
  12338. /**
  12339. * Key for the effect.
  12340. */
  12341. _key: string;
  12342. private _indexParameters;
  12343. private _fallbacks;
  12344. private _vertexSourceCode;
  12345. private _fragmentSourceCode;
  12346. private _vertexSourceCodeOverride;
  12347. private _fragmentSourceCodeOverride;
  12348. private _transformFeedbackVaryings;
  12349. /**
  12350. * Compiled shader to webGL program.
  12351. */
  12352. _program: WebGLProgram;
  12353. private _valueCache;
  12354. private static _baseCache;
  12355. /**
  12356. * Instantiates an effect.
  12357. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12358. * @param baseName Name of the effect.
  12359. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12360. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12361. * @param samplers List of sampler variables that will be passed to the shader.
  12362. * @param engine Engine to be used to render the effect
  12363. * @param defines Define statements to be added to the shader.
  12364. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12365. * @param onCompiled Callback that will be called when the shader is compiled.
  12366. * @param onError Callback that will be called if an error occurs during shader compilation.
  12367. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12368. */
  12369. 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);
  12370. /**
  12371. * Unique key for this effect
  12372. */
  12373. readonly key: string;
  12374. /**
  12375. * If the effect has been compiled and prepared.
  12376. * @returns if the effect is compiled and prepared.
  12377. */
  12378. isReady(): boolean;
  12379. /**
  12380. * The engine the effect was initialized with.
  12381. * @returns the engine.
  12382. */
  12383. getEngine(): Engine;
  12384. /**
  12385. * The compiled webGL program for the effect
  12386. * @returns the webGL program.
  12387. */
  12388. getProgram(): WebGLProgram;
  12389. /**
  12390. * The set of names of attribute variables for the shader.
  12391. * @returns An array of attribute names.
  12392. */
  12393. getAttributesNames(): string[];
  12394. /**
  12395. * Returns the attribute at the given index.
  12396. * @param index The index of the attribute.
  12397. * @returns The location of the attribute.
  12398. */
  12399. getAttributeLocation(index: number): number;
  12400. /**
  12401. * Returns the attribute based on the name of the variable.
  12402. * @param name of the attribute to look up.
  12403. * @returns the attribute location.
  12404. */
  12405. getAttributeLocationByName(name: string): number;
  12406. /**
  12407. * The number of attributes.
  12408. * @returns the numnber of attributes.
  12409. */
  12410. getAttributesCount(): number;
  12411. /**
  12412. * Gets the index of a uniform variable.
  12413. * @param uniformName of the uniform to look up.
  12414. * @returns the index.
  12415. */
  12416. getUniformIndex(uniformName: string): number;
  12417. /**
  12418. * Returns the attribute based on the name of the variable.
  12419. * @param uniformName of the uniform to look up.
  12420. * @returns the location of the uniform.
  12421. */
  12422. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12423. /**
  12424. * Returns an array of sampler variable names
  12425. * @returns The array of sampler variable neames.
  12426. */
  12427. getSamplers(): string[];
  12428. /**
  12429. * The error from the last compilation.
  12430. * @returns the error string.
  12431. */
  12432. getCompilationError(): string;
  12433. /**
  12434. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12435. * @param func The callback to be used.
  12436. */
  12437. executeWhenCompiled(func: (effect: Effect) => void): void;
  12438. /** @hidden */
  12439. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12440. /** @hidden */
  12441. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12442. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12443. private _processShaderConversion(sourceCode, isFragment, callback);
  12444. private _processIncludes(sourceCode, callback);
  12445. private _processPrecision(source);
  12446. /**
  12447. * Recompiles the webGL program
  12448. * @param vertexSourceCode The source code for the vertex shader.
  12449. * @param fragmentSourceCode The source code for the fragment shader.
  12450. * @param onCompiled Callback called when completed.
  12451. * @param onError Callback called on error.
  12452. */
  12453. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12454. /**
  12455. * Gets the uniform locations of the the specified variable names
  12456. * @param names THe names of the variables to lookup.
  12457. * @returns Array of locations in the same order as variable names.
  12458. */
  12459. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12460. /**
  12461. * Prepares the effect
  12462. */
  12463. _prepareEffect(): void;
  12464. /**
  12465. * Checks if the effect is supported. (Must be called after compilation)
  12466. */
  12467. readonly isSupported: boolean;
  12468. /**
  12469. * Binds a texture to the engine to be used as output of the shader.
  12470. * @param channel Name of the output variable.
  12471. * @param texture Texture to bind.
  12472. */
  12473. _bindTexture(channel: string, texture: InternalTexture): void;
  12474. /**
  12475. * Sets a texture on the engine to be used in the shader.
  12476. * @param channel Name of the sampler variable.
  12477. * @param texture Texture to set.
  12478. */
  12479. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12480. /**
  12481. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12482. * @param channel Name of the sampler variable.
  12483. * @param texture Texture to set.
  12484. */
  12485. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12486. /**
  12487. * Sets an array of textures on the engine to be used in the shader.
  12488. * @param channel Name of the variable.
  12489. * @param textures Textures to set.
  12490. */
  12491. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12492. /**
  12493. * 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)
  12494. * @param channel Name of the sampler variable.
  12495. * @param postProcess Post process to get the input texture from.
  12496. */
  12497. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12498. /**
  12499. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12500. * 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)
  12501. * @param channel Name of the sampler variable.
  12502. * @param postProcess Post process to get the output texture from.
  12503. */
  12504. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12505. /** @hidden */
  12506. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12507. /** @hidden */
  12508. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12509. /** @hidden */
  12510. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12511. /** @hidden */
  12512. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12513. /**
  12514. * Binds a buffer to a uniform.
  12515. * @param buffer Buffer to bind.
  12516. * @param name Name of the uniform variable to bind to.
  12517. */
  12518. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12519. /**
  12520. * Binds block to a uniform.
  12521. * @param blockName Name of the block to bind.
  12522. * @param index Index to bind.
  12523. */
  12524. bindUniformBlock(blockName: string, index: number): void;
  12525. /**
  12526. * Sets an interger value on a uniform variable.
  12527. * @param uniformName Name of the variable.
  12528. * @param value Value to be set.
  12529. * @returns this effect.
  12530. */
  12531. setInt(uniformName: string, value: number): Effect;
  12532. /**
  12533. * Sets an int array on a uniform variable.
  12534. * @param uniformName Name of the variable.
  12535. * @param array array to be set.
  12536. * @returns this effect.
  12537. */
  12538. setIntArray(uniformName: string, array: Int32Array): Effect;
  12539. /**
  12540. * 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)
  12541. * @param uniformName Name of the variable.
  12542. * @param array array to be set.
  12543. * @returns this effect.
  12544. */
  12545. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12546. /**
  12547. * 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)
  12548. * @param uniformName Name of the variable.
  12549. * @param array array to be set.
  12550. * @returns this effect.
  12551. */
  12552. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12553. /**
  12554. * 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)
  12555. * @param uniformName Name of the variable.
  12556. * @param array array to be set.
  12557. * @returns this effect.
  12558. */
  12559. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12560. /**
  12561. * Sets an float array on a uniform variable.
  12562. * @param uniformName Name of the variable.
  12563. * @param array array to be set.
  12564. * @returns this effect.
  12565. */
  12566. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12567. /**
  12568. * 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)
  12569. * @param uniformName Name of the variable.
  12570. * @param array array to be set.
  12571. * @returns this effect.
  12572. */
  12573. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12574. /**
  12575. * 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)
  12576. * @param uniformName Name of the variable.
  12577. * @param array array to be set.
  12578. * @returns this effect.
  12579. */
  12580. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12581. /**
  12582. * 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)
  12583. * @param uniformName Name of the variable.
  12584. * @param array array to be set.
  12585. * @returns this effect.
  12586. */
  12587. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12588. /**
  12589. * Sets an array on a uniform variable.
  12590. * @param uniformName Name of the variable.
  12591. * @param array array to be set.
  12592. * @returns this effect.
  12593. */
  12594. setArray(uniformName: string, array: number[]): Effect;
  12595. /**
  12596. * 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)
  12597. * @param uniformName Name of the variable.
  12598. * @param array array to be set.
  12599. * @returns this effect.
  12600. */
  12601. setArray2(uniformName: string, array: number[]): Effect;
  12602. /**
  12603. * 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)
  12604. * @param uniformName Name of the variable.
  12605. * @param array array to be set.
  12606. * @returns this effect.
  12607. */
  12608. setArray3(uniformName: string, array: number[]): Effect;
  12609. /**
  12610. * 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)
  12611. * @param uniformName Name of the variable.
  12612. * @param array array to be set.
  12613. * @returns this effect.
  12614. */
  12615. setArray4(uniformName: string, array: number[]): Effect;
  12616. /**
  12617. * Sets matrices on a uniform variable.
  12618. * @param uniformName Name of the variable.
  12619. * @param matrices matrices to be set.
  12620. * @returns this effect.
  12621. */
  12622. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12623. /**
  12624. * Sets matrix on a uniform variable.
  12625. * @param uniformName Name of the variable.
  12626. * @param matrix matrix to be set.
  12627. * @returns this effect.
  12628. */
  12629. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12630. /**
  12631. * 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)
  12632. * @param uniformName Name of the variable.
  12633. * @param matrix matrix to be set.
  12634. * @returns this effect.
  12635. */
  12636. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12637. /**
  12638. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12639. * @param uniformName Name of the variable.
  12640. * @param matrix matrix to be set.
  12641. * @returns this effect.
  12642. */
  12643. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12644. /**
  12645. * Sets a float on a uniform variable.
  12646. * @param uniformName Name of the variable.
  12647. * @param value value to be set.
  12648. * @returns this effect.
  12649. */
  12650. setFloat(uniformName: string, value: number): Effect;
  12651. /**
  12652. * Sets a boolean on a uniform variable.
  12653. * @param uniformName Name of the variable.
  12654. * @param bool value to be set.
  12655. * @returns this effect.
  12656. */
  12657. setBool(uniformName: string, bool: boolean): Effect;
  12658. /**
  12659. * Sets a Vector2 on a uniform variable.
  12660. * @param uniformName Name of the variable.
  12661. * @param vector2 vector2 to be set.
  12662. * @returns this effect.
  12663. */
  12664. setVector2(uniformName: string, vector2: Vector2): Effect;
  12665. /**
  12666. * Sets a float2 on a uniform variable.
  12667. * @param uniformName Name of the variable.
  12668. * @param x First float in float2.
  12669. * @param y Second float in float2.
  12670. * @returns this effect.
  12671. */
  12672. setFloat2(uniformName: string, x: number, y: number): Effect;
  12673. /**
  12674. * Sets a Vector3 on a uniform variable.
  12675. * @param uniformName Name of the variable.
  12676. * @param vector3 Value to be set.
  12677. * @returns this effect.
  12678. */
  12679. setVector3(uniformName: string, vector3: Vector3): Effect;
  12680. /**
  12681. * Sets a float3 on a uniform variable.
  12682. * @param uniformName Name of the variable.
  12683. * @param x First float in float3.
  12684. * @param y Second float in float3.
  12685. * @param z Third float in float3.
  12686. * @returns this effect.
  12687. */
  12688. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12689. /**
  12690. * Sets a Vector4 on a uniform variable.
  12691. * @param uniformName Name of the variable.
  12692. * @param vector4 Value to be set.
  12693. * @returns this effect.
  12694. */
  12695. setVector4(uniformName: string, vector4: Vector4): Effect;
  12696. /**
  12697. * Sets a float4 on a uniform variable.
  12698. * @param uniformName Name of the variable.
  12699. * @param x First float in float4.
  12700. * @param y Second float in float4.
  12701. * @param z Third float in float4.
  12702. * @param w Fourth float in float4.
  12703. * @returns this effect.
  12704. */
  12705. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12706. /**
  12707. * Sets a Color3 on a uniform variable.
  12708. * @param uniformName Name of the variable.
  12709. * @param color3 Value to be set.
  12710. * @returns this effect.
  12711. */
  12712. setColor3(uniformName: string, color3: Color3): Effect;
  12713. /**
  12714. * Sets a Color4 on a uniform variable.
  12715. * @param uniformName Name of the variable.
  12716. * @param color3 Value to be set.
  12717. * @param alpha Alpha value to be set.
  12718. * @returns this effect.
  12719. */
  12720. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12721. /**
  12722. * Sets a Color4 on a uniform variable
  12723. * @param uniformName defines the name of the variable
  12724. * @param color4 defines the value to be set
  12725. * @returns this effect.
  12726. */
  12727. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12728. /**
  12729. * Store of each shader (The can be looked up using effect.key)
  12730. */
  12731. static ShadersStore: {
  12732. [key: string]: string;
  12733. };
  12734. /**
  12735. * Store of each included file for a shader (The can be looked up using effect.key)
  12736. */
  12737. static IncludesShadersStore: {
  12738. [key: string]: string;
  12739. };
  12740. /**
  12741. * Resets the cache of effects.
  12742. */
  12743. static ResetCache(): void;
  12744. }
  12745. }
  12746. declare module BABYLON {
  12747. class FresnelParameters {
  12748. private _isEnabled;
  12749. isEnabled: boolean;
  12750. leftColor: Color3;
  12751. rightColor: Color3;
  12752. bias: number;
  12753. power: number;
  12754. clone(): FresnelParameters;
  12755. serialize(): any;
  12756. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12757. }
  12758. }
  12759. declare module BABYLON {
  12760. /**
  12761. * Interface to follow in your material defines to integrate easily the
  12762. * Image proccessing functions.
  12763. * @hidden
  12764. */
  12765. interface IImageProcessingConfigurationDefines {
  12766. IMAGEPROCESSING: boolean;
  12767. VIGNETTE: boolean;
  12768. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12769. VIGNETTEBLENDMODEOPAQUE: boolean;
  12770. TONEMAPPING: boolean;
  12771. CONTRAST: boolean;
  12772. EXPOSURE: boolean;
  12773. COLORCURVES: boolean;
  12774. COLORGRADING: boolean;
  12775. COLORGRADING3D: boolean;
  12776. SAMPLER3DGREENDEPTH: boolean;
  12777. SAMPLER3DBGRMAP: boolean;
  12778. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12779. }
  12780. /**
  12781. * This groups together the common properties used for image processing either in direct forward pass
  12782. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12783. * or not.
  12784. */
  12785. class ImageProcessingConfiguration {
  12786. /**
  12787. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12788. */
  12789. colorCurves: Nullable<ColorCurves>;
  12790. private _colorCurvesEnabled;
  12791. /**
  12792. * Gets wether the color curves effect is enabled.
  12793. */
  12794. /**
  12795. * Sets wether the color curves effect is enabled.
  12796. */
  12797. colorCurvesEnabled: boolean;
  12798. /**
  12799. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12800. */
  12801. colorGradingTexture: Nullable<BaseTexture>;
  12802. private _colorGradingEnabled;
  12803. /**
  12804. * Gets wether the color grading effect is enabled.
  12805. */
  12806. /**
  12807. * Sets wether the color grading effect is enabled.
  12808. */
  12809. colorGradingEnabled: boolean;
  12810. private _colorGradingWithGreenDepth;
  12811. /**
  12812. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12813. */
  12814. /**
  12815. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12816. */
  12817. colorGradingWithGreenDepth: boolean;
  12818. private _colorGradingBGR;
  12819. /**
  12820. * Gets wether the color grading texture contains BGR values.
  12821. */
  12822. /**
  12823. * Sets wether the color grading texture contains BGR values.
  12824. */
  12825. colorGradingBGR: boolean;
  12826. _exposure: number;
  12827. /**
  12828. * Gets the Exposure used in the effect.
  12829. */
  12830. /**
  12831. * Sets the Exposure used in the effect.
  12832. */
  12833. exposure: number;
  12834. private _toneMappingEnabled;
  12835. /**
  12836. * Gets wether the tone mapping effect is enabled.
  12837. */
  12838. /**
  12839. * Sets wether the tone mapping effect is enabled.
  12840. */
  12841. toneMappingEnabled: boolean;
  12842. protected _contrast: number;
  12843. /**
  12844. * Gets the contrast used in the effect.
  12845. */
  12846. /**
  12847. * Sets the contrast used in the effect.
  12848. */
  12849. contrast: number;
  12850. /**
  12851. * Vignette stretch size.
  12852. */
  12853. vignetteStretch: number;
  12854. /**
  12855. * Vignette centre X Offset.
  12856. */
  12857. vignetteCentreX: number;
  12858. /**
  12859. * Vignette centre Y Offset.
  12860. */
  12861. vignetteCentreY: number;
  12862. /**
  12863. * Vignette weight or intensity of the vignette effect.
  12864. */
  12865. vignetteWeight: number;
  12866. /**
  12867. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12868. * if vignetteEnabled is set to true.
  12869. */
  12870. vignetteColor: Color4;
  12871. /**
  12872. * Camera field of view used by the Vignette effect.
  12873. */
  12874. vignetteCameraFov: number;
  12875. private _vignetteBlendMode;
  12876. /**
  12877. * Gets the vignette blend mode allowing different kind of effect.
  12878. */
  12879. /**
  12880. * Sets the vignette blend mode allowing different kind of effect.
  12881. */
  12882. vignetteBlendMode: number;
  12883. private _vignetteEnabled;
  12884. /**
  12885. * Gets wether the vignette effect is enabled.
  12886. */
  12887. /**
  12888. * Sets wether the vignette effect is enabled.
  12889. */
  12890. vignetteEnabled: boolean;
  12891. private _applyByPostProcess;
  12892. /**
  12893. * Gets wether the image processing is applied through a post process or not.
  12894. */
  12895. /**
  12896. * Sets wether the image processing is applied through a post process or not.
  12897. */
  12898. applyByPostProcess: boolean;
  12899. private _isEnabled;
  12900. /**
  12901. * Gets wether the image processing is enabled or not.
  12902. */
  12903. /**
  12904. * Sets wether the image processing is enabled or not.
  12905. */
  12906. isEnabled: boolean;
  12907. /**
  12908. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12909. */
  12910. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12911. /**
  12912. * Method called each time the image processing information changes requires to recompile the effect.
  12913. */
  12914. protected _updateParameters(): void;
  12915. getClassName(): string;
  12916. /**
  12917. * Prepare the list of uniforms associated with the Image Processing effects.
  12918. * @param uniformsList The list of uniforms used in the effect
  12919. * @param defines the list of defines currently in use
  12920. */
  12921. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12922. /**
  12923. * Prepare the list of samplers associated with the Image Processing effects.
  12924. * @param uniformsList The list of uniforms used in the effect
  12925. * @param defines the list of defines currently in use
  12926. */
  12927. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12928. /**
  12929. * Prepare the list of defines associated to the shader.
  12930. * @param defines the list of defines to complete
  12931. */
  12932. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12933. /**
  12934. * Returns true if all the image processing information are ready.
  12935. */
  12936. isReady(): boolean;
  12937. /**
  12938. * Binds the image processing to the shader.
  12939. * @param effect The effect to bind to
  12940. */
  12941. bind(effect: Effect, aspectRatio?: number): void;
  12942. /**
  12943. * Clones the current image processing instance.
  12944. * @return The cloned image processing
  12945. */
  12946. clone(): ImageProcessingConfiguration;
  12947. /**
  12948. * Serializes the current image processing instance to a json representation.
  12949. * @return a JSON representation
  12950. */
  12951. serialize(): any;
  12952. /**
  12953. * Parses the image processing from a json representation.
  12954. * @param source the JSON source to parse
  12955. * @return The parsed image processing
  12956. */
  12957. static Parse(source: any): ImageProcessingConfiguration;
  12958. private static _VIGNETTEMODE_MULTIPLY;
  12959. private static _VIGNETTEMODE_OPAQUE;
  12960. /**
  12961. * Used to apply the vignette as a mix with the pixel color.
  12962. */
  12963. static readonly VIGNETTEMODE_MULTIPLY: number;
  12964. /**
  12965. * Used to apply the vignette as a replacement of the pixel color.
  12966. */
  12967. static readonly VIGNETTEMODE_OPAQUE: number;
  12968. }
  12969. }
  12970. declare module BABYLON {
  12971. /**
  12972. * Manages the defines for the Material
  12973. */
  12974. class MaterialDefines {
  12975. private _keys;
  12976. private _isDirty;
  12977. /** @hidden */
  12978. _renderId: number;
  12979. /** @hidden */
  12980. _areLightsDirty: boolean;
  12981. /** @hidden */
  12982. _areAttributesDirty: boolean;
  12983. /** @hidden */
  12984. _areTexturesDirty: boolean;
  12985. /** @hidden */
  12986. _areFresnelDirty: boolean;
  12987. /** @hidden */
  12988. _areMiscDirty: boolean;
  12989. /** @hidden */
  12990. _areImageProcessingDirty: boolean;
  12991. /** @hidden */
  12992. _normals: boolean;
  12993. /** @hidden */
  12994. _uvs: boolean;
  12995. /** @hidden */
  12996. _needNormals: boolean;
  12997. /** @hidden */
  12998. _needUVs: boolean;
  12999. /**
  13000. * Specifies if the material needs to be re-calculated
  13001. */
  13002. readonly isDirty: boolean;
  13003. /**
  13004. * Marks the material to indicate that it has been re-calculated
  13005. */
  13006. markAsProcessed(): void;
  13007. /**
  13008. * Marks the material to indicate that it needs to be re-calculated
  13009. */
  13010. markAsUnprocessed(): void;
  13011. /**
  13012. * Marks the material to indicate all of its defines need to be re-calculated
  13013. */
  13014. markAllAsDirty(): void;
  13015. /**
  13016. * Marks the material to indicate that image processing needs to be re-calculated
  13017. */
  13018. markAsImageProcessingDirty(): void;
  13019. /**
  13020. * Marks the material to indicate the lights need to be re-calculated
  13021. */
  13022. markAsLightDirty(): void;
  13023. /**
  13024. * Marks the attribute state as changed
  13025. */
  13026. markAsAttributesDirty(): void;
  13027. /**
  13028. * Marks the texture state as changed
  13029. */
  13030. markAsTexturesDirty(): void;
  13031. /**
  13032. * Marks the fresnel state as changed
  13033. */
  13034. markAsFresnelDirty(): void;
  13035. /**
  13036. * Marks the misc state as changed
  13037. */
  13038. markAsMiscDirty(): void;
  13039. /**
  13040. * Rebuilds the material defines
  13041. */
  13042. rebuild(): void;
  13043. /**
  13044. * Specifies if two material defines are equal
  13045. * @param other - A material define instance to compare to
  13046. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13047. */
  13048. isEqual(other: MaterialDefines): boolean;
  13049. /**
  13050. * Clones this instance's defines to another instance
  13051. * @param other - material defines to clone values to
  13052. */
  13053. cloneTo(other: MaterialDefines): void;
  13054. /**
  13055. * Resets the material define values
  13056. */
  13057. reset(): void;
  13058. /**
  13059. * Converts the material define values to a string
  13060. * @returns - String of material define information
  13061. */
  13062. toString(): string;
  13063. }
  13064. /**
  13065. * Base class for the main features of a material in Babylon.js
  13066. */
  13067. class Material implements IAnimatable {
  13068. private static _TriangleFillMode;
  13069. private static _WireFrameFillMode;
  13070. private static _PointFillMode;
  13071. private static _PointListDrawMode;
  13072. private static _LineListDrawMode;
  13073. private static _LineLoopDrawMode;
  13074. private static _LineStripDrawMode;
  13075. private static _TriangleStripDrawMode;
  13076. private static _TriangleFanDrawMode;
  13077. /**
  13078. * Returns the triangle fill mode
  13079. */
  13080. static readonly TriangleFillMode: number;
  13081. /**
  13082. * Returns the wireframe mode
  13083. */
  13084. static readonly WireFrameFillMode: number;
  13085. /**
  13086. * Returns the point fill mode
  13087. */
  13088. static readonly PointFillMode: number;
  13089. /**
  13090. * Returns the point list draw mode
  13091. */
  13092. static readonly PointListDrawMode: number;
  13093. /**
  13094. * Returns the line list draw mode
  13095. */
  13096. static readonly LineListDrawMode: number;
  13097. /**
  13098. * Returns the line loop draw mode
  13099. */
  13100. static readonly LineLoopDrawMode: number;
  13101. /**
  13102. * Returns the line strip draw mode
  13103. */
  13104. static readonly LineStripDrawMode: number;
  13105. /**
  13106. * Returns the triangle strip draw mode
  13107. */
  13108. static readonly TriangleStripDrawMode: number;
  13109. /**
  13110. * Returns the triangle fan draw mode
  13111. */
  13112. static readonly TriangleFanDrawMode: number;
  13113. /**
  13114. * Stores the clock-wise side orientation
  13115. */
  13116. private static _ClockWiseSideOrientation;
  13117. /**
  13118. * Stores the counter clock-wise side orientation
  13119. */
  13120. private static _CounterClockWiseSideOrientation;
  13121. /**
  13122. * Returns the clock-wise side orientation
  13123. */
  13124. static readonly ClockWiseSideOrientation: number;
  13125. /**
  13126. * Returns the counter clock-wise side orientation
  13127. */
  13128. static readonly CounterClockWiseSideOrientation: number;
  13129. /**
  13130. * The dirty texture flag value
  13131. */
  13132. private static _TextureDirtyFlag;
  13133. /**
  13134. * The dirty light flag value
  13135. */
  13136. private static _LightDirtyFlag;
  13137. /**
  13138. * The dirty fresnel flag value
  13139. */
  13140. private static _FresnelDirtyFlag;
  13141. /**
  13142. * The dirty attribute flag value
  13143. */
  13144. private static _AttributesDirtyFlag;
  13145. /**
  13146. * The dirty misc flag value
  13147. */
  13148. private static _MiscDirtyFlag;
  13149. /**
  13150. * Returns the dirty texture flag value
  13151. */
  13152. static readonly TextureDirtyFlag: number;
  13153. /**
  13154. * Returns the dirty light flag value
  13155. */
  13156. static readonly LightDirtyFlag: number;
  13157. /**
  13158. * Returns the dirty fresnel flag value
  13159. */
  13160. static readonly FresnelDirtyFlag: number;
  13161. /**
  13162. * Returns the dirty attributes flag value
  13163. */
  13164. static readonly AttributesDirtyFlag: number;
  13165. /**
  13166. * Returns the dirty misc flag value
  13167. */
  13168. static readonly MiscDirtyFlag: number;
  13169. /**
  13170. * The ID of the material
  13171. */
  13172. id: string;
  13173. /**
  13174. * Gets or sets the unique id of the material
  13175. */
  13176. uniqueId: number;
  13177. /**
  13178. * The name of the material
  13179. */
  13180. name: string;
  13181. /**
  13182. * Specifies if the ready state should be checked on each call
  13183. */
  13184. checkReadyOnEveryCall: boolean;
  13185. /**
  13186. * Specifies if the ready state should be checked once
  13187. */
  13188. checkReadyOnlyOnce: boolean;
  13189. /**
  13190. * The state of the material
  13191. */
  13192. state: string;
  13193. /**
  13194. * The alpha value of the material
  13195. */
  13196. protected _alpha: number;
  13197. /**
  13198. * Gets the alpha value of the material
  13199. */
  13200. /**
  13201. * Sets the alpha value of the material
  13202. */
  13203. alpha: number;
  13204. /**
  13205. * Specifies if back face culling is enabled
  13206. */
  13207. protected _backFaceCulling: boolean;
  13208. /**
  13209. * Gets the back-face culling state
  13210. */
  13211. /**
  13212. * Sets the back-face culling state
  13213. */
  13214. backFaceCulling: boolean;
  13215. /**
  13216. * Stores the value for side orientation
  13217. */
  13218. sideOrientation: number;
  13219. /**
  13220. * Callback triggered when the material is compiled
  13221. */
  13222. onCompiled: (effect: Effect) => void;
  13223. /**
  13224. * Callback triggered when an error occurs
  13225. */
  13226. onError: (effect: Effect, errors: string) => void;
  13227. /**
  13228. * Callback triggered to get the render target textures
  13229. */
  13230. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13231. /**
  13232. * Specifies if the material should be serialized
  13233. */
  13234. doNotSerialize: boolean;
  13235. /**
  13236. * Specifies if the effect should be stored on sub meshes
  13237. */
  13238. storeEffectOnSubMeshes: boolean;
  13239. /**
  13240. * Stores the animations for the material
  13241. */
  13242. animations: Array<Animation>;
  13243. /**
  13244. * An event triggered when the material is disposed
  13245. */
  13246. onDisposeObservable: Observable<Material>;
  13247. /**
  13248. * An observer which watches for dispose events
  13249. */
  13250. private _onDisposeObserver;
  13251. /**
  13252. * Called during a dispose event
  13253. */
  13254. onDispose: () => void;
  13255. /**
  13256. * An event triggered when the material is bound
  13257. */
  13258. onBindObservable: Observable<AbstractMesh>;
  13259. /**
  13260. * An observer which watches for bind events
  13261. */
  13262. private _onBindObserver;
  13263. /**
  13264. * Called during a bind event
  13265. */
  13266. onBind: (Mesh: AbstractMesh) => void;
  13267. /**
  13268. * An event triggered when the material is unbound
  13269. */
  13270. onUnBindObservable: Observable<Material>;
  13271. /**
  13272. * Stores the value of the alpha mode
  13273. */
  13274. private _alphaMode;
  13275. /**
  13276. * Gets the value of the alpha mode
  13277. */
  13278. /**
  13279. * Sets the value of the alpha mode.
  13280. *
  13281. * | Value | Type | Description |
  13282. * | --- | --- | --- |
  13283. * | 0 | ALPHA_DISABLE | |
  13284. * | 1 | ALPHA_ADD | |
  13285. * | 2 | ALPHA_COMBINE | |
  13286. * | 3 | ALPHA_SUBTRACT | |
  13287. * | 4 | ALPHA_MULTIPLY | |
  13288. * | 5 | ALPHA_MAXIMIZED | |
  13289. * | 6 | ALPHA_ONEONE | |
  13290. * | 7 | ALPHA_PREMULTIPLIED | |
  13291. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13292. * | 9 | ALPHA_INTERPOLATE | |
  13293. * | 10 | ALPHA_SCREENMODE | |
  13294. *
  13295. */
  13296. alphaMode: number;
  13297. /**
  13298. * Stores the state of the need depth pre-pass value
  13299. */
  13300. private _needDepthPrePass;
  13301. /**
  13302. * Gets the depth pre-pass value
  13303. */
  13304. /**
  13305. * Sets the need depth pre-pass value
  13306. */
  13307. needDepthPrePass: boolean;
  13308. /**
  13309. * Specifies if depth writing should be disabled
  13310. */
  13311. disableDepthWrite: boolean;
  13312. /**
  13313. * Specifies if depth writing should be forced
  13314. */
  13315. forceDepthWrite: boolean;
  13316. /**
  13317. * Specifies if there should be a separate pass for culling
  13318. */
  13319. separateCullingPass: boolean;
  13320. /**
  13321. * Stores the state specifing if fog should be enabled
  13322. */
  13323. private _fogEnabled;
  13324. /**
  13325. * Gets the value of the fog enabled state
  13326. */
  13327. /**
  13328. * Sets the state for enabling fog
  13329. */
  13330. fogEnabled: boolean;
  13331. /**
  13332. * Stores the size of points
  13333. */
  13334. pointSize: number;
  13335. /**
  13336. * Stores the z offset value
  13337. */
  13338. zOffset: number;
  13339. /**
  13340. * Gets a value specifying if wireframe mode is enabled
  13341. */
  13342. /**
  13343. * Sets the state of wireframe mode
  13344. */
  13345. wireframe: boolean;
  13346. /**
  13347. * Gets the value specifying if point clouds are enabled
  13348. */
  13349. /**
  13350. * Sets the state of point cloud mode
  13351. */
  13352. pointsCloud: boolean;
  13353. /**
  13354. * Gets the material fill mode
  13355. */
  13356. /**
  13357. * Sets the material fill mode
  13358. */
  13359. fillMode: number;
  13360. /**
  13361. * Stores the effects for the material
  13362. */
  13363. _effect: Nullable<Effect>;
  13364. /**
  13365. * Specifies if the material was previously ready
  13366. */
  13367. _wasPreviouslyReady: boolean;
  13368. /**
  13369. * Specifies if uniform buffers should be used
  13370. */
  13371. private _useUBO;
  13372. /**
  13373. * Stores a reference to the scene
  13374. */
  13375. private _scene;
  13376. /**
  13377. * Stores the fill mode state
  13378. */
  13379. private _fillMode;
  13380. /**
  13381. * Specifies if the depth write state should be cached
  13382. */
  13383. private _cachedDepthWriteState;
  13384. /**
  13385. * Stores the uniform buffer
  13386. */
  13387. protected _uniformBuffer: UniformBuffer;
  13388. /**
  13389. * Creates a material instance
  13390. * @param name defines the name of the material
  13391. * @param scene defines the scene to reference
  13392. * @param doNotAdd specifies if the material should be added to the scene
  13393. */
  13394. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13395. /**
  13396. * Returns a string representation of the current material
  13397. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13398. * @returns a string with material information
  13399. */
  13400. toString(fullDetails?: boolean): string;
  13401. /**
  13402. * Gets the class name of the material
  13403. * @returns a string with the class name of the material
  13404. */
  13405. getClassName(): string;
  13406. /**
  13407. * Specifies if updates for the material been locked
  13408. */
  13409. readonly isFrozen: boolean;
  13410. /**
  13411. * Locks updates for the material
  13412. */
  13413. freeze(): void;
  13414. /**
  13415. * Unlocks updates for the material
  13416. */
  13417. unfreeze(): void;
  13418. /**
  13419. * Specifies if the material is ready to be used
  13420. * @param mesh defines the mesh to check
  13421. * @param useInstances specifies if instances should be used
  13422. * @returns a boolean indicating if the material is ready to be used
  13423. */
  13424. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13425. /**
  13426. * Specifies that the submesh is ready to be used
  13427. * @param mesh defines the mesh to check
  13428. * @param subMesh defines which submesh to check
  13429. * @param useInstances specifies that instances should be used
  13430. * @returns a boolean indicating that the submesh is ready or not
  13431. */
  13432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13433. /**
  13434. * Returns the material effect
  13435. * @returns the effect associated with the material
  13436. */
  13437. getEffect(): Nullable<Effect>;
  13438. /**
  13439. * Returns the current scene
  13440. * @returns a Scene
  13441. */
  13442. getScene(): Scene;
  13443. /**
  13444. * Specifies if the material will require alpha blending
  13445. * @returns a boolean specifying if alpha blending is needed
  13446. */
  13447. needAlphaBlending(): boolean;
  13448. /**
  13449. * Specifies if the mesh will require alpha blending
  13450. * @param mesh defines the mesh to check
  13451. * @returns a boolean specifying if alpha blending is needed for the mesh
  13452. */
  13453. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13454. /**
  13455. * Specifies if this material should be rendered in alpha test mode
  13456. * @returns a boolean specifying if an alpha test is needed.
  13457. */
  13458. needAlphaTesting(): boolean;
  13459. /**
  13460. * Gets the texture used for the alpha test
  13461. * @returns the texture to use for alpha testing
  13462. */
  13463. getAlphaTestTexture(): Nullable<BaseTexture>;
  13464. /**
  13465. * Marks the material to indicate that it needs to be re-calculated
  13466. */
  13467. markDirty(): void;
  13468. /** @hidden */
  13469. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13470. /**
  13471. * Binds the material to the mesh
  13472. * @param world defines the world transformation matrix
  13473. * @param mesh defines the mesh to bind the material to
  13474. */
  13475. bind(world: Matrix, mesh?: Mesh): void;
  13476. /**
  13477. * Binds the submesh to the material
  13478. * @param world defines the world transformation matrix
  13479. * @param mesh defines the mesh containing the submesh
  13480. * @param subMesh defines the submesh to bind the material to
  13481. */
  13482. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13483. /**
  13484. * Binds the world matrix to the material
  13485. * @param world defines the world transformation matrix
  13486. */
  13487. bindOnlyWorldMatrix(world: Matrix): void;
  13488. /**
  13489. * Binds the scene's uniform buffer to the effect.
  13490. * @param effect defines the effect to bind to the scene uniform buffer
  13491. * @param sceneUbo defines the uniform buffer storing scene data
  13492. */
  13493. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13494. /**
  13495. * Binds the view matrix to the effect
  13496. * @param effect defines the effect to bind the view matrix to
  13497. */
  13498. bindView(effect: Effect): void;
  13499. /**
  13500. * Binds the view projection matrix to the effect
  13501. * @param effect defines the effect to bind the view projection matrix to
  13502. */
  13503. bindViewProjection(effect: Effect): void;
  13504. /**
  13505. * Specifies if material alpha testing should be turned on for the mesh
  13506. * @param mesh defines the mesh to check
  13507. */
  13508. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13509. /**
  13510. * Processes to execute after binding the material to a mesh
  13511. * @param mesh defines the rendered mesh
  13512. */
  13513. protected _afterBind(mesh?: Mesh): void;
  13514. /**
  13515. * Unbinds the material from the mesh
  13516. */
  13517. unbind(): void;
  13518. /**
  13519. * Gets the active textures from the material
  13520. * @returns an array of textures
  13521. */
  13522. getActiveTextures(): BaseTexture[];
  13523. /**
  13524. * Specifies if the material uses a texture
  13525. * @param texture defines the texture to check against the material
  13526. * @returns a boolean specifying if the material uses the texture
  13527. */
  13528. hasTexture(texture: BaseTexture): boolean;
  13529. /**
  13530. * Makes a duplicate of the material, and gives it a new name
  13531. * @param name defines the new name for the duplicated material
  13532. * @returns the cloned material
  13533. */
  13534. clone(name: string): Nullable<Material>;
  13535. /**
  13536. * Gets the meshes bound to the material
  13537. * @returns an array of meshes bound to the material
  13538. */
  13539. getBindedMeshes(): AbstractMesh[];
  13540. /**
  13541. * Force shader compilation
  13542. * @param mesh defines the mesh associated with this material
  13543. * @param onCompiled defines a function to execute once the material is compiled
  13544. * @param options defines the options to configure the compilation
  13545. */
  13546. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13547. clipPlane: boolean;
  13548. }>): void;
  13549. /**
  13550. * Force shader compilation
  13551. * @param mesh defines the mesh that will use this material
  13552. * @param options defines additional options for compiling the shaders
  13553. * @returns a promise that resolves when the compilation completes
  13554. */
  13555. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13556. clipPlane: boolean;
  13557. }>): Promise<void>;
  13558. /**
  13559. * Marks a define in the material to indicate that it needs to be re-computed
  13560. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13561. */
  13562. markAsDirty(flag: number): void;
  13563. /**
  13564. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13565. * @param func defines a function which checks material defines against the submeshes
  13566. */
  13567. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13568. /**
  13569. * Indicates that image processing needs to be re-calculated for all submeshes
  13570. */
  13571. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13572. /**
  13573. * Indicates that textures need to be re-calculated for all submeshes
  13574. */
  13575. protected _markAllSubMeshesAsTexturesDirty(): void;
  13576. /**
  13577. * Indicates that fresnel needs to be re-calculated for all submeshes
  13578. */
  13579. protected _markAllSubMeshesAsFresnelDirty(): void;
  13580. /**
  13581. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13582. */
  13583. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13584. /**
  13585. * Indicates that lights need to be re-calculated for all submeshes
  13586. */
  13587. protected _markAllSubMeshesAsLightsDirty(): void;
  13588. /**
  13589. * Indicates that attributes need to be re-calculated for all submeshes
  13590. */
  13591. protected _markAllSubMeshesAsAttributesDirty(): void;
  13592. /**
  13593. * Indicates that misc needs to be re-calculated for all submeshes
  13594. */
  13595. protected _markAllSubMeshesAsMiscDirty(): void;
  13596. /**
  13597. * Indicates that textures and misc need to be re-calculated for all submeshes
  13598. */
  13599. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13600. /**
  13601. * Disposes the material
  13602. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13603. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13604. */
  13605. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13606. /**
  13607. * Serializes this material
  13608. * @returns the serialized material object
  13609. */
  13610. serialize(): any;
  13611. /**
  13612. * Creates a MultiMaterial from parsed MultiMaterial data.
  13613. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13614. * @param scene defines the hosting scene
  13615. * @returns a new MultiMaterial
  13616. */
  13617. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13618. /**
  13619. * Creates a material from parsed material data
  13620. * @param parsedMaterial defines parsed material data
  13621. * @param scene defines the hosting scene
  13622. * @param rootUrl defines the root URL to use to load textures
  13623. * @returns a new material
  13624. */
  13625. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13626. }
  13627. }
  13628. declare module BABYLON {
  13629. /**
  13630. * "Static Class" containing the most commonly used helper while dealing with material for
  13631. * rendering purpose.
  13632. *
  13633. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13634. *
  13635. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13636. */
  13637. class MaterialHelper {
  13638. /**
  13639. * Bind the current view position to an effect.
  13640. * @param effect The effect to be bound
  13641. * @param scene The scene the eyes position is used from
  13642. */
  13643. static BindEyePosition(effect: Effect, scene: Scene): void;
  13644. /**
  13645. * Helps preparing the defines values about the UVs in used in the effect.
  13646. * UVs are shared as much as we can accross chanels in the shaders.
  13647. * @param texture The texture we are preparing the UVs for
  13648. * @param defines The defines to update
  13649. * @param key The chanel key "diffuse", "specular"... used in the shader
  13650. */
  13651. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13652. /**
  13653. * Binds a texture matrix value to its corrsponding uniform
  13654. * @param texture The texture to bind the matrix for
  13655. * @param uniformBuffer The uniform buffer receivin the data
  13656. * @param key The chanel key "diffuse", "specular"... used in the shader
  13657. */
  13658. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13659. /**
  13660. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13661. * @param mesh defines the current mesh
  13662. * @param scene defines the current scene
  13663. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13664. * @param pointsCloud defines if point cloud rendering has to be turned on
  13665. * @param fogEnabled defines if fog has to be turned on
  13666. * @param alphaTest defines if alpha testing has to be turned on
  13667. * @param defines defines the current list of defines
  13668. */
  13669. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13670. /**
  13671. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13672. * @param scene defines the current scene
  13673. * @param engine defines the current engine
  13674. * @param defines specifies the list of active defines
  13675. * @param useInstances defines if instances have to be turned on
  13676. * @param useClipPlane defines if clip plane have to be turned on
  13677. */
  13678. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13679. /**
  13680. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13681. * @param mesh The mesh containing the geometry data we will draw
  13682. * @param defines The defines to update
  13683. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13684. * @param useBones Precise whether bones should be used or not (override mesh info)
  13685. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13686. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13687. * @returns false if defines are considered not dirty and have not been checked
  13688. */
  13689. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13690. /**
  13691. * Prepares the defines related to the light information passed in parameter
  13692. * @param scene The scene we are intending to draw
  13693. * @param mesh The mesh the effect is compiling for
  13694. * @param defines The defines to update
  13695. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13696. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13697. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13698. * @returns true if normals will be required for the rest of the effect
  13699. */
  13700. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13701. /**
  13702. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13703. * that won t be acctive due to defines being turned off.
  13704. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13705. * @param samplersList The samplers list
  13706. * @param defines The defines helping in the list generation
  13707. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13708. */
  13709. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13710. /**
  13711. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13712. * @param defines The defines to update while falling back
  13713. * @param fallbacks The authorized effect fallbacks
  13714. * @param maxSimultaneousLights The maximum number of lights allowed
  13715. * @param rank the current rank of the Effect
  13716. * @returns The newly affected rank
  13717. */
  13718. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13719. /**
  13720. * Prepares the list of attributes required for morph targets according to the effect defines.
  13721. * @param attribs The current list of supported attribs
  13722. * @param mesh The mesh to prepare the morph targets attributes for
  13723. * @param defines The current Defines of the effect
  13724. */
  13725. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13726. /**
  13727. * Prepares the list of attributes required for bones according to the effect defines.
  13728. * @param attribs The current list of supported attribs
  13729. * @param mesh The mesh to prepare the bones attributes for
  13730. * @param defines The current Defines of the effect
  13731. * @param fallbacks The current efffect fallback strategy
  13732. */
  13733. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13734. /**
  13735. * Prepares the list of attributes required for instances according to the effect defines.
  13736. * @param attribs The current list of supported attribs
  13737. * @param defines The current Defines of the effect
  13738. */
  13739. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13740. /**
  13741. * Binds the light shadow information to the effect for the given mesh.
  13742. * @param light The light containing the generator
  13743. * @param scene The scene the lights belongs to
  13744. * @param mesh The mesh we are binding the information to render
  13745. * @param lightIndex The light index in the effect used to render the mesh
  13746. * @param effect The effect we are binding the data to
  13747. */
  13748. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13749. /**
  13750. * Binds the light information to the effect.
  13751. * @param light The light containing the generator
  13752. * @param effect The effect we are binding the data to
  13753. * @param lightIndex The light index in the effect used to render
  13754. */
  13755. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13756. /**
  13757. * Binds the lights information from the scene to the effect for the given mesh.
  13758. * @param scene The scene the lights belongs to
  13759. * @param mesh The mesh we are binding the information to render
  13760. * @param effect The effect we are binding the data to
  13761. * @param defines The generated defines for the effect
  13762. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13763. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13764. */
  13765. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13766. /**
  13767. * Binds the fog information from the scene to the effect for the given mesh.
  13768. * @param scene The scene the lights belongs to
  13769. * @param mesh The mesh we are binding the information to render
  13770. * @param effect The effect we are binding the data to
  13771. */
  13772. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13773. /**
  13774. * Binds the bones information from the mesh to the effect.
  13775. * @param mesh The mesh we are binding the information to render
  13776. * @param effect The effect we are binding the data to
  13777. */
  13778. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13779. /**
  13780. * Binds the morph targets information from the mesh to the effect.
  13781. * @param abstractMesh The mesh we are binding the information to render
  13782. * @param effect The effect we are binding the data to
  13783. */
  13784. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13785. /**
  13786. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13787. * @param defines The generated defines used in the effect
  13788. * @param effect The effect we are binding the data to
  13789. * @param scene The scene we are willing to render with logarithmic scale for
  13790. */
  13791. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13792. /**
  13793. * Binds the clip plane information from the scene to the effect.
  13794. * @param scene The scene the clip plane information are extracted from
  13795. * @param effect The effect we are binding the data to
  13796. */
  13797. static BindClipPlane(effect: Effect, scene: Scene): void;
  13798. }
  13799. }
  13800. declare module BABYLON {
  13801. class MultiMaterial extends Material {
  13802. private _subMaterials;
  13803. subMaterials: Nullable<Material>[];
  13804. constructor(name: string, scene: Scene);
  13805. private _hookArray(array);
  13806. getSubMaterial(index: number): Nullable<Material>;
  13807. getActiveTextures(): BaseTexture[];
  13808. getClassName(): string;
  13809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13810. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13811. serialize(): any;
  13812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13813. }
  13814. }
  13815. declare module BABYLON {
  13816. class PushMaterial extends Material {
  13817. protected _activeEffect: Effect;
  13818. protected _normalMatrix: Matrix;
  13819. constructor(name: string, scene: Scene);
  13820. getEffect(): Effect;
  13821. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13822. /**
  13823. * Binds the given world matrix to the active effect
  13824. *
  13825. * @param world the matrix to bind
  13826. */
  13827. bindOnlyWorldMatrix(world: Matrix): void;
  13828. /**
  13829. * Binds the given normal matrix to the active effect
  13830. *
  13831. * @param normalMatrix the matrix to bind
  13832. */
  13833. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13834. bind(world: Matrix, mesh?: Mesh): void;
  13835. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13836. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13837. }
  13838. }
  13839. declare module BABYLON {
  13840. class ShaderMaterial extends Material {
  13841. private _shaderPath;
  13842. private _options;
  13843. private _textures;
  13844. private _textureArrays;
  13845. private _floats;
  13846. private _ints;
  13847. private _floatsArrays;
  13848. private _colors3;
  13849. private _colors3Arrays;
  13850. private _colors4;
  13851. private _vectors2;
  13852. private _vectors3;
  13853. private _vectors4;
  13854. private _matrices;
  13855. private _matrices3x3;
  13856. private _matrices2x2;
  13857. private _vectors2Arrays;
  13858. private _vectors3Arrays;
  13859. private _cachedWorldViewMatrix;
  13860. private _renderId;
  13861. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13862. getClassName(): string;
  13863. needAlphaBlending(): boolean;
  13864. needAlphaTesting(): boolean;
  13865. private _checkUniform(uniformName);
  13866. setTexture(name: string, texture: Texture): ShaderMaterial;
  13867. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13868. setFloat(name: string, value: number): ShaderMaterial;
  13869. setInt(name: string, value: number): ShaderMaterial;
  13870. setFloats(name: string, value: number[]): ShaderMaterial;
  13871. setColor3(name: string, value: Color3): ShaderMaterial;
  13872. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13873. setColor4(name: string, value: Color4): ShaderMaterial;
  13874. setVector2(name: string, value: Vector2): ShaderMaterial;
  13875. setVector3(name: string, value: Vector3): ShaderMaterial;
  13876. setVector4(name: string, value: Vector4): ShaderMaterial;
  13877. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13878. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13879. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13880. setArray2(name: string, value: number[]): ShaderMaterial;
  13881. setArray3(name: string, value: number[]): ShaderMaterial;
  13882. private _checkCache(scene, mesh?, useInstances?);
  13883. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13884. bindOnlyWorldMatrix(world: Matrix): void;
  13885. bind(world: Matrix, mesh?: Mesh): void;
  13886. getActiveTextures(): BaseTexture[];
  13887. hasTexture(texture: BaseTexture): boolean;
  13888. clone(name: string): ShaderMaterial;
  13889. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13890. serialize(): any;
  13891. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13892. }
  13893. }
  13894. declare module BABYLON {
  13895. /** @hidden */
  13896. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13897. MAINUV1: boolean;
  13898. MAINUV2: boolean;
  13899. DIFFUSE: boolean;
  13900. DIFFUSEDIRECTUV: number;
  13901. AMBIENT: boolean;
  13902. AMBIENTDIRECTUV: number;
  13903. OPACITY: boolean;
  13904. OPACITYDIRECTUV: number;
  13905. OPACITYRGB: boolean;
  13906. REFLECTION: boolean;
  13907. EMISSIVE: boolean;
  13908. EMISSIVEDIRECTUV: number;
  13909. SPECULAR: boolean;
  13910. SPECULARDIRECTUV: number;
  13911. BUMP: boolean;
  13912. BUMPDIRECTUV: number;
  13913. PARALLAX: boolean;
  13914. PARALLAXOCCLUSION: boolean;
  13915. SPECULAROVERALPHA: boolean;
  13916. CLIPPLANE: boolean;
  13917. ALPHATEST: boolean;
  13918. DEPTHPREPASS: boolean;
  13919. ALPHAFROMDIFFUSE: boolean;
  13920. POINTSIZE: boolean;
  13921. FOG: boolean;
  13922. SPECULARTERM: boolean;
  13923. DIFFUSEFRESNEL: boolean;
  13924. OPACITYFRESNEL: boolean;
  13925. REFLECTIONFRESNEL: boolean;
  13926. REFRACTIONFRESNEL: boolean;
  13927. EMISSIVEFRESNEL: boolean;
  13928. FRESNEL: boolean;
  13929. NORMAL: boolean;
  13930. UV1: boolean;
  13931. UV2: boolean;
  13932. VERTEXCOLOR: boolean;
  13933. VERTEXALPHA: boolean;
  13934. NUM_BONE_INFLUENCERS: number;
  13935. BonesPerMesh: number;
  13936. INSTANCES: boolean;
  13937. GLOSSINESS: boolean;
  13938. ROUGHNESS: boolean;
  13939. EMISSIVEASILLUMINATION: boolean;
  13940. LINKEMISSIVEWITHDIFFUSE: boolean;
  13941. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13942. LIGHTMAP: boolean;
  13943. LIGHTMAPDIRECTUV: number;
  13944. OBJECTSPACE_NORMALMAP: boolean;
  13945. USELIGHTMAPASSHADOWMAP: boolean;
  13946. REFLECTIONMAP_3D: boolean;
  13947. REFLECTIONMAP_SPHERICAL: boolean;
  13948. REFLECTIONMAP_PLANAR: boolean;
  13949. REFLECTIONMAP_CUBIC: boolean;
  13950. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13951. REFLECTIONMAP_PROJECTION: boolean;
  13952. REFLECTIONMAP_SKYBOX: boolean;
  13953. REFLECTIONMAP_EXPLICIT: boolean;
  13954. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13955. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13956. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13957. INVERTCUBICMAP: boolean;
  13958. LOGARITHMICDEPTH: boolean;
  13959. REFRACTION: boolean;
  13960. REFRACTIONMAP_3D: boolean;
  13961. REFLECTIONOVERALPHA: boolean;
  13962. TWOSIDEDLIGHTING: boolean;
  13963. SHADOWFLOAT: boolean;
  13964. MORPHTARGETS: boolean;
  13965. MORPHTARGETS_NORMAL: boolean;
  13966. MORPHTARGETS_TANGENT: boolean;
  13967. NUM_MORPH_INFLUENCERS: number;
  13968. NONUNIFORMSCALING: boolean;
  13969. PREMULTIPLYALPHA: boolean;
  13970. IMAGEPROCESSING: boolean;
  13971. VIGNETTE: boolean;
  13972. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13973. VIGNETTEBLENDMODEOPAQUE: boolean;
  13974. TONEMAPPING: boolean;
  13975. CONTRAST: boolean;
  13976. COLORCURVES: boolean;
  13977. COLORGRADING: boolean;
  13978. COLORGRADING3D: boolean;
  13979. SAMPLER3DGREENDEPTH: boolean;
  13980. SAMPLER3DBGRMAP: boolean;
  13981. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13982. /**
  13983. * If the reflection texture on this material is in linear color space
  13984. * @hidden
  13985. */
  13986. IS_REFLECTION_LINEAR: boolean;
  13987. /**
  13988. * If the refraction texture on this material is in linear color space
  13989. * @hidden
  13990. */
  13991. IS_REFRACTION_LINEAR: boolean;
  13992. EXPOSURE: boolean;
  13993. constructor();
  13994. setReflectionMode(modeToEnable: string): void;
  13995. }
  13996. class StandardMaterial extends PushMaterial {
  13997. private _diffuseTexture;
  13998. diffuseTexture: Nullable<BaseTexture>;
  13999. private _ambientTexture;
  14000. ambientTexture: Nullable<BaseTexture>;
  14001. private _opacityTexture;
  14002. opacityTexture: Nullable<BaseTexture>;
  14003. private _reflectionTexture;
  14004. reflectionTexture: Nullable<BaseTexture>;
  14005. private _emissiveTexture;
  14006. emissiveTexture: Nullable<BaseTexture>;
  14007. private _specularTexture;
  14008. specularTexture: Nullable<BaseTexture>;
  14009. private _bumpTexture;
  14010. bumpTexture: Nullable<BaseTexture>;
  14011. private _lightmapTexture;
  14012. lightmapTexture: Nullable<BaseTexture>;
  14013. private _refractionTexture;
  14014. refractionTexture: Nullable<BaseTexture>;
  14015. ambientColor: Color3;
  14016. diffuseColor: Color3;
  14017. specularColor: Color3;
  14018. emissiveColor: Color3;
  14019. specularPower: number;
  14020. private _useAlphaFromDiffuseTexture;
  14021. useAlphaFromDiffuseTexture: boolean;
  14022. private _useEmissiveAsIllumination;
  14023. useEmissiveAsIllumination: boolean;
  14024. private _linkEmissiveWithDiffuse;
  14025. linkEmissiveWithDiffuse: boolean;
  14026. private _useSpecularOverAlpha;
  14027. useSpecularOverAlpha: boolean;
  14028. private _useReflectionOverAlpha;
  14029. useReflectionOverAlpha: boolean;
  14030. private _disableLighting;
  14031. disableLighting: boolean;
  14032. private _useObjectSpaceNormalMap;
  14033. /**
  14034. * Allows using an object space normal map (instead of tangent space).
  14035. */
  14036. useObjectSpaceNormalMap: boolean;
  14037. private _useParallax;
  14038. useParallax: boolean;
  14039. private _useParallaxOcclusion;
  14040. useParallaxOcclusion: boolean;
  14041. parallaxScaleBias: number;
  14042. private _roughness;
  14043. roughness: number;
  14044. indexOfRefraction: number;
  14045. invertRefractionY: boolean;
  14046. /**
  14047. * Defines the alpha limits in alpha test mode
  14048. */
  14049. alphaCutOff: number;
  14050. private _useLightmapAsShadowmap;
  14051. useLightmapAsShadowmap: boolean;
  14052. private _diffuseFresnelParameters;
  14053. diffuseFresnelParameters: FresnelParameters;
  14054. private _opacityFresnelParameters;
  14055. opacityFresnelParameters: FresnelParameters;
  14056. private _reflectionFresnelParameters;
  14057. reflectionFresnelParameters: FresnelParameters;
  14058. private _refractionFresnelParameters;
  14059. refractionFresnelParameters: FresnelParameters;
  14060. private _emissiveFresnelParameters;
  14061. emissiveFresnelParameters: FresnelParameters;
  14062. private _useReflectionFresnelFromSpecular;
  14063. useReflectionFresnelFromSpecular: boolean;
  14064. private _useGlossinessFromSpecularMapAlpha;
  14065. useGlossinessFromSpecularMapAlpha: boolean;
  14066. private _maxSimultaneousLights;
  14067. maxSimultaneousLights: number;
  14068. /**
  14069. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14070. */
  14071. private _invertNormalMapX;
  14072. invertNormalMapX: boolean;
  14073. /**
  14074. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14075. */
  14076. private _invertNormalMapY;
  14077. invertNormalMapY: boolean;
  14078. /**
  14079. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14080. */
  14081. private _twoSidedLighting;
  14082. twoSidedLighting: boolean;
  14083. /**
  14084. * Default configuration related to image processing available in the standard Material.
  14085. */
  14086. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14087. /**
  14088. * Gets the image processing configuration used either in this material.
  14089. */
  14090. /**
  14091. * Sets the Default image processing configuration used either in the this material.
  14092. *
  14093. * If sets to null, the scene one is in use.
  14094. */
  14095. imageProcessingConfiguration: ImageProcessingConfiguration;
  14096. /**
  14097. * Keep track of the image processing observer to allow dispose and replace.
  14098. */
  14099. private _imageProcessingObserver;
  14100. /**
  14101. * Attaches a new image processing configuration to the Standard Material.
  14102. * @param configuration
  14103. */
  14104. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14105. /**
  14106. * Gets wether the color curves effect is enabled.
  14107. */
  14108. /**
  14109. * Sets wether the color curves effect is enabled.
  14110. */
  14111. cameraColorCurvesEnabled: boolean;
  14112. /**
  14113. * Gets wether the color grading effect is enabled.
  14114. */
  14115. /**
  14116. * Gets wether the color grading effect is enabled.
  14117. */
  14118. cameraColorGradingEnabled: boolean;
  14119. /**
  14120. * Gets wether tonemapping is enabled or not.
  14121. */
  14122. /**
  14123. * Sets wether tonemapping is enabled or not
  14124. */
  14125. cameraToneMappingEnabled: boolean;
  14126. /**
  14127. * The camera exposure used on this material.
  14128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14129. * This corresponds to a photographic exposure.
  14130. */
  14131. /**
  14132. * The camera exposure used on this material.
  14133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14134. * This corresponds to a photographic exposure.
  14135. */
  14136. cameraExposure: number;
  14137. /**
  14138. * Gets The camera contrast used on this material.
  14139. */
  14140. /**
  14141. * Sets The camera contrast used on this material.
  14142. */
  14143. cameraContrast: number;
  14144. /**
  14145. * Gets the Color Grading 2D Lookup Texture.
  14146. */
  14147. /**
  14148. * Sets the Color Grading 2D Lookup Texture.
  14149. */
  14150. cameraColorGradingTexture: Nullable<BaseTexture>;
  14151. /**
  14152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14154. * 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;
  14155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14156. */
  14157. /**
  14158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14160. * 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;
  14161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14162. */
  14163. cameraColorCurves: Nullable<ColorCurves>;
  14164. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14165. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14166. protected _worldViewProjectionMatrix: Matrix;
  14167. protected _globalAmbientColor: Color3;
  14168. protected _useLogarithmicDepth: boolean;
  14169. constructor(name: string, scene: Scene);
  14170. getClassName(): string;
  14171. useLogarithmicDepth: boolean;
  14172. needAlphaBlending(): boolean;
  14173. needAlphaTesting(): boolean;
  14174. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14175. getAlphaTestTexture(): Nullable<BaseTexture>;
  14176. /**
  14177. * Child classes can use it to update shaders
  14178. */
  14179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14180. buildUniformLayout(): void;
  14181. unbind(): void;
  14182. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14183. getAnimatables(): IAnimatable[];
  14184. getActiveTextures(): BaseTexture[];
  14185. hasTexture(texture: BaseTexture): boolean;
  14186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14187. clone(name: string): StandardMaterial;
  14188. serialize(): any;
  14189. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14190. static _DiffuseTextureEnabled: boolean;
  14191. static DiffuseTextureEnabled: boolean;
  14192. static _AmbientTextureEnabled: boolean;
  14193. static AmbientTextureEnabled: boolean;
  14194. static _OpacityTextureEnabled: boolean;
  14195. static OpacityTextureEnabled: boolean;
  14196. static _ReflectionTextureEnabled: boolean;
  14197. static ReflectionTextureEnabled: boolean;
  14198. static _EmissiveTextureEnabled: boolean;
  14199. static EmissiveTextureEnabled: boolean;
  14200. static _SpecularTextureEnabled: boolean;
  14201. static SpecularTextureEnabled: boolean;
  14202. static _BumpTextureEnabled: boolean;
  14203. static BumpTextureEnabled: boolean;
  14204. static _LightmapTextureEnabled: boolean;
  14205. static LightmapTextureEnabled: boolean;
  14206. static _RefractionTextureEnabled: boolean;
  14207. static RefractionTextureEnabled: boolean;
  14208. static _ColorGradingTextureEnabled: boolean;
  14209. static ColorGradingTextureEnabled: boolean;
  14210. static _FresnelEnabled: boolean;
  14211. static FresnelEnabled: boolean;
  14212. }
  14213. }
  14214. declare module BABYLON {
  14215. class UniformBuffer {
  14216. private _engine;
  14217. private _buffer;
  14218. private _data;
  14219. private _bufferData;
  14220. private _dynamic?;
  14221. private _uniformLocations;
  14222. private _uniformSizes;
  14223. private _uniformLocationPointer;
  14224. private _needSync;
  14225. private _noUBO;
  14226. private _currentEffect;
  14227. private static _MAX_UNIFORM_SIZE;
  14228. private static _tempBuffer;
  14229. /**
  14230. * Wrapper for updateUniform.
  14231. * @method updateMatrix3x3
  14232. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14233. * @param {Float32Array} matrix
  14234. */
  14235. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14236. /**
  14237. * Wrapper for updateUniform.
  14238. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14239. * @param {Float32Array} matrix
  14240. */
  14241. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14242. /**
  14243. * Wrapper for updateUniform.
  14244. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14245. * @param {number} x
  14246. */
  14247. updateFloat: (name: string, x: number) => void;
  14248. /**
  14249. * Wrapper for updateUniform.
  14250. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14251. * @param {number} x
  14252. * @param {number} y
  14253. * @param {string} [suffix] Suffix to add to the uniform name.
  14254. */
  14255. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14256. /**
  14257. * Wrapper for updateUniform.
  14258. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14259. * @param {number} x
  14260. * @param {number} y
  14261. * @param {number} z
  14262. * @param {string} [suffix] Suffix to add to the uniform name.
  14263. */
  14264. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14265. /**
  14266. * Wrapper for updateUniform.
  14267. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14268. * @param {number} x
  14269. * @param {number} y
  14270. * @param {number} z
  14271. * @param {number} w
  14272. * @param {string} [suffix] Suffix to add to the uniform name.
  14273. */
  14274. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14275. /**
  14276. * Wrapper for updateUniform.
  14277. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14278. * @param {Matrix} A 4x4 matrix.
  14279. */
  14280. updateMatrix: (name: string, mat: Matrix) => void;
  14281. /**
  14282. * Wrapper for updateUniform.
  14283. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14284. * @param {Vector3} vector
  14285. */
  14286. updateVector3: (name: string, vector: Vector3) => void;
  14287. /**
  14288. * Wrapper for updateUniform.
  14289. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14290. * @param {Vector4} vector
  14291. */
  14292. updateVector4: (name: string, vector: Vector4) => void;
  14293. /**
  14294. * Wrapper for updateUniform.
  14295. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14296. * @param {Color3} color
  14297. * @param {string} [suffix] Suffix to add to the uniform name.
  14298. */
  14299. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14300. /**
  14301. * Wrapper for updateUniform.
  14302. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14303. * @param {Color3} color
  14304. * @param {number} alpha
  14305. * @param {string} [suffix] Suffix to add to the uniform name.
  14306. */
  14307. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14308. /**
  14309. * Uniform buffer objects.
  14310. *
  14311. * Handles blocks of uniform on the GPU.
  14312. *
  14313. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14314. *
  14315. * For more information, please refer to :
  14316. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14317. */
  14318. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14319. /**
  14320. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14321. * or just falling back on setUniformXXX calls.
  14322. */
  14323. readonly useUbo: boolean;
  14324. /**
  14325. * Indicates if the WebGL underlying uniform buffer is in sync
  14326. * with the javascript cache data.
  14327. */
  14328. readonly isSync: boolean;
  14329. /**
  14330. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14331. * Also, a dynamic UniformBuffer will disable cache verification and always
  14332. * update the underlying WebGL uniform buffer to the GPU.
  14333. */
  14334. isDynamic(): boolean;
  14335. /**
  14336. * The data cache on JS side.
  14337. */
  14338. getData(): Float32Array;
  14339. /**
  14340. * The underlying WebGL Uniform buffer.
  14341. */
  14342. getBuffer(): Nullable<WebGLBuffer>;
  14343. /**
  14344. * std140 layout specifies how to align data within an UBO structure.
  14345. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14346. * for specs.
  14347. */
  14348. private _fillAlignment(size);
  14349. /**
  14350. * Adds an uniform in the buffer.
  14351. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14352. * for the layout to be correct !
  14353. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14354. * @param {number|number[]} size Data size, or data directly.
  14355. */
  14356. addUniform(name: string, size: number | number[]): void;
  14357. /**
  14358. * Wrapper for addUniform.
  14359. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14360. * @param {Matrix} mat A 4x4 matrix.
  14361. */
  14362. addMatrix(name: string, mat: Matrix): void;
  14363. /**
  14364. * Wrapper for addUniform.
  14365. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14366. * @param {number} x
  14367. * @param {number} y
  14368. */
  14369. addFloat2(name: string, x: number, y: number): void;
  14370. /**
  14371. * Wrapper for addUniform.
  14372. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14373. * @param {number} x
  14374. * @param {number} y
  14375. * @param {number} z
  14376. */
  14377. addFloat3(name: string, x: number, y: number, z: number): void;
  14378. /**
  14379. * Wrapper for addUniform.
  14380. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14381. * @param {Color3} color
  14382. */
  14383. addColor3(name: string, color: Color3): void;
  14384. /**
  14385. * Wrapper for addUniform.
  14386. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14387. * @param {Color3} color
  14388. * @param {number} alpha
  14389. */
  14390. addColor4(name: string, color: Color3, alpha: number): void;
  14391. /**
  14392. * Wrapper for addUniform.
  14393. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14394. * @param {Vector3} vector
  14395. */
  14396. addVector3(name: string, vector: Vector3): void;
  14397. /**
  14398. * Wrapper for addUniform.
  14399. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14400. */
  14401. addMatrix3x3(name: string): void;
  14402. /**
  14403. * Wrapper for addUniform.
  14404. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14405. */
  14406. addMatrix2x2(name: string): void;
  14407. /**
  14408. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14409. */
  14410. create(): void;
  14411. _rebuild(): void;
  14412. /**
  14413. * Updates the WebGL Uniform Buffer on the GPU.
  14414. * If the `dynamic` flag is set to true, no cache comparison is done.
  14415. * Otherwise, the buffer will be updated only if the cache differs.
  14416. */
  14417. update(): void;
  14418. /**
  14419. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14420. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14421. * @param {number[]|Float32Array} data Flattened data
  14422. * @param {number} size Size of the data.
  14423. */
  14424. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14425. private _updateMatrix3x3ForUniform(name, matrix);
  14426. private _updateMatrix3x3ForEffect(name, matrix);
  14427. private _updateMatrix2x2ForEffect(name, matrix);
  14428. private _updateMatrix2x2ForUniform(name, matrix);
  14429. private _updateFloatForEffect(name, x);
  14430. private _updateFloatForUniform(name, x);
  14431. private _updateFloat2ForEffect(name, x, y, suffix?);
  14432. private _updateFloat2ForUniform(name, x, y, suffix?);
  14433. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14434. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14435. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14436. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14437. private _updateMatrixForEffect(name, mat);
  14438. private _updateMatrixForUniform(name, mat);
  14439. private _updateVector3ForEffect(name, vector);
  14440. private _updateVector3ForUniform(name, vector);
  14441. private _updateVector4ForEffect(name, vector);
  14442. private _updateVector4ForUniform(name, vector);
  14443. private _updateColor3ForEffect(name, color, suffix?);
  14444. private _updateColor3ForUniform(name, color, suffix?);
  14445. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14446. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14447. /**
  14448. * Sets a sampler uniform on the effect.
  14449. * @param {string} name Name of the sampler.
  14450. * @param {Texture} texture
  14451. */
  14452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14453. /**
  14454. * Directly updates the value of the uniform in the cache AND on the GPU.
  14455. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14456. * @param {number[]|Float32Array} data Flattened data
  14457. */
  14458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14459. /**
  14460. * Binds this uniform buffer to an effect.
  14461. * @param {Effect} effect
  14462. * @param {string} name Name of the uniform block in the shader.
  14463. */
  14464. bindToEffect(effect: Effect, name: string): void;
  14465. /**
  14466. * Disposes the uniform buffer.
  14467. */
  14468. dispose(): void;
  14469. }
  14470. }
  14471. declare module BABYLON {
  14472. interface ILoadingScreen {
  14473. displayLoadingUI: () => void;
  14474. hideLoadingUI: () => void;
  14475. loadingUIBackgroundColor: string;
  14476. loadingUIText: string;
  14477. }
  14478. class DefaultLoadingScreen implements ILoadingScreen {
  14479. private _renderingCanvas;
  14480. private _loadingText;
  14481. private _loadingDivBackgroundColor;
  14482. private _loadingDiv;
  14483. private _loadingTextDiv;
  14484. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  14485. displayLoadingUI(): void;
  14486. hideLoadingUI(): void;
  14487. loadingUIText: string;
  14488. loadingUIBackgroundColor: string;
  14489. private _resizeLoadingUI;
  14490. }
  14491. }
  14492. declare module BABYLON {
  14493. class SceneLoaderProgressEvent {
  14494. readonly lengthComputable: boolean;
  14495. readonly loaded: number;
  14496. readonly total: number;
  14497. constructor(lengthComputable: boolean, loaded: number, total: number);
  14498. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  14499. }
  14500. interface ISceneLoaderPluginExtensions {
  14501. [extension: string]: {
  14502. isBinary: boolean;
  14503. };
  14504. }
  14505. interface ISceneLoaderPluginFactory {
  14506. name: string;
  14507. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  14508. canDirectLoad?: (data: string) => boolean;
  14509. }
  14510. interface ISceneLoaderPlugin {
  14511. /**
  14512. * The friendly name of this plugin.
  14513. */
  14514. name: string;
  14515. /**
  14516. * The file extensions supported by this plugin.
  14517. */
  14518. extensions: string | ISceneLoaderPluginExtensions;
  14519. /**
  14520. * Import meshes into a scene.
  14521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  14522. * @param scene The scene to import into
  14523. * @param data The data to import
  14524. * @param rootUrl The root url for scene and resources
  14525. * @param meshes The meshes array to import into
  14526. * @param particleSystems The particle systems array to import into
  14527. * @param skeletons The skeletons array to import into
  14528. * @param onError The callback when import fails
  14529. * @returns True if successful or false otherwise
  14530. */
  14531. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  14532. /**
  14533. * Load into a scene.
  14534. * @param scene The scene to load into
  14535. * @param data The data to import
  14536. * @param rootUrl The root url for scene and resources
  14537. * @param onError The callback when import fails
  14538. * @returns true if successful or false otherwise
  14539. */
  14540. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  14541. /**
  14542. * The callback that returns true if the data can be directly loaded.
  14543. */
  14544. canDirectLoad?: (data: string) => boolean;
  14545. /**
  14546. * The callback that allows custom handling of the root url based on the response url.
  14547. */
  14548. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  14549. /**
  14550. * Load into an asset container.
  14551. * @param scene The scene to load into
  14552. * @param data The data to import
  14553. * @param rootUrl The root url for scene and resources
  14554. * @param onError The callback when import fails
  14555. * @returns The loaded asset container
  14556. */
  14557. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  14558. }
  14559. interface ISceneLoaderPluginAsync {
  14560. /**
  14561. * The friendly name of this plugin.
  14562. */
  14563. name: string;
  14564. /**
  14565. * The file extensions supported by this plugin.
  14566. */
  14567. extensions: string | ISceneLoaderPluginExtensions;
  14568. /**
  14569. * Import meshes into a scene.
  14570. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  14571. * @param scene The scene to import into
  14572. * @param data The data to import
  14573. * @param rootUrl The root url for scene and resources
  14574. * @param onProgress The callback when the load progresses
  14575. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  14576. */
  14577. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  14578. meshes: AbstractMesh[];
  14579. particleSystems: ParticleSystem[];
  14580. skeletons: Skeleton[];
  14581. animationGroups: AnimationGroup[];
  14582. }>;
  14583. /**
  14584. * Load into a scene.
  14585. * @param scene The scene to load into
  14586. * @param data The data to import
  14587. * @param rootUrl The root url for scene and resources
  14588. * @param onProgress The callback when the load progresses
  14589. * @returns Nothing
  14590. */
  14591. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  14592. /**
  14593. * The callback that returns true if the data can be directly loaded.
  14594. */
  14595. canDirectLoad?: (data: string) => boolean;
  14596. /**
  14597. * The callback that allows custom handling of the root url based on the response url.
  14598. */
  14599. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  14600. /**
  14601. * Load into an asset container.
  14602. * @param scene The scene to load into
  14603. * @param data The data to import
  14604. * @param rootUrl The root url for scene and resources
  14605. * @param onProgress The callback when the load progresses
  14606. * @returns The loaded asset container
  14607. */
  14608. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  14609. }
  14610. class SceneLoader {
  14611. private static _ForceFullSceneLoadingForIncremental;
  14612. private static _ShowLoadingScreen;
  14613. private static _CleanBoneMatrixWeights;
  14614. static readonly NO_LOGGING: number;
  14615. static readonly MINIMAL_LOGGING: number;
  14616. static readonly SUMMARY_LOGGING: number;
  14617. static readonly DETAILED_LOGGING: number;
  14618. private static _loggingLevel;
  14619. static ForceFullSceneLoadingForIncremental: boolean;
  14620. static ShowLoadingScreen: boolean;
  14621. static loggingLevel: number;
  14622. static CleanBoneMatrixWeights: boolean;
  14623. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  14624. private static _registeredPlugins;
  14625. private static _getDefaultPlugin();
  14626. private static _getPluginForExtension(extension);
  14627. private static _getPluginForDirectLoad(data);
  14628. private static _getPluginForFilename(sceneFilename);
  14629. private static _getDirectLoad(sceneFilename);
  14630. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  14631. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  14632. static IsPluginForExtensionAvailable(extension: string): boolean;
  14633. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  14634. /**
  14635. * Import meshes into a scene
  14636. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  14637. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14638. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14639. * @param scene the instance of BABYLON.Scene to append to
  14640. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  14641. * @param onProgress a callback with a progress event for each file being loaded
  14642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  14643. * @param pluginExtension the extension used to determine the plugin
  14644. * @returns The loaded plugin
  14645. */
  14646. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<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>;
  14647. /**
  14648. * Import meshes into a scene
  14649. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  14650. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14651. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14652. * @param scene the instance of BABYLON.Scene to append to
  14653. * @param onProgress a callback with a progress event for each file being loaded
  14654. * @param pluginExtension the extension used to determine the plugin
  14655. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  14656. */
  14657. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  14658. meshes: AbstractMesh[];
  14659. particleSystems: ParticleSystem[];
  14660. skeletons: Skeleton[];
  14661. animationGroups: AnimationGroup[];
  14662. }>;
  14663. /**
  14664. * Load a scene
  14665. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14666. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14667. * @param engine is the instance of BABYLON.Engine to use to create the scene
  14668. * @param onSuccess a callback with the scene when import succeeds
  14669. * @param onProgress a callback with a progress event for each file being loaded
  14670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  14671. * @param pluginExtension the extension used to determine the plugin
  14672. * @returns The loaded plugin
  14673. */
  14674. 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>;
  14675. /**
  14676. * Load a scene
  14677. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14678. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14679. * @param engine is the instance of BABYLON.Engine to use to create the scene
  14680. * @param onProgress a callback with a progress event for each file being loaded
  14681. * @param pluginExtension the extension used to determine the plugin
  14682. * @returns The loaded scene
  14683. */
  14684. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  14685. /**
  14686. * Append a scene
  14687. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14688. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14689. * @param scene is the instance of BABYLON.Scene to append to
  14690. * @param onSuccess a callback with the scene when import succeeds
  14691. * @param onProgress a callback with a progress event for each file being loaded
  14692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  14693. * @param pluginExtension the extension used to determine the plugin
  14694. * @returns The loaded plugin
  14695. */
  14696. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  14697. /**
  14698. * Append a scene
  14699. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14700. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14701. * @param scene is the instance of BABYLON.Scene to append to
  14702. * @param onProgress a callback with a progress event for each file being loaded
  14703. * @param pluginExtension the extension used to determine the plugin
  14704. * @returns The given scene
  14705. */
  14706. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  14707. /**
  14708. * Load a scene into an asset container
  14709. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14710. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14711. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  14712. * @param onSuccess a callback with the scene when import succeeds
  14713. * @param onProgress a callback with a progress event for each file being loaded
  14714. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  14715. * @param pluginExtension the extension used to determine the plugin
  14716. * @returns The loaded plugin
  14717. */
  14718. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  14719. /**
  14720. * Load a scene into an asset container
  14721. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  14722. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  14723. * @param scene is the instance of BABYLON.Scene to append to
  14724. * @param onProgress a callback with a progress event for each file being loaded
  14725. * @param pluginExtension the extension used to determine the plugin
  14726. * @returns The loaded asset container
  14727. */
  14728. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  14729. }
  14730. }
  14731. declare module BABYLON {
  14732. class Scalar {
  14733. /**
  14734. * Two pi constants convenient for computation.
  14735. */
  14736. static TwoPi: number;
  14737. /**
  14738. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14739. */
  14740. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14741. /**
  14742. * Returns a string : the upper case translation of the number i to hexadecimal.
  14743. */
  14744. static ToHex(i: number): string;
  14745. /**
  14746. * Returns -1 if value is negative and +1 is value is positive.
  14747. * Returns the value itself if it's equal to zero.
  14748. */
  14749. static Sign(value: number): number;
  14750. /**
  14751. * Returns the value itself if it's between min and max.
  14752. * Returns min if the value is lower than min.
  14753. * Returns max if the value is greater than max.
  14754. */
  14755. static Clamp(value: number, min?: number, max?: number): number;
  14756. /**
  14757. * Returns the log2 of value.
  14758. */
  14759. static Log2(value: number): number;
  14760. /**
  14761. * Loops the value, so that it is never larger than length and never smaller than 0.
  14762. *
  14763. * This is similar to the modulo operator but it works with floating point numbers.
  14764. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14765. * With t = 5 and length = 2.5, the result would be 0.0.
  14766. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14767. */
  14768. static Repeat(value: number, length: number): number;
  14769. /**
  14770. * Normalize the value between 0.0 and 1.0 using min and max values
  14771. */
  14772. static Normalize(value: number, min: number, max: number): number;
  14773. /**
  14774. * Denormalize the value from 0.0 and 1.0 using min and max values
  14775. */
  14776. static Denormalize(normalized: number, min: number, max: number): number;
  14777. /**
  14778. * Calculates the shortest difference between two given angles given in degrees.
  14779. */
  14780. static DeltaAngle(current: number, target: number): number;
  14781. /**
  14782. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14783. *
  14784. * The returned value will move back and forth between 0 and length
  14785. */
  14786. static PingPong(tx: number, length: number): number;
  14787. /**
  14788. * Interpolates between min and max with smoothing at the limits.
  14789. *
  14790. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14791. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14792. */
  14793. static SmoothStep(from: number, to: number, tx: number): number;
  14794. /**
  14795. * Moves a value current towards target.
  14796. *
  14797. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14798. * Negative values of maxDelta pushes the value away from target.
  14799. */
  14800. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14801. /**
  14802. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14803. *
  14804. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14805. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14806. */
  14807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14808. /**
  14809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14810. */
  14811. static Lerp(start: number, end: number, amount: number): number;
  14812. /**
  14813. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14814. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14815. */
  14816. static LerpAngle(start: number, end: number, amount: number): number;
  14817. /**
  14818. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14819. */
  14820. static InverseLerp(a: number, b: number, value: number): number;
  14821. /**
  14822. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14823. */
  14824. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14825. /**
  14826. * Returns a random float number between and min and max values
  14827. */
  14828. static RandomRange(min: number, max: number): number;
  14829. /**
  14830. * This function returns percentage of a number in a given range.
  14831. *
  14832. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14833. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14834. */
  14835. static RangeToPercent(number: number, min: number, max: number): number;
  14836. /**
  14837. * This function returns number that corresponds to the percentage in a given range.
  14838. *
  14839. * PercentToRange(0.34,0,100) will return 34.
  14840. */
  14841. static PercentToRange(percent: number, min: number, max: number): number;
  14842. /**
  14843. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14844. * @param angle The angle to normalize in radian.
  14845. * @return The converted angle.
  14846. */
  14847. static NormalizeRadians(angle: number): number;
  14848. }
  14849. }
  14850. declare module BABYLON {
  14851. const ToGammaSpace: number;
  14852. const ToLinearSpace = 2.2;
  14853. const Epsilon = 0.001;
  14854. /**
  14855. * Class used to hold a RBG color
  14856. */
  14857. class Color3 {
  14858. /**
  14859. * Defines the red component (between 0 and 1, default is 0)
  14860. */
  14861. r: number;
  14862. /**
  14863. * Defines the green component (between 0 and 1, default is 0)
  14864. */
  14865. g: number;
  14866. /**
  14867. * Defines the blue component (between 0 and 1, default is 0)
  14868. */
  14869. b: number;
  14870. /**
  14871. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14872. * @param r defines the red component (between 0 and 1, default is 0)
  14873. * @param g defines the green component (between 0 and 1, default is 0)
  14874. * @param b defines the blue component (between 0 and 1, default is 0)
  14875. */
  14876. constructor(
  14877. /**
  14878. * Defines the red component (between 0 and 1, default is 0)
  14879. */
  14880. r?: number,
  14881. /**
  14882. * Defines the green component (between 0 and 1, default is 0)
  14883. */
  14884. g?: number,
  14885. /**
  14886. * Defines the blue component (between 0 and 1, default is 0)
  14887. */
  14888. b?: number);
  14889. /**
  14890. * Creates a string with the Color3 current values
  14891. * @returns the string representation of the Color3 object
  14892. */
  14893. toString(): string;
  14894. /**
  14895. * Returns the string "Color3"
  14896. * @returns "Color3"
  14897. */
  14898. getClassName(): string;
  14899. /**
  14900. * Compute the Color3 hash code
  14901. * @returns an unique number that can be used to hash Color3 objects
  14902. */
  14903. getHashCode(): number;
  14904. /**
  14905. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14906. * @param array defines the array where to store the r,g,b components
  14907. * @param index defines an optional index in the target array to define where to start storing values
  14908. * @returns the current Color3 object
  14909. */
  14910. toArray(array: FloatArray, index?: number): Color3;
  14911. /**
  14912. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14913. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14914. * @returns a new {BABYLON.Color4} object
  14915. */
  14916. toColor4(alpha?: number): Color4;
  14917. /**
  14918. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14919. * @returns the new array
  14920. */
  14921. asArray(): number[];
  14922. /**
  14923. * Returns the luminance value
  14924. * @returns a float value
  14925. */
  14926. toLuminance(): number;
  14927. /**
  14928. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14929. * @param otherColor defines the second operand
  14930. * @returns the new Color3 object
  14931. */
  14932. multiply(otherColor: Color3): Color3;
  14933. /**
  14934. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14935. * @param otherColor defines the second operand
  14936. * @param result defines the Color3 object where to store the result
  14937. * @returns the current Color3
  14938. */
  14939. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14940. /**
  14941. * Determines equality between Color3 objects
  14942. * @param otherColor defines the second operand
  14943. * @returns true if the rgb values are equal to the given ones
  14944. */
  14945. equals(otherColor: Color3): boolean;
  14946. /**
  14947. * Determines equality between the current Color3 object and a set of r,b,g values
  14948. * @param r defines the red component to check
  14949. * @param g defines the green component to check
  14950. * @param b defines the blue component to check
  14951. * @returns true if the rgb values are equal to the given ones
  14952. */
  14953. equalsFloats(r: number, g: number, b: number): boolean;
  14954. /**
  14955. * Multiplies in place each rgb value by scale
  14956. * @param scale defines the scaling factor
  14957. * @returns the updated Color3
  14958. */
  14959. scale(scale: number): Color3;
  14960. /**
  14961. * Multiplies the rgb values by scale and stores the result into "result"
  14962. * @param scale defines the scaling factor
  14963. * @param result defines the Color3 object where to store the result
  14964. * @returns the unmodified current Color3
  14965. */
  14966. scaleToRef(scale: number, result: Color3): Color3;
  14967. /**
  14968. * Scale the current Color3 values by a factor and add the result to a given Color3
  14969. * @param scale defines the scale factor
  14970. * @param result defines color to store the result into
  14971. * @returns the unmodified current Color3
  14972. */
  14973. scaleAndAddToRef(scale: number, result: Color3): Color3;
  14974. /**
  14975. * Clamps the rgb values by the min and max values and stores the result into "result"
  14976. * @param min defines minimum clamping value (default is 0)
  14977. * @param max defines maximum clamping value (default is 1)
  14978. * @param result defines color to store the result into
  14979. * @returns the original Color3
  14980. */
  14981. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14982. /**
  14983. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  14984. * @param otherColor defines the second operand
  14985. * @returns the new Color3
  14986. */
  14987. add(otherColor: Color3): Color3;
  14988. /**
  14989. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  14990. * @param otherColor defines the second operand
  14991. * @param result defines Color3 object to store the result into
  14992. * @returns the unmodified current Color3
  14993. */
  14994. addToRef(otherColor: Color3, result: Color3): Color3;
  14995. /**
  14996. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  14997. * @param otherColor defines the second operand
  14998. * @returns the new Color3
  14999. */
  15000. subtract(otherColor: Color3): Color3;
  15001. /**
  15002. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15003. * @param otherColor defines the second operand
  15004. * @param result defines Color3 object to store the result into
  15005. * @returns the unmodified current Color3
  15006. */
  15007. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15008. /**
  15009. * Copy the current object
  15010. * @returns a new Color3 copied the current one
  15011. */
  15012. clone(): Color3;
  15013. /**
  15014. * Copies the rgb values from the source in the current Color3
  15015. * @param source defines the source Color3 object
  15016. * @returns the updated Color3 object
  15017. */
  15018. copyFrom(source: Color3): Color3;
  15019. /**
  15020. * Updates the Color3 rgb values from the given floats
  15021. * @param r defines the red component to read from
  15022. * @param g defines the green component to read from
  15023. * @param b defines the blue component to read from
  15024. * @returns the current Color3 object
  15025. */
  15026. copyFromFloats(r: number, g: number, b: number): Color3;
  15027. /**
  15028. * Updates the Color3 rgb values from the given floats
  15029. * @param r defines the red component to read from
  15030. * @param g defines the green component to read from
  15031. * @param b defines the blue component to read from
  15032. * @returns the current Color3 object
  15033. */
  15034. set(r: number, g: number, b: number): Color3;
  15035. /**
  15036. * Compute the Color3 hexadecimal code as a string
  15037. * @returns a string containing the hexadecimal representation of the Color3 object
  15038. */
  15039. toHexString(): string;
  15040. /**
  15041. * Computes a new Color3 converted from the current one to linear space
  15042. * @returns a new Color3 object
  15043. */
  15044. toLinearSpace(): Color3;
  15045. /**
  15046. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15047. * @param convertedColor defines the Color3 object where to store the linear space version
  15048. * @returns the unmodified Color3
  15049. */
  15050. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15051. /**
  15052. * Computes a new Color3 converted from the current one to gamma space
  15053. * @returns a new Color3 object
  15054. */
  15055. toGammaSpace(): Color3;
  15056. /**
  15057. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15058. * @param convertedColor defines the Color3 object where to store the gamma space version
  15059. * @returns the unmodified Color3
  15060. */
  15061. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15062. /**
  15063. * Creates a new Color3 from the string containing valid hexadecimal values
  15064. * @param hex defines a string containing valid hexadecimal values
  15065. * @returns a new Color3 object
  15066. */
  15067. static FromHexString(hex: string): Color3;
  15068. /**
  15069. * Creates a new Vector3 from the starting index of the given array
  15070. * @param array defines the source array
  15071. * @param offset defines an offset in the source array
  15072. * @returns a new Color3 object
  15073. */
  15074. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15075. /**
  15076. * Creates a new Color3 from integer values (< 256)
  15077. * @param r defines the red component to read from (value between 0 and 255)
  15078. * @param g defines the green component to read from (value between 0 and 255)
  15079. * @param b defines the blue component to read from (value between 0 and 255)
  15080. * @returns a new Color3 object
  15081. */
  15082. static FromInts(r: number, g: number, b: number): Color3;
  15083. /**
  15084. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15085. * @param start defines the start Color3 value
  15086. * @param end defines the end Color3 value
  15087. * @param amount defines the gradient value between start and end
  15088. * @returns a new Color3 object
  15089. */
  15090. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15091. /**
  15092. * Returns a Color3 value containing a red color
  15093. * @returns a new Color3 object
  15094. */
  15095. static Red(): Color3;
  15096. /**
  15097. * Returns a Color3 value containing a green color
  15098. * @returns a new Color3 object
  15099. */
  15100. static Green(): Color3;
  15101. /**
  15102. * Returns a Color3 value containing a blue color
  15103. * @returns a new Color3 object
  15104. */
  15105. static Blue(): Color3;
  15106. /**
  15107. * Returns a Color3 value containing a black color
  15108. * @returns a new Color3 object
  15109. */
  15110. static Black(): Color3;
  15111. /**
  15112. * Returns a Color3 value containing a white color
  15113. * @returns a new Color3 object
  15114. */
  15115. static White(): Color3;
  15116. /**
  15117. * Returns a Color3 value containing a purple color
  15118. * @returns a new Color3 object
  15119. */
  15120. static Purple(): Color3;
  15121. /**
  15122. * Returns a Color3 value containing a magenta color
  15123. * @returns a new Color3 object
  15124. */
  15125. static Magenta(): Color3;
  15126. /**
  15127. * Returns a Color3 value containing a yellow color
  15128. * @returns a new Color3 object
  15129. */
  15130. static Yellow(): Color3;
  15131. /**
  15132. * Returns a Color3 value containing a gray color
  15133. * @returns a new Color3 object
  15134. */
  15135. static Gray(): Color3;
  15136. /**
  15137. * Returns a Color3 value containing a teal color
  15138. * @returns a new Color3 object
  15139. */
  15140. static Teal(): Color3;
  15141. /**
  15142. * Returns a Color3 value containing a random color
  15143. * @returns a new Color3 object
  15144. */
  15145. static Random(): Color3;
  15146. }
  15147. /**
  15148. * Class used to hold a RBGA color
  15149. */
  15150. class Color4 {
  15151. /**
  15152. * Defines the red component (between 0 and 1, default is 0)
  15153. */
  15154. r: number;
  15155. /**
  15156. * Defines the green component (between 0 and 1, default is 0)
  15157. */
  15158. g: number;
  15159. /**
  15160. * Defines the blue component (between 0 and 1, default is 0)
  15161. */
  15162. b: number;
  15163. /**
  15164. * Defines the alpha component (between 0 and 1, default is 1)
  15165. */
  15166. a: number;
  15167. /**
  15168. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15169. * @param r defines the red component (between 0 and 1, default is 0)
  15170. * @param g defines the green component (between 0 and 1, default is 0)
  15171. * @param b defines the blue component (between 0 and 1, default is 0)
  15172. * @param a defines the alpha component (between 0 and 1, default is 1)
  15173. */
  15174. constructor(
  15175. /**
  15176. * Defines the red component (between 0 and 1, default is 0)
  15177. */
  15178. r?: number,
  15179. /**
  15180. * Defines the green component (between 0 and 1, default is 0)
  15181. */
  15182. g?: number,
  15183. /**
  15184. * Defines the blue component (between 0 and 1, default is 0)
  15185. */
  15186. b?: number,
  15187. /**
  15188. * Defines the alpha component (between 0 and 1, default is 1)
  15189. */
  15190. a?: number);
  15191. /**
  15192. * Adds in place the given Color4 values to the current Color4 object
  15193. * @param right defines the second operand
  15194. * @returns the current updated Color4 object
  15195. */
  15196. addInPlace(right: Color4): Color4;
  15197. /**
  15198. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15199. * @returns the new array
  15200. */
  15201. asArray(): number[];
  15202. /**
  15203. * Stores from the starting index in the given array the Color4 successive values
  15204. * @param array defines the array where to store the r,g,b components
  15205. * @param index defines an optional index in the target array to define where to start storing values
  15206. * @returns the current Color4 object
  15207. */
  15208. toArray(array: number[], index?: number): Color4;
  15209. /**
  15210. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15211. * @param right defines the second operand
  15212. * @returns a new Color4 object
  15213. */
  15214. add(right: Color4): Color4;
  15215. /**
  15216. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15217. * @param right defines the second operand
  15218. * @returns a new Color4 object
  15219. */
  15220. subtract(right: Color4): Color4;
  15221. /**
  15222. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15223. * @param right defines the second operand
  15224. * @param result defines the Color4 object where to store the result
  15225. * @returns the current Color4 object
  15226. */
  15227. subtractToRef(right: Color4, result: Color4): Color4;
  15228. /**
  15229. * Creates a new Color4 with the current Color4 values multiplied by scale
  15230. * @param scale defines the scaling factor to apply
  15231. * @returns a new Color4 object
  15232. */
  15233. scale(scale: number): Color4;
  15234. /**
  15235. * Multiplies the current Color4 values by scale and stores the result in "result"
  15236. * @param scale defines the scaling factor to apply
  15237. * @param result defines the Color4 object where to store the result
  15238. * @returns the current unmodified Color4
  15239. */
  15240. scaleToRef(scale: number, result: Color4): Color4;
  15241. /**
  15242. * Scale the current Color4 values by a factor and add the result to a given Color4
  15243. * @param scale defines the scale factor
  15244. * @param result defines the Color4 object where to store the result
  15245. * @returns the unmodified current Color4
  15246. */
  15247. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15248. /**
  15249. * Clamps the rgb values by the min and max values and stores the result into "result"
  15250. * @param min defines minimum clamping value (default is 0)
  15251. * @param max defines maximum clamping value (default is 1)
  15252. * @param result defines color to store the result into.
  15253. * @returns the cuurent Color4
  15254. */
  15255. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15256. /**
  15257. * Multipy an Color4 value by another and return a new Color4 object
  15258. * @param color defines the Color4 value to multiply by
  15259. * @returns a new Color4 object
  15260. */
  15261. multiply(color: Color4): Color4;
  15262. /**
  15263. * Multipy a Color4 value by another and push the result in a reference value
  15264. * @param color defines the Color4 value to multiply by
  15265. * @param result defines the Color4 to fill the result in
  15266. * @returns the result Color4
  15267. */
  15268. multiplyToRef(color: Color4, result: Color4): Color4;
  15269. /**
  15270. * Creates a string with the Color4 current values
  15271. * @returns the string representation of the Color4 object
  15272. */
  15273. toString(): string;
  15274. /**
  15275. * Returns the string "Color4"
  15276. * @returns "Color4"
  15277. */
  15278. getClassName(): string;
  15279. /**
  15280. * Compute the Color4 hash code
  15281. * @returns an unique number that can be used to hash Color4 objects
  15282. */
  15283. getHashCode(): number;
  15284. /**
  15285. * Creates a new Color4 copied from the current one
  15286. * @returns a new Color4 object
  15287. */
  15288. clone(): Color4;
  15289. /**
  15290. * Copies the given Color4 values into the current one
  15291. * @param source defines the source Color4 object
  15292. * @returns the current updated Color4 object
  15293. */
  15294. copyFrom(source: Color4): Color4;
  15295. /**
  15296. * Copies the given float values into the current one
  15297. * @param r defines the red component to read from
  15298. * @param g defines the green component to read from
  15299. * @param b defines the blue component to read from
  15300. * @param a defines the alpha component to read from
  15301. * @returns the current updated Color4 object
  15302. */
  15303. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15304. /**
  15305. * Copies the given float values into the current one
  15306. * @param r defines the red component to read from
  15307. * @param g defines the green component to read from
  15308. * @param b defines the blue component to read from
  15309. * @param a defines the alpha component to read from
  15310. * @returns the current updated Color4 object
  15311. */
  15312. set(r: number, g: number, b: number, a: number): Color4;
  15313. /**
  15314. * Compute the Color4 hexadecimal code as a string
  15315. * @returns a string containing the hexadecimal representation of the Color4 object
  15316. */
  15317. toHexString(): string;
  15318. /**
  15319. * Computes a new Color4 converted from the current one to linear space
  15320. * @returns a new Color4 object
  15321. */
  15322. toLinearSpace(): Color4;
  15323. /**
  15324. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15325. * @param convertedColor defines the Color4 object where to store the linear space version
  15326. * @returns the unmodified Color4
  15327. */
  15328. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15329. /**
  15330. * Computes a new Color4 converted from the current one to gamma space
  15331. * @returns a new Color4 object
  15332. */
  15333. toGammaSpace(): Color4;
  15334. /**
  15335. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15336. * @param convertedColor defines the Color4 object where to store the gamma space version
  15337. * @returns the unmodified Color4
  15338. */
  15339. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15340. /**
  15341. * Creates a new Color4 from the string containing valid hexadecimal values
  15342. * @param hex defines a string containing valid hexadecimal values
  15343. * @returns a new Color4 object
  15344. */
  15345. static FromHexString(hex: string): Color4;
  15346. /**
  15347. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15348. * @param left defines the start value
  15349. * @param right defines the end value
  15350. * @param amount defines the gradient factor
  15351. * @returns a new Color4 object
  15352. */
  15353. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15354. /**
  15355. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15356. * @param left defines the start value
  15357. * @param right defines the end value
  15358. * @param amount defines the gradient factor
  15359. * @param result defines the Color4 object where to store data
  15360. */
  15361. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15362. /**
  15363. * Creates a new Color4 from the starting index element of the given array
  15364. * @param array defines the source array to read from
  15365. * @param offset defines the offset in the source array
  15366. * @returns a new Color4 object
  15367. */
  15368. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15369. /**
  15370. * Creates a new Color3 from integer values (< 256)
  15371. * @param r defines the red component to read from (value between 0 and 255)
  15372. * @param g defines the green component to read from (value between 0 and 255)
  15373. * @param b defines the blue component to read from (value between 0 and 255)
  15374. * @param a defines the alpha component to read from (value between 0 and 255)
  15375. * @returns a new Color3 object
  15376. */
  15377. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15378. /**
  15379. * Check the content of a given array and convert it to an array containing RGBA data
  15380. * If the original array was already containing count * 4 values then it is returned directly
  15381. * @param colors defines the array to check
  15382. * @param count defines the number of RGBA data to expect
  15383. * @returns an array containing count * 4 values (RGBA)
  15384. */
  15385. static CheckColors4(colors: number[], count: number): number[];
  15386. }
  15387. /**
  15388. * Class representing a vector containing 2 coordinates
  15389. */
  15390. class Vector2 {
  15391. /** defines the first coordinate */
  15392. x: number;
  15393. /** defines the second coordinate */
  15394. y: number;
  15395. /**
  15396. * Creates a new Vector2 from the given x and y coordinates
  15397. * @param x defines the first coordinate
  15398. * @param y defines the second coordinate
  15399. */
  15400. constructor(
  15401. /** defines the first coordinate */
  15402. x: number,
  15403. /** defines the second coordinate */
  15404. y: number);
  15405. /**
  15406. * Gets a string with the Vector2 coordinates
  15407. * @returns a string with the Vector2 coordinates
  15408. */
  15409. toString(): string;
  15410. /**
  15411. * Gets class name
  15412. * @returns the string "Vector2"
  15413. */
  15414. getClassName(): string;
  15415. /**
  15416. * Gets current vector hash code
  15417. * @returns the Vector2 hash code as a number
  15418. */
  15419. getHashCode(): number;
  15420. /**
  15421. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15422. * @param array defines the source array
  15423. * @param index defines the offset in source array
  15424. * @returns the current Vector2
  15425. */
  15426. toArray(array: FloatArray, index?: number): Vector2;
  15427. /**
  15428. * Copy the current vector to an array
  15429. * @returns a new array with 2 elements: the Vector2 coordinates.
  15430. */
  15431. asArray(): number[];
  15432. /**
  15433. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15434. * @param source defines the source Vector2
  15435. * @returns the current updated Vector2
  15436. */
  15437. copyFrom(source: Vector2): Vector2;
  15438. /**
  15439. * Sets the Vector2 coordinates with the given floats
  15440. * @param x defines the first coordinate
  15441. * @param y defines the second coordinate
  15442. * @returns the current updated Vector2
  15443. */
  15444. copyFromFloats(x: number, y: number): Vector2;
  15445. /**
  15446. * Sets the Vector2 coordinates with the given floats
  15447. * @param x defines the first coordinate
  15448. * @param y defines the second coordinate
  15449. * @returns the current updated Vector2
  15450. */
  15451. set(x: number, y: number): Vector2;
  15452. /**
  15453. * Add another vector with the current one
  15454. * @param otherVector defines the other vector
  15455. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15456. */
  15457. add(otherVector: Vector2): Vector2;
  15458. /**
  15459. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15460. * @param otherVector defines the other vector
  15461. * @param result defines the target vector
  15462. * @returns the unmodified current Vector2
  15463. */
  15464. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15465. /**
  15466. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15467. * @param otherVector defines the other vector
  15468. * @returns the current updated Vector2
  15469. */
  15470. addInPlace(otherVector: Vector2): Vector2;
  15471. /**
  15472. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15473. * @param otherVector defines the other vector
  15474. * @returns a new Vector2
  15475. */
  15476. addVector3(otherVector: Vector3): Vector2;
  15477. /**
  15478. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15479. * @param otherVector defines the other vector
  15480. * @returns a new Vector2
  15481. */
  15482. subtract(otherVector: Vector2): Vector2;
  15483. /**
  15484. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15485. * @param otherVector defines the other vector
  15486. * @param result defines the target vector
  15487. * @returns the unmodified current Vector2
  15488. */
  15489. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15490. /**
  15491. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15492. * @param otherVector defines the other vector
  15493. * @returns the current updated Vector2
  15494. */
  15495. subtractInPlace(otherVector: Vector2): Vector2;
  15496. /**
  15497. * Multiplies in place the current Vector2 coordinates by the given ones
  15498. * @param otherVector defines the other vector
  15499. * @returns the current updated Vector2
  15500. */
  15501. multiplyInPlace(otherVector: Vector2): Vector2;
  15502. /**
  15503. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15504. * @param otherVector defines the other vector
  15505. * @returns a new Vector2
  15506. */
  15507. multiply(otherVector: Vector2): Vector2;
  15508. /**
  15509. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15510. * @param otherVector defines the other vector
  15511. * @param result defines the target vector
  15512. * @returns the unmodified current Vector2
  15513. */
  15514. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15515. /**
  15516. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15517. * @param x defines the first coordinate
  15518. * @param y defines the second coordinate
  15519. * @returns a new Vector2
  15520. */
  15521. multiplyByFloats(x: number, y: number): Vector2;
  15522. /**
  15523. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15524. * @param otherVector defines the other vector
  15525. * @returns a new Vector2
  15526. */
  15527. divide(otherVector: Vector2): Vector2;
  15528. /**
  15529. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15530. * @param otherVector defines the other vector
  15531. * @param result defines the target vector
  15532. * @returns the unmodified current Vector2
  15533. */
  15534. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15535. /**
  15536. * Divides the current Vector3 coordinates by the given ones
  15537. * @param otherVector defines the other vector
  15538. * @returns the current updated Vector2
  15539. */
  15540. divideInPlace(otherVector: Vector2): Vector2;
  15541. /**
  15542. * Gets a new Vector2 with current Vector2 negated coordinates
  15543. * @returns a new Vector2
  15544. */
  15545. negate(): Vector2;
  15546. /**
  15547. * Multiply the Vector2 coordinates by scale
  15548. * @param scale defines the scaling factor
  15549. * @returns the current updated Vector2
  15550. */
  15551. scaleInPlace(scale: number): Vector2;
  15552. /**
  15553. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15554. * @param scale defines the scaling factor
  15555. * @returns a new Vector2
  15556. */
  15557. scale(scale: number): Vector2;
  15558. /**
  15559. * Scale the current Vector2 values by a factor to a given Vector2
  15560. * @param scale defines the scale factor
  15561. * @param result defines the Vector2 object where to store the result
  15562. * @returns the unmodified current Vector2
  15563. */
  15564. scaleToRef(scale: number, result: Vector2): Vector2;
  15565. /**
  15566. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15567. * @param scale defines the scale factor
  15568. * @param result defines the Vector2 object where to store the result
  15569. * @returns the unmodified current Vector2
  15570. */
  15571. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15572. /**
  15573. * Gets a boolean if two vectors are equals
  15574. * @param otherVector defines the other vector
  15575. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15576. */
  15577. equals(otherVector: Vector2): boolean;
  15578. /**
  15579. * Gets a boolean if two vectors are equals (using an epsilon value)
  15580. * @param otherVector defines the other vector
  15581. * @param epsilon defines the minimal distance to consider equality
  15582. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15583. */
  15584. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15585. /**
  15586. * Gets the length of the vector
  15587. * @returns the vector length (float)
  15588. */
  15589. length(): number;
  15590. /**
  15591. * Gets the vector squared length
  15592. * @returns the vector squared length (float)
  15593. */
  15594. lengthSquared(): number;
  15595. /**
  15596. * Normalize the vector
  15597. * @returns the current updated Vector2
  15598. */
  15599. normalize(): Vector2;
  15600. /**
  15601. * Gets a new Vector2 copied from the Vector2
  15602. * @returns a new Vector2
  15603. */
  15604. clone(): Vector2;
  15605. /**
  15606. * Gets a new Vector2(0, 0)
  15607. * @returns a new Vector2
  15608. */
  15609. static Zero(): Vector2;
  15610. /**
  15611. * Gets a new Vector2(1, 1)
  15612. * @returns a new Vector2
  15613. */
  15614. static One(): Vector2;
  15615. /**
  15616. * Gets a new Vector2 set from the given index element of the given array
  15617. * @param array defines the data source
  15618. * @param offset defines the offset in the data source
  15619. * @returns a new Vector2
  15620. */
  15621. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15622. /**
  15623. * Sets "result" from the given index element of the given array
  15624. * @param array defines the data source
  15625. * @param offset defines the offset in the data source
  15626. * @param result defines the target vector
  15627. */
  15628. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15629. /**
  15630. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15631. * @param value1 defines 1st point of control
  15632. * @param value2 defines 2nd point of control
  15633. * @param value3 defines 3rd point of control
  15634. * @param value4 defines 4th point of control
  15635. * @param amount defines the interpolation factor
  15636. * @returns a new Vector2
  15637. */
  15638. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15639. /**
  15640. * 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".
  15641. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15642. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15643. * @param value defines the value to clamp
  15644. * @param min defines the lower limit
  15645. * @param max defines the upper limit
  15646. * @returns a new Vector2
  15647. */
  15648. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15649. /**
  15650. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15651. * @param value1 defines the 1st control point
  15652. * @param tangent1 defines the outgoing tangent
  15653. * @param value2 defines the 2nd control point
  15654. * @param tangent2 defines the incoming tangent
  15655. * @param amount defines the interpolation factor
  15656. * @returns a new Vector2
  15657. */
  15658. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15659. /**
  15660. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15661. * @param start defines the start vector
  15662. * @param end defines the end vector
  15663. * @param amount defines the interpolation factor
  15664. * @returns a new Vector2
  15665. */
  15666. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15667. /**
  15668. * Gets the dot product of the vector "left" and the vector "right"
  15669. * @param left defines first vector
  15670. * @param right defines second vector
  15671. * @returns the dot product (float)
  15672. */
  15673. static Dot(left: Vector2, right: Vector2): number;
  15674. /**
  15675. * Returns a new Vector2 equal to the normalized given vector
  15676. * @param vector defines the vector to normalize
  15677. * @returns a new Vector2
  15678. */
  15679. static Normalize(vector: Vector2): Vector2;
  15680. /**
  15681. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15682. * @param left defines 1st vector
  15683. * @param right defines 2nd vector
  15684. * @returns a new Vector2
  15685. */
  15686. static Minimize(left: Vector2, right: Vector2): Vector2;
  15687. /**
  15688. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15689. * @param left defines 1st vector
  15690. * @param right defines 2nd vector
  15691. * @returns a new Vector2
  15692. */
  15693. static Maximize(left: Vector2, right: Vector2): Vector2;
  15694. /**
  15695. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15696. * @param vector defines the vector to transform
  15697. * @param transformation defines the matrix to apply
  15698. * @returns a new Vector2
  15699. */
  15700. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15701. /**
  15702. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15703. * @param vector defines the vector to transform
  15704. * @param transformation defines the matrix to apply
  15705. * @param result defines the target vector
  15706. */
  15707. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15708. /**
  15709. * Determines if a given vector is included in a triangle
  15710. * @param p defines the vector to test
  15711. * @param p0 defines 1st triangle point
  15712. * @param p1 defines 2nd triangle point
  15713. * @param p2 defines 3rd triangle point
  15714. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15715. */
  15716. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15717. /**
  15718. * Gets the distance between the vectors "value1" and "value2"
  15719. * @param value1 defines first vector
  15720. * @param value2 defines second vector
  15721. * @returns the distance between vectors
  15722. */
  15723. static Distance(value1: Vector2, value2: Vector2): number;
  15724. /**
  15725. * Returns the squared distance between the vectors "value1" and "value2"
  15726. * @param value1 defines first vector
  15727. * @param value2 defines second vector
  15728. * @returns the squared distance between vectors
  15729. */
  15730. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15731. /**
  15732. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15733. * @param value1 defines first vector
  15734. * @param value2 defines second vector
  15735. * @returns a new Vector2
  15736. */
  15737. static Center(value1: Vector2, value2: Vector2): Vector2;
  15738. /**
  15739. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15740. * @param p defines the middle point
  15741. * @param segA defines one point of the segment
  15742. * @param segB defines the other point of the segment
  15743. * @returns the shortest distance
  15744. */
  15745. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15746. }
  15747. /**
  15748. * Classed used to store (x,y,z) vector representation
  15749. * A Vector3 is the main object used in 3D geometry
  15750. * It can represent etiher the coordinates of a point the space, either a direction
  15751. * Reminder: Babylon.js uses a left handed forward facing system
  15752. */
  15753. class Vector3 {
  15754. /**
  15755. * Defines the first coordinates (on X axis)
  15756. */
  15757. x: number;
  15758. /**
  15759. * Defines the second coordinates (on Y axis)
  15760. */
  15761. y: number;
  15762. /**
  15763. * Defines the third coordinates (on Z axis)
  15764. */
  15765. z: number;
  15766. /**
  15767. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15768. * @param x defines the first coordinates (on X axis)
  15769. * @param y defines the second coordinates (on Y axis)
  15770. * @param z defines the third coordinates (on Z axis)
  15771. */
  15772. constructor(
  15773. /**
  15774. * Defines the first coordinates (on X axis)
  15775. */
  15776. x: number,
  15777. /**
  15778. * Defines the second coordinates (on Y axis)
  15779. */
  15780. y: number,
  15781. /**
  15782. * Defines the third coordinates (on Z axis)
  15783. */
  15784. z: number);
  15785. /**
  15786. * Creates a string representation of the Vector3
  15787. * @returns a string with the Vector3 coordinates.
  15788. */
  15789. toString(): string;
  15790. /**
  15791. * Gets the class name
  15792. * @returns the string "Vector3"
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * Creates the Vector3 hash code
  15797. * @returns a number which tends to be unique between Vector3 instances
  15798. */
  15799. getHashCode(): number;
  15800. /**
  15801. * Creates an array containing three elements : the coordinates of the Vector3
  15802. * @returns a new array of numbers
  15803. */
  15804. asArray(): number[];
  15805. /**
  15806. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15807. * @param array defines the destination array
  15808. * @param index defines the offset in the destination array
  15809. * @returns the current Vector3
  15810. */
  15811. toArray(array: FloatArray, index?: number): Vector3;
  15812. /**
  15813. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15814. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15815. */
  15816. toQuaternion(): Quaternion;
  15817. /**
  15818. * Adds the given vector to the current Vector3
  15819. * @param otherVector defines the second operand
  15820. * @returns the current updated Vector3
  15821. */
  15822. addInPlace(otherVector: Vector3): Vector3;
  15823. /**
  15824. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15825. * @param otherVector defines the second operand
  15826. * @returns the resulting Vector3
  15827. */
  15828. add(otherVector: Vector3): Vector3;
  15829. /**
  15830. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15831. * @param otherVector defines the second operand
  15832. * @param result defines the Vector3 object where to store the result
  15833. * @returns the current Vector3
  15834. */
  15835. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15836. /**
  15837. * Subtract the given vector from the current Vector3
  15838. * @param otherVector defines the second operand
  15839. * @returns the current updated Vector3
  15840. */
  15841. subtractInPlace(otherVector: Vector3): Vector3;
  15842. /**
  15843. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15844. * @param otherVector defines the second operand
  15845. * @returns the resulting Vector3
  15846. */
  15847. subtract(otherVector: Vector3): Vector3;
  15848. /**
  15849. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15850. * @param otherVector defines the second operand
  15851. * @param result defines the Vector3 object where to store the result
  15852. * @returns the current Vector3
  15853. */
  15854. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15855. /**
  15856. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15857. * @param x defines the x coordinate of the operand
  15858. * @param y defines the y coordinate of the operand
  15859. * @param z defines the z coordinate of the operand
  15860. * @returns the resulting Vector3
  15861. */
  15862. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15863. /**
  15864. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15865. * @param x defines the x coordinate of the operand
  15866. * @param y defines the y coordinate of the operand
  15867. * @param z defines the z coordinate of the operand
  15868. * @param result defines the Vector3 object where to store the result
  15869. * @returns the current Vector3
  15870. */
  15871. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15872. /**
  15873. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15874. * @returns a new Vector3
  15875. */
  15876. negate(): Vector3;
  15877. /**
  15878. * Multiplies the Vector3 coordinates by the float "scale"
  15879. * @param scale defines the multiplier factor
  15880. * @returns the current updated Vector3
  15881. */
  15882. scaleInPlace(scale: number): Vector3;
  15883. /**
  15884. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15885. * @param scale defines the multiplier factor
  15886. * @returns a new Vector3
  15887. */
  15888. scale(scale: number): Vector3;
  15889. /**
  15890. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15891. * @param scale defines the multiplier factor
  15892. * @param result defines the Vector3 object where to store the result
  15893. * @returns the current Vector3
  15894. */
  15895. scaleToRef(scale: number, result: Vector3): Vector3;
  15896. /**
  15897. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15898. * @param scale defines the scale factor
  15899. * @param result defines the Vector3 object where to store the result
  15900. * @returns the unmodified current Vector3
  15901. */
  15902. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15903. /**
  15904. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15905. * @param otherVector defines the second operand
  15906. * @returns true if both vectors are equals
  15907. */
  15908. equals(otherVector: Vector3): boolean;
  15909. /**
  15910. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15911. * @param otherVector defines the second operand
  15912. * @param epsilon defines the minimal distance to define values as equals
  15913. * @returns true if both vectors are distant less than epsilon
  15914. */
  15915. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15916. /**
  15917. * Returns true if the current Vector3 coordinates equals the given floats
  15918. * @param x defines the x coordinate of the operand
  15919. * @param y defines the y coordinate of the operand
  15920. * @param z defines the z coordinate of the operand
  15921. * @returns true if both vectors are equals
  15922. */
  15923. equalsToFloats(x: number, y: number, z: number): boolean;
  15924. /**
  15925. * Multiplies the current Vector3 coordinates by the given ones
  15926. * @param otherVector defines the second operand
  15927. * @returns the current updated Vector3
  15928. */
  15929. multiplyInPlace(otherVector: Vector3): Vector3;
  15930. /**
  15931. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15932. * @param otherVector defines the second operand
  15933. * @returns the new Vector3
  15934. */
  15935. multiply(otherVector: Vector3): Vector3;
  15936. /**
  15937. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  15938. * @param otherVector defines the second operand
  15939. * @param result defines the Vector3 object where to store the result
  15940. * @returns the current Vector3
  15941. */
  15942. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15943. /**
  15944. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15945. * @param x defines the x coordinate of the operand
  15946. * @param y defines the y coordinate of the operand
  15947. * @param z defines the z coordinate of the operand
  15948. * @returns the new Vector3
  15949. */
  15950. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15951. /**
  15952. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15953. * @param otherVector defines the second operand
  15954. * @returns the new Vector3
  15955. */
  15956. divide(otherVector: Vector3): Vector3;
  15957. /**
  15958. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15959. * @param otherVector defines the second operand
  15960. * @param result defines the Vector3 object where to store the result
  15961. * @returns the current Vector3
  15962. */
  15963. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15964. /**
  15965. * Divides the current Vector3 coordinates by the given ones.
  15966. * @param otherVector defines the second operand
  15967. * @returns the current updated Vector3
  15968. */
  15969. divideInPlace(otherVector: Vector3): Vector3;
  15970. /**
  15971. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  15972. * @param other defines the second operand
  15973. * @returns the current updated Vector3
  15974. */
  15975. minimizeInPlace(other: Vector3): Vector3;
  15976. /**
  15977. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  15978. * @param other defines the second operand
  15979. * @returns the current updated Vector3
  15980. */
  15981. maximizeInPlace(other: Vector3): Vector3;
  15982. /**
  15983. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15984. */
  15985. readonly isNonUniform: boolean;
  15986. /**
  15987. * Gets the length of the Vector3
  15988. * @returns the length of the Vecto3
  15989. */
  15990. length(): number;
  15991. /**
  15992. * Gets the squared length of the Vector3
  15993. * @returns squared length of the Vector3
  15994. */
  15995. lengthSquared(): number;
  15996. /**
  15997. * Normalize the current Vector3.
  15998. * Please note that this is an in place operation.
  15999. * @returns the current updated Vector3
  16000. */
  16001. normalize(): Vector3;
  16002. /**
  16003. * Normalize the current Vector3 to a new vector
  16004. * @returns the new Vector3
  16005. */
  16006. normalizeToNew(): Vector3;
  16007. /**
  16008. * Normalize the current Vector3 to the reference
  16009. * @param reference define the Vector3 to update
  16010. * @returns the updated Vector3
  16011. */
  16012. normalizeToRef(reference: Vector3): Vector3;
  16013. /**
  16014. * Creates a new Vector3 copied from the current Vector3
  16015. * @returns the new Vector3
  16016. */
  16017. clone(): Vector3;
  16018. /**
  16019. * Copies the given vector coordinates to the current Vector3 ones
  16020. * @param source defines the source Vector3
  16021. * @returns the current updated Vector3
  16022. */
  16023. copyFrom(source: Vector3): Vector3;
  16024. /**
  16025. * Copies the given floats to the current Vector3 coordinates
  16026. * @param x defines the x coordinate of the operand
  16027. * @param y defines the y coordinate of the operand
  16028. * @param z defines the z coordinate of the operand
  16029. * @returns the current updated Vector3
  16030. */
  16031. copyFromFloats(x: number, y: number, z: number): Vector3;
  16032. /**
  16033. * Copies the given floats to the current Vector3 coordinates
  16034. * @param x defines the x coordinate of the operand
  16035. * @param y defines the y coordinate of the operand
  16036. * @param z defines the z coordinate of the operand
  16037. * @returns the current updated Vector3
  16038. */
  16039. set(x: number, y: number, z: number): Vector3;
  16040. /**
  16041. * Get the clip factor between two vectors
  16042. * @param vector0 defines the first operand
  16043. * @param vector1 defines the second operand
  16044. * @param axis defines the axis to use
  16045. * @param size defines the size along the axis
  16046. * @returns the clip factor
  16047. */
  16048. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16049. /**
  16050. * Get angle between two vectors
  16051. * @param vector0 angle between vector0 and vector1
  16052. * @param vector1 angle between vector0 and vector1
  16053. * @param normal direction of the normal
  16054. * @return the angle between vector0 and vector1
  16055. */
  16056. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16057. /**
  16058. * Returns a new Vector3 set from the index "offset" of the given array
  16059. * @param array defines the source array
  16060. * @param offset defines the offset in the source array
  16061. * @returns the new Vector3
  16062. */
  16063. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16064. /**
  16065. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16066. * This function is deprecated. Use FromArray instead
  16067. * @param array defines the source array
  16068. * @param offset defines the offset in the source array
  16069. * @returns the new Vector3
  16070. */
  16071. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16072. /**
  16073. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16074. * @param array defines the source array
  16075. * @param offset defines the offset in the source array
  16076. * @param result defines the Vector3 where to store the result
  16077. */
  16078. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16079. /**
  16080. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16081. * This function is deprecated. Use FromArrayToRef instead.
  16082. * @param array defines the source array
  16083. * @param offset defines the offset in the source array
  16084. * @param result defines the Vector3 where to store the result
  16085. */
  16086. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16087. /**
  16088. * Sets the given vector "result" with the given floats.
  16089. * @param x defines the x coordinate of the source
  16090. * @param y defines the y coordinate of the source
  16091. * @param z defines the z coordinate of the source
  16092. * @param result defines the Vector3 where to store the result
  16093. */
  16094. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16095. /**
  16096. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16097. * @returns a new empty Vector3
  16098. */
  16099. static Zero(): Vector3;
  16100. /**
  16101. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16102. * @returns a new unit Vector3
  16103. */
  16104. static One(): Vector3;
  16105. /**
  16106. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16107. * @returns a new up Vector3
  16108. */
  16109. static Up(): Vector3;
  16110. /**
  16111. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16112. * @returns a new forward Vector3
  16113. */
  16114. static Forward(): Vector3;
  16115. /**
  16116. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16117. * @returns a new right Vector3
  16118. */
  16119. static Right(): Vector3;
  16120. /**
  16121. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16122. * @returns a new left Vector3
  16123. */
  16124. static Left(): Vector3;
  16125. /**
  16126. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16127. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16128. * @param vector defines the Vector3 to transform
  16129. * @param transformation defines the transformation matrix
  16130. * @returns the transformed Vector3
  16131. */
  16132. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16133. /**
  16134. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16135. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16136. * @param vector defines the Vector3 to transform
  16137. * @param transformation defines the transformation matrix
  16138. * @param result defines the Vector3 where to store the result
  16139. */
  16140. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16141. /**
  16142. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16143. * This method computes tranformed coordinates only, not transformed direction vectors
  16144. * @param x define the x coordinate of the source vector
  16145. * @param y define the y coordinate of the source vector
  16146. * @param z define the z coordinate of the source vector
  16147. * @param transformation defines the transformation matrix
  16148. * @param result defines the Vector3 where to store the result
  16149. */
  16150. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16151. /**
  16152. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16153. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16154. * @param vector defines the Vector3 to transform
  16155. * @param transformation defines the transformation matrix
  16156. * @returns the new Vector3
  16157. */
  16158. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16159. /**
  16160. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16161. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16162. * @param vector defines the Vector3 to transform
  16163. * @param transformation defines the transformation matrix
  16164. * @param result defines the Vector3 where to store the result
  16165. */
  16166. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16167. /**
  16168. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16169. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16170. * @param x define the x coordinate of the source vector
  16171. * @param y define the y coordinate of the source vector
  16172. * @param z define the z coordinate of the source vector
  16173. * @param transformation defines the transformation matrix
  16174. * @param result defines the Vector3 where to store the result
  16175. */
  16176. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16177. /**
  16178. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16179. * @param value1 defines the first control point
  16180. * @param value2 defines the second control point
  16181. * @param value3 defines the third control point
  16182. * @param value4 defines the fourth control point
  16183. * @param amount defines the amount on the spline to use
  16184. * @returns the new Vector3
  16185. */
  16186. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16187. /**
  16188. * 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"
  16189. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16190. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16191. * @param value defines the current value
  16192. * @param min defines the lower range value
  16193. * @param max defines the upper range value
  16194. * @returns the new Vector3
  16195. */
  16196. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16197. /**
  16198. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16199. * @param value1 defines the first control point
  16200. * @param tangent1 defines the first tangent vector
  16201. * @param value2 defines the second control point
  16202. * @param tangent2 defines the second tangent vector
  16203. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16204. * @returns the new Vector3
  16205. */
  16206. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16207. /**
  16208. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16209. * @param start defines the start value
  16210. * @param end defines the end value
  16211. * @param amount max defines amount between both (between 0 and 1)
  16212. * @returns the new Vector3
  16213. */
  16214. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16215. /**
  16216. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16217. * @param start defines the start value
  16218. * @param end defines the end value
  16219. * @param amount max defines amount between both (between 0 and 1)
  16220. * @param result defines the Vector3 where to store the result
  16221. */
  16222. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16223. /**
  16224. * Returns the dot product (float) between the vectors "left" and "right"
  16225. * @param left defines the left operand
  16226. * @param right defines the right operand
  16227. * @returns the dot product
  16228. */
  16229. static Dot(left: Vector3, right: Vector3): number;
  16230. /**
  16231. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16232. * The cross product is then orthogonal to both "left" and "right"
  16233. * @param left defines the left operand
  16234. * @param right defines the right operand
  16235. * @returns the cross product
  16236. */
  16237. static Cross(left: Vector3, right: Vector3): Vector3;
  16238. /**
  16239. * Sets the given vector "result" with the cross product of "left" and "right"
  16240. * The cross product is then orthogonal to both "left" and "right"
  16241. * @param left defines the left operand
  16242. * @param right defines the right operand
  16243. * @param result defines the Vector3 where to store the result
  16244. */
  16245. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16246. /**
  16247. * Returns a new Vector3 as the normalization of the given vector
  16248. * @param vector defines the Vector3 to normalize
  16249. * @returns the new Vector3
  16250. */
  16251. static Normalize(vector: Vector3): Vector3;
  16252. /**
  16253. * Sets the given vector "result" with the normalization of the given first vector
  16254. * @param vector defines the Vector3 to normalize
  16255. * @param result defines the Vector3 where to store the result
  16256. */
  16257. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16258. private static _viewportMatrixCache;
  16259. /**
  16260. * Project a Vector3 onto screen space
  16261. * @param vector defines the Vector3 to project
  16262. * @param world defines the world matrix to use
  16263. * @param transform defines the transform (view x projection) matrix to use
  16264. * @param viewport defines the screen viewport to use
  16265. * @returns the new Vector3
  16266. */
  16267. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16268. /**
  16269. * Unproject from screen space to object space
  16270. * @param source defines the screen space Vector3 to use
  16271. * @param viewportWidth defines the current width of the viewport
  16272. * @param viewportHeight defines the current height of the viewport
  16273. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16274. * @param transform defines the transform (view x projection) matrix to use
  16275. * @returns the new Vector3
  16276. */
  16277. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16278. /**
  16279. * Unproject from screen space to object space
  16280. * @param source defines the screen space Vector3 to use
  16281. * @param viewportWidth defines the current width of the viewport
  16282. * @param viewportHeight defines the current height of the viewport
  16283. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16284. * @param view defines the view matrix to use
  16285. * @param projection defines the projection matrix to use
  16286. * @returns the new Vector3
  16287. */
  16288. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16289. /**
  16290. * Unproject from screen space to object space
  16291. * @param source defines the screen space Vector3 to use
  16292. * @param viewportWidth defines the current width of the viewport
  16293. * @param viewportHeight defines the current height of the viewport
  16294. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16295. * @param view defines the view matrix to use
  16296. * @param projection defines the projection matrix to use
  16297. * @param result defines the Vector3 where to store the result
  16298. */
  16299. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16300. /**
  16301. * Unproject from screen space to object space
  16302. * @param sourceX defines the screen space x coordinate to use
  16303. * @param sourceY defines the screen space y coordinate to use
  16304. * @param sourceZ defines the screen space z coordinate to use
  16305. * @param viewportWidth defines the current width of the viewport
  16306. * @param viewportHeight defines the current height of the viewport
  16307. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16308. * @param view defines the view matrix to use
  16309. * @param projection defines the projection matrix to use
  16310. * @param result defines the Vector3 where to store the result
  16311. */
  16312. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16313. /**
  16314. * Gets the minimal coordinate values between two Vector3
  16315. * @param left defines the first operand
  16316. * @param right defines the second operand
  16317. * @returns the new Vector3
  16318. */
  16319. static Minimize(left: Vector3, right: Vector3): Vector3;
  16320. /**
  16321. * Gets the maximal coordinate values between two Vector3
  16322. * @param left defines the first operand
  16323. * @param right defines the second operand
  16324. * @returns the new Vector3
  16325. */
  16326. static Maximize(left: Vector3, right: Vector3): Vector3;
  16327. /**
  16328. * Returns the distance between the vectors "value1" and "value2"
  16329. * @param value1 defines the first operand
  16330. * @param value2 defines the second operand
  16331. * @returns the distance
  16332. */
  16333. static Distance(value1: Vector3, value2: Vector3): number;
  16334. /**
  16335. * Returns the squared distance between the vectors "value1" and "value2"
  16336. * @param value1 defines the first operand
  16337. * @param value2 defines the second operand
  16338. * @returns the squared distance
  16339. */
  16340. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16341. /**
  16342. * Returns a new Vector3 located at the center between "value1" and "value2"
  16343. * @param value1 defines the first operand
  16344. * @param value2 defines the second operand
  16345. * @returns the new Vector3
  16346. */
  16347. static Center(value1: Vector3, value2: Vector3): Vector3;
  16348. /**
  16349. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16350. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16351. * to something in order to rotate it from its local system to the given target system
  16352. * Note: axis1, axis2 and axis3 are normalized during this operation
  16353. * @param axis1 defines the first axis
  16354. * @param axis2 defines the second axis
  16355. * @param axis3 defines the third axis
  16356. * @returns a new Vector3
  16357. */
  16358. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16359. /**
  16360. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16361. * @param axis1 defines the first axis
  16362. * @param axis2 defines the second axis
  16363. * @param axis3 defines the third axis
  16364. * @param ref defines the Vector3 where to store the result
  16365. */
  16366. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16367. }
  16368. class Vector4 {
  16369. x: number;
  16370. y: number;
  16371. z: number;
  16372. w: number;
  16373. /**
  16374. * Creates a Vector4 object from the given floats.
  16375. */
  16376. constructor(x: number, y: number, z: number, w: number);
  16377. /**
  16378. * Returns the string with the Vector4 coordinates.
  16379. */
  16380. toString(): string;
  16381. /**
  16382. * Returns the string "Vector4".
  16383. */
  16384. getClassName(): string;
  16385. /**
  16386. * Returns the Vector4 hash code.
  16387. */
  16388. getHashCode(): number;
  16389. /**
  16390. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16391. */
  16392. asArray(): number[];
  16393. /**
  16394. * Populates the given array from the given index with the Vector4 coordinates.
  16395. * Returns the Vector4.
  16396. */
  16397. toArray(array: FloatArray, index?: number): Vector4;
  16398. /**
  16399. * Adds the given vector to the current Vector4.
  16400. * Returns the updated Vector4.
  16401. */
  16402. addInPlace(otherVector: Vector4): Vector4;
  16403. /**
  16404. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16405. */
  16406. add(otherVector: Vector4): Vector4;
  16407. /**
  16408. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16409. * Returns the current Vector4.
  16410. */
  16411. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16412. /**
  16413. * Subtract in place the given vector from the current Vector4.
  16414. * Returns the updated Vector4.
  16415. */
  16416. subtractInPlace(otherVector: Vector4): Vector4;
  16417. /**
  16418. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16419. */
  16420. subtract(otherVector: Vector4): Vector4;
  16421. /**
  16422. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16423. * Returns the current Vector4.
  16424. */
  16425. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16426. /**
  16427. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16428. */
  16429. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16430. /**
  16431. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16432. * Returns the current Vector4.
  16433. */
  16434. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16435. /**
  16436. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16437. */
  16438. negate(): Vector4;
  16439. /**
  16440. * Multiplies the current Vector4 coordinates by scale (float).
  16441. * Returns the updated Vector4.
  16442. */
  16443. scaleInPlace(scale: number): Vector4;
  16444. /**
  16445. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16446. */
  16447. scale(scale: number): Vector4;
  16448. /**
  16449. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16450. * Returns the current Vector4.
  16451. */
  16452. scaleToRef(scale: number, result: Vector4): Vector4;
  16453. /**
  16454. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16455. * @param scale defines the scale factor
  16456. * @param result defines the Vector4 object where to store the result
  16457. * @returns the unmodified current Vector4
  16458. */
  16459. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16460. /**
  16461. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16462. */
  16463. equals(otherVector: Vector4): boolean;
  16464. /**
  16465. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16466. */
  16467. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16468. /**
  16469. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16470. */
  16471. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16472. /**
  16473. * Multiplies in place the current Vector4 by the given one.
  16474. * Returns the updated Vector4.
  16475. */
  16476. multiplyInPlace(otherVector: Vector4): Vector4;
  16477. /**
  16478. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16479. */
  16480. multiply(otherVector: Vector4): Vector4;
  16481. /**
  16482. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16483. * Returns the current Vector4.
  16484. */
  16485. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16486. /**
  16487. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16488. */
  16489. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16490. /**
  16491. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16492. */
  16493. divide(otherVector: Vector4): Vector4;
  16494. /**
  16495. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16496. * Returns the current Vector4.
  16497. */
  16498. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16499. /**
  16500. * Divides the current Vector3 coordinates by the given ones.
  16501. * @returns the updated Vector3.
  16502. */
  16503. divideInPlace(otherVector: Vector4): Vector4;
  16504. /**
  16505. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16506. * @param other defines the second operand
  16507. * @returns the current updated Vector4
  16508. */
  16509. minimizeInPlace(other: Vector4): Vector4;
  16510. /**
  16511. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16512. * @param other defines the second operand
  16513. * @returns the current updated Vector4
  16514. */
  16515. maximizeInPlace(other: Vector4): Vector4;
  16516. /**
  16517. * Returns the Vector4 length (float).
  16518. */
  16519. length(): number;
  16520. /**
  16521. * Returns the Vector4 squared length (float).
  16522. */
  16523. lengthSquared(): number;
  16524. /**
  16525. * Normalizes in place the Vector4.
  16526. * Returns the updated Vector4.
  16527. */
  16528. normalize(): Vector4;
  16529. /**
  16530. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16531. */
  16532. toVector3(): Vector3;
  16533. /**
  16534. * Returns a new Vector4 copied from the current one.
  16535. */
  16536. clone(): Vector4;
  16537. /**
  16538. * Updates the current Vector4 with the given one coordinates.
  16539. * Returns the updated Vector4.
  16540. */
  16541. copyFrom(source: Vector4): Vector4;
  16542. /**
  16543. * Updates the current Vector4 coordinates with the given floats.
  16544. * Returns the updated Vector4.
  16545. */
  16546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16547. /**
  16548. * Updates the current Vector4 coordinates with the given floats.
  16549. * Returns the updated Vector4.
  16550. */
  16551. set(x: number, y: number, z: number, w: number): Vector4;
  16552. /**
  16553. * Returns a new Vector4 set from the starting index of the given array.
  16554. */
  16555. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16556. /**
  16557. * Updates the given vector "result" from the starting index of the given array.
  16558. */
  16559. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16560. /**
  16561. * Updates the given vector "result" from the starting index of the given Float32Array.
  16562. */
  16563. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16564. /**
  16565. * Updates the given vector "result" coordinates from the given floats.
  16566. */
  16567. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16568. /**
  16569. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16570. */
  16571. static Zero(): Vector4;
  16572. /**
  16573. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16574. */
  16575. static One(): Vector4;
  16576. /**
  16577. * Returns a new normalized Vector4 from the given one.
  16578. */
  16579. static Normalize(vector: Vector4): Vector4;
  16580. /**
  16581. * Updates the given vector "result" from the normalization of the given one.
  16582. */
  16583. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16584. static Minimize(left: Vector4, right: Vector4): Vector4;
  16585. static Maximize(left: Vector4, right: Vector4): Vector4;
  16586. /**
  16587. * Returns the distance (float) between the vectors "value1" and "value2".
  16588. */
  16589. static Distance(value1: Vector4, value2: Vector4): number;
  16590. /**
  16591. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16592. */
  16593. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16594. /**
  16595. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16596. */
  16597. static Center(value1: Vector4, value2: Vector4): Vector4;
  16598. /**
  16599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16600. * This methods computes transformed normalized direction vectors only.
  16601. */
  16602. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16603. /**
  16604. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16605. * This methods computes transformed normalized direction vectors only.
  16606. */
  16607. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16608. /**
  16609. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16610. * This methods computes transformed normalized direction vectors only.
  16611. */
  16612. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16613. }
  16614. interface ISize {
  16615. width: number;
  16616. height: number;
  16617. }
  16618. class Size implements ISize {
  16619. width: number;
  16620. height: number;
  16621. /**
  16622. * Creates a Size object from the given width and height (floats).
  16623. */
  16624. constructor(width: number, height: number);
  16625. toString(): string;
  16626. /**
  16627. * Returns the string "Size"
  16628. */
  16629. getClassName(): string;
  16630. /**
  16631. * Returns the Size hash code.
  16632. */
  16633. getHashCode(): number;
  16634. /**
  16635. * Updates the current size from the given one.
  16636. * Returns the updated Size.
  16637. */
  16638. copyFrom(src: Size): void;
  16639. /**
  16640. * Updates in place the current Size from the given floats.
  16641. * Returns the updated Size.
  16642. */
  16643. copyFromFloats(width: number, height: number): Size;
  16644. /**
  16645. * Updates in place the current Size from the given floats.
  16646. * Returns the updated Size.
  16647. */
  16648. set(width: number, height: number): Size;
  16649. /**
  16650. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16651. */
  16652. multiplyByFloats(w: number, h: number): Size;
  16653. /**
  16654. * Returns a new Size copied from the given one.
  16655. */
  16656. clone(): Size;
  16657. /**
  16658. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16659. */
  16660. equals(other: Size): boolean;
  16661. /**
  16662. * Returns the surface of the Size : width * height (float).
  16663. */
  16664. readonly surface: number;
  16665. /**
  16666. * Returns a new Size set to (0.0, 0.0)
  16667. */
  16668. static Zero(): Size;
  16669. /**
  16670. * Returns a new Size set as the addition result of the current Size and the given one.
  16671. */
  16672. add(otherSize: Size): Size;
  16673. /**
  16674. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16675. */
  16676. subtract(otherSize: Size): Size;
  16677. /**
  16678. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16679. */
  16680. static Lerp(start: Size, end: Size, amount: number): Size;
  16681. }
  16682. /**
  16683. * Class used to store quaternion data
  16684. * @see https://en.wikipedia.org/wiki/Quaternion
  16685. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16686. */
  16687. class Quaternion {
  16688. /** defines the first component (0 by default) */
  16689. x: number;
  16690. /** defines the second component (0 by default) */
  16691. y: number;
  16692. /** defines the third component (0 by default) */
  16693. z: number;
  16694. /** defines the fourth component (1.0 by default) */
  16695. w: number;
  16696. /**
  16697. * Creates a new Quaternion from the given floats
  16698. * @param x defines the first component (0 by default)
  16699. * @param y defines the second component (0 by default)
  16700. * @param z defines the third component (0 by default)
  16701. * @param w defines the fourth component (1.0 by default)
  16702. */
  16703. constructor(
  16704. /** defines the first component (0 by default) */
  16705. x?: number,
  16706. /** defines the second component (0 by default) */
  16707. y?: number,
  16708. /** defines the third component (0 by default) */
  16709. z?: number,
  16710. /** defines the fourth component (1.0 by default) */
  16711. w?: number);
  16712. /**
  16713. * Gets a string representation for the current quaternion
  16714. * @returns a string with the Quaternion coordinates
  16715. */
  16716. toString(): string;
  16717. /**
  16718. * Gets the class name of the quaternion
  16719. * @returns the string "Quaternion"
  16720. */
  16721. getClassName(): string;
  16722. /**
  16723. * Gets a hash code for this quaternion
  16724. * @returns the quaternion hash code
  16725. */
  16726. getHashCode(): number;
  16727. /**
  16728. * Copy the quaternion to an array
  16729. * @returns a new array populated with 4 elements from the quaternion coordinates
  16730. */
  16731. asArray(): number[];
  16732. /**
  16733. * Check if two quaternions are equals
  16734. * @param otherQuaternion defines the second operand
  16735. * @return true if the current quaternion and the given one coordinates are strictly equals
  16736. */
  16737. equals(otherQuaternion: Quaternion): boolean;
  16738. /**
  16739. * Clone the current quaternion
  16740. * @returns a new quaternion copied from the current one
  16741. */
  16742. clone(): Quaternion;
  16743. /**
  16744. * Copy a quaternion to the current one
  16745. * @param other defines the other quaternion
  16746. * @returns the updated current quaternion
  16747. */
  16748. copyFrom(other: Quaternion): Quaternion;
  16749. /**
  16750. * Updates the current quaternion with the given float coordinates
  16751. * @param x defines the x coordinate
  16752. * @param y defines the y coordinate
  16753. * @param z defines the z coordinate
  16754. * @param w defines the w coordinate
  16755. * @returns the updated current quaternion
  16756. */
  16757. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16758. /**
  16759. * Updates the current quaternion from the given float coordinates
  16760. * @param x defines the x coordinate
  16761. * @param y defines the y coordinate
  16762. * @param z defines the z coordinate
  16763. * @param w defines the w coordinate
  16764. * @returns the updated current quaternion
  16765. */
  16766. set(x: number, y: number, z: number, w: number): Quaternion;
  16767. /**
  16768. * Adds two quaternions
  16769. * @param other defines the second operand
  16770. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16771. */
  16772. add(other: Quaternion): Quaternion;
  16773. /**
  16774. * Add a quaternion to the current one
  16775. * @param other defines the quaternion to add
  16776. * @returns the current quaternion
  16777. */
  16778. addInPlace(other: Quaternion): Quaternion;
  16779. /**
  16780. * Subtract two quaternions
  16781. * @param other defines the second operand
  16782. * @returns a new quaternion as the subtraction result of the given one from the current one
  16783. */
  16784. subtract(other: Quaternion): Quaternion;
  16785. /**
  16786. * Multiplies the current quaternion by a scale factor
  16787. * @param value defines the scale factor
  16788. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16789. */
  16790. scale(value: number): Quaternion;
  16791. /**
  16792. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16793. * @param scale defines the scale factor
  16794. * @param result defines the Quaternion object where to store the result
  16795. * @returns the unmodified current quaternion
  16796. */
  16797. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16798. /**
  16799. * Multiplies in place the current quaternion by a scale factor
  16800. * @param value defines the scale factor
  16801. * @returns the current modified quaternion
  16802. */
  16803. scaleInPlace(value: number): Quaternion;
  16804. /**
  16805. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16806. * @param scale defines the scale factor
  16807. * @param result defines the Quaternion object where to store the result
  16808. * @returns the unmodified current quaternion
  16809. */
  16810. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16811. /**
  16812. * Multiplies two quaternions
  16813. * @param q1 defines the second operand
  16814. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16815. */
  16816. multiply(q1: Quaternion): Quaternion;
  16817. /**
  16818. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16819. * @param q1 defines the second operand
  16820. * @param result defines the target quaternion
  16821. * @returns the current quaternion
  16822. */
  16823. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16824. /**
  16825. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16826. * @param q1 defines the second operand
  16827. * @returns the currentupdated quaternion
  16828. */
  16829. multiplyInPlace(q1: Quaternion): Quaternion;
  16830. /**
  16831. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16832. * @param ref defines the target quaternion
  16833. * @returns the current quaternion
  16834. */
  16835. conjugateToRef(ref: Quaternion): Quaternion;
  16836. /**
  16837. * Conjugates in place (1-q) the current quaternion
  16838. * @returns the current updated quaternion
  16839. */
  16840. conjugateInPlace(): Quaternion;
  16841. /**
  16842. * Conjugates in place (1-q) the current quaternion
  16843. * @returns a new quaternion
  16844. */
  16845. conjugate(): Quaternion;
  16846. /**
  16847. * Gets length of current quaternion
  16848. * @returns the quaternion length (float)
  16849. */
  16850. length(): number;
  16851. /**
  16852. * Normalize in place the current quaternion
  16853. * @returns the current updated quaternion
  16854. */
  16855. normalize(): Quaternion;
  16856. /**
  16857. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16858. * @param order is a reserved parameter and is ignore for now
  16859. * @returns a new Vector3 containing the Euler angles
  16860. */
  16861. toEulerAngles(order?: string): Vector3;
  16862. /**
  16863. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16864. * @param result defines the vector which will be filled with the Euler angles
  16865. * @param order is a reserved parameter and is ignore for now
  16866. * @returns the current unchanged quaternion
  16867. */
  16868. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16869. /**
  16870. * Updates the given rotation matrix with the current quaternion values
  16871. * @param result defines the target matrix
  16872. * @returns the current unchanged quaternion
  16873. */
  16874. toRotationMatrix(result: Matrix): Quaternion;
  16875. /**
  16876. * Updates the current quaternion from the given rotation matrix values
  16877. * @param matrix defines the source matrix
  16878. * @returns the current updated quaternion
  16879. */
  16880. fromRotationMatrix(matrix: Matrix): Quaternion;
  16881. /**
  16882. * Creates a new quaternion from a rotation matrix
  16883. * @param matrix defines the source matrix
  16884. * @returns a new quaternion created from the given rotation matrix values
  16885. */
  16886. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16887. /**
  16888. * Updates the given quaternion with the given rotation matrix values
  16889. * @param matrix defines the source matrix
  16890. * @param result defines the target quaternion
  16891. */
  16892. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16893. /**
  16894. * Returns the dot product (float) between the quaternions "left" and "right"
  16895. * @param left defines the left operand
  16896. * @param right defines the right operand
  16897. * @returns the dot product
  16898. */
  16899. static Dot(left: Quaternion, right: Quaternion): number;
  16900. /**
  16901. * Checks if the two quaternions are close to each other
  16902. * @param quat0 defines the first quaternion to check
  16903. * @param quat1 defines the second quaternion to check
  16904. * @returns true if the two quaternions are close to each other
  16905. */
  16906. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16907. /**
  16908. * Creates an empty quaternion
  16909. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16910. */
  16911. static Zero(): Quaternion;
  16912. /**
  16913. * Inverse a given quaternion
  16914. * @param q defines the source quaternion
  16915. * @returns a new quaternion as the inverted current quaternion
  16916. */
  16917. static Inverse(q: Quaternion): Quaternion;
  16918. /**
  16919. * Creates an identity quaternion
  16920. * @returns the identity quaternion
  16921. */
  16922. static Identity(): Quaternion;
  16923. /**
  16924. * Gets a boolean indicating if the given quaternion is identity
  16925. * @param quaternion defines the quaternion to check
  16926. * @returns true if the quaternion is identity
  16927. */
  16928. static IsIdentity(quaternion: Quaternion): boolean;
  16929. /**
  16930. * Creates a quaternion from a rotation around an axis
  16931. * @param axis defines the axis to use
  16932. * @param angle defines the angle to use
  16933. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16934. */
  16935. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16936. /**
  16937. * Creates a rotation around an axis and stores it into the given quaternion
  16938. * @param axis defines the axis to use
  16939. * @param angle defines the angle to use
  16940. * @param result defines the target quaternion
  16941. * @returns the target quaternion
  16942. */
  16943. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16944. /**
  16945. * Creates a new quaternion from data stored into an array
  16946. * @param array defines the data source
  16947. * @param offset defines the offset in the source array where the data starts
  16948. * @returns a new quaternion
  16949. */
  16950. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16951. /**
  16952. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16953. * @param yaw defines the rotation around Y axis
  16954. * @param pitch defines the rotation around X axis
  16955. * @param roll defines the rotation around Z axis
  16956. * @returns the new quaternion
  16957. */
  16958. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16959. /**
  16960. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  16961. * @param yaw defines the rotation around Y axis
  16962. * @param pitch defines the rotation around X axis
  16963. * @param roll defines the rotation around Z axis
  16964. * @param result defines the target quaternion
  16965. */
  16966. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16967. /**
  16968. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  16969. * @param alpha defines the rotation around first axis
  16970. * @param beta defines the rotation around second axis
  16971. * @param gamma defines the rotation around third axis
  16972. * @returns the new quaternion
  16973. */
  16974. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16975. /**
  16976. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  16977. * @param alpha defines the rotation around first axis
  16978. * @param beta defines the rotation around second axis
  16979. * @param gamma defines the rotation around third axis
  16980. * @param result defines the target quaternion
  16981. */
  16982. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16983. /**
  16984. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  16985. * @param axis1 defines the first axis
  16986. * @param axis2 defines the second axis
  16987. * @param axis3 defines the third axis
  16988. * @returns the new quaternion
  16989. */
  16990. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  16991. /**
  16992. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  16993. * @param axis1 defines the first axis
  16994. * @param axis2 defines the second axis
  16995. * @param axis3 defines the third axis
  16996. * @param ref defines the target quaternion
  16997. */
  16998. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16999. /**
  17000. * Interpolates between two quaternions
  17001. * @param left defines first quaternion
  17002. * @param right defines second quaternion
  17003. * @param amount defines the gradient to use
  17004. * @returns the new interpolated quaternion
  17005. */
  17006. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17007. /**
  17008. * Interpolates between two quaternions and stores it into a target quaternion
  17009. * @param left defines first quaternion
  17010. * @param right defines second quaternion
  17011. * @param amount defines the gradient to use
  17012. * @param result defines the target quaternion
  17013. */
  17014. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17015. /**
  17016. * Interpolate between two quaternions using Hermite interpolation
  17017. * @param value1 defines first quaternion
  17018. * @param tangent1 defines the incoming tangent
  17019. * @param value2 defines second quaternion
  17020. * @param tangent2 defines the outgoing tangent
  17021. * @param amount defines the target quaternion
  17022. * @returns the new interpolated quaternion
  17023. */
  17024. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17025. }
  17026. /**
  17027. * Class used to store matrix data (4x4)
  17028. */
  17029. class Matrix {
  17030. private static _tempQuaternion;
  17031. private static _xAxis;
  17032. private static _yAxis;
  17033. private static _zAxis;
  17034. private static _updateFlagSeed;
  17035. private static _identityReadOnly;
  17036. private _isIdentity;
  17037. private _isIdentityDirty;
  17038. /**
  17039. * Gets the update flag of the matrix which is an unique number for the matrix.
  17040. * It will be incremented every time the matrix data change.
  17041. * You can use it to speed the comparison between two versions of the same matrix.
  17042. */
  17043. updateFlag: number;
  17044. /**
  17045. * Gets or sets the internal data of the matrix
  17046. */
  17047. m: Float32Array;
  17048. /** @hidden */
  17049. _markAsUpdated(): void;
  17050. /**
  17051. * Creates an empty matrix (filled with zeros)
  17052. */
  17053. constructor();
  17054. /**
  17055. * Check if the current matrix is indentity
  17056. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17057. * @returns true is the matrix is the identity matrix
  17058. */
  17059. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17060. /**
  17061. * Gets the determinant of the matrix
  17062. * @returns the matrix determinant
  17063. */
  17064. determinant(): number;
  17065. /**
  17066. * Returns the matrix as a Float32Array
  17067. * @returns the matrix underlying array
  17068. */
  17069. toArray(): Float32Array;
  17070. /**
  17071. * Returns the matrix as a Float32Array
  17072. * @returns the matrix underlying array.
  17073. */
  17074. asArray(): Float32Array;
  17075. /**
  17076. * Inverts the current matrix in place
  17077. * @returns the current inverted matrix
  17078. */
  17079. invert(): Matrix;
  17080. /**
  17081. * Sets all the matrix elements to zero
  17082. * @returns the current matrix
  17083. */
  17084. reset(): Matrix;
  17085. /**
  17086. * Adds the current matrix with a second one
  17087. * @param other defines the matrix to add
  17088. * @returns a new matrix as the addition of the current matrix and the given one
  17089. */
  17090. add(other: Matrix): Matrix;
  17091. /**
  17092. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17093. * @param other defines the matrix to add
  17094. * @param result defines the target matrix
  17095. * @returns the current matrix
  17096. */
  17097. addToRef(other: Matrix, result: Matrix): Matrix;
  17098. /**
  17099. * Adds in place the given matrix to the current matrix
  17100. * @param other defines the second operand
  17101. * @returns the current updated matrix
  17102. */
  17103. addToSelf(other: Matrix): Matrix;
  17104. /**
  17105. * Sets the given matrix to the current inverted Matrix
  17106. * @param other defines the target matrix
  17107. * @returns the unmodified current matrix
  17108. */
  17109. invertToRef(other: Matrix): Matrix;
  17110. /**
  17111. * Inserts the translation vector (using 3 floats) in the current matrix
  17112. * @param x defines the 1st component of the translation
  17113. * @param y defines the 2nd component of the translation
  17114. * @param z defines the 3rd component of the translation
  17115. * @returns the current updated matrix
  17116. */
  17117. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17118. /**
  17119. * Inserts the translation vector in the current matrix
  17120. * @param vector3 defines the translation to insert
  17121. * @returns the current updated matrix
  17122. */
  17123. setTranslation(vector3: Vector3): Matrix;
  17124. /**
  17125. * Gets the translation value of the current matrix
  17126. * @returns a new Vector3 as the extracted translation from the matrix
  17127. */
  17128. getTranslation(): Vector3;
  17129. /**
  17130. * Fill a Vector3 with the extracted translation from the matrix
  17131. * @param result defines the Vector3 where to store the translation
  17132. * @returns the current matrix
  17133. */
  17134. getTranslationToRef(result: Vector3): Matrix;
  17135. /**
  17136. * Remove rotation and scaling part from the matrix
  17137. * @returns the updated matrix
  17138. */
  17139. removeRotationAndScaling(): Matrix;
  17140. /**
  17141. * Multiply two matrices
  17142. * @param other defines the second operand
  17143. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17144. */
  17145. multiply(other: Matrix): Matrix;
  17146. /**
  17147. * Copy the current matrix from the given one
  17148. * @param other defines the source matrix
  17149. * @returns the current updated matrix
  17150. */
  17151. copyFrom(other: Matrix): Matrix;
  17152. /**
  17153. * Populates the given array from the starting index with the current matrix values
  17154. * @param array defines the target array
  17155. * @param offset defines the offset in the target array where to start storing values
  17156. * @returns the current matrix
  17157. */
  17158. copyToArray(array: Float32Array, offset?: number): Matrix;
  17159. /**
  17160. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17161. * @param other defines the second operand
  17162. * @param result defines the matrix where to store the multiplication
  17163. * @returns the current matrix
  17164. */
  17165. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17166. /**
  17167. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17168. * @param other defines the second operand
  17169. * @param result defines the array where to store the multiplication
  17170. * @param offset defines the offset in the target array where to start storing values
  17171. * @returns the current matrix
  17172. */
  17173. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17174. /**
  17175. * Check equality between this matrix and a second one
  17176. * @param value defines the second matrix to compare
  17177. * @returns true is the current matrix and the given one values are strictly equal
  17178. */
  17179. equals(value: Matrix): boolean;
  17180. /**
  17181. * Clone the current matrix
  17182. * @returns a new matrix from the current matrix
  17183. */
  17184. clone(): Matrix;
  17185. /**
  17186. * Returns the name of the current matrix class
  17187. * @returns the string "Matrix"
  17188. */
  17189. getClassName(): string;
  17190. /**
  17191. * Gets the hash code of the current matrix
  17192. * @returns the hash code
  17193. */
  17194. getHashCode(): number;
  17195. /**
  17196. * Decomposes the current Matrix into a translation, rotation and scaling components
  17197. * @param scale defines the scale vector3 given as a reference to update
  17198. * @param rotation defines the rotation quaternion given as a reference to update
  17199. * @param translation defines the translation vector3 given as a reference to update
  17200. * @returns true if operation was successful
  17201. */
  17202. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17203. /**
  17204. * Gets specific row of the matrix
  17205. * @param index defines the number of the row to get
  17206. * @returns the index-th row of the current matrix as a new Vector4
  17207. */
  17208. getRow(index: number): Nullable<Vector4>;
  17209. /**
  17210. * Sets the index-th row of the current matrix to the vector4 values
  17211. * @param index defines the number of the row to set
  17212. * @param row defines the target vector4
  17213. * @returns the updated current matrix
  17214. */
  17215. setRow(index: number, row: Vector4): Matrix;
  17216. /**
  17217. * Compute the transpose of the matrix
  17218. * @returns the new transposed matrix
  17219. */
  17220. transpose(): Matrix;
  17221. /**
  17222. * Compute the transpose of the matrix and store it in a given matrix
  17223. * @param result defines the target matrix
  17224. * @returns the current matrix
  17225. */
  17226. transposeToRef(result: Matrix): Matrix;
  17227. /**
  17228. * Sets the index-th row of the current matrix with the given 4 x float values
  17229. * @param index defines the row index
  17230. * @param x defines the x component to set
  17231. * @param y defines the y component to set
  17232. * @param z defines the z component to set
  17233. * @param w defines the w component to set
  17234. * @returns the updated current matrix
  17235. */
  17236. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17237. /**
  17238. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17239. * @param scale defines the scale factor
  17240. * @returns a new matrix
  17241. */
  17242. scale(scale: number): Matrix;
  17243. /**
  17244. * Scale the current matrix values by a factor to a given result matrix
  17245. * @param scale defines the scale factor
  17246. * @param result defines the matrix to store the result
  17247. * @returns the current matrix
  17248. */
  17249. scaleToRef(scale: number, result: Matrix): Matrix;
  17250. /**
  17251. * Scale the current matrix values by a factor and add the result to a given matrix
  17252. * @param scale defines the scale factor
  17253. * @param result defines the Matrix to store the result
  17254. * @returns the current matrix
  17255. */
  17256. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17257. /**
  17258. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17259. * @param ref matrix to store the result
  17260. */
  17261. toNormalMatrix(ref: Matrix): void;
  17262. /**
  17263. * Gets only rotation part of the current matrix
  17264. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17265. */
  17266. getRotationMatrix(): Matrix;
  17267. /**
  17268. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17269. * @param result defines the target matrix to store data to
  17270. * @returns the current matrix
  17271. */
  17272. getRotationMatrixToRef(result: Matrix): Matrix;
  17273. /**
  17274. * Creates a matrix from an array
  17275. * @param array defines the source array
  17276. * @param offset defines an offset in the source array
  17277. * @returns a new Matrix set from the starting index of the given array
  17278. */
  17279. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17280. /**
  17281. * Copy the content of an array into a given matrix
  17282. * @param array defines the source array
  17283. * @param offset defines an offset in the source array
  17284. * @param result defines the target matrix
  17285. */
  17286. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17287. /**
  17288. * Stores an array into a matrix after having multiplied each component by a given factor
  17289. * @param array defines the source array
  17290. * @param offset defines the offset in the source array
  17291. * @param scale defines the scaling factor
  17292. * @param result defines the target matrix
  17293. */
  17294. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17295. /**
  17296. * Stores a list of values (16) inside a given matrix
  17297. * @param initialM11 defines 1st value of 1st row
  17298. * @param initialM12 defines 2nd value of 1st row
  17299. * @param initialM13 defines 3rd value of 1st row
  17300. * @param initialM14 defines 4th value of 1st row
  17301. * @param initialM21 defines 1st value of 2nd row
  17302. * @param initialM22 defines 2nd value of 2nd row
  17303. * @param initialM23 defines 3rd value of 2nd row
  17304. * @param initialM24 defines 4th value of 2nd row
  17305. * @param initialM31 defines 1st value of 3rd row
  17306. * @param initialM32 defines 2nd value of 3rd row
  17307. * @param initialM33 defines 3rd value of 3rd row
  17308. * @param initialM34 defines 4th value of 3rd row
  17309. * @param initialM41 defines 1st value of 4th row
  17310. * @param initialM42 defines 2nd value of 4th row
  17311. * @param initialM43 defines 3rd value of 4th row
  17312. * @param initialM44 defines 4th value of 4th row
  17313. * @param result defines the target matrix
  17314. */
  17315. 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;
  17316. /**
  17317. * Gets an identity matrix that must not be updated
  17318. */
  17319. static readonly IdentityReadOnly: Matrix;
  17320. /**
  17321. * Creates new matrix from a list of values (16)
  17322. * @param initialM11 defines 1st value of 1st row
  17323. * @param initialM12 defines 2nd value of 1st row
  17324. * @param initialM13 defines 3rd value of 1st row
  17325. * @param initialM14 defines 4th value of 1st row
  17326. * @param initialM21 defines 1st value of 2nd row
  17327. * @param initialM22 defines 2nd value of 2nd row
  17328. * @param initialM23 defines 3rd value of 2nd row
  17329. * @param initialM24 defines 4th value of 2nd row
  17330. * @param initialM31 defines 1st value of 3rd row
  17331. * @param initialM32 defines 2nd value of 3rd row
  17332. * @param initialM33 defines 3rd value of 3rd row
  17333. * @param initialM34 defines 4th value of 3rd row
  17334. * @param initialM41 defines 1st value of 4th row
  17335. * @param initialM42 defines 2nd value of 4th row
  17336. * @param initialM43 defines 3rd value of 4th row
  17337. * @param initialM44 defines 4th value of 4th row
  17338. * @returns the new matrix
  17339. */
  17340. 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;
  17341. /**
  17342. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17343. * @param scale defines the scale vector3
  17344. * @param rotation defines the rotation quaternion
  17345. * @param translation defines the translation vector3
  17346. * @returns a new matrix
  17347. */
  17348. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17349. /**
  17350. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17351. * @param scale defines the scale vector3
  17352. * @param rotation defines the rotation quaternion
  17353. * @param translation defines the translation vector3
  17354. * @param result defines the target matrix
  17355. */
  17356. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17357. /**
  17358. * Creates a new identity matrix
  17359. * @returns a new identity matrix
  17360. */
  17361. static Identity(): Matrix;
  17362. /**
  17363. * Creates a new identity matrix and stores the result in a given matrix
  17364. * @param result defines the target matrix
  17365. */
  17366. static IdentityToRef(result: Matrix): void;
  17367. /**
  17368. * Creates a new zero matrix
  17369. * @returns a new zero matrix
  17370. */
  17371. static Zero(): Matrix;
  17372. /**
  17373. * Creates a new rotation matrix for "angle" radians around the X axis
  17374. * @param angle defines the angle (in radians) to use
  17375. * @return the new matrix
  17376. */
  17377. static RotationX(angle: number): Matrix;
  17378. /**
  17379. * Creates a new matrix as the invert of a given matrix
  17380. * @param source defines the source matrix
  17381. * @returns the new matrix
  17382. */
  17383. static Invert(source: Matrix): Matrix;
  17384. /**
  17385. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17386. * @param angle defines the angle (in radians) to use
  17387. * @param result defines the target matrix
  17388. */
  17389. static RotationXToRef(angle: number, result: Matrix): void;
  17390. /**
  17391. * Creates a new rotation matrix for "angle" radians around the Y axis
  17392. * @param angle defines the angle (in radians) to use
  17393. * @return the new matrix
  17394. */
  17395. static RotationY(angle: number): Matrix;
  17396. /**
  17397. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17398. * @param angle defines the angle (in radians) to use
  17399. * @param result defines the target matrix
  17400. */
  17401. static RotationYToRef(angle: number, result: Matrix): void;
  17402. /**
  17403. * Creates a new rotation matrix for "angle" radians around the Z axis
  17404. * @param angle defines the angle (in radians) to use
  17405. * @return the new matrix
  17406. */
  17407. static RotationZ(angle: number): Matrix;
  17408. /**
  17409. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17410. * @param angle defines the angle (in radians) to use
  17411. * @param result defines the target matrix
  17412. */
  17413. static RotationZToRef(angle: number, result: Matrix): void;
  17414. /**
  17415. * Creates a new rotation matrix for "angle" radians around the given axis
  17416. * @param axis defines the axis to use
  17417. * @param angle defines the angle (in radians) to use
  17418. * @return the new matrix
  17419. */
  17420. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17421. /**
  17422. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17423. * @param axis defines the axis to use
  17424. * @param angle defines the angle (in radians) to use
  17425. * @param result defines the target matrix
  17426. */
  17427. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17428. /**
  17429. * Creates a rotation matrix
  17430. * @param yaw defines the yaw angle in radians (Y axis)
  17431. * @param pitch defines the pitch angle in radians (X axis)
  17432. * @param roll defines the roll angle in radians (X axis)
  17433. * @returns the new rotation matrix
  17434. */
  17435. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17436. /**
  17437. * Creates a rotation matrix and stores it in a given matrix
  17438. * @param yaw defines the yaw angle in radians (Y axis)
  17439. * @param pitch defines the pitch angle in radians (X axis)
  17440. * @param roll defines the roll angle in radians (X axis)
  17441. * @param result defines the target matrix
  17442. */
  17443. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17444. /**
  17445. * Creates a scaling matrix
  17446. * @param x defines the scale factor on X axis
  17447. * @param y defines the scale factor on Y axis
  17448. * @param z defines the scale factor on Z axis
  17449. * @returns the new matrix
  17450. */
  17451. static Scaling(x: number, y: number, z: number): Matrix;
  17452. /**
  17453. * Creates a scaling matrix and stores it in a given matrix
  17454. * @param x defines the scale factor on X axis
  17455. * @param y defines the scale factor on Y axis
  17456. * @param z defines the scale factor on Z axis
  17457. * @param result defines the target matrix
  17458. */
  17459. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17460. /**
  17461. * Creates a translation matrix
  17462. * @param x defines the translation on X axis
  17463. * @param y defines the translation on Y axis
  17464. * @param z defines the translationon Z axis
  17465. * @returns the new matrix
  17466. */
  17467. static Translation(x: number, y: number, z: number): Matrix;
  17468. /**
  17469. * Creates a translation matrix and stores it in a given matrix
  17470. * @param x defines the translation on X axis
  17471. * @param y defines the translation on Y axis
  17472. * @param z defines the translationon Z axis
  17473. * @param result defines the target matrix
  17474. */
  17475. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17476. /**
  17477. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17478. * @param startValue defines the start value
  17479. * @param endValue defines the end value
  17480. * @param gradient defines the gradient factor
  17481. * @returns the new matrix
  17482. */
  17483. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17484. /**
  17485. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17486. * @param startValue defines the start value
  17487. * @param endValue defines the end value
  17488. * @param gradient defines the gradient factor
  17489. * @param result defines the Matrix object where to store data
  17490. */
  17491. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17492. /**
  17493. * Builds a new matrix whose values are computed by:
  17494. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17495. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17496. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17497. * @param startValue defines the first matrix
  17498. * @param endValue defines the second matrix
  17499. * @param gradient defines the gradient between the two matrices
  17500. * @returns the new matrix
  17501. */
  17502. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17503. /**
  17504. * Update a matrix to values which are computed by:
  17505. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17506. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17507. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17508. * @param startValue defines the first matrix
  17509. * @param endValue defines the second matrix
  17510. * @param gradient defines the gradient between the two matrices
  17511. * @param result defines the target matrix
  17512. */
  17513. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17514. /**
  17515. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  17516. * This function works in left handed mode
  17517. * @param eye defines the final position of the entity
  17518. * @param target defines where the entity should look at
  17519. * @param up defines the up vector for the entity
  17520. * @returns the new matrix
  17521. */
  17522. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17523. /**
  17524. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  17525. * This function works in left handed mode
  17526. * @param eye defines the final position of the entity
  17527. * @param target defines where the entity should look at
  17528. * @param up defines the up vector for the entity
  17529. * @param result defines the target matrix
  17530. */
  17531. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17532. /**
  17533. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  17534. * This function works in right handed mode
  17535. * @param eye defines the final position of the entity
  17536. * @param target defines where the entity should look at
  17537. * @param up defines the up vector for the entity
  17538. * @returns the new matrix
  17539. */
  17540. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17541. /**
  17542. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  17543. * This function works in right handed mode
  17544. * @param eye defines the final position of the entity
  17545. * @param target defines where the entity should look at
  17546. * @param up defines the up vector for the entity
  17547. * @param result defines the target matrix
  17548. */
  17549. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17550. /**
  17551. * Create a left-handed orthographic projection matrix
  17552. * @param width defines the viewport width
  17553. * @param height defines the viewport height
  17554. * @param znear defines the near clip plane
  17555. * @param zfar defines the far clip plane
  17556. * @returns a new matrix as a left-handed orthographic projection matrix
  17557. */
  17558. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17559. /**
  17560. * Store a left-handed orthographic projection to a given matrix
  17561. * @param width defines the viewport width
  17562. * @param height defines the viewport height
  17563. * @param znear defines the near clip plane
  17564. * @param zfar defines the far clip plane
  17565. * @param result defines the target matrix
  17566. */
  17567. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17568. /**
  17569. * Create a left-handed orthographic projection matrix
  17570. * @param left defines the viewport left coordinate
  17571. * @param right defines the viewport right coordinate
  17572. * @param bottom defines the viewport bottom coordinate
  17573. * @param top defines the viewport top coordinate
  17574. * @param znear defines the near clip plane
  17575. * @param zfar defines the far clip plane
  17576. * @returns a new matrix as a left-handed orthographic projection matrix
  17577. */
  17578. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17579. /**
  17580. * Stores a left-handed orthographic projection into a given matrix
  17581. * @param left defines the viewport left coordinate
  17582. * @param right defines the viewport right coordinate
  17583. * @param bottom defines the viewport bottom coordinate
  17584. * @param top defines the viewport top coordinate
  17585. * @param znear defines the near clip plane
  17586. * @param zfar defines the far clip plane
  17587. * @param result defines the target matrix
  17588. */
  17589. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17590. /**
  17591. * Creates a right-handed orthographic projection matrix
  17592. * @param left defines the viewport left coordinate
  17593. * @param right defines the viewport right coordinate
  17594. * @param bottom defines the viewport bottom coordinate
  17595. * @param top defines the viewport top coordinate
  17596. * @param znear defines the near clip plane
  17597. * @param zfar defines the far clip plane
  17598. * @returns a new matrix as a right-handed orthographic projection matrix
  17599. */
  17600. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17601. /**
  17602. * Stores a right-handed orthographic projection into a given matrix
  17603. * @param left defines the viewport left coordinate
  17604. * @param right defines the viewport right coordinate
  17605. * @param bottom defines the viewport bottom coordinate
  17606. * @param top defines the viewport top coordinate
  17607. * @param znear defines the near clip plane
  17608. * @param zfar defines the far clip plane
  17609. * @param result defines the target matrix
  17610. */
  17611. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17612. /**
  17613. * Creates a left-handed perspective projection matrix
  17614. * @param width defines the viewport width
  17615. * @param height defines the viewport height
  17616. * @param znear defines the near clip plane
  17617. * @param zfar defines the far clip plane
  17618. * @returns a new matrix as a left-handed perspective projection matrix
  17619. */
  17620. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17621. /**
  17622. * Creates a left-handed perspective projection matrix
  17623. * @param fov defines the horizontal field of view
  17624. * @param aspect defines the aspect ratio
  17625. * @param znear defines the near clip plane
  17626. * @param zfar defines the far clip plane
  17627. * @returns a new matrix as a left-handed perspective projection matrix
  17628. */
  17629. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17630. /**
  17631. * Stores a left-handed perspective projection into a given matrix
  17632. * @param fov defines the horizontal field of view
  17633. * @param aspect defines the aspect ratio
  17634. * @param znear defines the near clip plane
  17635. * @param zfar defines the far clip plane
  17636. * @param result defines the target matrix
  17637. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17638. */
  17639. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17640. /**
  17641. * Creates a right-handed perspective projection matrix
  17642. * @param fov defines the horizontal field of view
  17643. * @param aspect defines the aspect ratio
  17644. * @param znear defines the near clip plane
  17645. * @param zfar defines the far clip plane
  17646. * @returns a new matrix as a right-handed perspective projection matrix
  17647. */
  17648. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17649. /**
  17650. * Stores a right-handed perspective projection into a given matrix
  17651. * @param fov defines the horizontal field of view
  17652. * @param aspect defines the aspect ratio
  17653. * @param znear defines the near clip plane
  17654. * @param zfar defines the far clip plane
  17655. * @param result defines the target matrix
  17656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17657. */
  17658. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17659. /**
  17660. * Stores a perspective projection for WebVR info a given matrix
  17661. * @param fov defines the field of view
  17662. * @param znear defines the near clip plane
  17663. * @param zfar defines the far clip plane
  17664. * @param result defines the target matrix
  17665. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17666. */
  17667. static PerspectiveFovWebVRToRef(fov: {
  17668. upDegrees: number;
  17669. downDegrees: number;
  17670. leftDegrees: number;
  17671. rightDegrees: number;
  17672. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17673. /**
  17674. * Computes a complete transformation matrix
  17675. * @param viewport defines the viewport to use
  17676. * @param world defines the world matrix
  17677. * @param view defines the view matrix
  17678. * @param projection defines the projection matrix
  17679. * @param zmin defines the near clip plane
  17680. * @param zmax defines the far clip plane
  17681. * @returns the transformation matrix
  17682. */
  17683. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17684. /**
  17685. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17686. * @param matrix defines the matrix to use
  17687. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17688. */
  17689. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17690. /**
  17691. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17692. * @param matrix defines the matrix to use
  17693. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17694. */
  17695. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17696. /**
  17697. * Compute the transpose of a given matrix
  17698. * @param matrix defines the matrix to transpose
  17699. * @returns the new matrix
  17700. */
  17701. static Transpose(matrix: Matrix): Matrix;
  17702. /**
  17703. * Compute the transpose of a matrix and store it in a target matrix
  17704. * @param matrix defines the matrix to transpose
  17705. * @param result defines the target matrix
  17706. */
  17707. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17708. /**
  17709. * Computes a reflection matrix from a plane
  17710. * @param plane defines the reflection plane
  17711. * @returns a new matrix
  17712. */
  17713. static Reflection(plane: Plane): Matrix;
  17714. /**
  17715. * Computes a reflection matrix from a plane
  17716. * @param plane defines the reflection plane
  17717. * @param result defines the target matrix
  17718. */
  17719. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17720. /**
  17721. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17722. * @param xaxis defines the value of the 1st axis
  17723. * @param yaxis defines the value of the 2nd axis
  17724. * @param zaxis defines the value of the 3rd axis
  17725. * @param result defines the target matrix
  17726. */
  17727. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17728. /**
  17729. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17730. * @param quat defines the quaternion to use
  17731. * @param result defines the target matrix
  17732. */
  17733. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17734. }
  17735. class Plane {
  17736. normal: Vector3;
  17737. d: number;
  17738. /**
  17739. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17740. */
  17741. constructor(a: number, b: number, c: number, d: number);
  17742. /**
  17743. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17744. */
  17745. asArray(): number[];
  17746. /**
  17747. * Returns a new plane copied from the current Plane.
  17748. */
  17749. clone(): Plane;
  17750. /**
  17751. * Returns the string "Plane".
  17752. */
  17753. getClassName(): string;
  17754. /**
  17755. * Returns the Plane hash code.
  17756. */
  17757. getHashCode(): number;
  17758. /**
  17759. * Normalize the current Plane in place.
  17760. * Returns the updated Plane.
  17761. */
  17762. normalize(): Plane;
  17763. /**
  17764. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17765. */
  17766. transform(transformation: Matrix): Plane;
  17767. /**
  17768. * Returns the dot product (float) of the point coordinates and the plane normal.
  17769. */
  17770. dotCoordinate(point: Vector3): number;
  17771. /**
  17772. * Updates the current Plane from the plane defined by the three given points.
  17773. * Returns the updated Plane.
  17774. */
  17775. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17776. /**
  17777. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17778. */
  17779. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17780. /**
  17781. * Returns the signed distance (float) from the given point to the Plane.
  17782. */
  17783. signedDistanceTo(point: Vector3): number;
  17784. /**
  17785. * Returns a new Plane from the given array.
  17786. */
  17787. static FromArray(array: ArrayLike<number>): Plane;
  17788. /**
  17789. * Returns a new Plane defined by the three given points.
  17790. */
  17791. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17792. /**
  17793. * Returns a new Plane the normal vector to this plane at the given origin point.
  17794. * Note : the vector "normal" is updated because normalized.
  17795. */
  17796. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17797. /**
  17798. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17799. */
  17800. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17801. }
  17802. class Viewport {
  17803. x: number;
  17804. y: number;
  17805. width: number;
  17806. height: number;
  17807. /**
  17808. * Creates a Viewport object located at (x, y) and sized (width, height).
  17809. */
  17810. constructor(x: number, y: number, width: number, height: number);
  17811. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17812. /**
  17813. * Returns a new Viewport copied from the current one.
  17814. */
  17815. clone(): Viewport;
  17816. }
  17817. class Frustum {
  17818. /**
  17819. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17820. */
  17821. static GetPlanes(transform: Matrix): Plane[];
  17822. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17823. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17824. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17825. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17826. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17827. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17828. /**
  17829. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17830. */
  17831. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17832. }
  17833. /** Defines supported spaces */
  17834. enum Space {
  17835. /** Local (object) space */
  17836. LOCAL = 0,
  17837. /** World space */
  17838. WORLD = 1,
  17839. /** Bone space */
  17840. BONE = 2,
  17841. }
  17842. /** Defines the 3 main axes */
  17843. class Axis {
  17844. /** X axis */
  17845. static X: Vector3;
  17846. /** Y axis */
  17847. static Y: Vector3;
  17848. /** Z axis */
  17849. static Z: Vector3;
  17850. }
  17851. class BezierCurve {
  17852. /**
  17853. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17854. */
  17855. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17856. }
  17857. /**
  17858. * Defines potential orientation for back face culling
  17859. */
  17860. enum Orientation {
  17861. /**
  17862. * Clockwise
  17863. */
  17864. CW = 0,
  17865. /** Counter clockwise */
  17866. CCW = 1,
  17867. }
  17868. /**
  17869. * Defines angle representation
  17870. */
  17871. class Angle {
  17872. private _radians;
  17873. /**
  17874. * Creates an Angle object of "radians" radians (float).
  17875. */
  17876. constructor(radians: number);
  17877. /**
  17878. * Get value in degrees
  17879. * @returns the Angle value in degrees (float)
  17880. */
  17881. degrees(): number;
  17882. /**
  17883. * Get value in radians
  17884. * @returns the Angle value in radians (float)
  17885. */
  17886. radians(): number;
  17887. /**
  17888. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17889. * @param a defines first vector
  17890. * @param b defines second vector
  17891. * @returns a new Angle
  17892. */
  17893. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17894. /**
  17895. * Gets a new Angle object from the given float in radians
  17896. * @param radians defines the angle value in radians
  17897. * @returns a new Angle
  17898. */
  17899. static FromRadians(radians: number): Angle;
  17900. /**
  17901. * Gets a new Angle object from the given float in degrees
  17902. * @param degrees defines the angle value in degrees
  17903. * @returns a new Angle
  17904. */
  17905. static FromDegrees(degrees: number): Angle;
  17906. }
  17907. class Arc2 {
  17908. startPoint: Vector2;
  17909. midPoint: Vector2;
  17910. endPoint: Vector2;
  17911. centerPoint: Vector2;
  17912. radius: number;
  17913. angle: Angle;
  17914. startAngle: Angle;
  17915. orientation: Orientation;
  17916. /**
  17917. * Creates an Arc object from the three given points : start, middle and end.
  17918. */
  17919. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17920. }
  17921. class Path2 {
  17922. private _points;
  17923. private _length;
  17924. closed: boolean;
  17925. /**
  17926. * Creates a Path2 object from the starting 2D coordinates x and y.
  17927. */
  17928. constructor(x: number, y: number);
  17929. /**
  17930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17931. * Returns the updated Path2.
  17932. */
  17933. addLineTo(x: number, y: number): Path2;
  17934. /**
  17935. * 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.
  17936. * Returns the updated Path2.
  17937. */
  17938. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17939. /**
  17940. * Closes the Path2.
  17941. * Returns the Path2.
  17942. */
  17943. close(): Path2;
  17944. /**
  17945. * Returns the Path2 total length (float).
  17946. */
  17947. length(): number;
  17948. /**
  17949. * Returns the Path2 internal array of points.
  17950. */
  17951. getPoints(): Vector2[];
  17952. /**
  17953. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17954. */
  17955. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17956. /**
  17957. * Returns a new Path2 starting at the coordinates (x, y).
  17958. */
  17959. static StartingAt(x: number, y: number): Path2;
  17960. }
  17961. class Path3D {
  17962. path: Vector3[];
  17963. private _curve;
  17964. private _distances;
  17965. private _tangents;
  17966. private _normals;
  17967. private _binormals;
  17968. private _raw;
  17969. /**
  17970. * new Path3D(path, normal, raw)
  17971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  17972. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  17973. * path : an array of Vector3, the curve axis of the Path3D
  17974. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  17975. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  17976. */
  17977. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  17978. /**
  17979. * Returns the Path3D array of successive Vector3 designing its curve.
  17980. */
  17981. getCurve(): Vector3[];
  17982. /**
  17983. * Returns an array populated with tangent vectors on each Path3D curve point.
  17984. */
  17985. getTangents(): Vector3[];
  17986. /**
  17987. * Returns an array populated with normal vectors on each Path3D curve point.
  17988. */
  17989. getNormals(): Vector3[];
  17990. /**
  17991. * Returns an array populated with binormal vectors on each Path3D curve point.
  17992. */
  17993. getBinormals(): Vector3[];
  17994. /**
  17995. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  17996. */
  17997. getDistances(): number[];
  17998. /**
  17999. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18000. * Returns the same object updated.
  18001. */
  18002. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18003. private _compute(firstNormal);
  18004. private _getFirstNonNullVector(index);
  18005. private _getLastNonNullVector(index);
  18006. private _normalVector(v0, vt, va);
  18007. }
  18008. class Curve3 {
  18009. private _points;
  18010. private _length;
  18011. /**
  18012. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18013. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18014. * @param v1 (Vector3) the control point
  18015. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18016. * @param nbPoints (integer) the wanted number of points in the curve
  18017. */
  18018. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18019. /**
  18020. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18021. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18022. * @param v1 (Vector3) the first control point
  18023. * @param v2 (Vector3) the second control point
  18024. * @param v3 (Vector3) the end point of the Cubic Bezier
  18025. * @param nbPoints (integer) the wanted number of points in the curve
  18026. */
  18027. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18028. /**
  18029. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18030. * @param p1 (Vector3) the origin point of the Hermite Spline
  18031. * @param t1 (Vector3) the tangent vector at the origin point
  18032. * @param p2 (Vector3) the end point of the Hermite Spline
  18033. * @param t2 (Vector3) the tangent vector at the end point
  18034. * @param nbPoints (integer) the wanted number of points in the curve
  18035. */
  18036. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18037. /**
  18038. * Returns a Curve3 object along a CatmullRom Spline curve :
  18039. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18040. * @param nbPoints (integer) the wanted number of points between each curve control points
  18041. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18042. */
  18043. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18044. /**
  18045. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18046. * A Curve3 is designed from a series of successive Vector3.
  18047. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18048. */
  18049. constructor(points: Vector3[]);
  18050. /**
  18051. * Returns the Curve3 stored array of successive Vector3
  18052. */
  18053. getPoints(): Vector3[];
  18054. /**
  18055. * Returns the computed length (float) of the curve.
  18056. */
  18057. length(): number;
  18058. /**
  18059. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18060. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18061. * curveA and curveB keep unchanged.
  18062. */
  18063. continue(curve: Curve3): Curve3;
  18064. private _computeLength(path);
  18065. }
  18066. class PositionNormalVertex {
  18067. position: Vector3;
  18068. normal: Vector3;
  18069. constructor(position?: Vector3, normal?: Vector3);
  18070. clone(): PositionNormalVertex;
  18071. }
  18072. class PositionNormalTextureVertex {
  18073. position: Vector3;
  18074. normal: Vector3;
  18075. uv: Vector2;
  18076. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18077. clone(): PositionNormalTextureVertex;
  18078. }
  18079. class Tmp {
  18080. static Color3: Color3[];
  18081. static Vector2: Vector2[];
  18082. static Vector3: Vector3[];
  18083. static Vector4: Vector4[];
  18084. static Quaternion: Quaternion[];
  18085. static Matrix: Matrix[];
  18086. }
  18087. }
  18088. declare module BABYLON {
  18089. class SphericalPolynomial {
  18090. x: Vector3;
  18091. y: Vector3;
  18092. z: Vector3;
  18093. xx: Vector3;
  18094. yy: Vector3;
  18095. zz: Vector3;
  18096. xy: Vector3;
  18097. yz: Vector3;
  18098. zx: Vector3;
  18099. addAmbient(color: Color3): void;
  18100. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18101. scale(scale: number): void;
  18102. }
  18103. class SphericalHarmonics {
  18104. L00: Vector3;
  18105. L1_1: Vector3;
  18106. L10: Vector3;
  18107. L11: Vector3;
  18108. L2_2: Vector3;
  18109. L2_1: Vector3;
  18110. L20: Vector3;
  18111. L21: Vector3;
  18112. L22: Vector3;
  18113. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18114. scale(scale: number): void;
  18115. convertIncidentRadianceToIrradiance(): void;
  18116. convertIrradianceToLambertianRadiance(): void;
  18117. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18118. }
  18119. }
  18120. declare module BABYLON {
  18121. /**
  18122. * Defines a target to use with MorphTargetManager
  18123. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18124. */
  18125. class MorphTarget implements IAnimatable {
  18126. /** defines the name of the target */
  18127. name: string;
  18128. /**
  18129. * Gets or sets the list of animations
  18130. */
  18131. animations: Animation[];
  18132. private _scene;
  18133. private _positions;
  18134. private _normals;
  18135. private _tangents;
  18136. private _influence;
  18137. /**
  18138. * Observable raised when the influence changes
  18139. */
  18140. onInfluenceChanged: Observable<boolean>;
  18141. /**
  18142. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18143. */
  18144. influence: number;
  18145. private _animationPropertiesOverride;
  18146. /**
  18147. * Gets or sets the animation properties override
  18148. */
  18149. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18150. /**
  18151. * Creates a new MorphTarget
  18152. * @param name defines the name of the target
  18153. * @param influence defines the influence to use
  18154. */
  18155. constructor(
  18156. /** defines the name of the target */
  18157. name: string, influence?: number, scene?: Nullable<Scene>);
  18158. /**
  18159. * Gets a boolean defining if the target contains position data
  18160. */
  18161. readonly hasPositions: boolean;
  18162. /**
  18163. * Gets a boolean defining if the target contains normal data
  18164. */
  18165. readonly hasNormals: boolean;
  18166. /**
  18167. * Gets a boolean defining if the target contains tangent data
  18168. */
  18169. readonly hasTangents: boolean;
  18170. /**
  18171. * Affects position data to this target
  18172. * @param data defines the position data to use
  18173. */
  18174. setPositions(data: Nullable<FloatArray>): void;
  18175. /**
  18176. * Gets the position data stored in this target
  18177. * @returns a FloatArray containing the position data (or null if not present)
  18178. */
  18179. getPositions(): Nullable<FloatArray>;
  18180. /**
  18181. * Affects normal data to this target
  18182. * @param data defines the normal data to use
  18183. */
  18184. setNormals(data: Nullable<FloatArray>): void;
  18185. /**
  18186. * Gets the normal data stored in this target
  18187. * @returns a FloatArray containing the normal data (or null if not present)
  18188. */
  18189. getNormals(): Nullable<FloatArray>;
  18190. /**
  18191. * Affects tangent data to this target
  18192. * @param data defines the tangent data to use
  18193. */
  18194. setTangents(data: Nullable<FloatArray>): void;
  18195. /**
  18196. * Gets the tangent data stored in this target
  18197. * @returns a FloatArray containing the tangent data (or null if not present)
  18198. */
  18199. getTangents(): Nullable<FloatArray>;
  18200. /**
  18201. * Serializes the current target into a Serialization object
  18202. * @returns the serialized object
  18203. */
  18204. serialize(): any;
  18205. /**
  18206. * Creates a new target from serialized data
  18207. * @param serializationObject defines the serialized data to use
  18208. * @returns a new MorphTarget
  18209. */
  18210. static Parse(serializationObject: any): MorphTarget;
  18211. /**
  18212. * Creates a MorphTarget from mesh data
  18213. * @param mesh defines the source mesh
  18214. * @param name defines the name to use for the new target
  18215. * @param influence defines the influence to attach to the target
  18216. * @returns a new MorphTarget
  18217. */
  18218. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18219. }
  18220. }
  18221. declare module BABYLON {
  18222. /**
  18223. * This class is used to deform meshes using morphing between different targets
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18225. */
  18226. class MorphTargetManager {
  18227. private _targets;
  18228. private _targetObservable;
  18229. private _activeTargets;
  18230. private _scene;
  18231. private _influences;
  18232. private _supportsNormals;
  18233. private _supportsTangents;
  18234. private _vertexCount;
  18235. private _uniqueId;
  18236. private _tempInfluences;
  18237. /**
  18238. * Creates a new MorphTargetManager
  18239. * @param scene defines the current scene
  18240. */
  18241. constructor(scene?: Nullable<Scene>);
  18242. /**
  18243. * Gets the unique ID of this manager
  18244. */
  18245. readonly uniqueId: number;
  18246. /**
  18247. * Gets the number of vertices handled by this manager
  18248. */
  18249. readonly vertexCount: number;
  18250. /**
  18251. * Gets a boolean indicating if this manager supports morphing of normals
  18252. */
  18253. readonly supportsNormals: boolean;
  18254. /**
  18255. * Gets a boolean indicating if this manager supports morphing of tangents
  18256. */
  18257. readonly supportsTangents: boolean;
  18258. /**
  18259. * Gets the number of targets stored in this manager
  18260. */
  18261. readonly numTargets: number;
  18262. /**
  18263. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18264. */
  18265. readonly numInfluencers: number;
  18266. /**
  18267. * Gets the list of influences (one per target)
  18268. */
  18269. readonly influences: Float32Array;
  18270. /**
  18271. * Gets the active target at specified index. An active target is a target with an influence > 0
  18272. * @param index defines the index to check
  18273. * @returns the requested target
  18274. */
  18275. getActiveTarget(index: number): MorphTarget;
  18276. /**
  18277. * Gets the target at specified index
  18278. * @param index defines the index to check
  18279. * @returns the requested target
  18280. */
  18281. getTarget(index: number): MorphTarget;
  18282. /**
  18283. * Add a new target to this manager
  18284. * @param target defines the target to add
  18285. */
  18286. addTarget(target: MorphTarget): void;
  18287. /**
  18288. * Removes a target from the manager
  18289. * @param target defines the target to remove
  18290. */
  18291. removeTarget(target: MorphTarget): void;
  18292. /**
  18293. * Serializes the current manager into a Serialization object
  18294. * @returns the serialized object
  18295. */
  18296. serialize(): any;
  18297. private _syncActiveTargets(needUpdate);
  18298. /**
  18299. * Syncrhonize the targets with all the meshes using this morph target manager
  18300. */
  18301. synchronize(): void;
  18302. /**
  18303. * Creates a new MorphTargetManager from serialized data
  18304. * @param serializationObject defines the serialized data
  18305. * @param scene defines the hosting scene
  18306. * @returns the new MorphTargetManager
  18307. */
  18308. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18309. }
  18310. }
  18311. declare module BABYLON {
  18312. /**
  18313. * Class used to store all common mesh properties
  18314. */
  18315. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18316. /** No occlusion */
  18317. static OCCLUSION_TYPE_NONE: number;
  18318. /** Occlusion set to optimisitic */
  18319. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18320. /** Occlusion set to strict */
  18321. static OCCLUSION_TYPE_STRICT: number;
  18322. /** Use an accurante occlusion algorithm */
  18323. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18324. /** Use a conservative occlusion algorithm */
  18325. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18326. /**
  18327. * No billboard
  18328. */
  18329. static readonly BILLBOARDMODE_NONE: number;
  18330. /** Billboard on X axis */
  18331. static readonly BILLBOARDMODE_X: number;
  18332. /** Billboard on Y axis */
  18333. static readonly BILLBOARDMODE_Y: number;
  18334. /** Billboard on Z axis */
  18335. static readonly BILLBOARDMODE_Z: number;
  18336. /** Billboard on all axes */
  18337. static readonly BILLBOARDMODE_ALL: number;
  18338. private _facetPositions;
  18339. private _facetNormals;
  18340. private _facetPartitioning;
  18341. private _facetNb;
  18342. private _partitioningSubdivisions;
  18343. private _partitioningBBoxRatio;
  18344. private _facetDataEnabled;
  18345. private _facetParameters;
  18346. private _bbSize;
  18347. private _subDiv;
  18348. private _facetDepthSort;
  18349. private _facetDepthSortEnabled;
  18350. private _depthSortedIndices;
  18351. private _depthSortedFacets;
  18352. private _facetDepthSortFunction;
  18353. private _facetDepthSortFrom;
  18354. private _facetDepthSortOrigin;
  18355. private _invertedMatrix;
  18356. /**
  18357. * Gets the number of facets in the mesh
  18358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18359. */
  18360. readonly facetNb: number;
  18361. /**
  18362. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18364. */
  18365. partitioningSubdivisions: number;
  18366. /**
  18367. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18368. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18370. */
  18371. partitioningBBoxRatio: number;
  18372. /**
  18373. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18374. * Works only for updatable meshes.
  18375. * Doesn't work with multi-materials
  18376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18377. */
  18378. mustDepthSortFacets: boolean;
  18379. /**
  18380. * The location (Vector3) where the facet depth sort must be computed from.
  18381. * By default, the active camera position.
  18382. * Used only when facet depth sort is enabled
  18383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18384. */
  18385. facetDepthSortFrom: Vector3;
  18386. /**
  18387. * gets a boolean indicating if facetData is enabled
  18388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18389. */
  18390. readonly isFacetDataEnabled: boolean;
  18391. /** @hidden */
  18392. _updateNonUniformScalingState(value: boolean): boolean;
  18393. /**
  18394. * An event triggered when this mesh collides with another one
  18395. */
  18396. onCollideObservable: Observable<AbstractMesh>;
  18397. private _onCollideObserver;
  18398. /** Set a function to call when this mesh collides with another one */
  18399. onCollide: () => void;
  18400. /**
  18401. * An event triggered when the collision's position changes
  18402. */
  18403. onCollisionPositionChangeObservable: Observable<Vector3>;
  18404. private _onCollisionPositionChangeObserver;
  18405. /** Set a function to call when the collision's position changes */
  18406. onCollisionPositionChange: () => void;
  18407. /**
  18408. * An event triggered when material is changed
  18409. */
  18410. onMaterialChangedObservable: Observable<AbstractMesh>;
  18411. /**
  18412. * Gets or sets the orientation for POV movement & rotation
  18413. */
  18414. definedFacingForward: boolean;
  18415. /**
  18416. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18417. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18418. * * 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.
  18419. * @see http://doc.babylonjs.com/features/occlusionquery
  18420. */
  18421. occlusionQueryAlgorithmType: number;
  18422. /**
  18423. * 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:
  18424. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18425. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18426. * * 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.
  18427. * @see http://doc.babylonjs.com/features/occlusionquery
  18428. */
  18429. occlusionType: number;
  18430. /**
  18431. * 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.
  18432. * The default value is -1 which means don't break the query and wait till the result
  18433. * @see http://doc.babylonjs.com/features/occlusionquery
  18434. */
  18435. occlusionRetryCount: number;
  18436. private _occlusionInternalRetryCounter;
  18437. protected _isOccluded: boolean;
  18438. /**
  18439. * 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
  18440. * @see http://doc.babylonjs.com/features/occlusionquery
  18441. */
  18442. isOccluded: boolean;
  18443. private _isOcclusionQueryInProgress;
  18444. /**
  18445. * Flag to check the progress status of the query
  18446. * @see http://doc.babylonjs.com/features/occlusionquery
  18447. */
  18448. readonly isOcclusionQueryInProgress: boolean;
  18449. private _occlusionQuery;
  18450. private _visibility;
  18451. /**
  18452. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18453. */
  18454. /**
  18455. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18456. */
  18457. visibility: number;
  18458. /** Gets or sets the alpha index used to sort transparent meshes
  18459. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18460. */
  18461. alphaIndex: number;
  18462. /**
  18463. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18464. */
  18465. isVisible: boolean;
  18466. /**
  18467. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18468. */
  18469. isPickable: boolean;
  18470. /**
  18471. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18472. */
  18473. showBoundingBox: boolean;
  18474. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18475. showSubMeshesBoundingBox: boolean;
  18476. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18477. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18478. */
  18479. isBlocker: boolean;
  18480. /**
  18481. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18482. */
  18483. enablePointerMoveEvents: boolean;
  18484. /**
  18485. * Specifies the rendering group id for this mesh (0 by default)
  18486. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18487. */
  18488. renderingGroupId: number;
  18489. private _material;
  18490. /** Gets or sets current material */
  18491. material: Nullable<Material>;
  18492. private _receiveShadows;
  18493. /**
  18494. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18495. * @see http://doc.babylonjs.com/babylon101/shadows
  18496. */
  18497. receiveShadows: boolean;
  18498. /**
  18499. * Gets or sets a boolean indicating if the outline must be rendered as well
  18500. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18501. */
  18502. renderOutline: boolean;
  18503. /** Defines color to use when rendering outline */
  18504. outlineColor: Color3;
  18505. /** Define width to use when rendering outline */
  18506. outlineWidth: number;
  18507. /**
  18508. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18509. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18510. */
  18511. renderOverlay: boolean;
  18512. /** Defines color to use when rendering overlay */
  18513. overlayColor: Color3;
  18514. /** Defines alpha to use when rendering overlay */
  18515. overlayAlpha: number;
  18516. private _hasVertexAlpha;
  18517. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18518. hasVertexAlpha: boolean;
  18519. private _useVertexColors;
  18520. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  18521. useVertexColors: boolean;
  18522. private _computeBonesUsingShaders;
  18523. /**
  18524. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18525. */
  18526. computeBonesUsingShaders: boolean;
  18527. private _numBoneInfluencers;
  18528. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18529. numBoneInfluencers: number;
  18530. private _applyFog;
  18531. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18532. applyFog: boolean;
  18533. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18534. useOctreeForRenderingSelection: boolean;
  18535. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18536. useOctreeForPicking: boolean;
  18537. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18538. useOctreeForCollisions: boolean;
  18539. private _layerMask;
  18540. /**
  18541. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18542. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18543. */
  18544. layerMask: number;
  18545. /**
  18546. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18547. */
  18548. alwaysSelectAsActiveMesh: boolean;
  18549. /**
  18550. * Gets or sets the current action manager
  18551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18552. */
  18553. actionManager: Nullable<ActionManager>;
  18554. /**
  18555. * Gets or sets impostor used for physic simulation
  18556. * @see http://doc.babylonjs.com/features/physics_engine
  18557. */
  18558. physicsImpostor: Nullable<PhysicsImpostor>;
  18559. private _checkCollisions;
  18560. private _collisionMask;
  18561. private _collisionGroup;
  18562. /**
  18563. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18565. */
  18566. ellipsoid: Vector3;
  18567. /**
  18568. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18570. */
  18571. ellipsoidOffset: Vector3;
  18572. private _collider;
  18573. private _oldPositionForCollisions;
  18574. private _diffPositionForCollisions;
  18575. /**
  18576. * Gets or sets a collision mask used to mask collisions (default is -1).
  18577. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18578. */
  18579. collisionMask: number;
  18580. /**
  18581. * Gets or sets the current collision group mask (-1 by default).
  18582. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18583. */
  18584. collisionGroup: number;
  18585. /**
  18586. * Defines edge width used when edgesRenderer is enabled
  18587. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18588. */
  18589. edgesWidth: number;
  18590. /**
  18591. * Defines edge color used when edgesRenderer is enabled
  18592. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18593. */
  18594. edgesColor: Color4;
  18595. /** @hidden */
  18596. _edgesRenderer: Nullable<EdgesRenderer>;
  18597. private _collisionsTransformMatrix;
  18598. private _collisionsScalingMatrix;
  18599. /** @hidden */
  18600. _masterMesh: Nullable<AbstractMesh>;
  18601. /** @hidden */
  18602. _boundingInfo: Nullable<BoundingInfo>;
  18603. /** @hidden */
  18604. _renderId: number;
  18605. /**
  18606. * Gets or sets the list of subMeshes
  18607. * @see http://doc.babylonjs.com/how_to/multi_materials
  18608. */
  18609. subMeshes: SubMesh[];
  18610. /** @hidden */
  18611. _submeshesOctree: Octree<SubMesh>;
  18612. /** @hidden */
  18613. _intersectionsInProgress: AbstractMesh[];
  18614. /** @hidden */
  18615. _unIndexed: boolean;
  18616. /** @hidden */
  18617. _lightSources: Light[];
  18618. /** @hidden */
  18619. readonly _positions: Nullable<Vector3[]>;
  18620. /** @hidden */
  18621. _waitingActions: any;
  18622. /** @hidden */
  18623. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18624. private _skeleton;
  18625. /** @hidden */
  18626. _bonesTransformMatrices: Nullable<Float32Array>;
  18627. /**
  18628. * Gets or sets a skeleton to apply skining transformations
  18629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18630. */
  18631. skeleton: Nullable<Skeleton>;
  18632. /**
  18633. * Creates a new AbstractMesh
  18634. * @param name defines the name of the mesh
  18635. * @param scene defines the hosting scene
  18636. */
  18637. constructor(name: string, scene?: Nullable<Scene>);
  18638. /**
  18639. * Returns the string "AbstractMesh"
  18640. * @returns "AbstractMesh"
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Gets a string representation of the current mesh
  18645. * @param fullDetails defines a boolean indicating if full details must be included
  18646. * @returns a string representation of the current mesh
  18647. */
  18648. toString(fullDetails?: boolean): string;
  18649. /** @hidden */
  18650. _rebuild(): void;
  18651. /** @hidden */
  18652. _resyncLightSources(): void;
  18653. /** @hidden */
  18654. _resyncLighSource(light: Light): void;
  18655. /** @hidden */
  18656. _unBindEffect(): void;
  18657. /** @hidden */
  18658. _removeLightSource(light: Light): void;
  18659. private _markSubMeshesAsDirty(func);
  18660. /** @hidden */
  18661. _markSubMeshesAsLightDirty(): void;
  18662. /** @hidden */
  18663. _markSubMeshesAsAttributesDirty(): void;
  18664. /** @hidden */
  18665. _markSubMeshesAsMiscDirty(): void;
  18666. /**
  18667. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18668. */
  18669. scaling: Vector3;
  18670. /**
  18671. * Disables the mesh edge rendering mode
  18672. * @returns the currentAbstractMesh
  18673. */
  18674. disableEdgesRendering(): AbstractMesh;
  18675. /**
  18676. * Enables the edge rendering mode on the mesh.
  18677. * This mode makes the mesh edges visible
  18678. * @param epsilon defines the maximal distance between two angles to detect a face
  18679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18680. * @returns the currentAbstractMesh
  18681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18682. */
  18683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18684. /**
  18685. * Gets the edgesRenderer associated with the mesh
  18686. */
  18687. readonly edgesRenderer: Nullable<EdgesRenderer>;
  18688. /**
  18689. * Returns true if the mesh is blocked. Implemented by child classes
  18690. */
  18691. readonly isBlocked: boolean;
  18692. /**
  18693. * Returns the mesh itself by default. Implemented by child classes
  18694. * @param camera defines the camera to use to pick the right LOD level
  18695. * @returns the currentAbstractMesh
  18696. */
  18697. getLOD(camera: Camera): AbstractMesh;
  18698. /**
  18699. * Returns 0 by default. Implemented by child classes
  18700. * @returns an integer
  18701. */
  18702. getTotalVertices(): number;
  18703. /**
  18704. * Returns null by default. Implemented by child classes
  18705. * @returns null
  18706. */
  18707. getIndices(): Nullable<IndicesArray>;
  18708. /**
  18709. * Returns the array of the requested vertex data kind. Implemented by child classes
  18710. * @param kind defines the vertex data kind to use
  18711. * @returns null
  18712. */
  18713. getVerticesData(kind: string): Nullable<FloatArray>;
  18714. /**
  18715. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18716. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18717. * Note that a new underlying VertexBuffer object is created each call.
  18718. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18719. * @param kind defines vertex data kind:
  18720. * * BABYLON.VertexBuffer.PositionKind
  18721. * * BABYLON.VertexBuffer.UVKind
  18722. * * BABYLON.VertexBuffer.UV2Kind
  18723. * * BABYLON.VertexBuffer.UV3Kind
  18724. * * BABYLON.VertexBuffer.UV4Kind
  18725. * * BABYLON.VertexBuffer.UV5Kind
  18726. * * BABYLON.VertexBuffer.UV6Kind
  18727. * * BABYLON.VertexBuffer.ColorKind
  18728. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18729. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18730. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18731. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18732. * @param data defines the data source
  18733. * @param updatable defines if the data must be flagged as updatable (or static)
  18734. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  18735. * @returns the current mesh
  18736. */
  18737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18738. /**
  18739. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18740. * If the mesh has no geometry, it is simply returned as it is.
  18741. * @param kind defines vertex data kind:
  18742. * * BABYLON.VertexBuffer.PositionKind
  18743. * * BABYLON.VertexBuffer.UVKind
  18744. * * BABYLON.VertexBuffer.UV2Kind
  18745. * * BABYLON.VertexBuffer.UV3Kind
  18746. * * BABYLON.VertexBuffer.UV4Kind
  18747. * * BABYLON.VertexBuffer.UV5Kind
  18748. * * BABYLON.VertexBuffer.UV6Kind
  18749. * * BABYLON.VertexBuffer.ColorKind
  18750. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18751. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18752. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18753. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18754. * @param data defines the data source
  18755. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  18756. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  18757. * @returns the current mesh
  18758. */
  18759. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  18760. /**
  18761. * Sets the mesh indices,
  18762. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18763. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18764. * @param totalVertices Defines the total number of vertices
  18765. * @returns the current mesh
  18766. */
  18767. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  18768. /**
  18769. * Gets a boolean indicating if specific vertex data is present
  18770. * @param kind defines the vertex data kind to use
  18771. * @returns true is data kind is present
  18772. */
  18773. isVerticesDataPresent(kind: string): boolean;
  18774. /**
  18775. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  18776. * @returns a BoundingInfo
  18777. */
  18778. getBoundingInfo(): BoundingInfo;
  18779. /**
  18780. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  18781. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  18782. * @returns the current mesh
  18783. */
  18784. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  18785. /**
  18786. * Overwrite the current bounding info
  18787. * @param boundingInfo defines the new bounding info
  18788. * @returns the current mesh
  18789. */
  18790. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  18791. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  18792. readonly useBones: boolean;
  18793. /** @hidden */
  18794. _preActivate(): void;
  18795. /** @hidden */
  18796. _preActivateForIntermediateRendering(renderId: number): void;
  18797. /** @hidden */
  18798. _activate(renderId: number): void;
  18799. /**
  18800. * Gets the current world matrix
  18801. * @returns a Matrix
  18802. */
  18803. getWorldMatrix(): Matrix;
  18804. /** @hidden */
  18805. _getWorldMatrixDeterminant(): number;
  18806. /**
  18807. * Perform relative position change from the point of view of behind the front of the mesh.
  18808. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18809. * Supports definition of mesh facing forward or backward
  18810. * @param amountRight defines the distance on the right axis
  18811. * @param amountUp defines the distance on the up axis
  18812. * @param amountForward defines the distance on the forward axis
  18813. * @returns the current mesh
  18814. */
  18815. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  18816. /**
  18817. * Calculate relative position change from the point of view of behind the front of the mesh.
  18818. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18819. * Supports definition of mesh facing forward or backward
  18820. * @param amountRight defines the distance on the right axis
  18821. * @param amountUp defines the distance on the up axis
  18822. * @param amountForward defines the distance on the forward axis
  18823. * @returns the new displacement vector
  18824. */
  18825. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  18826. /**
  18827. * Perform relative rotation change from the point of view of behind the front of the mesh.
  18828. * Supports definition of mesh facing forward or backward
  18829. * @param flipBack defines the flip
  18830. * @param twirlClockwise defines the twirl
  18831. * @param tiltRight defines the tilt
  18832. * @returns the current mesh
  18833. */
  18834. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  18835. /**
  18836. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  18837. * Supports definition of mesh facing forward or backward.
  18838. * @param flipBack defines the flip
  18839. * @param twirlClockwise defines the twirl
  18840. * @param tiltRight defines the tilt
  18841. * @returns the new rotation vector
  18842. */
  18843. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  18844. /**
  18845. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  18846. * @param includeDescendants Include bounding info from descendants as well (true by default)
  18847. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  18848. * @returns the new bounding vectors
  18849. */
  18850. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  18851. min: Vector3;
  18852. max: Vector3;
  18853. };
  18854. /** @hidden */
  18855. _updateBoundingInfo(): AbstractMesh;
  18856. /** @hidden */
  18857. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  18858. /** @hidden */
  18859. protected _afterComputeWorldMatrix(): void;
  18860. /**
  18861. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18862. * A mesh is in the frustum if its bounding box intersects the frustum
  18863. * @param frustumPlanes defines the frustum to test
  18864. * @returns true if the mesh is in the frustum planes
  18865. */
  18866. isInFrustum(frustumPlanes: Plane[]): boolean;
  18867. /**
  18868. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  18869. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  18870. * @param frustumPlanes defines the frustum to test
  18871. * @returns true if the mesh is completely in the frustum planes
  18872. */
  18873. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18874. /**
  18875. * True if the mesh intersects another mesh or a SolidParticle object
  18876. * @param mesh defines a target mesh or SolidParticle to test
  18877. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  18878. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  18879. * @returns true if there is an intersection
  18880. */
  18881. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  18882. /**
  18883. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  18884. * @param point defines the point to test
  18885. * @returns true if there is an intersection
  18886. */
  18887. intersectsPoint(point: Vector3): boolean;
  18888. /**
  18889. * Gets the current physics impostor
  18890. * @see http://doc.babylonjs.com/features/physics_engine
  18891. * @returns a physics impostor or null
  18892. */
  18893. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  18894. /**
  18895. * Gets the position of the current mesh in camera space
  18896. * @param camera defines the camera to use
  18897. * @returns a position
  18898. */
  18899. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  18900. /**
  18901. * Returns the distance from the mesh to the active camera
  18902. * @param camera defines the camera to use
  18903. * @returns the distance
  18904. */
  18905. getDistanceToCamera(camera?: Nullable<Camera>): number;
  18906. /**
  18907. * Apply a physic impulse to the mesh
  18908. * @param force defines the force to apply
  18909. * @param contactPoint defines where to apply the force
  18910. * @returns the current mesh
  18911. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18912. */
  18913. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  18914. /**
  18915. * Creates a physic joint between two meshes
  18916. * @param otherMesh defines the other mesh to use
  18917. * @param pivot1 defines the pivot to use on this mesh
  18918. * @param pivot2 defines the pivot to use on the other mesh
  18919. * @param options defines additional options (can be plugin dependent)
  18920. * @returns the current mesh
  18921. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  18922. */
  18923. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  18924. /**
  18925. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  18926. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18927. */
  18928. checkCollisions: boolean;
  18929. /**
  18930. * Gets Collider object used to compute collisions (not physics)
  18931. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18932. */
  18933. readonly collider: Collider;
  18934. /**
  18935. * Move the mesh using collision engine
  18936. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18937. * @param displacement defines the requested displacement vector
  18938. * @returns the current mesh
  18939. */
  18940. moveWithCollisions(displacement: Vector3): AbstractMesh;
  18941. private _onCollisionPositionChange;
  18942. /**
  18943. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  18944. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18945. * @param maxCapacity defines the maximum size of each block (64 by default)
  18946. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  18947. * @returns the new octree
  18948. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  18949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  18950. */
  18951. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  18952. /** @hidden */
  18953. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  18954. /** @hidden */
  18955. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  18956. /** @hidden */
  18957. _checkCollision(collider: Collider): AbstractMesh;
  18958. /** @hidden */
  18959. _generatePointsArray(): boolean;
  18960. /**
  18961. * Checks if the passed Ray intersects with the mesh
  18962. * @param ray defines the ray to use
  18963. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  18964. * @returns the picking info
  18965. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  18966. */
  18967. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  18968. /**
  18969. * Clones the current mesh
  18970. * @param name defines the mesh name
  18971. * @param newParent defines the new mesh parent
  18972. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  18973. * @returns the new mesh
  18974. */
  18975. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18976. /**
  18977. * Disposes all the submeshes of the current meshnp
  18978. * @returns the current mesh
  18979. */
  18980. releaseSubMeshes(): AbstractMesh;
  18981. /**
  18982. * Releases resources associated with this abstract mesh.
  18983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18985. */
  18986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18987. /**
  18988. * Adds the passed mesh as a child to the current mesh
  18989. * @param mesh defines the child mesh
  18990. * @returns the current mesh
  18991. */
  18992. addChild(mesh: AbstractMesh): AbstractMesh;
  18993. /**
  18994. * Removes the passed mesh from the current mesh children list
  18995. * @param mesh defines the child mesh
  18996. * @returns the current mesh
  18997. */
  18998. removeChild(mesh: AbstractMesh): AbstractMesh;
  18999. /** @hidden */
  19000. private _initFacetData();
  19001. /**
  19002. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19003. * This method can be called within the render loop.
  19004. * 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
  19005. * @returns the current mesh
  19006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19007. */
  19008. updateFacetData(): AbstractMesh;
  19009. /**
  19010. * Returns the facetLocalNormals array.
  19011. * The normals are expressed in the mesh local spac
  19012. * @returns an array of Vector3
  19013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19014. */
  19015. getFacetLocalNormals(): Vector3[];
  19016. /**
  19017. * Returns the facetLocalPositions array.
  19018. * The facet positions are expressed in the mesh local space
  19019. * @returns an array of Vector3
  19020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19021. */
  19022. getFacetLocalPositions(): Vector3[];
  19023. /**
  19024. * Returns the facetLocalPartioning array
  19025. * @returns an array of array of numbers
  19026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19027. */
  19028. getFacetLocalPartitioning(): number[][];
  19029. /**
  19030. * Returns the i-th facet position in the world system.
  19031. * This method allocates a new Vector3 per call
  19032. * @param i defines the facet index
  19033. * @returns a new Vector3
  19034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19035. */
  19036. getFacetPosition(i: number): Vector3;
  19037. /**
  19038. * Sets the reference Vector3 with the i-th facet position in the world system
  19039. * @param i defines the facet index
  19040. * @param ref defines the target vector
  19041. * @returns the current mesh
  19042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19043. */
  19044. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19045. /**
  19046. * Returns the i-th facet normal in the world system.
  19047. * This method allocates a new Vector3 per call
  19048. * @param i defines the facet index
  19049. * @returns a new Vector3
  19050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19051. */
  19052. getFacetNormal(i: number): Vector3;
  19053. /**
  19054. * Sets the reference Vector3 with the i-th facet normal in the world system
  19055. * @param i defines the facet index
  19056. * @param ref defines the target vector
  19057. * @returns the current mesh
  19058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19059. */
  19060. getFacetNormalToRef(i: number, ref: Vector3): this;
  19061. /**
  19062. * 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)
  19063. * @param x defines x coordinate
  19064. * @param y defines y coordinate
  19065. * @param z defines z coordinate
  19066. * @returns the array of facet indexes
  19067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19068. */
  19069. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19070. /**
  19071. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19072. * @param projected sets as the (x,y,z) world projection on the facet
  19073. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  19074. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  19075. * @param x defines x coordinate
  19076. * @param y defines y coordinate
  19077. * @param z defines z coordinate
  19078. * @returns the face index if found (or null instead)
  19079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19080. */
  19081. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19082. /**
  19083. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19084. * @param projected sets as the (x,y,z) local projection on the facet
  19085. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  19086. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  19087. * @param x defines x coordinate
  19088. * @param y defines y coordinate
  19089. * @param z defines z coordinate
  19090. * @returns the face index if found (or null instead)
  19091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19092. */
  19093. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19094. /**
  19095. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19096. * @returns the parameters
  19097. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19098. */
  19099. getFacetDataParameters(): any;
  19100. /**
  19101. * Disables the feature FacetData and frees the related memory
  19102. * @returns the current mesh
  19103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19104. */
  19105. disableFacetData(): AbstractMesh;
  19106. /**
  19107. * Updates the AbstractMesh indices array
  19108. * @param indices defines the data source
  19109. * @returns the current mesh
  19110. */
  19111. updateIndices(indices: IndicesArray): AbstractMesh;
  19112. /**
  19113. * Creates new normals data for the mesh
  19114. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19115. * @returns the current mesh
  19116. */
  19117. createNormals(updatable: boolean): AbstractMesh;
  19118. /**
  19119. * Align the mesh with a normal
  19120. * @param normal defines the normal to use
  19121. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19122. * @returns the current mesh
  19123. */
  19124. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19125. /** @hidden */
  19126. protected _checkOcclusionQuery(): void;
  19127. }
  19128. }
  19129. declare module BABYLON {
  19130. class Buffer {
  19131. private _engine;
  19132. private _buffer;
  19133. /** @hidden */
  19134. _data: Nullable<DataArray>;
  19135. private _updatable;
  19136. private _instanced;
  19137. /**
  19138. * Gets the byte stride.
  19139. */
  19140. readonly byteStride: number;
  19141. /**
  19142. * Constructor
  19143. * @param engine the engine
  19144. * @param data the data to use for this buffer
  19145. * @param updatable whether the data is updatable
  19146. * @param stride the stride (optional)
  19147. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19148. * @param instanced whether the buffer is instanced (optional)
  19149. * @param useBytes set to true if the stride in in bytes (optional)
  19150. */
  19151. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19152. /**
  19153. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19154. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19155. * @param offset defines offset in the buffer (0 by default)
  19156. * @param size defines the size in floats of attributes (position is 3 for instance)
  19157. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19158. * @param instanced defines if the vertex buffer contains indexed data
  19159. * @param useBytes defines if the offset and stride are in bytes
  19160. * @returns the new vertex buffer
  19161. */
  19162. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19163. isUpdatable(): boolean;
  19164. getData(): Nullable<DataArray>;
  19165. getBuffer(): Nullable<WebGLBuffer>;
  19166. /**
  19167. * Gets the stride in float32 units (i.e. byte stride / 4).
  19168. * May not be an integer if the byte stride is not divisible by 4.
  19169. * DEPRECATED. Use byteStride instead.
  19170. * @returns the stride in float32 units
  19171. */
  19172. getStrideSize(): number;
  19173. create(data?: Nullable<DataArray>): void;
  19174. _rebuild(): void;
  19175. update(data: DataArray): void;
  19176. /**
  19177. * Updates the data directly.
  19178. * @param data the new data
  19179. * @param offset the new offset
  19180. * @param vertexCount the vertex count (optional)
  19181. * @param useBytes set to true if the offset is in bytes
  19182. */
  19183. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19184. dispose(): void;
  19185. }
  19186. }
  19187. declare module BABYLON {
  19188. class CSG {
  19189. private polygons;
  19190. matrix: Matrix;
  19191. position: Vector3;
  19192. rotation: Vector3;
  19193. rotationQuaternion: Nullable<Quaternion>;
  19194. scaling: Vector3;
  19195. static FromMesh(mesh: Mesh): CSG;
  19196. private static FromPolygons(polygons);
  19197. clone(): CSG;
  19198. union(csg: CSG): CSG;
  19199. unionInPlace(csg: CSG): void;
  19200. subtract(csg: CSG): CSG;
  19201. subtractInPlace(csg: CSG): void;
  19202. intersect(csg: CSG): CSG;
  19203. intersectInPlace(csg: CSG): void;
  19204. inverse(): CSG;
  19205. inverseInPlace(): void;
  19206. copyTransformAttributes(csg: CSG): CSG;
  19207. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19208. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19209. }
  19210. }
  19211. declare module BABYLON {
  19212. /**
  19213. * Class used to store geometry data (vertex buffers + index buffer)
  19214. */
  19215. class Geometry implements IGetSetVerticesData {
  19216. /**
  19217. * Gets or sets the unique ID of the geometry
  19218. */
  19219. id: string;
  19220. /**
  19221. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19222. */
  19223. delayLoadState: number;
  19224. /**
  19225. * Gets the file containing the data to load when running in delay load state
  19226. */
  19227. delayLoadingFile: Nullable<string>;
  19228. /**
  19229. * Callback called when the geometry is updated
  19230. */
  19231. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19232. private _scene;
  19233. private _engine;
  19234. private _meshes;
  19235. private _totalVertices;
  19236. /** @hidden */
  19237. _indices: IndicesArray;
  19238. /** @hidden */
  19239. _vertexBuffers: {
  19240. [key: string]: VertexBuffer;
  19241. };
  19242. private _isDisposed;
  19243. private _extend;
  19244. private _boundingBias;
  19245. /** @hidden */
  19246. _delayInfo: Array<string>;
  19247. private _indexBuffer;
  19248. private _indexBufferIsUpdatable;
  19249. /** @hidden */
  19250. _boundingInfo: Nullable<BoundingInfo>;
  19251. /** @hidden */
  19252. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19253. /** @hidden */
  19254. _softwareSkinningRenderId: number;
  19255. private _vertexArrayObjects;
  19256. private _updatable;
  19257. /** @hidden */
  19258. _positions: Nullable<Vector3[]>;
  19259. /**
  19260. * 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
  19261. */
  19262. /**
  19263. * 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
  19264. */
  19265. boundingBias: Vector2;
  19266. /**
  19267. * Static function used to attach a new empty geometry to a mesh
  19268. * @param mesh defines the mesh to attach the geometry to
  19269. * @returns the new {BABYLON.Geometry}
  19270. */
  19271. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19272. /**
  19273. * Creates a new geometry
  19274. * @param id defines the unique ID
  19275. * @param scene defines the hosting scene
  19276. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19277. * @param updatable defines if geometry must be updatable (false by default)
  19278. * @param mesh defines the mesh that will be associated with the geometry
  19279. */
  19280. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19281. /**
  19282. * Gets the current extend of the geometry
  19283. */
  19284. readonly extend: {
  19285. minimum: Vector3;
  19286. maximum: Vector3;
  19287. };
  19288. /**
  19289. * Gets the hosting scene
  19290. * @returns the hosting {BABYLON.Scene}
  19291. */
  19292. getScene(): Scene;
  19293. /**
  19294. * Gets the hosting engine
  19295. * @returns the hosting {BABYLON.Engine}
  19296. */
  19297. getEngine(): Engine;
  19298. /**
  19299. * Defines if the geometry is ready to use
  19300. * @returns true if the geometry is ready to be used
  19301. */
  19302. isReady(): boolean;
  19303. /**
  19304. * Gets a value indicating that the geometry should not be serialized
  19305. */
  19306. readonly doNotSerialize: boolean;
  19307. /** @hidden */
  19308. _rebuild(): void;
  19309. /**
  19310. * Affects all gemetry data in one call
  19311. * @param vertexData defines the geometry data
  19312. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19313. */
  19314. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19315. /**
  19316. * Set specific vertex data
  19317. * @param kind defines the data kind (Position, normal, etc...)
  19318. * @param data defines the vertex data to use
  19319. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19320. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19321. */
  19322. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19323. /**
  19324. * Removes a specific vertex data
  19325. * @param kind defines the data kind (Position, normal, etc...)
  19326. */
  19327. removeVerticesData(kind: string): void;
  19328. /**
  19329. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19330. * @param buffer defines the vertex buffer to use
  19331. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19332. */
  19333. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19334. /**
  19335. * Update a specific vertex buffer
  19336. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19337. * It will do nothing if the buffer is not updatable
  19338. * @param kind defines the data kind (Position, normal, etc...)
  19339. * @param data defines the data to use
  19340. * @param offset defines the offset in the target buffer where to store the data
  19341. * @param useBytes set to true if the offset is in bytes
  19342. */
  19343. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19344. /**
  19345. * Update a specific vertex buffer
  19346. * This function will create a new buffer if the current one is not updatable
  19347. * @param kind defines the data kind (Position, normal, etc...)
  19348. * @param data defines the data to use
  19349. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19350. */
  19351. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19352. private _updateBoundingInfo(updateExtends, data);
  19353. /** @hidden */
  19354. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19355. /**
  19356. * Gets total number of vertices
  19357. * @returns the total number of vertices
  19358. */
  19359. getTotalVertices(): number;
  19360. /**
  19361. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19362. * @param kind defines the data kind (Position, normal, etc...)
  19363. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19364. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19365. * @returns a float array containing vertex data
  19366. */
  19367. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19368. /**
  19369. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19370. * @param kind defines the data kind (Position, normal, etc...)
  19371. * @returns true if the vertex buffer with the specified kind is updatable
  19372. */
  19373. isVertexBufferUpdatable(kind: string): boolean;
  19374. /**
  19375. * Gets a specific vertex buffer
  19376. * @param kind defines the data kind (Position, normal, etc...)
  19377. * @returns a {BABYLON.VertexBuffer}
  19378. */
  19379. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19380. /**
  19381. * Returns all vertex buffers
  19382. * @return an object holding all vertex buffers indexed by kind
  19383. */
  19384. getVertexBuffers(): Nullable<{
  19385. [key: string]: VertexBuffer;
  19386. }>;
  19387. /**
  19388. * Gets a boolean indicating if specific vertex buffer is present
  19389. * @param kind defines the data kind (Position, normal, etc...)
  19390. * @returns true if data is present
  19391. */
  19392. isVerticesDataPresent(kind: string): boolean;
  19393. /**
  19394. * Gets a list of all attached data kinds (Position, normal, etc...)
  19395. * @returns a list of string containing all kinds
  19396. */
  19397. getVerticesDataKinds(): string[];
  19398. /**
  19399. * Update index buffer
  19400. * @param indices defines the indices to store in the index buffer
  19401. * @param offset defines the offset in the target buffer where to store the data
  19402. */
  19403. updateIndices(indices: IndicesArray, offset?: number): void;
  19404. /**
  19405. * Creates a new index buffer
  19406. * @param indices defines the indices to store in the index buffer
  19407. * @param totalVertices defines the total number of vertices (could be null)
  19408. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19409. */
  19410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19411. /**
  19412. * Return the total number of indices
  19413. * @returns the total number of indices
  19414. */
  19415. getTotalIndices(): number;
  19416. /**
  19417. * Gets the index buffer array
  19418. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19419. * @returns the index buffer array
  19420. */
  19421. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19422. /**
  19423. * Gets the index buffer
  19424. * @return the index buffer
  19425. */
  19426. getIndexBuffer(): Nullable<WebGLBuffer>;
  19427. /** @hidden */
  19428. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19429. /**
  19430. * Release the associated resources for a specific mesh
  19431. * @param mesh defines the source mesh
  19432. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19433. */
  19434. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19435. /**
  19436. * Apply current geometry to a given mesh
  19437. * @param mesh defines the mesh to apply geometry to
  19438. */
  19439. applyToMesh(mesh: Mesh): void;
  19440. private _updateExtend(data?);
  19441. private _applyToMesh(mesh);
  19442. private notifyUpdate(kind?);
  19443. /**
  19444. * Load the geometry if it was flagged as delay loaded
  19445. * @param scene defines the hosting scene
  19446. * @param onLoaded defines a callback called when the geometry is loaded
  19447. */
  19448. load(scene: Scene, onLoaded?: () => void): void;
  19449. private _queueLoad(scene, onLoaded?);
  19450. /**
  19451. * Invert the geometry to move from a right handed system to a left handed one.
  19452. */
  19453. toLeftHanded(): void;
  19454. /** @hidden */
  19455. _resetPointsArrayCache(): void;
  19456. /** @hidden */
  19457. _generatePointsArray(): boolean;
  19458. /**
  19459. * Gets a value indicating if the geometry is disposed
  19460. * @returns true if the geometry was disposed
  19461. */
  19462. isDisposed(): boolean;
  19463. private _disposeVertexArrayObjects();
  19464. /**
  19465. * Free all associated resources
  19466. */
  19467. dispose(): void;
  19468. /**
  19469. * Clone the current geometry into a new geometry
  19470. * @param id defines the unique ID of the new geometry
  19471. * @returns a new geometry object
  19472. */
  19473. copy(id: string): Geometry;
  19474. /**
  19475. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19476. * @return a JSON representation of the current geometry data (without the vertices data)
  19477. */
  19478. serialize(): any;
  19479. private toNumberArray(origin);
  19480. /**
  19481. * Serialize all vertices data into a JSON oject
  19482. * @returns a JSON representation of the current geometry data
  19483. */
  19484. serializeVerticeData(): any;
  19485. /**
  19486. * Extracts a clone of a mesh geometry
  19487. * @param mesh defines the source mesh
  19488. * @param id defines the unique ID of the new geometry object
  19489. * @returns the new geometry object
  19490. */
  19491. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19492. /**
  19493. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19494. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19495. * Be aware Math.random() could cause collisions, but:
  19496. * "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"
  19497. * @returns a string containing a new GUID
  19498. */
  19499. static RandomId(): string;
  19500. /** @hidden */
  19501. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19502. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19503. /**
  19504. * Create a new geometry from persisted data (Using .babylon file format)
  19505. * @param parsedVertexData defines the persisted data
  19506. * @param scene defines the hosting scene
  19507. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19508. * @returns the new geometry object
  19509. */
  19510. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19511. }
  19512. /**
  19513. * Abstract class used to provide common services for all typed geometries
  19514. * @hidden
  19515. */
  19516. class _PrimitiveGeometry extends Geometry {
  19517. private _canBeRegenerated;
  19518. private _beingRegenerated;
  19519. /**
  19520. * Creates a new typed geometry
  19521. * @param id defines the unique ID of the geometry
  19522. * @param scene defines the hosting scene
  19523. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19524. * @param mesh defines the hosting mesh (can be null)
  19525. */
  19526. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19527. /**
  19528. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19529. * @returns true if the geometry can be regenerated
  19530. */
  19531. canBeRegenerated(): boolean;
  19532. /**
  19533. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19534. */
  19535. regenerate(): void;
  19536. /**
  19537. * Clone the geometry
  19538. * @param id defines the unique ID of the new geometry
  19539. * @returns the new geometry
  19540. */
  19541. asNewGeometry(id: string): Geometry;
  19542. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19544. /** @hidden */
  19545. _regenerateVertexData(): VertexData;
  19546. copy(id: string): Geometry;
  19547. serialize(): any;
  19548. }
  19549. /**
  19550. * Creates a ribbon geometry
  19551. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19552. */
  19553. class RibbonGeometry extends _PrimitiveGeometry {
  19554. /**
  19555. * Defines the array of paths to use
  19556. */
  19557. pathArray: Vector3[][];
  19558. /**
  19559. * Defines if the last and first points of each path in your pathArray must be joined
  19560. */
  19561. closeArray: boolean;
  19562. /**
  19563. * Defines if the last and first points of each path in your pathArray must be joined
  19564. */
  19565. closePath: boolean;
  19566. /**
  19567. * Defines the offset between points
  19568. */
  19569. offset: number;
  19570. /**
  19571. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19572. */
  19573. side: number;
  19574. /**
  19575. * Creates a ribbon geometry
  19576. * @param id defines the unique ID of the geometry
  19577. * @param scene defines the hosting scene
  19578. * @param pathArray defines the array of paths to use
  19579. * @param closeArray defines if the last path and the first path must be joined
  19580. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19581. * @param offset defines the offset between points
  19582. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19583. * @param mesh defines the hosting mesh (can be null)
  19584. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19585. */
  19586. constructor(id: string, scene: Scene,
  19587. /**
  19588. * Defines the array of paths to use
  19589. */
  19590. pathArray: Vector3[][],
  19591. /**
  19592. * Defines if the last and first points of each path in your pathArray must be joined
  19593. */
  19594. closeArray: boolean,
  19595. /**
  19596. * Defines if the last and first points of each path in your pathArray must be joined
  19597. */
  19598. closePath: boolean,
  19599. /**
  19600. * Defines the offset between points
  19601. */
  19602. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19603. /**
  19604. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19605. */
  19606. side?: number);
  19607. /** @hidden */
  19608. _regenerateVertexData(): VertexData;
  19609. copy(id: string): Geometry;
  19610. }
  19611. /**
  19612. * Creates a box geometry
  19613. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19614. */
  19615. class BoxGeometry extends _PrimitiveGeometry {
  19616. /**
  19617. * Defines the zise of the box (width, height and depth are the same)
  19618. */
  19619. size: number;
  19620. /**
  19621. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19622. */
  19623. side: number;
  19624. /**
  19625. * Creates a box geometry
  19626. * @param id defines the unique ID of the geometry
  19627. * @param scene defines the hosting scene
  19628. * @param size defines the zise of the box (width, height and depth are the same)
  19629. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19630. * @param mesh defines the hosting mesh (can be null)
  19631. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19632. */
  19633. constructor(id: string, scene: Scene,
  19634. /**
  19635. * Defines the zise of the box (width, height and depth are the same)
  19636. */
  19637. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19638. /**
  19639. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19640. */
  19641. side?: number);
  19642. _regenerateVertexData(): VertexData;
  19643. copy(id: string): Geometry;
  19644. serialize(): any;
  19645. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19646. }
  19647. /**
  19648. * Creates a sphere geometry
  19649. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19650. */
  19651. class SphereGeometry extends _PrimitiveGeometry {
  19652. /**
  19653. * Defines the number of segments to use to create the sphere
  19654. */
  19655. segments: number;
  19656. /**
  19657. * Defines the diameter of the sphere
  19658. */
  19659. diameter: number;
  19660. /**
  19661. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19662. */
  19663. side: number;
  19664. /**
  19665. * Create a new sphere geometry
  19666. * @param id defines the unique ID of the geometry
  19667. * @param scene defines the hosting scene
  19668. * @param segments defines the number of segments to use to create the sphere
  19669. * @param diameter defines the diameter of the sphere
  19670. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19671. * @param mesh defines the hosting mesh (can be null)
  19672. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19673. */
  19674. constructor(id: string, scene: Scene,
  19675. /**
  19676. * Defines the number of segments to use to create the sphere
  19677. */
  19678. segments: number,
  19679. /**
  19680. * Defines the diameter of the sphere
  19681. */
  19682. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19683. /**
  19684. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19685. */
  19686. side?: number);
  19687. _regenerateVertexData(): VertexData;
  19688. copy(id: string): Geometry;
  19689. serialize(): any;
  19690. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19691. }
  19692. /**
  19693. * Creates a disc geometry
  19694. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19695. */
  19696. class DiscGeometry extends _PrimitiveGeometry {
  19697. /**
  19698. * Defines the radius of the disc
  19699. */
  19700. radius: number;
  19701. /**
  19702. * Defines the tesselation factor to apply to the disc
  19703. */
  19704. tessellation: number;
  19705. /**
  19706. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19707. */
  19708. side: number;
  19709. /**
  19710. * Creates a new disc geometry
  19711. * @param id defines the unique ID of the geometry
  19712. * @param scene defines the hosting scene
  19713. * @param radius defines the radius of the disc
  19714. * @param tessellation defines the tesselation factor to apply to the disc
  19715. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19716. * @param mesh defines the hosting mesh (can be null)
  19717. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19718. */
  19719. constructor(id: string, scene: Scene,
  19720. /**
  19721. * Defines the radius of the disc
  19722. */
  19723. radius: number,
  19724. /**
  19725. * Defines the tesselation factor to apply to the disc
  19726. */
  19727. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19728. /**
  19729. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19730. */
  19731. side?: number);
  19732. _regenerateVertexData(): VertexData;
  19733. copy(id: string): Geometry;
  19734. }
  19735. /**
  19736. * Creates a new cylinder geometry
  19737. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  19738. */
  19739. class CylinderGeometry extends _PrimitiveGeometry {
  19740. /**
  19741. * Defines the height of the cylinder
  19742. */
  19743. height: number;
  19744. /**
  19745. * Defines the diameter of the cylinder's top cap
  19746. */
  19747. diameterTop: number;
  19748. /**
  19749. * Defines the diameter of the cylinder's bottom cap
  19750. */
  19751. diameterBottom: number;
  19752. /**
  19753. * Defines the tessellation factor to apply to the cylinder
  19754. */
  19755. tessellation: number;
  19756. /**
  19757. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19758. */
  19759. subdivisions: number;
  19760. /**
  19761. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19762. */
  19763. side: number;
  19764. /**
  19765. * Creates a new cylinder geometry
  19766. * @param id defines the unique ID of the geometry
  19767. * @param scene defines the hosting scene
  19768. * @param height defines the height of the cylinder
  19769. * @param diameterTop defines the diameter of the cylinder's top cap
  19770. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  19771. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  19772. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  19773. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19774. * @param mesh defines the hosting mesh (can be null)
  19775. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19776. */
  19777. constructor(id: string, scene: Scene,
  19778. /**
  19779. * Defines the height of the cylinder
  19780. */
  19781. height: number,
  19782. /**
  19783. * Defines the diameter of the cylinder's top cap
  19784. */
  19785. diameterTop: number,
  19786. /**
  19787. * Defines the diameter of the cylinder's bottom cap
  19788. */
  19789. diameterBottom: number,
  19790. /**
  19791. * Defines the tessellation factor to apply to the cylinder
  19792. */
  19793. tessellation: number,
  19794. /**
  19795. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19796. */
  19797. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19798. /**
  19799. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19800. */
  19801. side?: number);
  19802. _regenerateVertexData(): VertexData;
  19803. copy(id: string): Geometry;
  19804. serialize(): any;
  19805. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  19806. }
  19807. /**
  19808. * Creates a new torus geometry
  19809. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  19810. */
  19811. class TorusGeometry extends _PrimitiveGeometry {
  19812. /**
  19813. * Defines the diameter of the torus
  19814. */
  19815. diameter: number;
  19816. /**
  19817. * Defines the thickness of the torus (ie. internal diameter)
  19818. */
  19819. thickness: number;
  19820. /**
  19821. * Defines the tesselation factor to apply to the torus
  19822. */
  19823. tessellation: number;
  19824. /**
  19825. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19826. */
  19827. side: number;
  19828. /**
  19829. * Creates a new torus geometry
  19830. * @param id defines the unique ID of the geometry
  19831. * @param scene defines the hosting scene
  19832. * @param diameter defines the diameter of the torus
  19833. * @param thickness defines the thickness of the torus (ie. internal diameter)
  19834. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  19835. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19836. * @param mesh defines the hosting mesh (can be null)
  19837. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19838. */
  19839. constructor(id: string, scene: Scene,
  19840. /**
  19841. * Defines the diameter of the torus
  19842. */
  19843. diameter: number,
  19844. /**
  19845. * Defines the thickness of the torus (ie. internal diameter)
  19846. */
  19847. thickness: number,
  19848. /**
  19849. * Defines the tesselation factor to apply to the torus
  19850. */
  19851. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19852. /**
  19853. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19854. */
  19855. side?: number);
  19856. _regenerateVertexData(): VertexData;
  19857. copy(id: string): Geometry;
  19858. serialize(): any;
  19859. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  19860. }
  19861. /**
  19862. * Creates a new ground geometry
  19863. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  19864. */
  19865. class GroundGeometry extends _PrimitiveGeometry {
  19866. /**
  19867. * Defines the width of the ground
  19868. */
  19869. width: number;
  19870. /**
  19871. * Defines the height of the ground
  19872. */
  19873. height: number;
  19874. /**
  19875. * Defines the subdivisions to apply to the ground
  19876. */
  19877. subdivisions: number;
  19878. /**
  19879. * Creates a new ground geometry
  19880. * @param id defines the unique ID of the geometry
  19881. * @param scene defines the hosting scene
  19882. * @param width defines the width of the ground
  19883. * @param height defines the height of the ground
  19884. * @param subdivisions defines the subdivisions to apply to the ground
  19885. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19886. * @param mesh defines the hosting mesh (can be null)
  19887. */
  19888. constructor(id: string, scene: Scene,
  19889. /**
  19890. * Defines the width of the ground
  19891. */
  19892. width: number,
  19893. /**
  19894. * Defines the height of the ground
  19895. */
  19896. height: number,
  19897. /**
  19898. * Defines the subdivisions to apply to the ground
  19899. */
  19900. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19901. _regenerateVertexData(): VertexData;
  19902. copy(id: string): Geometry;
  19903. serialize(): any;
  19904. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  19905. }
  19906. /**
  19907. * Creates a tiled ground geometry
  19908. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  19909. */
  19910. class TiledGroundGeometry extends _PrimitiveGeometry {
  19911. /**
  19912. * Defines the minimum value on X axis
  19913. */
  19914. xmin: number;
  19915. /**
  19916. * Defines the minimum value on Z axis
  19917. */
  19918. zmin: number;
  19919. /**
  19920. * Defines the maximum value on X axis
  19921. */
  19922. xmax: number;
  19923. /**
  19924. * Defines the maximum value on Z axis
  19925. */
  19926. zmax: number;
  19927. /**
  19928. * Defines the subdivisions to apply to the ground
  19929. */
  19930. subdivisions: {
  19931. w: number;
  19932. h: number;
  19933. };
  19934. /**
  19935. * Defines the precision to use when computing the tiles
  19936. */
  19937. precision: {
  19938. w: number;
  19939. h: number;
  19940. };
  19941. /**
  19942. * Creates a tiled ground geometry
  19943. * @param id defines the unique ID of the geometry
  19944. * @param scene defines the hosting scene
  19945. * @param xmin defines the minimum value on X axis
  19946. * @param zmin defines the minimum value on Z axis
  19947. * @param xmax defines the maximum value on X axis
  19948. * @param zmax defines the maximum value on Z axis
  19949. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  19950. * @param precision defines the precision to use when computing the tiles
  19951. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19952. * @param mesh defines the hosting mesh (can be null)
  19953. */
  19954. constructor(id: string, scene: Scene,
  19955. /**
  19956. * Defines the minimum value on X axis
  19957. */
  19958. xmin: number,
  19959. /**
  19960. * Defines the minimum value on Z axis
  19961. */
  19962. zmin: number,
  19963. /**
  19964. * Defines the maximum value on X axis
  19965. */
  19966. xmax: number,
  19967. /**
  19968. * Defines the maximum value on Z axis
  19969. */
  19970. zmax: number,
  19971. /**
  19972. * Defines the subdivisions to apply to the ground
  19973. */
  19974. subdivisions: {
  19975. w: number;
  19976. h: number;
  19977. },
  19978. /**
  19979. * Defines the precision to use when computing the tiles
  19980. */
  19981. precision: {
  19982. w: number;
  19983. h: number;
  19984. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19985. _regenerateVertexData(): VertexData;
  19986. copy(id: string): Geometry;
  19987. }
  19988. /**
  19989. * Creates a plane geometry
  19990. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  19991. */
  19992. class PlaneGeometry extends _PrimitiveGeometry {
  19993. /**
  19994. * Defines the size of the plane (width === height)
  19995. */
  19996. size: number;
  19997. /**
  19998. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19999. */
  20000. side: number;
  20001. /**
  20002. * Creates a plane geometry
  20003. * @param id defines the unique ID of the geometry
  20004. * @param scene defines the hosting scene
  20005. * @param size defines the size of the plane (width === height)
  20006. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20007. * @param mesh defines the hosting mesh (can be null)
  20008. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20009. */
  20010. constructor(id: string, scene: Scene,
  20011. /**
  20012. * Defines the size of the plane (width === height)
  20013. */
  20014. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20015. /**
  20016. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20017. */
  20018. side?: number);
  20019. _regenerateVertexData(): VertexData;
  20020. copy(id: string): Geometry;
  20021. serialize(): any;
  20022. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20023. }
  20024. /**
  20025. * Creates a torus knot geometry
  20026. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20027. */
  20028. class TorusKnotGeometry extends _PrimitiveGeometry {
  20029. /**
  20030. * Defines the radius of the torus knot
  20031. */
  20032. radius: number;
  20033. /**
  20034. * Defines the thickness of the torus knot tube
  20035. */
  20036. tube: number;
  20037. /**
  20038. * Defines the number of radial segments
  20039. */
  20040. radialSegments: number;
  20041. /**
  20042. * Defines the number of tubular segments
  20043. */
  20044. tubularSegments: number;
  20045. /**
  20046. * Defines the first number of windings
  20047. */
  20048. p: number;
  20049. /**
  20050. * Defines the second number of windings
  20051. */
  20052. q: number;
  20053. /**
  20054. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20055. */
  20056. side: number;
  20057. /**
  20058. * Creates a torus knot geometry
  20059. * @param id defines the unique ID of the geometry
  20060. * @param scene defines the hosting scene
  20061. * @param radius defines the radius of the torus knot
  20062. * @param tube defines the thickness of the torus knot tube
  20063. * @param radialSegments defines the number of radial segments
  20064. * @param tubularSegments defines the number of tubular segments
  20065. * @param p defines the first number of windings
  20066. * @param q defines the second number of windings
  20067. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20068. * @param mesh defines the hosting mesh (can be null)
  20069. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20070. */
  20071. constructor(id: string, scene: Scene,
  20072. /**
  20073. * Defines the radius of the torus knot
  20074. */
  20075. radius: number,
  20076. /**
  20077. * Defines the thickness of the torus knot tube
  20078. */
  20079. tube: number,
  20080. /**
  20081. * Defines the number of radial segments
  20082. */
  20083. radialSegments: number,
  20084. /**
  20085. * Defines the number of tubular segments
  20086. */
  20087. tubularSegments: number,
  20088. /**
  20089. * Defines the first number of windings
  20090. */
  20091. p: number,
  20092. /**
  20093. * Defines the second number of windings
  20094. */
  20095. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20096. /**
  20097. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20098. */
  20099. side?: number);
  20100. _regenerateVertexData(): VertexData;
  20101. copy(id: string): Geometry;
  20102. serialize(): any;
  20103. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20104. }
  20105. }
  20106. declare module BABYLON {
  20107. class GroundMesh extends Mesh {
  20108. generateOctree: boolean;
  20109. private _heightQuads;
  20110. _subdivisionsX: number;
  20111. _subdivisionsY: number;
  20112. _width: number;
  20113. _height: number;
  20114. _minX: number;
  20115. _maxX: number;
  20116. _minZ: number;
  20117. _maxZ: number;
  20118. constructor(name: string, scene: Scene);
  20119. getClassName(): string;
  20120. readonly subdivisions: number;
  20121. readonly subdivisionsX: number;
  20122. readonly subdivisionsY: number;
  20123. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20124. /**
  20125. * Returns a height (y) value in the Worl system :
  20126. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20127. * Returns the ground y position if (x, z) are outside the ground surface.
  20128. */
  20129. getHeightAtCoordinates(x: number, z: number): number;
  20130. /**
  20131. * Returns a normalized vector (Vector3) orthogonal to the ground
  20132. * at the ground coordinates (x, z) expressed in the World system.
  20133. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20134. */
  20135. getNormalAtCoordinates(x: number, z: number): Vector3;
  20136. /**
  20137. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20138. * at the ground coordinates (x, z) expressed in the World system.
  20139. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20140. * Returns the GroundMesh.
  20141. */
  20142. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20143. /**
  20144. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20145. * if the ground has been updated.
  20146. * This can be used in the render loop.
  20147. * Returns the GroundMesh.
  20148. */
  20149. updateCoordinateHeights(): GroundMesh;
  20150. private _getFacetAt(x, z);
  20151. private _initHeightQuads();
  20152. private _computeHeightQuads();
  20153. serialize(serializationObject: any): void;
  20154. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20155. }
  20156. }
  20157. declare module BABYLON {
  20158. /**
  20159. * Creates an instance based on a source mesh.
  20160. */
  20161. class InstancedMesh extends AbstractMesh {
  20162. private _sourceMesh;
  20163. private _currentLOD;
  20164. constructor(name: string, source: Mesh);
  20165. /**
  20166. * Returns the string "InstancedMesh".
  20167. */
  20168. getClassName(): string;
  20169. readonly receiveShadows: boolean;
  20170. readonly material: Nullable<Material>;
  20171. readonly visibility: number;
  20172. readonly skeleton: Nullable<Skeleton>;
  20173. renderingGroupId: number;
  20174. /**
  20175. * Returns the total number of vertices (integer).
  20176. */
  20177. getTotalVertices(): number;
  20178. readonly sourceMesh: Mesh;
  20179. /**
  20180. * Is this node ready to be used/rendered
  20181. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20182. * @return {boolean} is it ready
  20183. */
  20184. isReady(completeCheck?: boolean): boolean;
  20185. /**
  20186. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20187. */
  20188. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20189. /**
  20190. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20191. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20192. * The `data` are either a numeric array either a Float32Array.
  20193. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20194. * 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).
  20195. * Note that a new underlying VertexBuffer object is created each call.
  20196. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20197. *
  20198. * Possible `kind` values :
  20199. * - BABYLON.VertexBuffer.PositionKind
  20200. * - BABYLON.VertexBuffer.UVKind
  20201. * - BABYLON.VertexBuffer.UV2Kind
  20202. * - BABYLON.VertexBuffer.UV3Kind
  20203. * - BABYLON.VertexBuffer.UV4Kind
  20204. * - BABYLON.VertexBuffer.UV5Kind
  20205. * - BABYLON.VertexBuffer.UV6Kind
  20206. * - BABYLON.VertexBuffer.ColorKind
  20207. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20208. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20209. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20210. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20211. *
  20212. * Returns the Mesh.
  20213. */
  20214. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20215. /**
  20216. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20217. * If the mesh has no geometry, it is simply returned as it is.
  20218. * The `data` are either a numeric array either a Float32Array.
  20219. * No new underlying VertexBuffer object is created.
  20220. * 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.
  20221. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20222. *
  20223. * Possible `kind` values :
  20224. * - BABYLON.VertexBuffer.PositionKind
  20225. * - BABYLON.VertexBuffer.UVKind
  20226. * - BABYLON.VertexBuffer.UV2Kind
  20227. * - BABYLON.VertexBuffer.UV3Kind
  20228. * - BABYLON.VertexBuffer.UV4Kind
  20229. * - BABYLON.VertexBuffer.UV5Kind
  20230. * - BABYLON.VertexBuffer.UV6Kind
  20231. * - BABYLON.VertexBuffer.ColorKind
  20232. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20233. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20234. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20235. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20236. *
  20237. * Returns the Mesh.
  20238. */
  20239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20240. /**
  20241. * Sets the mesh indices.
  20242. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20243. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20244. * This method creates a new index buffer each call.
  20245. * Returns the Mesh.
  20246. */
  20247. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20248. /**
  20249. * Boolean : True if the mesh owns the requested kind of data.
  20250. */
  20251. isVerticesDataPresent(kind: string): boolean;
  20252. /**
  20253. * Returns an array of indices (IndicesArray).
  20254. */
  20255. getIndices(): Nullable<IndicesArray>;
  20256. readonly _positions: Nullable<Vector3[]>;
  20257. /**
  20258. * Sets a new updated BoundingInfo to the mesh.
  20259. * Returns the mesh.
  20260. */
  20261. refreshBoundingInfo(): InstancedMesh;
  20262. _preActivate(): InstancedMesh;
  20263. _activate(renderId: number): InstancedMesh;
  20264. /**
  20265. * Returns the current associated LOD AbstractMesh.
  20266. */
  20267. getLOD(camera: Camera): AbstractMesh;
  20268. _syncSubMeshes(): InstancedMesh;
  20269. _generatePointsArray(): boolean;
  20270. /**
  20271. * Creates a new InstancedMesh from the current mesh.
  20272. * - name (string) : the cloned mesh name
  20273. * - newParent (optional Node) : the optional Node to parent the clone to.
  20274. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20275. *
  20276. * Returns the clone.
  20277. */
  20278. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20279. /**
  20280. * Disposes the InstancedMesh.
  20281. * Returns nothing.
  20282. */
  20283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20284. }
  20285. }
  20286. declare module BABYLON {
  20287. class LinesMesh extends Mesh {
  20288. useVertexColor: boolean | undefined;
  20289. useVertexAlpha: boolean | undefined;
  20290. color: Color3;
  20291. alpha: number;
  20292. /**
  20293. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20294. * This margin is expressed in world space coordinates, so its value may vary.
  20295. * Default value is 0.1
  20296. * @returns the intersection Threshold value.
  20297. */
  20298. /**
  20299. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20300. * This margin is expressed in world space coordinates, so its value may vary.
  20301. * @param value the new threshold to apply
  20302. */
  20303. intersectionThreshold: number;
  20304. private _intersectionThreshold;
  20305. private _colorShader;
  20306. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20307. /**
  20308. * Returns the string "LineMesh"
  20309. */
  20310. getClassName(): string;
  20311. material: Material;
  20312. readonly checkCollisions: boolean;
  20313. createInstance(name: string): InstancedMesh;
  20314. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20315. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20316. dispose(doNotRecurse?: boolean): void;
  20317. /**
  20318. * Returns a new LineMesh object cloned from the current one.
  20319. */
  20320. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20321. }
  20322. }
  20323. declare module BABYLON {
  20324. /**
  20325. * @hidden
  20326. **/
  20327. class _InstancesBatch {
  20328. mustReturn: boolean;
  20329. visibleInstances: Nullable<InstancedMesh[]>[];
  20330. renderSelf: boolean[];
  20331. }
  20332. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20333. static _FRONTSIDE: number;
  20334. static _BACKSIDE: number;
  20335. static _DOUBLESIDE: number;
  20336. static _DEFAULTSIDE: number;
  20337. static _NO_CAP: number;
  20338. static _CAP_START: number;
  20339. static _CAP_END: number;
  20340. static _CAP_ALL: number;
  20341. /**
  20342. * Mesh side orientation : usually the external or front surface
  20343. */
  20344. static readonly FRONTSIDE: number;
  20345. /**
  20346. * Mesh side orientation : usually the internal or back surface
  20347. */
  20348. static readonly BACKSIDE: number;
  20349. /**
  20350. * Mesh side orientation : both internal and external or front and back surfaces
  20351. */
  20352. static readonly DOUBLESIDE: number;
  20353. /**
  20354. * Mesh side orientation : by default, `FRONTSIDE`
  20355. */
  20356. static readonly DEFAULTSIDE: number;
  20357. /**
  20358. * Mesh cap setting : no cap
  20359. */
  20360. static readonly NO_CAP: number;
  20361. /**
  20362. * Mesh cap setting : one cap at the beginning of the mesh
  20363. */
  20364. static readonly CAP_START: number;
  20365. /**
  20366. * Mesh cap setting : one cap at the end of the mesh
  20367. */
  20368. static readonly CAP_END: number;
  20369. /**
  20370. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20371. */
  20372. static readonly CAP_ALL: number;
  20373. /**
  20374. * An event triggered before rendering the mesh
  20375. */
  20376. onBeforeRenderObservable: Observable<Mesh>;
  20377. /**
  20378. * An event triggered after rendering the mesh
  20379. */
  20380. onAfterRenderObservable: Observable<Mesh>;
  20381. /**
  20382. * An event triggered before drawing the mesh
  20383. */
  20384. onBeforeDrawObservable: Observable<Mesh>;
  20385. private _onBeforeDrawObserver;
  20386. onBeforeDraw: () => void;
  20387. delayLoadState: number;
  20388. instances: InstancedMesh[];
  20389. delayLoadingFile: string;
  20390. _binaryInfo: any;
  20391. private _LODLevels;
  20392. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  20393. private _morphTargetManager;
  20394. morphTargetManager: Nullable<MorphTargetManager>;
  20395. _geometry: Nullable<Geometry>;
  20396. _delayInfo: Array<string>;
  20397. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20398. _visibleInstances: any;
  20399. private _renderIdForInstances;
  20400. private _batchCache;
  20401. private _instancesBufferSize;
  20402. private _instancesBuffer;
  20403. private _instancesData;
  20404. private _overridenInstanceCount;
  20405. private _effectiveMaterial;
  20406. _shouldGenerateFlatShading: boolean;
  20407. private _preActivateId;
  20408. _originalBuilderSideOrientation: number;
  20409. overrideMaterialSideOrientation: Nullable<number>;
  20410. private _areNormalsFrozen;
  20411. private _sourcePositions;
  20412. private _sourceNormals;
  20413. private _source;
  20414. readonly source: Nullable<Mesh>;
  20415. isUnIndexed: boolean;
  20416. /**
  20417. * @constructor
  20418. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20419. * @param {Scene} scene The scene to add this mesh to.
  20420. * @param {Node} parent The parent of this mesh, if it has one
  20421. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20422. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20423. * When false, achieved by calling a clone(), also passing False.
  20424. * This will make creation of children, recursive.
  20425. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20426. */
  20427. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20428. /**
  20429. * Returns the string "Mesh".
  20430. */
  20431. getClassName(): string;
  20432. /**
  20433. * Returns a string.
  20434. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20435. */
  20436. toString(fullDetails?: boolean): string;
  20437. _unBindEffect(): void;
  20438. /**
  20439. * True if the mesh has some Levels Of Details (LOD).
  20440. * Returns a boolean.
  20441. */
  20442. readonly hasLODLevels: boolean;
  20443. /**
  20444. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20445. * @returns an array of {BABYLON.MeshLODLevel}
  20446. */
  20447. getLODLevels(): MeshLODLevel[];
  20448. private _sortLODLevels();
  20449. /**
  20450. * Add a mesh as LOD level triggered at the given distance.
  20451. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20452. * @param {number} distance The distance from the center of the object to show this level
  20453. * @param {Mesh} mesh The mesh to be added as LOD level
  20454. * @return {Mesh} This mesh (for chaining)
  20455. */
  20456. addLODLevel(distance: number, mesh: Mesh): Mesh;
  20457. /**
  20458. * Returns the LOD level mesh at the passed distance or null if not found.
  20459. * It is related to the method `addLODLevel(distance, mesh)`.
  20460. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20461. * Returns an object Mesh or `null`.
  20462. */
  20463. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20464. /**
  20465. * Remove a mesh from the LOD array
  20466. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20467. * @param {Mesh} mesh The mesh to be removed.
  20468. * @return {Mesh} This mesh (for chaining)
  20469. */
  20470. removeLODLevel(mesh: Mesh): Mesh;
  20471. /**
  20472. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20473. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20474. */
  20475. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  20476. /**
  20477. * Returns the mesh internal Geometry object.
  20478. */
  20479. readonly geometry: Nullable<Geometry>;
  20480. /**
  20481. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20482. */
  20483. getTotalVertices(): number;
  20484. /**
  20485. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20486. * 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.
  20487. * You can force the copy with forceCopy === true
  20488. * Returns null if the mesh has no geometry or no vertex buffer.
  20489. * Possible `kind` values :
  20490. * - BABYLON.VertexBuffer.PositionKind
  20491. * - BABYLON.VertexBuffer.UVKind
  20492. * - BABYLON.VertexBuffer.UV2Kind
  20493. * - BABYLON.VertexBuffer.UV3Kind
  20494. * - BABYLON.VertexBuffer.UV4Kind
  20495. * - BABYLON.VertexBuffer.UV5Kind
  20496. * - BABYLON.VertexBuffer.UV6Kind
  20497. * - BABYLON.VertexBuffer.ColorKind
  20498. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20499. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20500. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20501. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20502. */
  20503. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20504. /**
  20505. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20506. * Returns `null` if the mesh has no geometry.
  20507. * Possible `kind` values :
  20508. * - BABYLON.VertexBuffer.PositionKind
  20509. * - BABYLON.VertexBuffer.UVKind
  20510. * - BABYLON.VertexBuffer.UV2Kind
  20511. * - BABYLON.VertexBuffer.UV3Kind
  20512. * - BABYLON.VertexBuffer.UV4Kind
  20513. * - BABYLON.VertexBuffer.UV5Kind
  20514. * - BABYLON.VertexBuffer.UV6Kind
  20515. * - BABYLON.VertexBuffer.ColorKind
  20516. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20517. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20518. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20519. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20520. */
  20521. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20522. isVerticesDataPresent(kind: string): boolean;
  20523. /**
  20524. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20525. * Possible `kind` values :
  20526. * - BABYLON.VertexBuffer.PositionKind
  20527. * - BABYLON.VertexBuffer.UVKind
  20528. * - BABYLON.VertexBuffer.UV2Kind
  20529. * - BABYLON.VertexBuffer.UV3Kind
  20530. * - BABYLON.VertexBuffer.UV4Kind
  20531. * - BABYLON.VertexBuffer.UV5Kind
  20532. * - BABYLON.VertexBuffer.UV6Kind
  20533. * - BABYLON.VertexBuffer.ColorKind
  20534. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20535. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20536. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20537. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20538. */
  20539. isVertexBufferUpdatable(kind: string): boolean;
  20540. /**
  20541. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20542. * Possible `kind` values :
  20543. * - BABYLON.VertexBuffer.PositionKind
  20544. * - BABYLON.VertexBuffer.UVKind
  20545. * - BABYLON.VertexBuffer.UV2Kind
  20546. * - BABYLON.VertexBuffer.UV3Kind
  20547. * - BABYLON.VertexBuffer.UV4Kind
  20548. * - BABYLON.VertexBuffer.UV5Kind
  20549. * - BABYLON.VertexBuffer.UV6Kind
  20550. * - BABYLON.VertexBuffer.ColorKind
  20551. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20552. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20553. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20554. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20555. */
  20556. getVerticesDataKinds(): string[];
  20557. /**
  20558. * Returns a positive integer : the total number of indices in this mesh geometry.
  20559. * Returns zero if the mesh has no geometry.
  20560. */
  20561. getTotalIndices(): number;
  20562. /**
  20563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20564. * 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.
  20565. * Returns an empty array if the mesh has no geometry.
  20566. */
  20567. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20568. readonly isBlocked: boolean;
  20569. /**
  20570. * Determine if the current mesh is ready to be rendered
  20571. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20572. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20573. * @returns true if all associated assets are ready (material, textures, shaders)
  20574. */
  20575. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20576. /**
  20577. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20578. * This property is pertinent only for updatable parametric shapes.
  20579. */
  20580. readonly areNormalsFrozen: boolean;
  20581. /**
  20582. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20583. * It has no effect at all on other shapes.
  20584. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20585. * Returns the Mesh.
  20586. */
  20587. freezeNormals(): Mesh;
  20588. /**
  20589. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20590. * It has no effect at all on other shapes.
  20591. * It reactivates the mesh normals computation if it was previously frozen.
  20592. * Returns the Mesh.
  20593. */
  20594. unfreezeNormals(): Mesh;
  20595. /**
  20596. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20597. */
  20598. overridenInstanceCount: number;
  20599. _preActivate(): Mesh;
  20600. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20601. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20602. /**
  20603. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20604. * This means the mesh underlying bounding box and sphere are recomputed.
  20605. * Returns the Mesh.
  20606. */
  20607. refreshBoundingInfo(): Mesh;
  20608. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20609. private _getPositionData(applySkeleton);
  20610. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20611. subdivide(count: number): void;
  20612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20613. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20614. /**
  20615. * Sets the mesh VertexBuffer.
  20616. * Returns the Mesh.
  20617. */
  20618. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20619. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20620. /**
  20621. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20622. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20623. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20624. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20625. * Returns the Mesh.
  20626. */
  20627. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20628. /**
  20629. * Creates a un-shared specific occurence of the geometry for the mesh.
  20630. * Returns the Mesh.
  20631. */
  20632. makeGeometryUnique(): Mesh;
  20633. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20634. /**
  20635. * Update the current index buffer
  20636. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20637. * Returns the Mesh.
  20638. */
  20639. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20640. /**
  20641. * Invert the geometry to move from a right handed system to a left handed one.
  20642. * Returns the Mesh.
  20643. */
  20644. toLeftHanded(): Mesh;
  20645. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20646. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20647. /**
  20648. * Registers for this mesh a javascript function called just before the rendering process.
  20649. * This function is passed the current mesh.
  20650. * Return the Mesh.
  20651. */
  20652. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20653. /**
  20654. * Disposes a previously registered javascript function called before the rendering.
  20655. * This function is passed the current mesh.
  20656. * Returns the Mesh.
  20657. */
  20658. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20659. /**
  20660. * Registers for this mesh a javascript function called just after the rendering is complete.
  20661. * This function is passed the current mesh.
  20662. * Returns the Mesh.
  20663. */
  20664. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20665. /**
  20666. * Disposes a previously registered javascript function called after the rendering.
  20667. * This function is passed the current mesh.
  20668. * Return the Mesh.
  20669. */
  20670. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20671. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20672. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20673. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20674. /**
  20675. * Triggers the draw call for the mesh.
  20676. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20677. * Returns the Mesh.
  20678. */
  20679. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20680. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20681. /**
  20682. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20683. */
  20684. getEmittedParticleSystems(): IParticleSystem[];
  20685. /**
  20686. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20687. */
  20688. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20689. /**
  20690. * Normalize matrix weights so that all vertices have a total weight set to 1
  20691. */
  20692. cleanMatrixWeights(): void;
  20693. _checkDelayState(): Mesh;
  20694. private _queueLoad(scene);
  20695. /**
  20696. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20697. */
  20698. isInFrustum(frustumPlanes: Plane[]): boolean;
  20699. /**
  20700. * Sets the mesh material by the material or multiMaterial `id` property.
  20701. * The material `id` is a string identifying the material or the multiMaterial.
  20702. * This method returns the Mesh.
  20703. */
  20704. setMaterialByID(id: string): Mesh;
  20705. /**
  20706. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20707. */
  20708. getAnimatables(): IAnimatable[];
  20709. /**
  20710. * Modifies the mesh geometry according to the passed transformation matrix.
  20711. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20712. * The mesh normals are modified accordingly the same transformation.
  20713. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  20714. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20715. * Returns the Mesh.
  20716. */
  20717. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20718. /**
  20719. * Modifies the mesh geometry according to its own current World Matrix.
  20720. * The mesh World Matrix is then reset.
  20721. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20722. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20723. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20724. * Returns the Mesh.
  20725. */
  20726. bakeCurrentTransformIntoVertices(): Mesh;
  20727. readonly _positions: Nullable<Vector3[]>;
  20728. _resetPointsArrayCache(): Mesh;
  20729. _generatePointsArray(): boolean;
  20730. /**
  20731. * Returns a new Mesh object generated from the current mesh properties.
  20732. * This method must not get confused with createInstance().
  20733. * The parameter `name` is a string, the name given to the new mesh.
  20734. * The optional parameter `newParent` can be any Node object (default `null`).
  20735. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20736. * 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.
  20737. */
  20738. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20739. /**
  20740. * Releases resources associated with this mesh.
  20741. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20742. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20743. */
  20744. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20745. /**
  20746. * Modifies the mesh geometry according to a displacement map.
  20747. * 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.
  20748. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20749. * This method returns nothing.
  20750. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20751. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20752. * 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.
  20753. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20754. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20755. *
  20756. * Returns the Mesh.
  20757. */
  20758. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20759. /**
  20760. * Modifies the mesh geometry according to a displacementMap buffer.
  20761. * 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.
  20762. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20763. * This method returns nothing.
  20764. * 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.
  20765. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20766. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20767. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20768. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20769. *
  20770. * Returns the Mesh.
  20771. */
  20772. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20773. /**
  20774. * Modify the mesh to get a flat shading rendering.
  20775. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20776. * This method returns the Mesh.
  20777. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20778. */
  20779. convertToFlatShadedMesh(): Mesh;
  20780. /**
  20781. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20782. * In other words, more vertices, no more indices and a single bigger VBO.
  20783. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20784. * Returns the Mesh.
  20785. */
  20786. convertToUnIndexedMesh(): Mesh;
  20787. /**
  20788. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20789. * This method returns the Mesh.
  20790. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20791. */
  20792. flipFaces(flipNormals?: boolean): Mesh;
  20793. /**
  20794. * Creates a new InstancedMesh object from the mesh model.
  20795. * An instance shares the same properties and the same material than its model.
  20796. * Only these properties of each instance can then be set individually :
  20797. * - position
  20798. * - rotation
  20799. * - rotationQuaternion
  20800. * - setPivotMatrix
  20801. * - scaling
  20802. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20803. * Warning : this method is not supported for Line mesh and LineSystem
  20804. */
  20805. createInstance(name: string): InstancedMesh;
  20806. /**
  20807. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20808. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20809. * This method returns the Mesh.
  20810. */
  20811. synchronizeInstances(): Mesh;
  20812. /**
  20813. * Simplify the mesh according to the given array of settings.
  20814. * Function will return immediately and will simplify async. It returns the Mesh.
  20815. * @param settings a collection of simplification settings.
  20816. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20817. * @param type the type of simplification to run.
  20818. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20819. */
  20820. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20821. /**
  20822. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20823. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20824. * This should be used together with the simplification to avoid disappearing triangles.
  20825. * Returns the Mesh.
  20826. * @param successCallback an optional success callback to be called after the optimization finished.
  20827. */
  20828. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20829. serialize(serializationObject: any): void;
  20830. _syncGeometryWithMorphTargetManager(): void;
  20831. /**
  20832. * Returns a new Mesh object parsed from the source provided.
  20833. * The parameter `parsedMesh` is the source.
  20834. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20835. */
  20836. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20837. /**
  20838. * Creates a ribbon mesh.
  20839. * Please consider using the same method from the MeshBuilder class instead.
  20840. * 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.
  20841. *
  20842. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20843. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20844. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20845. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20846. * 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.
  20847. * 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.
  20848. * 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
  20849. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20850. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20851. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20852. */
  20853. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20854. /**
  20855. * Creates a plane polygonal mesh. By default, this is a disc.
  20856. * Please consider using the same method from the MeshBuilder class instead.
  20857. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20858. * 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.
  20859. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20860. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20861. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20862. */
  20863. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20864. /**
  20865. * Creates a box mesh.
  20866. * Please consider using the same method from the MeshBuilder class instead.
  20867. * The parameter `size` sets the size (float) of each box side (default 1).
  20868. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20869. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20870. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20871. */
  20872. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20873. /**
  20874. * Creates a sphere mesh.
  20875. * Please consider using the same method from the MeshBuilder class instead.
  20876. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20877. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20878. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20879. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20880. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20881. */
  20882. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20883. /**
  20884. * Creates a cylinder or a cone mesh.
  20885. * Please consider using the same method from the MeshBuilder class instead.
  20886. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20887. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20888. * 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.
  20889. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20890. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20891. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20892. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20893. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20894. */
  20895. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20896. /**
  20897. * Creates a torus mesh.
  20898. * Please consider using the same method from the MeshBuilder class instead.
  20899. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20900. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20901. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20902. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20903. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20904. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20905. */
  20906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20907. /**
  20908. * Creates a torus knot mesh.
  20909. * Please consider using the same method from the MeshBuilder class instead.
  20910. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20911. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20912. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20913. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20914. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20915. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20916. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20917. */
  20918. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20919. /**
  20920. * Creates a line mesh.
  20921. * Please consider using the same method from the MeshBuilder class instead.
  20922. * 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.
  20923. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20924. * The parameter `points` is an array successive Vector3.
  20925. * 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
  20926. * When updating an instance, remember that only point positions can change, not the number of points.
  20927. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20928. */
  20929. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20930. /**
  20931. * Creates a dashed line mesh.
  20932. * Please consider using the same method from the MeshBuilder class instead.
  20933. * 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.
  20934. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20935. * The parameter `points` is an array successive Vector3.
  20936. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20937. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20938. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20939. * 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
  20940. * When updating an instance, remember that only point positions can change, not the number of points.
  20941. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20942. */
  20943. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20944. /**
  20945. * Creates a polygon mesh.
  20946. * Please consider using the same method from the MeshBuilder class instead.
  20947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20948. * 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.
  20949. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20951. * Remember you can only change the shape positions, not their number when updating a polygon.
  20952. */
  20953. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20954. /**
  20955. * Creates an extruded polygon mesh, with depth in the Y direction.
  20956. * Please consider using the same method from the MeshBuilder class instead.
  20957. */
  20958. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20959. /**
  20960. * Creates an extruded shape mesh.
  20961. * 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.
  20962. * Please consider using the same method from the MeshBuilder class instead.
  20963. *
  20964. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20965. * 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
  20966. * extruded along the Z axis.
  20967. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20968. * 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.
  20969. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20970. * 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
  20971. * 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
  20972. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20973. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20974. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20975. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20976. */
  20977. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20978. /**
  20979. * Creates an custom extruded shape mesh.
  20980. * 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.
  20981. * Please consider using the same method from the MeshBuilder class instead.
  20982. *
  20983. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20984. * 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
  20985. * extruded along the Z axis.
  20986. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20987. * 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
  20988. * and the distance of this point from the begining of the path :
  20989. * ```javascript
  20990. * var rotationFunction = function(i, distance) {
  20991. * // do things
  20992. * return rotationValue; }
  20993. * ```
  20994. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20995. * 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
  20996. * and the distance of this point from the begining of the path :
  20997. * ```javascript
  20998. * var scaleFunction = function(i, distance) {
  20999. * // do things
  21000. * return scaleValue;}
  21001. * ```
  21002. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21003. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21004. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21005. * 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
  21006. * 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
  21007. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21008. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21009. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21010. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21011. */
  21012. 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;
  21013. /**
  21014. * Creates lathe mesh.
  21015. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21016. * Please consider using the same method from the MeshBuilder class instead.
  21017. * 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
  21018. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21019. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21020. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21021. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21022. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21023. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21024. */
  21025. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21026. /**
  21027. * Creates a plane mesh.
  21028. * Please consider using the same method from the MeshBuilder class instead.
  21029. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21030. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21031. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21032. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21033. */
  21034. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21035. /**
  21036. * Creates a ground mesh.
  21037. * Please consider using the same method from the MeshBuilder class instead.
  21038. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21039. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21040. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21041. */
  21042. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21043. /**
  21044. * Creates a tiled ground mesh.
  21045. * Please consider using the same method from the MeshBuilder class instead.
  21046. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21047. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21048. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21049. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21050. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21051. * numbers of subdivisions on the ground width and height of each tile.
  21052. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21053. */
  21054. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21055. w: number;
  21056. h: number;
  21057. }, precision: {
  21058. w: number;
  21059. h: number;
  21060. }, scene: Scene, updatable?: boolean): Mesh;
  21061. /**
  21062. * Creates a ground mesh from a height map.
  21063. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21064. * Please consider using the same method from the MeshBuilder class instead.
  21065. * The parameter `url` sets the URL of the height map image resource.
  21066. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21067. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21068. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21069. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21070. * 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).
  21071. * This function is passed the newly built mesh :
  21072. * ```javascript
  21073. * function(mesh) { // do things
  21074. * return; }
  21075. * ```
  21076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21077. */
  21078. 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;
  21079. /**
  21080. * Creates a tube mesh.
  21081. * 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.
  21082. * Please consider using the same method from the MeshBuilder class instead.
  21083. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21084. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21085. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21086. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21087. * 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.
  21088. * It must return a radius value (positive float) :
  21089. * ```javascript
  21090. * var radiusFunction = function(i, distance) {
  21091. * // do things
  21092. * return radius; }
  21093. * ```
  21094. * 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
  21095. * 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
  21096. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21097. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21098. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21099. */
  21100. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21101. (i: number, distance: number): number;
  21102. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21103. /**
  21104. * Creates a polyhedron mesh.
  21105. * Please consider using the same method from the MeshBuilder class instead.
  21106. * 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
  21107. * to choose the wanted type.
  21108. * The parameter `size` (positive float, default 1) sets the polygon size.
  21109. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21110. * 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`.
  21111. * 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
  21112. * 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)`).
  21113. * 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
  21114. * 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.
  21115. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21116. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21117. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21118. */
  21119. static CreatePolyhedron(name: string, options: {
  21120. type?: number;
  21121. size?: number;
  21122. sizeX?: number;
  21123. sizeY?: number;
  21124. sizeZ?: number;
  21125. custom?: any;
  21126. faceUV?: Vector4[];
  21127. faceColors?: Color4[];
  21128. updatable?: boolean;
  21129. sideOrientation?: number;
  21130. }, scene: Scene): Mesh;
  21131. /**
  21132. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21133. * Please consider using the same method from the MeshBuilder class instead.
  21134. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21135. * 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`).
  21136. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21137. * 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.
  21138. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21139. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21141. */
  21142. static CreateIcoSphere(name: string, options: {
  21143. radius?: number;
  21144. flat?: boolean;
  21145. subdivisions?: number;
  21146. sideOrientation?: number;
  21147. updatable?: boolean;
  21148. }, scene: Scene): Mesh;
  21149. /**
  21150. * Creates a decal mesh.
  21151. * Please consider using the same method from the MeshBuilder class instead.
  21152. * 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.
  21153. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21154. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21155. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21156. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21157. */
  21158. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21159. /**
  21160. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21161. */
  21162. setPositionsForCPUSkinning(): Float32Array;
  21163. /**
  21164. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21165. */
  21166. setNormalsForCPUSkinning(): Float32Array;
  21167. /**
  21168. * Updates the vertex buffer by applying transformation from the bones.
  21169. * Returns the Mesh.
  21170. *
  21171. * @param {skeleton} skeleton to apply
  21172. */
  21173. applySkeleton(skeleton: Skeleton): Mesh;
  21174. /**
  21175. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21176. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21177. */
  21178. static MinMax(meshes: AbstractMesh[]): {
  21179. min: Vector3;
  21180. max: Vector3;
  21181. };
  21182. /**
  21183. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21184. */
  21185. static Center(meshesOrMinMaxVector: {
  21186. min: Vector3;
  21187. max: Vector3;
  21188. } | AbstractMesh[]): Vector3;
  21189. /**
  21190. * Merge the array of meshes into a single mesh for performance reasons.
  21191. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21192. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21193. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21194. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21195. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21196. */
  21197. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21198. }
  21199. }
  21200. declare module BABYLON {
  21201. /**
  21202. * Define an interface for all classes that will get and set the data on vertices
  21203. */
  21204. interface IGetSetVerticesData {
  21205. isVerticesDataPresent(kind: string): boolean;
  21206. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21207. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21208. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21209. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21210. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21211. }
  21212. /**
  21213. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21214. */
  21215. class VertexData {
  21216. /**
  21217. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21218. */
  21219. positions: Nullable<FloatArray>;
  21220. /**
  21221. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21222. */
  21223. normals: Nullable<FloatArray>;
  21224. /**
  21225. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21226. */
  21227. tangents: Nullable<FloatArray>;
  21228. /**
  21229. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21230. */
  21231. uvs: Nullable<FloatArray>;
  21232. /**
  21233. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21234. */
  21235. uvs2: Nullable<FloatArray>;
  21236. /**
  21237. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21238. */
  21239. uvs3: Nullable<FloatArray>;
  21240. /**
  21241. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21242. */
  21243. uvs4: Nullable<FloatArray>;
  21244. /**
  21245. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21246. */
  21247. uvs5: Nullable<FloatArray>;
  21248. /**
  21249. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21250. */
  21251. uvs6: Nullable<FloatArray>;
  21252. /**
  21253. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21254. */
  21255. colors: Nullable<FloatArray>;
  21256. /**
  21257. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21258. */
  21259. matricesIndices: Nullable<FloatArray>;
  21260. /**
  21261. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21262. */
  21263. matricesWeights: Nullable<FloatArray>;
  21264. /**
  21265. * An array extending the number of possible indices
  21266. */
  21267. matricesIndicesExtra: Nullable<FloatArray>;
  21268. /**
  21269. * An array extending the number of possible weights when the number of indices is extended
  21270. */
  21271. matricesWeightsExtra: Nullable<FloatArray>;
  21272. /**
  21273. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21274. */
  21275. indices: Nullable<IndicesArray>;
  21276. /**
  21277. * Uses the passed data array to set the set the values for the specified kind of data
  21278. * @param data a linear array of floating numbers
  21279. * @param kind the type of data that is being set, eg positions, colors etc
  21280. */
  21281. set(data: FloatArray, kind: string): void;
  21282. /**
  21283. * Associates the vertexData to the passed Mesh.
  21284. * Sets it as updatable or not (default `false`)
  21285. * @param mesh the mesh the vertexData is applied to
  21286. * @param updatable when used and having the value true allows new data to update the vertexData
  21287. * @returns the VertexData
  21288. */
  21289. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21290. /**
  21291. * Associates the vertexData to the passed Geometry.
  21292. * Sets it as updatable or not (default `false`)
  21293. * @param geometry the geometry the vertexData is applied to
  21294. * @param updatable when used and having the value true allows new data to update the vertexData
  21295. * @returns VertexData
  21296. */
  21297. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21298. /**
  21299. * Updates the associated mesh
  21300. * @param mesh the mesh to be updated
  21301. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21302. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21303. * @returns VertexData
  21304. */
  21305. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21306. /**
  21307. * Updates the associated geometry
  21308. * @param geometry the geometry to be updated
  21309. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21310. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21311. * @returns VertexData.
  21312. */
  21313. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21314. private _applyTo(meshOrGeometry, updatable?);
  21315. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21316. /**
  21317. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21318. * @param matrix the transforming matrix
  21319. * @returns the VertexData
  21320. */
  21321. transform(matrix: Matrix): VertexData;
  21322. /**
  21323. * Merges the passed VertexData into the current one
  21324. * @param other the VertexData to be merged into the current one
  21325. * @returns the modified VertexData
  21326. */
  21327. merge(other: VertexData): VertexData;
  21328. private _mergeElement(source, other);
  21329. private _validate();
  21330. /**
  21331. * Serializes the VertexData
  21332. * @returns a serialized object
  21333. */
  21334. serialize(): any;
  21335. /**
  21336. * Extracts the vertexData from a mesh
  21337. * @param mesh the mesh from which to extract the VertexData
  21338. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21339. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21340. * @returns the object VertexData associated to the passed mesh
  21341. */
  21342. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21343. /**
  21344. * Extracts the vertexData from the geometry
  21345. * @param geometry the geometry from which to extract the VertexData
  21346. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21347. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21348. * @returns the object VertexData associated to the passed mesh
  21349. */
  21350. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21351. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21352. /**
  21353. * Creates the VertexData for a Ribbon
  21354. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21355. * * pathArray array of paths, each of which an array of successive Vector3
  21356. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21357. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21358. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21359. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21360. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21361. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21362. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21363. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21364. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21365. * @returns the VertexData of the ribbon
  21366. */
  21367. static CreateRibbon(options: {
  21368. pathArray: Vector3[][];
  21369. closeArray?: boolean;
  21370. closePath?: boolean;
  21371. offset?: number;
  21372. sideOrientation?: number;
  21373. frontUVs?: Vector4;
  21374. backUVs?: Vector4;
  21375. invertUV?: boolean;
  21376. uvs?: Vector2[];
  21377. colors?: Color4[];
  21378. }): VertexData;
  21379. /**
  21380. * Creates the VertexData for a box
  21381. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21382. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21383. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21384. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21385. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21386. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21387. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21388. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21389. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21390. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21391. * @returns the VertexData of the box
  21392. */
  21393. static CreateBox(options: {
  21394. size?: number;
  21395. width?: number;
  21396. height?: number;
  21397. depth?: number;
  21398. faceUV?: Vector4[];
  21399. faceColors?: Color4[];
  21400. sideOrientation?: number;
  21401. frontUVs?: Vector4;
  21402. backUVs?: Vector4;
  21403. }): VertexData;
  21404. /**
  21405. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21406. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21407. * * segments sets the number of horizontal strips optional, default 32
  21408. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21409. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21410. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21411. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21412. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  21413. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  21414. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21415. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21416. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21417. * @returns the VertexData of the ellipsoid
  21418. */
  21419. static CreateSphere(options: {
  21420. segments?: number;
  21421. diameter?: number;
  21422. diameterX?: number;
  21423. diameterY?: number;
  21424. diameterZ?: number;
  21425. arc?: number;
  21426. slice?: number;
  21427. sideOrientation?: number;
  21428. frontUVs?: Vector4;
  21429. backUVs?: Vector4;
  21430. }): VertexData;
  21431. /**
  21432. * Creates the VertexData for a cylinder, cone or prism
  21433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21434. * * height sets the height (y direction) of the cylinder, optional, default 2
  21435. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21436. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21437. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21438. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21439. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21440. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  21441. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21442. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21443. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21444. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21445. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21446. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21447. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21448. * @returns the VertexData of the cylinder, cone or prism
  21449. */
  21450. static CreateCylinder(options: {
  21451. height?: number;
  21452. diameterTop?: number;
  21453. diameterBottom?: number;
  21454. diameter?: number;
  21455. tessellation?: number;
  21456. subdivisions?: number;
  21457. arc?: number;
  21458. faceColors?: Color4[];
  21459. faceUV?: Vector4[];
  21460. hasRings?: boolean;
  21461. enclose?: boolean;
  21462. sideOrientation?: number;
  21463. frontUVs?: Vector4;
  21464. backUVs?: Vector4;
  21465. }): VertexData;
  21466. /**
  21467. * Creates the VertexData for a torus
  21468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21469. * * diameter the diameter of the torus, optional default 1
  21470. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21471. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21472. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21473. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21474. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21475. * @returns the VertexData of the torus
  21476. */
  21477. static CreateTorus(options: {
  21478. diameter?: number;
  21479. thickness?: number;
  21480. tessellation?: number;
  21481. sideOrientation?: number;
  21482. frontUVs?: Vector4;
  21483. backUVs?: Vector4;
  21484. }): VertexData;
  21485. /**
  21486. * Creates the VertexData of the LineSystem
  21487. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21488. * - lines an array of lines, each line being an array of successive Vector3
  21489. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21490. * @returns the VertexData of the LineSystem
  21491. */
  21492. static CreateLineSystem(options: {
  21493. lines: Vector3[][];
  21494. colors?: Nullable<Color4[][]>;
  21495. }): VertexData;
  21496. /**
  21497. * Create the VertexData for a DashedLines
  21498. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21499. * - points an array successive Vector3
  21500. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21501. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21502. * - dashNb the intended total number of dashes, optional, default 200
  21503. * @returns the VertexData for the DashedLines
  21504. */
  21505. static CreateDashedLines(options: {
  21506. points: Vector3[];
  21507. dashSize?: number;
  21508. gapSize?: number;
  21509. dashNb?: number;
  21510. }): VertexData;
  21511. /**
  21512. * Creates the VertexData for a Ground
  21513. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21514. * - width the width (x direction) of the ground, optional, default 1
  21515. * - height the height (z direction) of the ground, optional, default 1
  21516. * - subdivisions the number of subdivisions per side, optional, default 1
  21517. * @returns the VertexData of the Ground
  21518. */
  21519. static CreateGround(options: {
  21520. width?: number;
  21521. height?: number;
  21522. subdivisions?: number;
  21523. subdivisionsX?: number;
  21524. subdivisionsY?: number;
  21525. }): VertexData;
  21526. /**
  21527. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21528. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21529. * * xmin the ground minimum X coordinate, optional, default -1
  21530. * * zmin the ground minimum Z coordinate, optional, default -1
  21531. * * xmax the ground maximum X coordinate, optional, default 1
  21532. * * zmax the ground maximum Z coordinate, optional, default 1
  21533. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  21534. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  21535. * @returns the VertexData of the TiledGround
  21536. */
  21537. static CreateTiledGround(options: {
  21538. xmin: number;
  21539. zmin: number;
  21540. xmax: number;
  21541. zmax: number;
  21542. subdivisions?: {
  21543. w: number;
  21544. h: number;
  21545. };
  21546. precision?: {
  21547. w: number;
  21548. h: number;
  21549. };
  21550. }): VertexData;
  21551. /**
  21552. * Creates the VertexData of the Ground designed from a heightmap
  21553. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21554. * * width the width (x direction) of the ground
  21555. * * height the height (z direction) of the ground
  21556. * * subdivisions the number of subdivisions per side
  21557. * * minHeight the minimum altitude on the ground, optional, default 0
  21558. * * maxHeight the maximum altitude on the ground, optional default 1
  21559. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21560. * * buffer the array holding the image color data
  21561. * * bufferWidth the width of image
  21562. * * bufferHeight the height of image
  21563. * @returns the VertexData of the Ground designed from a heightmap
  21564. */
  21565. static CreateGroundFromHeightMap(options: {
  21566. width: number;
  21567. height: number;
  21568. subdivisions: number;
  21569. minHeight: number;
  21570. maxHeight: number;
  21571. colorFilter: Color3;
  21572. buffer: Uint8Array;
  21573. bufferWidth: number;
  21574. bufferHeight: number;
  21575. }): VertexData;
  21576. /**
  21577. * Creates the VertexData for a Plane
  21578. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21579. * * size sets the width and height of the plane to the value of size, optional default 1
  21580. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21581. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21582. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21583. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21584. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21585. * @returns the VertexData of the box
  21586. */
  21587. static CreatePlane(options: {
  21588. size?: number;
  21589. width?: number;
  21590. height?: number;
  21591. sideOrientation?: number;
  21592. frontUVs?: Vector4;
  21593. backUVs?: Vector4;
  21594. }): VertexData;
  21595. /**
  21596. * Creates the VertexData of the Disc or regular Polygon
  21597. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21598. * * radius the radius of the disc, optional default 0.5
  21599. * * tessellation the number of polygon sides, optional, default 64
  21600. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  21601. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21602. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21603. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21604. * @returns the VertexData of the box
  21605. */
  21606. static CreateDisc(options: {
  21607. radius?: number;
  21608. tessellation?: number;
  21609. arc?: number;
  21610. sideOrientation?: number;
  21611. frontUVs?: Vector4;
  21612. backUVs?: Vector4;
  21613. }): VertexData;
  21614. /**
  21615. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21616. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21617. * @param polygon a mesh built from polygonTriangulation.build()
  21618. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21619. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21620. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21621. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21622. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21623. * @returns the VertexData of the Polygon
  21624. */
  21625. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21626. /**
  21627. * Creates the VertexData of the IcoSphere
  21628. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21629. * * radius the radius of the IcoSphere, optional default 1
  21630. * * radiusX allows stretching in the x direction, optional, default radius
  21631. * * radiusY allows stretching in the y direction, optional, default radius
  21632. * * radiusZ allows stretching in the z direction, optional, default radius
  21633. * * flat when true creates a flat shaded mesh, optional, default true
  21634. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21635. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21636. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21637. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21638. * @returns the VertexData of the IcoSphere
  21639. */
  21640. static CreateIcoSphere(options: {
  21641. radius?: number;
  21642. radiusX?: number;
  21643. radiusY?: number;
  21644. radiusZ?: number;
  21645. flat?: boolean;
  21646. subdivisions?: number;
  21647. sideOrientation?: number;
  21648. frontUVs?: Vector4;
  21649. backUVs?: Vector4;
  21650. }): VertexData;
  21651. /**
  21652. * Creates the VertexData for a Polyhedron
  21653. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21654. * * type provided types are:
  21655. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21656. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  21657. * * size the size of the IcoSphere, optional default 1
  21658. * * sizeX allows stretching in the x direction, optional, default size
  21659. * * sizeY allows stretching in the y direction, optional, default size
  21660. * * sizeZ allows stretching in the z direction, optional, default size
  21661. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  21662. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21663. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21664. * * flat when true creates a flat shaded mesh, optional, default true
  21665. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21666. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21667. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21668. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21669. * @returns the VertexData of the Polyhedron
  21670. */
  21671. static CreatePolyhedron(options: {
  21672. type?: number;
  21673. size?: number;
  21674. sizeX?: number;
  21675. sizeY?: number;
  21676. sizeZ?: number;
  21677. custom?: any;
  21678. faceUV?: Vector4[];
  21679. faceColors?: Color4[];
  21680. flat?: boolean;
  21681. sideOrientation?: number;
  21682. frontUVs?: Vector4;
  21683. backUVs?: Vector4;
  21684. }): VertexData;
  21685. /**
  21686. * Creates the VertexData for a TorusKnot
  21687. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21688. * * radius the radius of the torus knot, optional, default 2
  21689. * * tube the thickness of the tube, optional, default 0.5
  21690. * * radialSegments the number of sides on each tube segments, optional, default 32
  21691. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21692. * * p the number of windings around the z axis, optional, default 2
  21693. * * q the number of windings around the x axis, optional, default 3
  21694. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21695. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21696. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21697. * @returns the VertexData of the Torus Knot
  21698. */
  21699. static CreateTorusKnot(options: {
  21700. radius?: number;
  21701. tube?: number;
  21702. radialSegments?: number;
  21703. tubularSegments?: number;
  21704. p?: number;
  21705. q?: number;
  21706. sideOrientation?: number;
  21707. frontUVs?: Vector4;
  21708. backUVs?: Vector4;
  21709. }): VertexData;
  21710. /**
  21711. * Compute normals for given positions and indices
  21712. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21713. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21714. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21715. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21716. * * facetNormals : optional array of facet normals (vector3)
  21717. * * facetPositions : optional array of facet positions (vector3)
  21718. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21719. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21720. * * bInfo : optional bounding info, required for facetPartitioning computation
  21721. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21722. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21723. * * useRightHandedSystem: optional boolean to for right handed system computation
  21724. * * depthSort : optional boolean to enable the facet depth sort computation
  21725. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21726. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21727. */
  21728. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21729. facetNormals?: any;
  21730. facetPositions?: any;
  21731. facetPartitioning?: any;
  21732. ratio?: number;
  21733. bInfo?: any;
  21734. bbSize?: Vector3;
  21735. subDiv?: any;
  21736. useRightHandedSystem?: boolean;
  21737. depthSort?: boolean;
  21738. distanceTo?: Vector3;
  21739. depthSortedFacets?: any;
  21740. }): void;
  21741. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21742. /**
  21743. * Applies VertexData created from the imported parameters to the geometry
  21744. * @param parsedVertexData the parsed data from an imported file
  21745. * @param geometry the geometry to apply the VertexData to
  21746. */
  21747. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21748. }
  21749. }
  21750. declare module BABYLON {
  21751. /**
  21752. * Class containing static functions to help procedurally build meshes
  21753. */
  21754. class MeshBuilder {
  21755. private static updateSideOrientation(orientation?);
  21756. /**
  21757. * Creates a box mesh
  21758. * * The parameter `size` sets the size (float) of each box side (default 1)
  21759. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  21760. * * 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)
  21761. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21765. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21766. * @param name defines the name of the mesh
  21767. * @param options defines the options used to create the mesh
  21768. * @param scene defines the hosting scene
  21769. * @returns the box mesh
  21770. */
  21771. static CreateBox(name: string, options: {
  21772. size?: number;
  21773. width?: number;
  21774. height?: number;
  21775. depth?: number;
  21776. faceUV?: Vector4[];
  21777. faceColors?: Color4[];
  21778. sideOrientation?: number;
  21779. frontUVs?: Vector4;
  21780. backUVs?: Vector4;
  21781. updatable?: boolean;
  21782. }, scene?: Nullable<Scene>): Mesh;
  21783. /**
  21784. * Creates a sphere mesh
  21785. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  21786. * * 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`)
  21787. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  21788. * * 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
  21789. * * 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)
  21790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21793. * @param name defines the name of the mesh
  21794. * @param options defines the options used to create the mesh
  21795. * @param scene defines the hosting scene
  21796. * @returns the sphere mesh
  21797. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21798. */
  21799. static CreateSphere(name: string, options: {
  21800. segments?: number;
  21801. diameter?: number;
  21802. diameterX?: number;
  21803. diameterY?: number;
  21804. diameterZ?: number;
  21805. arc?: number;
  21806. slice?: number;
  21807. sideOrientation?: number;
  21808. frontUVs?: Vector4;
  21809. backUVs?: Vector4;
  21810. updatable?: boolean;
  21811. }, scene: any): Mesh;
  21812. /**
  21813. * Creates a plane polygonal mesh. By default, this is a disc
  21814. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21815. * * 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
  21816. * * 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
  21817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21820. * @param name defines the name of the mesh
  21821. * @param options defines the options used to create the mesh
  21822. * @param scene defines the hosting scene
  21823. * @returns the plane polygonal mesh
  21824. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21825. */
  21826. static CreateDisc(name: string, options: {
  21827. radius?: number;
  21828. tessellation?: number;
  21829. arc?: number;
  21830. updatable?: boolean;
  21831. sideOrientation?: number;
  21832. frontUVs?: Vector4;
  21833. backUVs?: Vector4;
  21834. }, scene?: Nullable<Scene>): Mesh;
  21835. /**
  21836. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21837. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21838. * * 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`)
  21839. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21840. * * 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
  21841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21844. * @param name defines the name of the mesh
  21845. * @param options defines the options used to create the mesh
  21846. * @param scene defines the hosting scene
  21847. * @returns the icosahedron mesh
  21848. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21849. */
  21850. static CreateIcoSphere(name: string, options: {
  21851. radius?: number;
  21852. radiusX?: number;
  21853. radiusY?: number;
  21854. radiusZ?: number;
  21855. flat?: boolean;
  21856. subdivisions?: number;
  21857. sideOrientation?: number;
  21858. frontUVs?: Vector4;
  21859. backUVs?: Vector4;
  21860. updatable?: boolean;
  21861. }, scene: Scene): Mesh;
  21862. /**
  21863. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21864. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  21865. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  21866. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  21867. * * 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
  21868. * * 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
  21869. * * 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
  21870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21873. * * 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
  21874. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  21875. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  21876. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  21877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21878. * @param name defines the name of the mesh
  21879. * @param options defines the options used to create the mesh
  21880. * @param scene defines the hosting scene
  21881. * @returns the ribbon mesh
  21882. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21883. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21884. */
  21885. static CreateRibbon(name: string, options: {
  21886. pathArray: Vector3[][];
  21887. closeArray?: boolean;
  21888. closePath?: boolean;
  21889. offset?: number;
  21890. updatable?: boolean;
  21891. sideOrientation?: number;
  21892. frontUVs?: Vector4;
  21893. backUVs?: Vector4;
  21894. instance?: Mesh;
  21895. invertUV?: boolean;
  21896. uvs?: Vector2[];
  21897. colors?: Color4[];
  21898. }, scene?: Nullable<Scene>): Mesh;
  21899. /**
  21900. * Creates a cylinder or a cone mesh
  21901. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21902. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21903. * * 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.
  21904. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21905. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21906. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21907. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21908. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21909. * * 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).
  21910. * * 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
  21911. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21912. * * 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
  21913. * * 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.
  21914. * * If `enclose` is false, a ring surface is one element.
  21915. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21916. * * 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
  21917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21920. * @param name defines the name of the mesh
  21921. * @param options defines the options used to create the mesh
  21922. * @param scene defines the hosting scene
  21923. * @returns the cylinder mesh
  21924. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21925. */
  21926. static CreateCylinder(name: string, options: {
  21927. height?: number;
  21928. diameterTop?: number;
  21929. diameterBottom?: number;
  21930. diameter?: number;
  21931. tessellation?: number;
  21932. subdivisions?: number;
  21933. arc?: number;
  21934. faceColors?: Color4[];
  21935. faceUV?: Vector4[];
  21936. updatable?: boolean;
  21937. hasRings?: boolean;
  21938. enclose?: boolean;
  21939. sideOrientation?: number;
  21940. frontUVs?: Vector4;
  21941. backUVs?: Vector4;
  21942. }, scene: any): Mesh;
  21943. /**
  21944. * Creates a torus mesh
  21945. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  21946. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  21947. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  21948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21951. * @param name defines the name of the mesh
  21952. * @param options defines the options used to create the mesh
  21953. * @param scene defines the hosting scene
  21954. * @returns the torus mesh
  21955. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21956. */
  21957. static CreateTorus(name: string, options: {
  21958. diameter?: number;
  21959. thickness?: number;
  21960. tessellation?: number;
  21961. updatable?: boolean;
  21962. sideOrientation?: number;
  21963. frontUVs?: Vector4;
  21964. backUVs?: Vector4;
  21965. }, scene: any): Mesh;
  21966. /**
  21967. * Creates a torus knot mesh
  21968. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  21969. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  21970. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  21971. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  21972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21975. * @param name defines the name of the mesh
  21976. * @param options defines the options used to create the mesh
  21977. * @param scene defines the hosting scene
  21978. * @returns the torus knot mesh
  21979. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21980. */
  21981. static CreateTorusKnot(name: string, options: {
  21982. radius?: number;
  21983. tube?: number;
  21984. radialSegments?: number;
  21985. tubularSegments?: number;
  21986. p?: number;
  21987. q?: number;
  21988. updatable?: boolean;
  21989. sideOrientation?: number;
  21990. frontUVs?: Vector4;
  21991. backUVs?: Vector4;
  21992. }, scene: any): Mesh;
  21993. /**
  21994. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  21995. * * 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
  21996. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  21997. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  21998. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  21999. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22000. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22001. * * 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
  22002. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22004. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22005. * @param name defines the name of the new line system
  22006. * @param options defines the options used to create the line system
  22007. * @param scene defines the hosting scene
  22008. * @returns a new line system mesh
  22009. */
  22010. static CreateLineSystem(name: string, options: {
  22011. lines: Vector3[][];
  22012. updatable?: boolean;
  22013. instance?: Nullable<LinesMesh>;
  22014. colors?: Nullable<Color4[][]>;
  22015. useVertexAlpha?: boolean;
  22016. }, scene: Nullable<Scene>): LinesMesh;
  22017. /**
  22018. * Creates a line mesh
  22019. * 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
  22020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22021. * * The parameter `points` is an array successive Vector3
  22022. * * 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
  22023. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22025. * * When updating an instance, remember that only point positions can change, not the number of points
  22026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22027. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22028. * @param name defines the name of the new line system
  22029. * @param options defines the options used to create the line system
  22030. * @param scene defines the hosting scene
  22031. * @returns a new line mesh
  22032. */
  22033. static CreateLines(name: string, options: {
  22034. points: Vector3[];
  22035. updatable?: boolean;
  22036. instance?: Nullable<LinesMesh>;
  22037. colors?: Color4[];
  22038. useVertexAlpha?: boolean;
  22039. }, scene?: Nullable<Scene>): LinesMesh;
  22040. /**
  22041. * Creates a dashed line mesh
  22042. * * 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
  22043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22044. * * The parameter `points` is an array successive Vector3
  22045. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22046. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22047. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22048. * * 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
  22049. * * When updating an instance, remember that only point positions can change, not the number of points
  22050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22051. * @param name defines the name of the mesh
  22052. * @param options defines the options used to create the mesh
  22053. * @param scene defines the hosting scene
  22054. * @returns the dashed line mesh
  22055. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22056. */
  22057. static CreateDashedLines(name: string, options: {
  22058. points: Vector3[];
  22059. dashSize?: number;
  22060. gapSize?: number;
  22061. dashNb?: number;
  22062. updatable?: boolean;
  22063. instance?: LinesMesh;
  22064. }, scene?: Nullable<Scene>): LinesMesh;
  22065. /**
  22066. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22067. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  22068. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22069. * * 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.
  22070. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22071. * * 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
  22072. * * 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
  22073. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22078. * @param name defines the name of the mesh
  22079. * @param options defines the options used to create the mesh
  22080. * @param scene defines the hosting scene
  22081. * @returns the extruded shape mesh
  22082. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22083. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22084. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22085. */
  22086. static ExtrudeShape(name: string, options: {
  22087. shape: Vector3[];
  22088. path: Vector3[];
  22089. scale?: number;
  22090. rotation?: number;
  22091. cap?: number;
  22092. updatable?: boolean;
  22093. sideOrientation?: number;
  22094. frontUVs?: Vector4;
  22095. backUVs?: Vector4;
  22096. instance?: Mesh;
  22097. invertUV?: boolean;
  22098. }, scene?: Nullable<Scene>): Mesh;
  22099. /**
  22100. * Creates an custom extruded shape mesh.
  22101. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22102. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  22103. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22104. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  22105. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22106. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  22107. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22108. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22109. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22110. * * 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
  22111. * * 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
  22112. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22115. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22117. * @param name defines the name of the mesh
  22118. * @param options defines the options used to create the mesh
  22119. * @param scene defines the hosting scene
  22120. * @returns the custom extruded shape mesh
  22121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22122. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22123. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22124. */
  22125. static ExtrudeShapeCustom(name: string, options: {
  22126. shape: Vector3[];
  22127. path: Vector3[];
  22128. scaleFunction?: any;
  22129. rotationFunction?: any;
  22130. ribbonCloseArray?: boolean;
  22131. ribbonClosePath?: boolean;
  22132. cap?: number;
  22133. updatable?: boolean;
  22134. sideOrientation?: number;
  22135. frontUVs?: Vector4;
  22136. backUVs?: Vector4;
  22137. instance?: Mesh;
  22138. invertUV?: boolean;
  22139. }, scene: Scene): Mesh;
  22140. /**
  22141. * Creates lathe mesh.
  22142. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22143. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  22144. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22145. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22146. * * 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
  22147. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22148. * * 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
  22149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22153. * @param name defines the name of the mesh
  22154. * @param options defines the options used to create the mesh
  22155. * @param scene defines the hosting scene
  22156. * @returns the lathe mesh
  22157. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22158. */
  22159. static CreateLathe(name: string, options: {
  22160. shape: Vector3[];
  22161. radius?: number;
  22162. tessellation?: number;
  22163. arc?: number;
  22164. closed?: boolean;
  22165. updatable?: boolean;
  22166. sideOrientation?: number;
  22167. frontUVs?: Vector4;
  22168. backUVs?: Vector4;
  22169. cap?: number;
  22170. invertUV?: boolean;
  22171. }, scene: Scene): Mesh;
  22172. /**
  22173. * Creates a plane mesh
  22174. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22175. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22176. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22180. * @param name defines the name of the mesh
  22181. * @param options defines the options used to create the mesh
  22182. * @param scene defines the hosting scene
  22183. * @returns the plane mesh
  22184. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22185. */
  22186. static CreatePlane(name: string, options: {
  22187. size?: number;
  22188. width?: number;
  22189. height?: number;
  22190. sideOrientation?: number;
  22191. frontUVs?: Vector4;
  22192. backUVs?: Vector4;
  22193. updatable?: boolean;
  22194. sourcePlane?: Plane;
  22195. }, scene: Scene): Mesh;
  22196. /**
  22197. * Creates a ground mesh
  22198. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22199. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22201. * @param name defines the name of the mesh
  22202. * @param options defines the options used to create the mesh
  22203. * @param scene defines the hosting scene
  22204. * @returns the ground mesh
  22205. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22206. */
  22207. static CreateGround(name: string, options: {
  22208. width?: number;
  22209. height?: number;
  22210. subdivisions?: number;
  22211. subdivisionsX?: number;
  22212. subdivisionsY?: number;
  22213. updatable?: boolean;
  22214. }, scene: any): Mesh;
  22215. /**
  22216. * Creates a tiled ground mesh
  22217. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22218. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22219. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  22220. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  22221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22222. * @param name defines the name of the mesh
  22223. * @param options defines the options used to create the mesh
  22224. * @param scene defines the hosting scene
  22225. * @returns the tiled ground mesh
  22226. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22227. */
  22228. static CreateTiledGround(name: string, options: {
  22229. xmin: number;
  22230. zmin: number;
  22231. xmax: number;
  22232. zmax: number;
  22233. subdivisions?: {
  22234. w: number;
  22235. h: number;
  22236. };
  22237. precision?: {
  22238. w: number;
  22239. h: number;
  22240. };
  22241. updatable?: boolean;
  22242. }, scene: Scene): Mesh;
  22243. /**
  22244. * Creates a ground mesh from a height map
  22245. * * The parameter `url` sets the URL of the height map image resource.
  22246. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22247. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22248. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22249. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22250. * * 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.
  22251. * * 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).
  22252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22253. * @param name defines the name of the mesh
  22254. * @param url defines the url to the height map
  22255. * @param options defines the options used to create the mesh
  22256. * @param scene defines the hosting scene
  22257. * @returns the ground mesh
  22258. * @see http://doc.babylonjs.com/babylon101/height_map
  22259. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22260. */
  22261. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22262. width?: number;
  22263. height?: number;
  22264. subdivisions?: number;
  22265. minHeight?: number;
  22266. maxHeight?: number;
  22267. colorFilter?: Color3;
  22268. updatable?: boolean;
  22269. onReady?: (mesh: GroundMesh) => void;
  22270. }, scene: Scene): GroundMesh;
  22271. /**
  22272. * Creates a polygon mesh
  22273. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22274. * * 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
  22275. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22277. * * 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)
  22278. * * Remember you can only change the shape positions, not their number when updating a polygon
  22279. * @param name defines the name of the mesh
  22280. * @param options defines the options used to create the mesh
  22281. * @param scene defines the hosting scene
  22282. * @returns the polygon mesh
  22283. */
  22284. static CreatePolygon(name: string, options: {
  22285. shape: Vector3[];
  22286. holes?: Vector3[][];
  22287. depth?: number;
  22288. faceUV?: Vector4[];
  22289. faceColors?: Color4[];
  22290. updatable?: boolean;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. }, scene: Scene): Mesh;
  22295. /**
  22296. * Creates an extruded polygon mesh, with depth in the Y direction.
  22297. * * 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)
  22298. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22299. * @param name defines the name of the mesh
  22300. * @param options defines the options used to create the mesh
  22301. * @param scene defines the hosting scene
  22302. * @returns the polygon mesh
  22303. */
  22304. static ExtrudePolygon(name: string, options: {
  22305. shape: Vector3[];
  22306. holes?: Vector3[][];
  22307. depth?: number;
  22308. faceUV?: Vector4[];
  22309. faceColors?: Color4[];
  22310. updatable?: boolean;
  22311. sideOrientation?: number;
  22312. frontUVs?: Vector4;
  22313. backUVs?: Vector4;
  22314. }, scene: Scene): Mesh;
  22315. /**
  22316. * Creates a tube mesh.
  22317. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22318. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22319. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22320. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22321. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22322. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  22323. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22324. * * 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
  22325. * * 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
  22326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22328. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22330. * @param name defines the name of the mesh
  22331. * @param options defines the options used to create the mesh
  22332. * @param scene defines the hosting scene
  22333. * @returns the tube mesh
  22334. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22335. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22336. */
  22337. static CreateTube(name: string, options: {
  22338. path: Vector3[];
  22339. radius?: number;
  22340. tessellation?: number;
  22341. radiusFunction?: {
  22342. (i: number, distance: number): number;
  22343. };
  22344. cap?: number;
  22345. arc?: number;
  22346. updatable?: boolean;
  22347. sideOrientation?: number;
  22348. frontUVs?: Vector4;
  22349. backUVs?: Vector4;
  22350. instance?: Mesh;
  22351. invertUV?: boolean;
  22352. }, scene: Scene): Mesh;
  22353. /**
  22354. * Creates a polyhedron mesh
  22355. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  22356. * * The parameter `size` (positive float, default 1) sets the polygon size
  22357. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22358. * * 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`
  22359. * * 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
  22360. * * 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)`)
  22361. * * 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
  22362. * * 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
  22363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22366. * @param name defines the name of the mesh
  22367. * @param options defines the options used to create the mesh
  22368. * @param scene defines the hosting scene
  22369. * @returns the polyhedron mesh
  22370. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22371. */
  22372. static CreatePolyhedron(name: string, options: {
  22373. type?: number;
  22374. size?: number;
  22375. sizeX?: number;
  22376. sizeY?: number;
  22377. sizeZ?: number;
  22378. custom?: any;
  22379. faceUV?: Vector4[];
  22380. faceColors?: Color4[];
  22381. flat?: boolean;
  22382. updatable?: boolean;
  22383. sideOrientation?: number;
  22384. frontUVs?: Vector4;
  22385. backUVs?: Vector4;
  22386. }, scene: Scene): Mesh;
  22387. /**
  22388. * Creates a decal mesh.
  22389. * 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
  22390. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22391. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22392. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22393. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22394. * @param name defines the name of the mesh
  22395. * @param sourceMesh defines the mesh where the decal must be applied
  22396. * @param options defines the options used to create the mesh
  22397. * @param scene defines the hosting scene
  22398. * @returns the decal mesh
  22399. * @see http://doc.babylonjs.com/how_to/decals
  22400. */
  22401. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22402. position?: Vector3;
  22403. normal?: Vector3;
  22404. size?: Vector3;
  22405. angle?: number;
  22406. }): Mesh;
  22407. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22408. }
  22409. }
  22410. declare module BABYLON {
  22411. class MeshLODLevel {
  22412. distance: number;
  22413. mesh: Mesh;
  22414. constructor(distance: number, mesh: Mesh);
  22415. }
  22416. }
  22417. declare module BABYLON {
  22418. /**
  22419. * A simplifier interface for future simplification implementations.
  22420. */
  22421. interface ISimplifier {
  22422. /**
  22423. * Simplification of a given mesh according to the given settings.
  22424. * Since this requires computation, it is assumed that the function runs async.
  22425. * @param settings The settings of the simplification, including quality and distance
  22426. * @param successCallback A callback that will be called after the mesh was simplified.
  22427. * @param errorCallback in case of an error, this callback will be called. optional.
  22428. */
  22429. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22430. }
  22431. /**
  22432. * Expected simplification settings.
  22433. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22434. */
  22435. interface ISimplificationSettings {
  22436. quality: number;
  22437. distance: number;
  22438. optimizeMesh?: boolean;
  22439. }
  22440. class SimplificationSettings implements ISimplificationSettings {
  22441. quality: number;
  22442. distance: number;
  22443. optimizeMesh: boolean | undefined;
  22444. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22445. }
  22446. interface ISimplificationTask {
  22447. settings: Array<ISimplificationSettings>;
  22448. simplificationType: SimplificationType;
  22449. mesh: Mesh;
  22450. successCallback?: () => void;
  22451. parallelProcessing: boolean;
  22452. }
  22453. class SimplificationQueue {
  22454. private _simplificationArray;
  22455. running: boolean;
  22456. constructor();
  22457. addTask(task: ISimplificationTask): void;
  22458. executeNext(): void;
  22459. runSimplification(task: ISimplificationTask): void;
  22460. private getSimplifier(task);
  22461. }
  22462. /**
  22463. * The implemented types of simplification
  22464. * At the moment only Quadratic Error Decimation is implemented
  22465. */
  22466. enum SimplificationType {
  22467. /** Quadratic error decimation */
  22468. QUADRATIC = 0,
  22469. }
  22470. class DecimationTriangle {
  22471. vertices: Array<DecimationVertex>;
  22472. normal: Vector3;
  22473. error: Array<number>;
  22474. deleted: boolean;
  22475. isDirty: boolean;
  22476. borderFactor: number;
  22477. deletePending: boolean;
  22478. originalOffset: number;
  22479. constructor(vertices: Array<DecimationVertex>);
  22480. }
  22481. class DecimationVertex {
  22482. position: Vector3;
  22483. id: number;
  22484. q: QuadraticMatrix;
  22485. isBorder: boolean;
  22486. triangleStart: number;
  22487. triangleCount: number;
  22488. originalOffsets: Array<number>;
  22489. constructor(position: Vector3, id: number);
  22490. updatePosition(newPosition: Vector3): void;
  22491. }
  22492. class QuadraticMatrix {
  22493. data: Array<number>;
  22494. constructor(data?: Array<number>);
  22495. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22496. addInPlace(matrix: QuadraticMatrix): void;
  22497. addArrayInPlace(data: Array<number>): void;
  22498. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22499. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22500. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22501. }
  22502. class Reference {
  22503. vertexId: number;
  22504. triangleId: number;
  22505. constructor(vertexId: number, triangleId: number);
  22506. }
  22507. /**
  22508. * An implementation of the Quadratic Error simplification algorithm.
  22509. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22510. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22511. * @author RaananW
  22512. */
  22513. class QuadraticErrorSimplification implements ISimplifier {
  22514. private _mesh;
  22515. private triangles;
  22516. private vertices;
  22517. private references;
  22518. private _reconstructedMesh;
  22519. syncIterations: number;
  22520. aggressiveness: number;
  22521. decimationIterations: number;
  22522. boundingBoxEpsilon: number;
  22523. constructor(_mesh: Mesh);
  22524. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22525. private runDecimation(settings, submeshIndex, successCallback);
  22526. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22527. private init(callback);
  22528. private reconstructMesh(submeshIndex);
  22529. private initDecimatedMesh();
  22530. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22531. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22532. private identifyBorder();
  22533. private updateMesh(identifyBorders?);
  22534. private vertexError(q, point);
  22535. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22536. }
  22537. }
  22538. declare module BABYLON {
  22539. class Polygon {
  22540. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22541. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22542. static Parse(input: string): Vector2[];
  22543. static StartingAt(x: number, y: number): Path2;
  22544. }
  22545. class PolygonMeshBuilder {
  22546. private _points;
  22547. private _outlinepoints;
  22548. private _holes;
  22549. private _name;
  22550. private _scene;
  22551. private _epoints;
  22552. private _eholes;
  22553. private _addToepoint(points);
  22554. constructor(name: string, contours: Path2, scene: Scene);
  22555. constructor(name: string, contours: Vector2[], scene: Scene);
  22556. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22557. build(updatable?: boolean, depth?: number): Mesh;
  22558. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22559. }
  22560. }
  22561. declare module BABYLON {
  22562. class BaseSubMesh {
  22563. _materialDefines: Nullable<MaterialDefines>;
  22564. _materialEffect: Nullable<Effect>;
  22565. readonly effect: Nullable<Effect>;
  22566. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22567. }
  22568. class SubMesh extends BaseSubMesh implements ICullable {
  22569. materialIndex: number;
  22570. verticesStart: number;
  22571. verticesCount: number;
  22572. indexStart: number;
  22573. indexCount: number;
  22574. linesIndexCount: number;
  22575. private _mesh;
  22576. private _renderingMesh;
  22577. private _boundingInfo;
  22578. private _linesIndexBuffer;
  22579. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22580. _trianglePlanes: Plane[];
  22581. _lastColliderTransformMatrix: Matrix;
  22582. _renderId: number;
  22583. _alphaIndex: number;
  22584. _distanceToCamera: number;
  22585. _id: number;
  22586. private _currentMaterial;
  22587. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22588. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22589. readonly IsGlobal: boolean;
  22590. /**
  22591. * Returns the submesh BoudingInfo object.
  22592. */
  22593. getBoundingInfo(): BoundingInfo;
  22594. /**
  22595. * Sets the submesh BoundingInfo.
  22596. * Return the SubMesh.
  22597. */
  22598. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22599. /**
  22600. * Returns the mesh of the current submesh.
  22601. */
  22602. getMesh(): AbstractMesh;
  22603. /**
  22604. * Returns the rendering mesh of the submesh.
  22605. */
  22606. getRenderingMesh(): Mesh;
  22607. /**
  22608. * Returns the submesh material.
  22609. */
  22610. getMaterial(): Nullable<Material>;
  22611. /**
  22612. * Sets a new updated BoundingInfo object to the submesh.
  22613. * Returns the SubMesh.
  22614. */
  22615. refreshBoundingInfo(): SubMesh;
  22616. _checkCollision(collider: Collider): boolean;
  22617. /**
  22618. * Updates the submesh BoundingInfo.
  22619. * Returns the Submesh.
  22620. */
  22621. updateBoundingInfo(world: Matrix): SubMesh;
  22622. /**
  22623. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22624. * Boolean returned.
  22625. */
  22626. isInFrustum(frustumPlanes: Plane[]): boolean;
  22627. /**
  22628. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22629. * Boolean returned.
  22630. */
  22631. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22632. /**
  22633. * Renders the submesh.
  22634. * Returns it.
  22635. */
  22636. render(enableAlphaMode: boolean): SubMesh;
  22637. /**
  22638. * Returns a new Index Buffer.
  22639. * Type returned : WebGLBuffer.
  22640. */
  22641. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22642. /**
  22643. * True is the passed Ray intersects the submesh bounding box.
  22644. * Boolean returned.
  22645. */
  22646. canIntersects(ray: Ray): boolean;
  22647. /**
  22648. * Returns an object IntersectionInfo.
  22649. */
  22650. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22651. _rebuild(): void;
  22652. /**
  22653. * Creates a new Submesh from the passed Mesh.
  22654. */
  22655. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22656. /**
  22657. * Disposes the Submesh.
  22658. * Returns nothing.
  22659. */
  22660. dispose(): void;
  22661. /**
  22662. * Creates a new Submesh from the passed parameters :
  22663. * - materialIndex (integer) : the index of the main mesh material.
  22664. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22665. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22666. * - mesh (Mesh) : the main mesh to create the submesh from.
  22667. * - renderingMesh (optional Mesh) : rendering mesh.
  22668. */
  22669. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22670. }
  22671. }
  22672. declare module BABYLON {
  22673. class TransformNode extends Node {
  22674. static BILLBOARDMODE_NONE: number;
  22675. static BILLBOARDMODE_X: number;
  22676. static BILLBOARDMODE_Y: number;
  22677. static BILLBOARDMODE_Z: number;
  22678. static BILLBOARDMODE_ALL: number;
  22679. private _forward;
  22680. private _forwardInverted;
  22681. private _up;
  22682. private _right;
  22683. private _rightInverted;
  22684. private _rotation;
  22685. private _rotationQuaternion;
  22686. protected _scaling: Vector3;
  22687. protected _isDirty: boolean;
  22688. private _transformToBoneReferal;
  22689. billboardMode: number;
  22690. scalingDeterminant: number;
  22691. infiniteDistance: boolean;
  22692. /**
  22693. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  22694. * By default the system will update normals to compensate
  22695. */
  22696. ignoreNonUniformScaling: boolean;
  22697. position: Vector3;
  22698. _poseMatrix: Matrix;
  22699. private _localWorld;
  22700. _worldMatrix: Matrix;
  22701. _worldMatrixDeterminant: number;
  22702. private _absolutePosition;
  22703. private _pivotMatrix;
  22704. private _pivotMatrixInverse;
  22705. private _postMultiplyPivotMatrix;
  22706. protected _isWorldMatrixFrozen: boolean;
  22707. /**
  22708. * An event triggered after the world matrix is updated
  22709. */
  22710. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22711. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22712. /**
  22713. * Gets a string idenfifying the name of the class
  22714. * @returns "TransformNode" string
  22715. */
  22716. getClassName(): string;
  22717. /**
  22718. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22719. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22720. * Default : (0.0, 0.0, 0.0)
  22721. */
  22722. rotation: Vector3;
  22723. /**
  22724. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22725. * Default : (1.0, 1.0, 1.0)
  22726. */
  22727. /**
  22728. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22729. * Default : (1.0, 1.0, 1.0)
  22730. */
  22731. scaling: Vector3;
  22732. /**
  22733. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22734. * It's null by default.
  22735. * 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)
  22736. */
  22737. rotationQuaternion: Nullable<Quaternion>;
  22738. /**
  22739. * The forward direction of that transform in world space.
  22740. */
  22741. readonly forward: Vector3;
  22742. /**
  22743. * The up direction of that transform in world space.
  22744. */
  22745. readonly up: Vector3;
  22746. /**
  22747. * The right direction of that transform in world space.
  22748. */
  22749. readonly right: Vector3;
  22750. /**
  22751. * Returns the latest update of the World matrix
  22752. * Returns a Matrix.
  22753. */
  22754. getWorldMatrix(): Matrix;
  22755. /** @hidden */
  22756. _getWorldMatrixDeterminant(): number;
  22757. /**
  22758. * Returns directly the latest state of the mesh World matrix.
  22759. * A Matrix is returned.
  22760. */
  22761. readonly worldMatrixFromCache: Matrix;
  22762. /**
  22763. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22764. * Returns the TransformNode.
  22765. */
  22766. updatePoseMatrix(matrix: Matrix): TransformNode;
  22767. /**
  22768. * Returns the mesh Pose matrix.
  22769. * Returned object : Matrix
  22770. */
  22771. getPoseMatrix(): Matrix;
  22772. _isSynchronized(): boolean;
  22773. _initCache(): void;
  22774. markAsDirty(property: string): TransformNode;
  22775. /**
  22776. * Returns the current mesh absolute position.
  22777. * Retuns a Vector3.
  22778. */
  22779. readonly absolutePosition: Vector3;
  22780. /**
  22781. * Sets a new matrix to apply before all other transformation
  22782. * @param matrix defines the transform matrix
  22783. * @returns the current TransformNode
  22784. */
  22785. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22786. /**
  22787. * Sets a new pivot matrix to the current node
  22788. * @param matrix defines the new pivot matrix to use
  22789. * @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
  22790. * @returns the current TransformNode
  22791. */
  22792. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22793. /**
  22794. * Returns the mesh pivot matrix.
  22795. * Default : Identity.
  22796. * A Matrix is returned.
  22797. */
  22798. getPivotMatrix(): Matrix;
  22799. /**
  22800. * Prevents the World matrix to be computed any longer.
  22801. * Returns the TransformNode.
  22802. */
  22803. freezeWorldMatrix(): TransformNode;
  22804. /**
  22805. * Allows back the World matrix computation.
  22806. * Returns the TransformNode.
  22807. */
  22808. unfreezeWorldMatrix(): this;
  22809. /**
  22810. * True if the World matrix has been frozen.
  22811. * Returns a boolean.
  22812. */
  22813. readonly isWorldMatrixFrozen: boolean;
  22814. /**
  22815. * Retuns the mesh absolute position in the World.
  22816. * Returns a Vector3.
  22817. */
  22818. getAbsolutePosition(): Vector3;
  22819. /**
  22820. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22821. * Returns the TransformNode.
  22822. */
  22823. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22824. /**
  22825. * Sets the mesh position in its local space.
  22826. * Returns the TransformNode.
  22827. */
  22828. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22829. /**
  22830. * Returns the mesh position in the local space from the current World matrix values.
  22831. * Returns a new Vector3.
  22832. */
  22833. getPositionExpressedInLocalSpace(): Vector3;
  22834. /**
  22835. * Translates the mesh along the passed Vector3 in its local space.
  22836. * Returns the TransformNode.
  22837. */
  22838. locallyTranslate(vector3: Vector3): TransformNode;
  22839. private static _lookAtVectorCache;
  22840. /**
  22841. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22842. * @param targetPoint the position (must be in same space as current mesh) to look at
  22843. * @param yawCor optional yaw (y-axis) correction in radians
  22844. * @param pitchCor optional pitch (x-axis) correction in radians
  22845. * @param rollCor optional roll (z-axis) correction in radians
  22846. * @param space the choosen space of the target
  22847. * @returns the TransformNode.
  22848. */
  22849. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22850. /**
  22851. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22852. * This Vector3 is expressed in the World space.
  22853. */
  22854. getDirection(localAxis: Vector3): Vector3;
  22855. /**
  22856. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22857. * localAxis is expressed in the mesh local space.
  22858. * result is computed in the Wordl space from the mesh World matrix.
  22859. * Returns the TransformNode.
  22860. */
  22861. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22862. /**
  22863. * Sets a new pivot point to the current node
  22864. * @param point defines the new pivot point to use
  22865. * @param space defines if the point is in world or local space (local by default)
  22866. * @returns the current TransformNode
  22867. */
  22868. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22869. /**
  22870. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22871. */
  22872. getPivotPoint(): Vector3;
  22873. /**
  22874. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22875. * Returns the TransformNode.
  22876. */
  22877. getPivotPointToRef(result: Vector3): TransformNode;
  22878. /**
  22879. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22880. */
  22881. getAbsolutePivotPoint(): Vector3;
  22882. /**
  22883. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22884. * Returns the TransformNode.
  22885. */
  22886. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22887. /**
  22888. * Defines the passed node as the parent of the current node.
  22889. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22890. * Returns the TransformNode.
  22891. */
  22892. setParent(node: Nullable<Node>): TransformNode;
  22893. private _nonUniformScaling;
  22894. readonly nonUniformScaling: boolean;
  22895. _updateNonUniformScalingState(value: boolean): boolean;
  22896. /**
  22897. * Attach the current TransformNode to another TransformNode associated with a bone
  22898. * @param bone Bone affecting the TransformNode
  22899. * @param affectedTransformNode TransformNode associated with the bone
  22900. */
  22901. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22902. detachFromBone(): TransformNode;
  22903. private static _rotationAxisCache;
  22904. /**
  22905. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22906. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22907. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22908. * The passed axis is also normalized.
  22909. * Returns the TransformNode.
  22910. */
  22911. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22912. /**
  22913. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22914. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22915. * The passed axis is also normalized.
  22916. * Returns the TransformNode.
  22917. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22918. */
  22919. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22920. /**
  22921. * Translates the mesh along the axis vector for the passed distance in the given space.
  22922. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22923. * Returns the TransformNode.
  22924. */
  22925. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22926. /**
  22927. * Adds a rotation step to the mesh current rotation.
  22928. * x, y, z are Euler angles expressed in radians.
  22929. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22930. * This means this rotation is made in the mesh local space only.
  22931. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22932. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22933. * ```javascript
  22934. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22935. * ```
  22936. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22937. * 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.
  22938. * Returns the TransformNode.
  22939. */
  22940. addRotation(x: number, y: number, z: number): TransformNode;
  22941. /**
  22942. * Computes the mesh World matrix and returns it.
  22943. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22944. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22945. * If the parameter `force`is set to `true`, the actual computation is done.
  22946. * Returns the mesh World Matrix.
  22947. */
  22948. computeWorldMatrix(force?: boolean): Matrix;
  22949. protected _afterComputeWorldMatrix(): void;
  22950. /**
  22951. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22952. * @param func: callback function to add
  22953. *
  22954. * Returns the TransformNode.
  22955. */
  22956. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22957. /**
  22958. * Removes a registered callback function.
  22959. * Returns the TransformNode.
  22960. */
  22961. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22962. /**
  22963. * Clone the current transform node
  22964. * Returns the new transform node
  22965. * @param name Name of the new clone
  22966. * @param newParent New parent for the clone
  22967. * @param doNotCloneChildren Do not clone children hierarchy
  22968. */
  22969. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22970. serialize(currentSerializationObject?: any): any;
  22971. /**
  22972. * Returns a new TransformNode object parsed from the source provided.
  22973. * The parameter `parsedMesh` is the source.
  22974. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22975. */
  22976. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22977. /**
  22978. * Releases resources associated with this transform node.
  22979. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22980. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22981. */
  22982. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22983. }
  22984. }
  22985. declare module BABYLON {
  22986. class VertexBuffer {
  22987. /** @hidden */
  22988. _buffer: Buffer;
  22989. private _kind;
  22990. private _size;
  22991. private _ownsBuffer;
  22992. private _instanced;
  22993. private _instanceDivisor;
  22994. /**
  22995. * The byte type.
  22996. */
  22997. static readonly BYTE: number;
  22998. /**
  22999. * The unsigned byte type.
  23000. */
  23001. static readonly UNSIGNED_BYTE: number;
  23002. /**
  23003. * The short type.
  23004. */
  23005. static readonly SHORT: number;
  23006. /**
  23007. * The unsigned short type.
  23008. */
  23009. static readonly UNSIGNED_SHORT: number;
  23010. /**
  23011. * The integer type.
  23012. */
  23013. static readonly INT: number;
  23014. /**
  23015. * The unsigned integer type.
  23016. */
  23017. static readonly UNSIGNED_INT: number;
  23018. /**
  23019. * The float type.
  23020. */
  23021. static readonly FLOAT: number;
  23022. /**
  23023. * Gets or sets the instance divisor when in instanced mode
  23024. */
  23025. instanceDivisor: number;
  23026. /**
  23027. * Gets the byte stride.
  23028. */
  23029. readonly byteStride: number;
  23030. /**
  23031. * Gets the byte offset.
  23032. */
  23033. readonly byteOffset: number;
  23034. /**
  23035. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23036. */
  23037. readonly normalized: boolean;
  23038. /**
  23039. * Gets the data type of each component in the array.
  23040. */
  23041. readonly type: number;
  23042. /**
  23043. * Constructor
  23044. * @param engine the engine
  23045. * @param data the data to use for this vertex buffer
  23046. * @param kind the vertex buffer kind
  23047. * @param updatable whether the data is updatable
  23048. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23049. * @param stride the stride (optional)
  23050. * @param instanced whether the buffer is instanced (optional)
  23051. * @param offset the offset of the data (optional)
  23052. * @param size the number of components (optional)
  23053. * @param type the type of the component (optional)
  23054. * @param normalized whether the data contains normalized data (optional)
  23055. * @param useBytes set to true if stride and offset are in bytes (optional)
  23056. */
  23057. 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);
  23058. _rebuild(): void;
  23059. /**
  23060. * Returns the kind of the VertexBuffer (string).
  23061. */
  23062. getKind(): string;
  23063. /**
  23064. * Boolean : is the VertexBuffer updatable ?
  23065. */
  23066. isUpdatable(): boolean;
  23067. /**
  23068. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23069. */
  23070. getData(): Nullable<DataArray>;
  23071. /**
  23072. * Returns the WebGLBuffer associated to the VertexBuffer.
  23073. */
  23074. getBuffer(): Nullable<WebGLBuffer>;
  23075. /**
  23076. * Returns the stride as a multiple of the type byte length.
  23077. * DEPRECATED. Use byteStride instead.
  23078. */
  23079. getStrideSize(): number;
  23080. /**
  23081. * Returns the offset as a multiple of the type byte length.
  23082. * DEPRECATED. Use byteOffset instead.
  23083. */
  23084. getOffset(): number;
  23085. /**
  23086. * Returns the number of components per vertex attribute (integer).
  23087. */
  23088. getSize(): number;
  23089. /**
  23090. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23091. */
  23092. getIsInstanced(): boolean;
  23093. /**
  23094. * Returns the instancing divisor, zero for non-instanced (integer).
  23095. */
  23096. getInstanceDivisor(): number;
  23097. /**
  23098. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23099. * Returns the created WebGLBuffer.
  23100. */
  23101. create(data?: DataArray): void;
  23102. /**
  23103. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23104. * This function will create a new buffer if the current one is not updatable
  23105. * Returns the updated WebGLBuffer.
  23106. */
  23107. update(data: DataArray): void;
  23108. /**
  23109. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23110. * Returns the directly updated WebGLBuffer.
  23111. * @param data the new data
  23112. * @param offset the new offset
  23113. * @param useBytes set to true if the offset is in bytes
  23114. */
  23115. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23116. /**
  23117. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23118. */
  23119. dispose(): void;
  23120. /**
  23121. * Enumerates each value of this vertex buffer as numbers.
  23122. * @param count the number of values to enumerate
  23123. * @param callback the callback function called for each value
  23124. */
  23125. forEach(count: number, callback: (value: number, index: number) => void): void;
  23126. private static _PositionKind;
  23127. private static _NormalKind;
  23128. private static _TangentKind;
  23129. private static _UVKind;
  23130. private static _UV2Kind;
  23131. private static _UV3Kind;
  23132. private static _UV4Kind;
  23133. private static _UV5Kind;
  23134. private static _UV6Kind;
  23135. private static _ColorKind;
  23136. private static _MatricesIndicesKind;
  23137. private static _MatricesWeightsKind;
  23138. private static _MatricesIndicesExtraKind;
  23139. private static _MatricesWeightsExtraKind;
  23140. static readonly PositionKind: string;
  23141. static readonly NormalKind: string;
  23142. static readonly TangentKind: string;
  23143. static readonly UVKind: string;
  23144. static readonly UV2Kind: string;
  23145. static readonly UV3Kind: string;
  23146. static readonly UV4Kind: string;
  23147. static readonly UV5Kind: string;
  23148. static readonly UV6Kind: string;
  23149. static readonly ColorKind: string;
  23150. static readonly MatricesIndicesKind: string;
  23151. static readonly MatricesWeightsKind: string;
  23152. static readonly MatricesIndicesExtraKind: string;
  23153. static readonly MatricesWeightsExtraKind: string;
  23154. /**
  23155. * Deduces the stride given a kind.
  23156. * @param kind The kind string to deduce
  23157. * @returns The deduced stride
  23158. */
  23159. static DeduceStride(kind: string): number;
  23160. /**
  23161. * Gets the byte length of the given type.
  23162. * @param type the type
  23163. * @returns the number of bytes
  23164. */
  23165. static GetTypeByteLength(type: number): number;
  23166. /**
  23167. * Enumerates each value of the given parameters as numbers.
  23168. * @param data the data to enumerate
  23169. * @param byteOffset the byte offset of the data
  23170. * @param byteStride the byte stride of the data
  23171. * @param componentCount the number of components per element
  23172. * @param componentType the type of the component
  23173. * @param count the total number of components
  23174. * @param normalized whether the data is normalized
  23175. * @param callback the callback function called for each value
  23176. */
  23177. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23178. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23179. }
  23180. }
  23181. declare module BABYLON {
  23182. interface PhysicsImpostorJoint {
  23183. mainImpostor: PhysicsImpostor;
  23184. connectedImpostor: PhysicsImpostor;
  23185. joint: PhysicsJoint;
  23186. }
  23187. class PhysicsEngine {
  23188. private _physicsPlugin;
  23189. gravity: Vector3;
  23190. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  23191. setGravity(gravity: Vector3): void;
  23192. /**
  23193. * Set the time step of the physics engine.
  23194. * default is 1/60.
  23195. * To slow it down, enter 1/600 for example.
  23196. * To speed it up, 1/30
  23197. * @param {number} newTimeStep the new timestep to apply to this world.
  23198. */
  23199. setTimeStep(newTimeStep?: number): void;
  23200. /**
  23201. * Get the time step of the physics engine.
  23202. */
  23203. getTimeStep(): number;
  23204. dispose(): void;
  23205. getPhysicsPluginName(): string;
  23206. static Epsilon: number;
  23207. private _impostors;
  23208. private _joints;
  23209. /**
  23210. * Adding a new impostor for the impostor tracking.
  23211. * This will be done by the impostor itself.
  23212. * @param {PhysicsImpostor} impostor the impostor to add
  23213. */
  23214. addImpostor(impostor: PhysicsImpostor): void;
  23215. /**
  23216. * Remove an impostor from the engine.
  23217. * This impostor and its mesh will not longer be updated by the physics engine.
  23218. * @param {PhysicsImpostor} impostor the impostor to remove
  23219. */
  23220. removeImpostor(impostor: PhysicsImpostor): void;
  23221. /**
  23222. * Add a joint to the physics engine
  23223. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  23224. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  23225. * @param {PhysicsJoint} the joint that will connect both impostors.
  23226. */
  23227. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23228. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23229. /**
  23230. * Called by the scene. no need to call it.
  23231. */
  23232. _step(delta: number): void;
  23233. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23234. getImpostors(): Array<PhysicsImpostor>;
  23235. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23236. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23237. }
  23238. interface IPhysicsEnginePlugin {
  23239. world: any;
  23240. name: string;
  23241. setGravity(gravity: Vector3): void;
  23242. setTimeStep(timeStep: number): void;
  23243. getTimeStep(): number;
  23244. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23245. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23246. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23247. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23248. removePhysicsBody(impostor: PhysicsImpostor): void;
  23249. generateJoint(joint: PhysicsImpostorJoint): void;
  23250. removeJoint(joint: PhysicsImpostorJoint): void;
  23251. isSupported(): boolean;
  23252. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23253. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23254. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23255. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23256. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23257. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23258. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23259. getBodyMass(impostor: PhysicsImpostor): number;
  23260. getBodyFriction(impostor: PhysicsImpostor): number;
  23261. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23262. getBodyRestitution(impostor: PhysicsImpostor): number;
  23263. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23264. sleepBody(impostor: PhysicsImpostor): void;
  23265. wakeUpBody(impostor: PhysicsImpostor): void;
  23266. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23267. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23268. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23269. getRadius(impostor: PhysicsImpostor): number;
  23270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23271. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23272. dispose(): void;
  23273. }
  23274. }
  23275. declare module BABYLON {
  23276. class PhysicsHelper {
  23277. private _scene;
  23278. private _physicsEngine;
  23279. constructor(scene: Scene);
  23280. /**
  23281. * @param {Vector3} origin the origin of the explosion
  23282. * @param {number} radius the explosion radius
  23283. * @param {number} strength the explosion strength
  23284. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23285. */
  23286. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  23287. /**
  23288. * @param {Vector3} origin the origin of the explosion
  23289. * @param {number} radius the explosion radius
  23290. * @param {number} strength the explosion strength
  23291. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23292. */
  23293. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  23294. /**
  23295. * @param {Vector3} origin the origin of the explosion
  23296. * @param {number} radius the explosion radius
  23297. * @param {number} strength the explosion strength
  23298. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23299. */
  23300. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  23301. /**
  23302. * @param {Vector3} origin the origin of the updraft
  23303. * @param {number} radius the radius of the updraft
  23304. * @param {number} strength the strength of the updraft
  23305. * @param {number} height the height of the updraft
  23306. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  23307. */
  23308. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  23309. /**
  23310. * @param {Vector3} origin the of the vortex
  23311. * @param {number} radius the radius of the vortex
  23312. * @param {number} strength the strength of the vortex
  23313. * @param {number} height the height of the vortex
  23314. */
  23315. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  23316. }
  23317. /***** Radial explosion *****/
  23318. class PhysicsRadialExplosionEvent {
  23319. private _scene;
  23320. private _sphere;
  23321. private _sphereOptions;
  23322. private _rays;
  23323. private _dataFetched;
  23324. constructor(scene: Scene);
  23325. /**
  23326. * Returns the data related to the radial explosion event (sphere & rays).
  23327. * @returns {PhysicsRadialExplosionEventData}
  23328. */
  23329. getData(): PhysicsRadialExplosionEventData;
  23330. /**
  23331. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  23332. * @param impostor
  23333. * @param {Vector3} origin the origin of the explosion
  23334. * @param {number} radius the explosion radius
  23335. * @param {number} strength the explosion strength
  23336. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  23337. * @returns {Nullable<PhysicsForceAndContactPoint>}
  23338. */
  23339. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  23340. /**
  23341. * Disposes the sphere.
  23342. * @param {bolean} force
  23343. */
  23344. dispose(force?: boolean): void;
  23345. /*** Helpers ***/
  23346. private _prepareSphere();
  23347. private _intersectsWithSphere(impostor, origin, radius);
  23348. }
  23349. /***** Gravitational Field *****/
  23350. class PhysicsGravitationalFieldEvent {
  23351. private _physicsHelper;
  23352. private _scene;
  23353. private _origin;
  23354. private _radius;
  23355. private _strength;
  23356. private _falloff;
  23357. private _tickCallback;
  23358. private _sphere;
  23359. private _dataFetched;
  23360. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  23361. /**
  23362. * Returns the data related to the gravitational field event (sphere).
  23363. * @returns {PhysicsGravitationalFieldEventData}
  23364. */
  23365. getData(): PhysicsGravitationalFieldEventData;
  23366. /**
  23367. * Enables the gravitational field.
  23368. */
  23369. enable(): void;
  23370. /**
  23371. * Disables the gravitational field.
  23372. */
  23373. disable(): void;
  23374. /**
  23375. * Disposes the sphere.
  23376. * @param {bolean} force
  23377. */
  23378. dispose(force?: boolean): void;
  23379. private _tick();
  23380. }
  23381. /***** Updraft *****/
  23382. class PhysicsUpdraftEvent {
  23383. private _scene;
  23384. private _origin;
  23385. private _radius;
  23386. private _strength;
  23387. private _height;
  23388. private _updraftMode;
  23389. private _physicsEngine;
  23390. private _originTop;
  23391. private _originDirection;
  23392. private _tickCallback;
  23393. private _cylinder;
  23394. private _cylinderPosition;
  23395. private _dataFetched;
  23396. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  23397. /**
  23398. * Returns the data related to the updraft event (cylinder).
  23399. * @returns {PhysicsUpdraftEventData}
  23400. */
  23401. getData(): PhysicsUpdraftEventData;
  23402. /**
  23403. * Enables the updraft.
  23404. */
  23405. enable(): void;
  23406. /**
  23407. * Disables the cortex.
  23408. */
  23409. disable(): void;
  23410. /**
  23411. * Disposes the sphere.
  23412. * @param {bolean} force
  23413. */
  23414. dispose(force?: boolean): void;
  23415. private getImpostorForceAndContactPoint(impostor);
  23416. private _tick();
  23417. /*** Helpers ***/
  23418. private _prepareCylinder();
  23419. private _intersectsWithCylinder(impostor);
  23420. }
  23421. /***** Vortex *****/
  23422. class PhysicsVortexEvent {
  23423. private _scene;
  23424. private _origin;
  23425. private _radius;
  23426. private _strength;
  23427. private _height;
  23428. private _physicsEngine;
  23429. private _originTop;
  23430. private _centripetalForceThreshold;
  23431. private _updraftMultiplier;
  23432. private _tickCallback;
  23433. private _cylinder;
  23434. private _cylinderPosition;
  23435. private _dataFetched;
  23436. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  23437. /**
  23438. * Returns the data related to the vortex event (cylinder).
  23439. * @returns {PhysicsVortexEventData}
  23440. */
  23441. getData(): PhysicsVortexEventData;
  23442. /**
  23443. * Enables the vortex.
  23444. */
  23445. enable(): void;
  23446. /**
  23447. * Disables the cortex.
  23448. */
  23449. disable(): void;
  23450. /**
  23451. * Disposes the sphere.
  23452. * @param {bolean} force
  23453. */
  23454. dispose(force?: boolean): void;
  23455. private getImpostorForceAndContactPoint(impostor);
  23456. private _tick();
  23457. /*** Helpers ***/
  23458. private _prepareCylinder();
  23459. private _intersectsWithCylinder(impostor);
  23460. }
  23461. /***** Enums *****/
  23462. /**
  23463. * The strenght of the force in correspondence to the distance of the affected object
  23464. */
  23465. enum PhysicsRadialImpulseFalloff {
  23466. /** Defines that impulse is constant in strength across it's whole radius */
  23467. Constant = 0,
  23468. /** DEfines that impulse gets weaker if it's further from the origin */
  23469. Linear = 1,
  23470. }
  23471. /**
  23472. * The strenght of the force in correspondence to the distance of the affected object
  23473. */
  23474. enum PhysicsUpdraftMode {
  23475. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  23476. Center = 0,
  23477. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  23478. Perpendicular = 1,
  23479. }
  23480. /***** Data interfaces *****/
  23481. interface PhysicsForceAndContactPoint {
  23482. force: Vector3;
  23483. contactPoint: Vector3;
  23484. }
  23485. interface PhysicsRadialExplosionEventData {
  23486. sphere: Mesh;
  23487. rays: Array<Ray>;
  23488. }
  23489. interface PhysicsGravitationalFieldEventData {
  23490. sphere: Mesh;
  23491. }
  23492. interface PhysicsUpdraftEventData {
  23493. cylinder: Mesh;
  23494. }
  23495. interface PhysicsVortexEventData {
  23496. cylinder: Mesh;
  23497. }
  23498. }
  23499. declare module BABYLON {
  23500. interface PhysicsImpostorParameters {
  23501. mass: number;
  23502. friction?: number;
  23503. restitution?: number;
  23504. nativeOptions?: any;
  23505. ignoreParent?: boolean;
  23506. disableBidirectionalTransformation?: boolean;
  23507. }
  23508. interface IPhysicsEnabledObject {
  23509. position: Vector3;
  23510. rotationQuaternion: Nullable<Quaternion>;
  23511. scaling: Vector3;
  23512. rotation?: Vector3;
  23513. parent?: any;
  23514. getBoundingInfo(): BoundingInfo;
  23515. computeWorldMatrix(force: boolean): Matrix;
  23516. getWorldMatrix?(): Matrix;
  23517. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23518. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23519. getIndices?(): Nullable<IndicesArray>;
  23520. getScene?(): Scene;
  23521. getAbsolutePosition(): Vector3;
  23522. getAbsolutePivotPoint(): Vector3;
  23523. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23524. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23525. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23526. getClassName(): string;
  23527. }
  23528. class PhysicsImpostor {
  23529. object: IPhysicsEnabledObject;
  23530. type: number;
  23531. private _options;
  23532. private _scene;
  23533. static DEFAULT_OBJECT_SIZE: Vector3;
  23534. static IDENTITY_QUATERNION: Quaternion;
  23535. private _physicsEngine;
  23536. private _physicsBody;
  23537. private _bodyUpdateRequired;
  23538. private _onBeforePhysicsStepCallbacks;
  23539. private _onAfterPhysicsStepCallbacks;
  23540. private _onPhysicsCollideCallbacks;
  23541. private _deltaPosition;
  23542. private _deltaRotation;
  23543. private _deltaRotationConjugated;
  23544. private _parent;
  23545. private _isDisposed;
  23546. private static _tmpVecs;
  23547. private static _tmpQuat;
  23548. readonly isDisposed: boolean;
  23549. mass: number;
  23550. friction: number;
  23551. restitution: number;
  23552. uniqueId: number;
  23553. private _joints;
  23554. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23555. /**
  23556. * This function will completly initialize this impostor.
  23557. * It will create a new body - but only if this mesh has no parent.
  23558. * If it has, this impostor will not be used other than to define the impostor
  23559. * of the child mesh.
  23560. */
  23561. _init(): void;
  23562. private _getPhysicsParent();
  23563. /**
  23564. * Should a new body be generated.
  23565. */
  23566. isBodyInitRequired(): boolean;
  23567. setScalingUpdated(updated: boolean): void;
  23568. /**
  23569. * Force a regeneration of this or the parent's impostor's body.
  23570. * Use under cautious - This will remove all joints already implemented.
  23571. */
  23572. forceUpdate(): void;
  23573. /**
  23574. * Gets the body that holds this impostor. Either its own, or its parent.
  23575. */
  23576. /**
  23577. * Set the physics body. Used mainly by the physics engine/plugin
  23578. */
  23579. physicsBody: any;
  23580. parent: Nullable<PhysicsImpostor>;
  23581. resetUpdateFlags(): void;
  23582. getObjectExtendSize(): Vector3;
  23583. getObjectCenter(): Vector3;
  23584. /**
  23585. * Get a specific parametes from the options parameter.
  23586. */
  23587. getParam(paramName: string): any;
  23588. /**
  23589. * Sets a specific parameter in the options given to the physics plugin
  23590. */
  23591. setParam(paramName: string, value: number): void;
  23592. /**
  23593. * Specifically change the body's mass option. Won't recreate the physics body object
  23594. */
  23595. setMass(mass: number): void;
  23596. getLinearVelocity(): Nullable<Vector3>;
  23597. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23598. getAngularVelocity(): Nullable<Vector3>;
  23599. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23600. /**
  23601. * Execute a function with the physics plugin native code.
  23602. * Provide a function the will have two variables - the world object and the physics body object.
  23603. */
  23604. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23605. /**
  23606. * Register a function that will be executed before the physics world is stepping forward.
  23607. */
  23608. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23609. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23610. /**
  23611. * Register a function that will be executed after the physics step
  23612. */
  23613. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23614. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23615. /**
  23616. * register a function that will be executed when this impostor collides against a different body.
  23617. */
  23618. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23619. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23620. private _tmpQuat;
  23621. private _tmpQuat2;
  23622. getParentsRotation(): Quaternion;
  23623. /**
  23624. * this function is executed by the physics engine.
  23625. */
  23626. beforeStep: () => void;
  23627. /**
  23628. * this function is executed by the physics engine.
  23629. */
  23630. afterStep: () => void;
  23631. /**
  23632. * Legacy collision detection event support
  23633. */
  23634. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23635. onCollide: (e: {
  23636. body: any;
  23637. }) => void;
  23638. /**
  23639. * Apply a force
  23640. */
  23641. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23642. /**
  23643. * Apply an impulse
  23644. */
  23645. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23646. /**
  23647. * A help function to create a joint.
  23648. */
  23649. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23650. /**
  23651. * Add a joint to this impostor with a different impostor.
  23652. */
  23653. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23654. /**
  23655. * Will keep this body still, in a sleep mode.
  23656. */
  23657. sleep(): PhysicsImpostor;
  23658. /**
  23659. * Wake the body up.
  23660. */
  23661. wakeUp(): PhysicsImpostor;
  23662. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23663. dispose(): void;
  23664. setDeltaPosition(position: Vector3): void;
  23665. setDeltaRotation(rotation: Quaternion): void;
  23666. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23667. getRadius(): number;
  23668. /**
  23669. * Sync a bone with this impostor
  23670. * @param bone The bone to sync to the impostor.
  23671. * @param boneMesh The mesh that the bone is influencing.
  23672. * @param jointPivot The pivot of the joint / bone in local space.
  23673. * @param distToJoint Optional distance from the impostor to the joint.
  23674. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23675. */
  23676. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23677. /**
  23678. * Sync impostor to a bone
  23679. * @param bone The bone that the impostor will be synced to.
  23680. * @param boneMesh The mesh that the bone is influencing.
  23681. * @param jointPivot The pivot of the joint / bone in local space.
  23682. * @param distToJoint Optional distance from the impostor to the joint.
  23683. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23684. * @param boneAxis Optional vector3 axis the bone is aligned with
  23685. */
  23686. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23687. static NoImpostor: number;
  23688. static SphereImpostor: number;
  23689. static BoxImpostor: number;
  23690. static PlaneImpostor: number;
  23691. static MeshImpostor: number;
  23692. static CylinderImpostor: number;
  23693. static ParticleImpostor: number;
  23694. static HeightmapImpostor: number;
  23695. }
  23696. }
  23697. declare module BABYLON {
  23698. interface PhysicsJointData {
  23699. mainPivot?: Vector3;
  23700. connectedPivot?: Vector3;
  23701. mainAxis?: Vector3;
  23702. connectedAxis?: Vector3;
  23703. collision?: boolean;
  23704. nativeParams?: any;
  23705. }
  23706. /**
  23707. * This is a holder class for the physics joint created by the physics plugin.
  23708. * It holds a set of functions to control the underlying joint.
  23709. */
  23710. class PhysicsJoint {
  23711. type: number;
  23712. jointData: PhysicsJointData;
  23713. private _physicsJoint;
  23714. protected _physicsPlugin: IPhysicsEnginePlugin;
  23715. constructor(type: number, jointData: PhysicsJointData);
  23716. physicsJoint: any;
  23717. physicsPlugin: IPhysicsEnginePlugin;
  23718. /**
  23719. * Execute a function that is physics-plugin specific.
  23720. * @param {Function} func the function that will be executed.
  23721. * It accepts two parameters: the physics world and the physics joint.
  23722. */
  23723. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23724. static DistanceJoint: number;
  23725. static HingeJoint: number;
  23726. static BallAndSocketJoint: number;
  23727. static WheelJoint: number;
  23728. static SliderJoint: number;
  23729. static PrismaticJoint: number;
  23730. static UniversalJoint: number;
  23731. static Hinge2Joint: number;
  23732. static PointToPointJoint: number;
  23733. static SpringJoint: number;
  23734. static LockJoint: number;
  23735. }
  23736. /**
  23737. * A class representing a physics distance joint.
  23738. */
  23739. class DistanceJoint extends PhysicsJoint {
  23740. constructor(jointData: DistanceJointData);
  23741. /**
  23742. * Update the predefined distance.
  23743. */
  23744. updateDistance(maxDistance: number, minDistance?: number): void;
  23745. }
  23746. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23747. constructor(type: number, jointData: PhysicsJointData);
  23748. /**
  23749. * Set the motor values.
  23750. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23751. * @param {number} force the force to apply
  23752. * @param {number} maxForce max force for this motor.
  23753. */
  23754. setMotor(force?: number, maxForce?: number): void;
  23755. /**
  23756. * Set the motor's limits.
  23757. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23758. */
  23759. setLimit(upperLimit: number, lowerLimit?: number): void;
  23760. }
  23761. /**
  23762. * This class represents a single hinge physics joint
  23763. */
  23764. class HingeJoint extends MotorEnabledJoint {
  23765. constructor(jointData: PhysicsJointData);
  23766. /**
  23767. * Set the motor values.
  23768. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23769. * @param {number} force the force to apply
  23770. * @param {number} maxForce max force for this motor.
  23771. */
  23772. setMotor(force?: number, maxForce?: number): void;
  23773. /**
  23774. * Set the motor's limits.
  23775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23776. */
  23777. setLimit(upperLimit: number, lowerLimit?: number): void;
  23778. }
  23779. /**
  23780. * This class represents a dual hinge physics joint (same as wheel joint)
  23781. */
  23782. class Hinge2Joint extends MotorEnabledJoint {
  23783. constructor(jointData: PhysicsJointData);
  23784. /**
  23785. * Set the motor values.
  23786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23787. * @param {number} force the force to apply
  23788. * @param {number} maxForce max force for this motor.
  23789. * @param {motorIndex} the motor's index, 0 or 1.
  23790. */
  23791. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23792. /**
  23793. * Set the motor limits.
  23794. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23795. * @param {number} upperLimit the upper limit
  23796. * @param {number} lowerLimit lower limit
  23797. * @param {motorIndex} the motor's index, 0 or 1.
  23798. */
  23799. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23800. }
  23801. interface IMotorEnabledJoint {
  23802. physicsJoint: any;
  23803. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23804. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23805. }
  23806. interface DistanceJointData extends PhysicsJointData {
  23807. maxDistance: number;
  23808. }
  23809. interface SpringJointData extends PhysicsJointData {
  23810. length: number;
  23811. stiffness: number;
  23812. damping: number;
  23813. }
  23814. }
  23815. declare module BABYLON {
  23816. /**
  23817. * This represents a GPU particle system in Babylon
  23818. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23819. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23820. */
  23821. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23822. /**
  23823. * The id of the Particle system.
  23824. */
  23825. id: string;
  23826. /**
  23827. * The friendly name of the Particle system.
  23828. */
  23829. name: string;
  23830. /**
  23831. * The emitter represents the Mesh or position we are attaching the particle system to.
  23832. */
  23833. emitter: Nullable<AbstractMesh | Vector3>;
  23834. /**
  23835. * The rendering group used by the Particle system to chose when to render.
  23836. */
  23837. renderingGroupId: number;
  23838. /**
  23839. * The layer mask we are rendering the particles through.
  23840. */
  23841. layerMask: number;
  23842. private _capacity;
  23843. private _activeCount;
  23844. private _currentActiveCount;
  23845. private _renderEffect;
  23846. private _updateEffect;
  23847. private _buffer0;
  23848. private _buffer1;
  23849. private _spriteBuffer;
  23850. private _updateVAO;
  23851. private _renderVAO;
  23852. private _targetIndex;
  23853. private _sourceBuffer;
  23854. private _targetBuffer;
  23855. private _scene;
  23856. private _engine;
  23857. private _currentRenderId;
  23858. private _started;
  23859. private _stopped;
  23860. private _timeDelta;
  23861. private _randomTexture;
  23862. private readonly _attributesStrideSize;
  23863. private _updateEffectOptions;
  23864. private _randomTextureSize;
  23865. private _actualFrame;
  23866. /**
  23867. * List of animations used by the particle system.
  23868. */
  23869. animations: Animation[];
  23870. /**
  23871. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23872. */
  23873. static readonly IsSupported: boolean;
  23874. /**
  23875. * An event triggered when the system is disposed.
  23876. */
  23877. onDisposeObservable: Observable<GPUParticleSystem>;
  23878. /**
  23879. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23880. */
  23881. updateSpeed: number;
  23882. /**
  23883. * The amount of time the particle system is running (depends of the overall update speed).
  23884. */
  23885. targetStopDuration: number;
  23886. /**
  23887. * The texture used to render each particle. (this can be a spritesheet)
  23888. */
  23889. particleTexture: Nullable<Texture>;
  23890. /**
  23891. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23892. */
  23893. blendMode: number;
  23894. /**
  23895. * Minimum life time of emitting particles.
  23896. */
  23897. minLifeTime: number;
  23898. /**
  23899. * Maximum life time of emitting particles.
  23900. */
  23901. maxLifeTime: number;
  23902. /**
  23903. * Minimum Size of emitting particles.
  23904. */
  23905. minSize: number;
  23906. /**
  23907. * Maximum Size of emitting particles.
  23908. */
  23909. maxSize: number;
  23910. /**
  23911. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23912. */
  23913. color1: Color4;
  23914. /**
  23915. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23916. */
  23917. color2: Color4;
  23918. /**
  23919. * Color the particle will have at the end of its lifetime.
  23920. */
  23921. colorDead: Color4;
  23922. /**
  23923. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23924. */
  23925. emitRate: number;
  23926. /**
  23927. * You can use gravity if you want to give an orientation to your particles.
  23928. */
  23929. gravity: Vector3;
  23930. /**
  23931. * Minimum power of emitting particles.
  23932. */
  23933. minEmitPower: number;
  23934. /**
  23935. * Maximum power of emitting particles.
  23936. */
  23937. maxEmitPower: number;
  23938. /**
  23939. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23940. */
  23941. minAngularSpeed: number;
  23942. /**
  23943. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23944. */
  23945. maxAngularSpeed: number;
  23946. /**
  23947. * The particle emitter type defines the emitter used by the particle system.
  23948. * It can be for example box, sphere, or cone...
  23949. */
  23950. particleEmitterType: Nullable<IParticleEmitterType>;
  23951. /**
  23952. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23953. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23954. */
  23955. direction1: Vector3;
  23956. /**
  23957. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23958. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23959. */
  23960. direction2: Vector3;
  23961. /**
  23962. * 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.
  23963. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23964. */
  23965. minEmitBox: Vector3;
  23966. /**
  23967. * 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.
  23968. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23969. */
  23970. maxEmitBox: Vector3;
  23971. /**
  23972. * Gets the maximum number of particles active at the same time.
  23973. * @returns The max number of active particles.
  23974. */
  23975. getCapacity(): number;
  23976. /**
  23977. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23978. * to override the particles.
  23979. */
  23980. forceDepthWrite: boolean;
  23981. /**
  23982. * Gets or set the number of active particles
  23983. */
  23984. activeParticleCount: number;
  23985. /**
  23986. * Is this system ready to be used/rendered
  23987. * @return true if the system is ready
  23988. */
  23989. isReady(): boolean;
  23990. /**
  23991. * Gets Wether the system has been started.
  23992. * @returns True if it has been started, otherwise false.
  23993. */
  23994. isStarted(): boolean;
  23995. /**
  23996. * Starts the particle system and begins to emit.
  23997. */
  23998. start(): void;
  23999. /**
  24000. * Stops the particle system.
  24001. */
  24002. stop(): void;
  24003. /**
  24004. * Remove all active particles
  24005. */
  24006. reset(): void;
  24007. /**
  24008. * Returns the string "GPUParticleSystem"
  24009. * @returns a string containing the class name
  24010. */
  24011. getClassName(): string;
  24012. /**
  24013. * Instantiates a GPU particle system.
  24014. * 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.
  24015. * @param name The name of the particle system
  24016. * @param capacity The max number of particles alive at the same time
  24017. * @param scene The scene the particle system belongs to
  24018. */
  24019. constructor(name: string, options: Partial<{
  24020. capacity: number;
  24021. randomTextureSize: number;
  24022. }>, scene: Scene);
  24023. private _createUpdateVAO(source);
  24024. private _createRenderVAO(source, spriteSource);
  24025. private _initialize(force?);
  24026. /** @hidden */
  24027. _recreateUpdateEffect(): void;
  24028. /** @hidden */
  24029. _recreateRenderEffect(): void;
  24030. /**
  24031. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24032. */
  24033. animate(): void;
  24034. /**
  24035. * Renders the particle system in its current state.
  24036. * @returns the current number of particles
  24037. */
  24038. render(): number;
  24039. /**
  24040. * Rebuilds the particle system
  24041. */
  24042. rebuild(): void;
  24043. private _releaseBuffers();
  24044. private _releaseVAOs();
  24045. /**
  24046. * Disposes the particle system and free the associated resources
  24047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24048. */
  24049. dispose(disposeTexture?: boolean): void;
  24050. /**
  24051. * Clones the particle system.
  24052. * @param name The name of the cloned object
  24053. * @param newEmitter The new emitter to use
  24054. * @returns the cloned particle system
  24055. */
  24056. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  24057. /**
  24058. * Serializes the particle system to a JSON object.
  24059. * @returns the JSON object
  24060. */
  24061. serialize(): any;
  24062. /**
  24063. * Parses a JSON object to create a GPU particle system.
  24064. * @param parsedParticleSystem The JSON object to parse
  24065. * @param scene The scene to create the particle system in
  24066. * @param rootUrl The root url to use to load external dependencies like texture
  24067. * @returns the parsed GPU particle system
  24068. */
  24069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  24070. }
  24071. }
  24072. declare module BABYLON {
  24073. /**
  24074. * Interface representing a particle system in Babylon.
  24075. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  24076. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  24077. */
  24078. interface IParticleSystem {
  24079. /**
  24080. * The id of the Particle system.
  24081. */
  24082. id: string;
  24083. /**
  24084. * The name of the Particle system.
  24085. */
  24086. name: string;
  24087. /**
  24088. * The emitter represents the Mesh or position we are attaching the particle system to.
  24089. */
  24090. emitter: Nullable<AbstractMesh | Vector3>;
  24091. /**
  24092. * The rendering group used by the Particle system to chose when to render.
  24093. */
  24094. renderingGroupId: number;
  24095. /**
  24096. * The layer mask we are rendering the particles through.
  24097. */
  24098. layerMask: number;
  24099. /**
  24100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24101. */
  24102. updateSpeed: number;
  24103. /**
  24104. * The amount of time the particle system is running (depends of the overall update speed).
  24105. */
  24106. targetStopDuration: number;
  24107. /**
  24108. * The texture used to render each particle. (this can be a spritesheet)
  24109. */
  24110. particleTexture: Nullable<Texture>;
  24111. /**
  24112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24113. */
  24114. blendMode: number;
  24115. /**
  24116. * Minimum life time of emitting particles.
  24117. */
  24118. minLifeTime: number;
  24119. /**
  24120. * Maximum life time of emitting particles.
  24121. */
  24122. maxLifeTime: number;
  24123. /**
  24124. * Minimum Size of emitting particles.
  24125. */
  24126. minSize: number;
  24127. /**
  24128. * Maximum Size of emitting particles.
  24129. */
  24130. maxSize: number;
  24131. /**
  24132. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24133. */
  24134. color1: Color4;
  24135. /**
  24136. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24137. */
  24138. color2: Color4;
  24139. /**
  24140. * Color the particle will have at the end of its lifetime.
  24141. */
  24142. colorDead: Color4;
  24143. /**
  24144. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24145. */
  24146. emitRate: number;
  24147. /**
  24148. * You can use gravity if you want to give an orientation to your particles.
  24149. */
  24150. gravity: Vector3;
  24151. /**
  24152. * Minimum power of emitting particles.
  24153. */
  24154. minEmitPower: number;
  24155. /**
  24156. * Maximum power of emitting particles.
  24157. */
  24158. maxEmitPower: number;
  24159. /**
  24160. * The particle emitter type defines the emitter used by the particle system.
  24161. * It can be for example box, sphere, or cone...
  24162. */
  24163. particleEmitterType: Nullable<IParticleEmitterType>;
  24164. /**
  24165. * Gets the maximum number of particles active at the same time.
  24166. * @returns The max number of active particles.
  24167. */
  24168. getCapacity(): number;
  24169. /**
  24170. * Gets Wether the system has been started.
  24171. * @returns True if it has been started, otherwise false.
  24172. */
  24173. isStarted(): boolean;
  24174. /**
  24175. * Gets if the particle system has been started.
  24176. * @return true if the system has been started, otherwise false.
  24177. */
  24178. isStarted(): boolean;
  24179. /**
  24180. * Animates the particle system for this frame.
  24181. */
  24182. animate(): void;
  24183. /**
  24184. * Renders the particle system in its current state.
  24185. * @returns the current number of particles
  24186. */
  24187. render(): number;
  24188. /**
  24189. * Dispose the particle system and frees its associated resources.
  24190. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24191. */
  24192. dispose(disposeTexture?: boolean): void;
  24193. /**
  24194. * Clones the particle system.
  24195. * @param name The name of the cloned object
  24196. * @param newEmitter The new emitter to use
  24197. * @returns the cloned particle system
  24198. */
  24199. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  24200. /**
  24201. * Serializes the particle system to a JSON object.
  24202. * @returns the JSON object
  24203. */
  24204. serialize(): any;
  24205. /**
  24206. * Rebuild the particle system
  24207. */
  24208. rebuild(): void;
  24209. /**
  24210. * Starts the particle system and begins to emit.
  24211. */
  24212. start(): void;
  24213. /**
  24214. * Stops the particle system.
  24215. */
  24216. stop(): void;
  24217. /**
  24218. * Remove all active particles
  24219. */
  24220. reset(): void;
  24221. /**
  24222. * Is this system ready to be used/rendered
  24223. * @return true if the system is ready
  24224. */
  24225. isReady(): boolean;
  24226. }
  24227. }
  24228. declare module BABYLON {
  24229. /**
  24230. * A particle represents one of the element emitted by a particle system.
  24231. * This is mainly define by its coordinates, direction, velocity and age.
  24232. */
  24233. class Particle {
  24234. /**
  24235. * particleSystem the particle system the particle belongs to.
  24236. */
  24237. particleSystem: ParticleSystem;
  24238. /**
  24239. * The world position of the particle in the scene.
  24240. */
  24241. position: Vector3;
  24242. /**
  24243. * The world direction of the particle in the scene.
  24244. */
  24245. direction: Vector3;
  24246. /**
  24247. * The color of the particle.
  24248. */
  24249. color: Color4;
  24250. /**
  24251. * The color change of the particle per step.
  24252. */
  24253. colorStep: Color4;
  24254. /**
  24255. * Defines how long will the life of the particle be.
  24256. */
  24257. lifeTime: number;
  24258. /**
  24259. * The current age of the particle.
  24260. */
  24261. age: number;
  24262. /**
  24263. * The current size of the particle.
  24264. */
  24265. size: number;
  24266. /**
  24267. * The current angle of the particle.
  24268. */
  24269. angle: number;
  24270. /**
  24271. * Defines how fast is the angle changing.
  24272. */
  24273. angularSpeed: number;
  24274. /**
  24275. * Defines the cell index used by the particle to be rendered from a sprite.
  24276. */
  24277. cellIndex: number;
  24278. private _currentFrameCounter;
  24279. /**
  24280. * Creates a new instance Particle
  24281. * @param particleSystem the particle system the particle belongs to
  24282. */
  24283. constructor(
  24284. /**
  24285. * particleSystem the particle system the particle belongs to.
  24286. */
  24287. particleSystem: ParticleSystem);
  24288. private updateCellInfoFromSystem();
  24289. /**
  24290. * Defines how the sprite cell index is updated for the particle. This is
  24291. * defined as a callback.
  24292. */
  24293. updateCellIndex: (scaledUpdateSpeed: number) => void;
  24294. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  24295. private _updateCellIndexWithCustomSpeed();
  24296. /**
  24297. * Copy the properties of particle to another one.
  24298. * @param other the particle to copy the information to.
  24299. */
  24300. copyTo(other: Particle): void;
  24301. }
  24302. }
  24303. declare module BABYLON {
  24304. /**
  24305. * This represents a particle system in Babylon.
  24306. * 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.
  24307. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24308. * @example https://doc.babylonjs.com/babylon101/particles
  24309. */
  24310. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  24311. /**
  24312. * Source color is added to the destination color without alpha affecting the result.
  24313. */
  24314. static BLENDMODE_ONEONE: number;
  24315. /**
  24316. * Blend current color and particle color using particle’s alpha.
  24317. */
  24318. static BLENDMODE_STANDARD: number;
  24319. /**
  24320. * List of animations used by the particle system.
  24321. */
  24322. animations: Animation[];
  24323. /**
  24324. * The id of the Particle system.
  24325. */
  24326. id: string;
  24327. /**
  24328. * The friendly name of the Particle system.
  24329. */
  24330. name: string;
  24331. /**
  24332. * The rendering group used by the Particle system to chose when to render.
  24333. */
  24334. renderingGroupId: number;
  24335. /**
  24336. * The emitter represents the Mesh or position we are attaching the particle system to.
  24337. */
  24338. emitter: Nullable<AbstractMesh | Vector3>;
  24339. /**
  24340. * The maximum number of particles to emit per frame
  24341. */
  24342. emitRate: number;
  24343. /**
  24344. * If you want to launch only a few particles at once, that can be done, as well.
  24345. */
  24346. manualEmitCount: number;
  24347. /**
  24348. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24349. */
  24350. updateSpeed: number;
  24351. /**
  24352. * The amount of time the particle system is running (depends of the overall update speed).
  24353. */
  24354. targetStopDuration: number;
  24355. /**
  24356. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24357. */
  24358. disposeOnStop: boolean;
  24359. /**
  24360. * Minimum power of emitting particles.
  24361. */
  24362. minEmitPower: number;
  24363. /**
  24364. * Maximum power of emitting particles.
  24365. */
  24366. maxEmitPower: number;
  24367. /**
  24368. * Minimum life time of emitting particles.
  24369. */
  24370. minLifeTime: number;
  24371. /**
  24372. * Maximum life time of emitting particles.
  24373. */
  24374. maxLifeTime: number;
  24375. /**
  24376. * Minimum Size of emitting particles.
  24377. */
  24378. minSize: number;
  24379. /**
  24380. * Maximum Size of emitting particles.
  24381. */
  24382. maxSize: number;
  24383. /**
  24384. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24385. */
  24386. minAngularSpeed: number;
  24387. /**
  24388. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24389. */
  24390. maxAngularSpeed: number;
  24391. /**
  24392. * The texture used to render each particle. (this can be a spritesheet)
  24393. */
  24394. particleTexture: Nullable<Texture>;
  24395. /**
  24396. * The layer mask we are rendering the particles through.
  24397. */
  24398. layerMask: number;
  24399. /**
  24400. * This can help using your own shader to render the particle system.
  24401. * The according effect will be created
  24402. */
  24403. customShader: any;
  24404. /**
  24405. * By default particle system starts as soon as they are created. This prevents the
  24406. * automatic start to happen and let you decide when to start emitting particles.
  24407. */
  24408. preventAutoStart: boolean;
  24409. /**
  24410. * This function can be defined to provide custom update for active particles.
  24411. * This function will be called instead of regular update (age, position, color, etc.).
  24412. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  24413. */
  24414. updateFunction: (particles: Particle[]) => void;
  24415. /**
  24416. * Callback triggered when the particle animation is ending.
  24417. */
  24418. onAnimationEnd: Nullable<() => void>;
  24419. /**
  24420. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24421. */
  24422. blendMode: number;
  24423. /**
  24424. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24425. * to override the particles.
  24426. */
  24427. forceDepthWrite: boolean;
  24428. /**
  24429. * You can use gravity if you want to give an orientation to your particles.
  24430. */
  24431. gravity: Vector3;
  24432. /**
  24433. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24434. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24435. */
  24436. direction1: Vector3;
  24437. /**
  24438. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24439. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24440. */
  24441. direction2: Vector3;
  24442. /**
  24443. * 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.
  24444. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24445. */
  24446. minEmitBox: Vector3;
  24447. /**
  24448. * 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.
  24449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24450. */
  24451. maxEmitBox: Vector3;
  24452. /**
  24453. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24454. */
  24455. color1: Color4;
  24456. /**
  24457. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24458. */
  24459. color2: Color4;
  24460. /**
  24461. * Color the particle will have at the end of its lifetime.
  24462. */
  24463. colorDead: Color4;
  24464. /**
  24465. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  24466. */
  24467. textureMask: Color4;
  24468. /**
  24469. * The particle emitter type defines the emitter used by the particle system.
  24470. * It can be for example box, sphere, or cone...
  24471. */
  24472. particleEmitterType: IParticleEmitterType;
  24473. /**
  24474. * This function can be defined to specify initial direction for every new particle.
  24475. * It by default use the emitterType defined function.
  24476. */
  24477. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  24478. /**
  24479. * This function can be defined to specify initial position for every new particle.
  24480. * It by default use the emitterType defined function.
  24481. */
  24482. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  24483. /**
  24484. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  24485. */
  24486. spriteCellLoop: boolean;
  24487. /**
  24488. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  24489. */
  24490. spriteCellChangeSpeed: number;
  24491. /**
  24492. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  24493. */
  24494. startSpriteCellID: number;
  24495. /**
  24496. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  24497. */
  24498. endSpriteCellID: number;
  24499. /**
  24500. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  24501. */
  24502. spriteCellWidth: number;
  24503. /**
  24504. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  24505. */
  24506. spriteCellHeight: number;
  24507. /**
  24508. * An event triggered when the system is disposed.
  24509. */
  24510. onDisposeObservable: Observable<ParticleSystem>;
  24511. private _onDisposeObserver;
  24512. /**
  24513. * Sets a callback that will be triggered when the system is disposed.
  24514. */
  24515. onDispose: () => void;
  24516. /**
  24517. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  24518. */
  24519. readonly isAnimationSheetEnabled: Boolean;
  24520. private _particles;
  24521. private _epsilon;
  24522. private _capacity;
  24523. private _scene;
  24524. private _stockParticles;
  24525. private _newPartsExcess;
  24526. private _vertexData;
  24527. private _vertexBuffer;
  24528. private _vertexBuffers;
  24529. private _indexBuffer;
  24530. private _effect;
  24531. private _customEffect;
  24532. private _cachedDefines;
  24533. private _scaledColorStep;
  24534. private _colorDiff;
  24535. private _scaledDirection;
  24536. private _scaledGravity;
  24537. private _currentRenderId;
  24538. private _alive;
  24539. private _started;
  24540. private _stopped;
  24541. private _actualFrame;
  24542. private _scaledUpdateSpeed;
  24543. private _vertexBufferSize;
  24544. private _isAnimationSheetEnabled;
  24545. /**
  24546. * 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.
  24547. */
  24548. subEmitters: ParticleSystem[];
  24549. /**
  24550. * The current active Sub-systems, this property is used by the root particle system only.
  24551. */
  24552. activeSubSystems: Array<ParticleSystem>;
  24553. private _rootParticleSystem;
  24554. /**
  24555. * Gets the current list of active particles
  24556. */
  24557. readonly particles: Particle[];
  24558. /**
  24559. * Returns the string "ParticleSystem"
  24560. * @returns a string containing the class name
  24561. */
  24562. getClassName(): string;
  24563. /**
  24564. * Instantiates a particle system.
  24565. * 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.
  24566. * @param name The name of the particle system
  24567. * @param capacity The max number of particles alive at the same time
  24568. * @param scene The scene the particle system belongs to
  24569. * @param customEffect a custom effect used to change the way particles are rendered by default
  24570. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24571. * @param epsilon Offset used to render the particles
  24572. */
  24573. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  24574. private _createIndexBuffer();
  24575. /**
  24576. * Gets the maximum number of particles active at the same time.
  24577. * @returns The max number of active particles.
  24578. */
  24579. getCapacity(): number;
  24580. /**
  24581. * Gets Wether there are still active particles in the system.
  24582. * @returns True if it is alive, otherwise false.
  24583. */
  24584. isAlive(): boolean;
  24585. /**
  24586. * Gets Wether the system has been started.
  24587. * @returns True if it has been started, otherwise false.
  24588. */
  24589. isStarted(): boolean;
  24590. /**
  24591. * Starts the particle system and begins to emit.
  24592. */
  24593. start(): void;
  24594. /**
  24595. * Stops the particle system.
  24596. * @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.
  24597. */
  24598. stop(stopSubEmitters?: boolean): void;
  24599. /**
  24600. * Remove all active particles
  24601. */
  24602. reset(): void;
  24603. /**
  24604. * @hidden (for internal use only)
  24605. */
  24606. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  24607. /**
  24608. * @hidden (for internal use only)
  24609. */
  24610. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  24611. /**
  24612. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  24613. * Its lifetime will start back at 0.
  24614. */
  24615. recycleParticle: (particle: Particle) => void;
  24616. private _stopSubEmitters();
  24617. private _createParticle;
  24618. private _removeFromRoot();
  24619. private _emitFromParticle;
  24620. private _update(newParticles);
  24621. private _getEffect();
  24622. /**
  24623. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24624. */
  24625. animate(): void;
  24626. private _appendParticleVertexes;
  24627. private _appenedParticleVertexesWithSheet(offset, particle);
  24628. private _appenedParticleVertexesNoSheet(offset, particle);
  24629. /**
  24630. * Rebuilds the particle system.
  24631. */
  24632. rebuild(): void;
  24633. /**
  24634. * Is this system ready to be used/rendered
  24635. * @return true if the system is ready
  24636. */
  24637. isReady(): boolean;
  24638. /**
  24639. * Renders the particle system in its current state.
  24640. * @returns the current number of particles
  24641. */
  24642. render(): number;
  24643. /**
  24644. * Disposes the particle system and free the associated resources
  24645. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24646. */
  24647. dispose(disposeTexture?: boolean): void;
  24648. /**
  24649. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  24650. * @param radius The radius of the sphere to emit from
  24651. * @returns the emitter
  24652. */
  24653. createSphereEmitter(radius?: number): SphereParticleEmitter;
  24654. /**
  24655. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  24656. * @param radius The radius of the sphere to emit from
  24657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24659. * @returns the emitter
  24660. */
  24661. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24662. /**
  24663. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  24664. * @param radius The radius of the cone to emit from
  24665. * @param angle The base angle of the cone
  24666. * @returns the emitter
  24667. */
  24668. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24669. /**
  24670. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24673. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24674. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24675. * @returns the emitter
  24676. */
  24677. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24678. /**
  24679. * Clones the particle system.
  24680. * @param name The name of the cloned object
  24681. * @param newEmitter The new emitter to use
  24682. * @returns the cloned particle system
  24683. */
  24684. clone(name: string, newEmitter: any): ParticleSystem;
  24685. /**
  24686. * Serializes the particle system to a JSON object.
  24687. * @returns the JSON object
  24688. */
  24689. serialize(): any;
  24690. /**
  24691. * Parses a JSON object to create a particle system.
  24692. * @param parsedParticleSystem The JSON object to parse
  24693. * @param scene The scene to create the particle system in
  24694. * @param rootUrl The root url to use to load external dependencies like texture
  24695. * @returns the Parsed particle system
  24696. */
  24697. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  24698. }
  24699. }
  24700. declare module BABYLON {
  24701. /**
  24702. * Represents one particle of a solid particle system.
  24703. */
  24704. class SolidParticle {
  24705. /**
  24706. * particle global index
  24707. */
  24708. idx: number;
  24709. /**
  24710. * The color of the particle
  24711. */
  24712. color: Nullable<Color4>;
  24713. /**
  24714. * The world space position of the particle.
  24715. */
  24716. position: Vector3;
  24717. /**
  24718. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24719. */
  24720. rotation: Vector3;
  24721. /**
  24722. * The world space rotation quaternion of the particle.
  24723. */
  24724. rotationQuaternion: Nullable<Quaternion>;
  24725. /**
  24726. * The scaling of the particle.
  24727. */
  24728. scaling: Vector3;
  24729. /**
  24730. * The uvs of the particle.
  24731. */
  24732. uvs: Vector4;
  24733. /**
  24734. * The current speed of the particle.
  24735. */
  24736. velocity: Vector3;
  24737. /**
  24738. * The pivot point in the particle local space.
  24739. */
  24740. pivot: Vector3;
  24741. /**
  24742. * Must the particle be translated from its pivot point in its local space ?
  24743. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24744. * Default : false
  24745. */
  24746. translateFromPivot: boolean;
  24747. /**
  24748. * Is the particle active or not ?
  24749. */
  24750. alive: boolean;
  24751. /**
  24752. * Is the particle visible or not ?
  24753. */
  24754. isVisible: boolean;
  24755. /**
  24756. * Index of this particle in the global "positions" array (Internal use)
  24757. */
  24758. _pos: number;
  24759. /**
  24760. * Index of this particle in the global "indices" array (Internal use)
  24761. */
  24762. _ind: number;
  24763. /**
  24764. * ModelShape of this particle (Internal use)
  24765. */
  24766. _model: ModelShape;
  24767. /**
  24768. * ModelShape id of this particle
  24769. */
  24770. shapeId: number;
  24771. /**
  24772. * Index of the particle in its shape id (Internal use)
  24773. */
  24774. idxInShape: number;
  24775. /**
  24776. * Reference to the shape model BoundingInfo object (Internal use)
  24777. */
  24778. _modelBoundingInfo: BoundingInfo;
  24779. /**
  24780. * Particle BoundingInfo object (Internal use)
  24781. */
  24782. _boundingInfo: BoundingInfo;
  24783. /**
  24784. * Reference to the SPS what the particle belongs to (Internal use)
  24785. */
  24786. _sps: SolidParticleSystem;
  24787. /**
  24788. * Still set as invisible in order to skip useless computations (Internal use)
  24789. */
  24790. _stillInvisible: boolean;
  24791. /**
  24792. * Last computed particle rotation matrix
  24793. */
  24794. _rotationMatrix: number[];
  24795. /**
  24796. * Parent particle Id, if any.
  24797. * Default null.
  24798. */
  24799. parentId: Nullable<number>;
  24800. /**
  24801. * Internal global position in the SPS.
  24802. */
  24803. _globalPosition: Vector3;
  24804. /**
  24805. * Creates a Solid Particle object.
  24806. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24807. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24808. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24809. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24810. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24811. * @param shapeId (integer) is the model shape identifier in the SPS.
  24812. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24813. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24814. */
  24815. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24816. /**
  24817. * Legacy support, changed scale to scaling
  24818. */
  24819. /**
  24820. * Legacy support, changed scale to scaling
  24821. */
  24822. scale: Vector3;
  24823. /**
  24824. * Legacy support, changed quaternion to rotationQuaternion
  24825. */
  24826. /**
  24827. * Legacy support, changed quaternion to rotationQuaternion
  24828. */
  24829. quaternion: Nullable<Quaternion>;
  24830. /**
  24831. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24832. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24833. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24834. * @returns true if it intersects
  24835. */
  24836. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24837. }
  24838. /**
  24839. * Represents the shape of the model used by one particle of a solid particle system.
  24840. * SPS internal tool, don't use it manually.
  24841. */
  24842. class ModelShape {
  24843. /**
  24844. * The shape id.
  24845. */
  24846. shapeID: number;
  24847. /**
  24848. * flat array of model positions (internal use)
  24849. */
  24850. _shape: Vector3[];
  24851. /**
  24852. * flat array of model UVs (internal use)
  24853. */
  24854. _shapeUV: number[];
  24855. /**
  24856. * length of the shape in the model indices array (internal use)
  24857. */
  24858. _indicesLength: number;
  24859. /**
  24860. * Custom position function (internal use)
  24861. */
  24862. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24863. /**
  24864. * Custom vertex function (internal use)
  24865. */
  24866. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24867. /**
  24868. * 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.
  24869. * SPS internal tool, don't use it manually.
  24870. * @hidden
  24871. */
  24872. 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>);
  24873. }
  24874. /**
  24875. * Represents a Depth Sorted Particle in the solid particle system.
  24876. */
  24877. class DepthSortedParticle {
  24878. /**
  24879. * Index of the particle in the "indices" array
  24880. */
  24881. ind: number;
  24882. /**
  24883. * Length of the particle shape in the "indices" array
  24884. */
  24885. indicesLength: number;
  24886. /**
  24887. * Squared distance from the particle to the camera
  24888. */
  24889. sqDistance: number;
  24890. }
  24891. }
  24892. declare module BABYLON {
  24893. /**
  24894. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24895. *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.
  24896. * The SPS is also a particle system. It provides some methods to manage the particles.
  24897. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24898. *
  24899. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24900. */
  24901. class SolidParticleSystem implements IDisposable {
  24902. /**
  24903. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24904. * Example : var p = SPS.particles[i];
  24905. */
  24906. particles: SolidParticle[];
  24907. /**
  24908. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24909. */
  24910. nbParticles: number;
  24911. /**
  24912. * If the particles must ever face the camera (default false). Useful for planar particles.
  24913. */
  24914. billboard: boolean;
  24915. /**
  24916. * Recompute normals when adding a shape
  24917. */
  24918. recomputeNormals: boolean;
  24919. /**
  24920. * This a counter ofr your own usage. It's not set by any SPS functions.
  24921. */
  24922. counter: number;
  24923. /**
  24924. * The SPS name. This name is also given to the underlying mesh.
  24925. */
  24926. name: string;
  24927. /**
  24928. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24929. */
  24930. mesh: Mesh;
  24931. /**
  24932. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24933. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24934. */
  24935. vars: any;
  24936. /**
  24937. * This array is populated when the SPS is set as 'pickable'.
  24938. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24939. * Each element of this array is an object `{idx: int, faceId: int}`.
  24940. * `idx` is the picked particle index in the `SPS.particles` array
  24941. * `faceId` is the picked face index counted within this particle.
  24942. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24943. */
  24944. pickedParticles: {
  24945. idx: number;
  24946. faceId: number;
  24947. }[];
  24948. /**
  24949. * This array is populated when `enableDepthSort` is set to true.
  24950. * Each element of this array is an instance of the class DepthSortedParticle.
  24951. */
  24952. depthSortedParticles: DepthSortedParticle[];
  24953. /**
  24954. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24955. */
  24956. _bSphereOnly: boolean;
  24957. /**
  24958. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24959. */
  24960. _bSphereRadiusFactor: number;
  24961. private _scene;
  24962. private _positions;
  24963. private _indices;
  24964. private _normals;
  24965. private _colors;
  24966. private _uvs;
  24967. private _indices32;
  24968. private _positions32;
  24969. private _normals32;
  24970. private _fixedNormal32;
  24971. private _colors32;
  24972. private _uvs32;
  24973. private _index;
  24974. private _updatable;
  24975. private _pickable;
  24976. private _isVisibilityBoxLocked;
  24977. private _alwaysVisible;
  24978. private _depthSort;
  24979. private _shapeCounter;
  24980. private _copy;
  24981. private _shape;
  24982. private _shapeUV;
  24983. private _color;
  24984. private _computeParticleColor;
  24985. private _computeParticleTexture;
  24986. private _computeParticleRotation;
  24987. private _computeParticleVertex;
  24988. private _computeBoundingBox;
  24989. private _depthSortParticles;
  24990. private _cam_axisZ;
  24991. private _cam_axisY;
  24992. private _cam_axisX;
  24993. private _axisZ;
  24994. private _camera;
  24995. private _particle;
  24996. private _camDir;
  24997. private _camInvertedPosition;
  24998. private _rotMatrix;
  24999. private _invertMatrix;
  25000. private _rotated;
  25001. private _quaternion;
  25002. private _vertex;
  25003. private _normal;
  25004. private _yaw;
  25005. private _pitch;
  25006. private _roll;
  25007. private _halfroll;
  25008. private _halfpitch;
  25009. private _halfyaw;
  25010. private _sinRoll;
  25011. private _cosRoll;
  25012. private _sinPitch;
  25013. private _cosPitch;
  25014. private _sinYaw;
  25015. private _cosYaw;
  25016. private _mustUnrotateFixedNormals;
  25017. private _minimum;
  25018. private _maximum;
  25019. private _minBbox;
  25020. private _maxBbox;
  25021. private _particlesIntersect;
  25022. private _depthSortFunction;
  25023. private _needs32Bits;
  25024. private _pivotBackTranslation;
  25025. private _scaledPivot;
  25026. private _particleHasParent;
  25027. private _parent;
  25028. /**
  25029. * Creates a SPS (Solid Particle System) object.
  25030. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25031. * @param scene (Scene) is the scene in which the SPS is added.
  25032. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25033. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25034. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25035. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25036. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25037. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25038. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25039. */
  25040. constructor(name: string, scene: Scene, options?: {
  25041. updatable?: boolean;
  25042. isPickable?: boolean;
  25043. enableDepthSort?: boolean;
  25044. particleIntersection?: boolean;
  25045. boundingSphereOnly?: boolean;
  25046. bSphereRadiusFactor?: number;
  25047. });
  25048. /**
  25049. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25050. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25051. * @returns the created mesh
  25052. */
  25053. buildMesh(): Mesh;
  25054. /**
  25055. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25056. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25057. * Thus the particles generated from `digest()` have their property `position` set yet.
  25058. * @param mesh ( Mesh ) is the mesh to be digested
  25059. * @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
  25060. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25061. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25062. * @returns the current SPS
  25063. */
  25064. digest(mesh: Mesh, options?: {
  25065. facetNb?: number;
  25066. number?: number;
  25067. delta?: number;
  25068. }): SolidParticleSystem;
  25069. private _unrotateFixedNormals();
  25070. private _resetCopy();
  25071. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  25072. private _posToShape(positions);
  25073. private _uvsToShapeUV(uvs);
  25074. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  25075. /**
  25076. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25077. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25078. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25079. * @param nb (positive integer) the number of particles to be created from this model
  25080. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25081. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25082. * @returns the number of shapes in the system
  25083. */
  25084. addShape(mesh: Mesh, nb: number, options?: {
  25085. positionFunction?: any;
  25086. vertexFunction?: any;
  25087. }): number;
  25088. private _rebuildParticle(particle);
  25089. /**
  25090. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25091. * @returns the SPS.
  25092. */
  25093. rebuildMesh(): SolidParticleSystem;
  25094. /**
  25095. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25096. * This method calls `updateParticle()` for each particle of the SPS.
  25097. * For an animated SPS, it is usually called within the render loop.
  25098. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25099. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25100. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25101. * @returns the SPS.
  25102. */
  25103. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25104. private _quaternionRotationYPR();
  25105. private _quaternionToRotationMatrix();
  25106. /**
  25107. * Disposes the SPS.
  25108. */
  25109. dispose(): void;
  25110. /**
  25111. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25112. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25113. * @returns the SPS.
  25114. */
  25115. refreshVisibleSize(): SolidParticleSystem;
  25116. /**
  25117. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25118. * @param size the size (float) of the visibility box
  25119. * note : this doesn't lock the SPS mesh bounding box.
  25120. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25121. */
  25122. setVisibilityBox(size: number): void;
  25123. /**
  25124. * Gets whether the SPS as always visible or not
  25125. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25126. */
  25127. /**
  25128. * Sets the SPS as always visible or not
  25129. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25130. */
  25131. isAlwaysVisible: boolean;
  25132. /**
  25133. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25134. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25135. */
  25136. /**
  25137. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25138. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25139. */
  25140. isVisibilityBoxLocked: boolean;
  25141. /**
  25142. * Gets if `setParticles()` computes the particle rotations or not.
  25143. * Default value : true. The SPS is faster when it's set to false.
  25144. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25145. */
  25146. /**
  25147. * Tells to `setParticles()` to compute the particle rotations or not.
  25148. * Default value : true. The SPS is faster when it's set to false.
  25149. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25150. */
  25151. computeParticleRotation: boolean;
  25152. /**
  25153. * Gets if `setParticles()` computes the particle colors or not.
  25154. * Default value : true. The SPS is faster when it's set to false.
  25155. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25156. */
  25157. /**
  25158. * Tells to `setParticles()` to compute the particle colors or not.
  25159. * Default value : true. The SPS is faster when it's set to false.
  25160. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25161. */
  25162. computeParticleColor: boolean;
  25163. /**
  25164. * Gets if `setParticles()` computes the particle textures or not.
  25165. * Default value : true. The SPS is faster when it's set to false.
  25166. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25167. */
  25168. computeParticleTexture: boolean;
  25169. /**
  25170. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25171. * Default value : false. The SPS is faster when it's set to false.
  25172. * Note : the particle custom vertex positions aren't stored values.
  25173. */
  25174. /**
  25175. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25176. * Default value : false. The SPS is faster when it's set to false.
  25177. * Note : the particle custom vertex positions aren't stored values.
  25178. */
  25179. computeParticleVertex: boolean;
  25180. /**
  25181. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25182. */
  25183. /**
  25184. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25185. */
  25186. computeBoundingBox: boolean;
  25187. /**
  25188. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25189. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25190. * Default : `true`
  25191. */
  25192. /**
  25193. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25194. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25195. * Default : `true`
  25196. */
  25197. depthSortParticles: boolean;
  25198. /**
  25199. * This function does nothing. It may be overwritten to set all the particle first values.
  25200. * The SPS doesn't call this function, you may have to call it by your own.
  25201. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25202. */
  25203. initParticles(): void;
  25204. /**
  25205. * This function does nothing. It may be overwritten to recycle a particle.
  25206. * The SPS doesn't call this function, you may have to call it by your own.
  25207. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25208. * @param particle The particle to recycle
  25209. * @returns the recycled particle
  25210. */
  25211. recycleParticle(particle: SolidParticle): SolidParticle;
  25212. /**
  25213. * Updates a particle : this function should be overwritten by the user.
  25214. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25215. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25216. * @example : just set a particle position or velocity and recycle conditions
  25217. * @param particle The particle to update
  25218. * @returns the updated particle
  25219. */
  25220. updateParticle(particle: SolidParticle): SolidParticle;
  25221. /**
  25222. * Updates a vertex of a particle : it can be overwritten by the user.
  25223. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25224. * @param particle the current particle
  25225. * @param vertex the current index of the current particle
  25226. * @param pt the index of the current vertex in the particle shape
  25227. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25228. * @example : just set a vertex particle position
  25229. * @returns the updated vertex
  25230. */
  25231. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25232. /**
  25233. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25234. * This does nothing and may be overwritten by the user.
  25235. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25236. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25237. * @param update the boolean update value actually passed to setParticles()
  25238. */
  25239. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25240. /**
  25241. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25242. * This will be passed three parameters.
  25243. * This does nothing and may be overwritten by the user.
  25244. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25245. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25246. * @param update the boolean update value actually passed to setParticles()
  25247. */
  25248. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25249. }
  25250. }
  25251. declare module BABYLON {
  25252. class ReflectionProbe {
  25253. name: string;
  25254. private _scene;
  25255. private _renderTargetTexture;
  25256. private _projectionMatrix;
  25257. private _viewMatrix;
  25258. private _target;
  25259. private _add;
  25260. private _attachedMesh;
  25261. private _invertYAxis;
  25262. position: Vector3;
  25263. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25264. samples: number;
  25265. refreshRate: number;
  25266. getScene(): Scene;
  25267. readonly cubeTexture: RenderTargetTexture;
  25268. readonly renderList: Nullable<AbstractMesh[]>;
  25269. attachToMesh(mesh: AbstractMesh): void;
  25270. /**
  25271. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25272. *
  25273. * @param renderingGroupId The rendering group id corresponding to its index
  25274. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25275. */
  25276. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25277. dispose(): void;
  25278. }
  25279. }
  25280. declare module BABYLON {
  25281. /**
  25282. * Postprocess used to generate anaglyphic rendering
  25283. */
  25284. class AnaglyphPostProcess extends PostProcess {
  25285. private _passedProcess;
  25286. /**
  25287. * Creates a new AnaglyphPostProcess
  25288. * @param name defines postprocess name
  25289. * @param options defines creation options or target ratio scale
  25290. * @param rigCameras defines cameras using this postprocess
  25291. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25292. * @param engine defines hosting engine
  25293. * @param reusable defines if the postprocess will be reused multiple times per frame
  25294. */
  25295. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25296. }
  25297. }
  25298. declare module BABYLON {
  25299. class BlackAndWhitePostProcess extends PostProcess {
  25300. degree: number;
  25301. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25302. }
  25303. }
  25304. declare module BABYLON {
  25305. /**
  25306. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25307. */
  25308. class BloomEffect extends PostProcessRenderEffect {
  25309. private bloomScale;
  25310. /**
  25311. * Internal
  25312. */
  25313. _effects: Array<PostProcess>;
  25314. /**
  25315. * Internal
  25316. */
  25317. _downscale: ExtractHighlightsPostProcess;
  25318. private _blurX;
  25319. private _blurY;
  25320. private _merge;
  25321. /**
  25322. * The luminance threshold to find bright areas of the image to bloom.
  25323. */
  25324. threshold: number;
  25325. /**
  25326. * The strength of the bloom.
  25327. */
  25328. weight: number;
  25329. /**
  25330. * Specifies the size of the bloom blur kernel, relative to the final output size
  25331. */
  25332. kernel: number;
  25333. /**
  25334. * Creates a new instance of @see BloomEffect
  25335. * @param scene The scene the effect belongs to.
  25336. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25337. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25338. * @param bloomWeight The the strength of bloom.
  25339. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25340. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  25341. */
  25342. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25343. /**
  25344. * Disposes each of the internal effects for a given camera.
  25345. * @param camera The camera to dispose the effect on.
  25346. */
  25347. disposeEffects(camera: Camera): void;
  25348. /**
  25349. * Internal
  25350. */
  25351. _updateEffects(): void;
  25352. /**
  25353. * Internal
  25354. * @returns if all the contained post processes are ready.
  25355. */
  25356. _isReady(): boolean;
  25357. }
  25358. }
  25359. declare module BABYLON {
  25360. /**
  25361. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25362. */
  25363. class BloomMergePostProcess extends PostProcess {
  25364. /** Weight of the bloom to be added to the original input. */ weight: number;
  25365. /**
  25366. * Creates a new instance of @see BloomMergePostProcess
  25367. * @param name The name of the effect.
  25368. * @param originalFromInput Post process which's input will be used for the merge.
  25369. * @param blurred Blurred highlights post process which's output will be used.
  25370. * @param weight Weight of the bloom to be added to the original input.
  25371. * @param options The required width/height ratio to downsize to before computing the render pass.
  25372. * @param camera The camera to apply the render pass to.
  25373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25374. * @param engine The engine which the post process will be applied. (default: current engine)
  25375. * @param reusable If the post process can be reused on the same frame. (default: false)
  25376. * @param textureType Type of textures used when performing the post process. (default: 0)
  25377. * @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)
  25378. */
  25379. 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);
  25380. }
  25381. }
  25382. declare module BABYLON {
  25383. /**
  25384. * The Blur Post Process which blurs an image based on a kernel and direction.
  25385. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25386. */
  25387. class BlurPostProcess extends PostProcess {
  25388. /** The direction in which to blur the image. */ direction: Vector2;
  25389. private blockCompilation;
  25390. protected _kernel: number;
  25391. protected _idealKernel: number;
  25392. protected _packedFloat: boolean;
  25393. private _staticDefines;
  25394. /**
  25395. * Gets the length in pixels of the blur sample region
  25396. */
  25397. /**
  25398. * Sets the length in pixels of the blur sample region
  25399. */
  25400. kernel: number;
  25401. /**
  25402. * Gets wether or not the blur is unpacking/repacking floats
  25403. */
  25404. /**
  25405. * Sets wether or not the blur needs to unpack/repack floats
  25406. */
  25407. packedFloat: boolean;
  25408. /**
  25409. * Creates a new instance BlurPostProcess
  25410. * @param name The name of the effect.
  25411. * @param direction The direction in which to blur the image.
  25412. * @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.
  25413. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25414. * @param camera The camera to apply the render pass to.
  25415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25416. * @param engine The engine which the post process will be applied. (default: current engine)
  25417. * @param reusable If the post process can be reused on the same frame. (default: false)
  25418. * @param textureType Type of textures used when performing the post process. (default: 0)
  25419. * @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)
  25420. */
  25421. 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);
  25422. /**
  25423. * Updates the effect with the current post process compile time values and recompiles the shader.
  25424. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25425. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25426. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25427. * @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
  25428. * @param onCompiled Called when the shader has been compiled.
  25429. * @param onError Called if there is an error when compiling a shader.
  25430. */
  25431. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25432. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25433. /**
  25434. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25435. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25436. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25437. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25438. * The gaps between physical kernels are compensated for in the weighting of the samples
  25439. * @param idealKernel Ideal blur kernel.
  25440. * @return Nearest best kernel.
  25441. */
  25442. protected _nearestBestKernel(idealKernel: number): number;
  25443. /**
  25444. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25445. * @param x The point on the Gaussian distribution to sample.
  25446. * @return the value of the Gaussian function at x.
  25447. */
  25448. protected _gaussianWeight(x: number): number;
  25449. /**
  25450. * Generates a string that can be used as a floating point number in GLSL.
  25451. * @param x Value to print.
  25452. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25453. * @return GLSL float string.
  25454. */
  25455. protected _glslFloat(x: number, decimalFigures?: number): string;
  25456. }
  25457. }
  25458. declare module BABYLON {
  25459. /**
  25460. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25461. */
  25462. class ChromaticAberrationPostProcess extends PostProcess {
  25463. /**
  25464. * The amount of seperation of rgb channels (default: 30)
  25465. */
  25466. aberrationAmount: number;
  25467. /**
  25468. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25469. */
  25470. radialIntensity: number;
  25471. /**
  25472. * 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))
  25473. */
  25474. direction: Vector2;
  25475. /**
  25476. * 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))
  25477. */
  25478. centerPosition: Vector2;
  25479. /**
  25480. * Creates a new instance ChromaticAberrationPostProcess
  25481. * @param name The name of the effect.
  25482. * @param screenWidth The width of the screen to apply the effect on.
  25483. * @param screenHeight The height of the screen to apply the effect on.
  25484. * @param options The required width/height ratio to downsize to before computing the render pass.
  25485. * @param camera The camera to apply the render pass to.
  25486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25487. * @param engine The engine which the post process will be applied. (default: current engine)
  25488. * @param reusable If the post process can be reused on the same frame. (default: false)
  25489. * @param textureType Type of textures used when performing the post process. (default: 0)
  25490. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  25491. */
  25492. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25493. }
  25494. }
  25495. declare module BABYLON {
  25496. /**
  25497. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25498. */
  25499. class CircleOfConfusionPostProcess extends PostProcess {
  25500. /**
  25501. * 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.
  25502. */
  25503. lensSize: number;
  25504. /**
  25505. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25506. */
  25507. fStop: number;
  25508. /**
  25509. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25510. */
  25511. focusDistance: number;
  25512. /**
  25513. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25514. */
  25515. focalLength: number;
  25516. private _depthTexture;
  25517. /**
  25518. * Creates a new instance CircleOfConfusionPostProcess
  25519. * @param name The name of the effect.
  25520. * @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.
  25521. * @param options The required width/height ratio to downsize to before computing the render pass.
  25522. * @param camera The camera to apply the render pass to.
  25523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25524. * @param engine The engine which the post process will be applied. (default: current engine)
  25525. * @param reusable If the post process can be reused on the same frame. (default: false)
  25526. * @param textureType Type of textures used when performing the post process. (default: 0)
  25527. * @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)
  25528. */
  25529. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25530. /**
  25531. * 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.
  25532. */
  25533. depthTexture: RenderTargetTexture;
  25534. }
  25535. }
  25536. declare module BABYLON {
  25537. class ColorCorrectionPostProcess extends PostProcess {
  25538. private _colorTableTexture;
  25539. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25540. }
  25541. }
  25542. declare module BABYLON {
  25543. /**
  25544. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25545. * input texture to perform effects such as edge detection or sharpening
  25546. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25547. */
  25548. class ConvolutionPostProcess extends PostProcess {
  25549. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25550. /**
  25551. * Creates a new instance ConvolutionPostProcess
  25552. * @param name The name of the effect.
  25553. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25554. * @param options The required width/height ratio to downsize to before computing the render pass.
  25555. * @param camera The camera to apply the render pass to.
  25556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25557. * @param engine The engine which the post process will be applied. (default: current engine)
  25558. * @param reusable If the post process can be reused on the same frame. (default: false)
  25559. * @param textureType Type of textures used when performing the post process. (default: 0)
  25560. */
  25561. 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);
  25562. /**
  25563. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25564. */
  25565. static EdgeDetect0Kernel: number[];
  25566. /**
  25567. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25568. */
  25569. static EdgeDetect1Kernel: number[];
  25570. /**
  25571. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25572. */
  25573. static EdgeDetect2Kernel: number[];
  25574. /**
  25575. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25576. */
  25577. static SharpenKernel: number[];
  25578. /**
  25579. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25580. */
  25581. static EmbossKernel: number[];
  25582. /**
  25583. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25584. */
  25585. static GaussianKernel: number[];
  25586. }
  25587. }
  25588. declare module BABYLON {
  25589. /**
  25590. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25591. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25592. * based on samples that have a large difference in distance than the center pixel.
  25593. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25594. */
  25595. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25596. direction: Vector2;
  25597. /**
  25598. * Creates a new instance CircleOfConfusionPostProcess
  25599. * @param name The name of the effect.
  25600. * @param scene The scene the effect belongs to.
  25601. * @param direction The direction the blur should be applied.
  25602. * @param kernel The size of the kernel used to blur.
  25603. * @param options The required width/height ratio to downsize to before computing the render pass.
  25604. * @param camera The camera to apply the render pass to.
  25605. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25606. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25608. * @param engine The engine which the post process will be applied. (default: current engine)
  25609. * @param reusable If the post process can be reused on the same frame. (default: false)
  25610. * @param textureType Type of textures used when performing the post process. (default: 0)
  25611. * @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)
  25612. */
  25613. 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);
  25614. }
  25615. }
  25616. declare module BABYLON {
  25617. /**
  25618. * Specifies the level of max blur that should be applied when using the depth of field effect
  25619. */
  25620. enum DepthOfFieldEffectBlurLevel {
  25621. /**
  25622. * Subtle blur
  25623. */
  25624. Low = 0,
  25625. /**
  25626. * Medium blur
  25627. */
  25628. Medium = 1,
  25629. /**
  25630. * Large blur
  25631. */
  25632. High = 2,
  25633. }
  25634. /**
  25635. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25636. */
  25637. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25638. private _circleOfConfusion;
  25639. /**
  25640. * Internal, blurs from high to low
  25641. */
  25642. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25643. private _depthOfFieldBlurY;
  25644. private _dofMerge;
  25645. /**
  25646. * Internal post processes in depth of field effect
  25647. */
  25648. _effects: Array<PostProcess>;
  25649. /**
  25650. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25651. */
  25652. focalLength: number;
  25653. /**
  25654. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25655. */
  25656. fStop: number;
  25657. /**
  25658. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25659. */
  25660. focusDistance: number;
  25661. /**
  25662. * 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.
  25663. */
  25664. lensSize: number;
  25665. /**
  25666. * Creates a new instance DepthOfFieldEffect
  25667. * @param scene The scene the effect belongs to.
  25668. * @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.
  25669. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25670. * @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)
  25671. */
  25672. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25673. /**
  25674. * 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.
  25675. */
  25676. depthTexture: RenderTargetTexture;
  25677. /**
  25678. * Disposes each of the internal effects for a given camera.
  25679. * @param camera The camera to dispose the effect on.
  25680. */
  25681. disposeEffects(camera: Camera): void;
  25682. /**
  25683. * Internal
  25684. */
  25685. _updateEffects(): void;
  25686. /**
  25687. * Internal
  25688. * @returns if all the contained post processes are ready.
  25689. */
  25690. _isReady(): boolean;
  25691. }
  25692. }
  25693. declare module BABYLON {
  25694. /**
  25695. * Options to be set when merging outputs from the default pipeline.
  25696. */
  25697. class DepthOfFieldMergePostProcessOptions {
  25698. /**
  25699. * The original image to merge on top of
  25700. */
  25701. originalFromInput: PostProcess;
  25702. /**
  25703. * Parameters to perform the merge of the depth of field effect
  25704. */
  25705. depthOfField?: {
  25706. circleOfConfusion: PostProcess;
  25707. blurSteps: Array<PostProcess>;
  25708. };
  25709. /**
  25710. * Parameters to perform the merge of bloom effect
  25711. */
  25712. bloom?: {
  25713. blurred: PostProcess;
  25714. weight: number;
  25715. };
  25716. }
  25717. /**
  25718. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25719. */
  25720. class DepthOfFieldMergePostProcess extends PostProcess {
  25721. private blurSteps;
  25722. /**
  25723. * Creates a new instance of DepthOfFieldMergePostProcess
  25724. * @param name The name of the effect.
  25725. * @param originalFromInput Post process which's input will be used for the merge.
  25726. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25727. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25728. * @param options The required width/height ratio to downsize to before computing the render pass.
  25729. * @param camera The camera to apply the render pass to.
  25730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25731. * @param engine The engine which the post process will be applied. (default: current engine)
  25732. * @param reusable If the post process can be reused on the same frame. (default: false)
  25733. * @param textureType Type of textures used when performing the post process. (default: 0)
  25734. * @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)
  25735. */
  25736. 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);
  25737. /**
  25738. * Updates the effect with the current post process compile time values and recompiles the shader.
  25739. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25740. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25741. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25742. * @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
  25743. * @param onCompiled Called when the shader has been compiled.
  25744. * @param onError Called if there is an error when compiling a shader.
  25745. */
  25746. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25747. }
  25748. }
  25749. declare module BABYLON {
  25750. class DisplayPassPostProcess extends PostProcess {
  25751. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25752. }
  25753. }
  25754. declare module BABYLON {
  25755. /**
  25756. * 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.
  25757. */
  25758. class ExtractHighlightsPostProcess extends PostProcess {
  25759. /**
  25760. * The luminance threshold, pixels below this value will be set to black.
  25761. */
  25762. threshold: number;
  25763. /**
  25764. * Internal
  25765. */
  25766. _exposure: number;
  25767. /**
  25768. * Post process which has the input texture to be used when performing highlight extraction
  25769. */
  25770. _inputPostProcess: Nullable<PostProcess>;
  25771. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25772. }
  25773. }
  25774. declare module BABYLON {
  25775. class FilterPostProcess extends PostProcess {
  25776. kernelMatrix: Matrix;
  25777. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25778. }
  25779. }
  25780. declare module BABYLON {
  25781. class FxaaPostProcess extends PostProcess {
  25782. texelWidth: number;
  25783. texelHeight: number;
  25784. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25785. private _getDefines();
  25786. }
  25787. }
  25788. declare module BABYLON {
  25789. /**
  25790. * The GrainPostProcess adds noise to the image at mid luminance levels
  25791. */
  25792. class GrainPostProcess extends PostProcess {
  25793. /**
  25794. * The intensity of the grain added (default: 30)
  25795. */
  25796. intensity: number;
  25797. /**
  25798. * If the grain should be randomized on every frame
  25799. */
  25800. animated: boolean;
  25801. /**
  25802. * Creates a new instance of @see GrainPostProcess
  25803. * @param name The name of the effect.
  25804. * @param options The required width/height ratio to downsize to before computing the render pass.
  25805. * @param camera The camera to apply the render pass to.
  25806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25807. * @param engine The engine which the post process will be applied. (default: current engine)
  25808. * @param reusable If the post process can be reused on the same frame. (default: false)
  25809. * @param textureType Type of textures used when performing the post process. (default: 0)
  25810. * @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)
  25811. */
  25812. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25813. }
  25814. }
  25815. declare module BABYLON {
  25816. class HighlightsPostProcess extends PostProcess {
  25817. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25818. }
  25819. }
  25820. declare module BABYLON {
  25821. class ImageProcessingPostProcess extends PostProcess {
  25822. /**
  25823. * Default configuration related to image processing available in the PBR Material.
  25824. */
  25825. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25826. /**
  25827. * Gets the image processing configuration used either in this material.
  25828. */
  25829. /**
  25830. * Sets the Default image processing configuration used either in the this material.
  25831. *
  25832. * If sets to null, the scene one is in use.
  25833. */
  25834. imageProcessingConfiguration: ImageProcessingConfiguration;
  25835. /**
  25836. * Keep track of the image processing observer to allow dispose and replace.
  25837. */
  25838. private _imageProcessingObserver;
  25839. /**
  25840. * Attaches a new image processing configuration to the PBR Material.
  25841. * @param configuration
  25842. */
  25843. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25844. /**
  25845. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25846. */
  25847. /**
  25848. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25849. */
  25850. colorCurves: Nullable<ColorCurves>;
  25851. /**
  25852. * Gets wether the color curves effect is enabled.
  25853. */
  25854. /**
  25855. * Sets wether the color curves effect is enabled.
  25856. */
  25857. colorCurvesEnabled: boolean;
  25858. /**
  25859. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25860. */
  25861. /**
  25862. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25863. */
  25864. colorGradingTexture: Nullable<BaseTexture>;
  25865. /**
  25866. * Gets wether the color grading effect is enabled.
  25867. */
  25868. /**
  25869. * Gets wether the color grading effect is enabled.
  25870. */
  25871. colorGradingEnabled: boolean;
  25872. /**
  25873. * Gets exposure used in the effect.
  25874. */
  25875. /**
  25876. * Sets exposure used in the effect.
  25877. */
  25878. exposure: number;
  25879. /**
  25880. * Gets wether tonemapping is enabled or not.
  25881. */
  25882. /**
  25883. * Sets wether tonemapping is enabled or not
  25884. */
  25885. toneMappingEnabled: boolean;
  25886. /**
  25887. * Gets contrast used in the effect.
  25888. */
  25889. /**
  25890. * Sets contrast used in the effect.
  25891. */
  25892. contrast: number;
  25893. /**
  25894. * Gets Vignette stretch size.
  25895. */
  25896. /**
  25897. * Sets Vignette stretch size.
  25898. */
  25899. vignetteStretch: number;
  25900. /**
  25901. * Gets Vignette centre X Offset.
  25902. */
  25903. /**
  25904. * Sets Vignette centre X Offset.
  25905. */
  25906. vignetteCentreX: number;
  25907. /**
  25908. * Gets Vignette centre Y Offset.
  25909. */
  25910. /**
  25911. * Sets Vignette centre Y Offset.
  25912. */
  25913. vignetteCentreY: number;
  25914. /**
  25915. * Gets Vignette weight or intensity of the vignette effect.
  25916. */
  25917. /**
  25918. * Sets Vignette weight or intensity of the vignette effect.
  25919. */
  25920. vignetteWeight: number;
  25921. /**
  25922. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25923. * if vignetteEnabled is set to true.
  25924. */
  25925. /**
  25926. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25927. * if vignetteEnabled is set to true.
  25928. */
  25929. vignetteColor: Color4;
  25930. /**
  25931. * Gets Camera field of view used by the Vignette effect.
  25932. */
  25933. /**
  25934. * Sets Camera field of view used by the Vignette effect.
  25935. */
  25936. vignetteCameraFov: number;
  25937. /**
  25938. * Gets the vignette blend mode allowing different kind of effect.
  25939. */
  25940. /**
  25941. * Sets the vignette blend mode allowing different kind of effect.
  25942. */
  25943. vignetteBlendMode: number;
  25944. /**
  25945. * Gets wether the vignette effect is enabled.
  25946. */
  25947. /**
  25948. * Sets wether the vignette effect is enabled.
  25949. */
  25950. vignetteEnabled: boolean;
  25951. private _fromLinearSpace;
  25952. /**
  25953. * Gets wether the input of the processing is in Gamma or Linear Space.
  25954. */
  25955. /**
  25956. * Sets wether the input of the processing is in Gamma or Linear Space.
  25957. */
  25958. fromLinearSpace: boolean;
  25959. /**
  25960. * Defines cache preventing GC.
  25961. */
  25962. private _defines;
  25963. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25964. getClassName(): string;
  25965. protected _updateParameters(): void;
  25966. dispose(camera?: Camera): void;
  25967. }
  25968. }
  25969. declare module BABYLON {
  25970. class PassPostProcess extends PostProcess {
  25971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25972. }
  25973. }
  25974. declare module BABYLON {
  25975. type PostProcessOptions = {
  25976. width: number;
  25977. height: number;
  25978. };
  25979. /**
  25980. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25981. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25982. */
  25983. class PostProcess {
  25984. /** Name of the PostProcess. */ name: string;
  25985. /**
  25986. * Width of the texture to apply the post process on
  25987. */
  25988. width: number;
  25989. /**
  25990. * Height of the texture to apply the post process on
  25991. */
  25992. height: number;
  25993. /**
  25994. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25995. */
  25996. _outputTexture: Nullable<InternalTexture>;
  25997. /**
  25998. * Sampling mode used by the shader
  25999. * See https://doc.babylonjs.com/classes/3.1/texture
  26000. */
  26001. renderTargetSamplingMode: number;
  26002. /**
  26003. * Clear color to use when screen clearing
  26004. */
  26005. clearColor: Color4;
  26006. /**
  26007. * If the buffer needs to be cleared before applying the post process. (default: true)
  26008. * Should be set to false if shader will overwrite all previous pixels.
  26009. */
  26010. autoClear: boolean;
  26011. /**
  26012. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26013. */
  26014. alphaMode: number;
  26015. /**
  26016. * Sets the setAlphaBlendConstants of the babylon engine
  26017. */
  26018. alphaConstants: Color4;
  26019. /**
  26020. * Animations to be used for the post processing
  26021. */
  26022. animations: Animation[];
  26023. /**
  26024. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26025. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26026. */
  26027. enablePixelPerfectMode: boolean;
  26028. /**
  26029. * Force the postprocess to be applied without taking in account viewport
  26030. */
  26031. forceFullscreenViewport: boolean;
  26032. /**
  26033. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26034. */
  26035. scaleMode: number;
  26036. /**
  26037. * Force textures to be a power of two (default: false)
  26038. */
  26039. alwaysForcePOT: boolean;
  26040. /**
  26041. * Number of sample textures (default: 1)
  26042. */
  26043. samples: number;
  26044. /**
  26045. * Modify the scale of the post process to be the same as the viewport (default: false)
  26046. */
  26047. adaptScaleToCurrentViewport: boolean;
  26048. private _camera;
  26049. private _scene;
  26050. private _engine;
  26051. private _options;
  26052. private _reusable;
  26053. private _textureType;
  26054. /**
  26055. * Smart array of input and output textures for the post process.
  26056. */
  26057. _textures: SmartArray<InternalTexture>;
  26058. /**
  26059. * The index in _textures that corresponds to the output texture.
  26060. */
  26061. _currentRenderTextureInd: number;
  26062. private _effect;
  26063. private _samplers;
  26064. private _fragmentUrl;
  26065. private _vertexUrl;
  26066. private _parameters;
  26067. private _scaleRatio;
  26068. protected _indexParameters: any;
  26069. private _shareOutputWithPostProcess;
  26070. private _texelSize;
  26071. private _forcedOutputTexture;
  26072. /**
  26073. * An event triggered when the postprocess is activated.
  26074. */
  26075. onActivateObservable: Observable<Camera>;
  26076. private _onActivateObserver;
  26077. /**
  26078. * A function that is added to the onActivateObservable
  26079. */
  26080. onActivate: Nullable<(camera: Camera) => void>;
  26081. /**
  26082. * An event triggered when the postprocess changes its size.
  26083. */
  26084. onSizeChangedObservable: Observable<PostProcess>;
  26085. private _onSizeChangedObserver;
  26086. /**
  26087. * A function that is added to the onSizeChangedObservable
  26088. */
  26089. onSizeChanged: (postProcess: PostProcess) => void;
  26090. /**
  26091. * An event triggered when the postprocess applies its effect.
  26092. */
  26093. onApplyObservable: Observable<Effect>;
  26094. private _onApplyObserver;
  26095. /**
  26096. * A function that is added to the onApplyObservable
  26097. */
  26098. onApply: (effect: Effect) => void;
  26099. /**
  26100. * An event triggered before rendering the postprocess
  26101. */
  26102. onBeforeRenderObservable: Observable<Effect>;
  26103. private _onBeforeRenderObserver;
  26104. /**
  26105. * A function that is added to the onBeforeRenderObservable
  26106. */
  26107. onBeforeRender: (effect: Effect) => void;
  26108. /**
  26109. * An event triggered after rendering the postprocess
  26110. */
  26111. onAfterRenderObservable: Observable<Effect>;
  26112. private _onAfterRenderObserver;
  26113. /**
  26114. * A function that is added to the onAfterRenderObservable
  26115. */
  26116. onAfterRender: (efect: Effect) => void;
  26117. /**
  26118. * 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
  26119. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26120. */
  26121. inputTexture: InternalTexture;
  26122. /**
  26123. * Gets the camera which post process is applied to.
  26124. * @returns The camera the post process is applied to.
  26125. */
  26126. getCamera(): Camera;
  26127. /**
  26128. * Gets the texel size of the postprocess.
  26129. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26130. */
  26131. readonly texelSize: Vector2;
  26132. /**
  26133. * Creates a new instance PostProcess
  26134. * @param name The name of the PostProcess.
  26135. * @param fragmentUrl The url of the fragment shader to be used.
  26136. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26137. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26138. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26139. * @param camera The camera to apply the render pass to.
  26140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26141. * @param engine The engine which the post process will be applied. (default: current engine)
  26142. * @param reusable If the post process can be reused on the same frame. (default: false)
  26143. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26144. * @param textureType Type of textures used when performing the post process. (default: 0)
  26145. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26146. * @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
  26147. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26148. */
  26149. 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);
  26150. /**
  26151. * Gets the engine which this post process belongs to.
  26152. * @returns The engine the post process was enabled with.
  26153. */
  26154. getEngine(): Engine;
  26155. /**
  26156. * The effect that is created when initializing the post process.
  26157. * @returns The created effect corrisponding the the postprocess.
  26158. */
  26159. getEffect(): Effect;
  26160. /**
  26161. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26162. * @param postProcess The post process to share the output with.
  26163. * @returns This post process.
  26164. */
  26165. shareOutputWith(postProcess: PostProcess): PostProcess;
  26166. /**
  26167. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26168. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26169. */
  26170. useOwnOutput(): void;
  26171. /**
  26172. * Updates the effect with the current post process compile time values and recompiles the shader.
  26173. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26174. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26175. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26176. * @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
  26177. * @param onCompiled Called when the shader has been compiled.
  26178. * @param onError Called if there is an error when compiling a shader.
  26179. */
  26180. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26181. /**
  26182. * The post process is reusable if it can be used multiple times within one frame.
  26183. * @returns If the post process is reusable
  26184. */
  26185. isReusable(): boolean;
  26186. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26187. markTextureDirty(): void;
  26188. /**
  26189. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26190. * 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.
  26191. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26192. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26193. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26194. * @returns The target texture that was bound to be written to.
  26195. */
  26196. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26197. /**
  26198. * If the post process is supported.
  26199. */
  26200. readonly isSupported: boolean;
  26201. /**
  26202. * The aspect ratio of the output texture.
  26203. */
  26204. readonly aspectRatio: number;
  26205. /**
  26206. * Get a value indicating if the post-process is ready to be used
  26207. * @returns true if the post-process is ready (shader is compiled)
  26208. */
  26209. isReady(): boolean;
  26210. /**
  26211. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26212. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26213. */
  26214. apply(): Nullable<Effect>;
  26215. private _disposeTextures();
  26216. /**
  26217. * Disposes the post process.
  26218. * @param camera The camera to dispose the post process on.
  26219. */
  26220. dispose(camera?: Camera): void;
  26221. }
  26222. }
  26223. declare module BABYLON {
  26224. /**
  26225. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26226. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26227. */
  26228. class PostProcessManager {
  26229. private _scene;
  26230. private _indexBuffer;
  26231. private _vertexBuffers;
  26232. /**
  26233. * Creates a new instance PostProcess
  26234. * @param scene The scene that the post process is associated with.
  26235. */
  26236. constructor(scene: Scene);
  26237. private _prepareBuffers();
  26238. private _buildIndexBuffer();
  26239. /**
  26240. * Rebuilds the vertex buffers of the manager.
  26241. */
  26242. _rebuild(): void;
  26243. /**
  26244. * Prepares a frame to be run through a post process.
  26245. * @param sourceTexture The input texture to the post procesess. (default: null)
  26246. * @param postProcesses An array of post processes to be run. (default: null)
  26247. * @returns True if the post processes were able to be run.
  26248. */
  26249. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26250. /**
  26251. * Manually render a set of post processes to a texture.
  26252. * @param postProcesses An array of post processes to be run.
  26253. * @param targetTexture The target texture to render to.
  26254. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26255. */
  26256. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26257. /**
  26258. * Finalize the result of the output of the postprocesses.
  26259. * @param doNotPresent If true the result will not be displayed to the screen.
  26260. * @param targetTexture The target texture to render to.
  26261. * @param faceIndex The index of the face to bind the target texture to.
  26262. * @param postProcesses The array of post processes to render.
  26263. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26264. */
  26265. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26266. /**
  26267. * Disposes of the post process manager.
  26268. */
  26269. dispose(): void;
  26270. }
  26271. }
  26272. declare module BABYLON {
  26273. class RefractionPostProcess extends PostProcess {
  26274. color: Color3;
  26275. depth: number;
  26276. colorLevel: number;
  26277. private _refTexture;
  26278. private _ownRefractionTexture;
  26279. /**
  26280. * Gets or sets the refraction texture
  26281. * Please note that you are responsible for disposing the texture if you set it manually
  26282. */
  26283. refractionTexture: Texture;
  26284. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26285. dispose(camera: Camera): void;
  26286. }
  26287. }
  26288. declare module BABYLON {
  26289. /**
  26290. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26291. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26292. */
  26293. class SharpenPostProcess extends PostProcess {
  26294. /**
  26295. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26296. */
  26297. colorAmount: number;
  26298. /**
  26299. * How much sharpness should be applied (default: 0.3)
  26300. */
  26301. edgeAmount: number;
  26302. /**
  26303. * Creates a new instance ConvolutionPostProcess
  26304. * @param name The name of the effect.
  26305. * @param options The required width/height ratio to downsize to before computing the render pass.
  26306. * @param camera The camera to apply the render pass to.
  26307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26308. * @param engine The engine which the post process will be applied. (default: current engine)
  26309. * @param reusable If the post process can be reused on the same frame. (default: false)
  26310. * @param textureType Type of textures used when performing the post process. (default: 0)
  26311. * @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)
  26312. */
  26313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26314. }
  26315. }
  26316. declare module BABYLON {
  26317. class StereoscopicInterlacePostProcess extends PostProcess {
  26318. private _stepSize;
  26319. private _passedProcess;
  26320. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26321. }
  26322. }
  26323. declare module BABYLON {
  26324. /** Defines operator used for tonemapping */
  26325. enum TonemappingOperator {
  26326. /** Hable */
  26327. Hable = 0,
  26328. /** Reinhard */
  26329. Reinhard = 1,
  26330. /** HejiDawson */
  26331. HejiDawson = 2,
  26332. /** Photographic */
  26333. Photographic = 3,
  26334. }
  26335. /**
  26336. * Defines a post process to apply tone mapping
  26337. */
  26338. class TonemapPostProcess extends PostProcess {
  26339. private _operator;
  26340. /** Defines the required exposure adjustement */
  26341. exposureAdjustment: number;
  26342. /**
  26343. * Creates a new TonemapPostProcess
  26344. * @param name defines the name of the postprocess
  26345. * @param _operator defines the operator to use
  26346. * @param exposureAdjustment defines the required exposure adjustement
  26347. * @param camera defines the camera to use (can be null)
  26348. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26349. * @param engine defines the hosting engine (can be ignore if camera is set)
  26350. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26351. */
  26352. constructor(name: string, _operator: TonemappingOperator,
  26353. /** Defines the required exposure adjustement */
  26354. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26355. }
  26356. }
  26357. declare module BABYLON {
  26358. class VolumetricLightScatteringPostProcess extends PostProcess {
  26359. private _volumetricLightScatteringPass;
  26360. private _volumetricLightScatteringRTT;
  26361. private _viewPort;
  26362. private _screenCoordinates;
  26363. private _cachedDefines;
  26364. /**
  26365. * If not undefined, the mesh position is computed from the attached node position
  26366. */
  26367. attachedNode: {
  26368. position: Vector3;
  26369. };
  26370. /**
  26371. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26372. */
  26373. customMeshPosition: Vector3;
  26374. /**
  26375. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26376. */
  26377. useCustomMeshPosition: boolean;
  26378. /**
  26379. * If the post-process should inverse the light scattering direction
  26380. */
  26381. invert: boolean;
  26382. /**
  26383. * The internal mesh used by the post-process
  26384. */
  26385. mesh: Mesh;
  26386. useDiffuseColor: boolean;
  26387. /**
  26388. * Array containing the excluded meshes not rendered in the internal pass
  26389. */
  26390. excludedMeshes: AbstractMesh[];
  26391. /**
  26392. * Controls the overall intensity of the post-process
  26393. */
  26394. exposure: number;
  26395. /**
  26396. * Dissipates each sample's contribution in range [0, 1]
  26397. */
  26398. decay: number;
  26399. /**
  26400. * Controls the overall intensity of each sample
  26401. */
  26402. weight: number;
  26403. /**
  26404. * Controls the density of each sample
  26405. */
  26406. density: number;
  26407. /**
  26408. * @constructor
  26409. * @param {string} name - The post-process name
  26410. * @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)
  26411. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26412. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26413. * @param {number} samples - The post-process quality, default 100
  26414. * @param {number} samplingMode - The post-process filtering mode
  26415. * @param {BABYLON.Engine} engine - The babylon engine
  26416. * @param {boolean} reusable - If the post-process is reusable
  26417. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26418. */
  26419. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26420. getClassName(): string;
  26421. private _isReady(subMesh, useInstances);
  26422. /**
  26423. * Sets the new light position for light scattering effect
  26424. * @param {BABYLON.Vector3} The new custom light position
  26425. */
  26426. setCustomMeshPosition(position: Vector3): void;
  26427. /**
  26428. * Returns the light position for light scattering effect
  26429. * @return {BABYLON.Vector3} The custom light position
  26430. */
  26431. getCustomMeshPosition(): Vector3;
  26432. /**
  26433. * Disposes the internal assets and detaches the post-process from the camera
  26434. */
  26435. dispose(camera: Camera): void;
  26436. /**
  26437. * Returns the render target texture used by the post-process
  26438. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26439. */
  26440. getPass(): RenderTargetTexture;
  26441. private _meshExcluded(mesh);
  26442. private _createPass(scene, ratio);
  26443. private _updateMeshScreenCoordinates(scene);
  26444. /**
  26445. * Creates a default mesh for the Volumeric Light Scattering post-process
  26446. * @param {string} The mesh name
  26447. * @param {BABYLON.Scene} The scene where to create the mesh
  26448. * @return {BABYLON.Mesh} the default mesh
  26449. */
  26450. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26451. }
  26452. }
  26453. declare module BABYLON {
  26454. class VRDistortionCorrectionPostProcess extends PostProcess {
  26455. private _isRightEye;
  26456. private _distortionFactors;
  26457. private _postProcessScaleFactor;
  26458. private _lensCenterOffset;
  26459. private _scaleIn;
  26460. private _scaleFactor;
  26461. private _lensCenter;
  26462. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26463. }
  26464. }
  26465. declare module BABYLON {
  26466. class BoundingBoxRenderer {
  26467. frontColor: Color3;
  26468. backColor: Color3;
  26469. showBackLines: boolean;
  26470. renderList: SmartArray<BoundingBox>;
  26471. private _scene;
  26472. private _colorShader;
  26473. private _vertexBuffers;
  26474. private _indexBuffer;
  26475. constructor(scene: Scene);
  26476. private _prepareRessources();
  26477. private _createIndexBuffer();
  26478. _rebuild(): void;
  26479. reset(): void;
  26480. render(): void;
  26481. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26482. dispose(): void;
  26483. }
  26484. }
  26485. declare module BABYLON {
  26486. /**
  26487. * This represents a depth renderer in Babylon.
  26488. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26489. */
  26490. class DepthRenderer {
  26491. private _scene;
  26492. private _depthMap;
  26493. private _effect;
  26494. private _cachedDefines;
  26495. private _camera;
  26496. /**
  26497. * Instantiates a depth renderer
  26498. * @param scene The scene the renderer belongs to
  26499. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26500. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26501. */
  26502. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26503. /**
  26504. * Creates the depth rendering effect and checks if the effect is ready.
  26505. * @param subMesh The submesh to be used to render the depth map of
  26506. * @param useInstances If multiple world instances should be used
  26507. * @returns if the depth renderer is ready to render the depth map
  26508. */
  26509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26510. /**
  26511. * Gets the texture which the depth map will be written to.
  26512. * @returns The depth map texture
  26513. */
  26514. getDepthMap(): RenderTargetTexture;
  26515. /**
  26516. * Disposes of the depth renderer.
  26517. */
  26518. dispose(): void;
  26519. }
  26520. }
  26521. declare module BABYLON {
  26522. class EdgesRenderer {
  26523. edgesWidthScalerForOrthographic: number;
  26524. edgesWidthScalerForPerspective: number;
  26525. private _source;
  26526. private _linesPositions;
  26527. private _linesNormals;
  26528. private _linesIndices;
  26529. private _epsilon;
  26530. private _indicesCount;
  26531. private _lineShader;
  26532. private _ib;
  26533. private _buffers;
  26534. private _checkVerticesInsteadOfIndices;
  26535. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26536. isEnabled: boolean;
  26537. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26538. private _prepareRessources();
  26539. _rebuild(): void;
  26540. dispose(): void;
  26541. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26542. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26543. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26544. _generateEdgesLines(): void;
  26545. render(): void;
  26546. }
  26547. }
  26548. declare module BABYLON {
  26549. /**
  26550. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26551. */
  26552. class GeometryBufferRenderer {
  26553. private _scene;
  26554. private _multiRenderTarget;
  26555. private _ratio;
  26556. private _enablePosition;
  26557. protected _effect: Effect;
  26558. protected _cachedDefines: string;
  26559. /**
  26560. * Set the render list (meshes to be rendered) used in the G buffer.
  26561. */
  26562. renderList: Mesh[];
  26563. /**
  26564. * Gets wether or not G buffer are supported by the running hardware.
  26565. * This requires draw buffer supports
  26566. */
  26567. readonly isSupported: boolean;
  26568. /**
  26569. * Gets wether or not position are enabled for the G buffer.
  26570. */
  26571. /**
  26572. * Sets wether or not position are enabled for the G buffer.
  26573. */
  26574. enablePosition: boolean;
  26575. /**
  26576. * Gets the scene associated with the buffer.
  26577. */
  26578. readonly scene: Scene;
  26579. /**
  26580. * Gets the ratio used by the buffer during its creation.
  26581. * How big is the buffer related to the main canvas.
  26582. */
  26583. readonly ratio: number;
  26584. /**
  26585. * Creates a new G Buffer for the scene
  26586. * @param scene The scene the buffer belongs to
  26587. * @param ratio How big is the buffer related to the main canvas.
  26588. */
  26589. constructor(scene: Scene, ratio?: number);
  26590. /**
  26591. * Checks wether everything is ready to render a submesh to the G buffer.
  26592. * @param subMesh the submesh to check readiness for
  26593. * @param useInstances is the mesh drawn using instance or not
  26594. * @returns true if ready otherwise false
  26595. */
  26596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26597. /**
  26598. * Gets the current underlying G Buffer.
  26599. * @returns the buffer
  26600. */
  26601. getGBuffer(): MultiRenderTarget;
  26602. /**
  26603. * Gets the number of samples used to render the buffer (anti aliasing).
  26604. */
  26605. /**
  26606. * Sets the number of samples used to render the buffer (anti aliasing).
  26607. */
  26608. samples: number;
  26609. /**
  26610. * Disposes the renderer and frees up associated resources.
  26611. */
  26612. dispose(): void;
  26613. protected _createRenderTargets(): void;
  26614. }
  26615. }
  26616. declare module BABYLON {
  26617. class OutlineRenderer {
  26618. private _scene;
  26619. private _effect;
  26620. private _cachedDefines;
  26621. zOffset: number;
  26622. constructor(scene: Scene);
  26623. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26624. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26625. }
  26626. }
  26627. declare module BABYLON {
  26628. class RenderingGroup {
  26629. index: number;
  26630. private _scene;
  26631. private _opaqueSubMeshes;
  26632. private _transparentSubMeshes;
  26633. private _alphaTestSubMeshes;
  26634. private _depthOnlySubMeshes;
  26635. private _particleSystems;
  26636. private _spriteManagers;
  26637. private _opaqueSortCompareFn;
  26638. private _alphaTestSortCompareFn;
  26639. private _transparentSortCompareFn;
  26640. private _renderOpaque;
  26641. private _renderAlphaTest;
  26642. private _renderTransparent;
  26643. private _edgesRenderers;
  26644. onBeforeTransparentRendering: () => void;
  26645. /**
  26646. * Set the opaque sort comparison function.
  26647. * If null the sub meshes will be render in the order they were created
  26648. */
  26649. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26650. /**
  26651. * Set the alpha test sort comparison function.
  26652. * If null the sub meshes will be render in the order they were created
  26653. */
  26654. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26655. /**
  26656. * Set the transparent sort comparison function.
  26657. * If null the sub meshes will be render in the order they were created
  26658. */
  26659. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26660. /**
  26661. * Creates a new rendering group.
  26662. * @param index The rendering group index
  26663. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26664. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26665. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26666. */
  26667. 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>);
  26668. /**
  26669. * Render all the sub meshes contained in the group.
  26670. * @param customRenderFunction Used to override the default render behaviour of the group.
  26671. * @returns true if rendered some submeshes.
  26672. */
  26673. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26674. /**
  26675. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26676. * @param subMeshes The submeshes to render
  26677. */
  26678. private renderOpaqueSorted(subMeshes);
  26679. /**
  26680. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26681. * @param subMeshes The submeshes to render
  26682. */
  26683. private renderAlphaTestSorted(subMeshes);
  26684. /**
  26685. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26686. * @param subMeshes The submeshes to render
  26687. */
  26688. private renderTransparentSorted(subMeshes);
  26689. /**
  26690. * Renders the submeshes in a specified order.
  26691. * @param subMeshes The submeshes to sort before render
  26692. * @param sortCompareFn The comparison function use to sort
  26693. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26694. * @param transparent Specifies to activate blending if true
  26695. */
  26696. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26697. /**
  26698. * Renders the submeshes in the order they were dispatched (no sort applied).
  26699. * @param subMeshes The submeshes to render
  26700. */
  26701. private static renderUnsorted(subMeshes);
  26702. /**
  26703. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26704. * are rendered back to front if in the same alpha index.
  26705. *
  26706. * @param a The first submesh
  26707. * @param b The second submesh
  26708. * @returns The result of the comparison
  26709. */
  26710. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26711. /**
  26712. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26713. * are rendered back to front.
  26714. *
  26715. * @param a The first submesh
  26716. * @param b The second submesh
  26717. * @returns The result of the comparison
  26718. */
  26719. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26720. /**
  26721. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26722. * are rendered front to back (prevent overdraw).
  26723. *
  26724. * @param a The first submesh
  26725. * @param b The second submesh
  26726. * @returns The result of the comparison
  26727. */
  26728. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26729. /**
  26730. * Resets the different lists of submeshes to prepare a new frame.
  26731. */
  26732. prepare(): void;
  26733. dispose(): void;
  26734. /**
  26735. * Inserts the submesh in its correct queue depending on its material.
  26736. * @param subMesh The submesh to dispatch
  26737. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26738. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26739. */
  26740. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26741. dispatchSprites(spriteManager: SpriteManager): void;
  26742. dispatchParticles(particleSystem: IParticleSystem): void;
  26743. private _renderParticles(activeMeshes);
  26744. private _renderSprites();
  26745. }
  26746. }
  26747. declare module BABYLON {
  26748. class RenderingManager {
  26749. /**
  26750. * The max id used for rendering groups (not included)
  26751. */
  26752. static MAX_RENDERINGGROUPS: number;
  26753. /**
  26754. * The min id used for rendering groups (included)
  26755. */
  26756. static MIN_RENDERINGGROUPS: number;
  26757. /**
  26758. * Used to globally prevent autoclearing scenes.
  26759. */
  26760. static AUTOCLEAR: boolean;
  26761. private _scene;
  26762. private _renderingGroups;
  26763. private _depthStencilBufferAlreadyCleaned;
  26764. private _autoClearDepthStencil;
  26765. private _customOpaqueSortCompareFn;
  26766. private _customAlphaTestSortCompareFn;
  26767. private _customTransparentSortCompareFn;
  26768. private _renderinGroupInfo;
  26769. constructor(scene: Scene);
  26770. private _clearDepthStencilBuffer(depth?, stencil?);
  26771. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26772. reset(): void;
  26773. dispose(): void;
  26774. /**
  26775. * Clear the info related to rendering groups preventing retention points during dispose.
  26776. */
  26777. freeRenderingGroups(): void;
  26778. private _prepareRenderingGroup(renderingGroupId);
  26779. dispatchSprites(spriteManager: SpriteManager): void;
  26780. dispatchParticles(particleSystem: IParticleSystem): void;
  26781. /**
  26782. * @param subMesh The submesh to dispatch
  26783. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26784. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26785. */
  26786. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26787. /**
  26788. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26789. * This allowed control for front to back rendering or reversly depending of the special needs.
  26790. *
  26791. * @param renderingGroupId The rendering group id corresponding to its index
  26792. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26793. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26794. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26795. */
  26796. 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;
  26797. /**
  26798. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26799. *
  26800. * @param renderingGroupId The rendering group id corresponding to its index
  26801. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26802. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26803. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26804. */
  26805. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26806. }
  26807. }
  26808. declare module BABYLON {
  26809. /**
  26810. * Renders a layer on top of an existing scene
  26811. */
  26812. class UtilityLayerRenderer implements IDisposable {
  26813. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26814. /**
  26815. * The scene that is rendered on top of the original scene
  26816. */
  26817. utilityLayerScene: Scene;
  26818. /**
  26819. * If the utility layer should automatically be rendered on top of existing scene
  26820. */
  26821. shouldRender: boolean;
  26822. private _afterRenderObserver;
  26823. private _sceneDisposeObserver;
  26824. /**
  26825. * Instantiates a UtilityLayerRenderer
  26826. * @param originalScene the original scene that will be rendered on top of
  26827. */
  26828. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26829. /**
  26830. * Renders the utility layers scene on top of the original scene
  26831. */
  26832. render(): void;
  26833. /**
  26834. * Disposes of the renderer
  26835. */
  26836. dispose(): void;
  26837. private _updateCamera();
  26838. }
  26839. }
  26840. declare module BABYLON {
  26841. /**
  26842. * @hidden
  26843. **/
  26844. class _AlphaState {
  26845. private _isAlphaBlendDirty;
  26846. private _isBlendFunctionParametersDirty;
  26847. private _isBlendEquationParametersDirty;
  26848. private _isBlendConstantsDirty;
  26849. private _alphaBlend;
  26850. private _blendFunctionParameters;
  26851. private _blendEquationParameters;
  26852. private _blendConstants;
  26853. /**
  26854. * Initializes the state.
  26855. */
  26856. constructor();
  26857. readonly isDirty: boolean;
  26858. alphaBlend: boolean;
  26859. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26860. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26861. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26862. reset(): void;
  26863. apply(gl: WebGLRenderingContext): void;
  26864. }
  26865. }
  26866. declare module BABYLON {
  26867. /**
  26868. * @hidden
  26869. **/
  26870. class _DepthCullingState {
  26871. private _isDepthTestDirty;
  26872. private _isDepthMaskDirty;
  26873. private _isDepthFuncDirty;
  26874. private _isCullFaceDirty;
  26875. private _isCullDirty;
  26876. private _isZOffsetDirty;
  26877. private _isFrontFaceDirty;
  26878. private _depthTest;
  26879. private _depthMask;
  26880. private _depthFunc;
  26881. private _cull;
  26882. private _cullFace;
  26883. private _zOffset;
  26884. private _frontFace;
  26885. /**
  26886. * Initializes the state.
  26887. */
  26888. constructor();
  26889. readonly isDirty: boolean;
  26890. zOffset: number;
  26891. cullFace: Nullable<number>;
  26892. cull: Nullable<boolean>;
  26893. depthFunc: Nullable<number>;
  26894. depthMask: boolean;
  26895. depthTest: boolean;
  26896. frontFace: Nullable<number>;
  26897. reset(): void;
  26898. apply(gl: WebGLRenderingContext): void;
  26899. }
  26900. }
  26901. declare module BABYLON {
  26902. /**
  26903. * @hidden
  26904. **/
  26905. class _StencilState {
  26906. private _isStencilTestDirty;
  26907. private _isStencilMaskDirty;
  26908. private _isStencilFuncDirty;
  26909. private _isStencilOpDirty;
  26910. private _stencilTest;
  26911. private _stencilMask;
  26912. private _stencilFunc;
  26913. private _stencilFuncRef;
  26914. private _stencilFuncMask;
  26915. private _stencilOpStencilFail;
  26916. private _stencilOpDepthFail;
  26917. private _stencilOpStencilDepthPass;
  26918. readonly isDirty: boolean;
  26919. stencilFunc: number;
  26920. stencilFuncRef: number;
  26921. stencilFuncMask: number;
  26922. stencilOpStencilFail: number;
  26923. stencilOpDepthFail: number;
  26924. stencilOpStencilDepthPass: number;
  26925. stencilMask: number;
  26926. stencilTest: boolean;
  26927. constructor();
  26928. reset(): void;
  26929. apply(gl: WebGLRenderingContext): void;
  26930. }
  26931. }
  26932. declare module BABYLON {
  26933. class Sprite {
  26934. name: string;
  26935. position: Vector3;
  26936. color: Color4;
  26937. width: number;
  26938. height: number;
  26939. angle: number;
  26940. cellIndex: number;
  26941. invertU: number;
  26942. invertV: number;
  26943. disposeWhenFinishedAnimating: boolean;
  26944. animations: Animation[];
  26945. isPickable: boolean;
  26946. actionManager: ActionManager;
  26947. private _animationStarted;
  26948. private _loopAnimation;
  26949. private _fromIndex;
  26950. private _toIndex;
  26951. private _delay;
  26952. private _direction;
  26953. private _manager;
  26954. private _time;
  26955. private _onAnimationEnd;
  26956. size: number;
  26957. constructor(name: string, manager: SpriteManager);
  26958. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26959. stopAnimation(): void;
  26960. _animate(deltaTime: number): void;
  26961. dispose(): void;
  26962. }
  26963. }
  26964. declare module BABYLON {
  26965. class SpriteManager {
  26966. name: string;
  26967. sprites: Sprite[];
  26968. renderingGroupId: number;
  26969. layerMask: number;
  26970. fogEnabled: boolean;
  26971. isPickable: boolean;
  26972. cellWidth: number;
  26973. cellHeight: number;
  26974. /**
  26975. * An event triggered when the manager is disposed.
  26976. */
  26977. onDisposeObservable: Observable<SpriteManager>;
  26978. private _onDisposeObserver;
  26979. onDispose: () => void;
  26980. private _capacity;
  26981. private _spriteTexture;
  26982. private _epsilon;
  26983. private _scene;
  26984. private _vertexData;
  26985. private _buffer;
  26986. private _vertexBuffers;
  26987. private _indexBuffer;
  26988. private _effectBase;
  26989. private _effectFog;
  26990. texture: Texture;
  26991. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26992. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26993. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26994. render(): void;
  26995. dispose(): void;
  26996. }
  26997. }
  26998. declare module BABYLON {
  26999. /**
  27000. * Class used to evalaute queries containing `and` and `or` operators
  27001. */
  27002. class AndOrNotEvaluator {
  27003. /**
  27004. * Evaluate a query
  27005. * @param query defines the query to evaluate
  27006. * @param evaluateCallback defines the callback used to filter result
  27007. * @returns true if the query matches
  27008. */
  27009. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27010. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27011. private static _SimplifyNegation(booleanString);
  27012. }
  27013. }
  27014. declare module BABYLON {
  27015. /**
  27016. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27017. */
  27018. enum AssetTaskState {
  27019. /**
  27020. * Initialization
  27021. */
  27022. INIT = 0,
  27023. /**
  27024. * Running
  27025. */
  27026. RUNNING = 1,
  27027. /**
  27028. * Done
  27029. */
  27030. DONE = 2,
  27031. /**
  27032. * Error
  27033. */
  27034. ERROR = 3,
  27035. }
  27036. /**
  27037. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27038. */
  27039. abstract class AbstractAssetTask {
  27040. /**
  27041. * Task name
  27042. */ name: string;
  27043. /**
  27044. * Callback called when the task is successful
  27045. */
  27046. onSuccess: (task: any) => void;
  27047. /**
  27048. * Callback called when the task is not successful
  27049. */
  27050. onError: (task: any, message?: string, exception?: any) => void;
  27051. /**
  27052. * Creates a new {BABYLON.AssetsManager}
  27053. * @param name defines the name of the task
  27054. */
  27055. constructor(
  27056. /**
  27057. * Task name
  27058. */ name: string);
  27059. private _isCompleted;
  27060. private _taskState;
  27061. private _errorObject;
  27062. /**
  27063. * Get if the task is completed
  27064. */
  27065. readonly isCompleted: boolean;
  27066. /**
  27067. * Gets the current state of the task
  27068. */
  27069. readonly taskState: AssetTaskState;
  27070. /**
  27071. * Gets the current error object (if task is in error)
  27072. */
  27073. readonly errorObject: {
  27074. message?: string;
  27075. exception?: any;
  27076. };
  27077. /**
  27078. * Internal only
  27079. * @hidden
  27080. */
  27081. _setErrorObject(message?: string, exception?: any): void;
  27082. /**
  27083. * Execute the current task
  27084. * @param scene defines the scene where you want your assets to be loaded
  27085. * @param onSuccess is a callback called when the task is successfully executed
  27086. * @param onError is a callback called if an error occurs
  27087. */
  27088. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27089. /**
  27090. * Execute the current task
  27091. * @param scene defines the scene where you want your assets to be loaded
  27092. * @param onSuccess is a callback called when the task is successfully executed
  27093. * @param onError is a callback called if an error occurs
  27094. */
  27095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27096. private onErrorCallback(onError, message?, exception?);
  27097. private onDoneCallback(onSuccess, onError);
  27098. }
  27099. /**
  27100. * Define the interface used by progress events raised during assets loading
  27101. */
  27102. interface IAssetsProgressEvent {
  27103. /**
  27104. * Defines the number of remaining tasks to process
  27105. */
  27106. remainingCount: number;
  27107. /**
  27108. * Defines the total number of tasks
  27109. */
  27110. totalCount: number;
  27111. /**
  27112. * Defines the task that was just processed
  27113. */
  27114. task: AbstractAssetTask;
  27115. }
  27116. /**
  27117. * Class used to share progress information about assets loading
  27118. */
  27119. class AssetsProgressEvent implements IAssetsProgressEvent {
  27120. /**
  27121. * Defines the number of remaining tasks to process
  27122. */
  27123. remainingCount: number;
  27124. /**
  27125. * Defines the total number of tasks
  27126. */
  27127. totalCount: number;
  27128. /**
  27129. * Defines the task that was just processed
  27130. */
  27131. task: AbstractAssetTask;
  27132. /**
  27133. * Creates a {BABYLON.AssetsProgressEvent}
  27134. * @param remainingCount defines the number of remaining tasks to process
  27135. * @param totalCount defines the total number of tasks
  27136. * @param task defines the task that was just processed
  27137. */
  27138. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27139. }
  27140. /**
  27141. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27142. */
  27143. class MeshAssetTask extends AbstractAssetTask {
  27144. /**
  27145. * Defines the name of the task
  27146. */
  27147. name: string;
  27148. /**
  27149. * Defines the list of mesh's names you want to load
  27150. */
  27151. meshesNames: any;
  27152. /**
  27153. * Defines the root url to use as a base to load your meshes and associated resources
  27154. */
  27155. rootUrl: string;
  27156. /**
  27157. * Defines the filename of the scene to load from
  27158. */
  27159. sceneFilename: string;
  27160. /**
  27161. * Gets the list of loaded meshes
  27162. */
  27163. loadedMeshes: Array<AbstractMesh>;
  27164. /**
  27165. * Gets the list of loaded particle systems
  27166. */
  27167. loadedParticleSystems: Array<ParticleSystem>;
  27168. /**
  27169. * Gets the list of loaded skeletons
  27170. */
  27171. loadedSkeletons: Array<Skeleton>;
  27172. /**
  27173. * Callback called when the task is successful
  27174. */
  27175. onSuccess: (task: MeshAssetTask) => void;
  27176. /**
  27177. * Callback called when the task is successful
  27178. */
  27179. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27180. /**
  27181. * Creates a new {BABYLON.MeshAssetTask}
  27182. * @param name defines the name of the task
  27183. * @param meshesNames defines the list of mesh's names you want to load
  27184. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27185. * @param sceneFilename defines the filename of the scene to load from
  27186. */
  27187. constructor(
  27188. /**
  27189. * Defines the name of the task
  27190. */
  27191. name: string,
  27192. /**
  27193. * Defines the list of mesh's names you want to load
  27194. */
  27195. meshesNames: any,
  27196. /**
  27197. * Defines the root url to use as a base to load your meshes and associated resources
  27198. */
  27199. rootUrl: string,
  27200. /**
  27201. * Defines the filename of the scene to load from
  27202. */
  27203. sceneFilename: string);
  27204. /**
  27205. * Execute the current task
  27206. * @param scene defines the scene where you want your assets to be loaded
  27207. * @param onSuccess is a callback called when the task is successfully executed
  27208. * @param onError is a callback called if an error occurs
  27209. */
  27210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27211. }
  27212. /**
  27213. * Define a task used by {BABYLON.AssetsManager} to load text content
  27214. */
  27215. class TextFileAssetTask extends AbstractAssetTask {
  27216. /**
  27217. * Defines the name of the task
  27218. */
  27219. name: string;
  27220. /**
  27221. * Defines the location of the file to load
  27222. */
  27223. url: string;
  27224. /**
  27225. * Gets the loaded text string
  27226. */
  27227. text: string;
  27228. /**
  27229. * Callback called when the task is successful
  27230. */
  27231. onSuccess: (task: TextFileAssetTask) => void;
  27232. /**
  27233. * Callback called when the task is successful
  27234. */
  27235. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27236. /**
  27237. * Creates a new TextFileAssetTask object
  27238. * @param name defines the name of the task
  27239. * @param url defines the location of the file to load
  27240. */
  27241. constructor(
  27242. /**
  27243. * Defines the name of the task
  27244. */
  27245. name: string,
  27246. /**
  27247. * Defines the location of the file to load
  27248. */
  27249. url: string);
  27250. /**
  27251. * Execute the current task
  27252. * @param scene defines the scene where you want your assets to be loaded
  27253. * @param onSuccess is a callback called when the task is successfully executed
  27254. * @param onError is a callback called if an error occurs
  27255. */
  27256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27257. }
  27258. /**
  27259. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27260. */
  27261. class BinaryFileAssetTask extends AbstractAssetTask {
  27262. /**
  27263. * Defines the name of the task
  27264. */
  27265. name: string;
  27266. /**
  27267. * Defines the location of the file to load
  27268. */
  27269. url: string;
  27270. /**
  27271. * Gets the lodaded data (as an array buffer)
  27272. */
  27273. data: ArrayBuffer;
  27274. /**
  27275. * Callback called when the task is successful
  27276. */
  27277. onSuccess: (task: BinaryFileAssetTask) => void;
  27278. /**
  27279. * Callback called when the task is successful
  27280. */
  27281. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27282. /**
  27283. * Creates a new BinaryFileAssetTask object
  27284. * @param name defines the name of the new task
  27285. * @param url defines the location of the file to load
  27286. */
  27287. constructor(
  27288. /**
  27289. * Defines the name of the task
  27290. */
  27291. name: string,
  27292. /**
  27293. * Defines the location of the file to load
  27294. */
  27295. url: string);
  27296. /**
  27297. * Execute the current task
  27298. * @param scene defines the scene where you want your assets to be loaded
  27299. * @param onSuccess is a callback called when the task is successfully executed
  27300. * @param onError is a callback called if an error occurs
  27301. */
  27302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27303. }
  27304. /**
  27305. * Define a task used by {BABYLON.AssetsManager} to load images
  27306. */
  27307. class ImageAssetTask extends AbstractAssetTask {
  27308. /**
  27309. * Defines the name of the task
  27310. */
  27311. name: string;
  27312. /**
  27313. * Defines the location of the image to load
  27314. */
  27315. url: string;
  27316. /**
  27317. * Gets the loaded images
  27318. */
  27319. image: HTMLImageElement;
  27320. /**
  27321. * Callback called when the task is successful
  27322. */
  27323. onSuccess: (task: ImageAssetTask) => void;
  27324. /**
  27325. * Callback called when the task is successful
  27326. */
  27327. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27328. /**
  27329. * Creates a new ImageAssetTask
  27330. * @param name defines the name of the task
  27331. * @param url defines the location of the image to load
  27332. */
  27333. constructor(
  27334. /**
  27335. * Defines the name of the task
  27336. */
  27337. name: string,
  27338. /**
  27339. * Defines the location of the image to load
  27340. */
  27341. url: string);
  27342. /**
  27343. * Execute the current task
  27344. * @param scene defines the scene where you want your assets to be loaded
  27345. * @param onSuccess is a callback called when the task is successfully executed
  27346. * @param onError is a callback called if an error occurs
  27347. */
  27348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27349. }
  27350. /**
  27351. * Defines the interface used by texture loading tasks
  27352. */
  27353. interface ITextureAssetTask<TEX extends BaseTexture> {
  27354. /**
  27355. * Gets the loaded texture
  27356. */
  27357. texture: TEX;
  27358. }
  27359. /**
  27360. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27361. */
  27362. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27363. /**
  27364. * Defines the name of the task
  27365. */
  27366. name: string;
  27367. /**
  27368. * Defines the location of the file to load
  27369. */
  27370. url: string;
  27371. /**
  27372. * Defines if mipmap should not be generated (default is false)
  27373. */
  27374. noMipmap: boolean | undefined;
  27375. /**
  27376. * Defines if texture must be inverted on Y axis (default is false)
  27377. */
  27378. invertY: boolean | undefined;
  27379. /**
  27380. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27381. */
  27382. samplingMode: number;
  27383. /**
  27384. * Gets the loaded texture
  27385. */
  27386. texture: Texture;
  27387. /**
  27388. * Callback called when the task is successful
  27389. */
  27390. onSuccess: (task: TextureAssetTask) => void;
  27391. /**
  27392. * Callback called when the task is successful
  27393. */
  27394. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27395. /**
  27396. * Creates a new TextureAssetTask object
  27397. * @param name defines the name of the task
  27398. * @param url defines the location of the file to load
  27399. * @param noMipmap defines if mipmap should not be generated (default is false)
  27400. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27401. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27402. */
  27403. constructor(
  27404. /**
  27405. * Defines the name of the task
  27406. */
  27407. name: string,
  27408. /**
  27409. * Defines the location of the file to load
  27410. */
  27411. url: string,
  27412. /**
  27413. * Defines if mipmap should not be generated (default is false)
  27414. */
  27415. noMipmap?: boolean | undefined,
  27416. /**
  27417. * Defines if texture must be inverted on Y axis (default is false)
  27418. */
  27419. invertY?: boolean | undefined,
  27420. /**
  27421. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27422. */
  27423. samplingMode?: number);
  27424. /**
  27425. * Execute the current task
  27426. * @param scene defines the scene where you want your assets to be loaded
  27427. * @param onSuccess is a callback called when the task is successfully executed
  27428. * @param onError is a callback called if an error occurs
  27429. */
  27430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27431. }
  27432. /**
  27433. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27434. */
  27435. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27436. /**
  27437. * Defines the name of the task
  27438. */
  27439. name: string;
  27440. /**
  27441. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27442. */
  27443. url: string;
  27444. /**
  27445. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27446. */
  27447. extensions: string[] | undefined;
  27448. /**
  27449. * Defines if mipmaps should not be generated (default is false)
  27450. */
  27451. noMipmap: boolean | undefined;
  27452. /**
  27453. * Defines the explicit list of files (undefined by default)
  27454. */
  27455. files: string[] | undefined;
  27456. /**
  27457. * Gets the loaded texture
  27458. */
  27459. texture: CubeTexture;
  27460. /**
  27461. * Callback called when the task is successful
  27462. */
  27463. onSuccess: (task: CubeTextureAssetTask) => void;
  27464. /**
  27465. * Callback called when the task is successful
  27466. */
  27467. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27468. /**
  27469. * Creates a new CubeTextureAssetTask
  27470. * @param name defines the name of the task
  27471. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27472. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27473. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27474. * @param files defines the explicit list of files (undefined by default)
  27475. */
  27476. constructor(
  27477. /**
  27478. * Defines the name of the task
  27479. */
  27480. name: string,
  27481. /**
  27482. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27483. */
  27484. url: string,
  27485. /**
  27486. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27487. */
  27488. extensions?: string[] | undefined,
  27489. /**
  27490. * Defines if mipmaps should not be generated (default is false)
  27491. */
  27492. noMipmap?: boolean | undefined,
  27493. /**
  27494. * Defines the explicit list of files (undefined by default)
  27495. */
  27496. files?: string[] | undefined);
  27497. /**
  27498. * Execute the current task
  27499. * @param scene defines the scene where you want your assets to be loaded
  27500. * @param onSuccess is a callback called when the task is successfully executed
  27501. * @param onError is a callback called if an error occurs
  27502. */
  27503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27504. }
  27505. /**
  27506. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27507. */
  27508. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27509. /**
  27510. * Defines the name of the task
  27511. */
  27512. name: string;
  27513. /**
  27514. * Defines the location of the file to load
  27515. */
  27516. url: string;
  27517. /**
  27518. * Defines the desired size (the more it increases the longer the generation will be)
  27519. */
  27520. size: number;
  27521. /**
  27522. * Defines if mipmaps should not be generated (default is false)
  27523. */
  27524. noMipmap: boolean;
  27525. /**
  27526. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27527. */
  27528. generateHarmonics: boolean;
  27529. /**
  27530. * 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)
  27531. */
  27532. gammaSpace: boolean;
  27533. /**
  27534. * Internal Use Only
  27535. */
  27536. reserved: boolean;
  27537. /**
  27538. * Gets the loaded texture
  27539. */
  27540. texture: HDRCubeTexture;
  27541. /**
  27542. * Callback called when the task is successful
  27543. */
  27544. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27545. /**
  27546. * Callback called when the task is successful
  27547. */
  27548. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27549. /**
  27550. * Creates a new HDRCubeTextureAssetTask object
  27551. * @param name defines the name of the task
  27552. * @param url defines the location of the file to load
  27553. * @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.
  27554. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27555. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27556. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  27557. * @param reserved Internal use only
  27558. */
  27559. constructor(
  27560. /**
  27561. * Defines the name of the task
  27562. */
  27563. name: string,
  27564. /**
  27565. * Defines the location of the file to load
  27566. */
  27567. url: string,
  27568. /**
  27569. * Defines the desired size (the more it increases the longer the generation will be)
  27570. */
  27571. size: number,
  27572. /**
  27573. * Defines if mipmaps should not be generated (default is false)
  27574. */
  27575. noMipmap?: boolean,
  27576. /**
  27577. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27578. */
  27579. generateHarmonics?: boolean,
  27580. /**
  27581. * 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)
  27582. */
  27583. gammaSpace?: boolean,
  27584. /**
  27585. * Internal Use Only
  27586. */
  27587. reserved?: boolean);
  27588. /**
  27589. * Execute the current task
  27590. * @param scene defines the scene where you want your assets to be loaded
  27591. * @param onSuccess is a callback called when the task is successfully executed
  27592. * @param onError is a callback called if an error occurs
  27593. */
  27594. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27595. }
  27596. /**
  27597. * This class can be used to easily import assets into a scene
  27598. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27599. */
  27600. class AssetsManager {
  27601. private _scene;
  27602. private _isLoading;
  27603. protected _tasks: AbstractAssetTask[];
  27604. protected _waitingTasksCount: number;
  27605. protected _totalTasksCount: number;
  27606. /**
  27607. * Callback called when all tasks are processed
  27608. */
  27609. onFinish: (tasks: AbstractAssetTask[]) => void;
  27610. /**
  27611. * Callback called when a task is successful
  27612. */
  27613. onTaskSuccess: (task: AbstractAssetTask) => void;
  27614. /**
  27615. * Callback called when a task had an error
  27616. */
  27617. onTaskError: (task: AbstractAssetTask) => void;
  27618. /**
  27619. * Callback called when a task is done (whatever the result is)
  27620. */
  27621. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27622. /**
  27623. * Observable called when all tasks are processed
  27624. */
  27625. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27626. /**
  27627. * Observable called when a task had an error
  27628. */
  27629. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27630. /**
  27631. * Observable called when a task is successful
  27632. */
  27633. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27634. /**
  27635. * Observable called when a task is done (whatever the result is)
  27636. */
  27637. onProgressObservable: Observable<IAssetsProgressEvent>;
  27638. /**
  27639. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27641. */
  27642. useDefaultLoadingScreen: boolean;
  27643. /**
  27644. * Creates a new AssetsManager
  27645. * @param scene defines the scene to work on
  27646. */
  27647. constructor(scene: Scene);
  27648. /**
  27649. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27650. * @param taskName defines the name of the new task
  27651. * @param meshesNames defines the name of meshes to load
  27652. * @param rootUrl defines the root url to use to locate files
  27653. * @param sceneFilename defines the filename of the scene file
  27654. * @returns a new {BABYLON.MeshAssetTask} object
  27655. */
  27656. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27657. /**
  27658. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27659. * @param taskName defines the name of the new task
  27660. * @param url defines the url of the file to load
  27661. * @returns a new {BABYLON.TextFileAssetTask} object
  27662. */
  27663. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27664. /**
  27665. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27666. * @param taskName defines the name of the new task
  27667. * @param url defines the url of the file to load
  27668. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27669. */
  27670. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27671. /**
  27672. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27673. * @param taskName defines the name of the new task
  27674. * @param url defines the url of the file to load
  27675. * @returns a new {BABYLON.ImageAssetTask} object
  27676. */
  27677. addImageTask(taskName: string, url: string): ImageAssetTask;
  27678. /**
  27679. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27680. * @param taskName defines the name of the new task
  27681. * @param url defines the url of the file to load
  27682. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27683. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27684. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27685. * @returns a new {BABYLON.TextureAssetTask} object
  27686. */
  27687. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27688. /**
  27689. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27690. * @param taskName defines the name of the new task
  27691. * @param url defines the url of the file to load
  27692. * @param extensions defines the extension to use to load the cube map (can be null)
  27693. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27694. * @param files defines the list of files to load (can be null)
  27695. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27696. */
  27697. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27698. /**
  27699. *
  27700. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27701. * @param taskName defines the name of the new task
  27702. * @param url defines the url of the file to load
  27703. * @param size defines the size you want for the cubemap (can be null)
  27704. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27705. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27706. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  27707. * @param reserved Internal use only
  27708. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27709. */
  27710. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27711. private _decreaseWaitingTasksCount(task);
  27712. private _runTask(task);
  27713. /**
  27714. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27715. * @return the current instance of the {BABYLON.AssetsManager}
  27716. */
  27717. reset(): AssetsManager;
  27718. /**
  27719. * Start the loading process
  27720. * @return the current instance of the {BABYLON.AssetsManager}
  27721. */
  27722. load(): AssetsManager;
  27723. }
  27724. }
  27725. declare module BABYLON {
  27726. /**
  27727. * Class used to enable access to IndexedDB
  27728. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27729. */
  27730. class Database {
  27731. private callbackManifestChecked;
  27732. private currentSceneUrl;
  27733. private db;
  27734. private _enableSceneOffline;
  27735. private _enableTexturesOffline;
  27736. private manifestVersionFound;
  27737. private mustUpdateRessources;
  27738. private hasReachedQuota;
  27739. private isSupported;
  27740. private idbFactory;
  27741. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27742. static IsUASupportingBlobStorage: boolean;
  27743. /** Gets a boolean indicating if Database storate is enabled */
  27744. static IDBStorageEnabled: boolean;
  27745. /**
  27746. * Gets a boolean indicating if scene must be saved in the database
  27747. */
  27748. readonly enableSceneOffline: boolean;
  27749. /**
  27750. * Gets a boolean indicating if textures must be saved in the database
  27751. */
  27752. readonly enableTexturesOffline: boolean;
  27753. /**
  27754. * Creates a new Database
  27755. * @param urlToScene defines the url to load the scene
  27756. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27757. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27758. */
  27759. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27760. private static _ParseURL;
  27761. private static _ReturnFullUrlLocation;
  27762. private _checkManifestFile();
  27763. /**
  27764. * Open the database and make it available
  27765. * @param successCallback defines the callback to call on success
  27766. * @param errorCallback defines the callback to call on error
  27767. */
  27768. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27769. /**
  27770. * Loads an image from the database
  27771. * @param url defines the url to load from
  27772. * @param image defines the target DOM image
  27773. */
  27774. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27775. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27776. private _saveImageIntoDBAsync(url, image);
  27777. private _checkVersionFromDB(url, versionLoaded);
  27778. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27779. private _saveVersionIntoDBAsync(url, callback);
  27780. /**
  27781. * Loads a file from database
  27782. * @param url defines the URL to load from
  27783. * @param sceneLoaded defines a callback to call on success
  27784. * @param progressCallBack defines a callback to call when progress changed
  27785. * @param errorCallback defines a callback to call on error
  27786. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27787. */
  27788. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27789. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27790. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27791. }
  27792. }
  27793. declare module BABYLON {
  27794. interface DDSInfo {
  27795. width: number;
  27796. height: number;
  27797. mipmapCount: number;
  27798. isFourCC: boolean;
  27799. isRGB: boolean;
  27800. isLuminance: boolean;
  27801. isCube: boolean;
  27802. isCompressed: boolean;
  27803. dxgiFormat: number;
  27804. textureType: number;
  27805. /** Sphericle polynomial created for the dds texture */
  27806. sphericalPolynomial?: SphericalPolynomial;
  27807. }
  27808. class DDSTools {
  27809. static StoreLODInAlphaChannel: boolean;
  27810. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27811. private static _FloatView;
  27812. private static _Int32View;
  27813. private static _ToHalfFloat(value);
  27814. private static _FromHalfFloat(value);
  27815. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27816. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27817. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27818. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27819. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27820. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27821. private static _ExtractLongWordOrder(value);
  27822. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27823. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27824. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27825. }
  27826. }
  27827. declare module BABYLON {
  27828. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27829. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27830. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27831. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27832. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27833. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27834. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27835. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27836. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27837. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27838. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27839. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27840. /**
  27841. * Decorator used to define property that can be serialized as reference to a camera
  27842. * @param sourceName defines the name of the property to decorate
  27843. */
  27844. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27845. class SerializationHelper {
  27846. static Serialize<T>(entity: T, serializationObject?: any): any;
  27847. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27848. static Clone<T>(creationFunction: () => T, source: T): T;
  27849. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27850. }
  27851. }
  27852. declare module BABYLON {
  27853. /**
  27854. * Wrapper class for promise with external resolve and reject.
  27855. */
  27856. class Deferred<T> {
  27857. /**
  27858. * The promise associated with this deferred object.
  27859. */
  27860. readonly promise: Promise<T>;
  27861. private _resolve;
  27862. private _reject;
  27863. /**
  27864. * The resolve method of the promise associated with this deferred object.
  27865. */
  27866. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27867. /**
  27868. * The reject method of the promise associated with this deferred object.
  27869. */
  27870. readonly reject: (reason?: any) => void;
  27871. /**
  27872. * Constructor for this deferred object.
  27873. */
  27874. constructor();
  27875. }
  27876. }
  27877. declare module BABYLON {
  27878. class FilesInput {
  27879. static FilesToLoad: {
  27880. [key: string]: File;
  27881. };
  27882. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27883. private _engine;
  27884. private _currentScene;
  27885. private _sceneLoadedCallback;
  27886. private _progressCallback;
  27887. private _additionalRenderLoopLogicCallback;
  27888. private _textureLoadingCallback;
  27889. private _startingProcessingFilesCallback;
  27890. private _onReloadCallback;
  27891. private _errorCallback;
  27892. private _elementToMonitor;
  27893. private _sceneFileToLoad;
  27894. private _filesToLoad;
  27895. 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);
  27896. private _dragEnterHandler;
  27897. private _dragOverHandler;
  27898. private _dropHandler;
  27899. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27900. dispose(): void;
  27901. private renderFunction();
  27902. private drag(e);
  27903. private drop(eventDrop);
  27904. private _traverseFolder(folder, files, remaining, callback);
  27905. private _processFiles(files);
  27906. loadFiles(event: any): void;
  27907. private _processReload();
  27908. reload(): void;
  27909. }
  27910. }
  27911. declare module BABYLON {
  27912. /**
  27913. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27914. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27915. */
  27916. class KhronosTextureContainer {
  27917. arrayBuffer: any;
  27918. static HEADER_LEN: number;
  27919. static COMPRESSED_2D: number;
  27920. static COMPRESSED_3D: number;
  27921. static TEX_2D: number;
  27922. static TEX_3D: number;
  27923. glType: number;
  27924. glTypeSize: number;
  27925. glFormat: number;
  27926. glInternalFormat: number;
  27927. glBaseInternalFormat: number;
  27928. pixelWidth: number;
  27929. pixelHeight: number;
  27930. pixelDepth: number;
  27931. numberOfArrayElements: number;
  27932. numberOfFaces: number;
  27933. numberOfMipmapLevels: number;
  27934. bytesOfKeyValueData: number;
  27935. loadType: number;
  27936. /**
  27937. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27938. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27939. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27940. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27941. */
  27942. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27943. switchEndainness(val: number): number;
  27944. /**
  27945. * It is assumed that the texture has already been created & is currently bound
  27946. */
  27947. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27948. private _upload2DCompressedLevels(gl, loadMipmaps);
  27949. }
  27950. }
  27951. declare module BABYLON {
  27952. /**
  27953. * A class serves as a medium between the observable and its observers
  27954. */
  27955. class EventState {
  27956. /**
  27957. * Create a new EventState
  27958. * @param mask defines the mask associated with this state
  27959. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27960. * @param target defines the original target of the state
  27961. * @param currentTarget defines the current target of the state
  27962. */
  27963. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27964. /**
  27965. * Initialize the current event state
  27966. * @param mask defines the mask associated with this state
  27967. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27968. * @param target defines the original target of the state
  27969. * @param currentTarget defines the current target of the state
  27970. * @returns the current event state
  27971. */
  27972. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27973. /**
  27974. * An Observer can set this property to true to prevent subsequent observers of being notified
  27975. */
  27976. skipNextObservers: boolean;
  27977. /**
  27978. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27979. */
  27980. mask: number;
  27981. /**
  27982. * The object that originally notified the event
  27983. */
  27984. target?: any;
  27985. /**
  27986. * The current object in the bubbling phase
  27987. */
  27988. currentTarget?: any;
  27989. /**
  27990. * This will be populated with the return value of the last function that was executed.
  27991. * If it is the first function in the callback chain it will be the event data.
  27992. */
  27993. lastReturnValue?: any;
  27994. }
  27995. /**
  27996. * Represent an Observer registered to a given Observable object.
  27997. */
  27998. class Observer<T> {
  27999. /**
  28000. * Defines the callback to call when the observer is notified
  28001. */
  28002. callback: (eventData: T, eventState: EventState) => void;
  28003. /**
  28004. * Defines the mask of the observer (used to filter notifications)
  28005. */
  28006. mask: number;
  28007. /**
  28008. * Defines the current scope used to restore the JS context
  28009. */
  28010. scope: any;
  28011. /** @hidden */
  28012. _willBeUnregistered: boolean;
  28013. /**
  28014. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28015. */
  28016. unregisterOnNextCall: boolean;
  28017. /**
  28018. * Creates a new observer
  28019. * @param callback defines the callback to call when the observer is notified
  28020. * @param mask defines the mask of the observer (used to filter notifications)
  28021. * @param scope defines the current scope used to restore the JS context
  28022. */
  28023. constructor(
  28024. /**
  28025. * Defines the callback to call when the observer is notified
  28026. */
  28027. callback: (eventData: T, eventState: EventState) => void,
  28028. /**
  28029. * Defines the mask of the observer (used to filter notifications)
  28030. */
  28031. mask: number,
  28032. /**
  28033. * Defines the current scope used to restore the JS context
  28034. */
  28035. scope?: any);
  28036. }
  28037. /**
  28038. * Represent a list of observers registered to multiple Observables object.
  28039. */
  28040. class MultiObserver<T> {
  28041. private _observers;
  28042. private _observables;
  28043. /**
  28044. * Release associated resources
  28045. */
  28046. dispose(): void;
  28047. /**
  28048. * Raise a callback when one of the observable will notify
  28049. * @param observables defines a list of observables to watch
  28050. * @param callback defines the callback to call on notification
  28051. * @param mask defines the mask used to filter notifications
  28052. * @param scope defines the current scope used to restore the JS context
  28053. * @returns the new MultiObserver
  28054. */
  28055. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  28056. }
  28057. /**
  28058. * The Observable class is a simple implementation of the Observable pattern.
  28059. *
  28060. * 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.
  28061. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  28062. * 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).
  28063. * 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.
  28064. */
  28065. class Observable<T> {
  28066. private _observers;
  28067. private _eventState;
  28068. private _onObserverAdded;
  28069. /**
  28070. * Creates a new observable
  28071. * @param onObserverAdded defines a callback to call when a new observer is added
  28072. */
  28073. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  28074. /**
  28075. * Create a new Observer with the specified callback
  28076. * @param callback the callback that will be executed for that Observer
  28077. * @param mask the mask used to filter observers
  28078. * @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.
  28079. * @param scope optional scope for the callback to be called from
  28080. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  28081. * @returns the new observer created for the callback
  28082. */
  28083. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  28084. /**
  28085. * Create a new Observer with the specified callback and unregisters after the next notification
  28086. * @param callback the callback that will be executed for that Observer
  28087. * @returns the new observer created for the callback
  28088. */
  28089. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28090. /**
  28091. * Remove an Observer from the Observable object
  28092. * @param observer the instance of the Observer to remove
  28093. * @returns false if it doesn't belong to this Observable
  28094. */
  28095. remove(observer: Nullable<Observer<T>>): boolean;
  28096. /**
  28097. * Remove a callback from the Observable object
  28098. * @param callback the callback to remove
  28099. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28100. * @returns false if it doesn't belong to this Observable
  28101. */
  28102. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28103. private _deferUnregister(observer);
  28104. /**
  28105. * Notify all Observers by calling their respective callback with the given data
  28106. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28107. * @param eventData defines the data to send to all observers
  28108. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28109. * @param target defines the original target of the state
  28110. * @param currentTarget defines the current target of the state
  28111. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28112. */
  28113. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28114. /**
  28115. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28116. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28117. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28118. * and it is crucial that all callbacks will be executed.
  28119. * The order of the callbacks is kept, callbacks are not executed parallel.
  28120. *
  28121. * @param eventData The data to be sent to each callback
  28122. * @param mask is used to filter observers defaults to -1
  28123. * @param target defines the callback target (see EventState)
  28124. * @param currentTarget defines he current object in the bubbling phase
  28125. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28126. */
  28127. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28128. /**
  28129. * Notify a specific observer
  28130. * @param observer defines the observer to notify
  28131. * @param eventData defines the data to be sent to each callback
  28132. * @param mask is used to filter observers defaults to -1
  28133. */
  28134. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28135. /**
  28136. * Gets a boolean indicating if the observable has at least one observer
  28137. * @returns true is the Observable has at least one Observer registered
  28138. */
  28139. hasObservers(): boolean;
  28140. /**
  28141. * Clear the list of observers
  28142. */
  28143. clear(): void;
  28144. /**
  28145. * Clone the current observable
  28146. * @returns a new observable
  28147. */
  28148. clone(): Observable<T>;
  28149. /**
  28150. * Does this observable handles observer registered with a given mask
  28151. * @param mask defines the mask to be tested
  28152. * @return whether or not one observer registered with the given mask is handeled
  28153. **/
  28154. hasSpecificMask(mask?: number): boolean;
  28155. }
  28156. }
  28157. declare module BABYLON {
  28158. /**
  28159. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28160. */
  28161. class PerformanceMonitor {
  28162. private _enabled;
  28163. private _rollingFrameTime;
  28164. private _lastFrameTimeMs;
  28165. /**
  28166. * constructor
  28167. * @param frameSampleSize The number of samples required to saturate the sliding window
  28168. */
  28169. constructor(frameSampleSize?: number);
  28170. /**
  28171. * Samples current frame
  28172. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28173. */
  28174. sampleFrame(timeMs?: number): void;
  28175. /**
  28176. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28177. * @return Average frame time in milliseconds
  28178. */
  28179. readonly averageFrameTime: number;
  28180. /**
  28181. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28182. * @return Frame time variance in milliseconds squared
  28183. */
  28184. readonly averageFrameTimeVariance: number;
  28185. /**
  28186. * Returns the frame time of the most recent frame
  28187. * @return Frame time in milliseconds
  28188. */
  28189. readonly instantaneousFrameTime: number;
  28190. /**
  28191. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28192. * @return Framerate in frames per second
  28193. */
  28194. readonly averageFPS: number;
  28195. /**
  28196. * Returns the average framerate in frames per second using the most recent frame time
  28197. * @return Framerate in frames per second
  28198. */
  28199. readonly instantaneousFPS: number;
  28200. /**
  28201. * Returns true if enough samples have been taken to completely fill the sliding window
  28202. * @return true if saturated
  28203. */
  28204. readonly isSaturated: boolean;
  28205. /**
  28206. * Enables contributions to the sliding window sample set
  28207. */
  28208. enable(): void;
  28209. /**
  28210. * Disables contributions to the sliding window sample set
  28211. * Samples will not be interpolated over the disabled period
  28212. */
  28213. disable(): void;
  28214. /**
  28215. * Returns true if sampling is enabled
  28216. * @return true if enabled
  28217. */
  28218. readonly isEnabled: boolean;
  28219. /**
  28220. * Resets performance monitor
  28221. */
  28222. reset(): void;
  28223. }
  28224. /**
  28225. * RollingAverage
  28226. *
  28227. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28228. */
  28229. class RollingAverage {
  28230. /**
  28231. * Current average
  28232. */
  28233. average: number;
  28234. /**
  28235. * Current variance
  28236. */
  28237. variance: number;
  28238. protected _samples: Array<number>;
  28239. protected _sampleCount: number;
  28240. protected _pos: number;
  28241. protected _m2: number;
  28242. /**
  28243. * constructor
  28244. * @param length The number of samples required to saturate the sliding window
  28245. */
  28246. constructor(length: number);
  28247. /**
  28248. * Adds a sample to the sample set
  28249. * @param v The sample value
  28250. */
  28251. add(v: number): void;
  28252. /**
  28253. * Returns previously added values or null if outside of history or outside the sliding window domain
  28254. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28255. * @return Value previously recorded with add() or null if outside of range
  28256. */
  28257. history(i: number): number;
  28258. /**
  28259. * Returns true if enough samples have been taken to completely fill the sliding window
  28260. * @return true if sample-set saturated
  28261. */
  28262. isSaturated(): boolean;
  28263. /**
  28264. * Resets the rolling average (equivalent to 0 samples taken so far)
  28265. */
  28266. reset(): void;
  28267. /**
  28268. * Wraps a value around the sample range boundaries
  28269. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28270. * @return Wrapped position in sample range
  28271. */
  28272. protected _wrapPosition(i: number): number;
  28273. }
  28274. }
  28275. declare module BABYLON {
  28276. /**
  28277. * Helper class that provides a small promise polyfill
  28278. */
  28279. class PromisePolyfill {
  28280. /**
  28281. * Static function used to check if the polyfill is required
  28282. * If this is the case then the function will inject the polyfill to window.Promise
  28283. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28284. */
  28285. static Apply(force?: boolean): void;
  28286. }
  28287. }
  28288. declare module BABYLON {
  28289. /**
  28290. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28292. */
  28293. class SceneOptimization {
  28294. /**
  28295. * Defines the priority of this optimization (0 by default which means first in the list)
  28296. */
  28297. priority: number;
  28298. /**
  28299. * Gets a string describing the action executed by the current optimization
  28300. * @returns description string
  28301. */
  28302. getDescription(): string;
  28303. /**
  28304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28305. * @param scene defines the current scene where to apply this optimization
  28306. * @param optimizer defines the current optimizer
  28307. * @returns true if everything that can be done was applied
  28308. */
  28309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28310. /**
  28311. * Creates the SceneOptimization object
  28312. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28313. * @param desc defines the description associated with the optimization
  28314. */
  28315. constructor(
  28316. /**
  28317. * Defines the priority of this optimization (0 by default which means first in the list)
  28318. */
  28319. priority?: number);
  28320. }
  28321. /**
  28322. * Defines an optimization used to reduce the size of render target textures
  28323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28324. */
  28325. class TextureOptimization extends SceneOptimization {
  28326. /**
  28327. * Defines the priority of this optimization (0 by default which means first in the list)
  28328. */
  28329. priority: number;
  28330. /**
  28331. * 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
  28332. */
  28333. maximumSize: number;
  28334. /**
  28335. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28336. */
  28337. step: number;
  28338. /**
  28339. * Gets a string describing the action executed by the current optimization
  28340. * @returns description string
  28341. */
  28342. getDescription(): string;
  28343. /**
  28344. * Creates the TextureOptimization object
  28345. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28346. * @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
  28347. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28348. */
  28349. constructor(
  28350. /**
  28351. * Defines the priority of this optimization (0 by default which means first in the list)
  28352. */
  28353. priority?: number,
  28354. /**
  28355. * 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
  28356. */
  28357. maximumSize?: number,
  28358. /**
  28359. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28360. */
  28361. step?: number);
  28362. /**
  28363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28364. * @param scene defines the current scene where to apply this optimization
  28365. * @param optimizer defines the current optimizer
  28366. * @returns true if everything that can be done was applied
  28367. */
  28368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28369. }
  28370. /**
  28371. * Defines an optimization used to increase or decrease the rendering resolution
  28372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28373. */
  28374. class HardwareScalingOptimization extends SceneOptimization {
  28375. /**
  28376. * Defines the priority of this optimization (0 by default which means first in the list)
  28377. */
  28378. priority: number;
  28379. /**
  28380. * Defines the maximum scale to use (2 by default)
  28381. */
  28382. maximumScale: number;
  28383. /**
  28384. * Defines the step to use between two passes (0.5 by default)
  28385. */
  28386. step: number;
  28387. private _currentScale;
  28388. private _directionOffset;
  28389. /**
  28390. * Gets a string describing the action executed by the current optimization
  28391. * @return description string
  28392. */
  28393. getDescription(): string;
  28394. /**
  28395. * Creates the HardwareScalingOptimization object
  28396. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28397. * @param maximumScale defines the maximum scale to use (2 by default)
  28398. * @param step defines the step to use between two passes (0.5 by default)
  28399. */
  28400. constructor(
  28401. /**
  28402. * Defines the priority of this optimization (0 by default which means first in the list)
  28403. */
  28404. priority?: number,
  28405. /**
  28406. * Defines the maximum scale to use (2 by default)
  28407. */
  28408. maximumScale?: number,
  28409. /**
  28410. * Defines the step to use between two passes (0.5 by default)
  28411. */
  28412. step?: number);
  28413. /**
  28414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28415. * @param scene defines the current scene where to apply this optimization
  28416. * @param optimizer defines the current optimizer
  28417. * @returns true if everything that can be done was applied
  28418. */
  28419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28420. }
  28421. /**
  28422. * Defines an optimization used to remove shadows
  28423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28424. */
  28425. class ShadowsOptimization extends SceneOptimization {
  28426. /**
  28427. * Gets a string describing the action executed by the current optimization
  28428. * @return description string
  28429. */
  28430. getDescription(): string;
  28431. /**
  28432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28433. * @param scene defines the current scene where to apply this optimization
  28434. * @param optimizer defines the current optimizer
  28435. * @returns true if everything that can be done was applied
  28436. */
  28437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28438. }
  28439. /**
  28440. * Defines an optimization used to turn post-processes off
  28441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28442. */
  28443. class PostProcessesOptimization extends SceneOptimization {
  28444. /**
  28445. * Gets a string describing the action executed by the current optimization
  28446. * @return description string
  28447. */
  28448. getDescription(): string;
  28449. /**
  28450. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28451. * @param scene defines the current scene where to apply this optimization
  28452. * @param optimizer defines the current optimizer
  28453. * @returns true if everything that can be done was applied
  28454. */
  28455. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28456. }
  28457. /**
  28458. * Defines an optimization used to turn lens flares off
  28459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28460. */
  28461. class LensFlaresOptimization extends SceneOptimization {
  28462. /**
  28463. * Gets a string describing the action executed by the current optimization
  28464. * @return description string
  28465. */
  28466. getDescription(): string;
  28467. /**
  28468. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28469. * @param scene defines the current scene where to apply this optimization
  28470. * @param optimizer defines the current optimizer
  28471. * @returns true if everything that can be done was applied
  28472. */
  28473. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28474. }
  28475. /**
  28476. * Defines an optimization based on user defined callback.
  28477. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28478. */
  28479. class CustomOptimization extends SceneOptimization {
  28480. /**
  28481. * Callback called to apply the custom optimization.
  28482. */
  28483. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28484. /**
  28485. * Callback called to get custom description
  28486. */
  28487. onGetDescription: () => string;
  28488. /**
  28489. * Gets a string describing the action executed by the current optimization
  28490. * @returns description string
  28491. */
  28492. getDescription(): string;
  28493. /**
  28494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28495. * @param scene defines the current scene where to apply this optimization
  28496. * @param optimizer defines the current optimizer
  28497. * @returns true if everything that can be done was applied
  28498. */
  28499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28500. }
  28501. /**
  28502. * Defines an optimization used to turn particles off
  28503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28504. */
  28505. class ParticlesOptimization extends SceneOptimization {
  28506. /**
  28507. * Gets a string describing the action executed by the current optimization
  28508. * @return description string
  28509. */
  28510. getDescription(): string;
  28511. /**
  28512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28513. * @param scene defines the current scene where to apply this optimization
  28514. * @param optimizer defines the current optimizer
  28515. * @returns true if everything that can be done was applied
  28516. */
  28517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28518. }
  28519. /**
  28520. * Defines an optimization used to turn render targets off
  28521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28522. */
  28523. class RenderTargetsOptimization extends SceneOptimization {
  28524. /**
  28525. * Gets a string describing the action executed by the current optimization
  28526. * @return description string
  28527. */
  28528. getDescription(): string;
  28529. /**
  28530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28531. * @param scene defines the current scene where to apply this optimization
  28532. * @param optimizer defines the current optimizer
  28533. * @returns true if everything that can be done was applied
  28534. */
  28535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28536. }
  28537. /**
  28538. * Defines an optimization used to merge meshes with compatible materials
  28539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28540. */
  28541. class MergeMeshesOptimization extends SceneOptimization {
  28542. private static _UpdateSelectionTree;
  28543. /**
  28544. * Gets or sets a boolean which defines if optimization octree has to be updated
  28545. */
  28546. /**
  28547. * Gets or sets a boolean which defines if optimization octree has to be updated
  28548. */
  28549. static UpdateSelectionTree: boolean;
  28550. /**
  28551. * Gets a string describing the action executed by the current optimization
  28552. * @return description string
  28553. */
  28554. getDescription(): string;
  28555. private _canBeMerged;
  28556. /**
  28557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28558. * @param scene defines the current scene where to apply this optimization
  28559. * @param optimizer defines the current optimizer
  28560. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28561. * @returns true if everything that can be done was applied
  28562. */
  28563. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28564. }
  28565. /**
  28566. * Defines a list of options used by SceneOptimizer
  28567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28568. */
  28569. class SceneOptimizerOptions {
  28570. /**
  28571. * Defines the target frame rate to reach (60 by default)
  28572. */
  28573. targetFrameRate: number;
  28574. /**
  28575. * Defines the interval between two checkes (2000ms by default)
  28576. */
  28577. trackerDuration: number;
  28578. /**
  28579. * Gets the list of optimizations to apply
  28580. */
  28581. optimizations: SceneOptimization[];
  28582. /**
  28583. * Creates a new list of options used by SceneOptimizer
  28584. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28585. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28586. */
  28587. constructor(
  28588. /**
  28589. * Defines the target frame rate to reach (60 by default)
  28590. */
  28591. targetFrameRate?: number,
  28592. /**
  28593. * Defines the interval between two checkes (2000ms by default)
  28594. */
  28595. trackerDuration?: number);
  28596. /**
  28597. * Add a new optimization
  28598. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28599. * @returns the current SceneOptimizerOptions
  28600. */
  28601. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28602. /**
  28603. * Add a new custom optimization
  28604. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28605. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28606. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28607. * @returns the current SceneOptimizerOptions
  28608. */
  28609. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28610. /**
  28611. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28612. * @param targetFrameRate defines the target frame rate (60 by default)
  28613. * @returns a SceneOptimizerOptions object
  28614. */
  28615. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28616. /**
  28617. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28618. * @param targetFrameRate defines the target frame rate (60 by default)
  28619. * @returns a SceneOptimizerOptions object
  28620. */
  28621. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28622. /**
  28623. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28624. * @param targetFrameRate defines the target frame rate (60 by default)
  28625. * @returns a SceneOptimizerOptions object
  28626. */
  28627. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28628. }
  28629. /**
  28630. * Class used to run optimizations in order to reach a target frame rate
  28631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28632. */
  28633. class SceneOptimizer implements IDisposable {
  28634. private _isRunning;
  28635. private _options;
  28636. private _scene;
  28637. private _currentPriorityLevel;
  28638. private _targetFrameRate;
  28639. private _trackerDuration;
  28640. private _currentFrameRate;
  28641. private _sceneDisposeObserver;
  28642. private _improvementMode;
  28643. /**
  28644. * Defines an observable called when the optimizer reaches the target frame rate
  28645. */
  28646. onSuccessObservable: Observable<SceneOptimizer>;
  28647. /**
  28648. * Defines an observable called when the optimizer enables an optimization
  28649. */
  28650. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28651. /**
  28652. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28653. */
  28654. onFailureObservable: Observable<SceneOptimizer>;
  28655. /**
  28656. * Gets a boolean indicating if the optimizer is in improvement mode
  28657. */
  28658. readonly isInImprovementMode: boolean;
  28659. /**
  28660. * Gets the current priority level (0 at start)
  28661. */
  28662. readonly currentPriorityLevel: number;
  28663. /**
  28664. * Gets the current frame rate checked by the SceneOptimizer
  28665. */
  28666. readonly currentFrameRate: number;
  28667. /**
  28668. * Gets or sets the current target frame rate (60 by default)
  28669. */
  28670. /**
  28671. * Gets or sets the current target frame rate (60 by default)
  28672. */
  28673. targetFrameRate: number;
  28674. /**
  28675. * Gets or sets the current interval between two checks (every 2000ms by default)
  28676. */
  28677. /**
  28678. * Gets or sets the current interval between two checks (every 2000ms by default)
  28679. */
  28680. trackerDuration: number;
  28681. /**
  28682. * Gets the list of active optimizations
  28683. */
  28684. readonly optimizations: SceneOptimization[];
  28685. /**
  28686. * Creates a new SceneOptimizer
  28687. * @param scene defines the scene to work on
  28688. * @param options defines the options to use with the SceneOptimizer
  28689. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28690. * @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)
  28691. */
  28692. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28693. /**
  28694. * Stops the current optimizer
  28695. */
  28696. stop(): void;
  28697. /**
  28698. * Reset the optimizer to initial step (current priority level = 0)
  28699. */
  28700. reset(): void;
  28701. /**
  28702. * Start the optimizer. By default it will try to reach a specific framerate
  28703. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28704. */
  28705. start(): void;
  28706. private _checkCurrentState();
  28707. /**
  28708. * Release all resources
  28709. */
  28710. dispose(): void;
  28711. /**
  28712. * Helper function to create a SceneOptimizer with one single line of code
  28713. * @param scene defines the scene to work on
  28714. * @param options defines the options to use with the SceneOptimizer
  28715. * @param onSuccess defines a callback to call on success
  28716. * @param onFailure defines a callback to call on failure
  28717. * @returns the new SceneOptimizer object
  28718. */
  28719. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28720. }
  28721. }
  28722. declare module BABYLON {
  28723. class SceneSerializer {
  28724. static ClearCache(): void;
  28725. static Serialize(scene: Scene): any;
  28726. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28727. }
  28728. }
  28729. declare module BABYLON {
  28730. class SmartArray<T> {
  28731. data: Array<T>;
  28732. length: number;
  28733. protected _id: number;
  28734. [index: number]: T;
  28735. constructor(capacity: number);
  28736. push(value: T): void;
  28737. forEach(func: (content: T) => void): void;
  28738. sort(compareFn: (a: T, b: T) => number): void;
  28739. reset(): void;
  28740. dispose(): void;
  28741. concat(array: any): void;
  28742. indexOf(value: T): number;
  28743. contains(value: T): boolean;
  28744. private static _GlobalId;
  28745. }
  28746. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28747. private _duplicateId;
  28748. [index: number]: T;
  28749. push(value: T): void;
  28750. pushNoDuplicate(value: T): boolean;
  28751. reset(): void;
  28752. concatWithNoDuplicate(array: any): void;
  28753. }
  28754. }
  28755. declare module BABYLON {
  28756. /**
  28757. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28758. * The underlying implementation relies on an associative array to ensure the best performances.
  28759. * The value can be anything including 'null' but except 'undefined'
  28760. */
  28761. class StringDictionary<T> {
  28762. /**
  28763. * This will clear this dictionary and copy the content from the 'source' one.
  28764. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28765. * @param source the dictionary to take the content from and copy to this dictionary
  28766. */
  28767. copyFrom(source: StringDictionary<T>): void;
  28768. /**
  28769. * Get a value based from its key
  28770. * @param key the given key to get the matching value from
  28771. * @return the value if found, otherwise undefined is returned
  28772. */
  28773. get(key: string): T | undefined;
  28774. /**
  28775. * Get a value from its key or add it if it doesn't exist.
  28776. * This method will ensure you that a given key/data will be present in the dictionary.
  28777. * @param key the given key to get the matching value from
  28778. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28779. * The factory will only be invoked if there's no data for the given key.
  28780. * @return the value corresponding to the key.
  28781. */
  28782. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28783. /**
  28784. * Get a value from its key if present in the dictionary otherwise add it
  28785. * @param key the key to get the value from
  28786. * @param val if there's no such key/value pair in the dictionary add it with this value
  28787. * @return the value corresponding to the key
  28788. */
  28789. getOrAdd(key: string, val: T): T;
  28790. /**
  28791. * Check if there's a given key in the dictionary
  28792. * @param key the key to check for
  28793. * @return true if the key is present, false otherwise
  28794. */
  28795. contains(key: string): boolean;
  28796. /**
  28797. * Add a new key and its corresponding value
  28798. * @param key the key to add
  28799. * @param value the value corresponding to the key
  28800. * @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
  28801. */
  28802. add(key: string, value: T): boolean;
  28803. set(key: string, value: T): boolean;
  28804. /**
  28805. * Get the element of the given key and remove it from the dictionary
  28806. * @param key
  28807. */
  28808. getAndRemove(key: string): Nullable<T>;
  28809. /**
  28810. * Remove a key/value from the dictionary.
  28811. * @param key the key to remove
  28812. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28813. */
  28814. remove(key: string): boolean;
  28815. /**
  28816. * Clear the whole content of the dictionary
  28817. */
  28818. clear(): void;
  28819. readonly count: number;
  28820. /**
  28821. * Execute a callback on each key/val of the dictionary.
  28822. * Note that you can remove any element in this dictionary in the callback implementation
  28823. * @param callback the callback to execute on a given key/value pair
  28824. */
  28825. forEach(callback: (key: string, val: T) => void): void;
  28826. /**
  28827. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28828. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28829. * Note that you can remove any element in this dictionary in the callback implementation
  28830. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28831. */
  28832. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28833. private _count;
  28834. private _data;
  28835. }
  28836. }
  28837. declare module BABYLON {
  28838. class Tags {
  28839. static EnableFor(obj: any): void;
  28840. static DisableFor(obj: any): void;
  28841. static HasTags(obj: any): boolean;
  28842. static GetTags(obj: any, asString?: boolean): any;
  28843. static AddTagsTo(obj: any, tagsString: string): void;
  28844. static _AddTagTo(obj: any, tag: string): void;
  28845. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28846. static _RemoveTagFrom(obj: any, tag: string): void;
  28847. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28848. }
  28849. }
  28850. declare module BABYLON {
  28851. class TextureTools {
  28852. /**
  28853. * Uses the GPU to create a copy texture rescaled at a given size
  28854. * @param texture Texture to copy from
  28855. * @param width Desired width
  28856. * @param height Desired height
  28857. * @return Generated texture
  28858. */
  28859. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28860. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28861. private static _environmentBRDFBase64Texture;
  28862. }
  28863. }
  28864. declare module BABYLON {
  28865. class TGATools {
  28866. private static _TYPE_INDEXED;
  28867. private static _TYPE_RGB;
  28868. private static _TYPE_GREY;
  28869. private static _TYPE_RLE_INDEXED;
  28870. private static _TYPE_RLE_RGB;
  28871. private static _TYPE_RLE_GREY;
  28872. private static _ORIGIN_MASK;
  28873. private static _ORIGIN_SHIFT;
  28874. private static _ORIGIN_BL;
  28875. private static _ORIGIN_BR;
  28876. private static _ORIGIN_UL;
  28877. private static _ORIGIN_UR;
  28878. static GetTGAHeader(data: Uint8Array): any;
  28879. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28880. 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;
  28881. 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;
  28882. 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;
  28883. 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;
  28884. 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;
  28885. 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;
  28886. }
  28887. }
  28888. declare module BABYLON {
  28889. interface IAnimatable {
  28890. animations: Array<Animation>;
  28891. }
  28892. class LoadFileError extends Error {
  28893. request: XMLHttpRequest | undefined;
  28894. private static _setPrototypeOf;
  28895. constructor(message: string, request?: XMLHttpRequest | undefined);
  28896. }
  28897. class RetryStrategy {
  28898. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28899. }
  28900. interface IFileRequest {
  28901. /**
  28902. * Raised when the request is complete (success or error).
  28903. */
  28904. onCompleteObservable: Observable<IFileRequest>;
  28905. /**
  28906. * Aborts the request for a file.
  28907. */
  28908. abort: () => void;
  28909. }
  28910. class Tools {
  28911. static BaseUrl: string;
  28912. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28913. /**
  28914. * Default behaviour for cors in the application.
  28915. * It can be a string if the expected behavior is identical in the entire app.
  28916. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28917. */
  28918. static CorsBehavior: string | ((url: string | string[]) => string);
  28919. static UseFallbackTexture: boolean;
  28920. /**
  28921. * Use this object to register external classes like custom textures or material
  28922. * to allow the laoders to instantiate them
  28923. */
  28924. static RegisteredExternalClasses: {
  28925. [key: string]: Object;
  28926. };
  28927. static fallbackTexture: string;
  28928. /**
  28929. * Interpolates between a and b via alpha
  28930. * @param a The lower value (returned when alpha = 0)
  28931. * @param b The upper value (returned when alpha = 1)
  28932. * @param alpha The interpolation-factor
  28933. * @return The mixed value
  28934. */
  28935. static Mix(a: number, b: number, alpha: number): number;
  28936. static Instantiate(className: string): any;
  28937. /**
  28938. * Provides a slice function that will work even on IE
  28939. * @param data defines the array to slice
  28940. * @param start defines the start of the data (optional)
  28941. * @param end defines the end of the data (optional)
  28942. * @returns the new sliced array
  28943. */
  28944. static Slice<T>(data: T, start?: number, end?: number): T;
  28945. static SetImmediate(action: () => void): void;
  28946. static IsExponentOfTwo(value: number): boolean;
  28947. private static _tmpFloatArray;
  28948. /**
  28949. * Returns the nearest 32-bit single precision float representation of a Number
  28950. * @param value A Number. If the parameter is of a different type, it will get converted
  28951. * to a number or to NaN if it cannot be converted
  28952. * @returns number
  28953. */
  28954. static FloatRound(value: number): number;
  28955. /**
  28956. * Find the next highest power of two.
  28957. * @param x Number to start search from.
  28958. * @return Next highest power of two.
  28959. */
  28960. static CeilingPOT(x: number): number;
  28961. /**
  28962. * Find the next lowest power of two.
  28963. * @param x Number to start search from.
  28964. * @return Next lowest power of two.
  28965. */
  28966. static FloorPOT(x: number): number;
  28967. /**
  28968. * Find the nearest power of two.
  28969. * @param x Number to start search from.
  28970. * @return Next nearest power of two.
  28971. */
  28972. static NearestPOT(x: number): number;
  28973. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28974. static GetFilename(path: string): string;
  28975. /**
  28976. * Extracts the "folder" part of a path (everything before the filename).
  28977. * @param uri The URI to extract the info from
  28978. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28979. * @returns The "folder" part of the path
  28980. */
  28981. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28982. static GetDOMTextContent(element: HTMLElement): string;
  28983. static ToDegrees(angle: number): number;
  28984. static ToRadians(angle: number): number;
  28985. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28986. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28987. minimum: Vector3;
  28988. maximum: Vector3;
  28989. };
  28990. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28991. minimum: Vector3;
  28992. maximum: Vector3;
  28993. };
  28994. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28995. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28996. minimum: Vector2;
  28997. maximum: Vector2;
  28998. };
  28999. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29000. static GetPointerPrefix(): string;
  29001. /**
  29002. * @param func - the function to be called
  29003. * @param requester - the object that will request the next frame. Falls back to window.
  29004. */
  29005. static QueueNewFrame(func: () => void, requester?: any): number;
  29006. static RequestFullscreen(element: HTMLElement): void;
  29007. static ExitFullscreen(): void;
  29008. static SetCorsBehavior(url: string | string[], element: {
  29009. crossOrigin: string | null;
  29010. }): void;
  29011. static CleanUrl(url: string): string;
  29012. static PreprocessUrl: (url: string) => string;
  29013. /**
  29014. * Loads an image as an HTMLImageElement.
  29015. * @param input url string, ArrayBuffer, or Blob to load
  29016. * @param onLoad callback called when the image successfully loads
  29017. * @param onError callback called when the image fails to load
  29018. * @param database database for caching
  29019. * @returns the HTMLImageElement of the loaded image
  29020. */
  29021. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  29022. 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;
  29023. /**
  29024. * Load a script (identified by an url). When the url returns, the
  29025. * content of this file is added into a new script element, attached to the DOM (body element)
  29026. */
  29027. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29028. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29029. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29030. static FileAsURL(content: string): string;
  29031. static Format(value: number, decimals?: number): string;
  29032. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29033. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29034. static IsEmpty(obj: any): boolean;
  29035. static RegisterTopRootEvents(events: {
  29036. name: string;
  29037. handler: Nullable<(e: FocusEvent) => any>;
  29038. }[]): void;
  29039. static UnregisterTopRootEvents(events: {
  29040. name: string;
  29041. handler: Nullable<(e: FocusEvent) => any>;
  29042. }[]): void;
  29043. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29044. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29045. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29046. /**
  29047. * Generates an image screenshot from the specified camera.
  29048. *
  29049. * @param engine The engine to use for rendering
  29050. * @param camera The camera to use for rendering
  29051. * @param size This parameter can be set to a single number or to an object with the
  29052. * following (optional) properties: precision, width, height. If a single number is passed,
  29053. * it will be used for both width and height. If an object is passed, the screenshot size
  29054. * will be derived from the parameters. The precision property is a multiplier allowing
  29055. * rendering at a higher or lower resolution.
  29056. * @param successCallback The callback receives a single parameter which contains the
  29057. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29058. * src parameter of an <img> to display it.
  29059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29060. * Check your browser for supported MIME types.
  29061. * @param samples Texture samples (default: 1)
  29062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29063. * @param fileName A name for for the downloaded file.
  29064. * @constructor
  29065. */
  29066. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29067. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  29068. /**
  29069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29070. * Be aware Math.random() could cause collisions, but:
  29071. * "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"
  29072. */
  29073. static RandomId(): string;
  29074. /**
  29075. * Test if the given uri is a base64 string.
  29076. * @param uri The uri to test
  29077. * @return True if the uri is a base64 string or false otherwise.
  29078. */
  29079. static IsBase64(uri: string): boolean;
  29080. /**
  29081. * Decode the given base64 uri.
  29082. * @param uri The uri to decode
  29083. * @return The decoded base64 data.
  29084. */
  29085. static DecodeBase64(uri: string): ArrayBuffer;
  29086. private static _NoneLogLevel;
  29087. private static _MessageLogLevel;
  29088. private static _WarningLogLevel;
  29089. private static _ErrorLogLevel;
  29090. private static _LogCache;
  29091. static errorsCount: number;
  29092. static OnNewCacheEntry: (entry: string) => void;
  29093. static readonly NoneLogLevel: number;
  29094. static readonly MessageLogLevel: number;
  29095. static readonly WarningLogLevel: number;
  29096. static readonly ErrorLogLevel: number;
  29097. static readonly AllLogLevel: number;
  29098. private static _AddLogEntry(entry);
  29099. private static _FormatMessage(message);
  29100. private static _LogDisabled(message);
  29101. private static _LogEnabled(message);
  29102. private static _WarnDisabled(message);
  29103. private static _WarnEnabled(message);
  29104. private static _ErrorDisabled(message);
  29105. private static _ErrorEnabled(message);
  29106. static Log: (message: string) => void;
  29107. static Warn: (message: string) => void;
  29108. static Error: (message: string) => void;
  29109. static readonly LogCache: string;
  29110. static ClearLogCache(): void;
  29111. static LogLevels: number;
  29112. static IsWindowObjectExist(): boolean;
  29113. private static _PerformanceNoneLogLevel;
  29114. private static _PerformanceUserMarkLogLevel;
  29115. private static _PerformanceConsoleLogLevel;
  29116. private static _performance;
  29117. static readonly PerformanceNoneLogLevel: number;
  29118. static readonly PerformanceUserMarkLogLevel: number;
  29119. static readonly PerformanceConsoleLogLevel: number;
  29120. static PerformanceLogLevel: number;
  29121. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29122. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29123. static _StartUserMark(counterName: string, condition?: boolean): void;
  29124. static _EndUserMark(counterName: string, condition?: boolean): void;
  29125. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29126. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29127. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29128. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29129. static readonly Now: number;
  29130. /**
  29131. * This method will return the name of the class used to create the instance of the given object.
  29132. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29133. * @param object the object to get the class name from
  29134. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29135. */
  29136. static GetClassName(object: any, isType?: boolean): string;
  29137. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29138. /**
  29139. * This method will return the name of the full name of the class, including its owning module (if any).
  29140. * 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).
  29141. * @param object the object to get the class name from
  29142. * @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.
  29143. */
  29144. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29145. /**
  29146. * 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.
  29147. * @param array
  29148. */
  29149. static arrayOrStringFeeder(array: any): (i: number) => number;
  29150. /**
  29151. * Compute the hashCode of a stream of number
  29152. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29153. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29154. * @return the hash code computed
  29155. */
  29156. static hashCodeFromStream(feeder: (index: number) => number): number;
  29157. /**
  29158. * Returns a promise that resolves after the given amount of time.
  29159. * @param delay Number of milliseconds to delay
  29160. * @returns Promise that resolves after the given amount of time
  29161. */
  29162. static DelayAsync(delay: number): Promise<void>;
  29163. }
  29164. /**
  29165. * This class is used to track a performance counter which is number based.
  29166. * The user has access to many properties which give statistics of different nature
  29167. *
  29168. * The implementer can track two kinds of Performance Counter: time and count
  29169. * 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.
  29170. * 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.
  29171. */
  29172. class PerfCounter {
  29173. static Enabled: boolean;
  29174. /**
  29175. * Returns the smallest value ever
  29176. */
  29177. readonly min: number;
  29178. /**
  29179. * Returns the biggest value ever
  29180. */
  29181. readonly max: number;
  29182. /**
  29183. * Returns the average value since the performance counter is running
  29184. */
  29185. readonly average: number;
  29186. /**
  29187. * Returns the average value of the last second the counter was monitored
  29188. */
  29189. readonly lastSecAverage: number;
  29190. /**
  29191. * Returns the current value
  29192. */
  29193. readonly current: number;
  29194. readonly total: number;
  29195. readonly count: number;
  29196. constructor();
  29197. /**
  29198. * Call this method to start monitoring a new frame.
  29199. * 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.
  29200. */
  29201. fetchNewFrame(): void;
  29202. /**
  29203. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29204. * @param newCount the count value to add to the monitored count
  29205. * @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.
  29206. */
  29207. addCount(newCount: number, fetchResult: boolean): void;
  29208. /**
  29209. * Start monitoring this performance counter
  29210. */
  29211. beginMonitoring(): void;
  29212. /**
  29213. * Compute the time lapsed since the previous beginMonitoring() call.
  29214. * @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
  29215. */
  29216. endMonitoring(newFrame?: boolean): void;
  29217. private _fetchResult();
  29218. private _startMonitoringTime;
  29219. private _min;
  29220. private _max;
  29221. private _average;
  29222. private _current;
  29223. private _totalValueCount;
  29224. private _totalAccumulated;
  29225. private _lastSecAverage;
  29226. private _lastSecAccumulated;
  29227. private _lastSecTime;
  29228. private _lastSecValueCount;
  29229. }
  29230. /**
  29231. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29232. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29233. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29234. * @param name The name of the class, case should be preserved
  29235. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29236. */
  29237. function className(name: string, module?: string): (target: Object) => void;
  29238. /**
  29239. * An implementation of a loop for asynchronous functions.
  29240. */
  29241. class AsyncLoop {
  29242. iterations: number;
  29243. private _fn;
  29244. private _successCallback;
  29245. index: number;
  29246. private _done;
  29247. /**
  29248. * Constroctor.
  29249. * @param iterations the number of iterations.
  29250. * @param _fn the function to run each iteration
  29251. * @param _successCallback the callback that will be called upon succesful execution
  29252. * @param offset starting offset.
  29253. */
  29254. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  29255. /**
  29256. * Execute the next iteration. Must be called after the last iteration was finished.
  29257. */
  29258. executeNext(): void;
  29259. /**
  29260. * Break the loop and run the success callback.
  29261. */
  29262. breakLoop(): void;
  29263. /**
  29264. * Helper function
  29265. */
  29266. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  29267. /**
  29268. * A for-loop that will run a given number of iterations synchronous and the rest async.
  29269. * @param iterations total number of iterations
  29270. * @param syncedIterations number of synchronous iterations in each async iteration.
  29271. * @param fn the function to call each iteration.
  29272. * @param callback a success call back that will be called when iterating stops.
  29273. * @param breakFunction a break condition (optional)
  29274. * @param timeout timeout settings for the setTimeout function. default - 0.
  29275. * @constructor
  29276. */
  29277. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  29278. }
  29279. }
  29280. declare module BABYLON {
  29281. /**
  29282. * Defines the potential axis of a Joystick
  29283. */
  29284. enum JoystickAxis {
  29285. /** X axis */
  29286. X = 0,
  29287. /** Y axis */
  29288. Y = 1,
  29289. /** Z axis */
  29290. Z = 2,
  29291. }
  29292. /**
  29293. * Class used to define virtual joystick (used in touch mode)
  29294. */
  29295. class VirtualJoystick {
  29296. /**
  29297. * Gets or sets a boolean indicating that left and right values must be inverted
  29298. */
  29299. reverseLeftRight: boolean;
  29300. /**
  29301. * Gets or sets a boolean indicating that up and down values must be inverted
  29302. */
  29303. reverseUpDown: boolean;
  29304. /**
  29305. * Gets the offset value for the position (ie. the change of the position value)
  29306. */
  29307. deltaPosition: Vector3;
  29308. /**
  29309. * Gets a boolean indicating if the virtual joystick was pressed
  29310. */
  29311. pressed: boolean;
  29312. private static _globalJoystickIndex;
  29313. private static vjCanvas;
  29314. private static vjCanvasContext;
  29315. private static vjCanvasWidth;
  29316. private static vjCanvasHeight;
  29317. private static halfWidth;
  29318. private _action;
  29319. private _axisTargetedByLeftAndRight;
  29320. private _axisTargetedByUpAndDown;
  29321. private _joystickSensibility;
  29322. private _inversedSensibility;
  29323. private _joystickPointerID;
  29324. private _joystickColor;
  29325. private _joystickPointerPos;
  29326. private _joystickPreviousPointerPos;
  29327. private _joystickPointerStartPos;
  29328. private _deltaJoystickVector;
  29329. private _leftJoystick;
  29330. private _touches;
  29331. private _onPointerDownHandlerRef;
  29332. private _onPointerMoveHandlerRef;
  29333. private _onPointerUpHandlerRef;
  29334. private _onResize;
  29335. /**
  29336. * Creates a new virtual joystick
  29337. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29338. */
  29339. constructor(leftJoystick?: boolean);
  29340. /**
  29341. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29342. * @param newJoystickSensibility defines the new sensibility
  29343. */
  29344. setJoystickSensibility(newJoystickSensibility: number): void;
  29345. private _onPointerDown(e);
  29346. private _onPointerMove(e);
  29347. private _onPointerUp(e);
  29348. /**
  29349. * Change the color of the virtual joystick
  29350. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29351. */
  29352. setJoystickColor(newColor: string): void;
  29353. /**
  29354. * Defines a callback to call when the joystick is touched
  29355. * @param action defines the callback
  29356. */
  29357. setActionOnTouch(action: () => any): void;
  29358. /**
  29359. * Defines which axis you'd like to control for left & right
  29360. * @param axis defines the axis to use
  29361. */
  29362. setAxisForLeftRight(axis: JoystickAxis): void;
  29363. /**
  29364. * Defines which axis you'd like to control for up & down
  29365. * @param axis defines the axis to use
  29366. */
  29367. setAxisForUpDown(axis: JoystickAxis): void;
  29368. private _drawVirtualJoystick();
  29369. /**
  29370. * Release internal HTML canvas
  29371. */
  29372. releaseCanvas(): void;
  29373. }
  29374. }
  29375. declare module BABYLON {
  29376. /**
  29377. * Helper class to push actions to a pool of workers.
  29378. */
  29379. class WorkerPool implements IDisposable {
  29380. private _workerInfos;
  29381. private _pendingActions;
  29382. /**
  29383. * Constructor
  29384. * @param workers Array of workers to use for actions
  29385. */
  29386. constructor(workers: Array<Worker>);
  29387. /**
  29388. * Terminates all workers and clears any pending actions.
  29389. */
  29390. dispose(): void;
  29391. /**
  29392. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29393. * pended until a worker has completed its action.
  29394. * @param action The action to perform. Call onComplete when the action is complete.
  29395. */
  29396. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29397. private _execute(workerInfo, action);
  29398. }
  29399. }
  29400. declare module BABYLON {
  29401. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29402. readonly name: string;
  29403. private _zoomStopsAnimation;
  29404. private _idleRotationSpeed;
  29405. private _idleRotationWaitTime;
  29406. private _idleRotationSpinupTime;
  29407. /**
  29408. * Gets the flag that indicates if user zooming should stop animation.
  29409. */
  29410. /**
  29411. * Sets the flag that indicates if user zooming should stop animation.
  29412. */
  29413. zoomStopsAnimation: boolean;
  29414. /**
  29415. * Gets the default speed at which the camera rotates around the model.
  29416. */
  29417. /**
  29418. * Sets the default speed at which the camera rotates around the model.
  29419. */
  29420. idleRotationSpeed: number;
  29421. /**
  29422. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29423. */
  29424. /**
  29425. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29426. */
  29427. idleRotationWaitTime: number;
  29428. /**
  29429. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29430. */
  29431. /**
  29432. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29433. */
  29434. idleRotationSpinupTime: number;
  29435. /**
  29436. * Gets a value indicating if the camera is currently rotating because of this behavior
  29437. */
  29438. readonly rotationInProgress: boolean;
  29439. private _onPrePointerObservableObserver;
  29440. private _onAfterCheckInputsObserver;
  29441. private _attachedCamera;
  29442. private _isPointerDown;
  29443. private _lastFrameTime;
  29444. private _lastInteractionTime;
  29445. private _cameraRotationSpeed;
  29446. init(): void;
  29447. attach(camera: ArcRotateCamera): void;
  29448. detach(): void;
  29449. /**
  29450. * Returns true if user is scrolling.
  29451. * @return true if user is scrolling.
  29452. */
  29453. private _userIsZooming();
  29454. private _lastFrameRadius;
  29455. private _shouldAnimationStopForInteraction();
  29456. /**
  29457. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29458. */
  29459. private _applyUserInteraction();
  29460. private _userIsMoving();
  29461. }
  29462. }
  29463. declare module BABYLON {
  29464. /**
  29465. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29466. */
  29467. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29468. readonly name: string;
  29469. /**
  29470. * The easing function used by animations
  29471. */
  29472. static EasingFunction: BackEase;
  29473. /**
  29474. * The easing mode used by animations
  29475. */
  29476. static EasingMode: number;
  29477. /**
  29478. * The duration of the animation, in milliseconds
  29479. */
  29480. transitionDuration: number;
  29481. /**
  29482. * Length of the distance animated by the transition when lower radius is reached
  29483. */
  29484. lowerRadiusTransitionRange: number;
  29485. /**
  29486. * Length of the distance animated by the transition when upper radius is reached
  29487. */
  29488. upperRadiusTransitionRange: number;
  29489. private _autoTransitionRange;
  29490. /**
  29491. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29492. */
  29493. /**
  29494. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29495. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29496. */
  29497. autoTransitionRange: boolean;
  29498. private _attachedCamera;
  29499. private _onAfterCheckInputsObserver;
  29500. private _onMeshTargetChangedObserver;
  29501. init(): void;
  29502. attach(camera: ArcRotateCamera): void;
  29503. detach(): void;
  29504. private _radiusIsAnimating;
  29505. private _radiusBounceTransition;
  29506. private _animatables;
  29507. private _cachedWheelPrecision;
  29508. /**
  29509. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29510. * @param radiusLimit The limit to check against.
  29511. * @return Bool to indicate if at limit.
  29512. */
  29513. private _isRadiusAtLimit(radiusLimit);
  29514. /**
  29515. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29516. * @param radiusDelta The delta by which to animate to. Can be negative.
  29517. */
  29518. private _applyBoundRadiusAnimation(radiusDelta);
  29519. /**
  29520. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29521. */
  29522. protected _clearAnimationLocks(): void;
  29523. /**
  29524. * Stops and removes all animations that have been applied to the camera
  29525. */
  29526. stopAllAnimations(): void;
  29527. }
  29528. }
  29529. declare module BABYLON {
  29530. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29531. readonly name: string;
  29532. private _mode;
  29533. private _radiusScale;
  29534. private _positionScale;
  29535. private _defaultElevation;
  29536. private _elevationReturnTime;
  29537. private _elevationReturnWaitTime;
  29538. private _zoomStopsAnimation;
  29539. private _framingTime;
  29540. /**
  29541. * The easing function used by animations
  29542. */
  29543. static EasingFunction: ExponentialEase;
  29544. /**
  29545. * The easing mode used by animations
  29546. */
  29547. static EasingMode: number;
  29548. /**
  29549. * Gets current mode used by the behavior.
  29550. */
  29551. /**
  29552. * Sets the current mode used by the behavior
  29553. */
  29554. mode: number;
  29555. /**
  29556. * Gets the scale applied to the radius
  29557. */
  29558. /**
  29559. * Sets the scale applied to the radius (1 by default)
  29560. */
  29561. radiusScale: number;
  29562. /**
  29563. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29564. */
  29565. /**
  29566. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29567. */
  29568. positionScale: number;
  29569. /**
  29570. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29571. * behaviour is triggered, in radians.
  29572. */
  29573. /**
  29574. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29575. * behaviour is triggered, in radians.
  29576. */
  29577. defaultElevation: number;
  29578. /**
  29579. * Gets the time (in milliseconds) taken to return to the default beta position.
  29580. * Negative value indicates camera should not return to default.
  29581. */
  29582. /**
  29583. * Sets the time (in milliseconds) taken to return to the default beta position.
  29584. * Negative value indicates camera should not return to default.
  29585. */
  29586. elevationReturnTime: number;
  29587. /**
  29588. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29589. */
  29590. /**
  29591. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29592. */
  29593. elevationReturnWaitTime: number;
  29594. /**
  29595. * Gets the flag that indicates if user zooming should stop animation.
  29596. */
  29597. /**
  29598. * Sets the flag that indicates if user zooming should stop animation.
  29599. */
  29600. zoomStopsAnimation: boolean;
  29601. /**
  29602. * Gets the transition time when framing the mesh, in milliseconds
  29603. */
  29604. /**
  29605. * Sets the transition time when framing the mesh, in milliseconds
  29606. */
  29607. framingTime: number;
  29608. private _onPrePointerObservableObserver;
  29609. private _onAfterCheckInputsObserver;
  29610. private _onMeshTargetChangedObserver;
  29611. private _attachedCamera;
  29612. private _isPointerDown;
  29613. private _lastInteractionTime;
  29614. init(): void;
  29615. attach(camera: ArcRotateCamera): void;
  29616. detach(): void;
  29617. private _animatables;
  29618. private _betaIsAnimating;
  29619. private _betaTransition;
  29620. private _radiusTransition;
  29621. private _vectorTransition;
  29622. /**
  29623. * Targets the given mesh and updates zoom level accordingly.
  29624. * @param mesh The mesh to target.
  29625. * @param radius Optional. If a cached radius position already exists, overrides default.
  29626. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29627. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29628. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29629. */
  29630. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29631. /**
  29632. * Targets the given mesh with its children and updates zoom level accordingly.
  29633. * @param mesh The mesh to target.
  29634. * @param radius Optional. If a cached radius position already exists, overrides default.
  29635. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29636. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29637. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29638. */
  29639. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29640. /**
  29641. * Targets the given meshes with their children and updates zoom level accordingly.
  29642. * @param meshes The mesh to target.
  29643. * @param radius Optional. If a cached radius position already exists, overrides default.
  29644. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29645. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29646. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29647. */
  29648. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29649. /**
  29650. * Targets the given mesh and updates zoom level accordingly.
  29651. * @param mesh The mesh to target.
  29652. * @param radius Optional. If a cached radius position already exists, overrides default.
  29653. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29654. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29655. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29656. */
  29657. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29658. /**
  29659. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29660. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29661. * frustum width.
  29662. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29663. * to fully enclose the mesh in the viewing frustum.
  29664. */
  29665. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29666. /**
  29667. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29668. * is automatically returned to its default position (expected to be above ground plane).
  29669. */
  29670. private _maintainCameraAboveGround();
  29671. /**
  29672. * Returns the frustum slope based on the canvas ratio and camera FOV
  29673. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29674. */
  29675. private _getFrustumSlope();
  29676. /**
  29677. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29678. */
  29679. private _clearAnimationLocks();
  29680. /**
  29681. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29682. */
  29683. private _applyUserInteraction();
  29684. /**
  29685. * Stops and removes all animations that have been applied to the camera
  29686. */
  29687. stopAllAnimations(): void;
  29688. /**
  29689. * Gets a value indicating if the user is moving the camera
  29690. */
  29691. readonly isUserIsMoving: boolean;
  29692. /**
  29693. * The camera can move all the way towards the mesh.
  29694. */
  29695. static IgnoreBoundsSizeMode: number;
  29696. /**
  29697. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29698. */
  29699. static FitFrustumSidesMode: number;
  29700. }
  29701. }
  29702. declare module BABYLON {
  29703. /**
  29704. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  29705. */
  29706. class PointerDragBehavior implements Behavior<Mesh> {
  29707. private options;
  29708. private _attachedNode;
  29709. private _dragPlane;
  29710. private _scene;
  29711. private _pointerObserver;
  29712. private static _planeScene;
  29713. private _draggingID;
  29714. /**
  29715. * Fires each time the attached mesh is dragged with the pointer
  29716. */
  29717. onDragObservable: Observable<{
  29718. delta: Vector3;
  29719. dragPlanePoint: Vector3;
  29720. }>;
  29721. /**
  29722. * Fires each time a drag begins (eg. mouse down on mesh)
  29723. */
  29724. onDragStartObservable: Observable<{
  29725. dragPlanePoint: Vector3;
  29726. }>;
  29727. /**
  29728. * Fires each time a drag ends (eg. mouse release after drag)
  29729. */
  29730. onDragEndObservable: Observable<{
  29731. dragPlanePoint: Vector3;
  29732. }>;
  29733. /**
  29734. * If the attached mesh should be moved when dragged
  29735. */
  29736. moveAttached: boolean;
  29737. /**
  29738. * Mesh with the position where the drag plane should be placed
  29739. */
  29740. _dragPlaneParent: Nullable<Mesh>;
  29741. /**
  29742. * Creates a pointer drag behavior that can be attached to a mesh
  29743. * @param options The drag axis or normal of the plane that will be dragged across. pointerObservableScene can be used to listen to drag events from another scene(eg. if the attached mesh is in an overlay scene).
  29744. */
  29745. constructor(options: {
  29746. dragAxis?: Vector3;
  29747. dragPlaneNormal?: Vector3;
  29748. pointerObservableScene?: Scene;
  29749. });
  29750. /**
  29751. * The name of the behavior
  29752. */
  29753. readonly name: string;
  29754. /**
  29755. * Initializes the behavior
  29756. */
  29757. init(): void;
  29758. /**
  29759. * Attaches the drag behavior the passed in mesh
  29760. * @param ownerNode The mesh that will be dragged around once attached
  29761. */
  29762. attach(ownerNode: Mesh): void;
  29763. private _pickWithRayOnDragPlane(ray);
  29764. private _updateDragPlanePosition(ray);
  29765. /**
  29766. * Detaches the behavior from the mesh
  29767. */
  29768. detach(): void;
  29769. }
  29770. }
  29771. declare module BABYLON {
  29772. class VRCameraMetrics {
  29773. hResolution: number;
  29774. vResolution: number;
  29775. hScreenSize: number;
  29776. vScreenSize: number;
  29777. vScreenCenter: number;
  29778. eyeToScreenDistance: number;
  29779. lensSeparationDistance: number;
  29780. interpupillaryDistance: number;
  29781. distortionK: number[];
  29782. chromaAbCorrection: number[];
  29783. postProcessScaleFactor: number;
  29784. lensCenterOffset: number;
  29785. compensateDistortion: boolean;
  29786. readonly aspectRatio: number;
  29787. readonly aspectRatioFov: number;
  29788. readonly leftHMatrix: Matrix;
  29789. readonly rightHMatrix: Matrix;
  29790. readonly leftPreViewMatrix: Matrix;
  29791. readonly rightPreViewMatrix: Matrix;
  29792. static GetDefault(): VRCameraMetrics;
  29793. }
  29794. }
  29795. declare module BABYLON {
  29796. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29797. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29798. getClassName(): string;
  29799. }
  29800. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29801. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29802. getClassName(): string;
  29803. }
  29804. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29805. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29806. getClassName(): string;
  29807. }
  29808. }
  29809. declare module BABYLON {
  29810. /**
  29811. * Options to modify the vr teleportation behavior.
  29812. */
  29813. interface VRTeleportationOptions {
  29814. /**
  29815. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29816. */
  29817. floorMeshName?: string;
  29818. /**
  29819. * A list of meshes to be used as the teleportation floor. (default: empty)
  29820. */
  29821. floorMeshes?: Mesh[];
  29822. }
  29823. /**
  29824. * Options to modify the vr experience helper's behavior.
  29825. */
  29826. interface VRExperienceHelperOptions extends WebVROptions {
  29827. /**
  29828. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  29829. */
  29830. createDeviceOrientationCamera?: boolean;
  29831. /**
  29832. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  29833. */
  29834. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29835. /**
  29836. * Uses the main button on the controller to toggle the laser casted. (default: true)
  29837. */
  29838. laserToggle?: boolean;
  29839. /**
  29840. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  29841. */
  29842. floorMeshes?: Mesh[];
  29843. }
  29844. /**
  29845. * Helps to quickly add VR support to an existing scene.
  29846. * See http://doc.babylonjs.com/how_to/webvr_helper
  29847. */
  29848. class VRExperienceHelper {
  29849. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29850. private _scene;
  29851. private _position;
  29852. private _btnVR;
  29853. private _btnVRDisplayed;
  29854. private _webVRsupported;
  29855. private _webVRready;
  29856. private _webVRrequesting;
  29857. private _webVRpresenting;
  29858. private _fullscreenVRpresenting;
  29859. private _canvas;
  29860. private _webVRCamera;
  29861. private _vrDeviceOrientationCamera;
  29862. private _deviceOrientationCamera;
  29863. private _existingCamera;
  29864. private _onKeyDown;
  29865. private _onVrDisplayPresentChange;
  29866. private _onVRDisplayChanged;
  29867. private _onVRRequestPresentStart;
  29868. private _onVRRequestPresentComplete;
  29869. /**
  29870. * Observable raised when entering VR.
  29871. */
  29872. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29873. /**
  29874. * Observable raised when exiting VR.
  29875. */
  29876. onExitingVRObservable: Observable<VRExperienceHelper>;
  29877. /**
  29878. * Observable raised when controller mesh is loaded.
  29879. */
  29880. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29881. /** Return this.onEnteringVRObservable
  29882. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29883. */
  29884. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29885. /** Return this.onExitingVRObservable
  29886. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29887. */
  29888. readonly onExitingVR: Observable<VRExperienceHelper>;
  29889. /** Return this.onControllerMeshLoadedObservable
  29890. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29891. */
  29892. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29893. private _rayLength;
  29894. private _useCustomVRButton;
  29895. private _teleportationRequested;
  29896. private _teleportActive;
  29897. private _floorMeshName;
  29898. private _floorMeshesCollection;
  29899. private _rotationAllowed;
  29900. private _teleportBackwardsVector;
  29901. private _teleportationTarget;
  29902. private _isDefaultTeleportationTarget;
  29903. private _postProcessMove;
  29904. private _teleportationFillColor;
  29905. private _teleportationBorderColor;
  29906. private _rotationAngle;
  29907. private _haloCenter;
  29908. private _cameraGazer;
  29909. private _padSensibilityUp;
  29910. private _padSensibilityDown;
  29911. private leftController;
  29912. private rightController;
  29913. /**
  29914. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29915. */
  29916. onNewMeshSelected: Observable<AbstractMesh>;
  29917. /**
  29918. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29919. */
  29920. onNewMeshPicked: Observable<PickingInfo>;
  29921. private _circleEase;
  29922. /**
  29923. * Observable raised before camera teleportation
  29924. */
  29925. onBeforeCameraTeleport: Observable<Vector3>;
  29926. /**
  29927. * Observable raised after camera teleportation
  29928. */
  29929. onAfterCameraTeleport: Observable<Vector3>;
  29930. /**
  29931. * Observable raised when current selected mesh gets unselected
  29932. */
  29933. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29934. private _raySelectionPredicate;
  29935. /**
  29936. * To be optionaly changed by user to define custom ray selection
  29937. */
  29938. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29939. /**
  29940. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29941. */
  29942. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29943. /**
  29944. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29945. */
  29946. teleportationEnabled: boolean;
  29947. private _defaultHeight;
  29948. private _teleportationInitialized;
  29949. private _interactionsEnabled;
  29950. private _interactionsRequested;
  29951. private _displayGaze;
  29952. private _displayLaserPointer;
  29953. /**
  29954. * The mesh used to display where the user is going to teleport.
  29955. */
  29956. /**
  29957. * Sets the mesh to be used to display where the user is going to teleport.
  29958. */
  29959. teleportationTarget: Mesh;
  29960. /**
  29961. * The mesh used to display where the user is selecting,
  29962. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29963. * See http://doc.babylonjs.com/resources/baking_transformations
  29964. */
  29965. gazeTrackerMesh: Mesh;
  29966. /**
  29967. * If the ray of the gaze should be displayed.
  29968. */
  29969. /**
  29970. * Sets if the ray of the gaze should be displayed.
  29971. */
  29972. displayGaze: boolean;
  29973. /**
  29974. * If the ray of the LaserPointer should be displayed.
  29975. */
  29976. /**
  29977. * Sets if the ray of the LaserPointer should be displayed.
  29978. */
  29979. displayLaserPointer: boolean;
  29980. /**
  29981. * The deviceOrientationCamera used as the camera when not in VR.
  29982. */
  29983. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29984. /**
  29985. * Based on the current WebVR support, returns the current VR camera used.
  29986. */
  29987. readonly currentVRCamera: Nullable<Camera>;
  29988. /**
  29989. * The webVRCamera which is used when in VR.
  29990. */
  29991. readonly webVRCamera: WebVRFreeCamera;
  29992. /**
  29993. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29994. */
  29995. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29996. private readonly _teleportationRequestInitiated;
  29997. /**
  29998. * Instantiates a VRExperienceHelper.
  29999. * Helps to quickly add VR support to an existing scene.
  30000. * @param scene The scene the VRExperienceHelper belongs to.
  30001. * @param webVROptions Options to modify the vr experience helper's behavior.
  30002. */
  30003. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30004. private _onDefaultMeshLoaded(webVRController);
  30005. private _onResize;
  30006. private _onFullscreenChange;
  30007. /**
  30008. * Gets a value indicating if we are currently in VR mode.
  30009. */
  30010. readonly isInVRMode: boolean;
  30011. private onVrDisplayPresentChange();
  30012. private onVRDisplayChanged(eventArgs);
  30013. private moveButtonToBottomRight();
  30014. private displayVRButton();
  30015. private updateButtonVisibility();
  30016. /**
  30017. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30018. * Otherwise, will use the fullscreen API.
  30019. */
  30020. enterVR(): void;
  30021. /**
  30022. * Attempt to exit VR, or fullscreen.
  30023. */
  30024. exitVR(): void;
  30025. /**
  30026. * The position of the vr experience helper.
  30027. */
  30028. /**
  30029. * Sets the position of the vr experience helper.
  30030. */
  30031. position: Vector3;
  30032. /**
  30033. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30034. */
  30035. enableInteractions(): void;
  30036. private beforeRender;
  30037. private _isTeleportationFloor(mesh);
  30038. /**
  30039. * Adds a floor mesh to be used for teleportation.
  30040. * @param floorMesh the mesh to be used for teleportation.
  30041. */
  30042. addFloorMesh(floorMesh: Mesh): void;
  30043. /**
  30044. * Removes a floor mesh from being used for teleportation.
  30045. * @param floorMesh the mesh to be removed.
  30046. */
  30047. removeFloorMesh(floorMesh: Mesh): void;
  30048. /**
  30049. * Enables interactions and teleportation using the VR controllers and gaze.
  30050. * @param vrTeleportationOptions options to modify teleportation behavior.
  30051. */
  30052. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30053. private _onNewGamepadConnected;
  30054. private _tryEnableInteractionOnController;
  30055. private _onNewGamepadDisconnected;
  30056. private _enableInteractionOnController(controller);
  30057. private _checkTeleportWithRay(stateObject, gazer);
  30058. private _checkRotate(stateObject, gazer);
  30059. private _checkTeleportBackwards(stateObject, gazer);
  30060. private _enableTeleportationOnController(controller);
  30061. private _createTeleportationCircles();
  30062. private _displayTeleportationTarget();
  30063. private _hideTeleportationTarget();
  30064. private _rotateCamera(right);
  30065. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30066. private _workingVector;
  30067. private _workingQuaternion;
  30068. private _workingMatrix;
  30069. private _teleportCamera(location);
  30070. private _convertNormalToDirectionOfRay(normal, ray);
  30071. private _castRayAndSelectObject(gazer);
  30072. private _notifySelectedMeshUnselected(mesh);
  30073. /**
  30074. * Sets the color of the laser ray from the vr controllers.
  30075. * @param color new color for the ray.
  30076. */
  30077. changeLaserColor(color: Color3): void;
  30078. /**
  30079. * Sets the color of the ray from the vr headsets gaze.
  30080. * @param color new color for the ray.
  30081. */
  30082. changeGazeColor(color: Color3): void;
  30083. /**
  30084. * Exits VR and disposes of the vr experience helper
  30085. */
  30086. dispose(): void;
  30087. /**
  30088. * Gets the name of the VRExperienceHelper class
  30089. * @returns "VRExperienceHelper"
  30090. */
  30091. getClassName(): string;
  30092. }
  30093. }
  30094. declare module BABYLON {
  30095. /**
  30096. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30097. * IMPORTANT!! The data is right-hand data.
  30098. * @export
  30099. * @interface DevicePose
  30100. */
  30101. interface DevicePose {
  30102. /**
  30103. * The position of the device, values in array are [x,y,z].
  30104. */
  30105. readonly position: Nullable<Float32Array>;
  30106. /**
  30107. * The linearVelocity of the device, values in array are [x,y,z].
  30108. */
  30109. readonly linearVelocity: Nullable<Float32Array>;
  30110. /**
  30111. * The linearAcceleration of the device, values in array are [x,y,z].
  30112. */
  30113. readonly linearAcceleration: Nullable<Float32Array>;
  30114. /**
  30115. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30116. */
  30117. readonly orientation: Nullable<Float32Array>;
  30118. /**
  30119. * The angularVelocity of the device, values in array are [x,y,z].
  30120. */
  30121. readonly angularVelocity: Nullable<Float32Array>;
  30122. /**
  30123. * The angularAcceleration of the device, values in array are [x,y,z].
  30124. */
  30125. readonly angularAcceleration: Nullable<Float32Array>;
  30126. }
  30127. /**
  30128. * Interface representing a pose controlled object in Babylon.
  30129. * A pose controlled object has both regular pose values as well as pose values
  30130. * from an external device such as a VR head mounted display
  30131. */
  30132. interface PoseControlled {
  30133. /**
  30134. * The position of the object in babylon space.
  30135. */
  30136. position: Vector3;
  30137. /**
  30138. * The rotation quaternion of the object in babylon space.
  30139. */
  30140. rotationQuaternion: Quaternion;
  30141. /**
  30142. * The position of the device in babylon space.
  30143. */
  30144. devicePosition?: Vector3;
  30145. /**
  30146. * The rotation quaternion of the device in babylon space.
  30147. */
  30148. deviceRotationQuaternion: Quaternion;
  30149. /**
  30150. * The raw pose coming from the device.
  30151. */
  30152. rawPose: Nullable<DevicePose>;
  30153. /**
  30154. * The scale of the device to be used when translating from device space to babylon space.
  30155. */
  30156. deviceScaleFactor: number;
  30157. /**
  30158. * Updates the poseControlled values based on the input device pose.
  30159. * @param poseData the pose data to update the object with
  30160. */
  30161. updateFromDevice(poseData: DevicePose): void;
  30162. }
  30163. /**
  30164. * Set of options to customize the webVRCamera
  30165. */
  30166. interface WebVROptions {
  30167. /**
  30168. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  30169. */
  30170. trackPosition?: boolean;
  30171. /**
  30172. * Sets the scale of the vrDevice in babylon space. (default: 1)
  30173. */
  30174. positionScale?: number;
  30175. /**
  30176. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  30177. */
  30178. displayName?: string;
  30179. /**
  30180. * Should the native controller meshes be initialized. (default: true)
  30181. */
  30182. controllerMeshes?: boolean;
  30183. /**
  30184. * Creating a default HemiLight only on controllers. (default: true)
  30185. */
  30186. defaultLightingOnControllers?: boolean;
  30187. /**
  30188. * If you don't want to use the default VR button of the helper. (default: false)
  30189. */
  30190. useCustomVRButton?: boolean;
  30191. /**
  30192. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  30193. */
  30194. customVRButton?: HTMLButtonElement;
  30195. /**
  30196. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  30197. */
  30198. rayLength?: number;
  30199. /**
  30200. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  30201. */
  30202. defaultHeight?: number;
  30203. }
  30204. /**
  30205. * This represents a WebVR camera.
  30206. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  30207. * @example http://doc.babylonjs.com/how_to/webvr_camera
  30208. */
  30209. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  30210. private webVROptions;
  30211. /**
  30212. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  30213. */
  30214. _vrDevice: any;
  30215. /**
  30216. * The rawPose of the vrDevice.
  30217. */
  30218. rawPose: Nullable<DevicePose>;
  30219. private _onVREnabled;
  30220. private _specsVersion;
  30221. private _attached;
  30222. private _frameData;
  30223. protected _descendants: Array<Node>;
  30224. private _deviceRoomPosition;
  30225. private _deviceRoomRotationQuaternion;
  30226. private _standingMatrix;
  30227. /**
  30228. * Represents device position in babylon space.
  30229. */
  30230. devicePosition: Vector3;
  30231. /**
  30232. * Represents device rotation in babylon space.
  30233. */
  30234. deviceRotationQuaternion: Quaternion;
  30235. /**
  30236. * The scale of the device to be used when translating from device space to babylon space.
  30237. */
  30238. deviceScaleFactor: number;
  30239. private _deviceToWorld;
  30240. private _worldToDevice;
  30241. /**
  30242. * References to the webVR controllers for the vrDevice.
  30243. */
  30244. controllers: Array<WebVRController>;
  30245. /**
  30246. * Emits an event when a controller is attached.
  30247. */
  30248. onControllersAttachedObservable: Observable<WebVRController[]>;
  30249. /**
  30250. * Emits an event when a controller's mesh has been loaded;
  30251. */
  30252. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30253. /**
  30254. * If the rig cameras be used as parent instead of this camera.
  30255. */
  30256. rigParenting: boolean;
  30257. private _lightOnControllers;
  30258. private _defaultHeight?;
  30259. /**
  30260. * Instantiates a WebVRFreeCamera.
  30261. * @param name The name of the WebVRFreeCamera
  30262. * @param position The starting anchor position for the camera
  30263. * @param scene The scene the camera belongs to
  30264. * @param webVROptions a set of customizable options for the webVRCamera
  30265. */
  30266. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30267. /**
  30268. * Gets the device distance from the ground in meters.
  30269. * @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.
  30270. */
  30271. deviceDistanceToRoomGround(): number;
  30272. /**
  30273. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30274. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30275. */
  30276. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30277. /**
  30278. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30279. * @returns A promise with a boolean set to if the standing matrix is supported.
  30280. */
  30281. useStandingMatrixAsync(): Promise<boolean>;
  30282. /**
  30283. * Disposes the camera
  30284. */
  30285. dispose(): void;
  30286. /**
  30287. * Gets a vrController by name.
  30288. * @param name The name of the controller to retreive
  30289. * @returns the controller matching the name specified or null if not found
  30290. */
  30291. getControllerByName(name: string): Nullable<WebVRController>;
  30292. private _leftController;
  30293. /**
  30294. * The controller corrisponding to the users left hand.
  30295. */
  30296. readonly leftController: Nullable<WebVRController>;
  30297. private _rightController;
  30298. /**
  30299. * The controller corrisponding to the users right hand.
  30300. */
  30301. readonly rightController: Nullable<WebVRController>;
  30302. /**
  30303. * Casts a ray forward from the vrCamera's gaze.
  30304. * @param length Length of the ray (default: 100)
  30305. * @returns the ray corrisponding to the gaze
  30306. */
  30307. getForwardRay(length?: number): Ray;
  30308. /**
  30309. * Updates the camera based on device's frame data
  30310. */
  30311. _checkInputs(): void;
  30312. /**
  30313. * Updates the poseControlled values based on the input device pose.
  30314. * @param poseData Pose coming from the device
  30315. */
  30316. updateFromDevice(poseData: DevicePose): void;
  30317. /**
  30318. * WebVR's attach control will start broadcasting frames to the device.
  30319. * Note that in certain browsers (chrome for example) this function must be called
  30320. * within a user-interaction callback. Example:
  30321. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30322. *
  30323. * @param element html element to attach the vrDevice to
  30324. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30325. */
  30326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30327. /**
  30328. * Detaches the camera from the html element and disables VR
  30329. *
  30330. * @param element html element to detach from
  30331. */
  30332. detachControl(element: HTMLElement): void;
  30333. /**
  30334. * @returns the name of this class
  30335. */
  30336. getClassName(): string;
  30337. /**
  30338. * Calls resetPose on the vrDisplay
  30339. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30340. */
  30341. resetToCurrentRotation(): void;
  30342. /**
  30343. * Updates the rig cameras (left and right eye)
  30344. */
  30345. _updateRigCameras(): void;
  30346. private _workingVector;
  30347. private _oneVector;
  30348. private _workingMatrix;
  30349. private updateCacheCalled;
  30350. /**
  30351. * Updates the cached values of the camera
  30352. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30353. */
  30354. _updateCache(ignoreParentClass?: boolean): void;
  30355. /**
  30356. * Updates the current device position and rotation in the babylon world
  30357. */
  30358. update(): void;
  30359. /**
  30360. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  30361. * @returns an identity matrix
  30362. */
  30363. _getViewMatrix(): Matrix;
  30364. /**
  30365. * This function is called by the two RIG cameras.
  30366. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  30367. */
  30368. protected _getWebVRViewMatrix(): Matrix;
  30369. protected _getWebVRProjectionMatrix(): Matrix;
  30370. private _onGamepadConnectedObserver;
  30371. private _onGamepadDisconnectedObserver;
  30372. /**
  30373. * Initializes the controllers and their meshes
  30374. */
  30375. initControllers(): void;
  30376. }
  30377. }
  30378. declare module BABYLON {
  30379. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  30380. camera: ArcRotateCamera;
  30381. gamepad: Nullable<Gamepad>;
  30382. private _onGamepadConnectedObserver;
  30383. private _onGamepadDisconnectedObserver;
  30384. gamepadRotationSensibility: number;
  30385. gamepadMoveSensibility: number;
  30386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30387. detachControl(element: Nullable<HTMLElement>): void;
  30388. checkInputs(): void;
  30389. getClassName(): string;
  30390. getSimpleName(): string;
  30391. }
  30392. }
  30393. declare module BABYLON {
  30394. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  30395. camera: ArcRotateCamera;
  30396. private _keys;
  30397. keysUp: number[];
  30398. keysDown: number[];
  30399. keysLeft: number[];
  30400. keysRight: number[];
  30401. keysReset: number[];
  30402. panningSensibility: number;
  30403. zoomingSensibility: number;
  30404. useAltToZoom: boolean;
  30405. private _ctrlPressed;
  30406. private _altPressed;
  30407. private _onCanvasBlurObserver;
  30408. private _onKeyboardObserver;
  30409. private _engine;
  30410. private _scene;
  30411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30412. detachControl(element: Nullable<HTMLElement>): void;
  30413. checkInputs(): void;
  30414. getClassName(): string;
  30415. getSimpleName(): string;
  30416. }
  30417. }
  30418. declare module BABYLON {
  30419. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  30420. camera: ArcRotateCamera;
  30421. private _wheel;
  30422. private _observer;
  30423. wheelPrecision: number;
  30424. /**
  30425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  30426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  30427. */
  30428. wheelDeltaPercentage: number;
  30429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30430. detachControl(element: Nullable<HTMLElement>): void;
  30431. getClassName(): string;
  30432. getSimpleName(): string;
  30433. }
  30434. }
  30435. declare module BABYLON {
  30436. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  30437. camera: ArcRotateCamera;
  30438. buttons: number[];
  30439. angularSensibilityX: number;
  30440. angularSensibilityY: number;
  30441. pinchPrecision: number;
  30442. /**
  30443. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  30444. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  30445. */
  30446. pinchDeltaPercentage: number;
  30447. panningSensibility: number;
  30448. multiTouchPanning: boolean;
  30449. multiTouchPanAndZoom: boolean;
  30450. private _isPanClick;
  30451. pinchInwards: boolean;
  30452. private _pointerInput;
  30453. private _observer;
  30454. private _onMouseMove;
  30455. private _onGestureStart;
  30456. private _onGesture;
  30457. private _MSGestureHandler;
  30458. private _onLostFocus;
  30459. private _onContextMenu;
  30460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30461. detachControl(element: Nullable<HTMLElement>): void;
  30462. getClassName(): string;
  30463. getSimpleName(): string;
  30464. }
  30465. }
  30466. declare module BABYLON {
  30467. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  30468. camera: ArcRotateCamera;
  30469. alphaCorrection: number;
  30470. betaCorrection: number;
  30471. gammaCorrection: number;
  30472. private _alpha;
  30473. private _gamma;
  30474. private _dirty;
  30475. private _deviceOrientationHandler;
  30476. constructor();
  30477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30478. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  30479. checkInputs(): void;
  30480. detachControl(element: Nullable<HTMLElement>): void;
  30481. getClassName(): string;
  30482. getSimpleName(): string;
  30483. }
  30484. }
  30485. declare module BABYLON {
  30486. /**
  30487. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  30488. * Screen rotation is taken into account.
  30489. */
  30490. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  30491. private _camera;
  30492. private _screenOrientationAngle;
  30493. private _constantTranform;
  30494. private _screenQuaternion;
  30495. private _alpha;
  30496. private _beta;
  30497. private _gamma;
  30498. constructor();
  30499. camera: FreeCamera;
  30500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30501. private _orientationChanged;
  30502. private _deviceOrientation;
  30503. detachControl(element: Nullable<HTMLElement>): void;
  30504. checkInputs(): void;
  30505. getClassName(): string;
  30506. getSimpleName(): string;
  30507. }
  30508. }
  30509. declare module BABYLON {
  30510. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  30511. camera: FreeCamera;
  30512. gamepad: Nullable<Gamepad>;
  30513. private _onGamepadConnectedObserver;
  30514. private _onGamepadDisconnectedObserver;
  30515. gamepadAngularSensibility: number;
  30516. gamepadMoveSensibility: number;
  30517. private _cameraTransform;
  30518. private _deltaTransform;
  30519. private _vector3;
  30520. private _vector2;
  30521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30522. detachControl(element: Nullable<HTMLElement>): void;
  30523. checkInputs(): void;
  30524. getClassName(): string;
  30525. getSimpleName(): string;
  30526. }
  30527. }
  30528. declare module BABYLON {
  30529. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  30530. camera: FreeCamera;
  30531. private _keys;
  30532. private _onCanvasBlurObserver;
  30533. private _onKeyboardObserver;
  30534. private _engine;
  30535. private _scene;
  30536. keysUp: number[];
  30537. keysDown: number[];
  30538. keysLeft: number[];
  30539. keysRight: number[];
  30540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30541. detachControl(element: Nullable<HTMLElement>): void;
  30542. checkInputs(): void;
  30543. getClassName(): string;
  30544. _onLostFocus(e: FocusEvent): void;
  30545. getSimpleName(): string;
  30546. }
  30547. }
  30548. declare module BABYLON {
  30549. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  30550. touchEnabled: boolean;
  30551. camera: FreeCamera;
  30552. buttons: number[];
  30553. angularSensibility: number;
  30554. private _pointerInput;
  30555. private _onMouseMove;
  30556. private _observer;
  30557. private previousPosition;
  30558. constructor(touchEnabled?: boolean);
  30559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30560. detachControl(element: Nullable<HTMLElement>): void;
  30561. getClassName(): string;
  30562. getSimpleName(): string;
  30563. }
  30564. }
  30565. declare module BABYLON {
  30566. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  30567. camera: FreeCamera;
  30568. private _offsetX;
  30569. private _offsetY;
  30570. private _pointerPressed;
  30571. private _pointerInput;
  30572. private _observer;
  30573. private _onLostFocus;
  30574. touchAngularSensibility: number;
  30575. touchMoveSensibility: number;
  30576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30577. detachControl(element: Nullable<HTMLElement>): void;
  30578. checkInputs(): void;
  30579. getClassName(): string;
  30580. getSimpleName(): string;
  30581. }
  30582. }
  30583. declare module BABYLON {
  30584. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  30585. camera: FreeCamera;
  30586. private _leftjoystick;
  30587. private _rightjoystick;
  30588. getLeftJoystick(): VirtualJoystick;
  30589. getRightJoystick(): VirtualJoystick;
  30590. checkInputs(): void;
  30591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30592. detachControl(element: Nullable<HTMLElement>): void;
  30593. getClassName(): string;
  30594. getSimpleName(): string;
  30595. }
  30596. }
  30597. declare module BABYLON {
  30598. interface IOctreeContainer<T> {
  30599. blocks: Array<OctreeBlock<T>>;
  30600. }
  30601. class Octree<T> {
  30602. maxDepth: number;
  30603. blocks: Array<OctreeBlock<T>>;
  30604. dynamicContent: T[];
  30605. private _maxBlockCapacity;
  30606. private _selectionContent;
  30607. private _creationFunc;
  30608. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  30609. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  30610. addMesh(entry: T): void;
  30611. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  30612. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  30613. intersectsRay(ray: Ray): SmartArray<T>;
  30614. 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;
  30615. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  30616. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  30617. }
  30618. }
  30619. declare module BABYLON {
  30620. class OctreeBlock<T> {
  30621. entries: T[];
  30622. blocks: Array<OctreeBlock<T>>;
  30623. private _depth;
  30624. private _maxDepth;
  30625. private _capacity;
  30626. private _minPoint;
  30627. private _maxPoint;
  30628. private _boundingVectors;
  30629. private _creationFunc;
  30630. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  30631. readonly capacity: number;
  30632. readonly minPoint: Vector3;
  30633. readonly maxPoint: Vector3;
  30634. addEntry(entry: T): void;
  30635. addEntries(entries: T[]): void;
  30636. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30637. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30638. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  30639. createInnerBlocks(): void;
  30640. }
  30641. }
  30642. declare module BABYLON {
  30643. /**
  30644. * Google Daydream controller
  30645. */
  30646. class DaydreamController extends WebVRController {
  30647. /**
  30648. * Base Url for the controller model.
  30649. */
  30650. static MODEL_BASE_URL: string;
  30651. /**
  30652. * File name for the controller model.
  30653. */
  30654. static MODEL_FILENAME: string;
  30655. /**
  30656. * Gamepad Id prefix used to identify Daydream Controller.
  30657. */
  30658. static readonly GAMEPAD_ID_PREFIX: string;
  30659. /**
  30660. * Creates a new DaydreamController from a gamepad
  30661. * @param vrGamepad the gamepad that the controller should be created from
  30662. */
  30663. constructor(vrGamepad: any);
  30664. /**
  30665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30666. * @param scene scene in which to add meshes
  30667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30668. */
  30669. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30670. /**
  30671. * Called once for each button that changed state since the last frame
  30672. * @param buttonIdx Which button index changed
  30673. * @param state New state of the button
  30674. * @param changes Which properties on the state changed since last frame
  30675. */
  30676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30677. }
  30678. }
  30679. declare module BABYLON {
  30680. /**
  30681. * Gear VR Controller
  30682. */
  30683. class GearVRController extends WebVRController {
  30684. /**
  30685. * Base Url for the controller model.
  30686. */
  30687. static MODEL_BASE_URL: string;
  30688. /**
  30689. * File name for the controller model.
  30690. */
  30691. static MODEL_FILENAME: string;
  30692. /**
  30693. * Gamepad Id prefix used to identify this controller.
  30694. */
  30695. static readonly GAMEPAD_ID_PREFIX: string;
  30696. private readonly _buttonIndexToObservableNameMap;
  30697. /**
  30698. * Creates a new GearVRController from a gamepad
  30699. * @param vrGamepad the gamepad that the controller should be created from
  30700. */
  30701. constructor(vrGamepad: any);
  30702. /**
  30703. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30704. * @param scene scene in which to add meshes
  30705. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30706. */
  30707. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30708. /**
  30709. * Called once for each button that changed state since the last frame
  30710. * @param buttonIdx Which button index changed
  30711. * @param state New state of the button
  30712. * @param changes Which properties on the state changed since last frame
  30713. */
  30714. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30715. }
  30716. }
  30717. declare module BABYLON {
  30718. /**
  30719. * Generic Controller
  30720. */
  30721. class GenericController extends WebVRController {
  30722. /**
  30723. * Base Url for the controller model.
  30724. */
  30725. static readonly MODEL_BASE_URL: string;
  30726. /**
  30727. * File name for the controller model.
  30728. */
  30729. static readonly MODEL_FILENAME: string;
  30730. /**
  30731. * Creates a new GenericController from a gamepad
  30732. * @param vrGamepad the gamepad that the controller should be created from
  30733. */
  30734. constructor(vrGamepad: any);
  30735. /**
  30736. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30737. * @param scene scene in which to add meshes
  30738. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30739. */
  30740. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30741. /**
  30742. * Called once for each button that changed state since the last frame
  30743. * @param buttonIdx Which button index changed
  30744. * @param state New state of the button
  30745. * @param changes Which properties on the state changed since last frame
  30746. */
  30747. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30748. }
  30749. }
  30750. declare module BABYLON {
  30751. /**
  30752. * Oculus Touch Controller
  30753. */
  30754. class OculusTouchController extends WebVRController {
  30755. /**
  30756. * Base Url for the controller model.
  30757. */
  30758. static MODEL_BASE_URL: string;
  30759. /**
  30760. * File name for the left controller model.
  30761. */
  30762. static MODEL_LEFT_FILENAME: string;
  30763. /**
  30764. * File name for the right controller model.
  30765. */
  30766. static MODEL_RIGHT_FILENAME: string;
  30767. /**
  30768. * Fired when the secondary trigger on this controller is modified
  30769. */
  30770. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30771. /**
  30772. * Fired when the thumb rest on this controller is modified
  30773. */
  30774. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30775. /**
  30776. * Creates a new OculusTouchController from a gamepad
  30777. * @param vrGamepad the gamepad that the controller should be created from
  30778. */
  30779. constructor(vrGamepad: any);
  30780. /**
  30781. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30782. * @param scene scene in which to add meshes
  30783. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30784. */
  30785. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30786. /**
  30787. * Fired when the A button on this controller is modified
  30788. */
  30789. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30790. /**
  30791. * Fired when the B button on this controller is modified
  30792. */
  30793. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30794. /**
  30795. * Fired when the X button on this controller is modified
  30796. */
  30797. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30798. /**
  30799. * Fired when the Y button on this controller is modified
  30800. */
  30801. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30802. /**
  30803. * Called once for each button that changed state since the last frame
  30804. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30805. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30806. * 2) secondary trigger (same)
  30807. * 3) A (right) X (left), touch, pressed = value
  30808. * 4) B / Y
  30809. * 5) thumb rest
  30810. * @param buttonIdx Which button index changed
  30811. * @param state New state of the button
  30812. * @param changes Which properties on the state changed since last frame
  30813. */
  30814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30815. }
  30816. }
  30817. declare module BABYLON {
  30818. /**
  30819. * Defines the types of pose enabled controllers that are supported
  30820. */
  30821. enum PoseEnabledControllerType {
  30822. /**
  30823. * HTC Vive
  30824. */
  30825. VIVE = 0,
  30826. /**
  30827. * Oculus Rift
  30828. */
  30829. OCULUS = 1,
  30830. /**
  30831. * Windows mixed reality
  30832. */
  30833. WINDOWS = 2,
  30834. /**
  30835. * Samsung gear VR
  30836. */
  30837. GEAR_VR = 3,
  30838. /**
  30839. * Google Daydream
  30840. */
  30841. DAYDREAM = 4,
  30842. /**
  30843. * Generic
  30844. */
  30845. GENERIC = 5,
  30846. }
  30847. /**
  30848. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30849. */
  30850. interface MutableGamepadButton {
  30851. /**
  30852. * Value of the button/trigger
  30853. */
  30854. value: number;
  30855. /**
  30856. * If the button/trigger is currently touched
  30857. */
  30858. touched: boolean;
  30859. /**
  30860. * If the button/trigger is currently pressed
  30861. */
  30862. pressed: boolean;
  30863. }
  30864. /**
  30865. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30866. * @hidden
  30867. */
  30868. interface ExtendedGamepadButton extends GamepadButton {
  30869. /**
  30870. * If the button/trigger is currently pressed
  30871. */
  30872. readonly pressed: boolean;
  30873. /**
  30874. * If the button/trigger is currently touched
  30875. */
  30876. readonly touched: boolean;
  30877. /**
  30878. * Value of the button/trigger
  30879. */
  30880. readonly value: number;
  30881. }
  30882. /**
  30883. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30884. */
  30885. class PoseEnabledControllerHelper {
  30886. /**
  30887. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30888. * @param vrGamepad the gamepad to initialized
  30889. * @returns a vr controller of the type the gamepad identified as
  30890. */
  30891. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30892. }
  30893. /**
  30894. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30895. */
  30896. class PoseEnabledController extends Gamepad implements PoseControlled {
  30897. private _deviceRoomPosition;
  30898. private _deviceRoomRotationQuaternion;
  30899. /**
  30900. * The device position in babylon space
  30901. */
  30902. devicePosition: Vector3;
  30903. /**
  30904. * The device rotation in babylon space
  30905. */
  30906. deviceRotationQuaternion: Quaternion;
  30907. /**
  30908. * The scale factor of the device in babylon space
  30909. */
  30910. deviceScaleFactor: number;
  30911. /**
  30912. * (Likely devicePosition should be used instead) The device position in its room space
  30913. */
  30914. position: Vector3;
  30915. /**
  30916. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30917. */
  30918. rotationQuaternion: Quaternion;
  30919. /**
  30920. * The type of controller (Eg. Windows mixed reality)
  30921. */
  30922. controllerType: PoseEnabledControllerType;
  30923. protected _calculatedPosition: Vector3;
  30924. private _calculatedRotation;
  30925. /**
  30926. * The raw pose from the device
  30927. */
  30928. rawPose: DevicePose;
  30929. /**
  30930. * Internal, the mesh attached to the controller
  30931. */
  30932. _mesh: Nullable<AbstractMesh>;
  30933. private _poseControlledCamera;
  30934. private _leftHandSystemQuaternion;
  30935. /**
  30936. * Internal, matrix used to convert room space to babylon space
  30937. */
  30938. _deviceToWorld: Matrix;
  30939. /**
  30940. * Node to be used when casting a ray from the controller
  30941. */
  30942. _pointingPoseNode: Nullable<AbstractMesh>;
  30943. /**
  30944. * Name of the child mesh that can be used to cast a ray from the controller
  30945. */
  30946. static readonly POINTING_POSE: string;
  30947. /**
  30948. * Creates a new PoseEnabledController from a gamepad
  30949. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30950. */
  30951. constructor(browserGamepad: any);
  30952. private _workingMatrix;
  30953. /**
  30954. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30955. */
  30956. update(): void;
  30957. /**
  30958. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30959. * @param poseData raw pose fromthe device
  30960. */
  30961. updateFromDevice(poseData: DevicePose): void;
  30962. /**
  30963. * @hidden
  30964. */
  30965. _meshAttachedObservable: Observable<AbstractMesh>;
  30966. /**
  30967. * Attaches a mesh to the controller
  30968. * @param mesh the mesh to be attached
  30969. */
  30970. attachToMesh(mesh: AbstractMesh): void;
  30971. /**
  30972. * Attaches the controllers mesh to a camera
  30973. * @param camera the camera the mesh should be attached to
  30974. */
  30975. attachToPoseControlledCamera(camera: TargetCamera): void;
  30976. /**
  30977. * Disposes of the controller
  30978. */
  30979. dispose(): void;
  30980. /**
  30981. * The mesh that is attached to the controller
  30982. */
  30983. readonly mesh: Nullable<AbstractMesh>;
  30984. /**
  30985. * Gets the ray of the controller in the direction the controller is pointing
  30986. * @param length the length the resulting ray should be
  30987. * @returns a ray in the direction the controller is pointing
  30988. */
  30989. getForwardRay(length?: number): Ray;
  30990. }
  30991. }
  30992. declare module BABYLON {
  30993. /**
  30994. * Vive Controller
  30995. */
  30996. class ViveController extends WebVRController {
  30997. /**
  30998. * Base Url for the controller model.
  30999. */
  31000. static MODEL_BASE_URL: string;
  31001. /**
  31002. * File name for the controller model.
  31003. */
  31004. static MODEL_FILENAME: string;
  31005. /**
  31006. * Creates a new ViveController from a gamepad
  31007. * @param vrGamepad the gamepad that the controller should be created from
  31008. */
  31009. constructor(vrGamepad: any);
  31010. /**
  31011. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31012. * @param scene scene in which to add meshes
  31013. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31014. */
  31015. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31016. /**
  31017. * Fired when the left button on this controller is modified
  31018. */
  31019. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31020. /**
  31021. * Fired when the right button on this controller is modified
  31022. */
  31023. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31024. /**
  31025. * Fired when the menu button on this controller is modified
  31026. */
  31027. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31028. /**
  31029. * Called once for each button that changed state since the last frame
  31030. * Vive mapping:
  31031. * 0: touchpad
  31032. * 1: trigger
  31033. * 2: left AND right buttons
  31034. * 3: menu button
  31035. * @param buttonIdx Which button index changed
  31036. * @param state New state of the button
  31037. * @param changes Which properties on the state changed since last frame
  31038. */
  31039. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31040. }
  31041. }
  31042. declare module BABYLON {
  31043. /**
  31044. * Defines the WebVRController object that represents controllers tracked in 3D space
  31045. */
  31046. abstract class WebVRController extends PoseEnabledController {
  31047. /**
  31048. * Internal, the default controller model for the controller
  31049. */
  31050. protected _defaultModel: AbstractMesh;
  31051. /**
  31052. * Fired when the trigger state has changed
  31053. */
  31054. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31055. /**
  31056. * Fired when the main button state has changed
  31057. */
  31058. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31059. /**
  31060. * Fired when the secondary button state has changed
  31061. */
  31062. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31063. /**
  31064. * Fired when the pad state has changed
  31065. */
  31066. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  31067. /**
  31068. * Fired when controllers stick values have changed
  31069. */
  31070. onPadValuesChangedObservable: Observable<StickValues>;
  31071. /**
  31072. * Array of button availible on the controller
  31073. */
  31074. protected _buttons: Array<MutableGamepadButton>;
  31075. private _onButtonStateChange;
  31076. /**
  31077. * Fired when a controller button's state has changed
  31078. * @param callback the callback containing the button that was modified
  31079. */
  31080. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  31081. /**
  31082. * X and Y axis corrisponding to the controllers joystick
  31083. */
  31084. pad: StickValues;
  31085. /**
  31086. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31087. */
  31088. hand: string;
  31089. /**
  31090. * The default controller model for the controller
  31091. */
  31092. readonly defaultModel: AbstractMesh;
  31093. /**
  31094. * Creates a new WebVRController from a gamepad
  31095. * @param vrGamepad the gamepad that the WebVRController should be created from
  31096. */
  31097. constructor(vrGamepad: any);
  31098. /**
  31099. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31100. */
  31101. update(): void;
  31102. /**
  31103. * Function to be called when a button is modified
  31104. */
  31105. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31106. /**
  31107. * Loads a mesh and attaches it to the controller
  31108. * @param scene the scene the mesh should be added to
  31109. * @param meshLoaded callback for when the mesh has been loaded
  31110. */
  31111. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31112. private _setButtonValue(newState, currentState, buttonIndex);
  31113. private _changes;
  31114. private _checkChanges(newState, currentState);
  31115. /**
  31116. * Disposes of th webVRCOntroller
  31117. */
  31118. dispose(): void;
  31119. }
  31120. }
  31121. declare module BABYLON {
  31122. /**
  31123. * Defines the WindowsMotionController object that the state of the windows motion controller
  31124. */
  31125. class WindowsMotionController extends WebVRController {
  31126. /**
  31127. * The base url used to load the left and right controller models
  31128. */
  31129. static MODEL_BASE_URL: string;
  31130. /**
  31131. * The name of the left controller model file
  31132. */
  31133. static MODEL_LEFT_FILENAME: string;
  31134. /**
  31135. * The name of the right controller model file
  31136. */
  31137. static MODEL_RIGHT_FILENAME: string;
  31138. /**
  31139. * The controller name prefix for this controller type
  31140. */
  31141. static readonly GAMEPAD_ID_PREFIX: string;
  31142. /**
  31143. * The controller id pattern for this controller type
  31144. */
  31145. private static readonly GAMEPAD_ID_PATTERN;
  31146. private _loadedMeshInfo;
  31147. private readonly _mapping;
  31148. /**
  31149. * Fired when the trackpad on this controller is clicked
  31150. */
  31151. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  31152. /**
  31153. * Fired when the trackpad on this controller is modified
  31154. */
  31155. onTrackpadValuesChangedObservable: Observable<StickValues>;
  31156. /**
  31157. * The current x and y values of this controller's trackpad
  31158. */
  31159. trackpad: StickValues;
  31160. /**
  31161. * Creates a new WindowsMotionController from a gamepad
  31162. * @param vrGamepad the gamepad that the controller should be created from
  31163. */
  31164. constructor(vrGamepad: any);
  31165. /**
  31166. * Fired when the trigger on this controller is modified
  31167. */
  31168. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31169. /**
  31170. * Fired when the menu button on this controller is modified
  31171. */
  31172. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31173. /**
  31174. * Fired when the grip button on this controller is modified
  31175. */
  31176. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31177. /**
  31178. * Fired when the thumbstick button on this controller is modified
  31179. */
  31180. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31181. /**
  31182. * Fired when the touchpad button on this controller is modified
  31183. */
  31184. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31185. /**
  31186. * Fired when the touchpad values on this controller are modified
  31187. */
  31188. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  31189. /**
  31190. * Called once per frame by the engine.
  31191. */
  31192. update(): void;
  31193. /**
  31194. * Called once for each button that changed state since the last frame
  31195. * @param buttonIdx Which button index changed
  31196. * @param state New state of the button
  31197. * @param changes Which properties on the state changed since last frame
  31198. */
  31199. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31200. /**
  31201. * Moves the buttons on the controller mesh based on their current state
  31202. * @param buttonName the name of the button to move
  31203. * @param buttonValue the value of the button which determines the buttons new position
  31204. */
  31205. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  31206. /**
  31207. * Moves the axis on the controller mesh based on its current state
  31208. * @param axis the index of the axis
  31209. * @param axisValue the value of the axis which determines the meshes new position
  31210. * @hidden
  31211. */
  31212. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  31213. /**
  31214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31215. * @param scene scene in which to add meshes
  31216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31217. */
  31218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  31219. /**
  31220. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  31221. * can be transformed by button presses and axes values, based on this._mapping.
  31222. *
  31223. * @param scene scene in which the meshes exist
  31224. * @param meshes list of meshes that make up the controller model to process
  31225. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  31226. */
  31227. private processModel(scene, meshes);
  31228. private createMeshInfo(rootNode);
  31229. /**
  31230. * Gets the ray of the controller in the direction the controller is pointing
  31231. * @param length the length the resulting ray should be
  31232. * @returns a ray in the direction the controller is pointing
  31233. */
  31234. getForwardRay(length?: number): Ray;
  31235. /**
  31236. * Disposes of the controller
  31237. */
  31238. dispose(): void;
  31239. }
  31240. }
  31241. declare module BABYLON {
  31242. /**
  31243. * Interface to implement to create a shadow generator compatible with BJS.
  31244. */
  31245. interface IShadowGenerator {
  31246. /**
  31247. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31248. * @returns The render target texture if present otherwise, null
  31249. */
  31250. getShadowMap(): Nullable<RenderTargetTexture>;
  31251. /**
  31252. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31253. * @returns The render target texture if the shadow map is present otherwise, null
  31254. */
  31255. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31256. /**
  31257. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31258. * @param subMesh The submesh we want to render in the shadow map
  31259. * @param useInstances Defines wether will draw in the map using instances
  31260. * @returns true if ready otherwise, false
  31261. */
  31262. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31263. /**
  31264. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31265. * @param defines Defines of the material we want to update
  31266. * @param lightIndex Index of the light in the enabled light list of the material
  31267. */
  31268. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  31269. /**
  31270. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31271. * defined in the generator but impacting the effect).
  31272. * It implies the unifroms available on the materials are the standard BJS ones.
  31273. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31274. * @param effect The effect we are binfing the information for
  31275. */
  31276. bindShadowLight(lightIndex: string, effect: Effect): void;
  31277. /**
  31278. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31279. * (eq to shadow prjection matrix * light transform matrix)
  31280. * @returns The transform matrix used to create the shadow map
  31281. */
  31282. getTransformMatrix(): Matrix;
  31283. /**
  31284. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31285. * Cube and 2D textures for instance.
  31286. */
  31287. recreateShadowMap(): void;
  31288. /**
  31289. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31290. * @param onCompiled Callback triggered at the and of the effects compilation
  31291. * @param options Sets of optional options forcing the compilation with different modes
  31292. */
  31293. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31294. useInstances: boolean;
  31295. }>): void;
  31296. /**
  31297. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31298. * @param options Sets of optional options forcing the compilation with different modes
  31299. * @returns A promise that resolves when the compilation completes
  31300. */
  31301. forceCompilationAsync(options?: Partial<{
  31302. useInstances: boolean;
  31303. }>): Promise<void>;
  31304. /**
  31305. * Serializes the shadow generator setup to a json object.
  31306. * @returns The serialized JSON object
  31307. */
  31308. serialize(): any;
  31309. /**
  31310. * Disposes the Shadow map and related Textures and effects.
  31311. */
  31312. dispose(): void;
  31313. }
  31314. /**
  31315. * Default implementation IShadowGenerator.
  31316. * This is the main object responsible of generating shadows in the framework.
  31317. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  31318. */
  31319. class ShadowGenerator implements IShadowGenerator {
  31320. /**
  31321. * Shadow generator mode None: no filtering applied.
  31322. */
  31323. static readonly FILTER_NONE: number;
  31324. /**
  31325. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31326. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31327. */
  31328. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31329. /**
  31330. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31331. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31332. */
  31333. static readonly FILTER_POISSONSAMPLING: number;
  31334. /**
  31335. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31337. */
  31338. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31339. /**
  31340. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31341. * edge artifacts on steep falloff.
  31342. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31343. */
  31344. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31345. /**
  31346. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31347. * edge artifacts on steep falloff.
  31348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31349. */
  31350. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31351. /**
  31352. * Shadow generator mode PCF: Percentage Closer Filtering
  31353. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31354. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31355. */
  31356. static readonly FILTER_PCF: number;
  31357. /**
  31358. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31359. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31360. * Contact Hardening
  31361. */
  31362. static readonly FILTER_PCSS: number;
  31363. /**
  31364. * Reserved for PCF and PCSS
  31365. * Highest Quality.
  31366. *
  31367. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31368. *
  31369. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31370. */
  31371. static readonly QUALITY_HIGH: number;
  31372. /**
  31373. * Reserved for PCF and PCSS
  31374. * Good tradeoff for quality/perf cross devices
  31375. *
  31376. * Execute PCF on a 3*3 kernel.
  31377. *
  31378. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31379. */
  31380. static readonly QUALITY_MEDIUM: number;
  31381. /**
  31382. * Reserved for PCF and PCSS
  31383. * The lowest quality but the fastest.
  31384. *
  31385. * Execute PCF on a 1*1 kernel.
  31386. *
  31387. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31388. */
  31389. static readonly QUALITY_LOW: number;
  31390. private _bias;
  31391. /**
  31392. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31393. */
  31394. /**
  31395. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31396. */
  31397. bias: number;
  31398. private _normalBias;
  31399. /**
  31400. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31401. */
  31402. /**
  31403. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31404. */
  31405. normalBias: number;
  31406. private _blurBoxOffset;
  31407. /**
  31408. * Gets the blur box offset: offset applied during the blur pass.
  31409. * Only usefull if useKernelBlur = false
  31410. */
  31411. /**
  31412. * Sets the blur box offset: offset applied during the blur pass.
  31413. * Only usefull if useKernelBlur = false
  31414. */
  31415. blurBoxOffset: number;
  31416. private _blurScale;
  31417. /**
  31418. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31419. * 2 means half of the size.
  31420. */
  31421. /**
  31422. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31423. * 2 means half of the size.
  31424. */
  31425. blurScale: number;
  31426. private _blurKernel;
  31427. /**
  31428. * Gets the blur kernel: kernel size of the blur pass.
  31429. * Only usefull if useKernelBlur = true
  31430. */
  31431. /**
  31432. * Sets the blur kernel: kernel size of the blur pass.
  31433. * Only usefull if useKernelBlur = true
  31434. */
  31435. blurKernel: number;
  31436. private _useKernelBlur;
  31437. /**
  31438. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31439. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31440. */
  31441. /**
  31442. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31443. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31444. */
  31445. useKernelBlur: boolean;
  31446. private _depthScale;
  31447. /**
  31448. * Gets the depth scale used in ESM mode.
  31449. */
  31450. /**
  31451. * Sets the depth scale used in ESM mode.
  31452. * This can override the scale stored on the light.
  31453. */
  31454. depthScale: number;
  31455. private _filter;
  31456. /**
  31457. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31458. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31459. */
  31460. /**
  31461. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31462. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31463. */
  31464. filter: number;
  31465. /**
  31466. * Gets if the current filter is set to Poisson Sampling.
  31467. */
  31468. /**
  31469. * Sets the current filter to Poisson Sampling.
  31470. */
  31471. usePoissonSampling: boolean;
  31472. /**
  31473. * Gets if the current filter is set to VSM.
  31474. * DEPRECATED. Should use useExponentialShadowMap instead.
  31475. */
  31476. /**
  31477. * Sets the current filter is to VSM.
  31478. * DEPRECATED. Should use useExponentialShadowMap instead.
  31479. */
  31480. useVarianceShadowMap: boolean;
  31481. /**
  31482. * Gets if the current filter is set to blurred VSM.
  31483. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31484. */
  31485. /**
  31486. * Sets the current filter is to blurred VSM.
  31487. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31488. */
  31489. useBlurVarianceShadowMap: boolean;
  31490. /**
  31491. * Gets if the current filter is set to ESM.
  31492. */
  31493. /**
  31494. * Sets the current filter is to ESM.
  31495. */
  31496. useExponentialShadowMap: boolean;
  31497. /**
  31498. * Gets if the current filter is set to filtered ESM.
  31499. */
  31500. /**
  31501. * Gets if the current filter is set to filtered ESM.
  31502. */
  31503. useBlurExponentialShadowMap: boolean;
  31504. /**
  31505. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31506. * exponential to prevent steep falloff artifacts).
  31507. */
  31508. /**
  31509. * Sets the current filter to "close ESM" (using the inverse of the
  31510. * exponential to prevent steep falloff artifacts).
  31511. */
  31512. useCloseExponentialShadowMap: boolean;
  31513. /**
  31514. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31515. * exponential to prevent steep falloff artifacts).
  31516. */
  31517. /**
  31518. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31519. * exponential to prevent steep falloff artifacts).
  31520. */
  31521. useBlurCloseExponentialShadowMap: boolean;
  31522. /**
  31523. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31524. */
  31525. /**
  31526. * Sets the current filter to "PCF" (percentage closer filtering).
  31527. */
  31528. usePercentageCloserFiltering: boolean;
  31529. private _filteringQuality;
  31530. /**
  31531. * Gets the PCF or PCSS Quality.
  31532. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31533. */
  31534. /**
  31535. * Sets the PCF or PCSS Quality.
  31536. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31537. */
  31538. filteringQuality: number;
  31539. /**
  31540. * Gets if the current filter is set to "PCSS" (contact hardening).
  31541. */
  31542. /**
  31543. * Sets the current filter to "PCSS" (contact hardening).
  31544. */
  31545. useContactHardeningShadow: boolean;
  31546. private _contactHardeningLightSizeUVRatio;
  31547. /**
  31548. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31549. * Using a ratio helps keeping shape stability independently of the map size.
  31550. *
  31551. * It does not account for the light projection as it was having too much
  31552. * instability during the light setup or during light position changes.
  31553. *
  31554. * Only valid if useContactHardeningShadow is true.
  31555. */
  31556. /**
  31557. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31558. * Using a ratio helps keeping shape stability independently of the map size.
  31559. *
  31560. * It does not account for the light projection as it was having too much
  31561. * instability during the light setup or during light position changes.
  31562. *
  31563. * Only valid if useContactHardeningShadow is true.
  31564. */
  31565. contactHardeningLightSizeUVRatio: number;
  31566. private _darkness;
  31567. /**
  31568. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31569. * 0 means strongest and 1 would means no shadow.
  31570. * @returns the darkness.
  31571. */
  31572. getDarkness(): number;
  31573. /**
  31574. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31575. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31576. * @returns the shadow generator allowing fluent coding.
  31577. */
  31578. setDarkness(darkness: number): ShadowGenerator;
  31579. private _transparencyShadow;
  31580. /**
  31581. * Sets the ability to have transparent shadow (boolean).
  31582. * @param transparent True if transparent else False
  31583. * @returns the shadow generator allowing fluent coding
  31584. */
  31585. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31586. private _shadowMap;
  31587. private _shadowMap2;
  31588. /**
  31589. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31590. * @returns The render target texture if present otherwise, null
  31591. */
  31592. getShadowMap(): Nullable<RenderTargetTexture>;
  31593. /**
  31594. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31595. * @returns The render target texture if the shadow map is present otherwise, null
  31596. */
  31597. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31598. /**
  31599. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31600. * @param mesh Mesh to add
  31601. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31602. * @returns the Shadow Generator itself
  31603. */
  31604. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31605. /**
  31606. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31607. * @param mesh Mesh to remove
  31608. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31609. * @returns the Shadow Generator itself
  31610. */
  31611. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31612. /**
  31613. * Controls the extent to which the shadows fade out at the edge of the frustum
  31614. * Used only by directionals and spots
  31615. */
  31616. frustumEdgeFalloff: number;
  31617. private _light;
  31618. /**
  31619. * Returns the associated light object.
  31620. * @returns the light generating the shadow
  31621. */
  31622. getLight(): IShadowLight;
  31623. /**
  31624. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31625. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31626. * It might on the other hand introduce peter panning.
  31627. */
  31628. forceBackFacesOnly: boolean;
  31629. private _scene;
  31630. private _lightDirection;
  31631. private _effect;
  31632. private _viewMatrix;
  31633. private _projectionMatrix;
  31634. private _transformMatrix;
  31635. private _cachedPosition;
  31636. private _cachedDirection;
  31637. private _cachedDefines;
  31638. private _currentRenderID;
  31639. private _boxBlurPostprocess;
  31640. private _kernelBlurXPostprocess;
  31641. private _kernelBlurYPostprocess;
  31642. private _blurPostProcesses;
  31643. private _mapSize;
  31644. private _currentFaceIndex;
  31645. private _currentFaceIndexCache;
  31646. private _textureType;
  31647. private _defaultTextureMatrix;
  31648. /**
  31649. * Creates a ShadowGenerator object.
  31650. * A ShadowGenerator is the required tool to use the shadows.
  31651. * Each light casting shadows needs to use its own ShadowGenerator.
  31652. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31653. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31654. * @param light The light object generating the shadows.
  31655. * @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.
  31656. */
  31657. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31658. private _initializeGenerator();
  31659. private _initializeShadowMap();
  31660. private _initializeBlurRTTAndPostProcesses();
  31661. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31662. private _renderSubMeshForShadowMap(subMesh);
  31663. private _applyFilterValues();
  31664. /**
  31665. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31666. * @param onCompiled Callback triggered at the and of the effects compilation
  31667. * @param options Sets of optional options forcing the compilation with different modes
  31668. */
  31669. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31670. useInstances: boolean;
  31671. }>): void;
  31672. /**
  31673. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31674. * @param options Sets of optional options forcing the compilation with different modes
  31675. * @returns A promise that resolves when the compilation completes
  31676. */
  31677. forceCompilationAsync(options?: Partial<{
  31678. useInstances: boolean;
  31679. }>): Promise<void>;
  31680. /**
  31681. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31682. * @param subMesh The submesh we want to render in the shadow map
  31683. * @param useInstances Defines wether will draw in the map using instances
  31684. * @returns true if ready otherwise, false
  31685. */
  31686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31687. /**
  31688. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31689. * @param defines Defines of the material we want to update
  31690. * @param lightIndex Index of the light in the enabled light list of the material
  31691. */
  31692. prepareDefines(defines: any, lightIndex: number): void;
  31693. /**
  31694. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31695. * defined in the generator but impacting the effect).
  31696. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31697. * @param effect The effect we are binfing the information for
  31698. */
  31699. bindShadowLight(lightIndex: string, effect: Effect): void;
  31700. /**
  31701. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31702. * (eq to shadow prjection matrix * light transform matrix)
  31703. * @returns The transform matrix used to create the shadow map
  31704. */
  31705. getTransformMatrix(): Matrix;
  31706. /**
  31707. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31708. * Cube and 2D textures for instance.
  31709. */
  31710. recreateShadowMap(): void;
  31711. private _disposeBlurPostProcesses();
  31712. private _disposeRTTandPostProcesses();
  31713. /**
  31714. * Disposes the ShadowGenerator.
  31715. * Returns nothing.
  31716. */
  31717. dispose(): void;
  31718. /**
  31719. * Serializes the shadow generator setup to a json object.
  31720. * @returns The serialized JSON object
  31721. */
  31722. serialize(): any;
  31723. /**
  31724. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31725. * @param parsedShadowGenerator The JSON object to parse
  31726. * @param scene The scene to create the shadow map for
  31727. * @returns The parsed shadow generator
  31728. */
  31729. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31730. }
  31731. }
  31732. declare module BABYLON {
  31733. /**
  31734. * Background material used to create an efficient environement around your scene.
  31735. */
  31736. class BackgroundMaterial extends PushMaterial {
  31737. /**
  31738. * Standard reflectance value at parallel view angle.
  31739. */
  31740. static StandardReflectance0: number;
  31741. /**
  31742. * Standard reflectance value at grazing angle.
  31743. */
  31744. static StandardReflectance90: number;
  31745. protected _primaryColor: Color3;
  31746. /**
  31747. * Key light Color (multiply against the environement texture)
  31748. */
  31749. primaryColor: Color3;
  31750. protected __perceptualColor: Nullable<Color3>;
  31751. /**
  31752. * Experimental Internal Use Only.
  31753. *
  31754. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31755. * This acts as a helper to set the primary color to a more "human friendly" value.
  31756. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31757. * output color as close as possible from the chosen value.
  31758. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31759. * part of lighting setup.)
  31760. */
  31761. _perceptualColor: Nullable<Color3>;
  31762. protected _primaryColorShadowLevel: float;
  31763. /**
  31764. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31765. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31766. */
  31767. primaryColorShadowLevel: float;
  31768. protected _primaryColorHighlightLevel: float;
  31769. /**
  31770. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31771. * The primary color is used at the level chosen to define what the white area would look.
  31772. */
  31773. primaryColorHighlightLevel: float;
  31774. protected _reflectionTexture: Nullable<BaseTexture>;
  31775. /**
  31776. * Reflection Texture used in the material.
  31777. * Should be author in a specific way for the best result (refer to the documentation).
  31778. */
  31779. reflectionTexture: Nullable<BaseTexture>;
  31780. protected _reflectionBlur: float;
  31781. /**
  31782. * Reflection Texture level of blur.
  31783. *
  31784. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31785. * texture twice.
  31786. */
  31787. reflectionBlur: float;
  31788. protected _diffuseTexture: Nullable<BaseTexture>;
  31789. /**
  31790. * Diffuse Texture used in the material.
  31791. * Should be author in a specific way for the best result (refer to the documentation).
  31792. */
  31793. diffuseTexture: Nullable<BaseTexture>;
  31794. protected _shadowLights: Nullable<IShadowLight[]>;
  31795. /**
  31796. * Specify the list of lights casting shadow on the material.
  31797. * All scene shadow lights will be included if null.
  31798. */
  31799. shadowLights: Nullable<IShadowLight[]>;
  31800. protected _shadowLevel: float;
  31801. /**
  31802. * Helps adjusting the shadow to a softer level if required.
  31803. * 0 means black shadows and 1 means no shadows.
  31804. */
  31805. shadowLevel: float;
  31806. protected _sceneCenter: Vector3;
  31807. /**
  31808. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31809. * It is usually zero but might be interesting to modify according to your setup.
  31810. */
  31811. sceneCenter: Vector3;
  31812. protected _opacityFresnel: boolean;
  31813. /**
  31814. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31815. * This helps ensuring a nice transition when the camera goes under the ground.
  31816. */
  31817. opacityFresnel: boolean;
  31818. protected _reflectionFresnel: boolean;
  31819. /**
  31820. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31821. * This helps adding a mirror texture on the ground.
  31822. */
  31823. reflectionFresnel: boolean;
  31824. protected _reflectionFalloffDistance: number;
  31825. /**
  31826. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31827. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31828. */
  31829. reflectionFalloffDistance: number;
  31830. protected _reflectionAmount: number;
  31831. /**
  31832. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31833. */
  31834. reflectionAmount: number;
  31835. protected _reflectionReflectance0: number;
  31836. /**
  31837. * This specifies the weight of the reflection at grazing angle.
  31838. */
  31839. reflectionReflectance0: number;
  31840. protected _reflectionReflectance90: number;
  31841. /**
  31842. * This specifies the weight of the reflection at a perpendicular point of view.
  31843. */
  31844. reflectionReflectance90: number;
  31845. /**
  31846. * Sets the reflection reflectance fresnel values according to the default standard
  31847. * empirically know to work well :-)
  31848. */
  31849. reflectionStandardFresnelWeight: number;
  31850. protected _useRGBColor: boolean;
  31851. /**
  31852. * Helps to directly use the maps channels instead of their level.
  31853. */
  31854. useRGBColor: boolean;
  31855. protected _enableNoise: boolean;
  31856. /**
  31857. * This helps reducing the banding effect that could occur on the background.
  31858. */
  31859. enableNoise: boolean;
  31860. /**
  31861. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31862. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31863. * Recommended to be keep at 1.0 except for special cases.
  31864. */
  31865. fovMultiplier: number;
  31866. private _fovMultiplier;
  31867. /**
  31868. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31869. */
  31870. useEquirectangularFOV: boolean;
  31871. private _maxSimultaneousLights;
  31872. /**
  31873. * Number of Simultaneous lights allowed on the material.
  31874. */
  31875. maxSimultaneousLights: int;
  31876. /**
  31877. * Default configuration related to image processing available in the Background Material.
  31878. */
  31879. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31880. /**
  31881. * Keep track of the image processing observer to allow dispose and replace.
  31882. */
  31883. private _imageProcessingObserver;
  31884. /**
  31885. * Attaches a new image processing configuration to the PBR Material.
  31886. * @param configuration (if null the scene configuration will be use)
  31887. */
  31888. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31889. /**
  31890. * Gets the image processing configuration used either in this material.
  31891. */
  31892. /**
  31893. * Sets the Default image processing configuration used either in the this material.
  31894. *
  31895. * If sets to null, the scene one is in use.
  31896. */
  31897. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31898. /**
  31899. * Gets wether the color curves effect is enabled.
  31900. */
  31901. /**
  31902. * Sets wether the color curves effect is enabled.
  31903. */
  31904. cameraColorCurvesEnabled: boolean;
  31905. /**
  31906. * Gets wether the color grading effect is enabled.
  31907. */
  31908. /**
  31909. * Gets wether the color grading effect is enabled.
  31910. */
  31911. cameraColorGradingEnabled: boolean;
  31912. /**
  31913. * Gets wether tonemapping is enabled or not.
  31914. */
  31915. /**
  31916. * Sets wether tonemapping is enabled or not
  31917. */
  31918. cameraToneMappingEnabled: boolean;
  31919. /**
  31920. * The camera exposure used on this material.
  31921. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31922. * This corresponds to a photographic exposure.
  31923. */
  31924. /**
  31925. * The camera exposure used on this material.
  31926. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31927. * This corresponds to a photographic exposure.
  31928. */
  31929. cameraExposure: float;
  31930. /**
  31931. * Gets The camera contrast used on this material.
  31932. */
  31933. /**
  31934. * Sets The camera contrast used on this material.
  31935. */
  31936. cameraContrast: float;
  31937. /**
  31938. * Gets the Color Grading 2D Lookup Texture.
  31939. */
  31940. /**
  31941. * Sets the Color Grading 2D Lookup Texture.
  31942. */
  31943. cameraColorGradingTexture: Nullable<BaseTexture>;
  31944. /**
  31945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31947. * 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;
  31948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31949. */
  31950. /**
  31951. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31952. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31953. * 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;
  31954. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31955. */
  31956. cameraColorCurves: Nullable<ColorCurves>;
  31957. /**
  31958. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31959. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31960. */
  31961. switchToBGR: boolean;
  31962. private _renderTargets;
  31963. private _reflectionControls;
  31964. private _white;
  31965. private _primaryShadowColor;
  31966. private _primaryHighlightColor;
  31967. /**
  31968. * Instantiates a Background Material in the given scene
  31969. * @param name The friendly name of the material
  31970. * @param scene The scene to add the material to
  31971. */
  31972. constructor(name: string, scene: Scene);
  31973. /**
  31974. * The entire material has been created in order to prevent overdraw.
  31975. * @returns false
  31976. */
  31977. needAlphaTesting(): boolean;
  31978. /**
  31979. * The entire material has been created in order to prevent overdraw.
  31980. * @returns true if blending is enable
  31981. */
  31982. needAlphaBlending(): boolean;
  31983. /**
  31984. * Checks wether the material is ready to be rendered for a given mesh.
  31985. * @param mesh The mesh to render
  31986. * @param subMesh The submesh to check against
  31987. * @param useInstances Specify wether or not the material is used with instances
  31988. * @returns true if all the dependencies are ready (Textures, Effects...)
  31989. */
  31990. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31991. /**
  31992. * Compute the primary color according to the chosen perceptual color.
  31993. */
  31994. private _computePrimaryColorFromPerceptualColor();
  31995. /**
  31996. * Compute the highlights and shadow colors according to their chosen levels.
  31997. */
  31998. private _computePrimaryColors();
  31999. /**
  32000. * Build the uniform buffer used in the material.
  32001. */
  32002. buildUniformLayout(): void;
  32003. /**
  32004. * Unbind the material.
  32005. */
  32006. unbind(): void;
  32007. /**
  32008. * Bind only the world matrix to the material.
  32009. * @param world The world matrix to bind.
  32010. */
  32011. bindOnlyWorldMatrix(world: Matrix): void;
  32012. /**
  32013. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  32014. * @param world The world matrix to bind.
  32015. * @param subMesh The submesh to bind for.
  32016. */
  32017. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32018. /**
  32019. * Dispose the material.
  32020. * @param forceDisposeEffect Force disposal of the associated effect.
  32021. * @param forceDisposeTextures Force disposal of the associated textures.
  32022. */
  32023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32024. /**
  32025. * Clones the material.
  32026. * @param name The cloned name.
  32027. * @returns The cloned material.
  32028. */
  32029. clone(name: string): BackgroundMaterial;
  32030. /**
  32031. * Serializes the current material to its JSON representation.
  32032. * @returns The JSON representation.
  32033. */
  32034. serialize(): any;
  32035. /**
  32036. * Gets the class name of the material
  32037. * @returns "BackgroundMaterial"
  32038. */
  32039. getClassName(): string;
  32040. /**
  32041. * Parse a JSON input to create back a background material.
  32042. * @param source The JSON data to parse
  32043. * @param scene The scene to create the parsed material in
  32044. * @param rootUrl The root url of the assets the material depends upon
  32045. * @returns the instantiated BackgroundMaterial.
  32046. */
  32047. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  32048. }
  32049. }
  32050. declare module BABYLON {
  32051. /**
  32052. * The Physically based material base class of BJS.
  32053. *
  32054. * This offers the main features of a standard PBR material.
  32055. * For more information, please refer to the documentation :
  32056. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32057. */
  32058. abstract class PBRBaseMaterial extends PushMaterial {
  32059. /**
  32060. * Intensity of the direct lights e.g. the four lights available in your scene.
  32061. * This impacts both the direct diffuse and specular highlights.
  32062. */
  32063. protected _directIntensity: number;
  32064. /**
  32065. * Intensity of the emissive part of the material.
  32066. * This helps controlling the emissive effect without modifying the emissive color.
  32067. */
  32068. protected _emissiveIntensity: number;
  32069. /**
  32070. * Intensity of the environment e.g. how much the environment will light the object
  32071. * either through harmonics for rough material or through the refelction for shiny ones.
  32072. */
  32073. protected _environmentIntensity: number;
  32074. /**
  32075. * This is a special control allowing the reduction of the specular highlights coming from the
  32076. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32077. */
  32078. protected _specularIntensity: number;
  32079. /**
  32080. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32081. */
  32082. private _lightingInfos;
  32083. /**
  32084. * Debug Control allowing disabling the bump map on this material.
  32085. */
  32086. protected _disableBumpMap: boolean;
  32087. /**
  32088. * AKA Diffuse Texture in standard nomenclature.
  32089. */
  32090. protected _albedoTexture: BaseTexture;
  32091. /**
  32092. * AKA Occlusion Texture in other nomenclature.
  32093. */
  32094. protected _ambientTexture: BaseTexture;
  32095. /**
  32096. * AKA Occlusion Texture Intensity in other nomenclature.
  32097. */
  32098. protected _ambientTextureStrength: number;
  32099. /**
  32100. * Stores the alpha values in a texture.
  32101. */
  32102. protected _opacityTexture: BaseTexture;
  32103. /**
  32104. * Stores the reflection values in a texture.
  32105. */
  32106. protected _reflectionTexture: BaseTexture;
  32107. /**
  32108. * Stores the refraction values in a texture.
  32109. */
  32110. protected _refractionTexture: BaseTexture;
  32111. /**
  32112. * Stores the emissive values in a texture.
  32113. */
  32114. protected _emissiveTexture: BaseTexture;
  32115. /**
  32116. * AKA Specular texture in other nomenclature.
  32117. */
  32118. protected _reflectivityTexture: BaseTexture;
  32119. /**
  32120. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32121. */
  32122. protected _metallicTexture: BaseTexture;
  32123. /**
  32124. * Specifies the metallic scalar of the metallic/roughness workflow.
  32125. * Can also be used to scale the metalness values of the metallic texture.
  32126. */
  32127. protected _metallic: number;
  32128. /**
  32129. * Specifies the roughness scalar of the metallic/roughness workflow.
  32130. * Can also be used to scale the roughness values of the metallic texture.
  32131. */
  32132. protected _roughness: number;
  32133. /**
  32134. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32135. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32136. */
  32137. protected _microSurfaceTexture: BaseTexture;
  32138. /**
  32139. * Stores surface normal data used to displace a mesh in a texture.
  32140. */
  32141. protected _bumpTexture: BaseTexture;
  32142. /**
  32143. * Stores the pre-calculated light information of a mesh in a texture.
  32144. */
  32145. protected _lightmapTexture: BaseTexture;
  32146. /**
  32147. * The color of a material in ambient lighting.
  32148. */
  32149. protected _ambientColor: Color3;
  32150. /**
  32151. * AKA Diffuse Color in other nomenclature.
  32152. */
  32153. protected _albedoColor: Color3;
  32154. /**
  32155. * AKA Specular Color in other nomenclature.
  32156. */
  32157. protected _reflectivityColor: Color3;
  32158. /**
  32159. * The color applied when light is reflected from a material.
  32160. */
  32161. protected _reflectionColor: Color3;
  32162. /**
  32163. * The color applied when light is emitted from a material.
  32164. */
  32165. protected _emissiveColor: Color3;
  32166. /**
  32167. * AKA Glossiness in other nomenclature.
  32168. */
  32169. protected _microSurface: number;
  32170. /**
  32171. * source material index of refraction (IOR)' / 'destination material IOR.
  32172. */
  32173. protected _indexOfRefraction: number;
  32174. /**
  32175. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32176. */
  32177. protected _invertRefractionY: boolean;
  32178. /**
  32179. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32180. * Materials half opaque for instance using refraction could benefit from this control.
  32181. */
  32182. protected _linkRefractionWithTransparency: boolean;
  32183. /**
  32184. * Specifies that the material will use the light map as a show map.
  32185. */
  32186. protected _useLightmapAsShadowmap: boolean;
  32187. /**
  32188. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32189. * makes the reflect vector face the model (under horizon).
  32190. */
  32191. protected _useHorizonOcclusion: boolean;
  32192. /**
  32193. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32194. * too much the area relying on ambient texture to define their ambient occlusion.
  32195. */
  32196. protected _useRadianceOcclusion: boolean;
  32197. /**
  32198. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32199. */
  32200. protected _useAlphaFromAlbedoTexture: boolean;
  32201. /**
  32202. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32203. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32204. */
  32205. protected _useSpecularOverAlpha: boolean;
  32206. /**
  32207. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32208. */
  32209. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32210. /**
  32211. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32212. */
  32213. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32214. /**
  32215. * Specifies if the metallic texture contains the roughness information in its green channel.
  32216. */
  32217. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32218. /**
  32219. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32220. */
  32221. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32222. /**
  32223. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32224. */
  32225. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32226. /**
  32227. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32228. */
  32229. protected _useAmbientInGrayScale: boolean;
  32230. /**
  32231. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32232. * The material will try to infer what glossiness each pixel should be.
  32233. */
  32234. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32235. /**
  32236. * BJS is using an harcoded light falloff based on a manually sets up range.
  32237. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32238. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32239. */
  32240. protected _usePhysicalLightFalloff: boolean;
  32241. /**
  32242. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32243. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32244. */
  32245. protected _useRadianceOverAlpha: boolean;
  32246. /**
  32247. * Allows using an object space normal map (instead of tangent space).
  32248. */
  32249. protected _useObjectSpaceNormalMap: boolean;
  32250. /**
  32251. * Allows using the bump map in parallax mode.
  32252. */
  32253. protected _useParallax: boolean;
  32254. /**
  32255. * Allows using the bump map in parallax occlusion mode.
  32256. */
  32257. protected _useParallaxOcclusion: boolean;
  32258. /**
  32259. * Controls the scale bias of the parallax mode.
  32260. */
  32261. protected _parallaxScaleBias: number;
  32262. /**
  32263. * If sets to true, disables all the lights affecting the material.
  32264. */
  32265. protected _disableLighting: boolean;
  32266. /**
  32267. * Number of Simultaneous lights allowed on the material.
  32268. */
  32269. protected _maxSimultaneousLights: number;
  32270. /**
  32271. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32272. */
  32273. protected _invertNormalMapX: boolean;
  32274. /**
  32275. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32276. */
  32277. protected _invertNormalMapY: boolean;
  32278. /**
  32279. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32280. */
  32281. protected _twoSidedLighting: boolean;
  32282. /**
  32283. * Defines the alpha limits in alpha test mode.
  32284. */
  32285. protected _alphaCutOff: number;
  32286. /**
  32287. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32288. */
  32289. protected _forceAlphaTest: boolean;
  32290. /**
  32291. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32292. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32293. */
  32294. protected _useAlphaFresnel: boolean;
  32295. /**
  32296. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32297. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32298. */
  32299. protected _useLinearAlphaFresnel: boolean;
  32300. /**
  32301. * The transparency mode of the material.
  32302. */
  32303. protected _transparencyMode: Nullable<number>;
  32304. /**
  32305. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32306. * from cos thetav and roughness:
  32307. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32308. */
  32309. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32310. /**
  32311. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32312. */
  32313. protected _forceIrradianceInFragment: boolean;
  32314. /**
  32315. * Force normal to face away from face.
  32316. */
  32317. protected _forceNormalForward: boolean;
  32318. /**
  32319. * Enables specular anti aliasing in the PBR shader.
  32320. * It will both interacts on the Geometry for analytical and IBL lighting.
  32321. * It also prefilter the roughness map based on the bump values.
  32322. */
  32323. protected _enableSpecularAntiAliasing: boolean;
  32324. /**
  32325. * Default configuration related to image processing available in the PBR Material.
  32326. */
  32327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32328. /**
  32329. * Keep track of the image processing observer to allow dispose and replace.
  32330. */
  32331. private _imageProcessingObserver;
  32332. /**
  32333. * Attaches a new image processing configuration to the PBR Material.
  32334. * @param configuration
  32335. */
  32336. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32337. /**
  32338. * Stores the available render targets.
  32339. */
  32340. private _renderTargets;
  32341. /**
  32342. * Sets the global ambient color for the material used in lighting calculations.
  32343. */
  32344. private _globalAmbientColor;
  32345. /**
  32346. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32347. */
  32348. private _useLogarithmicDepth;
  32349. /**
  32350. * If set to true, no lighting calculations will be applied.
  32351. */
  32352. private _unlit;
  32353. /**
  32354. * Instantiates a new PBRMaterial instance.
  32355. *
  32356. * @param name The material name
  32357. * @param scene The scene the material will be use in.
  32358. */
  32359. constructor(name: string, scene: Scene);
  32360. /**
  32361. * Gets the name of the material class.
  32362. */
  32363. getClassName(): string;
  32364. /**
  32365. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32366. */
  32367. /**
  32368. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32369. */
  32370. useLogarithmicDepth: boolean;
  32371. /**
  32372. * Gets the current transparency mode.
  32373. */
  32374. /**
  32375. * Sets the transparency mode of the material.
  32376. *
  32377. * | Value | Type | Description |
  32378. * | ----- | ----------------------------------- | ----------- |
  32379. * | 0 | OPAQUE | |
  32380. * | 1 | ALPHATEST | |
  32381. * | 2 | ALPHABLEND | |
  32382. * | 3 | ALPHATESTANDBLEND | |
  32383. *
  32384. */
  32385. transparencyMode: Nullable<number>;
  32386. /**
  32387. * Returns true if alpha blending should be disabled.
  32388. */
  32389. private readonly _disableAlphaBlending;
  32390. /**
  32391. * Specifies whether or not this material should be rendered in alpha blend mode.
  32392. */
  32393. needAlphaBlending(): boolean;
  32394. /**
  32395. * Specifies if the mesh will require alpha blending.
  32396. * @param mesh - BJS mesh.
  32397. */
  32398. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32399. /**
  32400. * Specifies whether or not this material should be rendered in alpha test mode.
  32401. */
  32402. needAlphaTesting(): boolean;
  32403. /**
  32404. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32405. */
  32406. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32407. /**
  32408. * Gets the texture used for the alpha test.
  32409. */
  32410. getAlphaTestTexture(): BaseTexture;
  32411. /**
  32412. * Stores the reflectivity values based on metallic roughness workflow.
  32413. */
  32414. private static _scaledReflectivity;
  32415. /**
  32416. * Specifies that the submesh is ready to be used.
  32417. * @param mesh - BJS mesh.
  32418. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32419. * @param useInstances - Specifies that instances should be used.
  32420. * @returns - boolean indicating that the submesh is ready or not.
  32421. */
  32422. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32423. /**
  32424. * Specifies if the material uses metallic roughness workflow.
  32425. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32426. */
  32427. isMetallicWorkflow(): boolean;
  32428. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32429. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32430. /**
  32431. * Force shader compilation
  32432. */
  32433. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32434. clipPlane: boolean;
  32435. }>): void;
  32436. /**
  32437. * Initializes the uniform buffer layout for the shader.
  32438. */
  32439. buildUniformLayout(): void;
  32440. /**
  32441. * Unbinds the textures.
  32442. */
  32443. unbind(): void;
  32444. /**
  32445. * Binds the submesh data.
  32446. * @param world - The world matrix.
  32447. * @param mesh - The BJS mesh.
  32448. * @param subMesh - A submesh of the BJS mesh.
  32449. */
  32450. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32451. /**
  32452. * Returns the animatable textures.
  32453. * @returns - Array of animatable textures.
  32454. */
  32455. getAnimatables(): IAnimatable[];
  32456. /**
  32457. * Returns the texture used for reflections.
  32458. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32459. */
  32460. private _getReflectionTexture();
  32461. /**
  32462. * Returns the texture used for refraction or null if none is used.
  32463. * @returns - Refection texture if present. If no refraction texture and refraction
  32464. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32465. */
  32466. private _getRefractionTexture();
  32467. /**
  32468. * Disposes the resources of the material.
  32469. * @param forceDisposeEffect - Forces the disposal of effects.
  32470. * @param forceDisposeTextures - Forces the disposal of all textures.
  32471. */
  32472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32473. }
  32474. }
  32475. declare module BABYLON {
  32476. /**
  32477. * The Physically based simple base material of BJS.
  32478. *
  32479. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32480. * It is used as the base class for both the specGloss and metalRough conventions.
  32481. */
  32482. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32483. /**
  32484. * Number of Simultaneous lights allowed on the material.
  32485. */
  32486. maxSimultaneousLights: number;
  32487. /**
  32488. * If sets to true, disables all the lights affecting the material.
  32489. */
  32490. disableLighting: boolean;
  32491. /**
  32492. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32493. */
  32494. environmentTexture: BaseTexture;
  32495. /**
  32496. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32497. */
  32498. invertNormalMapX: boolean;
  32499. /**
  32500. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32501. */
  32502. invertNormalMapY: boolean;
  32503. /**
  32504. * Normal map used in the model.
  32505. */
  32506. normalTexture: BaseTexture;
  32507. /**
  32508. * Emissivie color used to self-illuminate the model.
  32509. */
  32510. emissiveColor: Color3;
  32511. /**
  32512. * Emissivie texture used to self-illuminate the model.
  32513. */
  32514. emissiveTexture: BaseTexture;
  32515. /**
  32516. * Occlusion Channel Strenght.
  32517. */
  32518. occlusionStrength: number;
  32519. /**
  32520. * Occlusion Texture of the material (adding extra occlusion effects).
  32521. */
  32522. occlusionTexture: BaseTexture;
  32523. /**
  32524. * Defines the alpha limits in alpha test mode.
  32525. */
  32526. alphaCutOff: number;
  32527. /**
  32528. * Gets the current double sided mode.
  32529. */
  32530. /**
  32531. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32532. */
  32533. doubleSided: boolean;
  32534. lightmapTexture: BaseTexture;
  32535. useLightmapAsShadowmap: boolean;
  32536. /**
  32537. * Return the active textures of the material.
  32538. */
  32539. getActiveTextures(): BaseTexture[];
  32540. hasTexture(texture: BaseTexture): boolean;
  32541. /**
  32542. * Instantiates a new PBRMaterial instance.
  32543. *
  32544. * @param name The material name
  32545. * @param scene The scene the material will be use in.
  32546. */
  32547. constructor(name: string, scene: Scene);
  32548. getClassName(): string;
  32549. }
  32550. }
  32551. declare module BABYLON {
  32552. /**
  32553. * The Physically based material of BJS.
  32554. *
  32555. * This offers the main features of a standard PBR material.
  32556. * For more information, please refer to the documentation :
  32557. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32558. */
  32559. class PBRMaterial extends PBRBaseMaterial {
  32560. private static _PBRMATERIAL_OPAQUE;
  32561. /**
  32562. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32563. */
  32564. static readonly PBRMATERIAL_OPAQUE: number;
  32565. /**
  32566. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32567. */
  32568. private static _PBRMATERIAL_ALPHATEST;
  32569. /**
  32570. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32571. */
  32572. static readonly PBRMATERIAL_ALPHATEST: number;
  32573. /**
  32574. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32575. */
  32576. private static _PBRMATERIAL_ALPHABLEND;
  32577. /**
  32578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32579. */
  32580. static readonly PBRMATERIAL_ALPHABLEND: number;
  32581. /**
  32582. * 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.
  32583. * They are also discarded below the alpha cutoff threshold to improve performances.
  32584. */
  32585. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32586. /**
  32587. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32588. * They are also discarded below the alpha cutoff threshold to improve performances.
  32589. */
  32590. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32591. /**
  32592. * Intensity of the direct lights e.g. the four lights available in your scene.
  32593. * This impacts both the direct diffuse and specular highlights.
  32594. */
  32595. directIntensity: number;
  32596. /**
  32597. * Intensity of the emissive part of the material.
  32598. * This helps controlling the emissive effect without modifying the emissive color.
  32599. */
  32600. emissiveIntensity: number;
  32601. /**
  32602. * Intensity of the environment e.g. how much the environment will light the object
  32603. * either through harmonics for rough material or through the refelction for shiny ones.
  32604. */
  32605. environmentIntensity: number;
  32606. /**
  32607. * This is a special control allowing the reduction of the specular highlights coming from the
  32608. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32609. */
  32610. specularIntensity: number;
  32611. /**
  32612. * Debug Control allowing disabling the bump map on this material.
  32613. */
  32614. disableBumpMap: boolean;
  32615. /**
  32616. * AKA Diffuse Texture in standard nomenclature.
  32617. */
  32618. albedoTexture: BaseTexture;
  32619. /**
  32620. * AKA Occlusion Texture in other nomenclature.
  32621. */
  32622. ambientTexture: BaseTexture;
  32623. /**
  32624. * AKA Occlusion Texture Intensity in other nomenclature.
  32625. */
  32626. ambientTextureStrength: number;
  32627. /**
  32628. * Stores the alpha values in a texture.
  32629. */
  32630. opacityTexture: BaseTexture;
  32631. /**
  32632. * Stores the reflection values in a texture.
  32633. */
  32634. reflectionTexture: Nullable<BaseTexture>;
  32635. /**
  32636. * Stores the emissive values in a texture.
  32637. */
  32638. emissiveTexture: BaseTexture;
  32639. /**
  32640. * AKA Specular texture in other nomenclature.
  32641. */
  32642. reflectivityTexture: BaseTexture;
  32643. /**
  32644. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32645. */
  32646. metallicTexture: BaseTexture;
  32647. /**
  32648. * Specifies the metallic scalar of the metallic/roughness workflow.
  32649. * Can also be used to scale the metalness values of the metallic texture.
  32650. */
  32651. metallic: number;
  32652. /**
  32653. * Specifies the roughness scalar of the metallic/roughness workflow.
  32654. * Can also be used to scale the roughness values of the metallic texture.
  32655. */
  32656. roughness: number;
  32657. /**
  32658. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32659. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32660. */
  32661. microSurfaceTexture: BaseTexture;
  32662. /**
  32663. * Stores surface normal data used to displace a mesh in a texture.
  32664. */
  32665. bumpTexture: BaseTexture;
  32666. /**
  32667. * Stores the pre-calculated light information of a mesh in a texture.
  32668. */
  32669. lightmapTexture: BaseTexture;
  32670. /**
  32671. * Stores the refracted light information in a texture.
  32672. */
  32673. refractionTexture: BaseTexture;
  32674. /**
  32675. * The color of a material in ambient lighting.
  32676. */
  32677. ambientColor: Color3;
  32678. /**
  32679. * AKA Diffuse Color in other nomenclature.
  32680. */
  32681. albedoColor: Color3;
  32682. /**
  32683. * AKA Specular Color in other nomenclature.
  32684. */
  32685. reflectivityColor: Color3;
  32686. /**
  32687. * The color reflected from the material.
  32688. */
  32689. reflectionColor: Color3;
  32690. /**
  32691. * The color emitted from the material.
  32692. */
  32693. emissiveColor: Color3;
  32694. /**
  32695. * AKA Glossiness in other nomenclature.
  32696. */
  32697. microSurface: number;
  32698. /**
  32699. * source material index of refraction (IOR)' / 'destination material IOR.
  32700. */
  32701. indexOfRefraction: number;
  32702. /**
  32703. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32704. */
  32705. invertRefractionY: boolean;
  32706. /**
  32707. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32708. * Materials half opaque for instance using refraction could benefit from this control.
  32709. */
  32710. linkRefractionWithTransparency: boolean;
  32711. useLightmapAsShadowmap: boolean;
  32712. /**
  32713. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32714. */
  32715. useAlphaFromAlbedoTexture: boolean;
  32716. /**
  32717. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32718. */
  32719. forceAlphaTest: boolean;
  32720. /**
  32721. * Defines the alpha limits in alpha test mode.
  32722. */
  32723. alphaCutOff: number;
  32724. /**
  32725. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32726. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32727. */
  32728. useSpecularOverAlpha: boolean;
  32729. /**
  32730. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32731. */
  32732. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32733. /**
  32734. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32735. */
  32736. useRoughnessFromMetallicTextureAlpha: boolean;
  32737. /**
  32738. * Specifies if the metallic texture contains the roughness information in its green channel.
  32739. */
  32740. useRoughnessFromMetallicTextureGreen: boolean;
  32741. /**
  32742. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32743. */
  32744. useMetallnessFromMetallicTextureBlue: boolean;
  32745. /**
  32746. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32747. */
  32748. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32749. /**
  32750. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32751. */
  32752. useAmbientInGrayScale: boolean;
  32753. /**
  32754. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32755. * The material will try to infer what glossiness each pixel should be.
  32756. */
  32757. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32758. /**
  32759. * BJS is using an harcoded light falloff based on a manually sets up range.
  32760. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32761. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32762. */
  32763. usePhysicalLightFalloff: boolean;
  32764. /**
  32765. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32766. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32767. */
  32768. useRadianceOverAlpha: boolean;
  32769. /**
  32770. * Allows using an object space normal map (instead of tangent space).
  32771. */
  32772. useObjectSpaceNormalMap: boolean;
  32773. /**
  32774. * Allows using the bump map in parallax mode.
  32775. */
  32776. useParallax: boolean;
  32777. /**
  32778. * Allows using the bump map in parallax occlusion mode.
  32779. */
  32780. useParallaxOcclusion: boolean;
  32781. /**
  32782. * Controls the scale bias of the parallax mode.
  32783. */
  32784. parallaxScaleBias: number;
  32785. /**
  32786. * If sets to true, disables all the lights affecting the material.
  32787. */
  32788. disableLighting: boolean;
  32789. /**
  32790. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32791. */
  32792. forceIrradianceInFragment: boolean;
  32793. /**
  32794. * Number of Simultaneous lights allowed on the material.
  32795. */
  32796. maxSimultaneousLights: number;
  32797. /**
  32798. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32799. */
  32800. invertNormalMapX: boolean;
  32801. /**
  32802. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32803. */
  32804. invertNormalMapY: boolean;
  32805. /**
  32806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32807. */
  32808. twoSidedLighting: boolean;
  32809. /**
  32810. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32811. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32812. */
  32813. useAlphaFresnel: boolean;
  32814. /**
  32815. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32816. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32817. */
  32818. useLinearAlphaFresnel: boolean;
  32819. /**
  32820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32821. * And/Or occlude the blended part.
  32822. */
  32823. environmentBRDFTexture: Nullable<BaseTexture>;
  32824. /**
  32825. * Force normal to face away from face.
  32826. */
  32827. forceNormalForward: boolean;
  32828. /**
  32829. * Enables specular anti aliasing in the PBR shader.
  32830. * It will both interacts on the Geometry for analytical and IBL lighting.
  32831. * It also prefilter the roughness map based on the bump values.
  32832. */
  32833. enableSpecularAntiAliasing: boolean;
  32834. /**
  32835. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32836. * makes the reflect vector face the model (under horizon).
  32837. */
  32838. useHorizonOcclusion: boolean;
  32839. /**
  32840. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32841. * too much the area relying on ambient texture to define their ambient occlusion.
  32842. */
  32843. useRadianceOcclusion: boolean;
  32844. /**
  32845. * If set to true, no lighting calculations will be applied.
  32846. */
  32847. unlit: boolean;
  32848. /**
  32849. * Gets the image processing configuration used either in this material.
  32850. */
  32851. /**
  32852. * Sets the Default image processing configuration used either in the this material.
  32853. *
  32854. * If sets to null, the scene one is in use.
  32855. */
  32856. imageProcessingConfiguration: ImageProcessingConfiguration;
  32857. /**
  32858. * Gets wether the color curves effect is enabled.
  32859. */
  32860. /**
  32861. * Sets wether the color curves effect is enabled.
  32862. */
  32863. cameraColorCurvesEnabled: boolean;
  32864. /**
  32865. * Gets wether the color grading effect is enabled.
  32866. */
  32867. /**
  32868. * Gets wether the color grading effect is enabled.
  32869. */
  32870. cameraColorGradingEnabled: boolean;
  32871. /**
  32872. * Gets wether tonemapping is enabled or not.
  32873. */
  32874. /**
  32875. * Sets wether tonemapping is enabled or not
  32876. */
  32877. cameraToneMappingEnabled: boolean;
  32878. /**
  32879. * The camera exposure used on this material.
  32880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32881. * This corresponds to a photographic exposure.
  32882. */
  32883. /**
  32884. * The camera exposure used on this material.
  32885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32886. * This corresponds to a photographic exposure.
  32887. */
  32888. cameraExposure: number;
  32889. /**
  32890. * Gets The camera contrast used on this material.
  32891. */
  32892. /**
  32893. * Sets The camera contrast used on this material.
  32894. */
  32895. cameraContrast: number;
  32896. /**
  32897. * Gets the Color Grading 2D Lookup Texture.
  32898. */
  32899. /**
  32900. * Sets the Color Grading 2D Lookup Texture.
  32901. */
  32902. cameraColorGradingTexture: Nullable<BaseTexture>;
  32903. /**
  32904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32906. * 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;
  32907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32908. */
  32909. /**
  32910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32912. * 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;
  32913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32914. */
  32915. cameraColorCurves: Nullable<ColorCurves>;
  32916. /**
  32917. * Instantiates a new PBRMaterial instance.
  32918. *
  32919. * @param name The material name
  32920. * @param scene The scene the material will be use in.
  32921. */
  32922. constructor(name: string, scene: Scene);
  32923. /**
  32924. * Returns the name of this material class.
  32925. */
  32926. getClassName(): string;
  32927. /**
  32928. * Returns an array of the actively used textures.
  32929. * @returns - Array of BaseTextures
  32930. */
  32931. getActiveTextures(): BaseTexture[];
  32932. /**
  32933. * Checks to see if a texture is used in the material.
  32934. * @param texture - Base texture to use.
  32935. * @returns - Boolean specifying if a texture is used in the material.
  32936. */
  32937. hasTexture(texture: BaseTexture): boolean;
  32938. /**
  32939. * Makes a duplicate of the current material.
  32940. * @param name - name to use for the new material.
  32941. */
  32942. clone(name: string): PBRMaterial;
  32943. /**
  32944. * Serializes this PBR Material.
  32945. * @returns - An object with the serialized material.
  32946. */
  32947. serialize(): any;
  32948. /**
  32949. * Parses a PBR Material from a serialized object.
  32950. * @param source - Serialized object.
  32951. * @param scene - BJS scene instance.
  32952. * @param rootUrl - url for the scene object
  32953. * @returns - PBRMaterial
  32954. */
  32955. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32956. }
  32957. }
  32958. declare module BABYLON {
  32959. /**
  32960. * The PBR material of BJS following the metal roughness convention.
  32961. *
  32962. * This fits to the PBR convention in the GLTF definition:
  32963. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32964. */
  32965. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32966. /**
  32967. * The base color has two different interpretations depending on the value of metalness.
  32968. * When the material is a metal, the base color is the specific measured reflectance value
  32969. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32970. * of the material.
  32971. */
  32972. baseColor: Color3;
  32973. /**
  32974. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32975. * well as opacity information in the alpha channel.
  32976. */
  32977. baseTexture: BaseTexture;
  32978. /**
  32979. * Specifies the metallic scalar value of the material.
  32980. * Can also be used to scale the metalness values of the metallic texture.
  32981. */
  32982. metallic: number;
  32983. /**
  32984. * Specifies the roughness scalar value of the material.
  32985. * Can also be used to scale the roughness values of the metallic texture.
  32986. */
  32987. roughness: number;
  32988. /**
  32989. * Texture containing both the metallic value in the B channel and the
  32990. * roughness value in the G channel to keep better precision.
  32991. */
  32992. metallicRoughnessTexture: BaseTexture;
  32993. /**
  32994. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32995. *
  32996. * @param name The material name
  32997. * @param scene The scene the material will be use in.
  32998. */
  32999. constructor(name: string, scene: Scene);
  33000. /**
  33001. * Return the currrent class name of the material.
  33002. */
  33003. getClassName(): string;
  33004. /**
  33005. * Return the active textures of the material.
  33006. */
  33007. getActiveTextures(): BaseTexture[];
  33008. /**
  33009. * Checks to see if a texture is used in the material.
  33010. * @param texture - Base texture to use.
  33011. * @returns - Boolean specifying if a texture is used in the material.
  33012. */
  33013. hasTexture(texture: BaseTexture): boolean;
  33014. /**
  33015. * Makes a duplicate of the current material.
  33016. * @param name - name to use for the new material.
  33017. */
  33018. clone(name: string): PBRMetallicRoughnessMaterial;
  33019. /**
  33020. * Serialize the material to a parsable JSON object.
  33021. */
  33022. serialize(): any;
  33023. /**
  33024. * Parses a JSON object correponding to the serialize function.
  33025. */
  33026. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33027. }
  33028. }
  33029. declare module BABYLON {
  33030. /**
  33031. * The PBR material of BJS following the specular glossiness convention.
  33032. *
  33033. * This fits to the PBR convention in the GLTF definition:
  33034. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33035. */
  33036. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33037. /**
  33038. * Specifies the diffuse color of the material.
  33039. */
  33040. diffuseColor: Color3;
  33041. /**
  33042. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33043. * channel.
  33044. */
  33045. diffuseTexture: BaseTexture;
  33046. /**
  33047. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33048. */
  33049. specularColor: Color3;
  33050. /**
  33051. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33052. */
  33053. glossiness: number;
  33054. /**
  33055. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33056. */
  33057. specularGlossinessTexture: BaseTexture;
  33058. /**
  33059. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33060. *
  33061. * @param name The material name
  33062. * @param scene The scene the material will be use in.
  33063. */
  33064. constructor(name: string, scene: Scene);
  33065. /**
  33066. * Return the currrent class name of the material.
  33067. */
  33068. getClassName(): string;
  33069. /**
  33070. * Return the active textures of the material.
  33071. */
  33072. getActiveTextures(): BaseTexture[];
  33073. /**
  33074. * Checks to see if a texture is used in the material.
  33075. * @param texture - Base texture to use.
  33076. * @returns - Boolean specifying if a texture is used in the material.
  33077. */
  33078. hasTexture(texture: BaseTexture): boolean;
  33079. /**
  33080. * Makes a duplicate of the current material.
  33081. * @param name - name to use for the new material.
  33082. */
  33083. clone(name: string): PBRSpecularGlossinessMaterial;
  33084. /**
  33085. * Serialize the material to a parsable JSON object.
  33086. */
  33087. serialize(): any;
  33088. /**
  33089. * Parses a JSON object correponding to the serialize function.
  33090. */
  33091. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33092. }
  33093. }
  33094. declare module BABYLON {
  33095. class BaseTexture {
  33096. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33097. name: string;
  33098. private _hasAlpha;
  33099. hasAlpha: boolean;
  33100. getAlphaFromRGB: boolean;
  33101. level: number;
  33102. coordinatesIndex: number;
  33103. private _coordinatesMode;
  33104. /**
  33105. * How a texture is mapped.
  33106. *
  33107. * | Value | Type | Description |
  33108. * | ----- | ----------------------------------- | ----------- |
  33109. * | 0 | EXPLICIT_MODE | |
  33110. * | 1 | SPHERICAL_MODE | |
  33111. * | 2 | PLANAR_MODE | |
  33112. * | 3 | CUBIC_MODE | |
  33113. * | 4 | PROJECTION_MODE | |
  33114. * | 5 | SKYBOX_MODE | |
  33115. * | 6 | INVCUBIC_MODE | |
  33116. * | 7 | EQUIRECTANGULAR_MODE | |
  33117. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33118. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33119. */
  33120. coordinatesMode: number;
  33121. /**
  33122. * | Value | Type | Description |
  33123. * | ----- | ------------------ | ----------- |
  33124. * | 0 | CLAMP_ADDRESSMODE | |
  33125. * | 1 | WRAP_ADDRESSMODE | |
  33126. * | 2 | MIRROR_ADDRESSMODE | |
  33127. */
  33128. wrapU: number;
  33129. /**
  33130. * | Value | Type | Description |
  33131. * | ----- | ------------------ | ----------- |
  33132. * | 0 | CLAMP_ADDRESSMODE | |
  33133. * | 1 | WRAP_ADDRESSMODE | |
  33134. * | 2 | MIRROR_ADDRESSMODE | |
  33135. */
  33136. wrapV: number;
  33137. /**
  33138. * | Value | Type | Description |
  33139. * | ----- | ------------------ | ----------- |
  33140. * | 0 | CLAMP_ADDRESSMODE | |
  33141. * | 1 | WRAP_ADDRESSMODE | |
  33142. * | 2 | MIRROR_ADDRESSMODE | |
  33143. */
  33144. wrapR: number;
  33145. anisotropicFilteringLevel: number;
  33146. isCube: boolean;
  33147. is3D: boolean;
  33148. gammaSpace: boolean;
  33149. invertZ: boolean;
  33150. lodLevelInAlpha: boolean;
  33151. lodGenerationOffset: number;
  33152. lodGenerationScale: number;
  33153. isRenderTarget: boolean;
  33154. readonly uid: string;
  33155. toString(): string;
  33156. getClassName(): string;
  33157. animations: Animation[];
  33158. /**
  33159. * An event triggered when the texture is disposed.
  33160. */
  33161. onDisposeObservable: Observable<BaseTexture>;
  33162. private _onDisposeObserver;
  33163. onDispose: () => void;
  33164. delayLoadState: number;
  33165. private _scene;
  33166. _texture: Nullable<InternalTexture>;
  33167. private _uid;
  33168. readonly isBlocking: boolean;
  33169. constructor(scene: Nullable<Scene>);
  33170. getScene(): Nullable<Scene>;
  33171. getTextureMatrix(): Matrix;
  33172. getReflectionTextureMatrix(): Matrix;
  33173. getInternalTexture(): Nullable<InternalTexture>;
  33174. isReadyOrNotBlocking(): boolean;
  33175. isReady(): boolean;
  33176. getSize(): ISize;
  33177. getBaseSize(): ISize;
  33178. scale(ratio: number): void;
  33179. readonly canRescale: boolean;
  33180. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  33181. _rebuild(): void;
  33182. delayLoad(): void;
  33183. clone(): Nullable<BaseTexture>;
  33184. readonly textureType: number;
  33185. readonly textureFormat: number;
  33186. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  33187. releaseInternalTexture(): void;
  33188. sphericalPolynomial: Nullable<SphericalPolynomial>;
  33189. readonly _lodTextureHigh: Nullable<BaseTexture>;
  33190. readonly _lodTextureMid: Nullable<BaseTexture>;
  33191. readonly _lodTextureLow: Nullable<BaseTexture>;
  33192. dispose(): void;
  33193. serialize(): any;
  33194. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33195. }
  33196. }
  33197. declare module BABYLON {
  33198. /**
  33199. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  33200. * It can help converting any input color in a desired output one. This can then be used to create effects
  33201. * from sepia, black and white to sixties or futuristic rendering...
  33202. *
  33203. * The only supported format is currently 3dl.
  33204. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  33205. */
  33206. class ColorGradingTexture extends BaseTexture {
  33207. /**
  33208. * The current texture matrix. (will always be identity in color grading texture)
  33209. */
  33210. private _textureMatrix;
  33211. /**
  33212. * The texture URL.
  33213. */
  33214. url: string;
  33215. /**
  33216. * Empty line regex stored for GC.
  33217. */
  33218. private static _noneEmptyLineRegex;
  33219. private _engine;
  33220. /**
  33221. * Instantiates a ColorGradingTexture from the following parameters.
  33222. *
  33223. * @param url The location of the color gradind data (currently only supporting 3dl)
  33224. * @param scene The scene the texture will be used in
  33225. */
  33226. constructor(url: string, scene: Scene);
  33227. /**
  33228. * Returns the texture matrix used in most of the material.
  33229. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  33230. */
  33231. getTextureMatrix(): Matrix;
  33232. /**
  33233. * Occurs when the file being loaded is a .3dl LUT file.
  33234. */
  33235. private load3dlTexture();
  33236. /**
  33237. * Starts the loading process of the texture.
  33238. */
  33239. private loadTexture();
  33240. /**
  33241. * Clones the color gradind texture.
  33242. */
  33243. clone(): ColorGradingTexture;
  33244. /**
  33245. * Called during delayed load for textures.
  33246. */
  33247. delayLoad(): void;
  33248. /**
  33249. * Parses a color grading texture serialized by Babylon.
  33250. * @param parsedTexture The texture information being parsedTexture
  33251. * @param scene The scene to load the texture in
  33252. * @param rootUrl The root url of the data assets to load
  33253. * @return A color gradind texture
  33254. */
  33255. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  33256. /**
  33257. * Serializes the LUT texture to json format.
  33258. */
  33259. serialize(): any;
  33260. }
  33261. }
  33262. declare module BABYLON {
  33263. class CubeTexture extends BaseTexture {
  33264. url: string;
  33265. coordinatesMode: number;
  33266. /**
  33267. * Gets or sets the center of the bounding box associated with the cube texture
  33268. * It must define where the camera used to render the texture was set
  33269. */
  33270. boundingBoxPosition: Vector3;
  33271. private _boundingBoxSize;
  33272. /**
  33273. * Gets or sets the size of the bounding box associated with the cube texture
  33274. * When defined, the cubemap will switch to local mode
  33275. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33276. * @example https://www.babylonjs-playground.com/#RNASML
  33277. */
  33278. boundingBoxSize: Vector3;
  33279. protected _rotationY: number;
  33280. /**
  33281. * Gets texture matrix rotation angle around Y axis radians.
  33282. */
  33283. /**
  33284. * Sets texture matrix rotation angle around Y axis in radians.
  33285. */
  33286. rotationY: number;
  33287. private _noMipmap;
  33288. private _files;
  33289. private _extensions;
  33290. private _textureMatrix;
  33291. private _format;
  33292. private _prefiltered;
  33293. private _createPolynomials;
  33294. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33295. /**
  33296. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33297. * @param url defines the url of the prefiltered texture
  33298. * @param scene defines the scene the texture is attached to
  33299. * @param forcedExtension defines the extension of the file if different from the url
  33300. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33301. * @return the prefiltered texture
  33302. */
  33303. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33304. /**
  33305. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33306. * as prefiltered data.
  33307. * @param rootUrl defines the url of the texture or the root name of the six images
  33308. * @param scene defines the scene the texture is attached to
  33309. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33310. * @param noMipmap defines if mipmaps should be created or not
  33311. * @param files defines the six files to load for the different faces
  33312. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33313. * @param onError defines a callback triggered in case of error during load
  33314. * @param format defines the internal format to use for the texture once loaded
  33315. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33316. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33317. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33318. * @return the cube texture
  33319. */
  33320. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean);
  33321. delayLoad(): void;
  33322. getReflectionTextureMatrix(): Matrix;
  33323. setReflectionTextureMatrix(value: Matrix): void;
  33324. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33325. clone(): CubeTexture;
  33326. }
  33327. }
  33328. declare module BABYLON {
  33329. /**
  33330. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33331. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33332. */
  33333. class DynamicTexture extends Texture {
  33334. private _generateMipMaps;
  33335. private _canvas;
  33336. private _context;
  33337. private _engine;
  33338. /**
  33339. * Creates a {BABYLON.DynamicTexture}
  33340. * @param name defines the name of the texture
  33341. * @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
  33342. * @param scene defines the scene where you want the texture
  33343. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33344. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33345. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33346. */
  33347. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33348. /**
  33349. * Gets the current state of canRescale
  33350. */
  33351. readonly canRescale: boolean;
  33352. private _recreate(textureSize);
  33353. /**
  33354. * Scales the texture
  33355. * @param ratio the scale factor to apply to both width and height
  33356. */
  33357. scale(ratio: number): void;
  33358. /**
  33359. * Resizes the texture
  33360. * @param width the new width
  33361. * @param height the new height
  33362. */
  33363. scaleTo(width: number, height: number): void;
  33364. /**
  33365. * Gets the context of the canvas used by the texture
  33366. * @returns the canvas context of the dynamic texture
  33367. */
  33368. getContext(): CanvasRenderingContext2D;
  33369. /**
  33370. * Clears the texture
  33371. */
  33372. clear(): void;
  33373. /**
  33374. * Updates the texture
  33375. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33376. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33377. */
  33378. update(invertY?: boolean, premulAlpha?: boolean): void;
  33379. /**
  33380. * Draws text onto the texture
  33381. * @param text defines the text to be drawn
  33382. * @param x defines the placement of the text from the left
  33383. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33384. * @param font defines the font to be used with font-style, font-size, font-name
  33385. * @param color defines the color used for the text
  33386. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33387. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33388. * @param update defines whether texture is immediately update (default is true)
  33389. */
  33390. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33391. /**
  33392. * Clones the texture
  33393. * @returns the clone of the texture.
  33394. */
  33395. clone(): DynamicTexture;
  33396. /** @hidden */
  33397. _rebuild(): void;
  33398. }
  33399. }
  33400. declare module BABYLON {
  33401. /**
  33402. * This represents a texture coming from an HDR input.
  33403. *
  33404. * The only supported format is currently panorama picture stored in RGBE format.
  33405. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33406. */
  33407. class HDRCubeTexture extends BaseTexture {
  33408. private static _facesMapping;
  33409. private _generateHarmonics;
  33410. private _noMipmap;
  33411. private _textureMatrix;
  33412. private _size;
  33413. private _onLoad;
  33414. private _onError;
  33415. /**
  33416. * The texture URL.
  33417. */
  33418. url: string;
  33419. /**
  33420. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33421. */
  33422. coordinatesMode: number;
  33423. protected _isBlocking: boolean;
  33424. /**
  33425. * Gets wether or not the texture is blocking during loading.
  33426. */
  33427. /**
  33428. * Sets wether or not the texture is blocking during loading.
  33429. */
  33430. isBlocking: boolean;
  33431. protected _rotationY: number;
  33432. /**
  33433. * Gets texture matrix rotation angle around Y axis radians.
  33434. */
  33435. /**
  33436. * Sets texture matrix rotation angle around Y axis in radians.
  33437. */
  33438. rotationY: number;
  33439. /**
  33440. * Gets or sets the center of the bounding box associated with the cube texture
  33441. * It must define where the camera used to render the texture was set
  33442. */
  33443. boundingBoxPosition: Vector3;
  33444. private _boundingBoxSize;
  33445. /**
  33446. * Gets or sets the size of the bounding box associated with the cube texture
  33447. * When defined, the cubemap will switch to local mode
  33448. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33449. * @example https://www.babylonjs-playground.com/#RNASML
  33450. */
  33451. boundingBoxSize: Vector3;
  33452. /**
  33453. * Instantiates an HDRTexture from the following parameters.
  33454. *
  33455. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33456. * @param scene The scene the texture will be used in
  33457. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33458. * @param noMipmap Forces to not generate the mipmap if true
  33459. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33460. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  33461. * @param reserved Reserved flag for internal use.
  33462. */
  33463. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  33464. /**
  33465. * Occurs when the file is raw .hdr file.
  33466. */
  33467. private loadTexture();
  33468. clone(): HDRCubeTexture;
  33469. delayLoad(): void;
  33470. getReflectionTextureMatrix(): Matrix;
  33471. setReflectionTextureMatrix(value: Matrix): void;
  33472. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33473. serialize(): any;
  33474. }
  33475. }
  33476. declare module BABYLON {
  33477. /**
  33478. * Class used to store data associated with WebGL texture data for the engine
  33479. * This class should not be used directly
  33480. */
  33481. class InternalTexture implements IInternalTextureTracker {
  33482. /**
  33483. * The source of the texture data is unknown
  33484. */
  33485. static DATASOURCE_UNKNOWN: number;
  33486. /**
  33487. * Texture data comes from an URL
  33488. */
  33489. static DATASOURCE_URL: number;
  33490. /**
  33491. * Texture data is only used for temporary storage
  33492. */
  33493. static DATASOURCE_TEMP: number;
  33494. /**
  33495. * Texture data comes from raw data (ArrayBuffer)
  33496. */
  33497. static DATASOURCE_RAW: number;
  33498. /**
  33499. * Texture content is dynamic (video or dynamic texture)
  33500. */
  33501. static DATASOURCE_DYNAMIC: number;
  33502. /**
  33503. * Texture content is generated by rendering to it
  33504. */
  33505. static DATASOURCE_RENDERTARGET: number;
  33506. /**
  33507. * Texture content is part of a multi render target process
  33508. */
  33509. static DATASOURCE_MULTIRENDERTARGET: number;
  33510. /**
  33511. * Texture data comes from a cube data file
  33512. */
  33513. static DATASOURCE_CUBE: number;
  33514. /**
  33515. * Texture data comes from a raw cube data
  33516. */
  33517. static DATASOURCE_CUBERAW: number;
  33518. /**
  33519. * Texture data come from a prefiltered cube data file
  33520. */
  33521. static DATASOURCE_CUBEPREFILTERED: number;
  33522. /**
  33523. * Texture content is raw 3D data
  33524. */
  33525. static DATASOURCE_RAW3D: number;
  33526. /**
  33527. * Texture content is a depth texture
  33528. */
  33529. static DATASOURCE_DEPTHTEXTURE: number;
  33530. /**
  33531. * Defines if the texture is ready
  33532. */
  33533. isReady: boolean;
  33534. /**
  33535. * Defines if the texture is a cube texture
  33536. */
  33537. isCube: boolean;
  33538. /**
  33539. * Defines if the texture contains 3D data
  33540. */
  33541. is3D: boolean;
  33542. /**
  33543. * Gets the URL used to load this texture
  33544. */
  33545. url: string;
  33546. /**
  33547. * Gets the sampling mode of the texture
  33548. */
  33549. samplingMode: number;
  33550. /**
  33551. * Gets a boolean indicating if the texture needs mipmaps generation
  33552. */
  33553. generateMipMaps: boolean;
  33554. /**
  33555. * Gets the number of samples used by the texture (WebGL2+ only)
  33556. */
  33557. samples: number;
  33558. /**
  33559. * Gets the type of the texture
  33560. */
  33561. type: number;
  33562. /**
  33563. * Gets the format of the texture
  33564. */
  33565. format: number;
  33566. /**
  33567. * Observable called when the texture is loaded
  33568. */
  33569. onLoadedObservable: Observable<InternalTexture>;
  33570. /**
  33571. * Gets the width of the texture
  33572. */
  33573. width: number;
  33574. /**
  33575. * Gets the height of the texture
  33576. */
  33577. height: number;
  33578. /**
  33579. * Gets the depth of the texture
  33580. */
  33581. depth: number;
  33582. /**
  33583. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33584. */
  33585. baseWidth: number;
  33586. /**
  33587. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33588. */
  33589. baseHeight: number;
  33590. /**
  33591. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33592. */
  33593. baseDepth: number;
  33594. /**
  33595. * Gets a boolean indicating if the texture is inverted on Y axis
  33596. */
  33597. invertY: boolean;
  33598. /**
  33599. * Gets or set the previous tracker in the list
  33600. */
  33601. previous: Nullable<IInternalTextureTracker>;
  33602. /**
  33603. * Gets or set the next tracker in the list
  33604. */
  33605. next: Nullable<IInternalTextureTracker>;
  33606. /** @hidden */
  33607. _initialSlot: number;
  33608. /** @hidden */
  33609. _designatedSlot: number;
  33610. /** @hidden */
  33611. _dataSource: number;
  33612. /** @hidden */
  33613. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  33614. /** @hidden */
  33615. _bufferView: Nullable<ArrayBufferView>;
  33616. /** @hidden */
  33617. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33618. /** @hidden */
  33619. _size: number;
  33620. /** @hidden */
  33621. _extension: string;
  33622. /** @hidden */
  33623. _files: Nullable<string[]>;
  33624. /** @hidden */
  33625. _workingCanvas: HTMLCanvasElement;
  33626. /** @hidden */
  33627. _workingContext: CanvasRenderingContext2D;
  33628. /** @hidden */
  33629. _framebuffer: Nullable<WebGLFramebuffer>;
  33630. /** @hidden */
  33631. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33632. /** @hidden */
  33633. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33634. /** @hidden */
  33635. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33636. /** @hidden */
  33637. _attachments: Nullable<number[]>;
  33638. /** @hidden */
  33639. _cachedCoordinatesMode: Nullable<number>;
  33640. /** @hidden */
  33641. _cachedWrapU: Nullable<number>;
  33642. /** @hidden */
  33643. _cachedWrapV: Nullable<number>;
  33644. /** @hidden */
  33645. _cachedWrapR: Nullable<number>;
  33646. /** @hidden */
  33647. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33648. /** @hidden */
  33649. _isDisabled: boolean;
  33650. /** @hidden */
  33651. _compression: Nullable<string>;
  33652. /** @hidden */
  33653. _generateStencilBuffer: boolean;
  33654. /** @hidden */
  33655. _generateDepthBuffer: boolean;
  33656. /** @hidden */
  33657. _comparisonFunction: number;
  33658. /** @hidden */
  33659. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33660. /** @hidden */
  33661. _lodGenerationScale: number;
  33662. /** @hidden */
  33663. _lodGenerationOffset: number;
  33664. /** @hidden */
  33665. _lodTextureHigh: BaseTexture;
  33666. /** @hidden */
  33667. _lodTextureMid: BaseTexture;
  33668. /** @hidden */
  33669. _lodTextureLow: BaseTexture;
  33670. /** @hidden */
  33671. _webGLTexture: Nullable<WebGLTexture>;
  33672. /** @hidden */
  33673. _references: number;
  33674. private _engine;
  33675. /**
  33676. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33677. */
  33678. readonly dataSource: number;
  33679. /**
  33680. * Creates a new InternalTexture
  33681. * @param engine defines the engine to use
  33682. * @param dataSource defines the type of data that will be used
  33683. */
  33684. constructor(engine: Engine, dataSource: number);
  33685. /**
  33686. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33687. */
  33688. incrementReferences(): void;
  33689. /**
  33690. * Change the size of the texture (not the size of the content)
  33691. * @param width defines the new width
  33692. * @param height defines the new height
  33693. * @param depth defines the new depth (1 by default)
  33694. */
  33695. updateSize(width: int, height: int, depth?: int): void;
  33696. /** @hidden */
  33697. _rebuild(): void;
  33698. private _swapAndDie(target);
  33699. /**
  33700. * Dispose the current allocated resources
  33701. */
  33702. dispose(): void;
  33703. }
  33704. }
  33705. declare module BABYLON {
  33706. /**
  33707. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33708. */
  33709. interface IInternalTextureTracker {
  33710. /**
  33711. * Gets or set the previous tracker in the list
  33712. */
  33713. previous: Nullable<IInternalTextureTracker>;
  33714. /**
  33715. * Gets or set the next tracker in the list
  33716. */
  33717. next: Nullable<IInternalTextureTracker>;
  33718. }
  33719. /**
  33720. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33721. */
  33722. class DummyInternalTextureTracker {
  33723. /**
  33724. * Gets or set the previous tracker in the list
  33725. */
  33726. previous: Nullable<IInternalTextureTracker>;
  33727. /**
  33728. * Gets or set the next tracker in the list
  33729. */
  33730. next: Nullable<IInternalTextureTracker>;
  33731. }
  33732. }
  33733. declare module BABYLON {
  33734. class MirrorTexture extends RenderTargetTexture {
  33735. private scene;
  33736. mirrorPlane: Plane;
  33737. private _transformMatrix;
  33738. private _mirrorMatrix;
  33739. private _savedViewMatrix;
  33740. private _blurX;
  33741. private _blurY;
  33742. private _adaptiveBlurKernel;
  33743. private _blurKernelX;
  33744. private _blurKernelY;
  33745. private _blurRatio;
  33746. blurRatio: number;
  33747. adaptiveBlurKernel: number;
  33748. blurKernel: number;
  33749. blurKernelX: number;
  33750. blurKernelY: number;
  33751. private _autoComputeBlurKernel();
  33752. protected _onRatioRescale(): void;
  33753. private _updateGammaSpace();
  33754. private _imageProcessingConfigChangeObserver;
  33755. constructor(name: string, size: number | {
  33756. width: number;
  33757. height: number;
  33758. } | {
  33759. ratio: number;
  33760. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33761. private _preparePostProcesses();
  33762. clone(): MirrorTexture;
  33763. serialize(): any;
  33764. dispose(): void;
  33765. }
  33766. }
  33767. declare module BABYLON {
  33768. interface IMultiRenderTargetOptions {
  33769. generateMipMaps?: boolean;
  33770. types?: number[];
  33771. samplingModes?: number[];
  33772. generateDepthBuffer?: boolean;
  33773. generateStencilBuffer?: boolean;
  33774. generateDepthTexture?: boolean;
  33775. textureCount?: number;
  33776. doNotChangeAspectRatio?: boolean;
  33777. defaultType?: number;
  33778. }
  33779. class MultiRenderTarget extends RenderTargetTexture {
  33780. private _internalTextures;
  33781. private _textures;
  33782. readonly isSupported: boolean;
  33783. private _multiRenderTargetOptions;
  33784. readonly textures: Texture[];
  33785. readonly depthTexture: Texture;
  33786. wrapU: number;
  33787. wrapV: number;
  33788. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33789. _rebuild(): void;
  33790. private _createInternalTextures();
  33791. private _createTextures();
  33792. samples: number;
  33793. resize(size: any): void;
  33794. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33795. dispose(): void;
  33796. releaseInternalTextures(): void;
  33797. }
  33798. }
  33799. declare module BABYLON {
  33800. class RawTexture extends Texture {
  33801. format: number;
  33802. private _engine;
  33803. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33804. update(data: ArrayBufferView): void;
  33805. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33806. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33807. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33808. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33809. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33810. }
  33811. }
  33812. declare module BABYLON {
  33813. /**
  33814. * Class used to store 3D textures containing user data
  33815. */
  33816. class RawTexture3D extends Texture {
  33817. /** Gets or sets the texture format to use */
  33818. format: number;
  33819. private _engine;
  33820. /**
  33821. * Create a new RawTexture3D
  33822. * @param data defines the data of the texture
  33823. * @param width defines the width of the texture
  33824. * @param height defines the height of the texture
  33825. * @param depth defines the depth of the texture
  33826. * @param format defines the texture format to use
  33827. * @param scene defines the hosting scene
  33828. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33829. * @param invertY defines if texture must be stored with Y axis inverted
  33830. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33831. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33832. */
  33833. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33834. /** Gets or sets the texture format to use */
  33835. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  33836. /**
  33837. * Update the texture with new data
  33838. * @param data defines the data to store in the texture
  33839. */
  33840. update(data: ArrayBufferView): void;
  33841. }
  33842. }
  33843. declare module BABYLON {
  33844. /**
  33845. * Creates a refraction texture used by refraction channel of the standard material.
  33846. * @param name the texture name
  33847. * @param size size of the underlying texture
  33848. * @param scene root scene
  33849. */
  33850. class RefractionTexture extends RenderTargetTexture {
  33851. refractionPlane: Plane;
  33852. depth: number;
  33853. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33854. clone(): RefractionTexture;
  33855. serialize(): any;
  33856. }
  33857. }
  33858. declare module BABYLON {
  33859. class RenderTargetTexture extends Texture {
  33860. isCube: boolean;
  33861. static _REFRESHRATE_RENDER_ONCE: number;
  33862. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33863. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33864. static readonly REFRESHRATE_RENDER_ONCE: number;
  33865. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33866. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33867. /**
  33868. * Use this predicate to dynamically define the list of mesh you want to render.
  33869. * If set, the renderList property will be overwritten.
  33870. */
  33871. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33872. /**
  33873. * Use this list to define the list of mesh you want to render.
  33874. */
  33875. renderList: Nullable<Array<AbstractMesh>>;
  33876. renderParticles: boolean;
  33877. renderSprites: boolean;
  33878. coordinatesMode: number;
  33879. activeCamera: Nullable<Camera>;
  33880. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33881. useCameraPostProcesses: boolean;
  33882. ignoreCameraViewport: boolean;
  33883. private _postProcessManager;
  33884. private _postProcesses;
  33885. private _resizeObserver;
  33886. /**
  33887. * An event triggered when the texture is unbind.
  33888. */
  33889. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33890. /**
  33891. * An event triggered when the texture is unbind.
  33892. */
  33893. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33894. private _onAfterUnbindObserver;
  33895. onAfterUnbind: () => void;
  33896. /**
  33897. * An event triggered before rendering the texture
  33898. */
  33899. onBeforeRenderObservable: Observable<number>;
  33900. private _onBeforeRenderObserver;
  33901. onBeforeRender: (faceIndex: number) => void;
  33902. /**
  33903. * An event triggered after rendering the texture
  33904. */
  33905. onAfterRenderObservable: Observable<number>;
  33906. private _onAfterRenderObserver;
  33907. onAfterRender: (faceIndex: number) => void;
  33908. /**
  33909. * An event triggered after the texture clear
  33910. */
  33911. onClearObservable: Observable<Engine>;
  33912. private _onClearObserver;
  33913. onClear: (Engine: Engine) => void;
  33914. clearColor: Color4;
  33915. protected _size: number | {
  33916. width: number;
  33917. height: number;
  33918. };
  33919. protected _initialSizeParameter: number | {
  33920. width: number;
  33921. height: number;
  33922. } | {
  33923. ratio: number;
  33924. };
  33925. protected _sizeRatio: Nullable<number>;
  33926. _generateMipMaps: boolean;
  33927. protected _renderingManager: RenderingManager;
  33928. _waitingRenderList: string[];
  33929. protected _doNotChangeAspectRatio: boolean;
  33930. protected _currentRefreshId: number;
  33931. protected _refreshRate: number;
  33932. protected _textureMatrix: Matrix;
  33933. protected _samples: number;
  33934. protected _renderTargetOptions: RenderTargetCreationOptions;
  33935. readonly renderTargetOptions: RenderTargetCreationOptions;
  33936. protected _engine: Engine;
  33937. protected _onRatioRescale(): void;
  33938. /**
  33939. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33940. * It must define where the camera used to render the texture is set
  33941. */
  33942. boundingBoxPosition: Vector3;
  33943. private _boundingBoxSize;
  33944. /**
  33945. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33946. * When defined, the cubemap will switch to local mode
  33947. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33948. * @example https://www.babylonjs-playground.com/#RNASML
  33949. */
  33950. boundingBoxSize: Vector3;
  33951. /**
  33952. * In case the RTT has been created with a depth texture, get the associated
  33953. * depth texture.
  33954. * Otherwise, return null.
  33955. */
  33956. depthStencilTexture: Nullable<InternalTexture>;
  33957. /**
  33958. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33959. * or used a shadow, depth texture...
  33960. * @param name The friendly name of the texture
  33961. * @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)
  33962. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33963. * @param generateMipMaps True if mip maps need to be generated after render.
  33964. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33965. * @param type The type of the buffer in the RTT (int, half float, float...)
  33966. * @param isCube True if a cube texture needs to be created
  33967. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33968. * @param generateDepthBuffer True to generate a depth buffer
  33969. * @param generateStencilBuffer True to generate a stencil buffer
  33970. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33971. */
  33972. constructor(name: string, size: number | {
  33973. width: number;
  33974. height: number;
  33975. } | {
  33976. ratio: number;
  33977. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33978. /**
  33979. * Creates a depth stencil texture.
  33980. * This is only available in WebGL 2 or with the depth texture extension available.
  33981. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33982. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33983. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33984. */
  33985. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33986. private _processSizeParameter(size);
  33987. samples: number;
  33988. resetRefreshCounter(): void;
  33989. refreshRate: number;
  33990. addPostProcess(postProcess: PostProcess): void;
  33991. clearPostProcesses(dispose?: boolean): void;
  33992. removePostProcess(postProcess: PostProcess): void;
  33993. _shouldRender(): boolean;
  33994. getRenderSize(): number;
  33995. getRenderWidth(): number;
  33996. getRenderHeight(): number;
  33997. readonly canRescale: boolean;
  33998. scale(ratio: number): void;
  33999. getReflectionTextureMatrix(): Matrix;
  34000. resize(size: number | {
  34001. width: number;
  34002. height: number;
  34003. } | {
  34004. ratio: number;
  34005. }): void;
  34006. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  34007. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  34008. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34009. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  34010. /**
  34011. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34012. * This allowed control for front to back rendering or reversly depending of the special needs.
  34013. *
  34014. * @param renderingGroupId The rendering group id corresponding to its index
  34015. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34016. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34017. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34018. */
  34019. 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;
  34020. /**
  34021. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34022. *
  34023. * @param renderingGroupId The rendering group id corresponding to its index
  34024. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34025. */
  34026. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34027. clone(): RenderTargetTexture;
  34028. serialize(): any;
  34029. disposeFramebufferObjects(): void;
  34030. dispose(): void;
  34031. _rebuild(): void;
  34032. /**
  34033. * Clear the info related to rendering groups preventing retention point in material dispose.
  34034. */
  34035. freeRenderingGroups(): void;
  34036. }
  34037. }
  34038. declare module BABYLON {
  34039. class Texture extends BaseTexture {
  34040. static NEAREST_SAMPLINGMODE: number;
  34041. static NEAREST_NEAREST_MIPLINEAR: number;
  34042. static BILINEAR_SAMPLINGMODE: number;
  34043. static LINEAR_LINEAR_MIPNEAREST: number;
  34044. static TRILINEAR_SAMPLINGMODE: number;
  34045. static LINEAR_LINEAR_MIPLINEAR: number;
  34046. static NEAREST_NEAREST_MIPNEAREST: number;
  34047. static NEAREST_LINEAR_MIPNEAREST: number;
  34048. static NEAREST_LINEAR_MIPLINEAR: number;
  34049. static NEAREST_LINEAR: number;
  34050. static NEAREST_NEAREST: number;
  34051. static LINEAR_NEAREST_MIPNEAREST: number;
  34052. static LINEAR_NEAREST_MIPLINEAR: number;
  34053. static LINEAR_LINEAR: number;
  34054. static LINEAR_NEAREST: number;
  34055. static EXPLICIT_MODE: number;
  34056. static SPHERICAL_MODE: number;
  34057. static PLANAR_MODE: number;
  34058. static CUBIC_MODE: number;
  34059. static PROJECTION_MODE: number;
  34060. static SKYBOX_MODE: number;
  34061. static INVCUBIC_MODE: number;
  34062. static EQUIRECTANGULAR_MODE: number;
  34063. static FIXED_EQUIRECTANGULAR_MODE: number;
  34064. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34065. static CLAMP_ADDRESSMODE: number;
  34066. static WRAP_ADDRESSMODE: number;
  34067. static MIRROR_ADDRESSMODE: number;
  34068. /**
  34069. * 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
  34070. */
  34071. static UseSerializedUrlIfAny: boolean;
  34072. url: Nullable<string>;
  34073. uOffset: number;
  34074. vOffset: number;
  34075. uScale: number;
  34076. vScale: number;
  34077. uAng: number;
  34078. vAng: number;
  34079. wAng: number;
  34080. /**
  34081. * Defines the center of rotation (U)
  34082. */
  34083. uRotationCenter: number;
  34084. /**
  34085. * Defines the center of rotation (V)
  34086. */
  34087. vRotationCenter: number;
  34088. /**
  34089. * Defines the center of rotation (W)
  34090. */
  34091. wRotationCenter: number;
  34092. readonly noMipmap: boolean;
  34093. private _noMipmap;
  34094. _invertY: boolean;
  34095. private _rowGenerationMatrix;
  34096. private _cachedTextureMatrix;
  34097. private _projectionModeMatrix;
  34098. private _t0;
  34099. private _t1;
  34100. private _t2;
  34101. private _cachedUOffset;
  34102. private _cachedVOffset;
  34103. private _cachedUScale;
  34104. private _cachedVScale;
  34105. private _cachedUAng;
  34106. private _cachedVAng;
  34107. private _cachedWAng;
  34108. private _cachedProjectionMatrixId;
  34109. private _cachedCoordinatesMode;
  34110. _samplingMode: number;
  34111. /** @hidden */
  34112. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34113. private _deleteBuffer;
  34114. protected _format: Nullable<number>;
  34115. private _delayedOnLoad;
  34116. private _delayedOnError;
  34117. protected _onLoadObservable: Nullable<Observable<Texture>>;
  34118. protected _isBlocking: boolean;
  34119. isBlocking: boolean;
  34120. readonly samplingMode: number;
  34121. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  34122. /**
  34123. * Update the url (and optional buffer) of this texture if url was null during construction.
  34124. * @param url the url of the texture
  34125. * @param buffer the buffer of the texture (defaults to null)
  34126. */
  34127. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  34128. delayLoad(): void;
  34129. updateSamplingMode(samplingMode: number): void;
  34130. private _prepareRowForTextureGeneration(x, y, z, t);
  34131. getTextureMatrix(): Matrix;
  34132. getReflectionTextureMatrix(): Matrix;
  34133. clone(): Texture;
  34134. readonly onLoadObservable: Observable<Texture>;
  34135. serialize(): any;
  34136. getClassName(): string;
  34137. dispose(): void;
  34138. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  34139. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  34140. 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;
  34141. }
  34142. }
  34143. declare module BABYLON {
  34144. /**
  34145. * Settings for finer control over video usage
  34146. */
  34147. interface VideoTextureSettings {
  34148. /**
  34149. * Applies `autoplay` to video, if specified
  34150. */
  34151. autoPlay?: boolean;
  34152. /**
  34153. * Applies `loop` to video, if specified
  34154. */
  34155. loop?: boolean;
  34156. /**
  34157. * Automatically updates internal texture from video at every frame in the render loop
  34158. */
  34159. autoUpdateTexture: boolean;
  34160. }
  34161. class VideoTexture extends Texture {
  34162. /**
  34163. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34164. */
  34165. readonly autoUpdateTexture: boolean;
  34166. /**
  34167. * The video instance used by the texture internally
  34168. */
  34169. readonly video: HTMLVideoElement;
  34170. private _generateMipMaps;
  34171. private _engine;
  34172. private _stillImageCaptured;
  34173. /**
  34174. * Creates a video texture.
  34175. * Sample : https://doc.babylonjs.com/how_to/video_texture
  34176. * @param {string | null} name optional name, will detect from video source, if not defined
  34177. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  34178. * @param {BABYLON.Scene} scene is obviously the current scene.
  34179. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34180. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  34181. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34182. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  34183. */
  34184. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34185. private _getName(src);
  34186. private _getVideo(src);
  34187. private _createInternalTexture;
  34188. private reset;
  34189. /**
  34190. * Internal method to initiate `update`.
  34191. */
  34192. _rebuild(): void;
  34193. /**
  34194. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34195. */
  34196. update(): void;
  34197. /**
  34198. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34199. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34200. */
  34201. updateTexture(isVisible: boolean): void;
  34202. protected _updateInternalTexture: (e?: Event | undefined) => void;
  34203. /**
  34204. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34205. * @param url New url.
  34206. */
  34207. updateURL(url: string): void;
  34208. dispose(): void;
  34209. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34210. minWidth: number;
  34211. maxWidth: number;
  34212. minHeight: number;
  34213. maxHeight: number;
  34214. deviceId: string;
  34215. }): void;
  34216. }
  34217. }
  34218. declare module BABYLON {
  34219. }
  34220. declare var DracoDecoderModule: any;
  34221. declare var WebAssembly: any;
  34222. declare module BABYLON {
  34223. /**
  34224. * Configuration for Draco compression
  34225. */
  34226. interface IDracoCompressionConfiguration {
  34227. /**
  34228. * Configuration for the decoder.
  34229. */
  34230. decoder?: {
  34231. /**
  34232. * The url to the WebAssembly module.
  34233. */
  34234. wasmUrl?: string;
  34235. /**
  34236. * The url to the WebAssembly binary.
  34237. */
  34238. wasmBinaryUrl?: string;
  34239. /**
  34240. * The url to the fallback JavaScript module.
  34241. */
  34242. fallbackUrl?: string;
  34243. };
  34244. }
  34245. /**
  34246. * Draco compression (https://google.github.io/draco/)
  34247. *
  34248. * This class wraps the Draco module.
  34249. *
  34250. * **Encoder**
  34251. *
  34252. * The encoder is not currently implemented.
  34253. *
  34254. * **Decoder**
  34255. *
  34256. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  34257. *
  34258. * To update the configuration, use the following code:
  34259. * ```javascript
  34260. * BABYLON.DracoCompression.Configuration = {
  34261. * decoder: {
  34262. * wasmUrl: "<url to the WebAssembly library>",
  34263. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  34264. * fallbackUrl: "<url to the fallback JavaScript library>",
  34265. * }
  34266. * };
  34267. * ```
  34268. *
  34269. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  34270. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  34271. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  34272. *
  34273. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  34274. * ```javascript
  34275. * var dracoCompression = new BABYLON.DracoCompression();
  34276. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  34277. * [BABYLON.VertexBuffer.PositionKind]: 0
  34278. * });
  34279. * ```
  34280. *
  34281. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  34282. */
  34283. class DracoCompression implements IDisposable {
  34284. private static _DecoderModulePromise;
  34285. /**
  34286. * The configuration. Defaults to the following urls:
  34287. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  34288. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  34289. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  34290. */
  34291. static Configuration: IDracoCompressionConfiguration;
  34292. /**
  34293. * Returns true if the decoder is available.
  34294. */
  34295. static readonly DecoderAvailable: boolean;
  34296. /**
  34297. * Constructor
  34298. */
  34299. constructor();
  34300. /**
  34301. * Stop all async operations and release resources.
  34302. */
  34303. dispose(): void;
  34304. /**
  34305. * Decode Draco compressed mesh data to vertex data.
  34306. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  34307. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  34308. * @returns A promise that resolves with the decoded vertex data
  34309. */
  34310. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  34311. [kind: string]: number;
  34312. }): Promise<VertexData>;
  34313. private static _GetDecoderModule();
  34314. private static _LoadScriptAsync(url);
  34315. private static _LoadFileAsync(url);
  34316. }
  34317. }
  34318. declare module BABYLON {
  34319. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34320. private _useDeltaForWorldStep;
  34321. world: any;
  34322. name: string;
  34323. private _physicsMaterials;
  34324. private _fixedTimeStep;
  34325. BJSCANNON: any;
  34326. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34327. setGravity(gravity: Vector3): void;
  34328. setTimeStep(timeStep: number): void;
  34329. getTimeStep(): number;
  34330. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34334. private _processChildMeshes(mainImpostor);
  34335. removePhysicsBody(impostor: PhysicsImpostor): void;
  34336. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34337. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34338. private _addMaterial(name, friction, restitution);
  34339. private _checkWithEpsilon(value);
  34340. private _createShape(impostor);
  34341. private _createHeightmap(object, pointDepth?);
  34342. private _minus90X;
  34343. private _plus90X;
  34344. private _tmpPosition;
  34345. private _tmpDeltaPosition;
  34346. private _tmpUnityRotation;
  34347. private _updatePhysicsBodyTransformation(impostor);
  34348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34350. isSupported(): boolean;
  34351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34352. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34354. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34355. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34356. getBodyMass(impostor: PhysicsImpostor): number;
  34357. getBodyFriction(impostor: PhysicsImpostor): number;
  34358. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34359. getBodyRestitution(impostor: PhysicsImpostor): number;
  34360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34361. sleepBody(impostor: PhysicsImpostor): void;
  34362. wakeUpBody(impostor: PhysicsImpostor): void;
  34363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34364. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34366. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34367. getRadius(impostor: PhysicsImpostor): number;
  34368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34369. dispose(): void;
  34370. private _extendNamespace();
  34371. }
  34372. }
  34373. declare module BABYLON {
  34374. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34375. world: any;
  34376. name: string;
  34377. BJSOIMO: any;
  34378. constructor(iterations?: number);
  34379. setGravity(gravity: Vector3): void;
  34380. setTimeStep(timeStep: number): void;
  34381. getTimeStep(): number;
  34382. private _tmpImpostorsArray;
  34383. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34384. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34385. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34386. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34387. private _tmpPositionVector;
  34388. removePhysicsBody(impostor: PhysicsImpostor): void;
  34389. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34390. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34391. isSupported(): boolean;
  34392. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34393. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34394. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34395. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34396. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34397. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34398. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34399. getBodyMass(impostor: PhysicsImpostor): number;
  34400. getBodyFriction(impostor: PhysicsImpostor): number;
  34401. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34402. getBodyRestitution(impostor: PhysicsImpostor): number;
  34403. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34404. sleepBody(impostor: PhysicsImpostor): void;
  34405. wakeUpBody(impostor: PhysicsImpostor): void;
  34406. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34407. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34408. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34409. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34410. getRadius(impostor: PhysicsImpostor): number;
  34411. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34412. dispose(): void;
  34413. }
  34414. }
  34415. declare module BABYLON {
  34416. /**
  34417. * Particle emitter emitting particles from the inside of a box.
  34418. * It emits the particles randomly between 2 given directions.
  34419. */
  34420. class BoxParticleEmitter implements IParticleEmitterType {
  34421. /**
  34422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34423. */
  34424. direction1: Vector3;
  34425. /**
  34426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34427. */
  34428. direction2: Vector3;
  34429. /**
  34430. * 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.
  34431. */
  34432. minEmitBox: Vector3;
  34433. /**
  34434. * 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.
  34435. */
  34436. maxEmitBox: Vector3;
  34437. /**
  34438. * Creates a new instance BoxParticleEmitter
  34439. */
  34440. constructor();
  34441. /**
  34442. * Called by the particle System when the direction is computed for the created particle.
  34443. * @param emitPower is the power of the particle (speed)
  34444. * @param worldMatrix is the world matrix of the particle system
  34445. * @param directionToUpdate is the direction vector to update with the result
  34446. * @param particle is the particle we are computed the direction for
  34447. */
  34448. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34449. /**
  34450. * Called by the particle System when the position is computed for the created particle.
  34451. * @param worldMatrix is the world matrix of the particle system
  34452. * @param positionToUpdate is the position vector to update with the result
  34453. * @param particle is the particle we are computed the position for
  34454. */
  34455. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34456. /**
  34457. * Clones the current emitter and returns a copy of it
  34458. * @returns the new emitter
  34459. */
  34460. clone(): BoxParticleEmitter;
  34461. /**
  34462. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34463. * @param effect defines the update shader
  34464. */
  34465. applyToShader(effect: Effect): void;
  34466. /**
  34467. * Returns a string to use to update the GPU particles update shader
  34468. * @returns a string containng the defines string
  34469. */
  34470. getEffectDefines(): string;
  34471. /**
  34472. * Returns the string "BoxEmitter"
  34473. * @returns a string containing the class name
  34474. */
  34475. getClassName(): string;
  34476. /**
  34477. * Serializes the particle system to a JSON object.
  34478. * @returns the JSON object
  34479. */
  34480. serialize(): any;
  34481. /**
  34482. * Parse properties from a JSON object
  34483. * @param serializationObject defines the JSON object
  34484. */
  34485. parse(serializationObject: any): void;
  34486. }
  34487. }
  34488. declare module BABYLON {
  34489. /**
  34490. * Particle emitter emitting particles from the inside of a cone.
  34491. * It emits the particles alongside the cone volume from the base to the particle.
  34492. * The emission direction might be randomized.
  34493. */
  34494. class ConeParticleEmitter implements IParticleEmitterType {
  34495. /**
  34496. * The radius of the emission cone.
  34497. */
  34498. angle: number;
  34499. /**
  34500. * The cone base angle.
  34501. */
  34502. directionRandomizer: number;
  34503. private _radius;
  34504. private _height;
  34505. /**
  34506. * Gets the radius of the emission cone.
  34507. */
  34508. /**
  34509. * Sets the radius of the emission cone.
  34510. */
  34511. radius: number;
  34512. /**
  34513. * Creates a new instance ConeParticleEmitter
  34514. * @param radius the radius of the emission cone (1 by default)
  34515. * @param angles the cone base angle (PI by default)
  34516. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34517. */
  34518. constructor(radius?: number,
  34519. /**
  34520. * The radius of the emission cone.
  34521. */
  34522. angle?: number,
  34523. /**
  34524. * The cone base angle.
  34525. */
  34526. directionRandomizer?: number);
  34527. /**
  34528. * Called by the particle System when the direction is computed for the created particle.
  34529. * @param emitPower is the power of the particle (speed)
  34530. * @param worldMatrix is the world matrix of the particle system
  34531. * @param directionToUpdate is the direction vector to update with the result
  34532. * @param particle is the particle we are computed the direction for
  34533. */
  34534. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34535. /**
  34536. * Called by the particle System when the position is computed for the created particle.
  34537. * @param worldMatrix is the world matrix of the particle system
  34538. * @param positionToUpdate is the position vector to update with the result
  34539. * @param particle is the particle we are computed the position for
  34540. */
  34541. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34542. /**
  34543. * Clones the current emitter and returns a copy of it
  34544. * @returns the new emitter
  34545. */
  34546. clone(): ConeParticleEmitter;
  34547. /**
  34548. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34549. * @param effect defines the update shader
  34550. */
  34551. applyToShader(effect: Effect): void;
  34552. /**
  34553. * Returns a string to use to update the GPU particles update shader
  34554. * @returns a string containng the defines string
  34555. */
  34556. getEffectDefines(): string;
  34557. /**
  34558. * Returns the string "BoxEmitter"
  34559. * @returns a string containing the class name
  34560. */
  34561. getClassName(): string;
  34562. /**
  34563. * Serializes the particle system to a JSON object.
  34564. * @returns the JSON object
  34565. */
  34566. serialize(): any;
  34567. /**
  34568. * Parse properties from a JSON object
  34569. * @param serializationObject defines the JSON object
  34570. */
  34571. parse(serializationObject: any): void;
  34572. }
  34573. }
  34574. declare module BABYLON {
  34575. /**
  34576. * Particle emitter represents a volume emitting particles.
  34577. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  34578. */
  34579. interface IParticleEmitterType {
  34580. /**
  34581. * Called by the particle System when the direction is computed for the created particle.
  34582. * @param emitPower is the power of the particle (speed)
  34583. * @param worldMatrix is the world matrix of the particle system
  34584. * @param directionToUpdate is the direction vector to update with the result
  34585. * @param particle is the particle we are computed the direction for
  34586. */
  34587. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34588. /**
  34589. * Called by the particle System when the position is computed for the created particle.
  34590. * @param worldMatrix is the world matrix of the particle system
  34591. * @param positionToUpdate is the position vector to update with the result
  34592. * @param particle is the particle we are computed the position for
  34593. */
  34594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34595. /**
  34596. * Clones the current emitter and returns a copy of it
  34597. * @returns the new emitter
  34598. */
  34599. clone(): IParticleEmitterType;
  34600. /**
  34601. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34602. * @param effect defines the update shader
  34603. */
  34604. applyToShader(effect: Effect): void;
  34605. /**
  34606. * Returns a string to use to update the GPU particles update shader
  34607. * @returns the effect defines string
  34608. */
  34609. getEffectDefines(): string;
  34610. /**
  34611. * Returns a string representing the class name
  34612. * @returns a string containing the class name
  34613. */
  34614. getClassName(): string;
  34615. /**
  34616. * Serializes the particle system to a JSON object.
  34617. * @returns the JSON object
  34618. */
  34619. serialize(): any;
  34620. /**
  34621. * Parse properties from a JSON object
  34622. * @param serializationObject defines the JSON object
  34623. */
  34624. parse(serializationObject: any): void;
  34625. }
  34626. }
  34627. declare module BABYLON {
  34628. /**
  34629. * Particle emitter emitting particles from the inside of a sphere.
  34630. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34631. */
  34632. class SphereParticleEmitter implements IParticleEmitterType {
  34633. /**
  34634. * The radius of the emission sphere.
  34635. */
  34636. radius: number;
  34637. /**
  34638. * How much to randomize the particle direction [0-1].
  34639. */
  34640. directionRandomizer: number;
  34641. /**
  34642. * Creates a new instance SphereParticleEmitter
  34643. * @param radius the radius of the emission sphere (1 by default)
  34644. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34645. */
  34646. constructor(
  34647. /**
  34648. * The radius of the emission sphere.
  34649. */
  34650. radius?: number,
  34651. /**
  34652. * How much to randomize the particle direction [0-1].
  34653. */
  34654. directionRandomizer?: number);
  34655. /**
  34656. * Called by the particle System when the direction is computed for the created particle.
  34657. * @param emitPower is the power of the particle (speed)
  34658. * @param worldMatrix is the world matrix of the particle system
  34659. * @param directionToUpdate is the direction vector to update with the result
  34660. * @param particle is the particle we are computed the direction for
  34661. */
  34662. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34663. /**
  34664. * Called by the particle System when the position is computed for the created particle.
  34665. * @param worldMatrix is the world matrix of the particle system
  34666. * @param positionToUpdate is the position vector to update with the result
  34667. * @param particle is the particle we are computed the position for
  34668. */
  34669. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34670. /**
  34671. * Clones the current emitter and returns a copy of it
  34672. * @returns the new emitter
  34673. */
  34674. clone(): SphereParticleEmitter;
  34675. /**
  34676. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34677. * @param effect defines the update shader
  34678. */
  34679. applyToShader(effect: Effect): void;
  34680. /**
  34681. * Returns a string to use to update the GPU particles update shader
  34682. * @returns a string containng the defines string
  34683. */
  34684. getEffectDefines(): string;
  34685. /**
  34686. * Returns the string "SphereParticleEmitter"
  34687. * @returns a string containing the class name
  34688. */
  34689. getClassName(): string;
  34690. /**
  34691. * Serializes the particle system to a JSON object.
  34692. * @returns the JSON object
  34693. */
  34694. serialize(): any;
  34695. /**
  34696. * Parse properties from a JSON object
  34697. * @param serializationObject defines the JSON object
  34698. */
  34699. parse(serializationObject: any): void;
  34700. }
  34701. /**
  34702. * Particle emitter emitting particles from the inside of a sphere.
  34703. * It emits the particles randomly between two vectors.
  34704. */
  34705. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34706. /**
  34707. * The min limit of the emission direction.
  34708. */
  34709. direction1: Vector3;
  34710. /**
  34711. * The max limit of the emission direction.
  34712. */
  34713. direction2: Vector3;
  34714. /**
  34715. * Creates a new instance SphereDirectedParticleEmitter
  34716. * @param radius the radius of the emission sphere (1 by default)
  34717. * @param direction1 the min limit of the emission direction (up vector by default)
  34718. * @param direction2 the max limit of the emission direction (up vector by default)
  34719. */
  34720. constructor(radius?: number,
  34721. /**
  34722. * The min limit of the emission direction.
  34723. */
  34724. direction1?: Vector3,
  34725. /**
  34726. * The max limit of the emission direction.
  34727. */
  34728. direction2?: Vector3);
  34729. /**
  34730. * Called by the particle System when the direction is computed for the created particle.
  34731. * @param emitPower is the power of the particle (speed)
  34732. * @param worldMatrix is the world matrix of the particle system
  34733. * @param directionToUpdate is the direction vector to update with the result
  34734. * @param particle is the particle we are computed the direction for
  34735. */
  34736. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34737. /**
  34738. * Clones the current emitter and returns a copy of it
  34739. * @returns the new emitter
  34740. */
  34741. clone(): SphereDirectedParticleEmitter;
  34742. /**
  34743. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34744. * @param effect defines the update shader
  34745. */
  34746. applyToShader(effect: Effect): void;
  34747. /**
  34748. * Returns a string to use to update the GPU particles update shader
  34749. * @returns a string containng the defines string
  34750. */
  34751. getEffectDefines(): string;
  34752. /**
  34753. * Returns the string "SphereDirectedParticleEmitter"
  34754. * @returns a string containing the class name
  34755. */
  34756. getClassName(): string;
  34757. /**
  34758. * Serializes the particle system to a JSON object.
  34759. * @returns the JSON object
  34760. */
  34761. serialize(): any;
  34762. /**
  34763. * Parse properties from a JSON object
  34764. * @param serializationObject defines the JSON object
  34765. */
  34766. parse(serializationObject: any): void;
  34767. }
  34768. }
  34769. declare module BABYLON {
  34770. /**
  34771. * This represents a set of one or more post processes in Babylon.
  34772. * A post process can be used to apply a shader to a texture after it is rendered.
  34773. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34774. */
  34775. class PostProcessRenderEffect {
  34776. private _postProcesses;
  34777. private _getPostProcesses;
  34778. private _singleInstance;
  34779. private _cameras;
  34780. private _indicesForCamera;
  34781. /**
  34782. * Name of the effect
  34783. */
  34784. _name: string;
  34785. /**
  34786. * Instantiates a post process render effect.
  34787. * A post process can be used to apply a shader to a texture after it is rendered.
  34788. * @param engine The engine the effect is tied to
  34789. * @param name The name of the effect
  34790. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34791. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34792. */
  34793. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34794. /**
  34795. * Checks if all the post processes in the effect are supported.
  34796. */
  34797. readonly isSupported: boolean;
  34798. /**
  34799. * Updates the current state of the effect
  34800. */
  34801. _update(): void;
  34802. /**
  34803. * Attaches the effect on cameras
  34804. * @param cameras The camera to attach to.
  34805. */
  34806. _attachCameras(cameras: Camera): void;
  34807. /**
  34808. * Attaches the effect on cameras
  34809. * @param cameras The camera to attach to.
  34810. */
  34811. _attachCameras(cameras: Camera[]): void;
  34812. /**
  34813. * Detatches the effect on cameras
  34814. * @param cameras The camera to detatch from.
  34815. */
  34816. _detachCameras(cameras: Camera): void;
  34817. /**
  34818. * Detatches the effect on cameras
  34819. * @param cameras The camera to detatch from.
  34820. */
  34821. _detachCameras(cameras: Camera[]): void;
  34822. /**
  34823. * Enables the effect on given cameras
  34824. * @param cameras The camera to enable.
  34825. */
  34826. _enable(cameras: Camera): void;
  34827. /**
  34828. * Enables the effect on given cameras
  34829. * @param cameras The camera to enable.
  34830. */
  34831. _enable(cameras: Nullable<Camera[]>): void;
  34832. /**
  34833. * Disables the effect on the given cameras
  34834. * @param cameras The camera to disable.
  34835. */
  34836. _disable(cameras: Camera): void;
  34837. /**
  34838. * Disables the effect on the given cameras
  34839. * @param cameras The camera to disable.
  34840. */
  34841. _disable(cameras: Nullable<Camera[]>): void;
  34842. /**
  34843. * Gets a list of the post processes contained in the effect.
  34844. * @param camera The camera to get the post processes on.
  34845. * @returns The list of the post processes in the effect.
  34846. */
  34847. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34848. }
  34849. }
  34850. declare module BABYLON {
  34851. class PostProcessRenderPipeline {
  34852. private engine;
  34853. private _renderEffects;
  34854. private _renderEffectsForIsolatedPass;
  34855. protected _cameras: Camera[];
  34856. _name: string;
  34857. constructor(engine: Engine, name: string);
  34858. getClassName(): string;
  34859. readonly isSupported: boolean;
  34860. addEffect(renderEffect: PostProcessRenderEffect): void;
  34861. _rebuild(): void;
  34862. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34863. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34864. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34865. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34866. _attachCameras(cameras: Camera, unique: boolean): void;
  34867. _attachCameras(cameras: Camera[], unique: boolean): void;
  34868. _detachCameras(cameras: Camera): void;
  34869. _detachCameras(cameras: Nullable<Camera[]>): void;
  34870. _update(): void;
  34871. _reset(): void;
  34872. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34873. dispose(): void;
  34874. }
  34875. }
  34876. declare module BABYLON {
  34877. class PostProcessRenderPipelineManager {
  34878. private _renderPipelines;
  34879. constructor();
  34880. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34881. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34882. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34883. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34884. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34885. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34886. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34887. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34888. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34889. update(): void;
  34890. _rebuild(): void;
  34891. dispose(): void;
  34892. }
  34893. }
  34894. declare module BABYLON {
  34895. /**
  34896. * Helper class dealing with the extraction of spherical polynomial dataArray
  34897. * from a cube map.
  34898. */
  34899. class CubeMapToSphericalPolynomialTools {
  34900. private static FileFaces;
  34901. /**
  34902. * Converts a texture to the according Spherical Polynomial data.
  34903. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34904. *
  34905. * @param texture The texture to extract the information from.
  34906. * @return The Spherical Polynomial data.
  34907. */
  34908. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34909. /**
  34910. * Converts a cubemap to the according Spherical Polynomial data.
  34911. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34912. *
  34913. * @param cubeInfo The Cube map to extract the information from.
  34914. * @return The Spherical Polynomial data.
  34915. */
  34916. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34917. }
  34918. }
  34919. declare module BABYLON {
  34920. /**
  34921. * Header information of HDR texture files.
  34922. */
  34923. interface HDRInfo {
  34924. /**
  34925. * The height of the texture in pixels.
  34926. */
  34927. height: number;
  34928. /**
  34929. * The width of the texture in pixels.
  34930. */
  34931. width: number;
  34932. /**
  34933. * The index of the beginning of the data in the binary file.
  34934. */
  34935. dataPosition: number;
  34936. }
  34937. /**
  34938. * This groups tools to convert HDR texture to native colors array.
  34939. */
  34940. class HDRTools {
  34941. private static Ldexp(mantissa, exponent);
  34942. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34943. private static readStringLine(uint8array, startIndex);
  34944. /**
  34945. * Reads header information from an RGBE texture stored in a native array.
  34946. * More information on this format are available here:
  34947. * https://en.wikipedia.org/wiki/RGBE_image_format
  34948. *
  34949. * @param uint8array The binary file stored in native array.
  34950. * @return The header information.
  34951. */
  34952. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34953. /**
  34954. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34955. * This RGBE texture needs to store the information as a panorama.
  34956. *
  34957. * More information on this format are available here:
  34958. * https://en.wikipedia.org/wiki/RGBE_image_format
  34959. *
  34960. * @param buffer The binary file stored in an array buffer.
  34961. * @param size The expected size of the extracted cubemap.
  34962. * @return The Cube Map information.
  34963. */
  34964. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34965. /**
  34966. * Returns the pixels data extracted from an RGBE texture.
  34967. * This pixels will be stored left to right up to down in the R G B order in one array.
  34968. *
  34969. * More information on this format are available here:
  34970. * https://en.wikipedia.org/wiki/RGBE_image_format
  34971. *
  34972. * @param uint8array The binary file stored in an array buffer.
  34973. * @param hdrInfo The header information of the file.
  34974. * @return The pixels data in RGB right to left up to down order.
  34975. */
  34976. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34977. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34978. }
  34979. }
  34980. declare module BABYLON {
  34981. /**
  34982. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34983. */
  34984. interface CubeMapInfo {
  34985. /**
  34986. * The pixel array for the front face.
  34987. * This is stored in format, left to right, up to down format.
  34988. */
  34989. front: Nullable<ArrayBufferView>;
  34990. /**
  34991. * The pixel array for the back face.
  34992. * This is stored in format, left to right, up to down format.
  34993. */
  34994. back: Nullable<ArrayBufferView>;
  34995. /**
  34996. * The pixel array for the left face.
  34997. * This is stored in format, left to right, up to down format.
  34998. */
  34999. left: Nullable<ArrayBufferView>;
  35000. /**
  35001. * The pixel array for the right face.
  35002. * This is stored in format, left to right, up to down format.
  35003. */
  35004. right: Nullable<ArrayBufferView>;
  35005. /**
  35006. * The pixel array for the up face.
  35007. * This is stored in format, left to right, up to down format.
  35008. */
  35009. up: Nullable<ArrayBufferView>;
  35010. /**
  35011. * The pixel array for the down face.
  35012. * This is stored in format, left to right, up to down format.
  35013. */
  35014. down: Nullable<ArrayBufferView>;
  35015. /**
  35016. * The size of the cubemap stored.
  35017. *
  35018. * Each faces will be size * size pixels.
  35019. */
  35020. size: number;
  35021. /**
  35022. * The format of the texture.
  35023. *
  35024. * RGBA, RGB.
  35025. */
  35026. format: number;
  35027. /**
  35028. * The type of the texture data.
  35029. *
  35030. * UNSIGNED_INT, FLOAT.
  35031. */
  35032. type: number;
  35033. /**
  35034. * Specifies whether the texture is in gamma space.
  35035. */
  35036. gammaSpace: boolean;
  35037. }
  35038. /**
  35039. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  35040. */
  35041. class PanoramaToCubeMapTools {
  35042. private static FACE_FRONT;
  35043. private static FACE_BACK;
  35044. private static FACE_RIGHT;
  35045. private static FACE_LEFT;
  35046. private static FACE_DOWN;
  35047. private static FACE_UP;
  35048. /**
  35049. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  35050. *
  35051. * @param float32Array The source data.
  35052. * @param inputWidth The width of the input panorama.
  35053. * @param inputhHeight The height of the input panorama.
  35054. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  35055. * @return The cubemap data
  35056. */
  35057. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  35058. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  35059. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  35060. }
  35061. }
  35062. declare module BABYLON {
  35063. class CustomProceduralTexture extends ProceduralTexture {
  35064. private _animate;
  35065. private _time;
  35066. private _config;
  35067. private _texturePath;
  35068. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  35069. private loadJson(jsonUrl);
  35070. isReady(): boolean;
  35071. render(useCameraPostProcess?: boolean): void;
  35072. updateTextures(): void;
  35073. updateShaderUniforms(): void;
  35074. animate: boolean;
  35075. }
  35076. }
  35077. declare module BABYLON {
  35078. class ProceduralTexture extends Texture {
  35079. isCube: boolean;
  35080. private _size;
  35081. _generateMipMaps: boolean;
  35082. isEnabled: boolean;
  35083. private _currentRefreshId;
  35084. private _refreshRate;
  35085. onGenerated: () => void;
  35086. private _vertexBuffers;
  35087. private _indexBuffer;
  35088. private _effect;
  35089. private _uniforms;
  35090. private _samplers;
  35091. private _fragment;
  35092. _textures: {
  35093. [key: string]: Texture;
  35094. };
  35095. private _floats;
  35096. private _floatsArrays;
  35097. private _colors3;
  35098. private _colors4;
  35099. private _vectors2;
  35100. private _vectors3;
  35101. private _matrices;
  35102. private _fallbackTexture;
  35103. private _fallbackTextureUsed;
  35104. private _engine;
  35105. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  35106. private _createIndexBuffer();
  35107. _rebuild(): void;
  35108. reset(): void;
  35109. isReady(): boolean;
  35110. resetRefreshCounter(): void;
  35111. setFragment(fragment: any): void;
  35112. refreshRate: number;
  35113. _shouldRender(): boolean;
  35114. getRenderSize(): number;
  35115. resize(size: number, generateMipMaps: boolean): void;
  35116. private _checkUniform(uniformName);
  35117. setTexture(name: string, texture: Texture): ProceduralTexture;
  35118. setFloat(name: string, value: number): ProceduralTexture;
  35119. setFloats(name: string, value: number[]): ProceduralTexture;
  35120. setColor3(name: string, value: Color3): ProceduralTexture;
  35121. setColor4(name: string, value: Color4): ProceduralTexture;
  35122. setVector2(name: string, value: Vector2): ProceduralTexture;
  35123. setVector3(name: string, value: Vector3): ProceduralTexture;
  35124. setMatrix(name: string, value: Matrix): ProceduralTexture;
  35125. render(useCameraPostProcess?: boolean): void;
  35126. clone(): ProceduralTexture;
  35127. dispose(): void;
  35128. }
  35129. }
  35130. declare module BABYLON {
  35131. /**
  35132. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  35133. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  35134. */
  35135. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35136. private _scene;
  35137. private _originalCameras;
  35138. /**
  35139. * ID of the sharpen post process,
  35140. */
  35141. private readonly SharpenPostProcessId;
  35142. /**
  35143. * ID of the image processing post process;
  35144. */
  35145. readonly ImageProcessingPostProcessId: string;
  35146. /**
  35147. * ID of the Fast Approximate Anti-Aliasing post process;
  35148. */
  35149. readonly FxaaPostProcessId: string;
  35150. /**
  35151. * ID of the chromatic aberration post process,
  35152. */
  35153. private readonly ChromaticAberrationPostProcessId;
  35154. /**
  35155. * ID of the grain post process
  35156. */
  35157. private readonly GrainPostProcessId;
  35158. /**
  35159. * Sharpen post process which will apply a sharpen convolution to enhance edges
  35160. */
  35161. sharpen: SharpenPostProcess;
  35162. private _sharpenEffect;
  35163. private bloom;
  35164. /**
  35165. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  35166. */
  35167. depthOfField: DepthOfFieldEffect;
  35168. /**
  35169. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  35170. */
  35171. fxaa: FxaaPostProcess;
  35172. /**
  35173. * Image post processing pass used to perform operations such as tone mapping or color grading.
  35174. */
  35175. imageProcessing: ImageProcessingPostProcess;
  35176. /**
  35177. * Chromatic aberration post process which will shift rgb colors in the image
  35178. */
  35179. chromaticAberration: ChromaticAberrationPostProcess;
  35180. private _chromaticAberrationEffect;
  35181. /**
  35182. * Grain post process which add noise to the image
  35183. */
  35184. grain: GrainPostProcess;
  35185. private _grainEffect;
  35186. /**
  35187. * Glow post process which adds a glow to emmisive areas of the image
  35188. */
  35189. private _glowLayer;
  35190. /**
  35191. * Animations which can be used to tweak settings over a period of time
  35192. */
  35193. animations: Animation[];
  35194. private _imageProcessingConfigurationObserver;
  35195. private _sharpenEnabled;
  35196. private _bloomEnabled;
  35197. private _depthOfFieldEnabled;
  35198. private _depthOfFieldBlurLevel;
  35199. private _fxaaEnabled;
  35200. private _imageProcessingEnabled;
  35201. private _defaultPipelineTextureType;
  35202. private _bloomScale;
  35203. private _chromaticAberrationEnabled;
  35204. private _grainEnabled;
  35205. private _buildAllowed;
  35206. /**
  35207. * Enable or disable the sharpen process from the pipeline
  35208. */
  35209. sharpenEnabled: boolean;
  35210. private _resizeObserver;
  35211. private _hardwareScaleLevel;
  35212. private _bloomKernel;
  35213. /**
  35214. * Specifies the size of the bloom blur kernel, relative to the final output size
  35215. */
  35216. bloomKernel: number;
  35217. /**
  35218. * Specifies the weight of the bloom in the final rendering
  35219. */
  35220. private _bloomWeight;
  35221. /**
  35222. * Specifies the luma threshold for the area that will be blurred by the bloom
  35223. */
  35224. private _bloomThreshold;
  35225. private _hdr;
  35226. /**
  35227. * The strength of the bloom.
  35228. */
  35229. bloomWeight: number;
  35230. /**
  35231. * The strength of the bloom.
  35232. */
  35233. bloomThreshold: number;
  35234. /**
  35235. * The scale of the bloom, lower value will provide better performance.
  35236. */
  35237. bloomScale: number;
  35238. /**
  35239. * Enable or disable the bloom from the pipeline
  35240. */
  35241. bloomEnabled: boolean;
  35242. private _rebuildBloom();
  35243. /**
  35244. * If the depth of field is enabled.
  35245. */
  35246. depthOfFieldEnabled: boolean;
  35247. /**
  35248. * Blur level of the depth of field effect. (Higher blur will effect performance)
  35249. */
  35250. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  35251. /**
  35252. * If the anti aliasing is enabled.
  35253. */
  35254. fxaaEnabled: boolean;
  35255. private _samples;
  35256. /**
  35257. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  35258. */
  35259. samples: number;
  35260. /**
  35261. * If image processing is enabled.
  35262. */
  35263. imageProcessingEnabled: boolean;
  35264. /**
  35265. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  35266. */
  35267. glowLayerEnabled: boolean;
  35268. /**
  35269. * Enable or disable the chromaticAberration process from the pipeline
  35270. */
  35271. chromaticAberrationEnabled: boolean;
  35272. /**
  35273. * Enable or disable the grain process from the pipeline
  35274. */
  35275. grainEnabled: boolean;
  35276. /**
  35277. * @constructor
  35278. * @param {string} name - The rendering pipeline name (default: "")
  35279. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  35280. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  35281. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  35282. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  35283. */
  35284. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  35285. /**
  35286. * Force the compilation of the entire pipeline.
  35287. */
  35288. prepare(): void;
  35289. private _hasCleared;
  35290. private _prevPostProcess;
  35291. private _prevPrevPostProcess;
  35292. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  35293. private _buildPipeline();
  35294. private _disposePostProcesses(disposeNonRecreated?);
  35295. /**
  35296. * Dispose of the pipeline and stop all post processes
  35297. */
  35298. dispose(): void;
  35299. /**
  35300. * Serialize the rendering pipeline (Used when exporting)
  35301. * @returns the serialized object
  35302. */
  35303. serialize(): any;
  35304. /**
  35305. * Parse the serialized pipeline
  35306. * @param source Source pipeline.
  35307. * @param scene The scene to load the pipeline to.
  35308. * @param rootUrl The URL of the serialized pipeline.
  35309. * @returns An instantiated pipeline from the serialized object.
  35310. */
  35311. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  35312. }
  35313. }
  35314. declare module BABYLON {
  35315. class LensRenderingPipeline extends PostProcessRenderPipeline {
  35316. /**
  35317. * The chromatic aberration PostProcess id in the pipeline
  35318. */
  35319. LensChromaticAberrationEffect: string;
  35320. /**
  35321. * The highlights enhancing PostProcess id in the pipeline
  35322. */
  35323. HighlightsEnhancingEffect: string;
  35324. /**
  35325. * The depth-of-field PostProcess id in the pipeline
  35326. */
  35327. LensDepthOfFieldEffect: string;
  35328. private _scene;
  35329. private _depthTexture;
  35330. private _grainTexture;
  35331. private _chromaticAberrationPostProcess;
  35332. private _highlightsPostProcess;
  35333. private _depthOfFieldPostProcess;
  35334. private _edgeBlur;
  35335. private _grainAmount;
  35336. private _chromaticAberration;
  35337. private _distortion;
  35338. private _highlightsGain;
  35339. private _highlightsThreshold;
  35340. private _dofDistance;
  35341. private _dofAperture;
  35342. private _dofDarken;
  35343. private _dofPentagon;
  35344. private _blurNoise;
  35345. /**
  35346. * @constructor
  35347. *
  35348. * Effect parameters are as follow:
  35349. * {
  35350. * chromatic_aberration: number; // from 0 to x (1 for realism)
  35351. * edge_blur: number; // from 0 to x (1 for realism)
  35352. * distortion: number; // from 0 to x (1 for realism)
  35353. * grain_amount: number; // from 0 to 1
  35354. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  35355. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  35356. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  35357. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  35358. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  35359. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  35360. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  35361. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  35362. * }
  35363. * Note: if an effect parameter is unset, effect is disabled
  35364. *
  35365. * @param {string} name - The rendering pipeline name
  35366. * @param {object} parameters - An object containing all parameters (see above)
  35367. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35368. * @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)
  35369. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35370. */
  35371. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  35372. setEdgeBlur(amount: number): void;
  35373. disableEdgeBlur(): void;
  35374. setGrainAmount(amount: number): void;
  35375. disableGrain(): void;
  35376. setChromaticAberration(amount: number): void;
  35377. disableChromaticAberration(): void;
  35378. setEdgeDistortion(amount: number): void;
  35379. disableEdgeDistortion(): void;
  35380. setFocusDistance(amount: number): void;
  35381. disableDepthOfField(): void;
  35382. setAperture(amount: number): void;
  35383. setDarkenOutOfFocus(amount: number): void;
  35384. enablePentagonBokeh(): void;
  35385. disablePentagonBokeh(): void;
  35386. enableNoiseBlur(): void;
  35387. disableNoiseBlur(): void;
  35388. setHighlightsGain(amount: number): void;
  35389. setHighlightsThreshold(amount: number): void;
  35390. disableHighlights(): void;
  35391. /**
  35392. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  35393. */
  35394. dispose(disableDepthRender?: boolean): void;
  35395. private _createChromaticAberrationPostProcess(ratio);
  35396. private _createHighlightsPostProcess(ratio);
  35397. private _createDepthOfFieldPostProcess(ratio);
  35398. private _createGrainTexture();
  35399. }
  35400. }
  35401. declare module BABYLON {
  35402. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35403. /**
  35404. * The PassPostProcess id in the pipeline that contains the original scene color
  35405. */
  35406. SSAOOriginalSceneColorEffect: string;
  35407. /**
  35408. * The SSAO PostProcess id in the pipeline
  35409. */
  35410. SSAORenderEffect: string;
  35411. /**
  35412. * The horizontal blur PostProcess id in the pipeline
  35413. */
  35414. SSAOBlurHRenderEffect: string;
  35415. /**
  35416. * The vertical blur PostProcess id in the pipeline
  35417. */
  35418. SSAOBlurVRenderEffect: string;
  35419. /**
  35420. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35421. */
  35422. SSAOCombineRenderEffect: string;
  35423. /**
  35424. * The output strength of the SSAO post-process. Default value is 1.0.
  35425. */
  35426. totalStrength: number;
  35427. /**
  35428. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35429. */
  35430. maxZ: number;
  35431. /**
  35432. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35433. */
  35434. minZAspect: number;
  35435. /**
  35436. * Number of samples used for the SSAO calculations. Default value is 8
  35437. */
  35438. private _samples;
  35439. /**
  35440. * Ratio object used for SSAO ratio and blur ratio
  35441. */
  35442. private _ratio;
  35443. /**
  35444. * Dynamically generated sphere sampler.
  35445. */
  35446. private _sampleSphere;
  35447. /**
  35448. * Blur filter offsets
  35449. */
  35450. private _samplerOffsets;
  35451. samples: number;
  35452. /**
  35453. * Are we using bilateral blur ?
  35454. */
  35455. private _expensiveBlur;
  35456. expensiveBlur: boolean;
  35457. /**
  35458. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35459. */
  35460. radius: number;
  35461. /**
  35462. * The base color of the SSAO post-process
  35463. * The final result is "base + ssao" between [0, 1]
  35464. */
  35465. base: number;
  35466. /**
  35467. * Support test.
  35468. */
  35469. static readonly IsSupported: boolean;
  35470. private _scene;
  35471. private _depthTexture;
  35472. private _normalTexture;
  35473. private _randomTexture;
  35474. private _originalColorPostProcess;
  35475. private _ssaoPostProcess;
  35476. private _blurHPostProcess;
  35477. private _blurVPostProcess;
  35478. private _ssaoCombinePostProcess;
  35479. private _firstUpdate;
  35480. /**
  35481. * @constructor
  35482. * @param {string} name - The rendering pipeline name
  35483. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35484. * @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 }
  35485. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35486. */
  35487. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35488. /**
  35489. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35490. */
  35491. dispose(disableGeometryBufferRenderer?: boolean): void;
  35492. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35493. _rebuild(): void;
  35494. private _generateHemisphere();
  35495. private _createSSAOPostProcess(ratio);
  35496. private _createSSAOCombinePostProcess(ratio);
  35497. private _createRandomTexture();
  35498. /**
  35499. * Serialize the rendering pipeline (Used when exporting)
  35500. * @returns the serialized object
  35501. */
  35502. serialize(): any;
  35503. /**
  35504. * Parse the serialized pipeline
  35505. * @param source Source pipeline.
  35506. * @param scene The scene to load the pipeline to.
  35507. * @param rootUrl The URL of the serialized pipeline.
  35508. * @returns An instantiated pipeline from the serialized object.
  35509. */
  35510. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35511. }
  35512. }
  35513. declare module BABYLON {
  35514. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35515. /**
  35516. * The PassPostProcess id in the pipeline that contains the original scene color
  35517. */
  35518. SSAOOriginalSceneColorEffect: string;
  35519. /**
  35520. * The SSAO PostProcess id in the pipeline
  35521. */
  35522. SSAORenderEffect: string;
  35523. /**
  35524. * The horizontal blur PostProcess id in the pipeline
  35525. */
  35526. SSAOBlurHRenderEffect: string;
  35527. /**
  35528. * The vertical blur PostProcess id in the pipeline
  35529. */
  35530. SSAOBlurVRenderEffect: string;
  35531. /**
  35532. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35533. */
  35534. SSAOCombineRenderEffect: string;
  35535. /**
  35536. * The output strength of the SSAO post-process. Default value is 1.0.
  35537. */
  35538. totalStrength: number;
  35539. /**
  35540. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35541. */
  35542. radius: number;
  35543. /**
  35544. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35545. * Must not be equal to fallOff and superior to fallOff.
  35546. * Default value is 0.975
  35547. */
  35548. area: number;
  35549. /**
  35550. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35551. * Must not be equal to area and inferior to area.
  35552. * Default value is 0.0
  35553. */
  35554. fallOff: number;
  35555. /**
  35556. * The base color of the SSAO post-process
  35557. * The final result is "base + ssao" between [0, 1]
  35558. */
  35559. base: number;
  35560. private _scene;
  35561. private _depthTexture;
  35562. private _randomTexture;
  35563. private _originalColorPostProcess;
  35564. private _ssaoPostProcess;
  35565. private _blurHPostProcess;
  35566. private _blurVPostProcess;
  35567. private _ssaoCombinePostProcess;
  35568. private _firstUpdate;
  35569. /**
  35570. * @constructor
  35571. * @param {string} name - The rendering pipeline name
  35572. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35573. * @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 }
  35574. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35575. */
  35576. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35577. /**
  35578. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35579. */
  35580. dispose(disableDepthRender?: boolean): void;
  35581. private _createBlurPostProcess(ratio);
  35582. _rebuild(): void;
  35583. private _createSSAOPostProcess(ratio);
  35584. private _createSSAOCombinePostProcess(ratio);
  35585. private _createRandomTexture();
  35586. }
  35587. }
  35588. declare module BABYLON {
  35589. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35590. /**
  35591. * Public members
  35592. */
  35593. originalPostProcess: Nullable<PostProcess>;
  35594. downSampleX4PostProcess: Nullable<PostProcess>;
  35595. brightPassPostProcess: Nullable<PostProcess>;
  35596. blurHPostProcesses: PostProcess[];
  35597. blurVPostProcesses: PostProcess[];
  35598. textureAdderPostProcess: Nullable<PostProcess>;
  35599. volumetricLightPostProcess: Nullable<PostProcess>;
  35600. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  35601. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  35602. volumetricLightMergePostProces: Nullable<PostProcess>;
  35603. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  35604. luminancePostProcess: Nullable<PostProcess>;
  35605. luminanceDownSamplePostProcesses: PostProcess[];
  35606. hdrPostProcess: Nullable<PostProcess>;
  35607. textureAdderFinalPostProcess: Nullable<PostProcess>;
  35608. lensFlareFinalPostProcess: Nullable<PostProcess>;
  35609. hdrFinalPostProcess: Nullable<PostProcess>;
  35610. lensFlarePostProcess: Nullable<PostProcess>;
  35611. lensFlareComposePostProcess: Nullable<PostProcess>;
  35612. motionBlurPostProcess: Nullable<PostProcess>;
  35613. depthOfFieldPostProcess: Nullable<PostProcess>;
  35614. brightThreshold: number;
  35615. blurWidth: number;
  35616. horizontalBlur: boolean;
  35617. exposure: number;
  35618. lensTexture: Nullable<Texture>;
  35619. volumetricLightCoefficient: number;
  35620. volumetricLightPower: number;
  35621. volumetricLightBlurScale: number;
  35622. sourceLight: Nullable<SpotLight | DirectionalLight>;
  35623. hdrMinimumLuminance: number;
  35624. hdrDecreaseRate: number;
  35625. hdrIncreaseRate: number;
  35626. lensColorTexture: Nullable<Texture>;
  35627. lensFlareStrength: number;
  35628. lensFlareGhostDispersal: number;
  35629. lensFlareHaloWidth: number;
  35630. lensFlareDistortionStrength: number;
  35631. lensStarTexture: Nullable<Texture>;
  35632. lensFlareDirtTexture: Nullable<Texture>;
  35633. depthOfFieldDistance: number;
  35634. depthOfFieldBlurWidth: number;
  35635. motionStrength: number;
  35636. animations: Animation[];
  35637. /**
  35638. * Private members
  35639. */
  35640. private _scene;
  35641. private _currentDepthOfFieldSource;
  35642. private _basePostProcess;
  35643. private _hdrCurrentLuminance;
  35644. private _floatTextureType;
  35645. private _ratio;
  35646. private _bloomEnabled;
  35647. private _depthOfFieldEnabled;
  35648. private _vlsEnabled;
  35649. private _lensFlareEnabled;
  35650. private _hdrEnabled;
  35651. private _motionBlurEnabled;
  35652. private _motionBlurSamples;
  35653. private _volumetricLightStepsCount;
  35654. BloomEnabled: boolean;
  35655. DepthOfFieldEnabled: boolean;
  35656. LensFlareEnabled: boolean;
  35657. HDREnabled: boolean;
  35658. VLSEnabled: boolean;
  35659. MotionBlurEnabled: boolean;
  35660. volumetricLightStepsCount: number;
  35661. motionBlurSamples: number;
  35662. /**
  35663. * @constructor
  35664. * @param {string} name - The rendering pipeline name
  35665. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35666. * @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)
  35667. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35668. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35669. */
  35670. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35671. private _buildPipeline();
  35672. private _createDownSampleX4PostProcess(scene, ratio);
  35673. private _createBrightPassPostProcess(scene, ratio);
  35674. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35675. private _createTextureAdderPostProcess(scene, ratio);
  35676. private _createVolumetricLightPostProcess(scene, ratio);
  35677. private _createLuminancePostProcesses(scene, textureType);
  35678. private _createHdrPostProcess(scene, ratio);
  35679. private _createLensFlarePostProcess(scene, ratio);
  35680. private _createDepthOfFieldPostProcess(scene, ratio);
  35681. private _createMotionBlurPostProcess(scene, ratio);
  35682. private _getDepthTexture();
  35683. private _disposePostProcesses();
  35684. /**
  35685. * Dispose of the pipeline and stop all post processes
  35686. */
  35687. dispose(): void;
  35688. /**
  35689. * Serialize the rendering pipeline (Used when exporting)
  35690. * @returns the serialized object
  35691. */
  35692. serialize(): any;
  35693. /**
  35694. * Parse the serialized pipeline
  35695. * @param source Source pipeline.
  35696. * @param scene The scene to load the pipeline to.
  35697. * @param rootUrl The URL of the serialized pipeline.
  35698. * @returns An instantiated pipeline from the serialized object.
  35699. */
  35700. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35701. static LuminanceSteps: number;
  35702. }
  35703. }