babylon.d.ts 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * 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.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isReady;
  377. /** @hidden */
  378. _currentRenderId: number;
  379. private _parentRenderId;
  380. protected _childRenderId: number;
  381. /** @hidden */
  382. _waitingParentId: Nullable<string>;
  383. /** @hidden */
  384. _scene: Scene;
  385. /** @hidden */
  386. _cache: any;
  387. private _parentNode;
  388. private _children;
  389. /**
  390. * Gets a boolean indicating if the node has been disposed
  391. * @returns true if the node was disposed
  392. */
  393. isDisposed(): boolean;
  394. /**
  395. * Gets or sets the parent of the node
  396. */
  397. parent: Nullable<Node>;
  398. private _animationPropertiesOverride;
  399. /**
  400. * Gets or sets the animation properties override
  401. */
  402. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  403. /**
  404. * Gets a string idenfifying the name of the class
  405. * @returns "Node" string
  406. */
  407. getClassName(): string;
  408. /**
  409. * An event triggered when the mesh is disposed
  410. */
  411. onDisposeObservable: Observable<Node>;
  412. private _onDisposeObserver;
  413. /**
  414. * Sets a callback that will be raised when the node will be disposed
  415. */
  416. onDispose: () => void;
  417. /**
  418. * Creates a new Node
  419. * @param {string} name - the name and id to be given to this node
  420. * @param {BABYLON.Scene} the scene this node will be added to
  421. */
  422. constructor(name: string, scene?: Nullable<Scene>);
  423. /**
  424. * Gets the scene of the node
  425. * @returns a {BABYLON.Scene}
  426. */
  427. getScene(): Scene;
  428. /**
  429. * Gets the engine of the node
  430. * @returns a {BABYLON.Engine}
  431. */
  432. getEngine(): Engine;
  433. private _behaviors;
  434. /**
  435. * Attach a behavior to the node
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. * @param behavior defines the behavior to attach
  438. * @returns the current Node
  439. */
  440. addBehavior(behavior: Behavior<Node>): Node;
  441. /**
  442. * Remove an attached behavior
  443. * @see http://doc.babylonjs.com/features/behaviour
  444. * @param behavior defines the behavior to attach
  445. * @returns the current Node
  446. */
  447. removeBehavior(behavior: Behavior<Node>): Node;
  448. /**
  449. * Gets the list of attached behaviors
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. */
  452. readonly behaviors: Behavior<Node>[];
  453. /**
  454. * Gets an attached behavior by name
  455. * @param name defines the name of the behavior to look for
  456. * @see http://doc.babylonjs.com/features/behaviour
  457. * @returns null if behavior was not found else the requested behavior
  458. */
  459. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  460. /**
  461. * Returns the world matrix of the node
  462. * @returns a matrix containing the node's world matrix
  463. */
  464. getWorldMatrix(): Matrix;
  465. /** @hidden */
  466. _getWorldMatrixDeterminant(): number;
  467. /** @hidden */
  468. _initCache(): void;
  469. /** @hidden */
  470. updateCache(force?: boolean): void;
  471. /** @hidden */
  472. _updateCache(ignoreParentClass?: boolean): void;
  473. /** @hidden */
  474. _isSynchronized(): boolean;
  475. /** @hidden */
  476. _markSyncedWithParent(): void;
  477. /** @hidden */
  478. isSynchronizedWithParent(): boolean;
  479. /** @hidden */
  480. isSynchronized(updateCache?: boolean): boolean;
  481. /** @hidden */
  482. hasNewParent(update?: boolean): boolean;
  483. /**
  484. * Is this node ready to be used/rendered
  485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  486. * @return true if the node is ready
  487. */
  488. isReady(completeCheck?: boolean): boolean;
  489. /**
  490. * Is this node enabled?
  491. * 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
  492. * @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
  493. * @return whether this node (and its parent) is enabled
  494. */
  495. isEnabled(checkAncestors?: boolean): boolean;
  496. /**
  497. * Set the enabled state of this node
  498. * @param value defines the new enabled state
  499. */
  500. setEnabled(value: boolean): void;
  501. /**
  502. * Is this node a descendant of the given node?
  503. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  504. * @param ancestor defines the parent node to inspect
  505. * @returns a boolean indicating if this node is a descendant of the given node
  506. */
  507. isDescendantOf(ancestor: Node): boolean;
  508. /** @hidden */
  509. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  510. /**
  511. * Will return all nodes that have this node as ascendant
  512. * @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
  513. * @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
  514. * @return all children nodes of all types
  515. */
  516. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  517. /**
  518. * Get all child-meshes of this node
  519. * @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
  520. * @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
  521. * @returns an array of {BABYLON.AbstractMesh}
  522. */
  523. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  524. /**
  525. * Get all child-transformNodes of this node
  526. * @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
  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.TransformNode}
  529. */
  530. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  531. /**
  532. * Get all direct children of this node
  533. * @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
  534. * @returns an array of {BABYLON.Node}
  535. */
  536. getChildren(predicate?: (node: Node) => boolean): Node[];
  537. /** @hidden */
  538. _setReady(state: boolean): void;
  539. /**
  540. * Get an animation by name
  541. * @param name defines the name of the animation to look for
  542. * @returns null if not found else the requested animation
  543. */
  544. getAnimationByName(name: string): Nullable<Animation>;
  545. /**
  546. * Creates an animation range for this node
  547. * @param name defines the name of the range
  548. * @param from defines the starting key
  549. * @param to defines the end key
  550. */
  551. createAnimationRange(name: string, from: number, to: number): void;
  552. /**
  553. * Delete a specific animation range
  554. * @param name defines the name of the range to delete
  555. * @param deleteFrames defines if animation frames from the range must be deleted as well
  556. */
  557. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  558. /**
  559. * Get an animation range by name
  560. * @param name defines the name of the animation range to look for
  561. * @returns null if not found else the requested animation range
  562. */
  563. getAnimationRange(name: string): Nullable<AnimationRange>;
  564. /**
  565. * Will start the animation sequence
  566. * @param name defines the range frames for animation sequence
  567. * @param loop defines if the animation should loop (false by default)
  568. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  569. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  570. * @returns the object created for this animation. If range does not exist, it will return null
  571. */
  572. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  573. /**
  574. * Serialize animation ranges into a JSON compatible object
  575. * @returns serialization object
  576. */
  577. serializeAnimationRanges(): any;
  578. /**
  579. * Computes the world matrix of the node
  580. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  581. * @returns the world matrix
  582. */
  583. computeWorldMatrix(force?: boolean): Matrix;
  584. /**
  585. * Releases resources associated with this node.
  586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  588. */
  589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  590. /**
  591. * Parse animation range data from a serialization object and store them into a given node
  592. * @param node defines where to store the animation ranges
  593. * @param parsedNode defines the serialization object to read data from
  594. * @param scene defines the hosting scene
  595. */
  596. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * Define an interface for all classes that will hold resources
  602. */
  603. interface IDisposable {
  604. /**
  605. * Releases all held resources
  606. */
  607. dispose(): void;
  608. }
  609. /**
  610. * Interface used to let developers provide their own mesh selection mechanism
  611. */
  612. interface IActiveMeshCandidateProvider {
  613. /**
  614. * Return the list of active meshes
  615. * @param scene defines the current scene
  616. * @returns the list of active meshes
  617. */
  618. getMeshes(scene: Scene): AbstractMesh[];
  619. /**
  620. * Indicates if the meshes have been checked to make sure they are isEnabled()
  621. */
  622. readonly checksIsEnabled: boolean;
  623. }
  624. /**
  625. * This class is used by the onRenderingGroupObservable
  626. */
  627. class RenderingGroupInfo {
  628. /**
  629. * The Scene that being rendered
  630. */
  631. scene: Scene;
  632. /**
  633. * The camera currently used for the rendering pass
  634. */
  635. camera: Nullable<Camera>;
  636. /**
  637. * The ID of the renderingGroup being processed
  638. */
  639. renderingGroupId: number;
  640. }
  641. /**
  642. * Represents a scene to be rendered by the engine.
  643. * @see http://doc.babylonjs.com/features/scene
  644. */
  645. class Scene extends AbstractScene implements IAnimatable {
  646. private static _uniqueIdCounter;
  647. /** The fog is deactivated */
  648. static readonly FOGMODE_NONE: number;
  649. /** The fog density is following an exponential function */
  650. static readonly FOGMODE_EXP: number;
  651. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  652. static readonly FOGMODE_EXP2: number;
  653. /** The fog density is following a linear function. */
  654. static readonly FOGMODE_LINEAR: number;
  655. /**
  656. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  658. */
  659. static MinDeltaTime: number;
  660. /**
  661. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  663. */
  664. static MaxDeltaTime: number;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  667. */
  668. autoClear: boolean;
  669. /**
  670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  671. */
  672. autoClearDepthAndStencil: boolean;
  673. /**
  674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  675. */
  676. clearColor: Color4;
  677. /**
  678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  679. */
  680. ambientColor: Color3;
  681. /** @hidden */
  682. _environmentBRDFTexture: BaseTexture;
  683. /** @hidden */
  684. protected _environmentTexture: BaseTexture;
  685. /**
  686. * Texture used in all pbr material as the reflection texture.
  687. * As in the majority of the scene they are the same (exception for multi room and so on),
  688. * this is easier to reference from here than from all the materials.
  689. */
  690. /**
  691. * Texture used in all pbr material as the reflection texture.
  692. * As in the majority of the scene they are the same (exception for multi room and so on),
  693. * this is easier to set here than in all the materials.
  694. */
  695. environmentTexture: BaseTexture;
  696. /** @hidden */
  697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  698. /**
  699. * Default image processing configuration used either in the rendering
  700. * Forward main pass or through the imageProcessingPostProcess if present.
  701. * As in the majority of the scene they are the same (exception for multi camera),
  702. * this is easier to reference from here than from all the materials and post process.
  703. *
  704. * No setter as we it is a shared configuration, you can set the values instead.
  705. */
  706. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  707. private _forceWireframe;
  708. /**
  709. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  710. */
  711. forceWireframe: boolean;
  712. private _forcePointsCloud;
  713. /**
  714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  715. */
  716. forcePointsCloud: boolean;
  717. /**
  718. * Gets or sets the active clipplane 1
  719. */
  720. clipPlane: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 2
  723. */
  724. clipPlane2: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 3
  727. */
  728. clipPlane3: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 4
  731. */
  732. clipPlane4: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. /**
  778. * An event triggered when the scene is disposed.
  779. */
  780. onDisposeObservable: Observable<Scene>;
  781. private _onDisposeObserver;
  782. /** Sets a function to be executed when this scene is disposed. */
  783. onDispose: () => void;
  784. /**
  785. * An event triggered before rendering the scene (right after animations and physics)
  786. */
  787. onBeforeRenderObservable: Observable<Scene>;
  788. private _onBeforeRenderObserver;
  789. /** Sets a function to be executed before rendering this scene */
  790. beforeRender: Nullable<() => void>;
  791. /**
  792. * An event triggered after rendering the scene
  793. */
  794. onAfterRenderObservable: Observable<Scene>;
  795. private _onAfterRenderObserver;
  796. /** Sets a function to be executed after rendering this scene */
  797. afterRender: Nullable<() => void>;
  798. /**
  799. * An event triggered before animating the scene
  800. */
  801. onBeforeAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered after animations processing
  804. */
  805. onAfterAnimationsObservable: Observable<Scene>;
  806. /**
  807. * An event triggered before draw calls are ready to be sent
  808. */
  809. onBeforeDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after draw calls have been sent
  812. */
  813. onAfterDrawPhaseObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when physic simulation is about to be run
  816. */
  817. onBeforePhysicsObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when physic simulation has been done
  820. */
  821. onAfterPhysicsObservable: Observable<Scene>;
  822. /**
  823. * An event triggered when the scene is ready
  824. */
  825. onReadyObservable: Observable<Scene>;
  826. /**
  827. * An event triggered before rendering a camera
  828. */
  829. onBeforeCameraRenderObservable: Observable<Camera>;
  830. private _onBeforeCameraRenderObserver;
  831. /** Sets a function to be executed before rendering a camera*/
  832. beforeCameraRender: () => void;
  833. /**
  834. * An event triggered after rendering a camera
  835. */
  836. onAfterCameraRenderObservable: Observable<Camera>;
  837. private _onAfterCameraRenderObserver;
  838. /** Sets a function to be executed after rendering a camera*/
  839. afterCameraRender: () => void;
  840. /**
  841. * An event triggered when active meshes evaluation is about to start
  842. */
  843. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when active meshes evaluation is done
  846. */
  847. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  848. /**
  849. * An event triggered when particles rendering is about to start
  850. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  851. */
  852. onBeforeParticlesRenderingObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is done
  855. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  856. */
  857. onAfterParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  860. */
  861. onDataLoadedObservable: Observable<Scene>;
  862. /**
  863. * An event triggered when a camera is created
  864. */
  865. onNewCameraAddedObservable: Observable<Camera>;
  866. /**
  867. * An event triggered when a camera is removed
  868. */
  869. onCameraRemovedObservable: Observable<Camera>;
  870. /**
  871. * An event triggered when a light is created
  872. */
  873. onNewLightAddedObservable: Observable<Light>;
  874. /**
  875. * An event triggered when a light is removed
  876. */
  877. onLightRemovedObservable: Observable<Light>;
  878. /**
  879. * An event triggered when a geometry is created
  880. */
  881. onNewGeometryAddedObservable: Observable<Geometry>;
  882. /**
  883. * An event triggered when a geometry is removed
  884. */
  885. onGeometryRemovedObservable: Observable<Geometry>;
  886. /**
  887. * An event triggered when a transform node is created
  888. */
  889. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  890. /**
  891. * An event triggered when a transform node is removed
  892. */
  893. onTransformNodeRemovedObservable: Observable<TransformNode>;
  894. /**
  895. * An event triggered when a mesh is created
  896. */
  897. onNewMeshAddedObservable: Observable<AbstractMesh>;
  898. /**
  899. * An event triggered when a mesh is removed
  900. */
  901. onMeshRemovedObservable: Observable<AbstractMesh>;
  902. /**
  903. * An event triggered when render targets are about to be rendered
  904. * Can happen multiple times per frame.
  905. */
  906. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when render targets were rendered.
  909. * Can happen multiple times per frame.
  910. */
  911. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  912. /**
  913. * An event triggered before calculating deterministic simulation step
  914. */
  915. onBeforeStepObservable: Observable<Scene>;
  916. /**
  917. * An event triggered after calculating deterministic simulation step
  918. */
  919. onAfterStepObservable: Observable<Scene>;
  920. /**
  921. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  922. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  923. * 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)
  924. */
  925. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  926. /**
  927. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  928. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  929. * 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)
  930. */
  931. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  932. private _registeredForLateAnimationBindings;
  933. /**
  934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  935. */
  936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  937. /**
  938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  939. */
  940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  943. */
  944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  945. private _onPointerMove;
  946. private _onPointerDown;
  947. private _onPointerUp;
  948. /** Deprecated. Use onPointerObservable instead */
  949. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  950. /** Deprecated. Use onPointerObservable instead */
  951. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  952. /** Deprecated. Use onPointerObservable instead */
  953. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  954. /** Deprecated. Use onPointerObservable instead */
  955. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  956. /**
  957. * 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).
  958. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  959. */
  960. onPrePointerObservable: Observable<PointerInfoPre>;
  961. /**
  962. * Observable event triggered each time an input event is received from the rendering canvas
  963. */
  964. onPointerObservable: Observable<PointerInfo>;
  965. /**
  966. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  967. */
  968. readonly unTranslatedPointer: Vector2;
  969. /** The distance in pixel that you have to move to prevent some events */
  970. static DragMovementThreshold: number;
  971. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  972. static LongPressDelay: number;
  973. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  974. static DoubleClickDelay: number;
  975. /** If you need to check double click without raising a single click at first click, enable this flag */
  976. static ExclusiveDoubleClickMode: boolean;
  977. private _initClickEvent;
  978. private _initActionManager;
  979. private _delayedSimpleClick;
  980. private _delayedSimpleClickTimeout;
  981. private _previousDelayedSimpleClickTimeout;
  982. private _meshPickProceed;
  983. private _previousButtonPressed;
  984. private _currentPickResult;
  985. private _previousPickResult;
  986. private _totalPointersPressed;
  987. private _doubleClickOccured;
  988. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  989. cameraToUseForPointers: Nullable<Camera>;
  990. private _pointerX;
  991. private _pointerY;
  992. private _unTranslatedPointerX;
  993. private _unTranslatedPointerY;
  994. private _startingPointerPosition;
  995. private _previousStartingPointerPosition;
  996. private _startingPointerTime;
  997. private _previousStartingPointerTime;
  998. private _pointerCaptures;
  999. private _timeAccumulator;
  1000. private _currentStepId;
  1001. private _currentInternalStep;
  1002. /** @hidden */
  1003. _mirroredCameraPosition: Nullable<Vector3>;
  1004. /**
  1005. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1006. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1007. */
  1008. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1009. /**
  1010. * Observable event triggered each time an keyboard event is received from the hosting window
  1011. */
  1012. onKeyboardObservable: Observable<KeyboardInfo>;
  1013. private _onKeyDown;
  1014. private _onKeyUp;
  1015. private _onCanvasFocusObserver;
  1016. private _onCanvasBlurObserver;
  1017. private _useRightHandedSystem;
  1018. /**
  1019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1020. */
  1021. useRightHandedSystem: boolean;
  1022. /**
  1023. * Sets the step Id used by deterministic lock step
  1024. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1025. * @param newStepId defines the step Id
  1026. */
  1027. setStepId(newStepId: number): void;
  1028. /**
  1029. * Gets the step Id used by deterministic lock step
  1030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1031. * @returns the step Id
  1032. */
  1033. getStepId(): number;
  1034. /**
  1035. * Gets the internal step used by deterministic lock step
  1036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1037. * @returns the internal step
  1038. */
  1039. getInternalStep(): number;
  1040. private _fogEnabled;
  1041. /**
  1042. * Gets or sets a boolean indicating if fog is enabled on this scene
  1043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1044. */
  1045. fogEnabled: boolean;
  1046. private _fogMode;
  1047. /**
  1048. * Gets or sets the fog mode to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogMode: number;
  1052. /**
  1053. * Gets or sets the fog color to use
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogColor: Color3;
  1057. /**
  1058. * Gets or sets the fog density to use
  1059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1060. */
  1061. fogDensity: number;
  1062. /**
  1063. * Gets or sets the fog start distance to use
  1064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1065. */
  1066. fogStart: number;
  1067. /**
  1068. * Gets or sets the fog end distance to use
  1069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1070. */
  1071. fogEnd: number;
  1072. private _shadowsEnabled;
  1073. /**
  1074. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1075. */
  1076. shadowsEnabled: boolean;
  1077. private _lightsEnabled;
  1078. /**
  1079. * Gets or sets a boolean indicating if lights are enabled on this scene
  1080. */
  1081. lightsEnabled: boolean;
  1082. /** All of the active cameras added to this scene. */
  1083. activeCameras: Camera[];
  1084. /** The current active camera */
  1085. activeCamera: Nullable<Camera>;
  1086. private _defaultMaterial;
  1087. /** The default material used on meshes when no material is affected */
  1088. /** The default material used on meshes when no material is affected */
  1089. defaultMaterial: Material;
  1090. private _texturesEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if textures are enabled on this scene
  1093. */
  1094. texturesEnabled: boolean;
  1095. /**
  1096. * Gets or sets a boolean indicating if particles are enabled on this scene
  1097. */
  1098. particlesEnabled: boolean;
  1099. /**
  1100. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1101. */
  1102. spritesEnabled: boolean;
  1103. private _skeletonsEnabled;
  1104. /**
  1105. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1106. */
  1107. skeletonsEnabled: boolean;
  1108. /**
  1109. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1110. */
  1111. lensFlaresEnabled: boolean;
  1112. /**
  1113. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1115. */
  1116. collisionsEnabled: boolean;
  1117. private _workerCollisions;
  1118. /** @hidden */
  1119. collisionCoordinator: ICollisionCoordinator;
  1120. /**
  1121. * Defines the gravity applied to this scene (used only for collisions)
  1122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1123. */
  1124. gravity: Vector3;
  1125. /**
  1126. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1127. */
  1128. postProcessesEnabled: boolean;
  1129. /**
  1130. * The list of postprocesses added to the scene
  1131. */
  1132. postProcesses: PostProcess[];
  1133. /**
  1134. * Gets the current postprocess manager
  1135. */
  1136. postProcessManager: PostProcessManager;
  1137. /**
  1138. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1139. */
  1140. renderTargetsEnabled: boolean;
  1141. /**
  1142. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1143. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1144. */
  1145. dumpNextRenderTargets: boolean;
  1146. /**
  1147. * The list of user defined render targets added to the scene
  1148. */
  1149. customRenderTargets: RenderTargetTexture[];
  1150. /**
  1151. * Defines if texture loading must be delayed
  1152. * If true, textures will only be loaded when they need to be rendered
  1153. */
  1154. useDelayedTextureLoading: boolean;
  1155. /**
  1156. * Gets the list of meshes imported to the scene through SceneLoader
  1157. */
  1158. importedMeshesFiles: String[];
  1159. /**
  1160. * Gets or sets a boolean indicating if probes are enabled on this scene
  1161. */
  1162. probesEnabled: boolean;
  1163. /**
  1164. * The list of reflection probes added to the scene
  1165. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1166. */
  1167. reflectionProbes: ReflectionProbe[];
  1168. /**
  1169. * @hidden
  1170. */
  1171. database: Database;
  1172. /**
  1173. * Gets or sets the action manager associated with the scene
  1174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1175. */
  1176. actionManager: ActionManager;
  1177. private _meshesForIntersections;
  1178. /**
  1179. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1180. */
  1181. proceduralTexturesEnabled: boolean;
  1182. /**
  1183. * The list of procedural textures added to the scene
  1184. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1185. */
  1186. proceduralTextures: ProceduralTexture[];
  1187. private _mainSoundTrack;
  1188. /**
  1189. * The list of sound tracks added to the scene
  1190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1191. */
  1192. soundTracks: SoundTrack[];
  1193. private _audioEnabled;
  1194. private _headphone;
  1195. /**
  1196. * Gets the main soundtrack associated with the scene
  1197. */
  1198. readonly mainSoundTrack: SoundTrack;
  1199. /**
  1200. * Gets or sets the VRExperienceHelper attached to the scene
  1201. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1202. * @ignorenaming
  1203. */
  1204. VRHelper: VRExperienceHelper;
  1205. private _engine;
  1206. private _totalVertices;
  1207. /** @hidden */
  1208. _activeIndices: PerfCounter;
  1209. /** @hidden */
  1210. _activeParticles: PerfCounter;
  1211. /** @hidden */
  1212. _activeBones: PerfCounter;
  1213. private _animationRatio;
  1214. private _animationTimeLast;
  1215. private _animationTime;
  1216. /**
  1217. * Gets or sets a general scale for animation speed
  1218. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1219. */
  1220. animationTimeScale: number;
  1221. /** @hidden */
  1222. _cachedMaterial: Nullable<Material>;
  1223. /** @hidden */
  1224. _cachedEffect: Nullable<Effect>;
  1225. /** @hidden */
  1226. _cachedVisibility: Nullable<number>;
  1227. private _renderId;
  1228. private _executeWhenReadyTimeoutId;
  1229. private _intermediateRendering;
  1230. private _viewUpdateFlag;
  1231. private _projectionUpdateFlag;
  1232. private _alternateViewUpdateFlag;
  1233. private _alternateProjectionUpdateFlag;
  1234. /** @hidden */
  1235. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1236. private _activeRequests;
  1237. private _pendingData;
  1238. private _isDisposed;
  1239. /**
  1240. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1241. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1242. */
  1243. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1244. private _activeMeshes;
  1245. private _processedMaterials;
  1246. private _renderTargets;
  1247. /** @hidden */
  1248. _activeParticleSystems: SmartArray<IParticleSystem>;
  1249. private _activeSkeletons;
  1250. private _softwareSkinnedMeshes;
  1251. private _renderingManager;
  1252. private _physicsEngine;
  1253. /** @hidden */
  1254. _activeAnimatables: Animatable[];
  1255. private _transformMatrix;
  1256. private _sceneUbo;
  1257. private _alternateSceneUbo;
  1258. private _pickWithRayInverseMatrix;
  1259. private _outlineRenderer;
  1260. private _viewMatrix;
  1261. private _projectionMatrix;
  1262. private _alternateViewMatrix;
  1263. private _alternateProjectionMatrix;
  1264. private _alternateTransformMatrix;
  1265. private _useAlternateCameraConfiguration;
  1266. private _alternateRendering;
  1267. /** @hidden */
  1268. _forcedViewPosition: Nullable<Vector3>;
  1269. /** @hidden */
  1270. readonly _isAlternateRenderingEnabled: boolean;
  1271. private _frustumPlanes;
  1272. /**
  1273. * Gets the list of frustum planes (built from the active camera)
  1274. */
  1275. readonly frustumPlanes: Plane[];
  1276. /**
  1277. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1278. * This is useful if there are more lights that the maximum simulteanous authorized
  1279. */
  1280. requireLightSorting: boolean;
  1281. private _selectionOctree;
  1282. private _pointerOverMesh;
  1283. private _debugLayer;
  1284. private _pickedDownMesh;
  1285. private _pickedUpMesh;
  1286. private _externalData;
  1287. private _uid;
  1288. /**
  1289. * @hidden
  1290. * Backing store of defined scene components.
  1291. */
  1292. _components: ISceneComponent[];
  1293. /**
  1294. * @hidden
  1295. * Backing store of defined scene components.
  1296. */
  1297. _serializableComponents: ISceneSerializableComponent[];
  1298. /**
  1299. * List of components to register on the next registration step.
  1300. */
  1301. private _transientComponents;
  1302. /**
  1303. * Registers the transient components if needed.
  1304. */
  1305. private _registerTransientComponents;
  1306. /**
  1307. * @hidden
  1308. * Add a component to the scene.
  1309. * Note that the ccomponent could be registered on th next frame if this is called after
  1310. * the register component stage.
  1311. * @param component Defines the component to add to the scene
  1312. */
  1313. _addComponent(component: ISceneComponent): void;
  1314. /**
  1315. * @hidden
  1316. * Gets a component from the scene.
  1317. * @param name defines the name of the component to retrieve
  1318. * @returns the component or null if not present
  1319. */
  1320. _getComponent(name: string): Nullable<ISceneComponent>;
  1321. /**
  1322. * @hidden
  1323. * Defines the actions happening before camera updates.
  1324. */
  1325. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1326. /**
  1327. * @hidden
  1328. * Defines the actions happening before camera updates.
  1329. */
  1330. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1331. /**
  1332. * @hidden
  1333. * Defines the actions happening during the per mesh ready checks.
  1334. */
  1335. _isReadyForMeshStage: Stage<MeshStageAction>;
  1336. /**
  1337. * @hidden
  1338. * Defines the actions happening before evaluate active mesh checks.
  1339. */
  1340. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1341. /**
  1342. * @hidden
  1343. * Defines the actions happening during the evaluate sub mesh checks.
  1344. */
  1345. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1346. /**
  1347. * @hidden
  1348. * Defines the actions happening during the active mesh stage.
  1349. */
  1350. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1351. /**
  1352. * @hidden
  1353. * Defines the actions happening during the per camera render target step.
  1354. */
  1355. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1356. /**
  1357. * @hidden
  1358. * Defines the actions happening just before the active camera is drawing.
  1359. */
  1360. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1361. /**
  1362. * Defines the actions happening just before a rendering group is drawing.
  1363. */
  1364. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1365. /**
  1366. * @hidden
  1367. * Defines the actions happening just after a rendering group has been drawn.
  1368. */
  1369. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1370. /**
  1371. * @hidden
  1372. * Defines the actions happening just after the active camera has been drawn.
  1373. */
  1374. _afterCameraDrawStage: Stage<CameraStageAction>;
  1375. /**
  1376. * @hidden
  1377. * Defines the actions happening when Geometries are rebuilding.
  1378. */
  1379. _rebuildGeometryStage: Stage<SimpleStageAction>;
  1380. /**
  1381. * @hidden
  1382. * Defines the actions happening when a pointer move event happens.
  1383. */
  1384. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1385. /**
  1386. * @hidden
  1387. * Defines the actions happening when a pointer down event happens.
  1388. */
  1389. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1390. /**
  1391. * @hidden
  1392. * Defines the actions happening when a pointer up event happens.
  1393. */
  1394. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1395. /**
  1396. * Creates a new Scene
  1397. * @param engine defines the engine to use to render this scene
  1398. */
  1399. constructor(engine: Engine);
  1400. /**
  1401. * Gets the debug layer (aka Inspector) associated with the scene
  1402. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1403. */
  1404. readonly debugLayer: DebugLayer;
  1405. /**
  1406. * Gets a boolean indicating if collisions are processed on a web worker
  1407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1408. */
  1409. workerCollisions: boolean;
  1410. /**
  1411. * Gets the octree used to boost mesh selection (picking)
  1412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1413. */
  1414. readonly selectionOctree: Octree<AbstractMesh>;
  1415. /**
  1416. * Gets the mesh that is currently under the pointer
  1417. */
  1418. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1419. /**
  1420. * Gets the current on-screen X position of the pointer
  1421. */
  1422. readonly pointerX: number;
  1423. /**
  1424. * Gets the current on-screen Y position of the pointer
  1425. */
  1426. readonly pointerY: number;
  1427. /**
  1428. * Gets the cached material (ie. the latest rendered one)
  1429. * @returns the cached material
  1430. */
  1431. getCachedMaterial(): Nullable<Material>;
  1432. /**
  1433. * Gets the cached effect (ie. the latest rendered one)
  1434. * @returns the cached effect
  1435. */
  1436. getCachedEffect(): Nullable<Effect>;
  1437. /**
  1438. * Gets the cached visibility state (ie. the latest rendered one)
  1439. * @returns the cached visibility state
  1440. */
  1441. getCachedVisibility(): Nullable<number>;
  1442. /**
  1443. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1444. * @param material defines the current material
  1445. * @param effect defines the current effect
  1446. * @param visibility defines the current visibility state
  1447. * @returns true if one parameter is not cached
  1448. */
  1449. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1450. /**
  1451. * Gets the outline renderer associated with the scene
  1452. * @returns a OutlineRenderer
  1453. */
  1454. getOutlineRenderer(): OutlineRenderer;
  1455. /**
  1456. * Gets the engine associated with the scene
  1457. * @returns an Engine
  1458. */
  1459. getEngine(): Engine;
  1460. /**
  1461. * Gets the total number of vertices rendered per frame
  1462. * @returns the total number of vertices rendered per frame
  1463. */
  1464. getTotalVertices(): number;
  1465. /**
  1466. * Gets the performance counter for total vertices
  1467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1468. */
  1469. readonly totalVerticesPerfCounter: PerfCounter;
  1470. /**
  1471. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1472. * @returns the total number of active indices rendered per frame
  1473. */
  1474. getActiveIndices(): number;
  1475. /**
  1476. * Gets the performance counter for active indices
  1477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1478. */
  1479. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1480. /**
  1481. * Gets the total number of active particles rendered per frame
  1482. * @returns the total number of active particles rendered per frame
  1483. */
  1484. getActiveParticles(): number;
  1485. /**
  1486. * Gets the performance counter for active particles
  1487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1488. */
  1489. readonly activeParticlesPerfCounter: PerfCounter;
  1490. /**
  1491. * Gets the total number of active bones rendered per frame
  1492. * @returns the total number of active bones rendered per frame
  1493. */
  1494. getActiveBones(): number;
  1495. /**
  1496. * Gets the performance counter for active bones
  1497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1498. */
  1499. readonly activeBonesPerfCounter: PerfCounter;
  1500. /** @hidden */
  1501. getInterFramePerfCounter(): number;
  1502. /** @hidden */
  1503. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1504. /** @hidden */
  1505. getLastFrameDuration(): number;
  1506. /** @hidden */
  1507. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1508. /** @hidden */
  1509. getEvaluateActiveMeshesDuration(): number;
  1510. /** @hidden */
  1511. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1512. /**
  1513. * Gets the array of active meshes
  1514. * @returns an array of AbstractMesh
  1515. */
  1516. getActiveMeshes(): SmartArray<AbstractMesh>;
  1517. /** @hidden */
  1518. getRenderTargetsDuration(): number;
  1519. /** @hidden */
  1520. getRenderDuration(): number;
  1521. /** @hidden */
  1522. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1523. /** @hidden */
  1524. getParticlesDuration(): number;
  1525. /** @hidden */
  1526. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1527. /** @hidden */
  1528. getSpritesDuration(): number;
  1529. /** @hidden */
  1530. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1531. /**
  1532. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1533. * @returns a number
  1534. */
  1535. getAnimationRatio(): number;
  1536. /**
  1537. * Gets an unique Id for the current frame
  1538. * @returns a number
  1539. */
  1540. getRenderId(): number;
  1541. /** Call this function if you want to manually increment the render Id*/
  1542. incrementRenderId(): void;
  1543. private _updatePointerPosition;
  1544. private _createUbo;
  1545. private _createAlternateUbo;
  1546. private _setRayOnPointerInfo;
  1547. /**
  1548. * Use this method to simulate a pointer move on a mesh
  1549. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1550. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1551. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1552. * @returns the current scene
  1553. */
  1554. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1555. private _processPointerMove;
  1556. private _checkPrePointerObservable;
  1557. /**
  1558. * Use this method to simulate a pointer down on a mesh
  1559. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1560. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1561. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1562. * @returns the current scene
  1563. */
  1564. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1565. private _processPointerDown;
  1566. /**
  1567. * Use this method to simulate a pointer up on a mesh
  1568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1571. * @returns the current scene
  1572. */
  1573. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1574. private _processPointerUp;
  1575. /**
  1576. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1577. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1578. * @returns true if the pointer was captured
  1579. */
  1580. isPointerCaptured(pointerId?: number): boolean;
  1581. /** @hidden */
  1582. _isPointerSwiping(): boolean;
  1583. /**
  1584. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1585. * @param attachUp defines if you want to attach events to pointerup
  1586. * @param attachDown defines if you want to attach events to pointerdown
  1587. * @param attachMove defines if you want to attach events to pointermove
  1588. */
  1589. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1590. /** Detaches all event handlers*/
  1591. detachControl(): void;
  1592. /**
  1593. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1594. * Delay loaded resources are not taking in account
  1595. * @return true if all required resources are ready
  1596. */
  1597. isReady(): boolean;
  1598. /** Resets all cached information relative to material (including effect and visibility) */
  1599. resetCachedMaterial(): void;
  1600. /**
  1601. * Registers a function to be called before every frame render
  1602. * @param func defines the function to register
  1603. */
  1604. registerBeforeRender(func: () => void): void;
  1605. /**
  1606. * Unregisters a function called before every frame render
  1607. * @param func defines the function to unregister
  1608. */
  1609. unregisterBeforeRender(func: () => void): void;
  1610. /**
  1611. * Registers a function to be called after every frame render
  1612. * @param func defines the function to register
  1613. */
  1614. registerAfterRender(func: () => void): void;
  1615. /**
  1616. * Unregisters a function called after every frame render
  1617. * @param func defines the function to unregister
  1618. */
  1619. unregisterAfterRender(func: () => void): void;
  1620. private _executeOnceBeforeRender;
  1621. /**
  1622. * The provided function will run before render once and will be disposed afterwards.
  1623. * A timeout delay can be provided so that the function will be executed in N ms.
  1624. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1625. * @param func The function to be executed.
  1626. * @param timeout optional delay in ms
  1627. */
  1628. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1629. /** @hidden */
  1630. _addPendingData(data: any): void;
  1631. /** @hidden */
  1632. _removePendingData(data: any): void;
  1633. /**
  1634. * Returns the number of items waiting to be loaded
  1635. * @returns the number of items waiting to be loaded
  1636. */
  1637. getWaitingItemsCount(): number;
  1638. /**
  1639. * Returns a boolean indicating if the scene is still loading data
  1640. */
  1641. readonly isLoading: boolean;
  1642. /**
  1643. * Registers a function to be executed when the scene is ready
  1644. * @param {Function} func - the function to be executed
  1645. */
  1646. executeWhenReady(func: () => void): void;
  1647. /**
  1648. * Returns a promise that resolves when the scene is ready
  1649. * @returns A promise that resolves when the scene is ready
  1650. */
  1651. whenReadyAsync(): Promise<void>;
  1652. /** @hidden */
  1653. _checkIsReady(): void;
  1654. /**
  1655. * Will start the animation sequence of a given target
  1656. * @param target defines the target
  1657. * @param from defines from which frame should animation start
  1658. * @param to defines until which frame should animation run.
  1659. * @param weight defines the weight to apply to the animation (1.0 by default)
  1660. * @param loop defines if the animation loops
  1661. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1662. * @param onAnimationEnd defines the function to be executed when the animation ends
  1663. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1664. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1665. * @returns the animatable object created for this animation
  1666. */
  1667. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1668. /**
  1669. * Will start the animation sequence of a given target
  1670. * @param target defines the target
  1671. * @param from defines from which frame should animation start
  1672. * @param to defines until which frame should animation run.
  1673. * @param loop defines if the animation loops
  1674. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1675. * @param onAnimationEnd defines the function to be executed when the animation ends
  1676. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1677. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1678. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1679. * @returns the animatable object created for this animation
  1680. */
  1681. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1682. /**
  1683. * Begin a new animation on a given node
  1684. * @param target defines the target where the animation will take place
  1685. * @param animations defines the list of animations to start
  1686. * @param from defines the initial value
  1687. * @param to defines the final value
  1688. * @param loop defines if you want animation to loop (off by default)
  1689. * @param speedRatio defines the speed ratio to apply to all animations
  1690. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1691. * @returns the list of created animatables
  1692. */
  1693. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1694. /**
  1695. * Begin a new animation on a given node and its hierarchy
  1696. * @param target defines the root node where the animation will take place
  1697. * @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.
  1698. * @param animations defines the list of animations to start
  1699. * @param from defines the initial value
  1700. * @param to defines the final value
  1701. * @param loop defines if you want animation to loop (off by default)
  1702. * @param speedRatio defines the speed ratio to apply to all animations
  1703. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1704. * @returns the list of animatables created for all nodes
  1705. */
  1706. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1707. /**
  1708. * Gets the animatable associated with a specific target
  1709. * @param target defines the target of the animatable
  1710. * @returns the required animatable if found
  1711. */
  1712. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1713. /**
  1714. * Gets all animatables associated with a given target
  1715. * @param target defines the target to look animatables for
  1716. * @returns an array of Animatables
  1717. */
  1718. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1719. /**
  1720. * Gets all animatable attached to the scene
  1721. */
  1722. readonly animatables: Animatable[];
  1723. /**
  1724. * Will stop the animation of the given target
  1725. * @param target - the target
  1726. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1727. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1728. */
  1729. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1730. /**
  1731. * Stops and removes all animations that have been applied to the scene
  1732. */
  1733. stopAllAnimations(): void;
  1734. private _animate;
  1735. /** @hidden */
  1736. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1737. private _processLateAnimationBindingsForMatrices;
  1738. private _processLateAnimationBindingsForQuaternions;
  1739. private _processLateAnimationBindings;
  1740. /** @hidden */
  1741. _switchToAlternateCameraConfiguration(active: boolean): void;
  1742. /**
  1743. * Gets the current view matrix
  1744. * @returns a Matrix
  1745. */
  1746. getViewMatrix(): Matrix;
  1747. /**
  1748. * Gets the current projection matrix
  1749. * @returns a Matrix
  1750. */
  1751. getProjectionMatrix(): Matrix;
  1752. /**
  1753. * Gets the current transform matrix
  1754. * @returns a Matrix made of View * Projection
  1755. */
  1756. getTransformMatrix(): Matrix;
  1757. /**
  1758. * Sets the current transform matrix
  1759. * @param view defines the View matrix to use
  1760. * @param projection defines the Projection matrix to use
  1761. */
  1762. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1763. /** @hidden */
  1764. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1765. /**
  1766. * Gets the uniform buffer used to store scene data
  1767. * @returns a UniformBuffer
  1768. */
  1769. getSceneUniformBuffer(): UniformBuffer;
  1770. /**
  1771. * Gets an unique (relatively to the current scene) Id
  1772. * @returns an unique number for the scene
  1773. */
  1774. getUniqueId(): number;
  1775. /**
  1776. * Add a mesh to the list of scene's meshes
  1777. * @param newMesh defines the mesh to add
  1778. * @param recursive if all child meshes should also be added to the scene
  1779. */
  1780. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1781. /**
  1782. * Remove a mesh for the list of scene's meshes
  1783. * @param toRemove defines the mesh to remove
  1784. * @param recursive if all child meshes should also be removed from the scene
  1785. * @returns the index where the mesh was in the mesh list
  1786. */
  1787. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1788. /**
  1789. * Add a transform node to the list of scene's transform nodes
  1790. * @param newTransformNode defines the transform node to add
  1791. */
  1792. addTransformNode(newTransformNode: TransformNode): void;
  1793. /**
  1794. * Remove a transform node for the list of scene's transform nodes
  1795. * @param toRemove defines the transform node to remove
  1796. * @returns the index where the transform node was in the transform node list
  1797. */
  1798. removeTransformNode(toRemove: TransformNode): number;
  1799. /**
  1800. * Remove a skeleton for the list of scene's skeletons
  1801. * @param toRemove defines the skeleton to remove
  1802. * @returns the index where the skeleton was in the skeleton list
  1803. */
  1804. removeSkeleton(toRemove: Skeleton): number;
  1805. /**
  1806. * Remove a morph target for the list of scene's morph targets
  1807. * @param toRemove defines the morph target to remove
  1808. * @returns the index where the morph target was in the morph target list
  1809. */
  1810. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1811. /**
  1812. * Remove a light for the list of scene's lights
  1813. * @param toRemove defines the light to remove
  1814. * @returns the index where the light was in the light list
  1815. */
  1816. removeLight(toRemove: Light): number;
  1817. /**
  1818. * Remove a camera for the list of scene's cameras
  1819. * @param toRemove defines the camera to remove
  1820. * @returns the index where the camera was in the camera list
  1821. */
  1822. removeCamera(toRemove: Camera): number;
  1823. /**
  1824. * Remove a particle system for the list of scene's particle systems
  1825. * @param toRemove defines the particle system to remove
  1826. * @returns the index where the particle system was in the particle system list
  1827. */
  1828. removeParticleSystem(toRemove: IParticleSystem): number;
  1829. /**
  1830. * Remove a animation for the list of scene's animations
  1831. * @param toRemove defines the animation to remove
  1832. * @returns the index where the animation was in the animation list
  1833. */
  1834. removeAnimation(toRemove: Animation): number;
  1835. /**
  1836. * Removes the given animation group from this scene.
  1837. * @param toRemove The animation group to remove
  1838. * @returns The index of the removed animation group
  1839. */
  1840. removeAnimationGroup(toRemove: AnimationGroup): number;
  1841. /**
  1842. * Removes the given multi-material from this scene.
  1843. * @param toRemove The multi-material to remove
  1844. * @returns The index of the removed multi-material
  1845. */
  1846. removeMultiMaterial(toRemove: MultiMaterial): number;
  1847. /**
  1848. * Removes the given material from this scene.
  1849. * @param toRemove The material to remove
  1850. * @returns The index of the removed material
  1851. */
  1852. removeMaterial(toRemove: Material): number;
  1853. /**
  1854. * Removes the given action manager from this scene.
  1855. * @param toRemove The action manager to remove
  1856. * @returns The index of the removed action manager
  1857. */
  1858. removeActionManager(toRemove: ActionManager): number;
  1859. /**
  1860. * Removes the given texture from this scene.
  1861. * @param toRemove The texture to remove
  1862. * @returns The index of the removed texture
  1863. */
  1864. removeTexture(toRemove: BaseTexture): number;
  1865. /**
  1866. * Adds the given light to this scene
  1867. * @param newLight The light to add
  1868. */
  1869. addLight(newLight: Light): void;
  1870. /**
  1871. * Sorts the list list based on light priorities
  1872. */
  1873. sortLightsByPriority(): void;
  1874. /**
  1875. * Adds the given camera to this scene
  1876. * @param newCamera The camera to add
  1877. */
  1878. addCamera(newCamera: Camera): void;
  1879. /**
  1880. * Adds the given skeleton to this scene
  1881. * @param newSkeleton The skeleton to add
  1882. */
  1883. addSkeleton(newSkeleton: Skeleton): void;
  1884. /**
  1885. * Adds the given particle system to this scene
  1886. * @param newParticleSystem The particle system to add
  1887. */
  1888. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1889. /**
  1890. * Adds the given animation to this scene
  1891. * @param newAnimation The animation to add
  1892. */
  1893. addAnimation(newAnimation: Animation): void;
  1894. /**
  1895. * Adds the given animation group to this scene.
  1896. * @param newAnimationGroup The animation group to add
  1897. */
  1898. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1899. /**
  1900. * Adds the given multi-material to this scene
  1901. * @param newMultiMaterial The multi-material to add
  1902. */
  1903. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1904. /**
  1905. * Adds the given material to this scene
  1906. * @param newMaterial The material to add
  1907. */
  1908. addMaterial(newMaterial: Material): void;
  1909. /**
  1910. * Adds the given morph target to this scene
  1911. * @param newMorphTargetManager The morph target to add
  1912. */
  1913. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1914. /**
  1915. * Adds the given geometry to this scene
  1916. * @param newGeometry The geometry to add
  1917. */
  1918. addGeometry(newGeometry: Geometry): void;
  1919. /**
  1920. * Adds the given action manager to this scene
  1921. * @param newActionManager The action manager to add
  1922. */
  1923. addActionManager(newActionManager: ActionManager): void;
  1924. /**
  1925. * Adds the given texture to this scene.
  1926. * @param newTexture The texture to add
  1927. */
  1928. addTexture(newTexture: BaseTexture): void;
  1929. /**
  1930. * Switch active camera
  1931. * @param newCamera defines the new active camera
  1932. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1933. */
  1934. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1935. /**
  1936. * sets the active camera of the scene using its ID
  1937. * @param id defines the camera's ID
  1938. * @return the new active camera or null if none found.
  1939. */
  1940. setActiveCameraByID(id: string): Nullable<Camera>;
  1941. /**
  1942. * sets the active camera of the scene using its name
  1943. * @param name defines the camera's name
  1944. * @returns the new active camera or null if none found.
  1945. */
  1946. setActiveCameraByName(name: string): Nullable<Camera>;
  1947. /**
  1948. * get an animation group using its name
  1949. * @param name defines the material's name
  1950. * @return the animation group or null if none found.
  1951. */
  1952. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1953. /**
  1954. * get a material using its id
  1955. * @param id defines the material's ID
  1956. * @return the material or null if none found.
  1957. */
  1958. getMaterialByID(id: string): Nullable<Material>;
  1959. /**
  1960. * Gets a material using its name
  1961. * @param name defines the material's name
  1962. * @return the material or null if none found.
  1963. */
  1964. getMaterialByName(name: string): Nullable<Material>;
  1965. /**
  1966. * Gets a camera using its id
  1967. * @param id defines the id to look for
  1968. * @returns the camera or null if not found
  1969. */
  1970. getCameraByID(id: string): Nullable<Camera>;
  1971. /**
  1972. * Gets a camera using its unique id
  1973. * @param uniqueId defines the unique id to look for
  1974. * @returns the camera or null if not found
  1975. */
  1976. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1977. /**
  1978. * Gets a camera using its name
  1979. * @param name defines the camera's name
  1980. * @return the camera or null if none found.
  1981. */
  1982. getCameraByName(name: string): Nullable<Camera>;
  1983. /**
  1984. * Gets a bone using its id
  1985. * @param id defines the bone's id
  1986. * @return the bone or null if not found
  1987. */
  1988. getBoneByID(id: string): Nullable<Bone>;
  1989. /**
  1990. * Gets a bone using its id
  1991. * @param name defines the bone's name
  1992. * @return the bone or null if not found
  1993. */
  1994. getBoneByName(name: string): Nullable<Bone>;
  1995. /**
  1996. * Gets a light node using its name
  1997. * @param name defines the the light's name
  1998. * @return the light or null if none found.
  1999. */
  2000. getLightByName(name: string): Nullable<Light>;
  2001. /**
  2002. * Gets a light node using its id
  2003. * @param id defines the light's id
  2004. * @return the light or null if none found.
  2005. */
  2006. getLightByID(id: string): Nullable<Light>;
  2007. /**
  2008. * Gets a light node using its scene-generated unique ID
  2009. * @param uniqueId defines the light's unique id
  2010. * @return the light or null if none found.
  2011. */
  2012. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2013. /**
  2014. * Gets a particle system by id
  2015. * @param id defines the particle system id
  2016. * @return the corresponding system or null if none found
  2017. */
  2018. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2019. /**
  2020. * Gets a geometry using its ID
  2021. * @param id defines the geometry's id
  2022. * @return the geometry or null if none found.
  2023. */
  2024. getGeometryByID(id: string): Nullable<Geometry>;
  2025. /**
  2026. * Add a new geometry to this scene
  2027. * @param geometry defines the geometry to be added to the scene.
  2028. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2029. * @return a boolean defining if the geometry was added or not
  2030. */
  2031. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2032. /**
  2033. * Removes an existing geometry
  2034. * @param geometry defines the geometry to be removed from the scene
  2035. * @return a boolean defining if the geometry was removed or not
  2036. */
  2037. removeGeometry(geometry: Geometry): boolean;
  2038. /**
  2039. * Gets the list of geometries attached to the scene
  2040. * @returns an array of Geometry
  2041. */
  2042. getGeometries(): Geometry[];
  2043. /**
  2044. * Gets the first added mesh found of a given ID
  2045. * @param id defines the id to search for
  2046. * @return the mesh found or null if not found at all
  2047. */
  2048. getMeshByID(id: string): Nullable<AbstractMesh>;
  2049. /**
  2050. * Gets a list of meshes using their id
  2051. * @param id defines the id to search for
  2052. * @returns a list of meshes
  2053. */
  2054. getMeshesByID(id: string): Array<AbstractMesh>;
  2055. /**
  2056. * Gets the first added transform node found of a given ID
  2057. * @param id defines the id to search for
  2058. * @return the found transform node or null if not found at all.
  2059. */
  2060. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2061. /**
  2062. * Gets a list of transform nodes using their id
  2063. * @param id defines the id to search for
  2064. * @returns a list of transform nodes
  2065. */
  2066. getTransformNodesByID(id: string): Array<TransformNode>;
  2067. /**
  2068. * Gets a mesh with its auto-generated unique id
  2069. * @param uniqueId defines the unique id to search for
  2070. * @return the found mesh or null if not found at all.
  2071. */
  2072. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2073. /**
  2074. * Gets a the last added mesh using a given id
  2075. * @param id defines the id to search for
  2076. * @return the found mesh or null if not found at all.
  2077. */
  2078. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2079. /**
  2080. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2081. * @param id defines the id to search for
  2082. * @return the found node or null if not found at all
  2083. */
  2084. getLastEntryByID(id: string): Nullable<Node>;
  2085. /**
  2086. * Gets a node (Mesh, Camera, Light) using a given id
  2087. * @param id defines the id to search for
  2088. * @return the found node or null if not found at all
  2089. */
  2090. getNodeByID(id: string): Nullable<Node>;
  2091. /**
  2092. * Gets a node (Mesh, Camera, Light) using a given name
  2093. * @param name defines the name to search for
  2094. * @return the found node or null if not found at all.
  2095. */
  2096. getNodeByName(name: string): Nullable<Node>;
  2097. /**
  2098. * Gets a mesh using a given name
  2099. * @param name defines the name to search for
  2100. * @return the found mesh or null if not found at all.
  2101. */
  2102. getMeshByName(name: string): Nullable<AbstractMesh>;
  2103. /**
  2104. * Gets a transform node using a given name
  2105. * @param name defines the name to search for
  2106. * @return the found transform node or null if not found at all.
  2107. */
  2108. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2109. /**
  2110. * Gets a sound using a given name
  2111. * @param name defines the name to search for
  2112. * @return the found sound or null if not found at all.
  2113. */
  2114. getSoundByName(name: string): Nullable<Sound>;
  2115. /**
  2116. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2117. * @param id defines the id to search for
  2118. * @return the found skeleton or null if not found at all.
  2119. */
  2120. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2121. /**
  2122. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2123. * @param id defines the id to search for
  2124. * @return the found skeleton or null if not found at all.
  2125. */
  2126. getSkeletonById(id: string): Nullable<Skeleton>;
  2127. /**
  2128. * Gets a skeleton using a given name
  2129. * @param name defines the name to search for
  2130. * @return the found skeleton or null if not found at all.
  2131. */
  2132. getSkeletonByName(name: string): Nullable<Skeleton>;
  2133. /**
  2134. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2135. * @param id defines the id to search for
  2136. * @return the found morph target manager or null if not found at all.
  2137. */
  2138. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2139. /**
  2140. * Gets a boolean indicating if the given mesh is active
  2141. * @param mesh defines the mesh to look for
  2142. * @returns true if the mesh is in the active list
  2143. */
  2144. isActiveMesh(mesh: AbstractMesh): boolean;
  2145. /**
  2146. * Return a unique id as a string which can serve as an identifier for the scene
  2147. */
  2148. readonly uid: string;
  2149. /**
  2150. * Add an externaly attached data from its key.
  2151. * This method call will fail and return false, if such key already exists.
  2152. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2153. * @param key the unique key that identifies the data
  2154. * @param data the data object to associate to the key for this Engine instance
  2155. * @return true if no such key were already present and the data was added successfully, false otherwise
  2156. */
  2157. addExternalData<T>(key: string, data: T): boolean;
  2158. /**
  2159. * Get an externaly attached data from its key
  2160. * @param key the unique key that identifies the data
  2161. * @return the associated data, if present (can be null), or undefined if not present
  2162. */
  2163. getExternalData<T>(key: string): Nullable<T>;
  2164. /**
  2165. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2166. * @param key the unique key that identifies the data
  2167. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2168. * @return the associated data, can be null if the factory returned null.
  2169. */
  2170. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2171. /**
  2172. * Remove an externaly attached data from the Engine instance
  2173. * @param key the unique key that identifies the data
  2174. * @return true if the data was successfully removed, false if it doesn't exist
  2175. */
  2176. removeExternalData(key: string): boolean;
  2177. private _evaluateSubMesh;
  2178. /**
  2179. * Clear the processed materials smart array preventing retention point in material dispose.
  2180. */
  2181. freeProcessedMaterials(): void;
  2182. /**
  2183. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2184. */
  2185. freeActiveMeshes(): void;
  2186. /**
  2187. * Clear the info related to rendering groups preventing retention points during dispose.
  2188. */
  2189. freeRenderingGroups(): void;
  2190. /** @hidden */
  2191. _isInIntermediateRendering(): boolean;
  2192. private _activeMeshCandidateProvider;
  2193. /**
  2194. * Defines the current active mesh candidate provider
  2195. * @param provider defines the provider to use
  2196. */
  2197. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2198. /**
  2199. * Gets the current active mesh candidate provider
  2200. * @returns the current active mesh candidate provider
  2201. */
  2202. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2203. private _activeMeshesFrozen;
  2204. /**
  2205. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2206. * @returns the current scene
  2207. */
  2208. freezeActiveMeshes(): Scene;
  2209. /**
  2210. * Use this function to restart evaluating active meshes on every frame
  2211. * @returns the current scene
  2212. */
  2213. unfreezeActiveMeshes(): Scene;
  2214. private _evaluateActiveMeshes;
  2215. private _activeMesh;
  2216. /**
  2217. * Update the transform matrix to update from the current active camera
  2218. * @param force defines a boolean used to force the update even if cache is up to date
  2219. */
  2220. updateTransformMatrix(force?: boolean): void;
  2221. /**
  2222. * 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)
  2223. * @param alternateCamera defines the camera to use
  2224. */
  2225. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2226. /** @hidden */
  2227. _allowPostProcessClearColor: boolean;
  2228. private _renderForCamera;
  2229. private _processSubCameras;
  2230. private _checkIntersections;
  2231. /**
  2232. * Render the scene
  2233. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2234. */
  2235. render(updateCameras?: boolean): void;
  2236. private _updateAudioParameters;
  2237. /**
  2238. * Gets or sets if audio support is enabled
  2239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2240. */
  2241. audioEnabled: boolean;
  2242. private _disableAudio;
  2243. private _enableAudio;
  2244. /**
  2245. * Gets or sets if audio will be output to headphones
  2246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2247. */
  2248. headphone: boolean;
  2249. private _switchAudioModeForHeadphones;
  2250. private _switchAudioModeForNormalSpeakers;
  2251. /**
  2252. * Freeze all materials
  2253. * A frozen material will not be updatable but should be faster to render
  2254. */
  2255. freezeMaterials(): void;
  2256. /**
  2257. * Unfreeze all materials
  2258. * A frozen material will not be updatable but should be faster to render
  2259. */
  2260. unfreezeMaterials(): void;
  2261. /**
  2262. * Releases all held ressources
  2263. */
  2264. dispose(): void;
  2265. /**
  2266. * Gets if the scene is already disposed
  2267. */
  2268. readonly isDisposed: boolean;
  2269. /**
  2270. * Releases sounds & soundtracks
  2271. */
  2272. disposeSounds(): void;
  2273. /**
  2274. * Call this function to reduce memory footprint of the scene.
  2275. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2276. */
  2277. clearCachedVertexData(): void;
  2278. /**
  2279. * This function will remove the local cached buffer data from texture.
  2280. * It will save memory but will prevent the texture from being rebuilt
  2281. */
  2282. cleanCachedTextureBuffer(): void;
  2283. /**
  2284. * Get the world extend vectors with an optional filter
  2285. *
  2286. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2287. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2288. */
  2289. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2290. min: Vector3;
  2291. max: Vector3;
  2292. };
  2293. /**
  2294. * Creates or updates the octree used to boost selection (picking)
  2295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2296. * @param maxCapacity defines the maximum capacity per leaf
  2297. * @param maxDepth defines the maximum depth of the octree
  2298. * @returns an octree of AbstractMesh
  2299. */
  2300. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2301. /**
  2302. * Creates a ray that can be used to pick in the scene
  2303. * @param x defines the x coordinate of the origin (on-screen)
  2304. * @param y defines the y coordinate of the origin (on-screen)
  2305. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2306. * @param camera defines the camera to use for the picking
  2307. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2308. * @returns a Ray
  2309. */
  2310. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2311. /**
  2312. * Creates a ray that can be used to pick in the scene
  2313. * @param x defines the x coordinate of the origin (on-screen)
  2314. * @param y defines the y coordinate of the origin (on-screen)
  2315. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2316. * @param result defines the ray where to store the picking ray
  2317. * @param camera defines the camera to use for the picking
  2318. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2319. * @returns the current scene
  2320. */
  2321. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2322. /**
  2323. * Creates a ray that can be used to pick in the scene
  2324. * @param x defines the x coordinate of the origin (on-screen)
  2325. * @param y defines the y coordinate of the origin (on-screen)
  2326. * @param camera defines the camera to use for the picking
  2327. * @returns a Ray
  2328. */
  2329. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2330. /**
  2331. * Creates a ray that can be used to pick in the scene
  2332. * @param x defines the x coordinate of the origin (on-screen)
  2333. * @param y defines the y coordinate of the origin (on-screen)
  2334. * @param result defines the ray where to store the picking ray
  2335. * @param camera defines the camera to use for the picking
  2336. * @returns the current scene
  2337. */
  2338. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2339. private _internalPick;
  2340. private _internalMultiPick;
  2341. private _tempPickingRay;
  2342. /** Launch a ray to try to pick a mesh in the scene
  2343. * @param x position on screen
  2344. * @param y position on screen
  2345. * @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
  2346. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2347. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2348. * @returns a PickingInfo
  2349. */
  2350. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2351. private _cachedRayForTransform;
  2352. /** Use the given ray to pick a mesh in the scene
  2353. * @param ray The ray to use to pick meshes
  2354. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2355. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2356. * @returns a PickingInfo
  2357. */
  2358. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2359. /**
  2360. * Launch a ray to try to pick a mesh in the scene
  2361. * @param x X position on screen
  2362. * @param y Y position on screen
  2363. * @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
  2364. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2365. * @returns an array of PickingInfo
  2366. */
  2367. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2368. /**
  2369. * Launch a ray to try to pick a mesh in the scene
  2370. * @param ray Ray to use
  2371. * @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
  2372. * @returns an array of PickingInfo
  2373. */
  2374. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2375. /**
  2376. * Force the value of meshUnderPointer
  2377. * @param mesh defines the mesh to use
  2378. */
  2379. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2380. /**
  2381. * Gets the mesh under the pointer
  2382. * @returns a Mesh or null if no mesh is under the pointer
  2383. */
  2384. getPointerOverMesh(): Nullable<AbstractMesh>;
  2385. /**
  2386. * Gets the current physics engine
  2387. * @returns a PhysicsEngine or null if none attached
  2388. */
  2389. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2390. /**
  2391. * Enables physics to the current scene
  2392. * @param gravity defines the scene's gravity for the physics engine
  2393. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2394. * @return a boolean indicating if the physics engine was initialized
  2395. */
  2396. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2397. /**
  2398. * Disables and disposes the physics engine associated with the scene
  2399. */
  2400. disablePhysicsEngine(): void;
  2401. /**
  2402. * Gets a boolean indicating if there is an active physics engine
  2403. * @returns a boolean indicating if there is an active physics engine
  2404. */
  2405. isPhysicsEnabled(): boolean;
  2406. /**
  2407. * Deletes a physics compound impostor
  2408. * @param compound defines the compound to delete
  2409. */
  2410. deleteCompoundImpostor(compound: any): void;
  2411. /** @hidden */
  2412. _rebuildGeometries(): void;
  2413. /** @hidden */
  2414. _rebuildTextures(): void;
  2415. /**
  2416. * Creates a default light for the scene.
  2417. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2418. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2419. */
  2420. createDefaultLight(replace?: boolean): void;
  2421. /**
  2422. * Creates a default camera for the scene.
  2423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2424. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2425. * @param replace has default false, when true replaces the active camera in the scene
  2426. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2427. */
  2428. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2429. /**
  2430. * Creates a default camera and a default light.
  2431. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2432. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2433. * @param replace has the default false, when true replaces the active camera/light in the scene
  2434. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2435. */
  2436. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2437. /**
  2438. * Creates a new sky box
  2439. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2440. * @param environmentTexture defines the texture to use as environment texture
  2441. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2442. * @param scale defines the overall scale of the skybox
  2443. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2444. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2445. * @returns a new mesh holding the sky box
  2446. */
  2447. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2448. /**
  2449. * Creates a new environment
  2450. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2451. * @param options defines the options you can use to configure the environment
  2452. * @returns the new EnvironmentHelper
  2453. */
  2454. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2455. /**
  2456. * Creates a new VREXperienceHelper
  2457. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2458. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2459. * @returns a new VREXperienceHelper
  2460. */
  2461. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2462. private _getByTags;
  2463. /**
  2464. * Get a list of meshes by tags
  2465. * @param tagsQuery defines the tags query to use
  2466. * @param forEach defines a predicate used to filter results
  2467. * @returns an array of Mesh
  2468. */
  2469. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2470. /**
  2471. * Get a list of cameras by tags
  2472. * @param tagsQuery defines the tags query to use
  2473. * @param forEach defines a predicate used to filter results
  2474. * @returns an array of Camera
  2475. */
  2476. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2477. /**
  2478. * Get a list of lights by tags
  2479. * @param tagsQuery defines the tags query to use
  2480. * @param forEach defines a predicate used to filter results
  2481. * @returns an array of Light
  2482. */
  2483. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2484. /**
  2485. * Get a list of materials by tags
  2486. * @param tagsQuery defines the tags query to use
  2487. * @param forEach defines a predicate used to filter results
  2488. * @returns an array of Material
  2489. */
  2490. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2491. /**
  2492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2493. * This allowed control for front to back rendering or reversly depending of the special needs.
  2494. *
  2495. * @param renderingGroupId The rendering group id corresponding to its index
  2496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2499. */
  2500. 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;
  2501. /**
  2502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2503. *
  2504. * @param renderingGroupId The rendering group id corresponding to its index
  2505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2508. */
  2509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2510. /**
  2511. * Gets the current auto clear configuration for one rendering group of the rendering
  2512. * manager.
  2513. * @param index the rendering group index to get the information for
  2514. * @returns The auto clear setup for the requested rendering group
  2515. */
  2516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2517. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2518. blockMaterialDirtyMechanism: boolean;
  2519. /**
  2520. * Will flag all materials as dirty to trigger new shader compilation
  2521. * @param flag defines the flag used to specify which material part must be marked as dirty
  2522. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2523. */
  2524. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2525. /** @hidden */
  2526. _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;
  2527. /** @hidden */
  2528. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2529. }
  2530. }
  2531. declare module BABYLON {
  2532. /**
  2533. * Groups all the scene component constants in one place to ease maintenance.
  2534. * @hidden
  2535. */
  2536. class SceneComponentConstants {
  2537. static readonly NAME_EFFECTLAYER: string;
  2538. static readonly NAME_LAYER: string;
  2539. static readonly NAME_LENSFLARESYSTEM: string;
  2540. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2541. static readonly NAME_PARTICLESYSTEM: string;
  2542. static readonly NAME_GAMEPAD: string;
  2543. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2544. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2545. static readonly NAME_DEPTHRENDERER: string;
  2546. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2547. static readonly NAME_SPRITE: string;
  2548. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2549. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2550. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2551. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2552. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2553. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2554. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2555. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2556. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2557. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2558. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2559. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2560. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2561. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2562. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2563. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2564. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2565. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2566. static readonly STEP_REBUILDGEOMETRY_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2567. static readonly STEP_POINTERMOVE_SPRITE: number;
  2568. static readonly STEP_POINTERDOWN_SPRITE: number;
  2569. static readonly STEP_POINTERUP_SPRITE: number;
  2570. }
  2571. /**
  2572. * This represents a scene component.
  2573. *
  2574. * This is used to decouple the dependency the scene is having on the different workloads like
  2575. * layers, post processes...
  2576. */
  2577. interface ISceneComponent {
  2578. /**
  2579. * The name of the component. Each component must have a unique name.
  2580. */
  2581. name: string;
  2582. /**
  2583. * The scene the component belongs to.
  2584. */
  2585. scene: Scene;
  2586. /**
  2587. * Register the component to one instance of a scene.
  2588. */
  2589. register(): void;
  2590. /**
  2591. * Rebuilds the elements related to this component in case of
  2592. * context lost for instance.
  2593. */
  2594. rebuild(): void;
  2595. /**
  2596. * Disposes the component and the associated ressources.
  2597. */
  2598. dispose(): void;
  2599. }
  2600. /**
  2601. * This represents a SERIALIZABLE scene component.
  2602. *
  2603. * This extends Scene Component to add Serialization methods on top.
  2604. */
  2605. interface ISceneSerializableComponent extends ISceneComponent {
  2606. /**
  2607. * Adds all the element from the container to the scene
  2608. * @param container the container holding the elements
  2609. */
  2610. addFromContainer(container: AbstractScene): void;
  2611. /**
  2612. * Removes all the elements in the container from the scene
  2613. * @param container contains the elements to remove
  2614. */
  2615. removeFromContainer(container: AbstractScene): void;
  2616. /**
  2617. * Serializes the component data to the specified json object
  2618. * @param serializationObject The object to serialize to
  2619. */
  2620. serialize(serializationObject: any): void;
  2621. }
  2622. /**
  2623. * Strong typing of a Mesh related stage step action
  2624. */
  2625. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2626. /**
  2627. * Strong typing of a Evaluate Sub Mesh related stage step action
  2628. */
  2629. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2630. /**
  2631. * Strong typing of a Active Mesh related stage step action
  2632. */
  2633. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2634. /**
  2635. * Strong typing of a Camera related stage step action
  2636. */
  2637. type CameraStageAction = (camera: Camera) => void;
  2638. /**
  2639. * Strong typing of a RenderingGroup related stage step action
  2640. */
  2641. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2642. /**
  2643. * Strong typing of a simple stage step action
  2644. */
  2645. type SimpleStageAction = () => void;
  2646. /**
  2647. * Strong typing of a render target action.
  2648. */
  2649. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2650. /**
  2651. * Strong typing of a pointer move action.
  2652. */
  2653. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2654. /**
  2655. * Strong typing of a pointer up/down action.
  2656. */
  2657. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2658. /**
  2659. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2660. * @hidden
  2661. */
  2662. class Stage<T extends Function> extends Array<{
  2663. index: number;
  2664. component: ISceneComponent;
  2665. action: T;
  2666. }> {
  2667. /**
  2668. * Hide ctor from the rest of the world.
  2669. * @param items The items to add.
  2670. */
  2671. private constructor();
  2672. /**
  2673. * Creates a new Stage.
  2674. * @returns A new instance of a Stage
  2675. */
  2676. static Create<T extends Function>(): Stage<T>;
  2677. /**
  2678. * Registers a step in an ordered way in the targeted stage.
  2679. * @param index Defines the position to register the step in
  2680. * @param component Defines the component attached to the step
  2681. * @param action Defines the action to launch during the step
  2682. */
  2683. registerStep(index: number, component: ISceneComponent, action: T): void;
  2684. /**
  2685. * Clears all the steps from the stage.
  2686. */
  2687. clear(): void;
  2688. }
  2689. }
  2690. declare module BABYLON {
  2691. type Nullable<T> = T | null;
  2692. type float = number;
  2693. type double = number;
  2694. type int = number;
  2695. type FloatArray = number[] | Float32Array;
  2696. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2697. /**
  2698. * Alias for types that can be used by a Buffer or VertexBuffer.
  2699. */
  2700. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2701. }
  2702. declare module BABYLON {
  2703. /**
  2704. * The action to be carried out following a trigger
  2705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2706. */
  2707. class Action {
  2708. /** the trigger, with or without parameters, for the action */
  2709. triggerOptions: any;
  2710. /**
  2711. * Trigger for the action
  2712. */
  2713. trigger: number;
  2714. /**
  2715. * Internal only - manager for action
  2716. * @hidden
  2717. */
  2718. _actionManager: ActionManager;
  2719. private _nextActiveAction;
  2720. private _child;
  2721. private _condition?;
  2722. private _triggerParameter;
  2723. /**
  2724. * An event triggered prior to action being executed.
  2725. */
  2726. onBeforeExecuteObservable: Observable<Action>;
  2727. /**
  2728. * Creates a new Action
  2729. * @param triggerOptions the trigger, with or without parameters, for the action
  2730. * @param condition an optional determinant of action
  2731. */
  2732. constructor(
  2733. /** the trigger, with or without parameters, for the action */
  2734. triggerOptions: any, condition?: Condition);
  2735. /**
  2736. * Internal only
  2737. * @hidden
  2738. */
  2739. _prepare(): void;
  2740. /**
  2741. * Gets the trigger parameters
  2742. * @returns the trigger parameters
  2743. */
  2744. getTriggerParameter(): any;
  2745. /**
  2746. * Internal only - executes current action event
  2747. * @hidden
  2748. */
  2749. _executeCurrent(evt?: ActionEvent): void;
  2750. /**
  2751. * Execute placeholder for child classes
  2752. * @param evt optional action event
  2753. */
  2754. execute(evt?: ActionEvent): void;
  2755. /**
  2756. * Skips to next active action
  2757. */
  2758. skipToNextActiveAction(): void;
  2759. /**
  2760. * Adds action to chain of actions, may be a DoNothingAction
  2761. * @param action defines the next action to execute
  2762. * @returns The action passed in
  2763. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2764. */
  2765. then(action: Action): Action;
  2766. /**
  2767. * Internal only
  2768. * @hidden
  2769. */
  2770. _getProperty(propertyPath: string): string;
  2771. /**
  2772. * Internal only
  2773. * @hidden
  2774. */
  2775. _getEffectiveTarget(target: any, propertyPath: string): any;
  2776. /**
  2777. * Serialize placeholder for child classes
  2778. * @param parent of child
  2779. * @returns the serialized object
  2780. */
  2781. serialize(parent: any): any;
  2782. /**
  2783. * Internal only called by serialize
  2784. * @hidden
  2785. */
  2786. protected _serialize(serializedAction: any, parent?: any): any;
  2787. /**
  2788. * Internal only
  2789. * @hidden
  2790. */
  2791. static _SerializeValueAsString: (value: any) => string;
  2792. /**
  2793. * Internal only
  2794. * @hidden
  2795. */
  2796. static _GetTargetProperty: (target: Scene | Node) => {
  2797. name: string;
  2798. targetType: string;
  2799. value: string;
  2800. };
  2801. }
  2802. }
  2803. declare module BABYLON {
  2804. /**
  2805. * ActionEvent is the event being sent when an action is triggered.
  2806. */
  2807. class ActionEvent {
  2808. /** The mesh or sprite that triggered the action */
  2809. source: any;
  2810. /** The X mouse cursor position at the time of the event */
  2811. pointerX: number;
  2812. /** The Y mouse cursor position at the time of the event */
  2813. pointerY: number;
  2814. /** The mesh that is currently pointed at (can be null) */
  2815. meshUnderPointer: Nullable<AbstractMesh>;
  2816. /** the original (browser) event that triggered the ActionEvent */
  2817. sourceEvent?: any;
  2818. /** additional data for the event */
  2819. additionalData?: any;
  2820. /**
  2821. * Creates a new ActionEvent
  2822. * @param source The mesh or sprite that triggered the action
  2823. * @param pointerX The X mouse cursor position at the time of the event
  2824. * @param pointerY The Y mouse cursor position at the time of the event
  2825. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2826. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2827. * @param additionalData additional data for the event
  2828. */
  2829. constructor(
  2830. /** The mesh or sprite that triggered the action */
  2831. source: any,
  2832. /** The X mouse cursor position at the time of the event */
  2833. pointerX: number,
  2834. /** The Y mouse cursor position at the time of the event */
  2835. pointerY: number,
  2836. /** The mesh that is currently pointed at (can be null) */
  2837. meshUnderPointer: Nullable<AbstractMesh>,
  2838. /** the original (browser) event that triggered the ActionEvent */
  2839. sourceEvent?: any,
  2840. /** additional data for the event */
  2841. additionalData?: any);
  2842. /**
  2843. * Helper function to auto-create an ActionEvent from a source mesh.
  2844. * @param source The source mesh that triggered the event
  2845. * @param evt The original (browser) event
  2846. * @param additionalData additional data for the event
  2847. * @returns the new ActionEvent
  2848. */
  2849. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2850. /**
  2851. * Helper function to auto-create an ActionEvent from a source sprite
  2852. * @param source The source sprite that triggered the event
  2853. * @param scene Scene associated with the sprite
  2854. * @param evt The original (browser) event
  2855. * @param additionalData additional data for the event
  2856. * @returns the new ActionEvent
  2857. */
  2858. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2859. /**
  2860. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2861. * @param scene the scene where the event occurred
  2862. * @param evt The original (browser) event
  2863. * @returns the new ActionEvent
  2864. */
  2865. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2866. /**
  2867. * Helper function to auto-create an ActionEvent from a primitive
  2868. * @param prim defines the target primitive
  2869. * @param pointerPos defines the pointer position
  2870. * @param evt The original (browser) event
  2871. * @param additionalData additional data for the event
  2872. * @returns the new ActionEvent
  2873. */
  2874. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2875. }
  2876. /**
  2877. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2878. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2880. */
  2881. class ActionManager {
  2882. private static _NothingTrigger;
  2883. private static _OnPickTrigger;
  2884. private static _OnLeftPickTrigger;
  2885. private static _OnRightPickTrigger;
  2886. private static _OnCenterPickTrigger;
  2887. private static _OnPickDownTrigger;
  2888. private static _OnDoublePickTrigger;
  2889. private static _OnPickUpTrigger;
  2890. private static _OnLongPressTrigger;
  2891. private static _OnPointerOverTrigger;
  2892. private static _OnPointerOutTrigger;
  2893. private static _OnEveryFrameTrigger;
  2894. private static _OnIntersectionEnterTrigger;
  2895. private static _OnIntersectionExitTrigger;
  2896. private static _OnKeyDownTrigger;
  2897. private static _OnKeyUpTrigger;
  2898. private static _OnPickOutTrigger;
  2899. /**
  2900. * Nothing
  2901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2902. */
  2903. static readonly NothingTrigger: number;
  2904. /**
  2905. * On pick
  2906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2907. */
  2908. static readonly OnPickTrigger: number;
  2909. /**
  2910. * On left pick
  2911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2912. */
  2913. static readonly OnLeftPickTrigger: number;
  2914. /**
  2915. * On right pick
  2916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2917. */
  2918. static readonly OnRightPickTrigger: number;
  2919. /**
  2920. * On center pick
  2921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2922. */
  2923. static readonly OnCenterPickTrigger: number;
  2924. /**
  2925. * On pick down
  2926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2927. */
  2928. static readonly OnPickDownTrigger: number;
  2929. /**
  2930. * On double pick
  2931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2932. */
  2933. static readonly OnDoublePickTrigger: number;
  2934. /**
  2935. * On pick up
  2936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2937. */
  2938. static readonly OnPickUpTrigger: number;
  2939. /**
  2940. * On pick out.
  2941. * This trigger will only be raised if you also declared a OnPickDown
  2942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2943. */
  2944. static readonly OnPickOutTrigger: number;
  2945. /**
  2946. * On long press
  2947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2948. */
  2949. static readonly OnLongPressTrigger: number;
  2950. /**
  2951. * On pointer over
  2952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2953. */
  2954. static readonly OnPointerOverTrigger: number;
  2955. /**
  2956. * On pointer out
  2957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2958. */
  2959. static readonly OnPointerOutTrigger: number;
  2960. /**
  2961. * On every frame
  2962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2963. */
  2964. static readonly OnEveryFrameTrigger: number;
  2965. /**
  2966. * On intersection enter
  2967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2968. */
  2969. static readonly OnIntersectionEnterTrigger: number;
  2970. /**
  2971. * On intersection exit
  2972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2973. */
  2974. static readonly OnIntersectionExitTrigger: number;
  2975. /**
  2976. * On key down
  2977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2978. */
  2979. static readonly OnKeyDownTrigger: number;
  2980. /**
  2981. * On key up
  2982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2983. */
  2984. static readonly OnKeyUpTrigger: number;
  2985. /** Gets the list of active triggers */
  2986. static Triggers: {
  2987. [key: string]: number;
  2988. };
  2989. /** Gets the list of actions */
  2990. actions: Action[];
  2991. /** Gets the cursor to use when hovering items */
  2992. hoverCursor: string;
  2993. private _scene;
  2994. /**
  2995. * Creates a new action manager
  2996. * @param scene defines the hosting scene
  2997. */
  2998. constructor(scene: Scene);
  2999. /**
  3000. * Releases all associated resources
  3001. */
  3002. dispose(): void;
  3003. /**
  3004. * Gets hosting scene
  3005. * @returns the hosting scene
  3006. */
  3007. getScene(): Scene;
  3008. /**
  3009. * Does this action manager handles actions of any of the given triggers
  3010. * @param triggers defines the triggers to be tested
  3011. * @return a boolean indicating whether one (or more) of the triggers is handled
  3012. */
  3013. hasSpecificTriggers(triggers: number[]): boolean;
  3014. /**
  3015. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3016. * speed.
  3017. * @param triggerA defines the trigger to be tested
  3018. * @param triggerB defines the trigger to be tested
  3019. * @return a boolean indicating whether one (or more) of the triggers is handled
  3020. */
  3021. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3022. /**
  3023. * Does this action manager handles actions of a given trigger
  3024. * @param trigger defines the trigger to be tested
  3025. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3026. * @return whether the trigger is handled
  3027. */
  3028. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3029. /**
  3030. * Does this action manager has pointer triggers
  3031. */
  3032. readonly hasPointerTriggers: boolean;
  3033. /**
  3034. * Does this action manager has pick triggers
  3035. */
  3036. readonly hasPickTriggers: boolean;
  3037. /**
  3038. * Does exist one action manager with at least one trigger
  3039. **/
  3040. static readonly HasTriggers: boolean;
  3041. /**
  3042. * Does exist one action manager with at least one pick trigger
  3043. **/
  3044. static readonly HasPickTriggers: boolean;
  3045. /**
  3046. * Does exist one action manager that handles actions of a given trigger
  3047. * @param trigger defines the trigger to be tested
  3048. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3049. **/
  3050. static HasSpecificTrigger(trigger: number): boolean;
  3051. /**
  3052. * Registers an action to this action manager
  3053. * @param action defines the action to be registered
  3054. * @return the action amended (prepared) after registration
  3055. */
  3056. registerAction(action: Action): Nullable<Action>;
  3057. /**
  3058. * Unregisters an action to this action manager
  3059. * @param action defines the action to be unregistered
  3060. * @return a boolean indicating whether the action has been unregistered
  3061. */
  3062. unregisterAction(action: Action): Boolean;
  3063. /**
  3064. * Process a specific trigger
  3065. * @param trigger defines the trigger to process
  3066. * @param evt defines the event details to be processed
  3067. */
  3068. processTrigger(trigger: number, evt?: ActionEvent): void;
  3069. /** @hidden */
  3070. _getEffectiveTarget(target: any, propertyPath: string): any;
  3071. /** @hidden */
  3072. _getProperty(propertyPath: string): string;
  3073. /**
  3074. * Serialize this manager to a JSON object
  3075. * @param name defines the property name to store this manager
  3076. * @returns a JSON representation of this manager
  3077. */
  3078. serialize(name: string): any;
  3079. /**
  3080. * Creates a new ActionManager from a JSON data
  3081. * @param parsedActions defines the JSON data to read from
  3082. * @param object defines the hosting mesh
  3083. * @param scene defines the hosting scene
  3084. */
  3085. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3086. /**
  3087. * Get a trigger name by index
  3088. * @param trigger defines the trigger index
  3089. * @returns a trigger name
  3090. */
  3091. static GetTriggerName(trigger: number): string;
  3092. }
  3093. }
  3094. declare module BABYLON {
  3095. /**
  3096. * A Condition applied to an Action
  3097. */
  3098. class Condition {
  3099. /**
  3100. * Internal only - manager for action
  3101. * @hidden
  3102. */
  3103. _actionManager: ActionManager;
  3104. /**
  3105. * Internal only
  3106. * @hidden
  3107. */
  3108. _evaluationId: number;
  3109. /**
  3110. * Internal only
  3111. * @hidden
  3112. */
  3113. _currentResult: boolean;
  3114. /**
  3115. * Creates a new Condition
  3116. * @param actionManager the manager of the action the condition is applied to
  3117. */
  3118. constructor(actionManager: ActionManager);
  3119. /**
  3120. * Check if the current condition is valid
  3121. * @returns a boolean
  3122. */
  3123. isValid(): boolean;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. _getProperty(propertyPath: string): string;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. _getEffectiveTarget(target: any, propertyPath: string): any;
  3134. /**
  3135. * Serialize placeholder for child classes
  3136. * @returns the serialized object
  3137. */
  3138. serialize(): any;
  3139. /**
  3140. * Internal only
  3141. * @hidden
  3142. */
  3143. protected _serialize(serializedCondition: any): any;
  3144. }
  3145. /**
  3146. * Defines specific conditional operators as extensions of Condition
  3147. */
  3148. class ValueCondition extends Condition {
  3149. /** path to specify the property of the target the conditional operator uses */
  3150. propertyPath: string;
  3151. /** the value compared by the conditional operator against the current value of the property */
  3152. value: any;
  3153. /** the conditional operator, default ValueCondition.IsEqual */
  3154. operator: number;
  3155. /**
  3156. * Internal only
  3157. * @hidden
  3158. */
  3159. private static _IsEqual;
  3160. /**
  3161. * Internal only
  3162. * @hidden
  3163. */
  3164. private static _IsDifferent;
  3165. /**
  3166. * Internal only
  3167. * @hidden
  3168. */
  3169. private static _IsGreater;
  3170. /**
  3171. * Internal only
  3172. * @hidden
  3173. */
  3174. private static _IsLesser;
  3175. /**
  3176. * returns the number for IsEqual
  3177. */
  3178. static readonly IsEqual: number;
  3179. /**
  3180. * Returns the number for IsDifferent
  3181. */
  3182. static readonly IsDifferent: number;
  3183. /**
  3184. * Returns the number for IsGreater
  3185. */
  3186. static readonly IsGreater: number;
  3187. /**
  3188. * Returns the number for IsLesser
  3189. */
  3190. static readonly IsLesser: number;
  3191. /**
  3192. * Internal only The action manager for the condition
  3193. * @hidden
  3194. */
  3195. _actionManager: ActionManager;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. private _target;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. private _effectiveTarget;
  3206. /**
  3207. * Internal only
  3208. * @hidden
  3209. */
  3210. private _property;
  3211. /**
  3212. * Creates a new ValueCondition
  3213. * @param actionManager manager for the action the condition applies to
  3214. * @param target for the action
  3215. * @param propertyPath path to specify the property of the target the conditional operator uses
  3216. * @param value the value compared by the conditional operator against the current value of the property
  3217. * @param operator the conditional operator, default ValueCondition.IsEqual
  3218. */
  3219. constructor(actionManager: ActionManager, target: any,
  3220. /** path to specify the property of the target the conditional operator uses */
  3221. propertyPath: string,
  3222. /** the value compared by the conditional operator against the current value of the property */
  3223. value: any,
  3224. /** the conditional operator, default ValueCondition.IsEqual */
  3225. operator?: number);
  3226. /**
  3227. * Compares the given value with the property value for the specified conditional operator
  3228. * @returns the result of the comparison
  3229. */
  3230. isValid(): boolean;
  3231. /**
  3232. * Serialize the ValueCondition into a JSON compatible object
  3233. * @returns serialization object
  3234. */
  3235. serialize(): any;
  3236. /**
  3237. * Gets the name of the conditional operator for the ValueCondition
  3238. * @param operator the conditional operator
  3239. * @returns the name
  3240. */
  3241. static GetOperatorName(operator: number): string;
  3242. }
  3243. /**
  3244. * Defines a predicate condition as an extension of Condition
  3245. */
  3246. class PredicateCondition extends Condition {
  3247. /** defines the predicate function used to validate the condition */
  3248. predicate: () => boolean;
  3249. /**
  3250. * Internal only - manager for action
  3251. * @hidden
  3252. */
  3253. _actionManager: ActionManager;
  3254. /**
  3255. * Creates a new PredicateCondition
  3256. * @param actionManager manager for the action the condition applies to
  3257. * @param predicate defines the predicate function used to validate the condition
  3258. */
  3259. constructor(actionManager: ActionManager,
  3260. /** defines the predicate function used to validate the condition */
  3261. predicate: () => boolean);
  3262. /**
  3263. * @returns the validity of the predicate condition
  3264. */
  3265. isValid(): boolean;
  3266. }
  3267. /**
  3268. * Defines a state condition as an extension of Condition
  3269. */
  3270. class StateCondition extends Condition {
  3271. value: string;
  3272. /**
  3273. * Internal only - manager for action
  3274. * @hidden
  3275. */
  3276. _actionManager: ActionManager;
  3277. /**
  3278. * Internal only
  3279. * @hidden
  3280. */
  3281. private _target;
  3282. /**
  3283. * Creates a new StateCondition
  3284. * @param actionManager manager for the action the condition applies to
  3285. * @param target of the condition
  3286. * @param value to compare with target state
  3287. */
  3288. constructor(actionManager: ActionManager, target: any, value: string);
  3289. /**
  3290. * @returns the validity of the state
  3291. */
  3292. isValid(): boolean;
  3293. /**
  3294. * Serialize the StateCondition into a JSON compatible object
  3295. * @returns serialization object
  3296. */
  3297. serialize(): any;
  3298. }
  3299. }
  3300. declare module BABYLON {
  3301. class SwitchBooleanAction extends Action {
  3302. propertyPath: string;
  3303. private _target;
  3304. private _effectiveTarget;
  3305. private _property;
  3306. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3307. /** @hidden */
  3308. _prepare(): void;
  3309. execute(): void;
  3310. serialize(parent: any): any;
  3311. }
  3312. class SetStateAction extends Action {
  3313. value: string;
  3314. private _target;
  3315. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3316. execute(): void;
  3317. serialize(parent: any): any;
  3318. }
  3319. class SetValueAction extends Action {
  3320. propertyPath: string;
  3321. value: any;
  3322. private _target;
  3323. private _effectiveTarget;
  3324. private _property;
  3325. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3326. /** @hidden */
  3327. _prepare(): void;
  3328. execute(): void;
  3329. serialize(parent: any): any;
  3330. }
  3331. class IncrementValueAction extends Action {
  3332. propertyPath: string;
  3333. value: any;
  3334. private _target;
  3335. private _effectiveTarget;
  3336. private _property;
  3337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3338. /** @hidden */
  3339. _prepare(): void;
  3340. execute(): void;
  3341. serialize(parent: any): any;
  3342. }
  3343. class PlayAnimationAction extends Action {
  3344. from: number;
  3345. to: number;
  3346. loop?: boolean | undefined;
  3347. private _target;
  3348. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3349. /** @hidden */
  3350. _prepare(): void;
  3351. execute(): void;
  3352. serialize(parent: any): any;
  3353. }
  3354. class StopAnimationAction extends Action {
  3355. private _target;
  3356. constructor(triggerOptions: any, target: any, condition?: Condition);
  3357. /** @hidden */
  3358. _prepare(): void;
  3359. execute(): void;
  3360. serialize(parent: any): any;
  3361. }
  3362. class DoNothingAction extends Action {
  3363. constructor(triggerOptions?: any, condition?: Condition);
  3364. execute(): void;
  3365. serialize(parent: any): any;
  3366. }
  3367. class CombineAction extends Action {
  3368. children: Action[];
  3369. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3370. /** @hidden */
  3371. _prepare(): void;
  3372. execute(evt: ActionEvent): void;
  3373. serialize(parent: any): any;
  3374. }
  3375. class ExecuteCodeAction extends Action {
  3376. func: (evt: ActionEvent) => void;
  3377. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3378. execute(evt: ActionEvent): void;
  3379. }
  3380. class SetParentAction extends Action {
  3381. private _parent;
  3382. private _target;
  3383. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3384. /** @hidden */
  3385. _prepare(): void;
  3386. execute(): void;
  3387. serialize(parent: any): any;
  3388. }
  3389. class PlaySoundAction extends Action {
  3390. private _sound;
  3391. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3392. /** @hidden */
  3393. _prepare(): void;
  3394. execute(): void;
  3395. serialize(parent: any): any;
  3396. }
  3397. class StopSoundAction extends Action {
  3398. private _sound;
  3399. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3400. /** @hidden */
  3401. _prepare(): void;
  3402. execute(): void;
  3403. serialize(parent: any): any;
  3404. }
  3405. }
  3406. declare module BABYLON {
  3407. class InterpolateValueAction extends Action {
  3408. propertyPath: string;
  3409. value: any;
  3410. duration: number;
  3411. stopOtherAnimations?: boolean | undefined;
  3412. onInterpolationDone?: (() => void) | undefined;
  3413. private _target;
  3414. private _effectiveTarget;
  3415. private _property;
  3416. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3417. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3418. /** @hidden */
  3419. _prepare(): void;
  3420. execute(): void;
  3421. serialize(parent: any): any;
  3422. }
  3423. }
  3424. declare module BABYLON {
  3425. /**
  3426. * Class used to store an actual running animation
  3427. */
  3428. class Animatable {
  3429. /** defines the target object */
  3430. target: any;
  3431. /** defines the starting frame number (default is 0) */
  3432. fromFrame: number;
  3433. /** defines the ending frame number (default is 100) */
  3434. toFrame: number;
  3435. /** defines if the animation must loop (default is false) */
  3436. loopAnimation: boolean;
  3437. /** defines a callback to call when animation ends if it is not looping */
  3438. onAnimationEnd?: (() => void) | null | undefined;
  3439. private _localDelayOffset;
  3440. private _pausedDelay;
  3441. private _runtimeAnimations;
  3442. private _paused;
  3443. private _scene;
  3444. private _speedRatio;
  3445. private _weight;
  3446. private _syncRoot;
  3447. /**
  3448. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3449. * This will only apply for non looping animation (default is true)
  3450. */
  3451. disposeOnEnd: boolean;
  3452. /**
  3453. * Gets a boolean indicating if the animation has started
  3454. */
  3455. animationStarted: boolean;
  3456. /**
  3457. * Observer raised when the animation ends
  3458. */
  3459. onAnimationEndObservable: Observable<Animatable>;
  3460. /**
  3461. * Gets the root Animatable used to synchronize and normalize animations
  3462. */
  3463. readonly syncRoot: Animatable;
  3464. /**
  3465. * Gets the current frame of the first RuntimeAnimation
  3466. * Used to synchronize Animatables
  3467. */
  3468. readonly masterFrame: number;
  3469. /**
  3470. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3471. */
  3472. weight: number;
  3473. /**
  3474. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3475. */
  3476. speedRatio: number;
  3477. /**
  3478. * Creates a new Animatable
  3479. * @param scene defines the hosting scene
  3480. * @param target defines the target object
  3481. * @param fromFrame defines the starting frame number (default is 0)
  3482. * @param toFrame defines the ending frame number (default is 100)
  3483. * @param loopAnimation defines if the animation must loop (default is false)
  3484. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3485. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3486. * @param animations defines a group of animation to add to the new Animatable
  3487. */
  3488. constructor(scene: Scene,
  3489. /** defines the target object */
  3490. target: any,
  3491. /** defines the starting frame number (default is 0) */
  3492. fromFrame?: number,
  3493. /** defines the ending frame number (default is 100) */
  3494. toFrame?: number,
  3495. /** defines if the animation must loop (default is false) */
  3496. loopAnimation?: boolean, speedRatio?: number,
  3497. /** defines a callback to call when animation ends if it is not looping */
  3498. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3499. /**
  3500. * Synchronize and normalize current Animatable with a source Animatable
  3501. * This is useful when using animation weights and when animations are not of the same length
  3502. * @param root defines the root Animatable to synchronize with
  3503. * @returns the current Animatable
  3504. */
  3505. syncWith(root: Animatable): Animatable;
  3506. /**
  3507. * Gets the list of runtime animations
  3508. * @returns an array of RuntimeAnimation
  3509. */
  3510. getAnimations(): RuntimeAnimation[];
  3511. /**
  3512. * Adds more animations to the current animatable
  3513. * @param target defines the target of the animations
  3514. * @param animations defines the new animations to add
  3515. */
  3516. appendAnimations(target: any, animations: Animation[]): void;
  3517. /**
  3518. * Gets the source animation for a specific property
  3519. * @param property defines the propertyu to look for
  3520. * @returns null or the source animation for the given property
  3521. */
  3522. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3523. /**
  3524. * Gets the runtime animation for a specific property
  3525. * @param property defines the propertyu to look for
  3526. * @returns null or the runtime animation for the given property
  3527. */
  3528. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3529. /**
  3530. * Resets the animatable to its original state
  3531. */
  3532. reset(): void;
  3533. /**
  3534. * Allows the animatable to blend with current running animations
  3535. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3536. * @param blendingSpeed defines the blending speed to use
  3537. */
  3538. enableBlending(blendingSpeed: number): void;
  3539. /**
  3540. * Disable animation blending
  3541. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3542. */
  3543. disableBlending(): void;
  3544. /**
  3545. * Jump directly to a given frame
  3546. * @param frame defines the frame to jump to
  3547. */
  3548. goToFrame(frame: number): void;
  3549. /**
  3550. * Pause the animation
  3551. */
  3552. pause(): void;
  3553. /**
  3554. * Restart the animation
  3555. */
  3556. restart(): void;
  3557. private _raiseOnAnimationEnd;
  3558. /**
  3559. * Stop and delete the current animation
  3560. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3561. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3562. */
  3563. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3564. /**
  3565. * Wait asynchronously for the animation to end
  3566. * @returns a promise which will be fullfilled when the animation ends
  3567. */
  3568. waitAsync(): Promise<Animatable>;
  3569. /** @hidden */
  3570. _animate(delay: number): boolean;
  3571. }
  3572. }
  3573. declare module BABYLON {
  3574. /**
  3575. * Represents the range of an animation
  3576. */
  3577. class AnimationRange {
  3578. /**The name of the animation range**/
  3579. name: string;
  3580. /**The starting frame of the animation */
  3581. from: number;
  3582. /**The ending frame of the animation*/
  3583. to: number;
  3584. /**
  3585. * Initializes the range of an animation
  3586. * @param name The name of the animation range
  3587. * @param from The starting frame of the animation
  3588. * @param to The ending frame of the animation
  3589. */
  3590. constructor(
  3591. /**The name of the animation range**/
  3592. name: string,
  3593. /**The starting frame of the animation */
  3594. from: number,
  3595. /**The ending frame of the animation*/
  3596. to: number);
  3597. /**
  3598. * Makes a copy of the animation range
  3599. * @returns A copy of the animation range
  3600. */
  3601. clone(): AnimationRange;
  3602. }
  3603. /**
  3604. * Composed of a frame, and an action function
  3605. */
  3606. class AnimationEvent {
  3607. /** The frame for which the event is triggered **/
  3608. frame: number;
  3609. /** The event to perform when triggered **/
  3610. action: (currentFrame: number) => void;
  3611. /** Specifies if the event should be triggered only once**/
  3612. onlyOnce?: boolean | undefined;
  3613. /**
  3614. * Specifies if the animation event is done
  3615. */
  3616. isDone: boolean;
  3617. /**
  3618. * Initializes the animation event
  3619. * @param frame The frame for which the event is triggered
  3620. * @param action The event to perform when triggered
  3621. * @param onlyOnce Specifies if the event should be triggered only once
  3622. */
  3623. constructor(
  3624. /** The frame for which the event is triggered **/
  3625. frame: number,
  3626. /** The event to perform when triggered **/
  3627. action: (currentFrame: number) => void,
  3628. /** Specifies if the event should be triggered only once**/
  3629. onlyOnce?: boolean | undefined);
  3630. /** @hidden */
  3631. _clone(): AnimationEvent;
  3632. }
  3633. /**
  3634. * A cursor which tracks a point on a path
  3635. */
  3636. class PathCursor {
  3637. private path;
  3638. /**
  3639. * Stores path cursor callbacks for when an onchange event is triggered
  3640. */
  3641. private _onchange;
  3642. /**
  3643. * The value of the path cursor
  3644. */
  3645. value: number;
  3646. /**
  3647. * The animation array of the path cursor
  3648. */
  3649. animations: Animation[];
  3650. /**
  3651. * Initializes the path cursor
  3652. * @param path The path to track
  3653. */
  3654. constructor(path: Path2);
  3655. /**
  3656. * Gets the cursor point on the path
  3657. * @returns A point on the path cursor at the cursor location
  3658. */
  3659. getPoint(): Vector3;
  3660. /**
  3661. * Moves the cursor ahead by the step amount
  3662. * @param step The amount to move the cursor forward
  3663. * @returns This path cursor
  3664. */
  3665. moveAhead(step?: number): PathCursor;
  3666. /**
  3667. * Moves the cursor behind by the step amount
  3668. * @param step The amount to move the cursor back
  3669. * @returns This path cursor
  3670. */
  3671. moveBack(step?: number): PathCursor;
  3672. /**
  3673. * Moves the cursor by the step amount
  3674. * If the step amount is greater than one, an exception is thrown
  3675. * @param step The amount to move the cursor
  3676. * @returns This path cursor
  3677. */
  3678. move(step: number): PathCursor;
  3679. /**
  3680. * Ensures that the value is limited between zero and one
  3681. * @returns This path cursor
  3682. */
  3683. private ensureLimits;
  3684. /**
  3685. * Runs onchange callbacks on change (used by the animation engine)
  3686. * @returns This path cursor
  3687. */
  3688. private raiseOnChange;
  3689. /**
  3690. * Executes a function on change
  3691. * @param f A path cursor onchange callback
  3692. * @returns This path cursor
  3693. */
  3694. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3695. }
  3696. /**
  3697. * Defines an interface which represents an animation key frame
  3698. */
  3699. interface IAnimationKey {
  3700. /**
  3701. * Frame of the key frame
  3702. */
  3703. frame: number;
  3704. /**
  3705. * Value at the specifies key frame
  3706. */
  3707. value: any;
  3708. /**
  3709. * The input tangent for the cubic hermite spline
  3710. */
  3711. inTangent?: any;
  3712. /**
  3713. * The output tangent for the cubic hermite spline
  3714. */
  3715. outTangent?: any;
  3716. /**
  3717. * The animation interpolation type
  3718. */
  3719. interpolation?: AnimationKeyInterpolation;
  3720. }
  3721. /**
  3722. * Enum for the animation key frame interpolation type
  3723. */
  3724. enum AnimationKeyInterpolation {
  3725. /**
  3726. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3727. */
  3728. STEP = 1
  3729. }
  3730. /**
  3731. * Class used to store any kind of animation
  3732. */
  3733. class Animation {
  3734. /**Name of the animation */
  3735. name: string;
  3736. /**Property to animate */
  3737. targetProperty: string;
  3738. /**The frames per second of the animation */
  3739. framePerSecond: number;
  3740. /**The data type of the animation */
  3741. dataType: number;
  3742. /**The loop mode of the animation */
  3743. loopMode?: number | undefined;
  3744. /**Specifies if blending should be enabled */
  3745. enableBlending?: boolean | undefined;
  3746. /**
  3747. * Use matrix interpolation instead of using direct key value when animating matrices
  3748. */
  3749. static AllowMatricesInterpolation: boolean;
  3750. /**
  3751. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3752. */
  3753. static AllowMatrixDecomposeForInterpolation: boolean;
  3754. /**
  3755. * Stores the key frames of the animation
  3756. */
  3757. private _keys;
  3758. /**
  3759. * Stores the easing function of the animation
  3760. */
  3761. private _easingFunction;
  3762. /**
  3763. * @hidden Internal use only
  3764. */
  3765. _runtimeAnimations: RuntimeAnimation[];
  3766. /**
  3767. * The set of event that will be linked to this animation
  3768. */
  3769. private _events;
  3770. /**
  3771. * Stores an array of target property paths
  3772. */
  3773. targetPropertyPath: string[];
  3774. /**
  3775. * Stores the blending speed of the animation
  3776. */
  3777. blendingSpeed: number;
  3778. /**
  3779. * Stores the animation ranges for the animation
  3780. */
  3781. private _ranges;
  3782. /**
  3783. * @hidden Internal use
  3784. */
  3785. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3786. /**
  3787. * Sets up an animation
  3788. * @param property The property to animate
  3789. * @param animationType The animation type to apply
  3790. * @param framePerSecond The frames per second of the animation
  3791. * @param easingFunction The easing function used in the animation
  3792. * @returns The created animation
  3793. */
  3794. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3795. /**
  3796. * Create and start an animation on a node
  3797. * @param name defines the name of the global animation that will be run on all nodes
  3798. * @param node defines the root node where the animation will take place
  3799. * @param targetProperty defines property to animate
  3800. * @param framePerSecond defines the number of frame per second yo use
  3801. * @param totalFrame defines the number of frames in total
  3802. * @param from defines the initial value
  3803. * @param to defines the final value
  3804. * @param loopMode defines which loop mode you want to use (off by default)
  3805. * @param easingFunction defines the easing function to use (linear by default)
  3806. * @param onAnimationEnd defines the callback to call when animation end
  3807. * @returns the animatable created for this animation
  3808. */
  3809. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3810. /**
  3811. * Create and start an animation on a node and its descendants
  3812. * @param name defines the name of the global animation that will be run on all nodes
  3813. * @param node defines the root node where the animation will take place
  3814. * @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
  3815. * @param targetProperty defines property to animate
  3816. * @param framePerSecond defines the number of frame per second to use
  3817. * @param totalFrame defines the number of frames in total
  3818. * @param from defines the initial value
  3819. * @param to defines the final value
  3820. * @param loopMode defines which loop mode you want to use (off by default)
  3821. * @param easingFunction defines the easing function to use (linear by default)
  3822. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3823. * @returns the list of animatables created for all nodes
  3824. * @example https://www.babylonjs-playground.com/#MH0VLI
  3825. */
  3826. 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[]>;
  3827. /**
  3828. * Creates a new animation, merges it with the existing animations and starts it
  3829. * @param name Name of the animation
  3830. * @param node Node which contains the scene that begins the animations
  3831. * @param targetProperty Specifies which property to animate
  3832. * @param framePerSecond The frames per second of the animation
  3833. * @param totalFrame The total number of frames
  3834. * @param from The frame at the beginning of the animation
  3835. * @param to The frame at the end of the animation
  3836. * @param loopMode Specifies the loop mode of the animation
  3837. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3838. * @param onAnimationEnd Callback to run once the animation is complete
  3839. * @returns Nullable animation
  3840. */
  3841. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3842. /**
  3843. * Transition property of an host to the target Value
  3844. * @param property The property to transition
  3845. * @param targetValue The target Value of the property
  3846. * @param host The object where the property to animate belongs
  3847. * @param scene Scene used to run the animation
  3848. * @param frameRate Framerate (in frame/s) to use
  3849. * @param transition The transition type we want to use
  3850. * @param duration The duration of the animation, in milliseconds
  3851. * @param onAnimationEnd Callback trigger at the end of the animation
  3852. * @returns Nullable animation
  3853. */
  3854. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3855. /**
  3856. * Return the array of runtime animations currently using this animation
  3857. */
  3858. readonly runtimeAnimations: RuntimeAnimation[];
  3859. /**
  3860. * Specifies if any of the runtime animations are currently running
  3861. */
  3862. readonly hasRunningRuntimeAnimations: boolean;
  3863. /**
  3864. * Initializes the animation
  3865. * @param name Name of the animation
  3866. * @param targetProperty Property to animate
  3867. * @param framePerSecond The frames per second of the animation
  3868. * @param dataType The data type of the animation
  3869. * @param loopMode The loop mode of the animation
  3870. * @param enableBlendings Specifies if blending should be enabled
  3871. */
  3872. constructor(
  3873. /**Name of the animation */
  3874. name: string,
  3875. /**Property to animate */
  3876. targetProperty: string,
  3877. /**The frames per second of the animation */
  3878. framePerSecond: number,
  3879. /**The data type of the animation */
  3880. dataType: number,
  3881. /**The loop mode of the animation */
  3882. loopMode?: number | undefined,
  3883. /**Specifies if blending should be enabled */
  3884. enableBlending?: boolean | undefined);
  3885. /**
  3886. * Converts the animation to a string
  3887. * @param fullDetails support for multiple levels of logging within scene loading
  3888. * @returns String form of the animation
  3889. */
  3890. toString(fullDetails?: boolean): string;
  3891. /**
  3892. * Add an event to this animation
  3893. * @param event Event to add
  3894. */
  3895. addEvent(event: AnimationEvent): void;
  3896. /**
  3897. * Remove all events found at the given frame
  3898. * @param frame The frame to remove events from
  3899. */
  3900. removeEvents(frame: number): void;
  3901. /**
  3902. * Retrieves all the events from the animation
  3903. * @returns Events from the animation
  3904. */
  3905. getEvents(): AnimationEvent[];
  3906. /**
  3907. * Creates an animation range
  3908. * @param name Name of the animation range
  3909. * @param from Starting frame of the animation range
  3910. * @param to Ending frame of the animation
  3911. */
  3912. createRange(name: string, from: number, to: number): void;
  3913. /**
  3914. * Deletes an animation range by name
  3915. * @param name Name of the animation range to delete
  3916. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3917. */
  3918. deleteRange(name: string, deleteFrames?: boolean): void;
  3919. /**
  3920. * Gets the animation range by name, or null if not defined
  3921. * @param name Name of the animation range
  3922. * @returns Nullable animation range
  3923. */
  3924. getRange(name: string): Nullable<AnimationRange>;
  3925. /**
  3926. * Gets the key frames from the animation
  3927. * @returns The key frames of the animation
  3928. */
  3929. getKeys(): Array<IAnimationKey>;
  3930. /**
  3931. * Gets the highest frame rate of the animation
  3932. * @returns Highest frame rate of the animation
  3933. */
  3934. getHighestFrame(): number;
  3935. /**
  3936. * Gets the easing function of the animation
  3937. * @returns Easing function of the animation
  3938. */
  3939. getEasingFunction(): IEasingFunction;
  3940. /**
  3941. * Sets the easing function of the animation
  3942. * @param easingFunction A custom mathematical formula for animation
  3943. */
  3944. setEasingFunction(easingFunction: EasingFunction): void;
  3945. /**
  3946. * Interpolates a scalar linearly
  3947. * @param startValue Start value of the animation curve
  3948. * @param endValue End value of the animation curve
  3949. * @param gradient Scalar amount to interpolate
  3950. * @returns Interpolated scalar value
  3951. */
  3952. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3953. /**
  3954. * Interpolates a scalar cubically
  3955. * @param startValue Start value of the animation curve
  3956. * @param outTangent End tangent of the animation
  3957. * @param endValue End value of the animation curve
  3958. * @param inTangent Start tangent of the animation curve
  3959. * @param gradient Scalar amount to interpolate
  3960. * @returns Interpolated scalar value
  3961. */
  3962. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3963. /**
  3964. * Interpolates a quaternion using a spherical linear interpolation
  3965. * @param startValue Start value of the animation curve
  3966. * @param endValue End value of the animation curve
  3967. * @param gradient Scalar amount to interpolate
  3968. * @returns Interpolated quaternion value
  3969. */
  3970. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3971. /**
  3972. * Interpolates a quaternion cubically
  3973. * @param startValue Start value of the animation curve
  3974. * @param outTangent End tangent of the animation curve
  3975. * @param endValue End value of the animation curve
  3976. * @param inTangent Start tangent of the animation curve
  3977. * @param gradient Scalar amount to interpolate
  3978. * @returns Interpolated quaternion value
  3979. */
  3980. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3981. /**
  3982. * Interpolates a Vector3 linearl
  3983. * @param startValue Start value of the animation curve
  3984. * @param endValue End value of the animation curve
  3985. * @param gradient Scalar amount to interpolate
  3986. * @returns Interpolated scalar value
  3987. */
  3988. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3989. /**
  3990. * Interpolates a Vector3 cubically
  3991. * @param startValue Start value of the animation curve
  3992. * @param outTangent End tangent of the animation
  3993. * @param endValue End value of the animation curve
  3994. * @param inTangent Start tangent of the animation curve
  3995. * @param gradient Scalar amount to interpolate
  3996. * @returns InterpolatedVector3 value
  3997. */
  3998. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3999. /**
  4000. * Interpolates a Vector2 linearly
  4001. * @param startValue Start value of the animation curve
  4002. * @param endValue End value of the animation curve
  4003. * @param gradient Scalar amount to interpolate
  4004. * @returns Interpolated Vector2 value
  4005. */
  4006. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4007. /**
  4008. * Interpolates a Vector2 cubically
  4009. * @param startValue Start value of the animation curve
  4010. * @param outTangent End tangent of the animation
  4011. * @param endValue End value of the animation curve
  4012. * @param inTangent Start tangent of the animation curve
  4013. * @param gradient Scalar amount to interpolate
  4014. * @returns Interpolated Vector2 value
  4015. */
  4016. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4017. /**
  4018. * Interpolates a size linearly
  4019. * @param startValue Start value of the animation curve
  4020. * @param endValue End value of the animation curve
  4021. * @param gradient Scalar amount to interpolate
  4022. * @returns Interpolated Size value
  4023. */
  4024. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4025. /**
  4026. * Interpolates a Color3 linearly
  4027. * @param startValue Start value of the animation curve
  4028. * @param endValue End value of the animation curve
  4029. * @param gradient Scalar amount to interpolate
  4030. * @returns Interpolated Color3 value
  4031. */
  4032. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4033. /**
  4034. * @hidden Internal use only
  4035. */
  4036. _getKeyValue(value: any): any;
  4037. /**
  4038. * @hidden Internal use only
  4039. */
  4040. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4041. /**
  4042. * Defines the function to use to interpolate matrices
  4043. * @param startValue defines the start matrix
  4044. * @param endValue defines the end matrix
  4045. * @param gradient defines the gradient between both matrices
  4046. * @param result defines an optional target matrix where to store the interpolation
  4047. * @returns the interpolated matrix
  4048. */
  4049. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4050. /**
  4051. * Makes a copy of the animation
  4052. * @returns Cloned animation
  4053. */
  4054. clone(): Animation;
  4055. /**
  4056. * Sets the key frames of the animation
  4057. * @param values The animation key frames to set
  4058. */
  4059. setKeys(values: Array<IAnimationKey>): void;
  4060. /**
  4061. * Serializes the animation to an object
  4062. * @returns Serialized object
  4063. */
  4064. serialize(): any;
  4065. /**
  4066. * Float animation type
  4067. */
  4068. private static _ANIMATIONTYPE_FLOAT;
  4069. /**
  4070. * Vector3 animation type
  4071. */
  4072. private static _ANIMATIONTYPE_VECTOR3;
  4073. /**
  4074. * Quaternion animation type
  4075. */
  4076. private static _ANIMATIONTYPE_QUATERNION;
  4077. /**
  4078. * Matrix animation type
  4079. */
  4080. private static _ANIMATIONTYPE_MATRIX;
  4081. /**
  4082. * Color3 animation type
  4083. */
  4084. private static _ANIMATIONTYPE_COLOR3;
  4085. /**
  4086. * Vector2 animation type
  4087. */
  4088. private static _ANIMATIONTYPE_VECTOR2;
  4089. /**
  4090. * Size animation type
  4091. */
  4092. private static _ANIMATIONTYPE_SIZE;
  4093. /**
  4094. * Relative Loop Mode
  4095. */
  4096. private static _ANIMATIONLOOPMODE_RELATIVE;
  4097. /**
  4098. * Cycle Loop Mode
  4099. */
  4100. private static _ANIMATIONLOOPMODE_CYCLE;
  4101. /**
  4102. * Constant Loop Mode
  4103. */
  4104. private static _ANIMATIONLOOPMODE_CONSTANT;
  4105. /**
  4106. * Get the float animation type
  4107. */
  4108. static readonly ANIMATIONTYPE_FLOAT: number;
  4109. /**
  4110. * Get the Vector3 animation type
  4111. */
  4112. static readonly ANIMATIONTYPE_VECTOR3: number;
  4113. /**
  4114. * Get the Vector2 animation type
  4115. */
  4116. static readonly ANIMATIONTYPE_VECTOR2: number;
  4117. /**
  4118. * Get the Size animation type
  4119. */
  4120. static readonly ANIMATIONTYPE_SIZE: number;
  4121. /**
  4122. * Get the Quaternion animation type
  4123. */
  4124. static readonly ANIMATIONTYPE_QUATERNION: number;
  4125. /**
  4126. * Get the Matrix animation type
  4127. */
  4128. static readonly ANIMATIONTYPE_MATRIX: number;
  4129. /**
  4130. * Get the Color3 animation type
  4131. */
  4132. static readonly ANIMATIONTYPE_COLOR3: number;
  4133. /**
  4134. * Get the Relative Loop Mode
  4135. */
  4136. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4137. /**
  4138. * Get the Cycle Loop Mode
  4139. */
  4140. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4141. /**
  4142. * Get the Constant Loop Mode
  4143. */
  4144. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4145. /** @hidden */
  4146. static _UniversalLerp(left: any, right: any, amount: number): any;
  4147. /**
  4148. * Parses an animation object and creates an animation
  4149. * @param parsedAnimation Parsed animation object
  4150. * @returns Animation object
  4151. */
  4152. static Parse(parsedAnimation: any): Animation;
  4153. /**
  4154. * Appends the serialized animations from the source animations
  4155. * @param source Source containing the animations
  4156. * @param destination Target to store the animations
  4157. */
  4158. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * This class defines the direct association between an animation and a target
  4164. */
  4165. class TargetedAnimation {
  4166. animation: Animation;
  4167. target: any;
  4168. }
  4169. /**
  4170. * Use this class to create coordinated animations on multiple targets
  4171. */
  4172. class AnimationGroup implements IDisposable {
  4173. name: string;
  4174. private _scene;
  4175. private _targetedAnimations;
  4176. private _animatables;
  4177. private _from;
  4178. private _to;
  4179. private _isStarted;
  4180. private _speedRatio;
  4181. onAnimationEndObservable: Observable<TargetedAnimation>;
  4182. /**
  4183. * This observable will notify when all animations have ended.
  4184. */
  4185. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4186. /**
  4187. * This observable will notify when all animations have paused.
  4188. */
  4189. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4190. /**
  4191. * Gets the first frame
  4192. */
  4193. readonly from: number;
  4194. /**
  4195. * Gets the last frame
  4196. */
  4197. readonly to: number;
  4198. /**
  4199. * Define if the animations are started
  4200. */
  4201. readonly isStarted: boolean;
  4202. /**
  4203. * Gets or sets the speed ratio to use for all animations
  4204. */
  4205. /**
  4206. * Gets or sets the speed ratio to use for all animations
  4207. */
  4208. speedRatio: number;
  4209. /**
  4210. * Gets the targeted animations for this animation group
  4211. */
  4212. readonly targetedAnimations: Array<TargetedAnimation>;
  4213. /**
  4214. * returning the list of animatables controlled by this animation group.
  4215. */
  4216. readonly animatables: Array<Animatable>;
  4217. constructor(name: string, scene?: Nullable<Scene>);
  4218. /**
  4219. * Add an animation (with its target) in the group
  4220. * @param animation defines the animation we want to add
  4221. * @param target defines the target of the animation
  4222. * @returns the {BABYLON.TargetedAnimation} object
  4223. */
  4224. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4225. /**
  4226. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4227. * It can add constant keys at begin or end
  4228. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4229. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4230. */
  4231. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4232. /**
  4233. * Start all animations on given targets
  4234. * @param loop defines if animations must loop
  4235. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4236. * @param from defines the from key (optional)
  4237. * @param to defines the to key (optional)
  4238. * @returns the current animation group
  4239. */
  4240. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4241. /**
  4242. * Pause all animations
  4243. */
  4244. pause(): AnimationGroup;
  4245. /**
  4246. * Play all animations to initial state
  4247. * This function will start() the animations if they were not started or will restart() them if they were paused
  4248. * @param loop defines if animations must loop
  4249. */
  4250. play(loop?: boolean): AnimationGroup;
  4251. /**
  4252. * Reset all animations to initial state
  4253. */
  4254. reset(): AnimationGroup;
  4255. /**
  4256. * Restart animations from key 0
  4257. */
  4258. restart(): AnimationGroup;
  4259. /**
  4260. * Stop all animations
  4261. */
  4262. stop(): AnimationGroup;
  4263. /**
  4264. * Set animation weight for all animatables
  4265. * @param weight defines the weight to use
  4266. * @return the animationGroup
  4267. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4268. */
  4269. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4270. /**
  4271. * Synchronize and normalize all animatables with a source animatable
  4272. * @param root defines the root animatable to synchronize with
  4273. * @return the animationGroup
  4274. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4275. */
  4276. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4277. /**
  4278. * Goes to a specific frame in this animation group
  4279. * @param frame the frame number to go to
  4280. * @return the animationGroup
  4281. */
  4282. goToFrame(frame: number): AnimationGroup;
  4283. /**
  4284. * Dispose all associated resources
  4285. */
  4286. dispose(): void;
  4287. private _checkAnimationGroupEnded;
  4288. }
  4289. }
  4290. declare module BABYLON {
  4291. /**
  4292. * Class used to override all child animations of a given target
  4293. */
  4294. class AnimationPropertiesOverride {
  4295. /**
  4296. * Gets or sets a value indicating if animation blending must be used
  4297. */
  4298. enableBlending: boolean;
  4299. /**
  4300. * Gets or sets the blending speed to use when enableBlending is true
  4301. */
  4302. blendingSpeed: number;
  4303. /**
  4304. * Gets or sets the default loop mode to use
  4305. */
  4306. loopMode: number;
  4307. }
  4308. }
  4309. declare module BABYLON {
  4310. interface IEasingFunction {
  4311. ease(gradient: number): number;
  4312. }
  4313. class EasingFunction implements IEasingFunction {
  4314. private static _EASINGMODE_EASEIN;
  4315. private static _EASINGMODE_EASEOUT;
  4316. private static _EASINGMODE_EASEINOUT;
  4317. static readonly EASINGMODE_EASEIN: number;
  4318. static readonly EASINGMODE_EASEOUT: number;
  4319. static readonly EASINGMODE_EASEINOUT: number;
  4320. private _easingMode;
  4321. setEasingMode(easingMode: number): void;
  4322. getEasingMode(): number;
  4323. easeInCore(gradient: number): number;
  4324. ease(gradient: number): number;
  4325. }
  4326. class CircleEase extends EasingFunction implements IEasingFunction {
  4327. easeInCore(gradient: number): number;
  4328. }
  4329. class BackEase extends EasingFunction implements IEasingFunction {
  4330. amplitude: number;
  4331. constructor(amplitude?: number);
  4332. easeInCore(gradient: number): number;
  4333. }
  4334. class BounceEase extends EasingFunction implements IEasingFunction {
  4335. bounces: number;
  4336. bounciness: number;
  4337. constructor(bounces?: number, bounciness?: number);
  4338. easeInCore(gradient: number): number;
  4339. }
  4340. class CubicEase extends EasingFunction implements IEasingFunction {
  4341. easeInCore(gradient: number): number;
  4342. }
  4343. class ElasticEase extends EasingFunction implements IEasingFunction {
  4344. oscillations: number;
  4345. springiness: number;
  4346. constructor(oscillations?: number, springiness?: number);
  4347. easeInCore(gradient: number): number;
  4348. }
  4349. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4350. exponent: number;
  4351. constructor(exponent?: number);
  4352. easeInCore(gradient: number): number;
  4353. }
  4354. class PowerEase extends EasingFunction implements IEasingFunction {
  4355. power: number;
  4356. constructor(power?: number);
  4357. easeInCore(gradient: number): number;
  4358. }
  4359. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4360. easeInCore(gradient: number): number;
  4361. }
  4362. class QuarticEase extends EasingFunction implements IEasingFunction {
  4363. easeInCore(gradient: number): number;
  4364. }
  4365. class QuinticEase extends EasingFunction implements IEasingFunction {
  4366. easeInCore(gradient: number): number;
  4367. }
  4368. class SineEase extends EasingFunction implements IEasingFunction {
  4369. easeInCore(gradient: number): number;
  4370. }
  4371. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4372. x1: number;
  4373. y1: number;
  4374. x2: number;
  4375. y2: number;
  4376. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4377. easeInCore(gradient: number): number;
  4378. }
  4379. }
  4380. declare module BABYLON {
  4381. /**
  4382. * Defines a runtime animation
  4383. */
  4384. class RuntimeAnimation {
  4385. private _events;
  4386. /**
  4387. * The current frame of the runtime animation
  4388. */
  4389. private _currentFrame;
  4390. /**
  4391. * The animation used by the runtime animation
  4392. */
  4393. private _animation;
  4394. /**
  4395. * The target of the runtime animation
  4396. */
  4397. private _target;
  4398. /**
  4399. * The initiating animatable
  4400. */
  4401. private _host;
  4402. /**
  4403. * The original value of the runtime animation
  4404. */
  4405. private _originalValue;
  4406. /**
  4407. * The original blend value of the runtime animation
  4408. */
  4409. private _originalBlendValue;
  4410. /**
  4411. * The offsets cache of the runtime animation
  4412. */
  4413. private _offsetsCache;
  4414. /**
  4415. * The high limits cache of the runtime animation
  4416. */
  4417. private _highLimitsCache;
  4418. /**
  4419. * Specifies if the runtime animation has been stopped
  4420. */
  4421. private _stopped;
  4422. /**
  4423. * The blending factor of the runtime animation
  4424. */
  4425. private _blendingFactor;
  4426. /**
  4427. * The BabylonJS scene
  4428. */
  4429. private _scene;
  4430. /**
  4431. * The current value of the runtime animation
  4432. */
  4433. private _currentValue;
  4434. /** @hidden */
  4435. _workValue: any;
  4436. /**
  4437. * The active target of the runtime animation
  4438. */
  4439. private _activeTarget;
  4440. /**
  4441. * The target path of the runtime animation
  4442. */
  4443. private _targetPath;
  4444. /**
  4445. * The weight of the runtime animation
  4446. */
  4447. private _weight;
  4448. /**
  4449. * The ratio offset of the runtime animation
  4450. */
  4451. private _ratioOffset;
  4452. /**
  4453. * The previous delay of the runtime animation
  4454. */
  4455. private _previousDelay;
  4456. /**
  4457. * The previous ratio of the runtime animation
  4458. */
  4459. private _previousRatio;
  4460. /**
  4461. * Gets the current frame of the runtime animation
  4462. */
  4463. readonly currentFrame: number;
  4464. /**
  4465. * Gets the weight of the runtime animation
  4466. */
  4467. readonly weight: number;
  4468. /**
  4469. * Gets the current value of the runtime animation
  4470. */
  4471. readonly currentValue: any;
  4472. /**
  4473. * Gets the target path of the runtime animation
  4474. */
  4475. readonly targetPath: string;
  4476. /**
  4477. * Gets the actual target of the runtime animation
  4478. */
  4479. readonly target: any;
  4480. /**
  4481. * Create a new RuntimeAnimation object
  4482. * @param target defines the target of the animation
  4483. * @param animation defines the source animation object
  4484. * @param scene defines the hosting scene
  4485. * @param host defines the initiating Animatable
  4486. */
  4487. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4488. /**
  4489. * Gets the animation from the runtime animation
  4490. */
  4491. readonly animation: Animation;
  4492. /**
  4493. * Resets the runtime animation to the beginning
  4494. * @param restoreOriginal defines whether to restore the target property to the original value
  4495. */
  4496. reset(restoreOriginal?: boolean): void;
  4497. /**
  4498. * Specifies if the runtime animation is stopped
  4499. * @returns Boolean specifying if the runtime animation is stopped
  4500. */
  4501. isStopped(): boolean;
  4502. /**
  4503. * Disposes of the runtime animation
  4504. */
  4505. dispose(): void;
  4506. /**
  4507. * Interpolates the animation from the current frame
  4508. * @param currentFrame The frame to interpolate the animation to
  4509. * @param repeatCount The number of times that the animation should loop
  4510. * @param loopMode The type of looping mode to use
  4511. * @param offsetValue Animation offset value
  4512. * @param highLimitValue The high limit value
  4513. * @returns The interpolated value
  4514. */
  4515. private _interpolate;
  4516. /**
  4517. * Apply the interpolated value to the target
  4518. * @param currentValue defines the value computed by the animation
  4519. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4520. */
  4521. setValue(currentValue: any, weight?: number): void;
  4522. private _setValue;
  4523. /**
  4524. * Gets the loop pmode of the runtime animation
  4525. * @returns Loop Mode
  4526. */
  4527. private _getCorrectLoopMode;
  4528. /**
  4529. * Move the current animation to a given frame
  4530. * @param frame defines the frame to move to
  4531. */
  4532. goToFrame(frame: number): void;
  4533. /**
  4534. * @hidden Internal use only
  4535. */
  4536. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4537. /**
  4538. * Execute the current animation
  4539. * @param delay defines the delay to add to the current frame
  4540. * @param from defines the lower bound of the animation range
  4541. * @param to defines the upper bound of the animation range
  4542. * @param loop defines if the current animation must loop
  4543. * @param speedRatio defines the current speed ratio
  4544. * @param weight defines the weight of the animation (default is -1 so no weight)
  4545. * @returns a boolean indicating if the animation is running
  4546. */
  4547. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /**
  4552. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4554. */
  4555. class Analyser {
  4556. /**
  4557. * Gets or sets the smoothing
  4558. * @ignorenaming
  4559. */
  4560. SMOOTHING: number;
  4561. /**
  4562. * Gets or sets the FFT table size
  4563. * @ignorenaming
  4564. */
  4565. FFT_SIZE: number;
  4566. /**
  4567. * Gets or sets the bar graph amplitude
  4568. * @ignorenaming
  4569. */
  4570. BARGRAPHAMPLITUDE: number;
  4571. /**
  4572. * Gets or sets the position of the debug canvas
  4573. * @ignorenaming
  4574. */
  4575. DEBUGCANVASPOS: {
  4576. x: number;
  4577. y: number;
  4578. };
  4579. /**
  4580. * Gets or sets the debug canvas size
  4581. * @ignorenaming
  4582. */
  4583. DEBUGCANVASSIZE: {
  4584. width: number;
  4585. height: number;
  4586. };
  4587. private _byteFreqs;
  4588. private _byteTime;
  4589. private _floatFreqs;
  4590. private _webAudioAnalyser;
  4591. private _debugCanvas;
  4592. private _debugCanvasContext;
  4593. private _scene;
  4594. private _registerFunc;
  4595. private _audioEngine;
  4596. /**
  4597. * Creates a new analyser
  4598. * @param scene defines hosting scene
  4599. */
  4600. constructor(scene: Scene);
  4601. /**
  4602. * Get the number of data values you will have to play with for the visualization
  4603. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4604. * @returns a number
  4605. */
  4606. getFrequencyBinCount(): number;
  4607. /**
  4608. * Gets the current frequency data as a byte array
  4609. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4610. * @returns a Uint8Array
  4611. */
  4612. getByteFrequencyData(): Uint8Array;
  4613. /**
  4614. * Gets the current waveform as a byte array
  4615. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4616. * @returns a Uint8Array
  4617. */
  4618. getByteTimeDomainData(): Uint8Array;
  4619. /**
  4620. * Gets the current frequency data as a float array
  4621. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4622. * @returns a Float32Array
  4623. */
  4624. getFloatFrequencyData(): Float32Array;
  4625. /**
  4626. * Renders the debug canvas
  4627. */
  4628. drawDebugCanvas(): void;
  4629. /**
  4630. * Stops rendering the debug canvas and removes it
  4631. */
  4632. stopDebugCanvas(): void;
  4633. /**
  4634. * Connects two audio nodes
  4635. * @param inputAudioNode defines first node to connect
  4636. * @param outputAudioNode defines second node to connect
  4637. */
  4638. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4639. /**
  4640. * Releases all associated resources
  4641. */
  4642. dispose(): void;
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. class AudioEngine {
  4647. private _audioContext;
  4648. private _audioContextInitialized;
  4649. canUseWebAudio: boolean;
  4650. masterGain: GainNode;
  4651. private _connectedAnalyser;
  4652. WarnedWebAudioUnsupported: boolean;
  4653. unlocked: boolean;
  4654. onAudioUnlocked: () => any;
  4655. isMP3supported: boolean;
  4656. isOGGsupported: boolean;
  4657. readonly audioContext: Nullable<AudioContext>;
  4658. constructor();
  4659. private _unlockiOSaudio;
  4660. private _initializeAudioContext;
  4661. dispose(): void;
  4662. getGlobalVolume(): number;
  4663. setGlobalVolume(newVolume: number): void;
  4664. connectToAnalyser(analyser: Analyser): void;
  4665. }
  4666. }
  4667. declare module BABYLON {
  4668. class Sound {
  4669. name: string;
  4670. autoplay: boolean;
  4671. loop: boolean;
  4672. useCustomAttenuation: boolean;
  4673. soundTrackId: number;
  4674. spatialSound: boolean;
  4675. refDistance: number;
  4676. rolloffFactor: number;
  4677. maxDistance: number;
  4678. distanceModel: string;
  4679. private _panningModel;
  4680. onended: () => any;
  4681. /**
  4682. * Observable event when the current playing sound finishes.
  4683. */
  4684. onEndedObservable: Observable<Sound>;
  4685. private _playbackRate;
  4686. private _streaming;
  4687. private _startTime;
  4688. private _startOffset;
  4689. private _position;
  4690. /** @hidden */
  4691. _positionInEmitterSpace: boolean;
  4692. private _localDirection;
  4693. private _volume;
  4694. private _isReadyToPlay;
  4695. isPlaying: boolean;
  4696. isPaused: boolean;
  4697. private _isDirectional;
  4698. private _readyToPlayCallback;
  4699. private _audioBuffer;
  4700. private _soundSource;
  4701. private _streamingSource;
  4702. private _soundPanner;
  4703. private _soundGain;
  4704. private _inputAudioNode;
  4705. private _outputAudioNode;
  4706. private _coneInnerAngle;
  4707. private _coneOuterAngle;
  4708. private _coneOuterGain;
  4709. private _scene;
  4710. private _connectedMesh;
  4711. private _customAttenuationFunction;
  4712. private _registerFunc;
  4713. private _isOutputConnected;
  4714. private _htmlAudioElement;
  4715. private _urlType;
  4716. /**
  4717. * Create a sound and attach it to a scene
  4718. * @param name Name of your sound
  4719. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4720. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4721. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4722. */
  4723. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4724. dispose(): void;
  4725. isReady(): boolean;
  4726. private _soundLoaded;
  4727. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4728. updateOptions(options: any): void;
  4729. private _createSpatialParameters;
  4730. private _updateSpatialParameters;
  4731. switchPanningModelToHRTF(): void;
  4732. switchPanningModelToEqualPower(): void;
  4733. private _switchPanningModel;
  4734. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4735. /**
  4736. * Transform this sound into a directional source
  4737. * @param coneInnerAngle Size of the inner cone in degree
  4738. * @param coneOuterAngle Size of the outer cone in degree
  4739. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4740. */
  4741. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4742. /**
  4743. * Gets or sets the inner angle for the directional cone.
  4744. */
  4745. /**
  4746. * Gets or sets the inner angle for the directional cone.
  4747. */
  4748. directionalConeInnerAngle: number;
  4749. /**
  4750. * Gets or sets the outer angle for the directional cone.
  4751. */
  4752. /**
  4753. * Gets or sets the outer angle for the directional cone.
  4754. */
  4755. directionalConeOuterAngle: number;
  4756. setPosition(newPosition: Vector3): void;
  4757. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4758. private _updateDirection;
  4759. updateDistanceFromListener(): void;
  4760. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4761. /**
  4762. * Play the sound
  4763. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4764. * @param offset (optional) Start the sound setting it at a specific time
  4765. */
  4766. play(time?: number, offset?: number): void;
  4767. private _onended;
  4768. /**
  4769. * Stop the sound
  4770. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4771. */
  4772. stop(time?: number): void;
  4773. pause(): void;
  4774. setVolume(newVolume: number, time?: number): void;
  4775. setPlaybackRate(newPlaybackRate: number): void;
  4776. getVolume(): number;
  4777. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4778. detachFromMesh(): void;
  4779. private _onRegisterAfterWorldMatrixUpdate;
  4780. clone(): Nullable<Sound>;
  4781. getAudioBuffer(): AudioBuffer | null;
  4782. serialize(): any;
  4783. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. class SoundTrack {
  4788. private _outputAudioNode;
  4789. private _scene;
  4790. id: number;
  4791. soundCollection: Array<Sound>;
  4792. private _isMainTrack;
  4793. private _connectedAnalyser;
  4794. private _options;
  4795. private _isInitialized;
  4796. constructor(scene: Scene, options?: any);
  4797. private _initializeSoundTrackAudioGraph;
  4798. dispose(): void;
  4799. AddSound(sound: Sound): void;
  4800. RemoveSound(sound: Sound): void;
  4801. setVolume(newVolume: number): void;
  4802. switchPanningModelToHRTF(): void;
  4803. switchPanningModelToEqualPower(): void;
  4804. connectToAnalyser(analyser: Analyser): void;
  4805. }
  4806. }
  4807. declare module BABYLON {
  4808. /**
  4809. * Wraps one or more Sound objects and selects one with random weight for playback.
  4810. */
  4811. class WeightedSound {
  4812. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4813. loop: boolean;
  4814. private _coneInnerAngle;
  4815. private _coneOuterAngle;
  4816. private _volume;
  4817. /** A Sound is currently playing. */
  4818. isPlaying: boolean;
  4819. /** A Sound is currently paused. */
  4820. isPaused: boolean;
  4821. private _sounds;
  4822. private _weights;
  4823. private _currentIndex?;
  4824. /**
  4825. * Creates a new WeightedSound from the list of sounds given.
  4826. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4827. * @param sounds Array of Sounds that will be selected from.
  4828. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4829. */
  4830. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4831. /**
  4832. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4833. */
  4834. /**
  4835. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4836. */
  4837. directionalConeInnerAngle: number;
  4838. /**
  4839. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4840. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4841. */
  4842. /**
  4843. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4844. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4845. */
  4846. directionalConeOuterAngle: number;
  4847. /**
  4848. * Playback volume.
  4849. */
  4850. /**
  4851. * Playback volume.
  4852. */
  4853. volume: number;
  4854. private _onended;
  4855. /**
  4856. * Suspend playback
  4857. */
  4858. pause(): void;
  4859. /**
  4860. * Stop playback
  4861. */
  4862. stop(): void;
  4863. /**
  4864. * Start playback.
  4865. * @param startOffset Position the clip head at a specific time in seconds.
  4866. */
  4867. play(startOffset?: number): void;
  4868. }
  4869. }
  4870. declare module BABYLON {
  4871. /**
  4872. * Interface used to define a behavior
  4873. */
  4874. interface Behavior<T> {
  4875. /** gets or sets behavior's name */
  4876. name: string;
  4877. /**
  4878. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4879. */
  4880. init(): void;
  4881. /**
  4882. * Called when the behavior is attached to a target
  4883. * @param target defines the target where the behavior is attached to
  4884. */
  4885. attach(target: T): void;
  4886. /**
  4887. * Called when the behavior is detached from its target
  4888. */
  4889. detach(): void;
  4890. }
  4891. /**
  4892. * Interface implemented by classes supporting behaviors
  4893. */
  4894. interface IBehaviorAware<T> {
  4895. /**
  4896. * Attach a behavior
  4897. * @param behavior defines the behavior to attach
  4898. * @returns the current host
  4899. */
  4900. addBehavior(behavior: Behavior<T>): T;
  4901. /**
  4902. * Remove a behavior from the current object
  4903. * @param behavior defines the behavior to detach
  4904. * @returns the current host
  4905. */
  4906. removeBehavior(behavior: Behavior<T>): T;
  4907. /**
  4908. * Gets a behavior using its name to search
  4909. * @param name defines the name to search
  4910. * @returns the behavior or null if not found
  4911. */
  4912. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4913. }
  4914. }
  4915. declare module BABYLON {
  4916. /**
  4917. * Class used to store bone information
  4918. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4919. */
  4920. class Bone extends Node {
  4921. /**
  4922. * defines the bone name
  4923. */
  4924. name: string;
  4925. private static _tmpVecs;
  4926. private static _tmpQuat;
  4927. private static _tmpMats;
  4928. /**
  4929. * Gets the list of child bones
  4930. */
  4931. children: Bone[];
  4932. /** Gets the animations associated with this bone */
  4933. animations: Animation[];
  4934. /**
  4935. * Gets or sets bone length
  4936. */
  4937. length: number;
  4938. /**
  4939. * @hidden Internal only
  4940. * Set this value to map this bone to a different index in the transform matrices
  4941. * Set this value to -1 to exclude the bone from the transform matrices
  4942. */
  4943. _index: Nullable<number>;
  4944. private _skeleton;
  4945. private _localMatrix;
  4946. private _restPose;
  4947. private _baseMatrix;
  4948. private _absoluteTransform;
  4949. private _invertedAbsoluteTransform;
  4950. private _parent;
  4951. private _scalingDeterminant;
  4952. private _worldTransform;
  4953. private _localScaling;
  4954. private _localRotation;
  4955. private _localPosition;
  4956. private _needToDecompose;
  4957. private _needToCompose;
  4958. /** @hidden */
  4959. /** @hidden */
  4960. _matrix: Matrix;
  4961. /**
  4962. * Create a new bone
  4963. * @param name defines the bone name
  4964. * @param skeleton defines the parent skeleton
  4965. * @param parentBone defines the parent (can be null if the bone is the root)
  4966. * @param localMatrix defines the local matrix
  4967. * @param restPose defines the rest pose matrix
  4968. * @param baseMatrix defines the base matrix
  4969. * @param index defines index of the bone in the hiearchy
  4970. */
  4971. constructor(
  4972. /**
  4973. * defines the bone name
  4974. */
  4975. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4976. /**
  4977. * Gets the parent skeleton
  4978. * @returns a skeleton
  4979. */
  4980. getSkeleton(): Skeleton;
  4981. /**
  4982. * Gets parent bone
  4983. * @returns a bone or null if the bone is the root of the bone hierarchy
  4984. */
  4985. getParent(): Nullable<Bone>;
  4986. /**
  4987. * Sets the parent bone
  4988. * @param parent defines the parent (can be null if the bone is the root)
  4989. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4990. */
  4991. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4992. /**
  4993. * Gets the local matrix
  4994. * @returns a matrix
  4995. */
  4996. getLocalMatrix(): Matrix;
  4997. /**
  4998. * Gets the base matrix (initial matrix which remains unchanged)
  4999. * @returns a matrix
  5000. */
  5001. getBaseMatrix(): Matrix;
  5002. /**
  5003. * Gets the rest pose matrix
  5004. * @returns a matrix
  5005. */
  5006. getRestPose(): Matrix;
  5007. /**
  5008. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5009. */
  5010. getWorldMatrix(): Matrix;
  5011. /**
  5012. * Sets the local matrix to rest pose matrix
  5013. */
  5014. returnToRest(): void;
  5015. /**
  5016. * Gets the inverse of the absolute transform matrix.
  5017. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5018. * @returns a matrix
  5019. */
  5020. getInvertedAbsoluteTransform(): Matrix;
  5021. /**
  5022. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5023. * @returns a matrix
  5024. */
  5025. getAbsoluteTransform(): Matrix;
  5026. /** Gets or sets current position (in local space) */
  5027. position: Vector3;
  5028. /** Gets or sets current rotation (in local space) */
  5029. rotation: Vector3;
  5030. /** Gets or sets current rotation quaternion (in local space) */
  5031. rotationQuaternion: Quaternion;
  5032. /** Gets or sets current scaling (in local space) */
  5033. scaling: Vector3;
  5034. /**
  5035. * Gets the animation properties override
  5036. */
  5037. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5038. private _decompose;
  5039. private _compose;
  5040. /**
  5041. * Update the base and local matrices
  5042. * @param matrix defines the new base or local matrix
  5043. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5044. * @param updateLocalMatrix defines if the local matrix should be updated
  5045. */
  5046. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5047. /** @hidden */
  5048. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5049. /**
  5050. * Flag the bone as dirty (Forcing it to update everything)
  5051. */
  5052. markAsDirty(): void;
  5053. private _markAsDirtyAndCompose;
  5054. private _markAsDirtyAndDecompose;
  5055. /**
  5056. * Copy an animation range from another bone
  5057. * @param source defines the source bone
  5058. * @param rangeName defines the range name to copy
  5059. * @param frameOffset defines the frame offset
  5060. * @param rescaleAsRequired defines if rescaling must be applied if required
  5061. * @param skelDimensionsRatio defines the scaling ratio
  5062. * @returns true if operation was successful
  5063. */
  5064. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5065. /**
  5066. * Translate the bone in local or world space
  5067. * @param vec The amount to translate the bone
  5068. * @param space The space that the translation is in
  5069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5070. */
  5071. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5072. /**
  5073. * Set the postion of the bone in local or world space
  5074. * @param position The position to set the bone
  5075. * @param space The space that the position is in
  5076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5077. */
  5078. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5079. /**
  5080. * Set the absolute position of the bone (world space)
  5081. * @param position The position to set the bone
  5082. * @param mesh The mesh that this bone is attached to
  5083. */
  5084. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5085. /**
  5086. * Scale the bone on the x, y and z axes (in local space)
  5087. * @param x The amount to scale the bone on the x axis
  5088. * @param y The amount to scale the bone on the y axis
  5089. * @param z The amount to scale the bone on the z axis
  5090. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5091. */
  5092. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5093. /**
  5094. * Set the bone scaling in local space
  5095. * @param scale defines the scaling vector
  5096. */
  5097. setScale(scale: Vector3): void;
  5098. /**
  5099. * Gets the current scaling in local space
  5100. * @returns the current scaling vector
  5101. */
  5102. getScale(): Vector3;
  5103. /**
  5104. * Gets the current scaling in local space and stores it in a target vector
  5105. * @param result defines the target vector
  5106. */
  5107. getScaleToRef(result: Vector3): void;
  5108. /**
  5109. * Set the yaw, pitch, and roll of the bone in local or world space
  5110. * @param yaw The rotation of the bone on the y axis
  5111. * @param pitch The rotation of the bone on the x axis
  5112. * @param roll The rotation of the bone on the z axis
  5113. * @param space The space that the axes of rotation are in
  5114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5115. */
  5116. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5117. /**
  5118. * Add a rotation to the bone on an axis in local or world space
  5119. * @param axis The axis to rotate the bone on
  5120. * @param amount The amount to rotate the bone
  5121. * @param space The space that the axis is in
  5122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5123. */
  5124. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5125. /**
  5126. * Set the rotation of the bone to a particular axis angle in local or world space
  5127. * @param axis The axis to rotate the bone on
  5128. * @param angle The angle that the bone should be rotated to
  5129. * @param space The space that the axis is in
  5130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5131. */
  5132. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5133. /**
  5134. * Set the euler rotation of the bone in local of world space
  5135. * @param rotation The euler rotation that the bone should be set to
  5136. * @param space The space that the rotation is in
  5137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5138. */
  5139. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5140. /**
  5141. * Set the quaternion rotation of the bone in local of world space
  5142. * @param quat The quaternion rotation that the bone should be set to
  5143. * @param space The space that the rotation is in
  5144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5145. */
  5146. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5147. /**
  5148. * Set the rotation matrix of the bone in local of world space
  5149. * @param rotMat The rotation matrix that the bone should be set to
  5150. * @param space The space that the rotation is in
  5151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5152. */
  5153. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5154. private _rotateWithMatrix;
  5155. private _getNegativeRotationToRef;
  5156. /**
  5157. * Get the position of the bone in local or world space
  5158. * @param space The space that the returned position is in
  5159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5160. * @returns The position of the bone
  5161. */
  5162. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5163. /**
  5164. * Copy the position of the bone to a vector3 in local or world space
  5165. * @param space The space that the returned position is in
  5166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5167. * @param result The vector3 to copy the position to
  5168. */
  5169. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5170. /**
  5171. * Get the absolute position of the bone (world space)
  5172. * @param mesh The mesh that this bone is attached to
  5173. * @returns The absolute position of the bone
  5174. */
  5175. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5176. /**
  5177. * Copy the absolute position of the bone (world space) to the result param
  5178. * @param mesh The mesh that this bone is attached to
  5179. * @param result The vector3 to copy the absolute position to
  5180. */
  5181. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5182. /**
  5183. * Compute the absolute transforms of this bone and its children
  5184. */
  5185. computeAbsoluteTransforms(): void;
  5186. /**
  5187. * Get the world direction from an axis that is in the local space of the bone
  5188. * @param localAxis The local direction that is used to compute the world direction
  5189. * @param mesh The mesh that this bone is attached to
  5190. * @returns The world direction
  5191. */
  5192. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5193. /**
  5194. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5195. * @param localAxis The local direction that is used to compute the world direction
  5196. * @param mesh The mesh that this bone is attached to
  5197. * @param result The vector3 that the world direction will be copied to
  5198. */
  5199. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5200. /**
  5201. * Get the euler rotation of the bone in local or world space
  5202. * @param space The space that the rotation should be in
  5203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5204. * @returns The euler rotation
  5205. */
  5206. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5207. /**
  5208. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5209. * @param space The space that the rotation should be in
  5210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5211. * @param result The vector3 that the rotation should be copied to
  5212. */
  5213. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5214. /**
  5215. * Get the quaternion rotation of the bone in either local or world space
  5216. * @param space The space that the rotation should be in
  5217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5218. * @returns The quaternion rotation
  5219. */
  5220. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5221. /**
  5222. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5223. * @param space The space that the rotation should be in
  5224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5225. * @param result The quaternion that the rotation should be copied to
  5226. */
  5227. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5228. /**
  5229. * Get the rotation matrix of the bone in local or world space
  5230. * @param space The space that the rotation should be in
  5231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5232. * @returns The rotation matrix
  5233. */
  5234. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5235. /**
  5236. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5237. * @param space The space that the rotation should be in
  5238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5239. * @param result The quaternion that the rotation should be copied to
  5240. */
  5241. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5242. /**
  5243. * Get the world position of a point that is in the local space of the bone
  5244. * @param position The local position
  5245. * @param mesh The mesh that this bone is attached to
  5246. * @returns The world position
  5247. */
  5248. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5249. /**
  5250. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5251. * @param position The local position
  5252. * @param mesh The mesh that this bone is attached to
  5253. * @param result The vector3 that the world position should be copied to
  5254. */
  5255. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5256. /**
  5257. * Get the local position of a point that is in world space
  5258. * @param position The world position
  5259. * @param mesh The mesh that this bone is attached to
  5260. * @returns The local position
  5261. */
  5262. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5263. /**
  5264. * Get the local position of a point that is in world space and copy it to the result param
  5265. * @param position The world position
  5266. * @param mesh The mesh that this bone is attached to
  5267. * @param result The vector3 that the local position should be copied to
  5268. */
  5269. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to apply inverse kinematics to bones
  5275. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5276. */
  5277. class BoneIKController {
  5278. private static _tmpVecs;
  5279. private static _tmpQuat;
  5280. private static _tmpMats;
  5281. /**
  5282. * Gets or sets the target mesh
  5283. */
  5284. targetMesh: AbstractMesh;
  5285. /** Gets or sets the mesh used as pole */
  5286. poleTargetMesh: AbstractMesh;
  5287. /**
  5288. * Gets or sets the bone used as pole
  5289. */
  5290. poleTargetBone: Nullable<Bone>;
  5291. /**
  5292. * Gets or sets the target position
  5293. */
  5294. targetPosition: Vector3;
  5295. /**
  5296. * Gets or sets the pole target position
  5297. */
  5298. poleTargetPosition: Vector3;
  5299. /**
  5300. * Gets or sets the pole target local offset
  5301. */
  5302. poleTargetLocalOffset: Vector3;
  5303. /**
  5304. * Gets or sets the pole angle
  5305. */
  5306. poleAngle: number;
  5307. /**
  5308. * Gets or sets the mesh associated with the controller
  5309. */
  5310. mesh: AbstractMesh;
  5311. /**
  5312. * 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)
  5313. */
  5314. slerpAmount: number;
  5315. private _bone1Quat;
  5316. private _bone1Mat;
  5317. private _bone2Ang;
  5318. private _bone1;
  5319. private _bone2;
  5320. private _bone1Length;
  5321. private _bone2Length;
  5322. private _maxAngle;
  5323. private _maxReach;
  5324. private _rightHandedSystem;
  5325. private _bendAxis;
  5326. private _slerping;
  5327. private _adjustRoll;
  5328. /**
  5329. * Gets or sets maximum allowed angle
  5330. */
  5331. maxAngle: number;
  5332. /**
  5333. * Creates a new BoneIKController
  5334. * @param mesh defines the mesh to control
  5335. * @param bone defines the bone to control
  5336. * @param options defines options to set up the controller
  5337. */
  5338. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5339. targetMesh?: AbstractMesh;
  5340. poleTargetMesh?: AbstractMesh;
  5341. poleTargetBone?: Bone;
  5342. poleTargetLocalOffset?: Vector3;
  5343. poleAngle?: number;
  5344. bendAxis?: Vector3;
  5345. maxAngle?: number;
  5346. slerpAmount?: number;
  5347. });
  5348. private _setMaxAngle;
  5349. /**
  5350. * Force the controller to update the bones
  5351. */
  5352. update(): void;
  5353. }
  5354. }
  5355. declare module BABYLON {
  5356. /**
  5357. * Class used to make a bone look toward a point in space
  5358. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5359. */
  5360. class BoneLookController {
  5361. private static _tmpVecs;
  5362. private static _tmpQuat;
  5363. private static _tmpMats;
  5364. /**
  5365. * The target Vector3 that the bone will look at
  5366. */
  5367. target: Vector3;
  5368. /**
  5369. * The mesh that the bone is attached to
  5370. */
  5371. mesh: AbstractMesh;
  5372. /**
  5373. * The bone that will be looking to the target
  5374. */
  5375. bone: Bone;
  5376. /**
  5377. * The up axis of the coordinate system that is used when the bone is rotated
  5378. */
  5379. upAxis: Vector3;
  5380. /**
  5381. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5382. */
  5383. upAxisSpace: Space;
  5384. /**
  5385. * Used to make an adjustment to the yaw of the bone
  5386. */
  5387. adjustYaw: number;
  5388. /**
  5389. * Used to make an adjustment to the pitch of the bone
  5390. */
  5391. adjustPitch: number;
  5392. /**
  5393. * Used to make an adjustment to the roll of the bone
  5394. */
  5395. adjustRoll: number;
  5396. /**
  5397. * 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)
  5398. */
  5399. slerpAmount: number;
  5400. private _minYaw;
  5401. private _maxYaw;
  5402. private _minPitch;
  5403. private _maxPitch;
  5404. private _minYawSin;
  5405. private _minYawCos;
  5406. private _maxYawSin;
  5407. private _maxYawCos;
  5408. private _midYawConstraint;
  5409. private _minPitchTan;
  5410. private _maxPitchTan;
  5411. private _boneQuat;
  5412. private _slerping;
  5413. private _transformYawPitch;
  5414. private _transformYawPitchInv;
  5415. private _firstFrameSkipped;
  5416. private _yawRange;
  5417. private _fowardAxis;
  5418. /**
  5419. * Gets or sets the minimum yaw angle that the bone can look to
  5420. */
  5421. minYaw: number;
  5422. /**
  5423. * Gets or sets the maximum yaw angle that the bone can look to
  5424. */
  5425. maxYaw: number;
  5426. /**
  5427. * Gets or sets the minimum pitch angle that the bone can look to
  5428. */
  5429. minPitch: number;
  5430. /**
  5431. * Gets or sets the maximum pitch angle that the bone can look to
  5432. */
  5433. maxPitch: number;
  5434. /**
  5435. * Create a BoneLookController
  5436. * @param mesh the mesh that the bone belongs to
  5437. * @param bone the bone that will be looking to the target
  5438. * @param target the target Vector3 to look at
  5439. * @param settings optional settings:
  5440. * * maxYaw: the maximum angle the bone will yaw to
  5441. * * minYaw: the minimum angle the bone will yaw to
  5442. * * maxPitch: the maximum angle the bone will pitch to
  5443. * * minPitch: the minimum angle the bone will yaw to
  5444. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5445. * * upAxis: the up axis of the coordinate system
  5446. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5447. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5448. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5449. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5450. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5451. * * adjustRoll: used to make an adjustment to the roll of the bone
  5452. **/
  5453. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5454. maxYaw?: number;
  5455. minYaw?: number;
  5456. maxPitch?: number;
  5457. minPitch?: number;
  5458. slerpAmount?: number;
  5459. upAxis?: Vector3;
  5460. upAxisSpace?: Space;
  5461. yawAxis?: Vector3;
  5462. pitchAxis?: Vector3;
  5463. adjustYaw?: number;
  5464. adjustPitch?: number;
  5465. adjustRoll?: number;
  5466. });
  5467. /**
  5468. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5469. */
  5470. update(): void;
  5471. private _getAngleDiff;
  5472. private _getAngleBetween;
  5473. private _isAngleBetween;
  5474. }
  5475. }
  5476. declare module BABYLON {
  5477. /**
  5478. * Class used to handle skinning animations
  5479. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5480. */
  5481. class Skeleton implements IAnimatable {
  5482. /** defines the skeleton name */
  5483. name: string;
  5484. /** defines the skeleton Id */
  5485. id: string;
  5486. /**
  5487. * Gets the list of child bones
  5488. */
  5489. bones: Bone[];
  5490. /**
  5491. * Gets an estimate of the dimension of the skeleton at rest
  5492. */
  5493. dimensionsAtRest: Vector3;
  5494. /**
  5495. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5496. */
  5497. needInitialSkinMatrix: boolean;
  5498. /**
  5499. * Gets the list of animations attached to this skeleton
  5500. */
  5501. animations: Array<Animation>;
  5502. private _scene;
  5503. private _isDirty;
  5504. private _transformMatrices;
  5505. private _meshesWithPoseMatrix;
  5506. private _animatables;
  5507. private _identity;
  5508. private _synchronizedWithMesh;
  5509. private _ranges;
  5510. private _lastAbsoluteTransformsUpdateId;
  5511. /**
  5512. * Specifies if the skeleton should be serialized
  5513. */
  5514. doNotSerialize: boolean;
  5515. private _animationPropertiesOverride;
  5516. /**
  5517. * Gets or sets the animation properties override
  5518. */
  5519. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5520. /**
  5521. * An observable triggered before computing the skeleton's matrices
  5522. */
  5523. onBeforeComputeObservable: Observable<Skeleton>;
  5524. /**
  5525. * Creates a new skeleton
  5526. * @param name defines the skeleton name
  5527. * @param id defines the skeleton Id
  5528. * @param scene defines the hosting scene
  5529. */
  5530. constructor(
  5531. /** defines the skeleton name */
  5532. name: string,
  5533. /** defines the skeleton Id */
  5534. id: string, scene: Scene);
  5535. /**
  5536. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5537. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5538. * @returns a Float32Array containing matrices data
  5539. */
  5540. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5541. /**
  5542. * Gets the current hosting scene
  5543. * @returns a scene object
  5544. */
  5545. getScene(): Scene;
  5546. /**
  5547. * Gets a string representing the current skeleton data
  5548. * @param fullDetails defines a boolean indicating if we want a verbose version
  5549. * @returns a string representing the current skeleton data
  5550. */
  5551. toString(fullDetails?: boolean): string;
  5552. /**
  5553. * Get bone's index searching by name
  5554. * @param name defines bone's name to search for
  5555. * @return the indice of the bone. Returns -1 if not found
  5556. */
  5557. getBoneIndexByName(name: string): number;
  5558. /**
  5559. * Creater a new animation range
  5560. * @param name defines the name of the range
  5561. * @param from defines the start key
  5562. * @param to defines the end key
  5563. */
  5564. createAnimationRange(name: string, from: number, to: number): void;
  5565. /**
  5566. * Delete a specific animation range
  5567. * @param name defines the name of the range
  5568. * @param deleteFrames defines if frames must be removed as well
  5569. */
  5570. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5571. /**
  5572. * Gets a specific animation range
  5573. * @param name defines the name of the range to look for
  5574. * @returns the requested animation range or null if not found
  5575. */
  5576. getAnimationRange(name: string): Nullable<AnimationRange>;
  5577. /**
  5578. * Gets the list of all animation ranges defined on this skeleton
  5579. * @returns an array
  5580. */
  5581. getAnimationRanges(): Nullable<AnimationRange>[];
  5582. /**
  5583. * Copy animation range from a source skeleton.
  5584. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5585. * @param source defines the source skeleton
  5586. * @param name defines the name of the range to copy
  5587. * @param rescaleAsRequired defines if rescaling must be applied if required
  5588. * @returns true if operation was successful
  5589. */
  5590. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5591. /**
  5592. * Forces the skeleton to go to rest pose
  5593. */
  5594. returnToRest(): void;
  5595. private _getHighestAnimationFrame;
  5596. /**
  5597. * Begin a specific animation range
  5598. * @param name defines the name of the range to start
  5599. * @param loop defines if looping must be turned on (false by default)
  5600. * @param speedRatio defines the speed ratio to apply (1 by default)
  5601. * @param onAnimationEnd defines a callback which will be called when animation will end
  5602. * @returns a new animatable
  5603. */
  5604. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5605. /** @hidden */
  5606. _markAsDirty(): void;
  5607. /** @hidden */
  5608. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5609. /** @hidden */
  5610. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5611. /** @hidden */
  5612. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5613. /**
  5614. * Build all resources required to render a skeleton
  5615. */
  5616. prepare(): void;
  5617. /**
  5618. * Gets the list of animatables currently running for this skeleton
  5619. * @returns an array of animatables
  5620. */
  5621. getAnimatables(): IAnimatable[];
  5622. /**
  5623. * Clone the current skeleton
  5624. * @param name defines the name of the new skeleton
  5625. * @param id defines the id of the enw skeleton
  5626. * @returns the new skeleton
  5627. */
  5628. clone(name: string, id: string): Skeleton;
  5629. /**
  5630. * Enable animation blending for this skeleton
  5631. * @param blendingSpeed defines the blending speed to apply
  5632. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5633. */
  5634. enableBlending(blendingSpeed?: number): void;
  5635. /**
  5636. * Releases all resources associated with the current skeleton
  5637. */
  5638. dispose(): void;
  5639. /**
  5640. * Serialize the skeleton in a JSON object
  5641. * @returns a JSON object
  5642. */
  5643. serialize(): any;
  5644. /**
  5645. * Creates a new skeleton from serialized data
  5646. * @param parsedSkeleton defines the serialized data
  5647. * @param scene defines the hosting scene
  5648. * @returns a new skeleton
  5649. */
  5650. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5651. /**
  5652. * Compute all node absolute transforms
  5653. * @param forceUpdate defines if computation must be done even if cache is up to date
  5654. */
  5655. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5656. /**
  5657. * Gets the root pose matrix
  5658. * @returns a matrix
  5659. */
  5660. getPoseMatrix(): Nullable<Matrix>;
  5661. /**
  5662. * Sorts bones per internal index
  5663. */
  5664. sortBones(): void;
  5665. private _sortBones;
  5666. }
  5667. }
  5668. declare module BABYLON {
  5669. class ArcRotateCamera extends TargetCamera {
  5670. alpha: number;
  5671. beta: number;
  5672. radius: number;
  5673. protected _target: Vector3;
  5674. protected _targetHost: Nullable<AbstractMesh>;
  5675. target: Vector3;
  5676. inertialAlphaOffset: number;
  5677. inertialBetaOffset: number;
  5678. inertialRadiusOffset: number;
  5679. lowerAlphaLimit: Nullable<number>;
  5680. upperAlphaLimit: Nullable<number>;
  5681. lowerBetaLimit: number;
  5682. upperBetaLimit: number;
  5683. lowerRadiusLimit: Nullable<number>;
  5684. upperRadiusLimit: Nullable<number>;
  5685. inertialPanningX: number;
  5686. inertialPanningY: number;
  5687. pinchToPanMaxDistance: number;
  5688. panningDistanceLimit: Nullable<number>;
  5689. panningOriginTarget: Vector3;
  5690. panningInertia: number;
  5691. angularSensibilityX: number;
  5692. angularSensibilityY: number;
  5693. pinchPrecision: number;
  5694. pinchDeltaPercentage: number;
  5695. panningSensibility: number;
  5696. keysUp: number[];
  5697. keysDown: number[];
  5698. keysLeft: number[];
  5699. keysRight: number[];
  5700. wheelPrecision: number;
  5701. wheelDeltaPercentage: number;
  5702. zoomOnFactor: number;
  5703. targetScreenOffset: Vector2;
  5704. allowUpsideDown: boolean;
  5705. /** @hidden */
  5706. _viewMatrix: Matrix;
  5707. /** @hidden */
  5708. _useCtrlForPanning: boolean;
  5709. /** @hidden */
  5710. _panningMouseButton: number;
  5711. inputs: ArcRotateCameraInputsManager;
  5712. /** @hidden */
  5713. _reset: () => void;
  5714. panningAxis: Vector3;
  5715. protected _localDirection: Vector3;
  5716. protected _transformedDirection: Vector3;
  5717. private _bouncingBehavior;
  5718. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5719. useBouncingBehavior: boolean;
  5720. private _framingBehavior;
  5721. readonly framingBehavior: Nullable<FramingBehavior>;
  5722. useFramingBehavior: boolean;
  5723. private _autoRotationBehavior;
  5724. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5725. useAutoRotationBehavior: boolean;
  5726. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5727. onCollide: (collidedMesh: AbstractMesh) => void;
  5728. checkCollisions: boolean;
  5729. collisionRadius: Vector3;
  5730. protected _collider: Collider;
  5731. protected _previousPosition: Vector3;
  5732. protected _collisionVelocity: Vector3;
  5733. protected _newPosition: Vector3;
  5734. protected _previousAlpha: number;
  5735. protected _previousBeta: number;
  5736. protected _previousRadius: number;
  5737. protected _collisionTriggered: boolean;
  5738. protected _targetBoundingCenter: Nullable<Vector3>;
  5739. private _computationVector;
  5740. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5741. /** @hidden */
  5742. _initCache(): void;
  5743. /** @hidden */
  5744. _updateCache(ignoreParentClass?: boolean): void;
  5745. protected _getTargetPosition(): Vector3;
  5746. /**
  5747. * Store current camera state (fov, position, etc..)
  5748. */
  5749. private _storedAlpha;
  5750. private _storedBeta;
  5751. private _storedRadius;
  5752. private _storedTarget;
  5753. storeState(): Camera;
  5754. /**
  5755. * @hidden
  5756. * Restored camera state. You must call storeState() first
  5757. */
  5758. _restoreStateValues(): boolean;
  5759. /** @hidden */
  5760. _isSynchronizedViewMatrix(): boolean;
  5761. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5762. detachControl(element: HTMLElement): void;
  5763. /** @hidden */
  5764. _checkInputs(): void;
  5765. protected _checkLimits(): void;
  5766. rebuildAnglesAndRadius(): void;
  5767. setPosition(position: Vector3): void;
  5768. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5769. /** @hidden */
  5770. _getViewMatrix(): Matrix;
  5771. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5772. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5773. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5774. min: Vector3;
  5775. max: Vector3;
  5776. distance: number;
  5777. }, doNotUpdateMaxZ?: boolean): void;
  5778. /**
  5779. * @override
  5780. * Override Camera.createRigCamera
  5781. */
  5782. createRigCamera(name: string, cameraIndex: number): Camera;
  5783. /**
  5784. * @hidden
  5785. * @override
  5786. * Override Camera._updateRigCameras
  5787. */
  5788. _updateRigCameras(): void;
  5789. dispose(): void;
  5790. getClassName(): string;
  5791. }
  5792. }
  5793. declare module BABYLON {
  5794. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5795. constructor(camera: ArcRotateCamera);
  5796. addMouseWheel(): ArcRotateCameraInputsManager;
  5797. addPointers(): ArcRotateCameraInputsManager;
  5798. addKeyboard(): ArcRotateCameraInputsManager;
  5799. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5800. }
  5801. }
  5802. declare module BABYLON {
  5803. class Camera extends Node {
  5804. inputs: CameraInputsManager<Camera>;
  5805. private static _PERSPECTIVE_CAMERA;
  5806. private static _ORTHOGRAPHIC_CAMERA;
  5807. private static _FOVMODE_VERTICAL_FIXED;
  5808. private static _FOVMODE_HORIZONTAL_FIXED;
  5809. private static _RIG_MODE_NONE;
  5810. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5811. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5812. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5813. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5814. private static _RIG_MODE_VR;
  5815. private static _RIG_MODE_WEBVR;
  5816. static readonly PERSPECTIVE_CAMERA: number;
  5817. static readonly ORTHOGRAPHIC_CAMERA: number;
  5818. /**
  5819. * This is the default FOV mode for perspective cameras.
  5820. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5821. *
  5822. */
  5823. static readonly FOVMODE_VERTICAL_FIXED: number;
  5824. /**
  5825. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5826. *
  5827. */
  5828. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5829. static readonly RIG_MODE_NONE: number;
  5830. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5831. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5832. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5833. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5834. static readonly RIG_MODE_VR: number;
  5835. static readonly RIG_MODE_WEBVR: number;
  5836. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5837. static UseAlternateWebVRRendering: boolean;
  5838. position: Vector3;
  5839. /**
  5840. * The vector the camera should consider as up.
  5841. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5842. */
  5843. upVector: Vector3;
  5844. orthoLeft: Nullable<number>;
  5845. orthoRight: Nullable<number>;
  5846. orthoBottom: Nullable<number>;
  5847. orthoTop: Nullable<number>;
  5848. /**
  5849. * FOV is set in Radians. (default is 0.8)
  5850. */
  5851. fov: number;
  5852. minZ: number;
  5853. maxZ: number;
  5854. inertia: number;
  5855. mode: number;
  5856. isIntermediate: boolean;
  5857. viewport: Viewport;
  5858. /**
  5859. * Restricts the camera to viewing objects with the same layerMask.
  5860. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5861. */
  5862. layerMask: number;
  5863. /**
  5864. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5865. */
  5866. fovMode: number;
  5867. cameraRigMode: number;
  5868. interaxialDistance: number;
  5869. isStereoscopicSideBySide: boolean;
  5870. /** @hidden */
  5871. _cameraRigParams: any;
  5872. /** @hidden */
  5873. _rigCameras: Camera[];
  5874. /** @hidden */
  5875. _rigPostProcess: Nullable<PostProcess>;
  5876. protected _webvrViewMatrix: Matrix;
  5877. /** @hidden */
  5878. _skipRendering: boolean;
  5879. /** @hidden */
  5880. _alternateCamera: Camera;
  5881. customRenderTargets: RenderTargetTexture[];
  5882. onViewMatrixChangedObservable: Observable<Camera>;
  5883. onProjectionMatrixChangedObservable: Observable<Camera>;
  5884. onAfterCheckInputsObservable: Observable<Camera>;
  5885. onRestoreStateObservable: Observable<Camera>;
  5886. private _computedViewMatrix;
  5887. _projectionMatrix: Matrix;
  5888. private _doNotComputeProjectionMatrix;
  5889. private _worldMatrix;
  5890. _postProcesses: Nullable<PostProcess>[];
  5891. private _transformMatrix;
  5892. _activeMeshes: SmartArray<AbstractMesh>;
  5893. protected _globalPosition: Vector3;
  5894. private _frustumPlanes;
  5895. private _refreshFrustumPlanes;
  5896. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5897. private _storedFov;
  5898. private _stateStored;
  5899. /**
  5900. * Store current camera state (fov, position, etc..)
  5901. */
  5902. storeState(): Camera;
  5903. /**
  5904. * Restores the camera state values if it has been stored. You must call storeState() first
  5905. */
  5906. protected _restoreStateValues(): boolean;
  5907. /**
  5908. * Restored camera state. You must call storeState() first
  5909. */
  5910. restoreState(): boolean;
  5911. getClassName(): string;
  5912. /**
  5913. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5914. */
  5915. toString(fullDetails?: boolean): string;
  5916. readonly globalPosition: Vector3;
  5917. getActiveMeshes(): SmartArray<AbstractMesh>;
  5918. isActiveMesh(mesh: Mesh): boolean;
  5919. /**
  5920. * Is this camera ready to be used/rendered
  5921. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5922. * @return true if the camera is ready
  5923. */
  5924. isReady(completeCheck?: boolean): boolean;
  5925. /** @hidden */
  5926. _initCache(): void;
  5927. /** @hidden */
  5928. _updateCache(ignoreParentClass?: boolean): void;
  5929. /** @hidden */
  5930. _isSynchronized(): boolean;
  5931. /** @hidden */
  5932. _isSynchronizedViewMatrix(): boolean;
  5933. /** @hidden */
  5934. _isSynchronizedProjectionMatrix(): boolean;
  5935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5936. detachControl(element: HTMLElement): void;
  5937. update(): void;
  5938. /** @hidden */
  5939. _checkInputs(): void;
  5940. readonly rigCameras: Camera[];
  5941. readonly rigPostProcess: Nullable<PostProcess>;
  5942. /**
  5943. * Internal, gets the first post proces.
  5944. * @returns the first post process to be run on this camera.
  5945. */
  5946. _getFirstPostProcess(): Nullable<PostProcess>;
  5947. private _cascadePostProcessesToRigCams;
  5948. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5949. detachPostProcess(postProcess: PostProcess): void;
  5950. getWorldMatrix(): Matrix;
  5951. /** @hidden */
  5952. _getViewMatrix(): Matrix;
  5953. getViewMatrix(force?: boolean): Matrix;
  5954. freezeProjectionMatrix(projection?: Matrix): void;
  5955. unfreezeProjectionMatrix(): void;
  5956. getProjectionMatrix(force?: boolean): Matrix;
  5957. /**
  5958. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5959. * @returns a Matrix
  5960. */
  5961. getTransformationMatrix(): Matrix;
  5962. private updateFrustumPlanes;
  5963. isInFrustum(target: ICullable): boolean;
  5964. isCompletelyInFrustum(target: ICullable): boolean;
  5965. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5966. /**
  5967. * Releases resources associated with this node.
  5968. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5969. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5970. */
  5971. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5972. readonly leftCamera: Nullable<FreeCamera>;
  5973. readonly rightCamera: Nullable<FreeCamera>;
  5974. getLeftTarget(): Nullable<Vector3>;
  5975. getRightTarget(): Nullable<Vector3>;
  5976. setCameraRigMode(mode: number, rigParams: any): void;
  5977. private _getVRProjectionMatrix;
  5978. protected _updateCameraRotationMatrix(): void;
  5979. protected _updateWebVRCameraRotationMatrix(): void;
  5980. /**
  5981. * This function MUST be overwritten by the different WebVR cameras available.
  5982. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5983. */
  5984. protected _getWebVRProjectionMatrix(): Matrix;
  5985. /**
  5986. * This function MUST be overwritten by the different WebVR cameras available.
  5987. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5988. */
  5989. protected _getWebVRViewMatrix(): Matrix;
  5990. setCameraRigParameter(name: string, value: any): void;
  5991. /**
  5992. * needs to be overridden by children so sub has required properties to be copied
  5993. */
  5994. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5995. /**
  5996. * May need to be overridden by children
  5997. * @hidden
  5998. */
  5999. _updateRigCameras(): void;
  6000. /** @hidden */
  6001. _setupInputs(): void;
  6002. serialize(): any;
  6003. clone(name: string): Camera;
  6004. getDirection(localAxis: Vector3): Vector3;
  6005. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6006. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6007. computeWorldMatrix(): Matrix;
  6008. static Parse(parsedCamera: any, scene: Scene): Camera;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. var CameraInputTypes: {};
  6013. interface ICameraInput<TCamera extends Camera> {
  6014. camera: Nullable<TCamera>;
  6015. getClassName(): string;
  6016. getSimpleName(): string;
  6017. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6018. detachControl: (element: Nullable<HTMLElement>) => void;
  6019. checkInputs?: () => void;
  6020. }
  6021. interface CameraInputsMap<TCamera extends Camera> {
  6022. [name: string]: ICameraInput<TCamera>;
  6023. [idx: number]: ICameraInput<TCamera>;
  6024. }
  6025. class CameraInputsManager<TCamera extends Camera> {
  6026. attached: CameraInputsMap<TCamera>;
  6027. attachedElement: Nullable<HTMLElement>;
  6028. noPreventDefault: boolean;
  6029. camera: TCamera;
  6030. checkInputs: () => void;
  6031. constructor(camera: TCamera);
  6032. /**
  6033. * Add an input method to a camera
  6034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6035. * @param input camera input method
  6036. */
  6037. add(input: ICameraInput<TCamera>): void;
  6038. /**
  6039. * Remove a specific input method from a camera
  6040. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6041. * @param inputToRemove camera input method
  6042. */
  6043. remove(inputToRemove: ICameraInput<TCamera>): void;
  6044. removeByType(inputType: string): void;
  6045. private _addCheckInputs;
  6046. attachInput(input: ICameraInput<TCamera>): void;
  6047. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6048. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6049. rebuildInputCheck(): void;
  6050. /**
  6051. * Remove all attached input methods from a camera
  6052. */
  6053. clear(): void;
  6054. serialize(serializedCamera: any): void;
  6055. parse(parsedCamera: any): void;
  6056. }
  6057. }
  6058. declare module BABYLON {
  6059. /**
  6060. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6061. * being tilted forward or back and left or right.
  6062. */
  6063. class DeviceOrientationCamera extends FreeCamera {
  6064. private _initialQuaternion;
  6065. private _quaternionCache;
  6066. /**
  6067. * Creates a new device orientation camera
  6068. * @param name The name of the camera
  6069. * @param position The start position camera
  6070. * @param scene The scene the camera belongs to
  6071. */
  6072. constructor(name: string, position: Vector3, scene: Scene);
  6073. /**
  6074. * Gets the current instance class name ("DeviceOrientationCamera").
  6075. * This helps avoiding instanceof at run time.
  6076. * @returns the class name
  6077. */
  6078. getClassName(): string;
  6079. /**
  6080. * @hidden
  6081. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6082. */
  6083. _checkInputs(): void;
  6084. /**
  6085. * Reset the camera to its default orientation on the specified axis only.
  6086. * @param axis The axis to reset
  6087. */
  6088. resetToCurrentRotation(axis?: Axis): void;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. class FollowCamera extends TargetCamera {
  6093. radius: number;
  6094. rotationOffset: number;
  6095. heightOffset: number;
  6096. cameraAcceleration: number;
  6097. maxCameraSpeed: number;
  6098. lockedTarget: Nullable<AbstractMesh>;
  6099. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6100. private getRadians;
  6101. private follow;
  6102. /** @hidden */
  6103. _checkInputs(): void;
  6104. getClassName(): string;
  6105. }
  6106. class ArcFollowCamera extends TargetCamera {
  6107. alpha: number;
  6108. beta: number;
  6109. radius: number;
  6110. target: Nullable<AbstractMesh>;
  6111. private _cartesianCoordinates;
  6112. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6113. private follow;
  6114. /** @hidden */
  6115. _checkInputs(): void;
  6116. getClassName(): string;
  6117. }
  6118. }
  6119. declare module BABYLON {
  6120. class FreeCamera extends TargetCamera {
  6121. ellipsoid: Vector3;
  6122. ellipsoidOffset: Vector3;
  6123. checkCollisions: boolean;
  6124. applyGravity: boolean;
  6125. inputs: FreeCameraInputsManager;
  6126. /**
  6127. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6128. * Higher values reduce sensitivity.
  6129. */
  6130. /**
  6131. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6132. * Higher values reduce sensitivity.
  6133. */
  6134. angularSensibility: number;
  6135. keysUp: number[];
  6136. keysDown: number[];
  6137. keysLeft: number[];
  6138. keysRight: number[];
  6139. onCollide: (collidedMesh: AbstractMesh) => void;
  6140. private _collider;
  6141. private _needMoveForGravity;
  6142. private _oldPosition;
  6143. private _diffPosition;
  6144. private _newPosition;
  6145. /** @hidden */
  6146. _localDirection: Vector3;
  6147. /** @hidden */
  6148. _transformedDirection: Vector3;
  6149. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6151. detachControl(element: HTMLElement): void;
  6152. private _collisionMask;
  6153. collisionMask: number;
  6154. /** @hidden */
  6155. _collideWithWorld(displacement: Vector3): void;
  6156. private _onCollisionPositionChange;
  6157. /** @hidden */
  6158. _checkInputs(): void;
  6159. /** @hidden */
  6160. _decideIfNeedsToMove(): boolean;
  6161. /** @hidden */
  6162. _updatePosition(): void;
  6163. dispose(): void;
  6164. getClassName(): string;
  6165. }
  6166. }
  6167. declare module BABYLON {
  6168. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6169. constructor(camera: FreeCamera);
  6170. addKeyboard(): FreeCameraInputsManager;
  6171. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6172. addDeviceOrientation(): FreeCameraInputsManager;
  6173. addTouch(): FreeCameraInputsManager;
  6174. addVirtualJoystick(): FreeCameraInputsManager;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. class GamepadCamera extends UniversalCamera {
  6179. gamepadAngularSensibility: number;
  6180. gamepadMoveSensibility: number;
  6181. constructor(name: string, position: Vector3, scene: Scene);
  6182. getClassName(): string;
  6183. }
  6184. }
  6185. declare module BABYLON {
  6186. class TargetCamera extends Camera {
  6187. cameraDirection: Vector3;
  6188. cameraRotation: Vector2;
  6189. rotation: Vector3;
  6190. rotationQuaternion: Quaternion;
  6191. speed: number;
  6192. noRotationConstraint: boolean;
  6193. lockedTarget: any;
  6194. /** @hidden */
  6195. _currentTarget: Vector3;
  6196. /** @hidden */
  6197. _viewMatrix: Matrix;
  6198. /** @hidden */
  6199. _camMatrix: Matrix;
  6200. /** @hidden */
  6201. _cameraTransformMatrix: Matrix;
  6202. /** @hidden */
  6203. _cameraRotationMatrix: Matrix;
  6204. private _rigCamTransformMatrix;
  6205. /** @hidden */
  6206. _referencePoint: Vector3;
  6207. /** @hidden */
  6208. _transformedReferencePoint: Vector3;
  6209. protected _globalCurrentTarget: Vector3;
  6210. protected _globalCurrentUpVector: Vector3;
  6211. /** @hidden */
  6212. _reset: () => void;
  6213. private _defaultUp;
  6214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6215. getFrontPosition(distance: number): Vector3;
  6216. /** @hidden */
  6217. _getLockedTargetPosition(): Nullable<Vector3>;
  6218. /**
  6219. * Store current camera state (fov, position, etc..)
  6220. */
  6221. private _storedPosition;
  6222. private _storedRotation;
  6223. private _storedRotationQuaternion;
  6224. storeState(): Camera;
  6225. /**
  6226. * Restored camera state. You must call storeState() first
  6227. * @returns whether it was successful or not
  6228. * @hidden
  6229. */
  6230. _restoreStateValues(): boolean;
  6231. /** @hidden */
  6232. _initCache(): void;
  6233. /** @hidden */
  6234. _updateCache(ignoreParentClass?: boolean): void;
  6235. /** @hidden */
  6236. _isSynchronizedViewMatrix(): boolean;
  6237. /** @hidden */
  6238. _computeLocalCameraSpeed(): number;
  6239. /** @hidden */
  6240. setTarget(target: Vector3): void;
  6241. /**
  6242. * Return the current target position of the camera. This value is expressed in local space.
  6243. */
  6244. getTarget(): Vector3;
  6245. /** @hidden */
  6246. _decideIfNeedsToMove(): boolean;
  6247. /** @hidden */
  6248. _updatePosition(): void;
  6249. /** @hidden */
  6250. _checkInputs(): void;
  6251. protected _updateCameraRotationMatrix(): void;
  6252. /**
  6253. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  6254. * @returns the current camera
  6255. */
  6256. private _rotateUpVectorWithCameraRotationMatrix;
  6257. private _cachedRotationZ;
  6258. /** @hidden */
  6259. _getViewMatrix(): Matrix;
  6260. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6261. /**
  6262. * @override
  6263. * Override Camera.createRigCamera
  6264. */
  6265. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6266. /**
  6267. * @hidden
  6268. * @override
  6269. * Override Camera._updateRigCameras
  6270. */
  6271. _updateRigCameras(): void;
  6272. private _getRigCamPosition;
  6273. getClassName(): string;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. class TouchCamera extends FreeCamera {
  6278. touchAngularSensibility: number;
  6279. touchMoveSensibility: number;
  6280. constructor(name: string, position: Vector3, scene: Scene);
  6281. getClassName(): string;
  6282. /** @hidden */
  6283. _setupInputs(): void;
  6284. }
  6285. }
  6286. declare module BABYLON {
  6287. class UniversalCamera extends TouchCamera {
  6288. gamepadAngularSensibility: number;
  6289. gamepadMoveSensibility: number;
  6290. constructor(name: string, position: Vector3, scene: Scene);
  6291. getClassName(): string;
  6292. }
  6293. }
  6294. declare module BABYLON {
  6295. class VirtualJoysticksCamera extends FreeCamera {
  6296. constructor(name: string, position: Vector3, scene: Scene);
  6297. getClassName(): string;
  6298. }
  6299. }
  6300. interface VRDisplay extends EventTarget {
  6301. /**
  6302. * Dictionary of capabilities describing the VRDisplay.
  6303. */
  6304. readonly capabilities: VRDisplayCapabilities;
  6305. /**
  6306. * z-depth defining the far plane of the eye view frustum
  6307. * enables mapping of values in the render target depth
  6308. * attachment to scene coordinates. Initially set to 10000.0.
  6309. */
  6310. depthFar: number;
  6311. /**
  6312. * z-depth defining the near plane of the eye view frustum
  6313. * enables mapping of values in the render target depth
  6314. * attachment to scene coordinates. Initially set to 0.01.
  6315. */
  6316. depthNear: number;
  6317. /**
  6318. * An identifier for this distinct VRDisplay. Used as an
  6319. * association point in the Gamepad API.
  6320. */
  6321. readonly displayId: number;
  6322. /**
  6323. * A display name, a user-readable name identifying it.
  6324. */
  6325. readonly displayName: string;
  6326. readonly isConnected: boolean;
  6327. readonly isPresenting: boolean;
  6328. /**
  6329. * If this VRDisplay supports room-scale experiences, the optional
  6330. * stage attribute contains details on the room-scale parameters.
  6331. */
  6332. readonly stageParameters: VRStageParameters | null;
  6333. /**
  6334. * Passing the value returned by `requestAnimationFrame` to
  6335. * `cancelAnimationFrame` will unregister the callback.
  6336. */
  6337. cancelAnimationFrame(handle: number): void;
  6338. /**
  6339. * Stops presenting to the VRDisplay.
  6340. */
  6341. exitPresent(): Promise<void>;
  6342. getEyeParameters(whichEye: string): VREyeParameters;
  6343. /**
  6344. * Populates the passed VRFrameData with the information required to render
  6345. * the current frame.
  6346. */
  6347. getFrameData(frameData: VRFrameData): boolean;
  6348. /**
  6349. * Get the layers currently being presented.
  6350. */
  6351. getLayers(): VRLayer[];
  6352. /**
  6353. * Return a VRPose containing the future predicted pose of the VRDisplay
  6354. * when the current frame will be presented. The value returned will not
  6355. * change until JavaScript has returned control to the browser.
  6356. *
  6357. * The VRPose will contain the position, orientation, velocity,
  6358. * and acceleration of each of these properties.
  6359. */
  6360. getPose(): VRPose;
  6361. /**
  6362. * Return the current instantaneous pose of the VRDisplay, with no
  6363. * prediction applied.
  6364. */
  6365. getImmediatePose(): VRPose;
  6366. /**
  6367. * The callback passed to `requestAnimationFrame` will be called
  6368. * any time a new frame should be rendered. When the VRDisplay is
  6369. * presenting the callback will be called at the native refresh
  6370. * rate of the HMD. When not presenting this function acts
  6371. * identically to how window.requestAnimationFrame acts. Content should
  6372. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6373. * asynchronously from other displays and at differing refresh rates.
  6374. */
  6375. requestAnimationFrame(callback: FrameRequestCallback): number;
  6376. /**
  6377. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6378. * Repeat calls while already presenting will update the VRLayers being displayed.
  6379. */
  6380. requestPresent(layers: VRLayer[]): Promise<void>;
  6381. /**
  6382. * Reset the pose for this display, treating its current position and
  6383. * orientation as the "origin/zero" values. VRPose.position,
  6384. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6385. * updated when calling resetPose(). This should be called in only
  6386. * sitting-space experiences.
  6387. */
  6388. resetPose(): void;
  6389. /**
  6390. * The VRLayer provided to the VRDisplay will be captured and presented
  6391. * in the HMD. Calling this function has the same effect on the source
  6392. * canvas as any other operation that uses its source image, and canvases
  6393. * created without preserveDrawingBuffer set to true will be cleared.
  6394. */
  6395. submitFrame(pose?: VRPose): void;
  6396. }
  6397. declare var VRDisplay: {
  6398. prototype: VRDisplay;
  6399. new (): VRDisplay;
  6400. };
  6401. interface VRLayer {
  6402. leftBounds?: number[] | Float32Array | null;
  6403. rightBounds?: number[] | Float32Array | null;
  6404. source?: HTMLCanvasElement | null;
  6405. }
  6406. interface VRDisplayCapabilities {
  6407. readonly canPresent: boolean;
  6408. readonly hasExternalDisplay: boolean;
  6409. readonly hasOrientation: boolean;
  6410. readonly hasPosition: boolean;
  6411. readonly maxLayers: number;
  6412. }
  6413. interface VREyeParameters {
  6414. /** @deprecated */
  6415. readonly fieldOfView: VRFieldOfView;
  6416. readonly offset: Float32Array;
  6417. readonly renderHeight: number;
  6418. readonly renderWidth: number;
  6419. }
  6420. interface VRFieldOfView {
  6421. readonly downDegrees: number;
  6422. readonly leftDegrees: number;
  6423. readonly rightDegrees: number;
  6424. readonly upDegrees: number;
  6425. }
  6426. interface VRFrameData {
  6427. readonly leftProjectionMatrix: Float32Array;
  6428. readonly leftViewMatrix: Float32Array;
  6429. readonly pose: VRPose;
  6430. readonly rightProjectionMatrix: Float32Array;
  6431. readonly rightViewMatrix: Float32Array;
  6432. readonly timestamp: number;
  6433. }
  6434. interface VRPose {
  6435. readonly angularAcceleration: Float32Array | null;
  6436. readonly angularVelocity: Float32Array | null;
  6437. readonly linearAcceleration: Float32Array | null;
  6438. readonly linearVelocity: Float32Array | null;
  6439. readonly orientation: Float32Array | null;
  6440. readonly position: Float32Array | null;
  6441. readonly timestamp: number;
  6442. }
  6443. interface VRStageParameters {
  6444. sittingToStandingTransform?: Float32Array;
  6445. sizeX?: number;
  6446. sizeY?: number;
  6447. }
  6448. interface Navigator {
  6449. getVRDisplays(): Promise<VRDisplay[]>;
  6450. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6451. }
  6452. interface Window {
  6453. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6454. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6455. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6456. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6457. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6458. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6459. }
  6460. interface Gamepad {
  6461. readonly displayId: number;
  6462. }
  6463. declare module BABYLON {
  6464. class Collider {
  6465. /** Define if a collision was found */
  6466. collisionFound: boolean;
  6467. /**
  6468. * Define last intersection point in local space
  6469. */
  6470. intersectionPoint: Vector3;
  6471. /**
  6472. * Define last collided mesh
  6473. */
  6474. collidedMesh: Nullable<AbstractMesh>;
  6475. private _collisionPoint;
  6476. private _planeIntersectionPoint;
  6477. private _tempVector;
  6478. private _tempVector2;
  6479. private _tempVector3;
  6480. private _tempVector4;
  6481. private _edge;
  6482. private _baseToVertex;
  6483. private _destinationPoint;
  6484. private _slidePlaneNormal;
  6485. private _displacementVector;
  6486. /** @hidden */
  6487. _radius: Vector3;
  6488. /** @hidden */
  6489. _retry: number;
  6490. private _velocity;
  6491. private _basePoint;
  6492. private _epsilon;
  6493. /** @hidden */
  6494. _velocityWorldLength: number;
  6495. /** @hidden */
  6496. _basePointWorld: Vector3;
  6497. private _velocityWorld;
  6498. private _normalizedVelocity;
  6499. /** @hidden */
  6500. _initialVelocity: Vector3;
  6501. /** @hidden */
  6502. _initialPosition: Vector3;
  6503. private _nearestDistance;
  6504. private _collisionMask;
  6505. collisionMask: number;
  6506. /**
  6507. * Gets the plane normal used to compute the sliding response (in local space)
  6508. */
  6509. readonly slidePlaneNormal: Vector3;
  6510. /** @hidden */
  6511. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6512. /** @hidden */
  6513. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6514. /** @hidden */
  6515. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6516. /** @hidden */
  6517. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6518. /** @hidden */
  6519. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6520. /** @hidden */
  6521. _getResponse(pos: Vector3, vel: Vector3): void;
  6522. }
  6523. }
  6524. declare module BABYLON {
  6525. var CollisionWorker: string;
  6526. interface ICollisionCoordinator {
  6527. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6528. init(scene: Scene): void;
  6529. destroy(): void;
  6530. onMeshAdded(mesh: AbstractMesh): void;
  6531. onMeshUpdated(mesh: AbstractMesh): void;
  6532. onMeshRemoved(mesh: AbstractMesh): void;
  6533. onGeometryAdded(geometry: Geometry): void;
  6534. onGeometryUpdated(geometry: Geometry): void;
  6535. onGeometryDeleted(geometry: Geometry): void;
  6536. }
  6537. interface SerializedMesh {
  6538. id: string;
  6539. name: string;
  6540. uniqueId: number;
  6541. geometryId: Nullable<string>;
  6542. sphereCenter: Array<number>;
  6543. sphereRadius: number;
  6544. boxMinimum: Array<number>;
  6545. boxMaximum: Array<number>;
  6546. worldMatrixFromCache: any;
  6547. subMeshes: Array<SerializedSubMesh>;
  6548. checkCollisions: boolean;
  6549. }
  6550. interface SerializedSubMesh {
  6551. position: number;
  6552. verticesStart: number;
  6553. verticesCount: number;
  6554. indexStart: number;
  6555. indexCount: number;
  6556. hasMaterial: boolean;
  6557. sphereCenter: Array<number>;
  6558. sphereRadius: number;
  6559. boxMinimum: Array<number>;
  6560. boxMaximum: Array<number>;
  6561. }
  6562. /**
  6563. * Interface describing the value associated with a geometry
  6564. */
  6565. interface SerializedGeometry {
  6566. /**
  6567. * Defines the unique ID of the geometry
  6568. */
  6569. id: string;
  6570. /**
  6571. * Defines the array containing the positions
  6572. */
  6573. positions: Float32Array;
  6574. /**
  6575. * Defines the array containing the indices
  6576. */
  6577. indices: Uint32Array;
  6578. /**
  6579. * Defines the array containing the normals
  6580. */
  6581. normals: Float32Array;
  6582. }
  6583. interface BabylonMessage {
  6584. taskType: WorkerTaskType;
  6585. payload: InitPayload | CollidePayload | UpdatePayload;
  6586. }
  6587. interface SerializedColliderToWorker {
  6588. position: Array<number>;
  6589. velocity: Array<number>;
  6590. radius: Array<number>;
  6591. }
  6592. /** Defines supported task for worker process */
  6593. enum WorkerTaskType {
  6594. /** Initialization */
  6595. INIT = 0,
  6596. /** Update of geometry */
  6597. UPDATE = 1,
  6598. /** Evaluate collision */
  6599. COLLIDE = 2
  6600. }
  6601. interface WorkerReply {
  6602. error: WorkerReplyType;
  6603. taskType: WorkerTaskType;
  6604. payload?: any;
  6605. }
  6606. interface CollisionReplyPayload {
  6607. newPosition: Array<number>;
  6608. collisionId: number;
  6609. collidedMeshUniqueId: number;
  6610. }
  6611. interface InitPayload {
  6612. }
  6613. interface CollidePayload {
  6614. collisionId: number;
  6615. collider: SerializedColliderToWorker;
  6616. maximumRetry: number;
  6617. excludedMeshUniqueId: Nullable<number>;
  6618. }
  6619. interface UpdatePayload {
  6620. updatedMeshes: {
  6621. [n: number]: SerializedMesh;
  6622. };
  6623. updatedGeometries: {
  6624. [s: string]: SerializedGeometry;
  6625. };
  6626. removedMeshes: Array<number>;
  6627. removedGeometries: Array<string>;
  6628. }
  6629. /** Defines kind of replies returned by worker */
  6630. enum WorkerReplyType {
  6631. /** Success */
  6632. SUCCESS = 0,
  6633. /** Unkown error */
  6634. UNKNOWN_ERROR = 1
  6635. }
  6636. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6637. private _scene;
  6638. private _scaledPosition;
  6639. private _scaledVelocity;
  6640. private _collisionsCallbackArray;
  6641. private _init;
  6642. private _runningUpdated;
  6643. private _worker;
  6644. private _addUpdateMeshesList;
  6645. private _addUpdateGeometriesList;
  6646. private _toRemoveMeshesArray;
  6647. private _toRemoveGeometryArray;
  6648. constructor();
  6649. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6650. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6651. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6652. init(scene: Scene): void;
  6653. destroy(): void;
  6654. onMeshAdded(mesh: AbstractMesh): void;
  6655. onMeshUpdated: (transformNode: TransformNode) => void;
  6656. onMeshRemoved(mesh: AbstractMesh): void;
  6657. onGeometryAdded(geometry: Geometry): void;
  6658. onGeometryUpdated: (geometry: Geometry) => void;
  6659. onGeometryDeleted(geometry: Geometry): void;
  6660. private _afterRender;
  6661. private _onMessageFromWorker;
  6662. }
  6663. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6664. private _scene;
  6665. private _scaledPosition;
  6666. private _scaledVelocity;
  6667. private _finalPosition;
  6668. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6669. init(scene: Scene): void;
  6670. destroy(): void;
  6671. onMeshAdded(mesh: AbstractMesh): void;
  6672. onMeshUpdated(mesh: AbstractMesh): void;
  6673. onMeshRemoved(mesh: AbstractMesh): void;
  6674. onGeometryAdded(geometry: Geometry): void;
  6675. onGeometryUpdated(geometry: Geometry): void;
  6676. onGeometryDeleted(geometry: Geometry): void;
  6677. private _collideWithWorld;
  6678. }
  6679. }
  6680. declare function importScripts(...urls: string[]): void;
  6681. declare const safePostMessage: any;
  6682. declare module BABYLON {
  6683. var WorkerIncluded: boolean;
  6684. class CollisionCache {
  6685. private _meshes;
  6686. private _geometries;
  6687. getMeshes(): {
  6688. [n: number]: SerializedMesh;
  6689. };
  6690. getGeometries(): {
  6691. [s: number]: SerializedGeometry;
  6692. };
  6693. getMesh(id: any): SerializedMesh;
  6694. addMesh(mesh: SerializedMesh): void;
  6695. removeMesh(uniqueId: number): void;
  6696. getGeometry(id: string): SerializedGeometry;
  6697. addGeometry(geometry: SerializedGeometry): void;
  6698. removeGeometry(id: string): void;
  6699. }
  6700. class CollideWorker {
  6701. collider: Collider;
  6702. private _collisionCache;
  6703. private finalPosition;
  6704. private collisionsScalingMatrix;
  6705. private collisionTranformationMatrix;
  6706. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6707. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6708. private checkCollision;
  6709. private processCollisionsForSubMeshes;
  6710. private collideForSubMesh;
  6711. private checkSubmeshCollision;
  6712. }
  6713. interface ICollisionDetector {
  6714. onInit(payload: InitPayload): void;
  6715. onUpdate(payload: UpdatePayload): void;
  6716. onCollision(payload: CollidePayload): void;
  6717. }
  6718. class CollisionDetectorTransferable implements ICollisionDetector {
  6719. private _collisionCache;
  6720. onInit(payload: InitPayload): void;
  6721. onUpdate(payload: UpdatePayload): void;
  6722. onCollision(payload: CollidePayload): void;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. class IntersectionInfo {
  6727. bu: Nullable<number>;
  6728. bv: Nullable<number>;
  6729. distance: number;
  6730. faceId: number;
  6731. subMeshId: number;
  6732. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6733. }
  6734. /**
  6735. * Information about the result of picking within a scene
  6736. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6737. */
  6738. class PickingInfo {
  6739. /**
  6740. * If the pick collided with an object
  6741. */
  6742. hit: boolean;
  6743. /**
  6744. * Distance away where the pick collided
  6745. */
  6746. distance: number;
  6747. /**
  6748. * The location of pick collision
  6749. */
  6750. pickedPoint: Nullable<Vector3>;
  6751. /**
  6752. * The mesh corresponding the the pick collision
  6753. */
  6754. pickedMesh: Nullable<AbstractMesh>;
  6755. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6756. bu: number;
  6757. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6758. bv: number;
  6759. /** The id of the face on the mesh that was picked */
  6760. faceId: number;
  6761. /** Id of the the submesh that was picked */
  6762. subMeshId: number;
  6763. /** If a sprite was picked, this will be the sprite the pick collided with */
  6764. pickedSprite: Nullable<Sprite>;
  6765. /**
  6766. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6767. */
  6768. originMesh: Nullable<AbstractMesh>;
  6769. /**
  6770. * The ray that was used to perform the picking.
  6771. */
  6772. ray: Nullable<Ray>;
  6773. /**
  6774. * Gets the normal correspodning to the face the pick collided with
  6775. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6776. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6777. * @returns The normal correspodning to the face the pick collided with
  6778. */
  6779. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6780. /**
  6781. * Gets the texture coordinates of where the pick occured
  6782. * @returns the vector containing the coordnates of the texture
  6783. */
  6784. getTextureCoordinates(): Nullable<Vector2>;
  6785. }
  6786. }
  6787. declare module BABYLON {
  6788. class BoundingBox implements ICullable {
  6789. vectors: Vector3[];
  6790. center: Vector3;
  6791. centerWorld: Vector3;
  6792. extendSize: Vector3;
  6793. extendSizeWorld: Vector3;
  6794. directions: Vector3[];
  6795. vectorsWorld: Vector3[];
  6796. minimumWorld: Vector3;
  6797. maximumWorld: Vector3;
  6798. minimum: Vector3;
  6799. maximum: Vector3;
  6800. private _worldMatrix;
  6801. /**
  6802. * Creates a new bounding box
  6803. * @param min defines the minimum vector (in local space)
  6804. * @param max defines the maximum vector (in local space)
  6805. */
  6806. constructor(min: Vector3, max: Vector3);
  6807. /**
  6808. * Recreates the entire bounding box from scratch
  6809. * @param min defines the new minimum vector (in local space)
  6810. * @param max defines the new maximum vector (in local space)
  6811. */
  6812. reConstruct(min: Vector3, max: Vector3): void;
  6813. /**
  6814. * Scale the current bounding box by applying a scale factor
  6815. * @param factor defines the scale factor to apply
  6816. * @returns the current bounding box
  6817. */
  6818. scale(factor: number): BoundingBox;
  6819. getWorldMatrix(): Matrix;
  6820. setWorldMatrix(matrix: Matrix): BoundingBox;
  6821. /** @hidden */
  6822. _update(world: Matrix): void;
  6823. isInFrustum(frustumPlanes: Plane[]): boolean;
  6824. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6825. intersectsPoint(point: Vector3): boolean;
  6826. intersectsSphere(sphere: BoundingSphere): boolean;
  6827. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6828. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6829. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6830. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6831. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6832. }
  6833. }
  6834. declare module BABYLON {
  6835. interface ICullable {
  6836. isInFrustum(frustumPlanes: Plane[]): boolean;
  6837. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6838. }
  6839. class BoundingInfo implements ICullable {
  6840. minimum: Vector3;
  6841. maximum: Vector3;
  6842. boundingBox: BoundingBox;
  6843. boundingSphere: BoundingSphere;
  6844. private _isLocked;
  6845. constructor(minimum: Vector3, maximum: Vector3);
  6846. isLocked: boolean;
  6847. update(world: Matrix): void;
  6848. /**
  6849. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6850. * @param center New center of the bounding info
  6851. * @param extend New extend of the bounding info
  6852. */
  6853. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6854. /**
  6855. * Scale the current bounding info by applying a scale factor
  6856. * @param factor defines the scale factor to apply
  6857. * @returns the current bounding info
  6858. */
  6859. scale(factor: number): BoundingInfo;
  6860. /**
  6861. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6862. * @param frustumPlanes defines the frustum to test
  6863. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6864. * @returns true if the bounding info is in the frustum planes
  6865. */
  6866. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6867. /**
  6868. * Gets the world distance between the min and max points of the bounding box
  6869. */
  6870. readonly diagonalLength: number;
  6871. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6872. /** @hidden */
  6873. _checkCollision(collider: Collider): boolean;
  6874. intersectsPoint(point: Vector3): boolean;
  6875. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6876. }
  6877. }
  6878. declare module BABYLON {
  6879. class BoundingSphere {
  6880. center: Vector3;
  6881. radius: number;
  6882. centerWorld: Vector3;
  6883. radiusWorld: number;
  6884. minimum: Vector3;
  6885. maximum: Vector3;
  6886. /**
  6887. * Creates a new bounding sphere
  6888. * @param min defines the minimum vector (in local space)
  6889. * @param max defines the maximum vector (in local space)
  6890. */
  6891. constructor(min: Vector3, max: Vector3);
  6892. /**
  6893. * Recreates the entire bounding sphere from scratch
  6894. * @param min defines the new minimum vector (in local space)
  6895. * @param max defines the new maximum vector (in local space)
  6896. */
  6897. reConstruct(min: Vector3, max: Vector3): void;
  6898. /**
  6899. * Scale the current bounding sphere by applying a scale factor
  6900. * @param factor defines the scale factor to apply
  6901. * @returns the current bounding box
  6902. */
  6903. scale(factor: number): BoundingSphere;
  6904. /** @hidden */
  6905. _update(world: Matrix): void;
  6906. isInFrustum(frustumPlanes: Plane[]): boolean;
  6907. intersectsPoint(point: Vector3): boolean;
  6908. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6909. }
  6910. }
  6911. declare module BABYLON {
  6912. class Ray {
  6913. origin: Vector3;
  6914. direction: Vector3;
  6915. length: number;
  6916. private _edge1;
  6917. private _edge2;
  6918. private _pvec;
  6919. private _tvec;
  6920. private _qvec;
  6921. private _tmpRay;
  6922. constructor(origin: Vector3, direction: Vector3, length?: number);
  6923. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6924. intersectsBox(box: BoundingBox): boolean;
  6925. intersectsSphere(sphere: BoundingSphere): boolean;
  6926. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6927. intersectsPlane(plane: Plane): Nullable<number>;
  6928. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6929. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6930. private _comparePickingInfo;
  6931. private static smallnum;
  6932. private static rayl;
  6933. /**
  6934. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6935. * @param sega the first point of the segment to test the intersection against
  6936. * @param segb the second point of the segment to test the intersection against
  6937. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6938. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6939. */
  6940. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6941. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6942. static Zero(): Ray;
  6943. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6944. /**
  6945. * 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
  6946. * transformed to the given world matrix.
  6947. * @param origin The origin point
  6948. * @param end The end point
  6949. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6950. */
  6951. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6952. static Transform(ray: Ray, matrix: Matrix): Ray;
  6953. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6954. }
  6955. }
  6956. /**
  6957. * Module Debug contains the (visual) components to debug a scene correctly
  6958. */
  6959. declare module BABYLON.Debug {
  6960. /**
  6961. * The Axes viewer will show 3 axes in a specific point in space
  6962. */
  6963. class AxesViewer {
  6964. private _xline;
  6965. private _yline;
  6966. private _zline;
  6967. private _xmesh;
  6968. private _ymesh;
  6969. private _zmesh;
  6970. /**
  6971. * Gets the hosting scene
  6972. */
  6973. scene: Nullable<Scene>;
  6974. /**
  6975. * Gets or sets a number used to scale line length
  6976. */
  6977. scaleLines: number;
  6978. /**
  6979. * Creates a new AxesViewer
  6980. * @param scene defines the hosting scene
  6981. * @param scaleLines defines a number used to scale line length (1 by default)
  6982. */
  6983. constructor(scene: Scene, scaleLines?: number);
  6984. /**
  6985. * Force the viewer to update
  6986. * @param position defines the position of the viewer
  6987. * @param xaxis defines the x axis of the viewer
  6988. * @param yaxis defines the y axis of the viewer
  6989. * @param zaxis defines the z axis of the viewer
  6990. */
  6991. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6992. /** Releases resources */
  6993. dispose(): void;
  6994. }
  6995. }
  6996. declare module BABYLON.Debug {
  6997. /**
  6998. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6999. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7000. */
  7001. class BoneAxesViewer extends AxesViewer {
  7002. /**
  7003. * Gets or sets the target mesh where to display the axes viewer
  7004. */
  7005. mesh: Nullable<Mesh>;
  7006. /**
  7007. * Gets or sets the target bone where to display the axes viewer
  7008. */
  7009. bone: Nullable<Bone>;
  7010. /** Gets current position */
  7011. pos: Vector3;
  7012. /** Gets direction of X axis */
  7013. xaxis: Vector3;
  7014. /** Gets direction of Y axis */
  7015. yaxis: Vector3;
  7016. /** Gets direction of Z axis */
  7017. zaxis: Vector3;
  7018. /**
  7019. * Creates a new BoneAxesViewer
  7020. * @param scene defines the hosting scene
  7021. * @param bone defines the target bone
  7022. * @param mesh defines the target mesh
  7023. * @param scaleLines defines a scaling factor for line length (1 by default)
  7024. */
  7025. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7026. /**
  7027. * Force the viewer to update
  7028. */
  7029. update(): void;
  7030. /** Releases resources */
  7031. dispose(): void;
  7032. }
  7033. }
  7034. declare module BABYLON {
  7035. class DebugLayer {
  7036. private _scene;
  7037. static InspectorURL: string;
  7038. private _inspector;
  7039. private BJSINSPECTOR;
  7040. onPropertyChangedObservable: Observable<{
  7041. object: any;
  7042. property: string;
  7043. value: any;
  7044. initialValue: any;
  7045. }>;
  7046. constructor(scene: Scene);
  7047. /** Creates the inspector window. */
  7048. private _createInspector;
  7049. isVisible(): boolean;
  7050. hide(): void;
  7051. /**
  7052. *
  7053. * Launch the debugLayer.
  7054. *
  7055. * initialTab:
  7056. * | Value | Tab Name |
  7057. * | --- | --- |
  7058. * | 0 | Scene |
  7059. * | 1 | Console |
  7060. * | 2 | Stats |
  7061. * | 3 | Textures |
  7062. * | 4 | Mesh |
  7063. * | 5 | Light |
  7064. * | 6 | Material |
  7065. * | 7 | GLTF |
  7066. * | 8 | GUI |
  7067. * | 9 | Physics |
  7068. * | 10 | Camera |
  7069. * | 11 | Audio |
  7070. *
  7071. */
  7072. show(config?: {
  7073. popup?: boolean;
  7074. initialTab?: number;
  7075. parentElement?: HTMLElement;
  7076. newColors?: {
  7077. backgroundColor?: string;
  7078. backgroundColorLighter?: string;
  7079. backgroundColorLighter2?: string;
  7080. backgroundColorLighter3?: string;
  7081. color?: string;
  7082. colorTop?: string;
  7083. colorBot?: string;
  7084. };
  7085. }): void;
  7086. /**
  7087. * Gets the active tab
  7088. * @return the index of the active tab or -1 if the inspector is hidden
  7089. */
  7090. getActiveTab(): number;
  7091. }
  7092. }
  7093. declare module BABYLON.Debug {
  7094. /**
  7095. * Used to show the physics impostor around the specific mesh
  7096. */
  7097. class PhysicsViewer {
  7098. /** @hidden */
  7099. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7100. /** @hidden */
  7101. protected _meshes: Array<Nullable<AbstractMesh>>;
  7102. /** @hidden */
  7103. protected _scene: Nullable<Scene>;
  7104. /** @hidden */
  7105. protected _numMeshes: number;
  7106. /** @hidden */
  7107. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7108. private _renderFunction;
  7109. private _debugBoxMesh;
  7110. private _debugSphereMesh;
  7111. private _debugMaterial;
  7112. /**
  7113. * Creates a new PhysicsViewer
  7114. * @param scene defines the hosting scene
  7115. */
  7116. constructor(scene: Scene);
  7117. /** @hidden */
  7118. protected _updateDebugMeshes(): void;
  7119. /**
  7120. * Renders a specified physic impostor
  7121. * @param impostor defines the impostor to render
  7122. */
  7123. showImpostor(impostor: PhysicsImpostor): void;
  7124. /**
  7125. * Hides a specified physic impostor
  7126. * @param impostor defines the impostor to hide
  7127. */
  7128. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7129. private _getDebugMaterial;
  7130. private _getDebugBoxMesh;
  7131. private _getDebugSphereMesh;
  7132. private _getDebugMesh;
  7133. /** Releases all resources */
  7134. dispose(): void;
  7135. }
  7136. }
  7137. declare module BABYLON {
  7138. class RayHelper {
  7139. ray: Nullable<Ray>;
  7140. private _renderPoints;
  7141. private _renderLine;
  7142. private _renderFunction;
  7143. private _scene;
  7144. private _updateToMeshFunction;
  7145. private _attachedToMesh;
  7146. private _meshSpaceDirection;
  7147. private _meshSpaceOrigin;
  7148. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7149. constructor(ray: Ray);
  7150. show(scene: Scene, color?: Color3): void;
  7151. hide(): void;
  7152. private _render;
  7153. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7154. detachFromMesh(): void;
  7155. private _updateToMesh;
  7156. dispose(): void;
  7157. }
  7158. }
  7159. declare module BABYLON.Debug {
  7160. /**
  7161. * Class used to render a debug view of a given skeleton
  7162. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7163. */
  7164. class SkeletonViewer {
  7165. /** defines the skeleton to render */
  7166. skeleton: Skeleton;
  7167. /** defines the mesh attached to the skeleton */
  7168. mesh: AbstractMesh;
  7169. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7170. autoUpdateBonesMatrices: boolean;
  7171. /** defines the rendering group id to use with the viewer */
  7172. renderingGroupId: number;
  7173. /** Gets or sets the color used to render the skeleton */
  7174. color: Color3;
  7175. private _scene;
  7176. private _debugLines;
  7177. private _debugMesh;
  7178. private _isEnabled;
  7179. private _renderFunction;
  7180. /**
  7181. * Creates a new SkeletonViewer
  7182. * @param skeleton defines the skeleton to render
  7183. * @param mesh defines the mesh attached to the skeleton
  7184. * @param scene defines the hosting scene
  7185. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7186. * @param renderingGroupId defines the rendering group id to use with the viewer
  7187. */
  7188. constructor(
  7189. /** defines the skeleton to render */
  7190. skeleton: Skeleton,
  7191. /** defines the mesh attached to the skeleton */
  7192. mesh: AbstractMesh, scene: Scene,
  7193. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7194. autoUpdateBonesMatrices?: boolean,
  7195. /** defines the rendering group id to use with the viewer */
  7196. renderingGroupId?: number);
  7197. /** Gets or sets a boolean indicating if the viewer is enabled */
  7198. isEnabled: boolean;
  7199. private _getBonePosition;
  7200. private _getLinesForBonesWithLength;
  7201. private _getLinesForBonesNoLength;
  7202. /** Update the viewer to sync with current skeleton state */
  7203. update(): void;
  7204. /** Release associated resources */
  7205. dispose(): void;
  7206. }
  7207. }
  7208. declare module BABYLON {
  7209. /**
  7210. * Interface for attribute information associated with buffer instanciation
  7211. */
  7212. class InstancingAttributeInfo {
  7213. /**
  7214. * Index/offset of the attribute in the vertex shader
  7215. */
  7216. index: number;
  7217. /**
  7218. * size of the attribute, 1, 2, 3 or 4
  7219. */
  7220. attributeSize: number;
  7221. /**
  7222. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7223. * default is FLOAT
  7224. */
  7225. attribyteType: number;
  7226. /**
  7227. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7228. */
  7229. normalized: boolean;
  7230. /**
  7231. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7232. */
  7233. offset: number;
  7234. /**
  7235. * Name of the GLSL attribute, for debugging purpose only
  7236. */
  7237. attributeName: string;
  7238. }
  7239. /**
  7240. * Define options used to create a render target texture
  7241. */
  7242. class RenderTargetCreationOptions {
  7243. /**
  7244. * Specifies is mipmaps must be generated
  7245. */
  7246. generateMipMaps?: boolean;
  7247. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7248. generateDepthBuffer?: boolean;
  7249. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7250. generateStencilBuffer?: boolean;
  7251. /** Defines texture type (int by default) */
  7252. type?: number;
  7253. /** Defines sampling mode (trilinear by default) */
  7254. samplingMode?: number;
  7255. /** Defines format (RGBA by default) */
  7256. format?: number;
  7257. }
  7258. /**
  7259. * Define options used to create a depth texture
  7260. */
  7261. class DepthTextureCreationOptions {
  7262. /** Specifies whether or not a stencil should be allocated in the texture */
  7263. generateStencil?: boolean;
  7264. /** Specifies whether or not bilinear filtering is enable on the texture */
  7265. bilinearFiltering?: boolean;
  7266. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7267. comparisonFunction?: number;
  7268. /** Specifies if the created texture is a cube texture */
  7269. isCube?: boolean;
  7270. }
  7271. /**
  7272. * Class used to describe the capabilities of the engine relatively to the current browser
  7273. */
  7274. class EngineCapabilities {
  7275. /** Maximum textures units per fragment shader */
  7276. maxTexturesImageUnits: number;
  7277. /** Maximum texture units per vertex shader */
  7278. maxVertexTextureImageUnits: number;
  7279. /** Maximum textures units in the entire pipeline */
  7280. maxCombinedTexturesImageUnits: number;
  7281. /** Maximum texture size */
  7282. maxTextureSize: number;
  7283. /** Maximum cube texture size */
  7284. maxCubemapTextureSize: number;
  7285. /** Maximum render texture size */
  7286. maxRenderTextureSize: number;
  7287. /** Maximum number of vertex attributes */
  7288. maxVertexAttribs: number;
  7289. /** Maximum number of varyings */
  7290. maxVaryingVectors: number;
  7291. /** Maximum number of uniforms per vertex shader */
  7292. maxVertexUniformVectors: number;
  7293. /** Maximum number of uniforms per fragment shader */
  7294. maxFragmentUniformVectors: number;
  7295. /** Defines if standard derivates (dx/dy) are supported */
  7296. standardDerivatives: boolean;
  7297. /** Defines if s3tc texture compression is supported */
  7298. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7299. /** Defines if pvrtc texture compression is supported */
  7300. pvrtc: any;
  7301. /** Defines if etc1 texture compression is supported */
  7302. etc1: any;
  7303. /** Defines if etc2 texture compression is supported */
  7304. etc2: any;
  7305. /** Defines if astc texture compression is supported */
  7306. astc: any;
  7307. /** Defines if float textures are supported */
  7308. textureFloat: boolean;
  7309. /** Defines if vertex array objects are supported */
  7310. vertexArrayObject: boolean;
  7311. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7312. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7313. /** Gets the maximum level of anisotropy supported */
  7314. maxAnisotropy: number;
  7315. /** Defines if instancing is supported */
  7316. instancedArrays: boolean;
  7317. /** Defines if 32 bits indices are supported */
  7318. uintIndices: boolean;
  7319. /** Defines if high precision shaders are supported */
  7320. highPrecisionShaderSupported: boolean;
  7321. /** Defines if depth reading in the fragment shader is supported */
  7322. fragmentDepthSupported: boolean;
  7323. /** Defines if float texture linear filtering is supported*/
  7324. textureFloatLinearFiltering: boolean;
  7325. /** Defines if rendering to float textures is supported */
  7326. textureFloatRender: boolean;
  7327. /** Defines if half float textures are supported*/
  7328. textureHalfFloat: boolean;
  7329. /** Defines if half float texture linear filtering is supported*/
  7330. textureHalfFloatLinearFiltering: boolean;
  7331. /** Defines if rendering to half float textures is supported */
  7332. textureHalfFloatRender: boolean;
  7333. /** Defines if textureLOD shader command is supported */
  7334. textureLOD: boolean;
  7335. /** Defines if draw buffers extension is supported */
  7336. drawBuffersExtension: boolean;
  7337. /** Defines if depth textures are supported */
  7338. depthTextureExtension: boolean;
  7339. /** Defines if float color buffer are supported */
  7340. colorBufferFloat: boolean;
  7341. /** Gets disjoint timer query extension (null if not supported) */
  7342. timerQuery: EXT_disjoint_timer_query;
  7343. /** Defines if timestamp can be used with timer query */
  7344. canUseTimestampForTimerQuery: boolean;
  7345. }
  7346. /** Interface defining initialization parameters for Engine class */
  7347. interface EngineOptions extends WebGLContextAttributes {
  7348. /**
  7349. * Defines if the engine should no exceed a specified device ratio
  7350. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7351. */
  7352. limitDeviceRatio?: number;
  7353. /**
  7354. * Defines if webvr should be enabled automatically
  7355. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7356. */
  7357. autoEnableWebVR?: boolean;
  7358. /**
  7359. * Defines if webgl2 should be turned off even if supported
  7360. * @see http://doc.babylonjs.com/features/webgl2
  7361. */
  7362. disableWebGL2Support?: boolean;
  7363. /**
  7364. * Defines if webaudio should be initialized as well
  7365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7366. */
  7367. audioEngine?: boolean;
  7368. /**
  7369. * Defines if animations should run using a deterministic lock step
  7370. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7371. */
  7372. deterministicLockstep?: boolean;
  7373. /** Defines the maximum steps to use with deterministic lock step mode */
  7374. lockstepMaxSteps?: number;
  7375. /**
  7376. * Defines that engine should ignore context lost events
  7377. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7378. */
  7379. doNotHandleContextLost?: boolean;
  7380. }
  7381. /**
  7382. * Defines the interface used by display changed events
  7383. */
  7384. interface IDisplayChangedEventArgs {
  7385. /** Gets the vrDisplay object (if any) */
  7386. vrDisplay: Nullable<any>;
  7387. /** Gets a boolean indicating if webVR is supported */
  7388. vrSupported: boolean;
  7389. }
  7390. /**
  7391. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7392. */
  7393. class Engine {
  7394. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7395. static ExceptionList: ({
  7396. key: string;
  7397. capture: string;
  7398. captureConstraint: number;
  7399. targets: string[];
  7400. } | {
  7401. key: string;
  7402. capture: null;
  7403. captureConstraint: null;
  7404. targets: string[];
  7405. })[];
  7406. /** Gets the list of created engines */
  7407. static Instances: Engine[];
  7408. /**
  7409. * Gets the latest created engine
  7410. */
  7411. static readonly LastCreatedEngine: Nullable<Engine>;
  7412. /**
  7413. * Gets the latest created scene
  7414. */
  7415. static readonly LastCreatedScene: Nullable<Scene>;
  7416. /**
  7417. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7418. * @param flag defines which part of the materials must be marked as dirty
  7419. * @param predicate defines a predicate used to filter which materials should be affected
  7420. */
  7421. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7422. /**
  7423. * Hidden
  7424. */
  7425. static _TextureLoaders: IInternalTextureLoader[];
  7426. /** Defines that alpha blending is disabled */
  7427. static readonly ALPHA_DISABLE: number;
  7428. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7429. static readonly ALPHA_ADD: number;
  7430. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7431. static readonly ALPHA_COMBINE: number;
  7432. /** Defines that alpha blending to DEST - SRC * DEST */
  7433. static readonly ALPHA_SUBTRACT: number;
  7434. /** Defines that alpha blending to SRC * DEST */
  7435. static readonly ALPHA_MULTIPLY: number;
  7436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7437. static readonly ALPHA_MAXIMIZED: number;
  7438. /** Defines that alpha blending to SRC + DEST */
  7439. static readonly ALPHA_ONEONE: number;
  7440. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7441. static readonly ALPHA_PREMULTIPLIED: number;
  7442. /**
  7443. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7444. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7445. */
  7446. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7447. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7448. static readonly ALPHA_INTERPOLATE: number;
  7449. /**
  7450. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7451. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7452. */
  7453. static readonly ALPHA_SCREENMODE: number;
  7454. /** Defines that the ressource is not delayed*/
  7455. static readonly DELAYLOADSTATE_NONE: number;
  7456. /** Defines that the ressource was successfully delay loaded */
  7457. static readonly DELAYLOADSTATE_LOADED: number;
  7458. /** Defines that the ressource is currently delay loading */
  7459. static readonly DELAYLOADSTATE_LOADING: number;
  7460. /** Defines that the ressource is delayed and has not started loading */
  7461. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7463. static readonly NEVER: number;
  7464. /** 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 */
  7465. static readonly ALWAYS: number;
  7466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7467. static readonly LESS: number;
  7468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7469. static readonly EQUAL: number;
  7470. /** 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 */
  7471. static readonly LEQUAL: number;
  7472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7473. static readonly GREATER: number;
  7474. /** 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 */
  7475. static readonly GEQUAL: number;
  7476. /** 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 */
  7477. static readonly NOTEQUAL: number;
  7478. /** Passed to stencilOperation to specify that stencil value must be kept */
  7479. static readonly KEEP: number;
  7480. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7481. static readonly REPLACE: number;
  7482. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7483. static readonly INCR: number;
  7484. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7485. static readonly DECR: number;
  7486. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7487. static readonly INVERT: number;
  7488. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7489. static readonly INCR_WRAP: number;
  7490. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7491. static readonly DECR_WRAP: number;
  7492. /** Texture is not repeating outside of 0..1 UVs */
  7493. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7494. /** Texture is repeating outside of 0..1 UVs */
  7495. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7496. /** Texture is repeating and mirrored */
  7497. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7498. /** ALPHA */
  7499. static readonly TEXTUREFORMAT_ALPHA: number;
  7500. /** LUMINANCE */
  7501. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7502. /** LUMINANCE_ALPHA */
  7503. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7504. /** RGB */
  7505. static readonly TEXTUREFORMAT_RGB: number;
  7506. /** RGBA */
  7507. static readonly TEXTUREFORMAT_RGBA: number;
  7508. /** RED */
  7509. static readonly TEXTUREFORMAT_RED: number;
  7510. /** RED (2nd reference) */
  7511. static readonly TEXTUREFORMAT_R: number;
  7512. /** RG */
  7513. static readonly TEXTUREFORMAT_RG: number;
  7514. /** RED_INTEGER */
  7515. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7516. /** RED_INTEGER (2nd reference) */
  7517. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7518. /** RG_INTEGER */
  7519. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7520. /** RGB_INTEGER */
  7521. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7522. /** RGBA_INTEGER */
  7523. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7524. /** UNSIGNED_BYTE */
  7525. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7526. /** UNSIGNED_BYTE (2nd reference) */
  7527. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7528. /** FLOAT */
  7529. static readonly TEXTURETYPE_FLOAT: number;
  7530. /** HALF_FLOAT */
  7531. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7532. /** BYTE */
  7533. static readonly TEXTURETYPE_BYTE: number;
  7534. /** SHORT */
  7535. static readonly TEXTURETYPE_SHORT: number;
  7536. /** UNSIGNED_SHORT */
  7537. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7538. /** INT */
  7539. static readonly TEXTURETYPE_INT: number;
  7540. /** UNSIGNED_INT */
  7541. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7542. /** UNSIGNED_SHORT_4_4_4_4 */
  7543. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7544. /** UNSIGNED_SHORT_5_5_5_1 */
  7545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7546. /** UNSIGNED_SHORT_5_6_5 */
  7547. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7548. /** UNSIGNED_INT_2_10_10_10_REV */
  7549. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7550. /** UNSIGNED_INT_24_8 */
  7551. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7552. /** UNSIGNED_INT_10F_11F_11F_REV */
  7553. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7554. /** UNSIGNED_INT_5_9_9_9_REV */
  7555. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7556. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7557. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7558. /** nearest is mag = nearest and min = nearest and mip = linear */
  7559. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7560. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7561. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7562. /** Trilinear is mag = linear and min = linear and mip = linear */
  7563. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7564. /** nearest is mag = nearest and min = nearest and mip = linear */
  7565. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7567. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7568. /** Trilinear is mag = linear and min = linear and mip = linear */
  7569. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7570. /** mag = nearest and min = nearest and mip = nearest */
  7571. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7572. /** mag = nearest and min = linear and mip = nearest */
  7573. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7574. /** mag = nearest and min = linear and mip = linear */
  7575. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7576. /** mag = nearest and min = linear and mip = none */
  7577. static readonly TEXTURE_NEAREST_LINEAR: number;
  7578. /** mag = nearest and min = nearest and mip = none */
  7579. static readonly TEXTURE_NEAREST_NEAREST: number;
  7580. /** mag = linear and min = nearest and mip = nearest */
  7581. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7582. /** mag = linear and min = nearest and mip = linear */
  7583. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7584. /** mag = linear and min = linear and mip = none */
  7585. static readonly TEXTURE_LINEAR_LINEAR: number;
  7586. /** mag = linear and min = nearest and mip = none */
  7587. static readonly TEXTURE_LINEAR_NEAREST: number;
  7588. /** Explicit coordinates mode */
  7589. static readonly TEXTURE_EXPLICIT_MODE: number;
  7590. /** Spherical coordinates mode */
  7591. static readonly TEXTURE_SPHERICAL_MODE: number;
  7592. /** Planar coordinates mode */
  7593. static readonly TEXTURE_PLANAR_MODE: number;
  7594. /** Cubic coordinates mode */
  7595. static readonly TEXTURE_CUBIC_MODE: number;
  7596. /** Projection coordinates mode */
  7597. static readonly TEXTURE_PROJECTION_MODE: number;
  7598. /** Skybox coordinates mode */
  7599. static readonly TEXTURE_SKYBOX_MODE: number;
  7600. /** Inverse Cubic coordinates mode */
  7601. static readonly TEXTURE_INVCUBIC_MODE: number;
  7602. /** Equirectangular coordinates mode */
  7603. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7604. /** Equirectangular Fixed coordinates mode */
  7605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7606. /** Equirectangular Fixed Mirrored coordinates mode */
  7607. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7608. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7609. static readonly SCALEMODE_FLOOR: number;
  7610. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7611. static readonly SCALEMODE_NEAREST: number;
  7612. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7613. static readonly SCALEMODE_CEILING: number;
  7614. /**
  7615. * Returns the current version of the framework
  7616. */
  7617. static readonly Version: string;
  7618. /**
  7619. * Gets or sets the epsilon value used by collision engine
  7620. */
  7621. static CollisionsEpsilon: number;
  7622. /**
  7623. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7624. */
  7625. static CodeRepository: string;
  7626. /**
  7627. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7628. */
  7629. static ShadersRepository: string;
  7630. /**
  7631. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7632. */
  7633. forcePOTTextures: boolean;
  7634. /**
  7635. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7636. */
  7637. isFullscreen: boolean;
  7638. /**
  7639. * Gets a boolean indicating if the pointer is currently locked
  7640. */
  7641. isPointerLock: boolean;
  7642. /**
  7643. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7644. */
  7645. cullBackFaces: boolean;
  7646. /**
  7647. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7648. */
  7649. renderEvenInBackground: boolean;
  7650. /**
  7651. * Gets or sets a boolean indicating that cache can be kept between frames
  7652. */
  7653. preventCacheWipeBetweenFrames: boolean;
  7654. /**
  7655. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7656. **/
  7657. enableOfflineSupport: boolean;
  7658. /**
  7659. * 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)
  7660. **/
  7661. disableManifestCheck: boolean;
  7662. /**
  7663. * Gets the list of created scenes
  7664. */
  7665. scenes: Scene[];
  7666. /**
  7667. * Gets the list of created postprocesses
  7668. */
  7669. postProcesses: PostProcess[];
  7670. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7671. validateShaderPrograms: boolean;
  7672. /**
  7673. * Observable event triggered each time the rendering canvas is resized
  7674. */
  7675. onResizeObservable: Observable<Engine>;
  7676. /**
  7677. * Observable event triggered each time the canvas loses focus
  7678. */
  7679. onCanvasBlurObservable: Observable<Engine>;
  7680. /**
  7681. * Observable event triggered each time the canvas gains focus
  7682. */
  7683. onCanvasFocusObservable: Observable<Engine>;
  7684. /**
  7685. * Observable event triggered each time the canvas receives pointerout event
  7686. */
  7687. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7688. /**
  7689. * Observable event triggered before each texture is initialized
  7690. */
  7691. onBeforeTextureInitObservable: Observable<Texture>;
  7692. private _vrDisplay;
  7693. private _vrSupported;
  7694. private _oldSize;
  7695. private _oldHardwareScaleFactor;
  7696. private _vrExclusivePointerMode;
  7697. private _webVRInitPromise;
  7698. /**
  7699. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7700. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7701. */
  7702. readonly isInVRExclusivePointerMode: boolean;
  7703. /**
  7704. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7705. */
  7706. disableUniformBuffers: boolean;
  7707. /** @hidden */
  7708. _uniformBuffers: UniformBuffer[];
  7709. /**
  7710. * Gets a boolean indicating that the engine supports uniform buffers
  7711. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7712. */
  7713. readonly supportsUniformBuffers: boolean;
  7714. /**
  7715. * Observable raised when the engine begins a new frame
  7716. */
  7717. onBeginFrameObservable: Observable<Engine>;
  7718. /**
  7719. * Observable raised when the engine ends the current frame
  7720. */
  7721. onEndFrameObservable: Observable<Engine>;
  7722. /**
  7723. * Observable raised when the engine is about to compile a shader
  7724. */
  7725. onBeforeShaderCompilationObservable: Observable<Engine>;
  7726. /**
  7727. * Observable raised when the engine has jsut compiled a shader
  7728. */
  7729. onAfterShaderCompilationObservable: Observable<Engine>;
  7730. /** @hidden */
  7731. _gl: WebGLRenderingContext;
  7732. private _renderingCanvas;
  7733. private _windowIsBackground;
  7734. private _webGLVersion;
  7735. /**
  7736. * Gets a boolean indicating that only power of 2 textures are supported
  7737. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7738. */
  7739. readonly needPOTTextures: boolean;
  7740. /** @hidden */
  7741. _badOS: boolean;
  7742. /** @hidden */
  7743. _badDesktopOS: boolean;
  7744. /**
  7745. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7746. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7747. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7748. */
  7749. disableTextureBindingOptimization: boolean;
  7750. /**
  7751. * Gets the audio engine
  7752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7753. * @ignorenaming
  7754. */
  7755. static audioEngine: AudioEngine;
  7756. private _onFocus;
  7757. private _onBlur;
  7758. private _onCanvasPointerOut;
  7759. private _onCanvasBlur;
  7760. private _onCanvasFocus;
  7761. private _onFullscreenChange;
  7762. private _onPointerLockChange;
  7763. private _onVRDisplayPointerRestricted;
  7764. private _onVRDisplayPointerUnrestricted;
  7765. private _onVrDisplayConnect;
  7766. private _onVrDisplayDisconnect;
  7767. private _onVrDisplayPresentChange;
  7768. /**
  7769. * Observable signaled when VR display mode changes
  7770. */
  7771. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7772. /**
  7773. * Observable signaled when VR request present is complete
  7774. */
  7775. onVRRequestPresentComplete: Observable<boolean>;
  7776. /**
  7777. * Observable signaled when VR request present starts
  7778. */
  7779. onVRRequestPresentStart: Observable<Engine>;
  7780. private _hardwareScalingLevel;
  7781. /** @hidden */
  7782. protected _caps: EngineCapabilities;
  7783. private _pointerLockRequested;
  7784. private _isStencilEnable;
  7785. private _colorWrite;
  7786. private _loadingScreen;
  7787. /** @hidden */
  7788. _drawCalls: PerfCounter;
  7789. /** @hidden */
  7790. _textureCollisions: PerfCounter;
  7791. private _glVersion;
  7792. private _glRenderer;
  7793. private _glVendor;
  7794. private _videoTextureSupported;
  7795. private _renderingQueueLaunched;
  7796. private _activeRenderLoops;
  7797. private _deterministicLockstep;
  7798. private _lockstepMaxSteps;
  7799. /**
  7800. * Observable signaled when a context lost event is raised
  7801. */
  7802. onContextLostObservable: Observable<Engine>;
  7803. /**
  7804. * Observable signaled when a context restored event is raised
  7805. */
  7806. onContextRestoredObservable: Observable<Engine>;
  7807. private _onContextLost;
  7808. private _onContextRestored;
  7809. private _contextWasLost;
  7810. private _doNotHandleContextLost;
  7811. /**
  7812. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7814. */
  7815. doNotHandleContextLost: boolean;
  7816. private _performanceMonitor;
  7817. private _fps;
  7818. private _deltaTime;
  7819. /**
  7820. * Turn this value on if you want to pause FPS computation when in background
  7821. */
  7822. disablePerformanceMonitorInBackground: boolean;
  7823. /**
  7824. * Gets the performance monitor attached to this engine
  7825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7826. */
  7827. readonly performanceMonitor: PerformanceMonitor;
  7828. /** @hidden */
  7829. protected _depthCullingState: _DepthCullingState;
  7830. /** @hidden */
  7831. protected _stencilState: _StencilState;
  7832. /** @hidden */
  7833. protected _alphaState: _AlphaState;
  7834. /** @hidden */
  7835. protected _alphaMode: number;
  7836. protected _internalTexturesCache: InternalTexture[];
  7837. /** @hidden */
  7838. protected _activeChannel: number;
  7839. private _currentTextureChannel;
  7840. /** @hidden */
  7841. protected _boundTexturesCache: {
  7842. [key: string]: Nullable<InternalTexture>;
  7843. };
  7844. /** @hidden */
  7845. protected _currentEffect: Nullable<Effect>;
  7846. /** @hidden */
  7847. protected _currentProgram: Nullable<WebGLProgram>;
  7848. private _compiledEffects;
  7849. private _vertexAttribArraysEnabled;
  7850. /** @hidden */
  7851. protected _cachedViewport: Nullable<Viewport>;
  7852. private _cachedVertexArrayObject;
  7853. /** @hidden */
  7854. protected _cachedVertexBuffers: any;
  7855. /** @hidden */
  7856. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7857. /** @hidden */
  7858. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7859. /** @hidden */
  7860. protected _currentRenderTarget: Nullable<InternalTexture>;
  7861. private _uintIndicesCurrentlySet;
  7862. private _currentBoundBuffer;
  7863. /** @hidden */
  7864. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7865. private _currentBufferPointers;
  7866. private _currentInstanceLocations;
  7867. private _currentInstanceBuffers;
  7868. private _textureUnits;
  7869. private _firstBoundInternalTextureTracker;
  7870. private _lastBoundInternalTextureTracker;
  7871. private _workingCanvas;
  7872. private _workingContext;
  7873. private _rescalePostProcess;
  7874. private _dummyFramebuffer;
  7875. private _externalData;
  7876. private _bindedRenderFunction;
  7877. private _vaoRecordInProgress;
  7878. private _mustWipeVertexAttributes;
  7879. private _emptyTexture;
  7880. private _emptyCubeTexture;
  7881. private _emptyTexture3D;
  7882. private _frameHandler;
  7883. private _nextFreeTextureSlots;
  7884. private _maxSimultaneousTextures;
  7885. private _activeRequests;
  7886. private _texturesSupported;
  7887. private _textureFormatInUse;
  7888. /**
  7889. * Gets the list of texture formats supported
  7890. */
  7891. readonly texturesSupported: Array<string>;
  7892. /**
  7893. * Gets the list of texture formats in use
  7894. */
  7895. readonly textureFormatInUse: Nullable<string>;
  7896. /**
  7897. * Gets the current viewport
  7898. */
  7899. readonly currentViewport: Nullable<Viewport>;
  7900. /**
  7901. * Gets the default empty texture
  7902. */
  7903. readonly emptyTexture: InternalTexture;
  7904. /**
  7905. * Gets the default empty 3D texture
  7906. */
  7907. readonly emptyTexture3D: InternalTexture;
  7908. /**
  7909. * Gets the default empty cube texture
  7910. */
  7911. readonly emptyCubeTexture: InternalTexture;
  7912. /**
  7913. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7914. */
  7915. readonly premultipliedAlpha: boolean;
  7916. /**
  7917. * Creates a new engine
  7918. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  7919. * @param antialias defines enable antialiasing (default: false)
  7920. * @param options defines further options to be sent to the getContext() function
  7921. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7922. */
  7923. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7924. private _rebuildInternalTextures;
  7925. private _rebuildEffects;
  7926. private _rebuildBuffers;
  7927. private _initGLContext;
  7928. /**
  7929. * Gets version of the current webGL context
  7930. */
  7931. readonly webGLVersion: number;
  7932. /**
  7933. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7934. */
  7935. readonly isStencilEnable: boolean;
  7936. private _prepareWorkingCanvas;
  7937. /**
  7938. * Reset the texture cache to empty state
  7939. */
  7940. resetTextureCache(): void;
  7941. /**
  7942. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7943. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7944. * @returns true if engine is in deterministic lock step mode
  7945. */
  7946. isDeterministicLockStep(): boolean;
  7947. /**
  7948. * Gets the max steps when engine is running in deterministic lock step
  7949. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7950. * @returns the max steps
  7951. */
  7952. getLockstepMaxSteps(): number;
  7953. /**
  7954. * Gets an object containing information about the current webGL context
  7955. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7956. */
  7957. getGlInfo(): {
  7958. vendor: string;
  7959. renderer: string;
  7960. version: string;
  7961. };
  7962. /**
  7963. * Gets current aspect ratio
  7964. * @param camera defines the camera to use to get the aspect ratio
  7965. * @param useScreen defines if screen size must be used (or the current render target if any)
  7966. * @returns a number defining the aspect ratio
  7967. */
  7968. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7969. /**
  7970. * Gets current screen aspect ratio
  7971. * @returns a number defining the aspect ratio
  7972. */
  7973. getScreenAspectRatio(): number;
  7974. /**
  7975. * Gets the current render width
  7976. * @param useScreen defines if screen size must be used (or the current render target if any)
  7977. * @returns a number defining the current render width
  7978. */
  7979. getRenderWidth(useScreen?: boolean): number;
  7980. /**
  7981. * Gets the current render height
  7982. * @param useScreen defines if screen size must be used (or the current render target if any)
  7983. * @returns a number defining the current render height
  7984. */
  7985. getRenderHeight(useScreen?: boolean): number;
  7986. /**
  7987. * Gets the HTML canvas attached with the current webGL context
  7988. * @returns a HTML canvas
  7989. */
  7990. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7991. /**
  7992. * Gets the client rect of the HTML canvas attached with the current webGL context
  7993. * @returns a client rectanglee
  7994. */
  7995. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7996. /**
  7997. * Defines the hardware scaling level.
  7998. * By default the hardware scaling level is computed from the window device ratio.
  7999. * 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.
  8000. * @param level defines the level to use
  8001. */
  8002. setHardwareScalingLevel(level: number): void;
  8003. /**
  8004. * Gets the current hardware scaling level.
  8005. * By default the hardware scaling level is computed from the window device ratio.
  8006. * 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.
  8007. * @returns a number indicating the current hardware scaling level
  8008. */
  8009. getHardwareScalingLevel(): number;
  8010. /**
  8011. * Gets the list of loaded textures
  8012. * @returns an array containing all loaded textures
  8013. */
  8014. getLoadedTexturesCache(): InternalTexture[];
  8015. /**
  8016. * Gets the object containing all engine capabilities
  8017. * @returns the EngineCapabilities object
  8018. */
  8019. getCaps(): EngineCapabilities;
  8020. /** @hidden */
  8021. readonly drawCalls: number;
  8022. /** @hidden */
  8023. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  8024. /**
  8025. * Gets the current depth function
  8026. * @returns a number defining the depth function
  8027. */
  8028. getDepthFunction(): Nullable<number>;
  8029. /**
  8030. * Sets the current depth function
  8031. * @param depthFunc defines the function to use
  8032. */
  8033. setDepthFunction(depthFunc: number): void;
  8034. /**
  8035. * Sets the current depth function to GREATER
  8036. */
  8037. setDepthFunctionToGreater(): void;
  8038. /**
  8039. * Sets the current depth function to GEQUAL
  8040. */
  8041. setDepthFunctionToGreaterOrEqual(): void;
  8042. /**
  8043. * Sets the current depth function to LESS
  8044. */
  8045. setDepthFunctionToLess(): void;
  8046. /**
  8047. * Sets the current depth function to LEQUAL
  8048. */
  8049. setDepthFunctionToLessOrEqual(): void;
  8050. /**
  8051. * Gets a boolean indicating if stencil buffer is enabled
  8052. * @returns the current stencil buffer state
  8053. */
  8054. getStencilBuffer(): boolean;
  8055. /**
  8056. * Enable or disable the stencil buffer
  8057. * @param enable defines if the stencil buffer must be enabled or disabled
  8058. */
  8059. setStencilBuffer(enable: boolean): void;
  8060. /**
  8061. * Gets the current stencil mask
  8062. * @returns a number defining the new stencil mask to use
  8063. */
  8064. getStencilMask(): number;
  8065. /**
  8066. * Sets the current stencil mask
  8067. * @param mask defines the new stencil mask to use
  8068. */
  8069. setStencilMask(mask: number): void;
  8070. /**
  8071. * Gets the current stencil function
  8072. * @returns a number defining the stencil function to use
  8073. */
  8074. getStencilFunction(): number;
  8075. /**
  8076. * Gets the current stencil reference value
  8077. * @returns a number defining the stencil reference value to use
  8078. */
  8079. getStencilFunctionReference(): number;
  8080. /**
  8081. * Gets the current stencil mask
  8082. * @returns a number defining the stencil mask to use
  8083. */
  8084. getStencilFunctionMask(): number;
  8085. /**
  8086. * Sets the current stencil function
  8087. * @param stencilFunc defines the new stencil function to use
  8088. */
  8089. setStencilFunction(stencilFunc: number): void;
  8090. /**
  8091. * Sets the current stencil reference
  8092. * @param reference defines the new stencil reference to use
  8093. */
  8094. setStencilFunctionReference(reference: number): void;
  8095. /**
  8096. * Sets the current stencil mask
  8097. * @param mask defines the new stencil mask to use
  8098. */
  8099. setStencilFunctionMask(mask: number): void;
  8100. /**
  8101. * Gets the current stencil operation when stencil fails
  8102. * @returns a number defining stencil operation to use when stencil fails
  8103. */
  8104. getStencilOperationFail(): number;
  8105. /**
  8106. * Gets the current stencil operation when depth fails
  8107. * @returns a number defining stencil operation to use when depth fails
  8108. */
  8109. getStencilOperationDepthFail(): number;
  8110. /**
  8111. * Gets the current stencil operation when stencil passes
  8112. * @returns a number defining stencil operation to use when stencil passes
  8113. */
  8114. getStencilOperationPass(): number;
  8115. /**
  8116. * Sets the stencil operation to use when stencil fails
  8117. * @param operation defines the stencil operation to use when stencil fails
  8118. */
  8119. setStencilOperationFail(operation: number): void;
  8120. /**
  8121. * Sets the stencil operation to use when depth fails
  8122. * @param operation defines the stencil operation to use when depth fails
  8123. */
  8124. setStencilOperationDepthFail(operation: number): void;
  8125. /**
  8126. * Sets the stencil operation to use when stencil passes
  8127. * @param operation defines the stencil operation to use when stencil passes
  8128. */
  8129. setStencilOperationPass(operation: number): void;
  8130. /**
  8131. * Sets a boolean indicating if the dithering state is enabled or disabled
  8132. * @param value defines the dithering state
  8133. */
  8134. setDitheringState(value: boolean): void;
  8135. /**
  8136. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8137. * @param value defines the rasterizer state
  8138. */
  8139. setRasterizerState(value: boolean): void;
  8140. /**
  8141. * stop executing a render loop function and remove it from the execution array
  8142. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8143. */
  8144. stopRenderLoop(renderFunction?: () => void): void;
  8145. /** @hidden */
  8146. _renderLoop(): void;
  8147. /**
  8148. * Register and execute a render loop. The engine can have more than one render function
  8149. * @param renderFunction defines the function to continuously execute
  8150. */
  8151. runRenderLoop(renderFunction: () => void): void;
  8152. /**
  8153. * Toggle full screen mode
  8154. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8155. * @param options defines an option object to be sent to the requestFullscreen function
  8156. */
  8157. switchFullscreen(requestPointerLock: boolean): void;
  8158. /**
  8159. * Clear the current render buffer or the current render target (if any is set up)
  8160. * @param color defines the color to use
  8161. * @param backBuffer defines if the back buffer must be cleared
  8162. * @param depth defines if the depth buffer must be cleared
  8163. * @param stencil defines if the stencil buffer must be cleared
  8164. */
  8165. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8166. /**
  8167. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8168. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8169. * @param y defines the y-coordinate of the corner of the clear rectangle
  8170. * @param width defines the width of the clear rectangle
  8171. * @param height defines the height of the clear rectangle
  8172. * @param clearColor defines the clear color
  8173. */
  8174. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8175. private _viewportCached;
  8176. /** @hidden */
  8177. _viewport(x: number, y: number, width: number, height: number): void;
  8178. /**
  8179. * Set the WebGL's viewport
  8180. * @param viewport defines the viewport element to be used
  8181. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8182. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8183. */
  8184. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8185. /**
  8186. * Directly set the WebGL Viewport
  8187. * @param x defines the x coordinate of the viewport (in screen space)
  8188. * @param y defines the y coordinate of the viewport (in screen space)
  8189. * @param width defines the width of the viewport (in screen space)
  8190. * @param height defines the height of the viewport (in screen space)
  8191. * @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
  8192. */
  8193. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8194. /**
  8195. * Begin a new frame
  8196. */
  8197. beginFrame(): void;
  8198. /**
  8199. * Enf the current frame
  8200. */
  8201. endFrame(): void;
  8202. /**
  8203. * Resize the view according to the canvas' size
  8204. */
  8205. resize(): void;
  8206. /**
  8207. * Force a specific size of the canvas
  8208. * @param width defines the new canvas' width
  8209. * @param height defines the new canvas' height
  8210. */
  8211. setSize(width: number, height: number): void;
  8212. /**
  8213. * Gets a boolean indicating if a webVR device was detected
  8214. * @returns true if a webVR device was detected
  8215. */
  8216. isVRDevicePresent(): boolean;
  8217. /**
  8218. * Gets the current webVR device
  8219. * @returns the current webVR device (or null)
  8220. */
  8221. getVRDevice(): any;
  8222. /**
  8223. * Initializes a webVR display and starts listening to display change events
  8224. * The onVRDisplayChangedObservable will be notified upon these changes
  8225. * @returns The onVRDisplayChangedObservable
  8226. */
  8227. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8228. /**
  8229. * Initializes a webVR display and starts listening to display change events
  8230. * The onVRDisplayChangedObservable will be notified upon these changes
  8231. * @returns A promise containing a VRDisplay and if vr is supported
  8232. */
  8233. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8234. /**
  8235. * Call this function to switch to webVR mode
  8236. * Will do nothing if webVR is not supported or if there is no webVR device
  8237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8238. */
  8239. enableVR(): void;
  8240. /**
  8241. * Call this function to leave webVR mode
  8242. * Will do nothing if webVR is not supported or if there is no webVR device
  8243. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8244. */
  8245. disableVR(): void;
  8246. private _onVRFullScreenTriggered;
  8247. private _getVRDisplaysAsync;
  8248. /**
  8249. * Binds the frame buffer to the specified texture.
  8250. * @param texture The texture to render to or null for the default canvas
  8251. * @param faceIndex The face of the texture to render to in case of cube texture
  8252. * @param requiredWidth The width of the target to render to
  8253. * @param requiredHeight The height of the target to render to
  8254. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8255. * @param depthStencilTexture The depth stencil texture to use to render
  8256. * @param lodLevel defines le lod level to bind to the frame buffer
  8257. */
  8258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8259. private bindUnboundFramebuffer;
  8260. /**
  8261. * Unbind the current render target texture from the webGL context
  8262. * @param texture defines the render target texture to unbind
  8263. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8264. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8265. */
  8266. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8267. /**
  8268. * Unbind a list of render target textures from the webGL context
  8269. * This is used only when drawBuffer extension or webGL2 are active
  8270. * @param textures defines the render target textures to unbind
  8271. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8272. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8273. */
  8274. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8275. /**
  8276. * Force the mipmap generation for the given render target texture
  8277. * @param texture defines the render target texture to use
  8278. */
  8279. generateMipMapsForCubemap(texture: InternalTexture): void;
  8280. /**
  8281. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8282. */
  8283. flushFramebuffer(): void;
  8284. /**
  8285. * Unbind the current render target and bind the default framebuffer
  8286. */
  8287. restoreDefaultFramebuffer(): void;
  8288. /**
  8289. * Create an uniform buffer
  8290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8291. * @param elements defines the content of the uniform buffer
  8292. * @returns the webGL uniform buffer
  8293. */
  8294. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8295. /**
  8296. * Create a dynamic uniform buffer
  8297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8298. * @param elements defines the content of the uniform buffer
  8299. * @returns the webGL uniform buffer
  8300. */
  8301. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8302. /**
  8303. * Update an existing uniform buffer
  8304. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8305. * @param uniformBuffer defines the target uniform buffer
  8306. * @param elements defines the content to update
  8307. * @param offset defines the offset in the uniform buffer where update should start
  8308. * @param count defines the size of the data to update
  8309. */
  8310. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8311. private _resetVertexBufferBinding;
  8312. /**
  8313. * Creates a vertex buffer
  8314. * @param data the data for the vertex buffer
  8315. * @returns the new WebGL static buffer
  8316. */
  8317. createVertexBuffer(data: DataArray): WebGLBuffer;
  8318. /**
  8319. * Creates a dynamic vertex buffer
  8320. * @param data the data for the dynamic vertex buffer
  8321. * @returns the new WebGL dynamic buffer
  8322. */
  8323. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8324. /**
  8325. * Update a dynamic index buffer
  8326. * @param indexBuffer defines the target index buffer
  8327. * @param indices defines the data to update
  8328. * @param offset defines the offset in the target index buffer where update should start
  8329. */
  8330. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8331. /**
  8332. * Updates a dynamic vertex buffer.
  8333. * @param vertexBuffer the vertex buffer to update
  8334. * @param data the data used to update the vertex buffer
  8335. * @param byteOffset the byte offset of the data
  8336. * @param byteLength the byte length of the data
  8337. */
  8338. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8339. private _resetIndexBufferBinding;
  8340. /**
  8341. * Creates a new index buffer
  8342. * @param indices defines the content of the index buffer
  8343. * @param updatable defines if the index buffer must be updatable
  8344. * @returns a new webGL buffer
  8345. */
  8346. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8347. /**
  8348. * Bind a webGL buffer to the webGL context
  8349. * @param buffer defines the buffer to bind
  8350. */
  8351. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8352. /**
  8353. * Bind an uniform buffer to the current webGL context
  8354. * @param buffer defines the buffer to bind
  8355. */
  8356. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8357. /**
  8358. * Bind a buffer to the current webGL context at a given location
  8359. * @param buffer defines the buffer to bind
  8360. * @param location defines the index where to bind the buffer
  8361. */
  8362. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8363. /**
  8364. * Bind a specific block at a given index in a specific shader program
  8365. * @param shaderProgram defines the shader program
  8366. * @param blockName defines the block name
  8367. * @param index defines the index where to bind the block
  8368. */
  8369. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8370. private bindIndexBuffer;
  8371. private bindBuffer;
  8372. /**
  8373. * update the bound buffer with the given data
  8374. * @param data defines the data to update
  8375. */
  8376. updateArrayBuffer(data: Float32Array): void;
  8377. private _vertexAttribPointer;
  8378. private _bindIndexBufferWithCache;
  8379. private _bindVertexBuffersAttributes;
  8380. /**
  8381. * Records a vertex array object
  8382. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8383. * @param vertexBuffers defines the list of vertex buffers to store
  8384. * @param indexBuffer defines the index buffer to store
  8385. * @param effect defines the effect to store
  8386. * @returns the new vertex array object
  8387. */
  8388. recordVertexArrayObject(vertexBuffers: {
  8389. [key: string]: VertexBuffer;
  8390. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8391. /**
  8392. * Bind a specific vertex array object
  8393. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8394. * @param vertexArrayObject defines the vertex array object to bind
  8395. * @param indexBuffer defines the index buffer to bind
  8396. */
  8397. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8398. /**
  8399. * Bind webGl buffers directly to the webGL context
  8400. * @param vertexBuffer defines the vertex buffer to bind
  8401. * @param indexBuffer defines the index buffer to bind
  8402. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8403. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8404. * @param effect defines the effect associated with the vertex buffer
  8405. */
  8406. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8407. private _unbindVertexArrayObject;
  8408. /**
  8409. * Bind a list of vertex buffers to the webGL context
  8410. * @param vertexBuffers defines the list of vertex buffers to bind
  8411. * @param indexBuffer defines the index buffer to bind
  8412. * @param effect defines the effect associated with the vertex buffers
  8413. */
  8414. bindBuffers(vertexBuffers: {
  8415. [key: string]: Nullable<VertexBuffer>;
  8416. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8417. /**
  8418. * Unbind all instance attributes
  8419. */
  8420. unbindInstanceAttributes(): void;
  8421. /**
  8422. * Release and free the memory of a vertex array object
  8423. * @param vao defines the vertex array object to delete
  8424. */
  8425. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8426. /** @hidden */
  8427. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8428. /**
  8429. * Creates a webGL buffer to use with instanciation
  8430. * @param capacity defines the size of the buffer
  8431. * @returns the webGL buffer
  8432. */
  8433. createInstancesBuffer(capacity: number): WebGLBuffer;
  8434. /**
  8435. * Delete a webGL buffer used with instanciation
  8436. * @param buffer defines the webGL buffer to delete
  8437. */
  8438. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8439. /**
  8440. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8441. * @param instancesBuffer defines the webGL buffer to update and bind
  8442. * @param data defines the data to store in the buffer
  8443. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8444. */
  8445. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8446. /**
  8447. * Apply all cached states (depth, culling, stencil and alpha)
  8448. */
  8449. applyStates(): void;
  8450. /**
  8451. * Send a draw order
  8452. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8453. * @param indexStart defines the starting index
  8454. * @param indexCount defines the number of index to draw
  8455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8456. */
  8457. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8458. /**
  8459. * Draw a list of points
  8460. * @param verticesStart defines the index of first vertex to draw
  8461. * @param verticesCount defines the count of vertices to draw
  8462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8463. */
  8464. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8465. /**
  8466. * Draw a list of unindexed primitives
  8467. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8468. * @param verticesStart defines the index of first vertex to draw
  8469. * @param verticesCount defines the count of vertices to draw
  8470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8471. */
  8472. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8473. /**
  8474. * Draw a list of indexed primitives
  8475. * @param fillMode defines the primitive to use
  8476. * @param indexStart defines the starting index
  8477. * @param indexCount defines the number of index to draw
  8478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8479. */
  8480. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8481. /**
  8482. * Draw a list of unindexed primitives
  8483. * @param fillMode defines the primitive to use
  8484. * @param verticesStart defines the index of first vertex to draw
  8485. * @param verticesCount defines the count of vertices to draw
  8486. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8487. */
  8488. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8489. private _drawMode;
  8490. /** @hidden */
  8491. _releaseEffect(effect: Effect): void;
  8492. /** @hidden */
  8493. _deleteProgram(program: WebGLProgram): void;
  8494. /**
  8495. * Create a new effect (used to store vertex/fragment shaders)
  8496. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8497. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8498. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8499. * @param samplers defines an array of string used to represent textures
  8500. * @param defines defines the string containing the defines to use to compile the shaders
  8501. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8502. * @param onCompiled defines a function to call when the effect creation is successful
  8503. * @param onError defines a function to call when the effect creation has failed
  8504. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8505. * @returns the new Effect
  8506. */
  8507. 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;
  8508. private _compileShader;
  8509. private _compileRawShader;
  8510. /**
  8511. * Directly creates a webGL program
  8512. * @param vertexCode defines the vertex shader code to use
  8513. * @param fragmentCode defines the fragment shader code to use
  8514. * @param context defines the webGL context to use (if not set, the current one will be used)
  8515. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8516. * @returns the new webGL program
  8517. */
  8518. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8519. /**
  8520. * Creates a webGL program
  8521. * @param vertexCode defines the vertex shader code to use
  8522. * @param fragmentCode defines the fragment shader code to use
  8523. * @param defines defines the string containing the defines to use to compile the shaders
  8524. * @param context defines the webGL context to use (if not set, the current one will be used)
  8525. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8526. * @returns the new webGL program
  8527. */
  8528. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8529. private _createShaderProgram;
  8530. /**
  8531. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8532. * @param shaderProgram defines the webGL program to use
  8533. * @param uniformsNames defines the list of uniform names
  8534. * @returns an array of webGL uniform locations
  8535. */
  8536. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8537. /**
  8538. * Gets the lsit of active attributes for a given webGL program
  8539. * @param shaderProgram defines the webGL program to use
  8540. * @param attributesNames defines the list of attribute names to get
  8541. * @returns an array of indices indicating the offset of each attribute
  8542. */
  8543. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8544. /**
  8545. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8546. * @param effect defines the effect to activate
  8547. */
  8548. enableEffect(effect: Nullable<Effect>): void;
  8549. /**
  8550. * Set the value of an uniform to an array of int32
  8551. * @param uniform defines the webGL uniform location where to store the value
  8552. * @param array defines the array of int32 to store
  8553. */
  8554. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8555. /**
  8556. * Set the value of an uniform to an array of int32 (stored as vec2)
  8557. * @param uniform defines the webGL uniform location where to store the value
  8558. * @param array defines the array of int32 to store
  8559. */
  8560. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8561. /**
  8562. * Set the value of an uniform to an array of int32 (stored as vec3)
  8563. * @param uniform defines the webGL uniform location where to store the value
  8564. * @param array defines the array of int32 to store
  8565. */
  8566. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8567. /**
  8568. * Set the value of an uniform to an array of int32 (stored as vec4)
  8569. * @param uniform defines the webGL uniform location where to store the value
  8570. * @param array defines the array of int32 to store
  8571. */
  8572. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8573. /**
  8574. * Set the value of an uniform to an array of float32
  8575. * @param uniform defines the webGL uniform location where to store the value
  8576. * @param array defines the array of float32 to store
  8577. */
  8578. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8579. /**
  8580. * Set the value of an uniform to an array of float32 (stored as vec2)
  8581. * @param uniform defines the webGL uniform location where to store the value
  8582. * @param array defines the array of float32 to store
  8583. */
  8584. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8585. /**
  8586. * Set the value of an uniform to an array of float32 (stored as vec3)
  8587. * @param uniform defines the webGL uniform location where to store the value
  8588. * @param array defines the array of float32 to store
  8589. */
  8590. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8591. /**
  8592. * Set the value of an uniform to an array of float32 (stored as vec4)
  8593. * @param uniform defines the webGL uniform location where to store the value
  8594. * @param array defines the array of float32 to store
  8595. */
  8596. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8597. /**
  8598. * Set the value of an uniform to an array of number
  8599. * @param uniform defines the webGL uniform location where to store the value
  8600. * @param array defines the array of number to store
  8601. */
  8602. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8603. /**
  8604. * Set the value of an uniform to an array of number (stored as vec2)
  8605. * @param uniform defines the webGL uniform location where to store the value
  8606. * @param array defines the array of number to store
  8607. */
  8608. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8609. /**
  8610. * Set the value of an uniform to an array of number (stored as vec3)
  8611. * @param uniform defines the webGL uniform location where to store the value
  8612. * @param array defines the array of number to store
  8613. */
  8614. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8615. /**
  8616. * Set the value of an uniform to an array of number (stored as vec4)
  8617. * @param uniform defines the webGL uniform location where to store the value
  8618. * @param array defines the array of number to store
  8619. */
  8620. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8621. /**
  8622. * Set the value of an uniform to an array of float32 (stored as matrices)
  8623. * @param uniform defines the webGL uniform location where to store the value
  8624. * @param matrices defines the array of float32 to store
  8625. */
  8626. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8627. /**
  8628. * Set the value of an uniform to a matrix
  8629. * @param uniform defines the webGL uniform location where to store the value
  8630. * @param matrix defines the matrix to store
  8631. */
  8632. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8633. /**
  8634. * Set the value of an uniform to a matrix (3x3)
  8635. * @param uniform defines the webGL uniform location where to store the value
  8636. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8637. */
  8638. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8639. /**
  8640. * Set the value of an uniform to a matrix (2x2)
  8641. * @param uniform defines the webGL uniform location where to store the value
  8642. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8643. */
  8644. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8645. /**
  8646. * Set the value of an uniform to a number (int)
  8647. * @param uniform defines the webGL uniform location where to store the value
  8648. * @param value defines the int number to store
  8649. */
  8650. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8651. /**
  8652. * Set the value of an uniform to a number (float)
  8653. * @param uniform defines the webGL uniform location where to store the value
  8654. * @param value defines the float number to store
  8655. */
  8656. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8657. /**
  8658. * Set the value of an uniform to a vec2
  8659. * @param uniform defines the webGL uniform location where to store the value
  8660. * @param x defines the 1st component of the value
  8661. * @param y defines the 2nd component of the value
  8662. */
  8663. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8664. /**
  8665. * Set the value of an uniform to a vec3
  8666. * @param uniform defines the webGL uniform location where to store the value
  8667. * @param x defines the 1st component of the value
  8668. * @param y defines the 2nd component of the value
  8669. * @param z defines the 3rd component of the value
  8670. */
  8671. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8672. /**
  8673. * Set the value of an uniform to a boolean
  8674. * @param uniform defines the webGL uniform location where to store the value
  8675. * @param bool defines the boolean to store
  8676. */
  8677. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8678. /**
  8679. * Set the value of an uniform to a vec4
  8680. * @param uniform defines the webGL uniform location where to store the value
  8681. * @param x defines the 1st component of the value
  8682. * @param y defines the 2nd component of the value
  8683. * @param z defines the 3rd component of the value
  8684. * @param w defines the 4th component of the value
  8685. */
  8686. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8687. /**
  8688. * Set the value of an uniform to a Color3
  8689. * @param uniform defines the webGL uniform location where to store the value
  8690. * @param color3 defines the color to store
  8691. */
  8692. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8693. /**
  8694. * Set the value of an uniform to a Color3 and an alpha value
  8695. * @param uniform defines the webGL uniform location where to store the value
  8696. * @param color3 defines the color to store
  8697. * @param alpha defines the alpha component to store
  8698. */
  8699. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8700. /**
  8701. * Sets a Color4 on a uniform variable
  8702. * @param uniform defines the uniform location
  8703. * @param color4 defines the value to be set
  8704. */
  8705. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8706. /**
  8707. * Set various states to the webGL context
  8708. * @param culling defines backface culling state
  8709. * @param zOffset defines the value to apply to zOffset (0 by default)
  8710. * @param force defines if states must be applied even if cache is up to date
  8711. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8712. */
  8713. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8714. /**
  8715. * Set the z offset to apply to current rendering
  8716. * @param value defines the offset to apply
  8717. */
  8718. setZOffset(value: number): void;
  8719. /**
  8720. * Gets the current value of the zOffset
  8721. * @returns the current zOffset state
  8722. */
  8723. getZOffset(): number;
  8724. /**
  8725. * Enable or disable depth buffering
  8726. * @param enable defines the state to set
  8727. */
  8728. setDepthBuffer(enable: boolean): void;
  8729. /**
  8730. * Gets a boolean indicating if depth writing is enabled
  8731. * @returns the current depth writing state
  8732. */
  8733. getDepthWrite(): boolean;
  8734. /**
  8735. * Enable or disable depth writing
  8736. * @param enable defines the state to set
  8737. */
  8738. setDepthWrite(enable: boolean): void;
  8739. /**
  8740. * Enable or disable color writing
  8741. * @param enable defines the state to set
  8742. */
  8743. setColorWrite(enable: boolean): void;
  8744. /**
  8745. * Gets a boolean indicating if color writing is enabled
  8746. * @returns the current color writing state
  8747. */
  8748. getColorWrite(): boolean;
  8749. /**
  8750. * Sets alpha constants used by some alpha blending modes
  8751. * @param r defines the red component
  8752. * @param g defines the green component
  8753. * @param b defines the blue component
  8754. * @param a defines the alpha component
  8755. */
  8756. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8757. /**
  8758. * Sets the current alpha mode
  8759. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8760. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8761. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8762. */
  8763. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8764. /**
  8765. * Gets the current alpha mode
  8766. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8767. * @returns the current alpha mode
  8768. */
  8769. getAlphaMode(): number;
  8770. /**
  8771. * Clears the list of texture accessible through engine.
  8772. * This can help preventing texture load conflict due to name collision.
  8773. */
  8774. clearInternalTexturesCache(): void;
  8775. /**
  8776. * Force the entire cache to be cleared
  8777. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8778. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8779. */
  8780. wipeCaches(bruteForce?: boolean): void;
  8781. /**
  8782. * Set the compressed texture format to use, based on the formats you have, and the formats
  8783. * supported by the hardware / browser.
  8784. *
  8785. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8786. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8787. * to API arguments needed to compressed textures. This puts the burden on the container
  8788. * generator to house the arcane code for determining these for current & future formats.
  8789. *
  8790. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8791. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8792. *
  8793. * Note: The result of this call is not taken into account when a texture is base64.
  8794. *
  8795. * @param formatsAvailable defines the list of those format families you have created
  8796. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8797. *
  8798. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8799. * @returns The extension selected.
  8800. */
  8801. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8802. private _getSamplingParameters;
  8803. private _partialLoadImg;
  8804. private _cascadeLoadImgs;
  8805. /** @hidden */
  8806. _createTexture(): WebGLTexture;
  8807. /**
  8808. * Usually called from BABYLON.Texture.ts.
  8809. * Passed information to create a WebGLTexture
  8810. * @param urlArg defines a value which contains one of the following:
  8811. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8812. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8813. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8814. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8815. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8816. * @param scene needed for loading to the correct scene
  8817. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8818. * @param onLoad optional callback to be called upon successful completion
  8819. * @param onError optional callback to be called upon failure
  8820. * @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
  8821. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8822. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8823. * @param forcedExtension defines the extension to use to pick the right loader
  8824. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8825. */
  8826. 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>, forcedExtension?: Nullable<string>): InternalTexture;
  8827. private _rescaleTexture;
  8828. /**
  8829. * Update a raw texture
  8830. * @param texture defines the texture to update
  8831. * @param data defines the data to store in the texture
  8832. * @param format defines the format of the data
  8833. * @param invertY defines if data must be stored with Y axis inverted
  8834. * @param compression defines the compression used (null by default)
  8835. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8836. */
  8837. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8838. /**
  8839. * Creates a raw texture
  8840. * @param data defines the data to store in the texture
  8841. * @param width defines the width of the texture
  8842. * @param height defines the height of the texture
  8843. * @param format defines the format of the data
  8844. * @param generateMipMaps defines if the engine should generate the mip levels
  8845. * @param invertY defines if data must be stored with Y axis inverted
  8846. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8847. * @param compression defines the compression used (null by default)
  8848. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8849. * @returns the raw texture inside an InternalTexture
  8850. */
  8851. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8852. private _unpackFlipYCached;
  8853. /** @hidden */
  8854. _unpackFlipY(value: boolean): void;
  8855. /** @hidden */
  8856. _getUnpackAlignement(): number;
  8857. /**
  8858. * Creates a dynamic texture
  8859. * @param width defines the width of the texture
  8860. * @param height defines the height of the texture
  8861. * @param generateMipMaps defines if the engine should generate the mip levels
  8862. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8863. * @returns the dynamic texture inside an InternalTexture
  8864. */
  8865. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8866. /**
  8867. * Update the sampling mode of a given texture
  8868. * @param samplingMode defines the required sampling mode
  8869. * @param texture defines the texture to update
  8870. */
  8871. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8872. /**
  8873. * Update the content of a dynamic texture
  8874. * @param texture defines the texture to update
  8875. * @param canvas defines the canvas containing the source
  8876. * @param invertY defines if data must be stored with Y axis inverted
  8877. * @param premulAlpha defines if alpha is stored as premultiplied
  8878. * @param format defines the format of the data
  8879. */
  8880. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8881. /**
  8882. * Update a video texture
  8883. * @param texture defines the texture to update
  8884. * @param video defines the video element to use
  8885. * @param invertY defines if data must be stored with Y axis inverted
  8886. */
  8887. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8888. /**
  8889. * Updates a depth texture Comparison Mode and Function.
  8890. * If the comparison Function is equal to 0, the mode will be set to none.
  8891. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8892. * @param texture The texture to set the comparison function for
  8893. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8894. */
  8895. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8896. private _setupDepthStencilTexture;
  8897. /**
  8898. * Creates a depth stencil texture.
  8899. * This is only available in WebGL 2 or with the depth texture extension available.
  8900. * @param size The size of face edge in the texture.
  8901. * @param options The options defining the texture.
  8902. * @returns The texture
  8903. */
  8904. createDepthStencilTexture(size: number | {
  8905. width: number;
  8906. height: number;
  8907. }, options: DepthTextureCreationOptions): InternalTexture;
  8908. /**
  8909. * Creates a depth stencil texture.
  8910. * This is only available in WebGL 2 or with the depth texture extension available.
  8911. * @param size The size of face edge in the texture.
  8912. * @param options The options defining the texture.
  8913. * @returns The texture
  8914. */
  8915. private _createDepthStencilTexture;
  8916. /**
  8917. * Creates a depth stencil cube texture.
  8918. * This is only available in WebGL 2.
  8919. * @param size The size of face edge in the cube texture.
  8920. * @param options The options defining the cube texture.
  8921. * @returns The cube texture
  8922. */
  8923. private _createDepthStencilCubeTexture;
  8924. /**
  8925. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8926. * @param renderTarget The render target to set the frame buffer for
  8927. */
  8928. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8929. /**
  8930. * Creates a new render target texture
  8931. * @param size defines the size of the texture
  8932. * @param options defines the options used to create the texture
  8933. * @returns a new render target texture stored in an InternalTexture
  8934. */
  8935. createRenderTargetTexture(size: number | {
  8936. width: number;
  8937. height: number;
  8938. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8939. /**
  8940. * Create a multi render target texture
  8941. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8942. * @param size defines the size of the texture
  8943. * @param options defines the creation options
  8944. * @returns the cube texture as an InternalTexture
  8945. */
  8946. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8947. private _setupFramebufferDepthAttachments;
  8948. /**
  8949. * Updates the sample count of a render target texture
  8950. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8951. * @param texture defines the texture to update
  8952. * @param samples defines the sample count to set
  8953. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8954. */
  8955. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8956. /**
  8957. * Update the sample count for a given multiple render target texture
  8958. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8959. * @param textures defines the textures to update
  8960. * @param samples defines the sample count to set
  8961. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8962. */
  8963. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8964. /** @hidden */
  8965. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8966. /** @hidden */
  8967. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8968. /** @hidden */
  8969. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8970. /** @hidden */
  8971. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8972. /**
  8973. * Creates a new render target cube texture
  8974. * @param size defines the size of the texture
  8975. * @param options defines the options used to create the texture
  8976. * @returns a new render target cube texture stored in an InternalTexture
  8977. */
  8978. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8979. /**
  8980. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8981. * @param rootUrl defines the url where the file to load is located
  8982. * @param scene defines the current scene
  8983. * @param lodScale defines scale to apply to the mip map selection
  8984. * @param lodOffset defines offset to apply to the mip map selection
  8985. * @param onLoad defines an optional callback raised when the texture is loaded
  8986. * @param onError defines an optional callback raised if there is an issue to load the texture
  8987. * @param format defines the format of the data
  8988. * @param forcedExtension defines the extension to use to pick the right loader
  8989. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8990. * @returns the cube texture as an InternalTexture
  8991. */
  8992. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8993. /**
  8994. * Creates a cube texture
  8995. * @param rootUrl defines the url where the files to load is located
  8996. * @param scene defines the current scene
  8997. * @param files defines the list of files to load (1 per face)
  8998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8999. * @param onLoad defines an optional callback raised when the texture is loaded
  9000. * @param onError defines an optional callback raised if there is an issue to load the texture
  9001. * @param format defines the format of the data
  9002. * @param forcedExtension defines the extension to use to pick the right loader
  9003. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  9004. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  9005. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  9006. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  9007. * @returns the cube texture as an InternalTexture
  9008. */
  9009. 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, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  9010. /**
  9011. * @hidden
  9012. */
  9013. _setCubeMapTextureParams(loadMipmap: boolean): void;
  9014. /**
  9015. * Update a raw cube texture
  9016. * @param texture defines the texture to udpdate
  9017. * @param data defines the data to store
  9018. * @param format defines the data format
  9019. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9020. * @param invertY defines if data must be stored with Y axis inverted
  9021. * @param compression defines the compression used (null by default)
  9022. * @param level defines which level of the texture to update
  9023. */
  9024. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  9025. /**
  9026. * Creates a new raw cube texture
  9027. * @param data defines the array of data to use to create each face
  9028. * @param size defines the size of the textures
  9029. * @param format defines the format of the data
  9030. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9031. * @param generateMipMaps defines if the engine should generate the mip levels
  9032. * @param invertY defines if data must be stored with Y axis inverted
  9033. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9034. * @param compression defines the compression used (null by default)
  9035. * @returns the cube texture as an InternalTexture
  9036. */
  9037. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  9038. /**
  9039. * Creates a new raw cube texture from a specified url
  9040. * @param url defines the url where the data is located
  9041. * @param scene defines the current scene
  9042. * @param size defines the size of the textures
  9043. * @param format defines the format of the data
  9044. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9045. * @param noMipmap defines if the engine should avoid generating the mip levels
  9046. * @param callback defines a callback used to extract texture data from loaded data
  9047. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9048. * @param onLoad defines a callback called when texture is loaded
  9049. * @param onError defines a callback called if there is an error
  9050. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9051. * @param invertY defines if data must be stored with Y axis inverted
  9052. * @returns the cube texture as an InternalTexture
  9053. */
  9054. 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;
  9055. /**
  9056. * Update a raw 3D texture
  9057. * @param texture defines the texture to update
  9058. * @param data defines the data to store
  9059. * @param format defines the data format
  9060. * @param invertY defines if data must be stored with Y axis inverted
  9061. * @param compression defines the used compression (can be null)
  9062. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9063. */
  9064. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  9065. /**
  9066. * Creates a new raw 3D texture
  9067. * @param data defines the data used to create the texture
  9068. * @param width defines the width of the texture
  9069. * @param height defines the height of the texture
  9070. * @param depth defines the depth of the texture
  9071. * @param format defines the format of the texture
  9072. * @param generateMipMaps defines if the engine must generate mip levels
  9073. * @param invertY defines if data must be stored with Y axis inverted
  9074. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9075. * @param compression defines the compressed used (can be null)
  9076. * @param textureType defines the compressed used (can be null)
  9077. * @returns a new raw 3D texture (stored in an InternalTexture)
  9078. */
  9079. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  9080. private _prepareWebGLTextureContinuation;
  9081. private _prepareWebGLTexture;
  9082. private _convertRGBtoRGBATextureData;
  9083. /** @hidden */
  9084. _releaseFramebufferObjects(texture: InternalTexture): void;
  9085. /** @hidden */
  9086. _releaseTexture(texture: InternalTexture): void;
  9087. private setProgram;
  9088. private _boundUniforms;
  9089. /**
  9090. * Binds an effect to the webGL context
  9091. * @param effect defines the effect to bind
  9092. */
  9093. bindSamplers(effect: Effect): void;
  9094. private _moveBoundTextureOnTop;
  9095. private _getCorrectTextureChannel;
  9096. private _linkTrackers;
  9097. private _removeDesignatedSlot;
  9098. private _activateCurrentTexture;
  9099. /** @hidden */
  9100. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  9101. /** @hidden */
  9102. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9103. /**
  9104. * Sets a texture to the webGL context from a postprocess
  9105. * @param channel defines the channel to use
  9106. * @param postProcess defines the source postprocess
  9107. */
  9108. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9109. /**
  9110. * Binds the output of the passed in post process to the texture channel specified
  9111. * @param channel The channel the texture should be bound to
  9112. * @param postProcess The post process which's output should be bound
  9113. */
  9114. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9115. /**
  9116. * Unbind all textures from the webGL context
  9117. */
  9118. unbindAllTextures(): void;
  9119. /**
  9120. * Sets a texture to the according uniform.
  9121. * @param channel The texture channel
  9122. * @param uniform The uniform to set
  9123. * @param texture The texture to apply
  9124. */
  9125. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9126. /**
  9127. * Sets a depth stencil texture from a render target to the according uniform.
  9128. * @param channel The texture channel
  9129. * @param uniform The uniform to set
  9130. * @param texture The render target texture containing the depth stencil texture to apply
  9131. */
  9132. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9133. private _bindSamplerUniformToChannel;
  9134. private _getTextureWrapMode;
  9135. private _setTexture;
  9136. /**
  9137. * Sets an array of texture to the webGL context
  9138. * @param channel defines the channel where the texture array must be set
  9139. * @param uniform defines the associated uniform location
  9140. * @param textures defines the array of textures to bind
  9141. */
  9142. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9143. /** @hidden */
  9144. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9145. private _setTextureParameterFloat;
  9146. private _setTextureParameterInteger;
  9147. /**
  9148. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9149. * @param x defines the x coordinate of the rectangle where pixels must be read
  9150. * @param y defines the y coordinate of the rectangle where pixels must be read
  9151. * @param width defines the width of the rectangle where pixels must be read
  9152. * @param height defines the height of the rectangle where pixels must be read
  9153. * @returns a Uint8Array containing RGBA colors
  9154. */
  9155. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9156. /**
  9157. * Add an externaly attached data from its key.
  9158. * This method call will fail and return false, if such key already exists.
  9159. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9160. * @param key the unique key that identifies the data
  9161. * @param data the data object to associate to the key for this Engine instance
  9162. * @return true if no such key were already present and the data was added successfully, false otherwise
  9163. */
  9164. addExternalData<T>(key: string, data: T): boolean;
  9165. /**
  9166. * Get an externaly attached data from its key
  9167. * @param key the unique key that identifies the data
  9168. * @return the associated data, if present (can be null), or undefined if not present
  9169. */
  9170. getExternalData<T>(key: string): T;
  9171. /**
  9172. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9173. * @param key the unique key that identifies the data
  9174. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9175. * @return the associated data, can be null if the factory returned null.
  9176. */
  9177. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9178. /**
  9179. * Remove an externaly attached data from the Engine instance
  9180. * @param key the unique key that identifies the data
  9181. * @return true if the data was successfully removed, false if it doesn't exist
  9182. */
  9183. removeExternalData(key: string): boolean;
  9184. /**
  9185. * Unbind all vertex attributes from the webGL context
  9186. */
  9187. unbindAllAttributes(): void;
  9188. /**
  9189. * 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
  9190. */
  9191. releaseEffects(): void;
  9192. /**
  9193. * Dispose and release all associated resources
  9194. */
  9195. dispose(): void;
  9196. /**
  9197. * Display the loading screen
  9198. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9199. */
  9200. displayLoadingUI(): void;
  9201. /**
  9202. * Hide the loading screen
  9203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9204. */
  9205. hideLoadingUI(): void;
  9206. /**
  9207. * Gets the current loading screen object
  9208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9209. */
  9210. /**
  9211. * Sets the current loading screen object
  9212. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9213. */
  9214. loadingScreen: ILoadingScreen;
  9215. /**
  9216. * Sets the current loading screen text
  9217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9218. */
  9219. loadingUIText: string;
  9220. /**
  9221. * Sets the current loading screen background color
  9222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9223. */
  9224. loadingUIBackgroundColor: string;
  9225. /**
  9226. * Attach a new callback raised when context lost event is fired
  9227. * @param callback defines the callback to call
  9228. */
  9229. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9230. /**
  9231. * Attach a new callback raised when context restored event is fired
  9232. * @param callback defines the callback to call
  9233. */
  9234. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9235. /**
  9236. * Gets the source code of the vertex shader associated with a specific webGL program
  9237. * @param program defines the program to use
  9238. * @returns a string containing the source code of the vertex shader associated with the program
  9239. */
  9240. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9241. /**
  9242. * Gets the source code of the fragment shader associated with a specific webGL program
  9243. * @param program defines the program to use
  9244. * @returns a string containing the source code of the fragment shader associated with the program
  9245. */
  9246. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9247. /**
  9248. * Get the current error code of the webGL context
  9249. * @returns the error code
  9250. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9251. */
  9252. getError(): number;
  9253. /**
  9254. * Gets the current framerate
  9255. * @returns a number representing the framerate
  9256. */
  9257. getFps(): number;
  9258. /**
  9259. * Gets the time spent between current and previous frame
  9260. * @returns a number representing the delta time in ms
  9261. */
  9262. getDeltaTime(): number;
  9263. private _measureFps;
  9264. /** @hidden */
  9265. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9266. private _canRenderToFloatFramebuffer;
  9267. private _canRenderToHalfFloatFramebuffer;
  9268. private _canRenderToFramebuffer;
  9269. /** @hidden */
  9270. _getWebGLTextureType(type: number): number;
  9271. private _getInternalFormat;
  9272. /** @hidden */
  9273. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9274. /** @hidden */
  9275. _getRGBAMultiSampleBufferFormat(type: number): number;
  9276. /** @hidden */
  9277. _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;
  9278. /** @hidden */
  9279. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9280. private _partialLoadFile;
  9281. private _cascadeLoadFiles;
  9282. /**
  9283. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9284. * @returns true if the engine can be created
  9285. * @ignorenaming
  9286. */
  9287. static isSupported(): boolean;
  9288. }
  9289. }
  9290. declare module BABYLON {
  9291. class NullEngineOptions {
  9292. renderWidth: number;
  9293. renderHeight: number;
  9294. textureSize: number;
  9295. deterministicLockstep: boolean;
  9296. lockstepMaxSteps: number;
  9297. }
  9298. /**
  9299. * The null engine class provides support for headless version of babylon.js.
  9300. * This can be used in server side scenario or for testing purposes
  9301. */
  9302. class NullEngine extends Engine {
  9303. private _options;
  9304. isDeterministicLockStep(): boolean;
  9305. getLockstepMaxSteps(): number;
  9306. getHardwareScalingLevel(): number;
  9307. constructor(options?: NullEngineOptions);
  9308. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9309. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9310. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9311. getRenderWidth(useScreen?: boolean): number;
  9312. getRenderHeight(useScreen?: boolean): number;
  9313. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9314. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9315. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9316. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9317. bindSamplers(effect: Effect): void;
  9318. enableEffect(effect: Effect): void;
  9319. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9320. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9321. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9322. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9323. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9324. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9325. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9326. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9327. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9328. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9329. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9330. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9331. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9332. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9333. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9334. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9335. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9336. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9337. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9338. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9339. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9340. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9341. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9342. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9343. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9344. bindBuffers(vertexBuffers: {
  9345. [key: string]: VertexBuffer;
  9346. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9347. wipeCaches(bruteForce?: boolean): void;
  9348. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9349. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9350. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9351. /** @hidden */
  9352. _createTexture(): WebGLTexture;
  9353. /** @hidden */
  9354. _releaseTexture(texture: InternalTexture): void;
  9355. 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;
  9356. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9357. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9358. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9359. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9360. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9361. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9362. /**
  9363. * @hidden
  9364. * Get the current error code of the webGL context
  9365. * @returns the error code
  9366. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9367. */
  9368. getError(): number;
  9369. /** @hidden */
  9370. _getUnpackAlignement(): number;
  9371. /** @hidden */
  9372. _unpackFlipY(value: boolean): void;
  9373. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9374. /**
  9375. * Updates a dynamic vertex buffer.
  9376. * @param vertexBuffer the vertex buffer to update
  9377. * @param data the data used to update the vertex buffer
  9378. * @param byteOffset the byte offset of the data (optional)
  9379. * @param byteLength the byte length of the data (optional)
  9380. */
  9381. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9382. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9383. /** @hidden */
  9384. _bindTexture(channel: number, texture: InternalTexture): void;
  9385. /** @hidden */
  9386. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9387. releaseEffects(): void;
  9388. displayLoadingUI(): void;
  9389. hideLoadingUI(): void;
  9390. /** @hidden */
  9391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9392. /** @hidden */
  9393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9394. /** @hidden */
  9395. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9396. /** @hidden */
  9397. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9398. }
  9399. }
  9400. interface WebGLRenderingContext {
  9401. readonly RASTERIZER_DISCARD: number;
  9402. readonly DEPTH_COMPONENT24: number;
  9403. readonly TEXTURE_3D: number;
  9404. readonly TEXTURE_2D_ARRAY: number;
  9405. readonly TEXTURE_COMPARE_FUNC: number;
  9406. readonly TEXTURE_COMPARE_MODE: number;
  9407. readonly COMPARE_REF_TO_TEXTURE: number;
  9408. readonly TEXTURE_WRAP_R: number;
  9409. readonly HALF_FLOAT: number;
  9410. readonly RGB8: number;
  9411. readonly RED_INTEGER: number;
  9412. readonly RG_INTEGER: number;
  9413. readonly RGB_INTEGER: number;
  9414. readonly RGBA_INTEGER: number;
  9415. readonly R8_SNORM: number;
  9416. readonly RG8_SNORM: number;
  9417. readonly RGB8_SNORM: number;
  9418. readonly RGBA8_SNORM: number;
  9419. readonly R8I: number;
  9420. readonly RG8I: number;
  9421. readonly RGB8I: number;
  9422. readonly RGBA8I: number;
  9423. readonly R8UI: number;
  9424. readonly RG8UI: number;
  9425. readonly RGB8UI: number;
  9426. readonly RGBA8UI: number;
  9427. readonly R16I: number;
  9428. readonly RG16I: number;
  9429. readonly RGB16I: number;
  9430. readonly RGBA16I: number;
  9431. readonly R16UI: number;
  9432. readonly RG16UI: number;
  9433. readonly RGB16UI: number;
  9434. readonly RGBA16UI: number;
  9435. readonly R32I: number;
  9436. readonly RG32I: number;
  9437. readonly RGB32I: number;
  9438. readonly RGBA32I: number;
  9439. readonly R32UI: number;
  9440. readonly RG32UI: number;
  9441. readonly RGB32UI: number;
  9442. readonly RGBA32UI: number;
  9443. readonly RGB10_A2UI: number;
  9444. readonly R11F_G11F_B10F: number;
  9445. readonly RGB9_E5: number;
  9446. readonly RGB10_A2: number;
  9447. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9448. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9449. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9450. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9451. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9452. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9453. 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;
  9454. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9455. readonly TRANSFORM_FEEDBACK: number;
  9456. readonly INTERLEAVED_ATTRIBS: number;
  9457. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9458. createTransformFeedback(): WebGLTransformFeedback;
  9459. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9460. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9461. beginTransformFeedback(primitiveMode: number): void;
  9462. endTransformFeedback(): void;
  9463. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9464. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9465. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9466. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9467. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9468. }
  9469. interface ImageBitmap {
  9470. readonly width: number;
  9471. readonly height: number;
  9472. close(): void;
  9473. }
  9474. interface WebGLQuery extends WebGLObject {
  9475. }
  9476. declare var WebGLQuery: {
  9477. prototype: WebGLQuery;
  9478. new (): WebGLQuery;
  9479. };
  9480. interface WebGLSampler extends WebGLObject {
  9481. }
  9482. declare var WebGLSampler: {
  9483. prototype: WebGLSampler;
  9484. new (): WebGLSampler;
  9485. };
  9486. interface WebGLSync extends WebGLObject {
  9487. }
  9488. declare var WebGLSync: {
  9489. prototype: WebGLSync;
  9490. new (): WebGLSync;
  9491. };
  9492. interface WebGLTransformFeedback extends WebGLObject {
  9493. }
  9494. declare var WebGLTransformFeedback: {
  9495. prototype: WebGLTransformFeedback;
  9496. new (): WebGLTransformFeedback;
  9497. };
  9498. interface WebGLVertexArrayObject extends WebGLObject {
  9499. }
  9500. declare var WebGLVertexArrayObject: {
  9501. prototype: WebGLVertexArrayObject;
  9502. new (): WebGLVertexArrayObject;
  9503. };
  9504. declare module BABYLON {
  9505. class KeyboardEventTypes {
  9506. static _KEYDOWN: number;
  9507. static _KEYUP: number;
  9508. static readonly KEYDOWN: number;
  9509. static readonly KEYUP: number;
  9510. }
  9511. class KeyboardInfo {
  9512. type: number;
  9513. event: KeyboardEvent;
  9514. constructor(type: number, event: KeyboardEvent);
  9515. }
  9516. /**
  9517. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9518. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9519. */
  9520. class KeyboardInfoPre extends KeyboardInfo {
  9521. constructor(type: number, event: KeyboardEvent);
  9522. skipOnPointerObservable: boolean;
  9523. }
  9524. }
  9525. declare module BABYLON {
  9526. class PointerEventTypes {
  9527. static _POINTERDOWN: number;
  9528. static _POINTERUP: number;
  9529. static _POINTERMOVE: number;
  9530. static _POINTERWHEEL: number;
  9531. static _POINTERPICK: number;
  9532. static _POINTERTAP: number;
  9533. static _POINTERDOUBLETAP: number;
  9534. static readonly POINTERDOWN: number;
  9535. static readonly POINTERUP: number;
  9536. static readonly POINTERMOVE: number;
  9537. static readonly POINTERWHEEL: number;
  9538. static readonly POINTERPICK: number;
  9539. static readonly POINTERTAP: number;
  9540. static readonly POINTERDOUBLETAP: number;
  9541. }
  9542. class PointerInfoBase {
  9543. type: number;
  9544. event: PointerEvent | MouseWheelEvent;
  9545. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9546. }
  9547. /**
  9548. * This class is used to store pointer related info for the onPrePointerObservable event.
  9549. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9550. */
  9551. class PointerInfoPre extends PointerInfoBase {
  9552. /**
  9553. * Ray from a pointer if availible (eg. 6dof controller)
  9554. */
  9555. ray: Nullable<Ray>;
  9556. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9557. localPosition: Vector2;
  9558. skipOnPointerObservable: boolean;
  9559. }
  9560. /**
  9561. * This type contains all the data related to a pointer event in Babylon.js.
  9562. * 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.
  9563. */
  9564. class PointerInfo extends PointerInfoBase {
  9565. pickInfo: Nullable<PickingInfo>;
  9566. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9567. }
  9568. }
  9569. declare module BABYLON {
  9570. class StickValues {
  9571. x: number;
  9572. y: number;
  9573. constructor(x: number, y: number);
  9574. }
  9575. interface GamepadButtonChanges {
  9576. changed: boolean;
  9577. pressChanged: boolean;
  9578. touchChanged: boolean;
  9579. valueChanged: boolean;
  9580. }
  9581. class Gamepad {
  9582. id: string;
  9583. index: number;
  9584. browserGamepad: any;
  9585. type: number;
  9586. private _leftStick;
  9587. private _rightStick;
  9588. /** @hidden */
  9589. _isConnected: boolean;
  9590. private _leftStickAxisX;
  9591. private _leftStickAxisY;
  9592. private _rightStickAxisX;
  9593. private _rightStickAxisY;
  9594. private _onleftstickchanged;
  9595. private _onrightstickchanged;
  9596. static GAMEPAD: number;
  9597. static GENERIC: number;
  9598. static XBOX: number;
  9599. static POSE_ENABLED: number;
  9600. protected _invertLeftStickY: boolean;
  9601. readonly isConnected: boolean;
  9602. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9603. onleftstickchanged(callback: (values: StickValues) => void): void;
  9604. onrightstickchanged(callback: (values: StickValues) => void): void;
  9605. leftStick: StickValues;
  9606. rightStick: StickValues;
  9607. update(): void;
  9608. dispose(): void;
  9609. }
  9610. class GenericPad extends Gamepad {
  9611. private _buttons;
  9612. private _onbuttondown;
  9613. private _onbuttonup;
  9614. onButtonDownObservable: Observable<number>;
  9615. onButtonUpObservable: Observable<number>;
  9616. onbuttondown(callback: (buttonPressed: number) => void): void;
  9617. onbuttonup(callback: (buttonReleased: number) => void): void;
  9618. constructor(id: string, index: number, browserGamepad: any);
  9619. private _setButtonValue;
  9620. update(): void;
  9621. dispose(): void;
  9622. }
  9623. }
  9624. declare module BABYLON {
  9625. class GamepadManager {
  9626. private _scene?;
  9627. private _babylonGamepads;
  9628. private _oneGamepadConnected;
  9629. /** @hidden */
  9630. _isMonitoring: boolean;
  9631. private _gamepadEventSupported;
  9632. private _gamepadSupport;
  9633. onGamepadConnectedObservable: Observable<Gamepad>;
  9634. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9635. private _onGamepadConnectedEvent;
  9636. private _onGamepadDisconnectedEvent;
  9637. constructor(_scene?: Scene | undefined);
  9638. readonly gamepads: Gamepad[];
  9639. getGamepadByType(type?: number): Nullable<Gamepad>;
  9640. dispose(): void;
  9641. private _addNewGamepad;
  9642. private _startMonitoringGamepads;
  9643. private _stopMonitoringGamepads;
  9644. /** @hidden */
  9645. _checkGamepadsStatus(): void;
  9646. private _updateGamepadObjects;
  9647. }
  9648. }
  9649. declare module BABYLON {
  9650. interface Scene {
  9651. /** @hidden */
  9652. _gamepadManager: Nullable<GamepadManager>;
  9653. /**
  9654. * Gets the gamepad manager associated with the scene
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9656. */
  9657. gamepadManager: GamepadManager;
  9658. }
  9659. interface FreeCameraInputsManager {
  9660. addGamepad(): FreeCameraInputsManager;
  9661. }
  9662. interface ArcRotateCameraInputsManager {
  9663. addGamepad(): ArcRotateCameraInputsManager;
  9664. }
  9665. /**
  9666. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9667. */
  9668. class GamepadSystemSceneComponent implements ISceneComponent {
  9669. /**
  9670. * The component name helpfull to identify the component in the list of scene components.
  9671. */
  9672. readonly name: string;
  9673. /**
  9674. * The scene the component belongs to.
  9675. */
  9676. scene: Scene;
  9677. /**
  9678. * Creates a new instance of the component for the given scene
  9679. * @param scene Defines the scene to register the component in
  9680. */
  9681. constructor(scene: Scene);
  9682. /**
  9683. * Registers the component in a given scene
  9684. */
  9685. register(): void;
  9686. /**
  9687. * Rebuilds the elements related to this component in case of
  9688. * context lost for instance.
  9689. */
  9690. rebuild(): void;
  9691. /**
  9692. * Disposes the component and the associated ressources
  9693. */
  9694. dispose(): void;
  9695. private _beforeCameraUpdate;
  9696. }
  9697. }
  9698. declare module BABYLON {
  9699. /**
  9700. * Defines supported buttons for XBox360 compatible gamepads
  9701. */
  9702. enum Xbox360Button {
  9703. /** A */
  9704. A = 0,
  9705. /** B */
  9706. B = 1,
  9707. /** X */
  9708. X = 2,
  9709. /** Y */
  9710. Y = 3,
  9711. /** Start */
  9712. Start = 4,
  9713. /** Back */
  9714. Back = 5,
  9715. /** Left button */
  9716. LB = 6,
  9717. /** Right button */
  9718. RB = 7,
  9719. /** Left stick */
  9720. LeftStick = 8,
  9721. /** Right stick */
  9722. RightStick = 9
  9723. }
  9724. /** Defines values for XBox360 DPad */
  9725. enum Xbox360Dpad {
  9726. /** Up */
  9727. Up = 0,
  9728. /** Down */
  9729. Down = 1,
  9730. /** Left */
  9731. Left = 2,
  9732. /** Right */
  9733. Right = 3
  9734. }
  9735. /**
  9736. * Defines a XBox360 gamepad
  9737. */
  9738. class Xbox360Pad extends Gamepad {
  9739. private _leftTrigger;
  9740. private _rightTrigger;
  9741. private _onlefttriggerchanged;
  9742. private _onrighttriggerchanged;
  9743. private _onbuttondown;
  9744. private _onbuttonup;
  9745. private _ondpaddown;
  9746. private _ondpadup;
  9747. /** Observable raised when a button is pressed */
  9748. onButtonDownObservable: Observable<Xbox360Button>;
  9749. /** Observable raised when a button is released */
  9750. onButtonUpObservable: Observable<Xbox360Button>;
  9751. /** Observable raised when a pad is pressed */
  9752. onPadDownObservable: Observable<Xbox360Dpad>;
  9753. /** Observable raised when a pad is released */
  9754. onPadUpObservable: Observable<Xbox360Dpad>;
  9755. private _buttonA;
  9756. private _buttonB;
  9757. private _buttonX;
  9758. private _buttonY;
  9759. private _buttonBack;
  9760. private _buttonStart;
  9761. private _buttonLB;
  9762. private _buttonRB;
  9763. private _buttonLeftStick;
  9764. private _buttonRightStick;
  9765. private _dPadUp;
  9766. private _dPadDown;
  9767. private _dPadLeft;
  9768. private _dPadRight;
  9769. private _isXboxOnePad;
  9770. /**
  9771. * Creates a new XBox360 gamepad object
  9772. * @param id defines the id of this gamepad
  9773. * @param index defines its index
  9774. * @param gamepad defines the internal HTML gamepad object
  9775. * @param xboxOne defines if it is a XBox One gamepad
  9776. */
  9777. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9778. /**
  9779. * Defines the callback to call when left trigger is pressed
  9780. * @param callback defines the callback to use
  9781. */
  9782. onlefttriggerchanged(callback: (value: number) => void): void;
  9783. /**
  9784. * Defines the callback to call when right trigger is pressed
  9785. * @param callback defines the callback to use
  9786. */
  9787. onrighttriggerchanged(callback: (value: number) => void): void;
  9788. /**
  9789. * Gets or sets left trigger value
  9790. */
  9791. leftTrigger: number;
  9792. /**
  9793. * Gets or sets right trigger value
  9794. */
  9795. rightTrigger: number;
  9796. /**
  9797. * Defines the callback to call when a button is pressed
  9798. * @param callback defines the callback to use
  9799. */
  9800. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9801. /**
  9802. * Defines the callback to call when a button is released
  9803. * @param callback defines the callback to use
  9804. */
  9805. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9806. /**
  9807. * Defines the callback to call when a pad is pressed
  9808. * @param callback defines the callback to use
  9809. */
  9810. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9811. /**
  9812. * Defines the callback to call when a pad is released
  9813. * @param callback defines the callback to use
  9814. */
  9815. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9816. private _setButtonValue;
  9817. private _setDPadValue;
  9818. /** Gets or sets value of A button */
  9819. buttonA: number;
  9820. /** Gets or sets value of B button */
  9821. buttonB: number;
  9822. /** Gets or sets value of X button */
  9823. buttonX: number;
  9824. /** Gets or sets value of Y button */
  9825. buttonY: number;
  9826. /** Gets or sets value of Start button */
  9827. buttonStart: number;
  9828. /** Gets or sets value of Back button */
  9829. buttonBack: number;
  9830. /** Gets or sets value of Left button */
  9831. buttonLB: number;
  9832. /** Gets or sets value of Right button */
  9833. buttonRB: number;
  9834. /** Gets or sets value of left stick */
  9835. buttonLeftStick: number;
  9836. /** Gets or sets value of right stick */
  9837. buttonRightStick: number;
  9838. /** Gets or sets value of DPad up */
  9839. dPadUp: number;
  9840. /** Gets or sets value of DPad down */
  9841. dPadDown: number;
  9842. /** Gets or sets value of DPad left */
  9843. dPadLeft: number;
  9844. /** Gets or sets value of DPad right */
  9845. dPadRight: number;
  9846. /**
  9847. * Force the gamepad to synchronize with device values
  9848. */
  9849. update(): void;
  9850. dispose(): void;
  9851. }
  9852. }
  9853. declare module BABYLON {
  9854. /**
  9855. * Single axis drag gizmo
  9856. */
  9857. class AxisDragGizmo extends Gizmo {
  9858. /**
  9859. * Drag behavior responsible for the gizmos dragging interactions
  9860. */
  9861. dragBehavior: PointerDragBehavior;
  9862. private _pointerObserver;
  9863. /**
  9864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9865. */
  9866. snapDistance: number;
  9867. /**
  9868. * Event that fires each time the gizmo snaps to a new location.
  9869. * * snapDistance is the the change in distance
  9870. */
  9871. onSnapObservable: Observable<{
  9872. snapDistance: number;
  9873. }>;
  9874. /**
  9875. * Creates an AxisDragGizmo
  9876. * @param gizmoLayer The utility layer the gizmo will be added to
  9877. * @param dragAxis The axis which the gizmo will be able to drag on
  9878. * @param color The color of the gizmo
  9879. */
  9880. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9881. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9882. /**
  9883. * Disposes of the gizmo
  9884. */
  9885. dispose(): void;
  9886. }
  9887. }
  9888. declare module BABYLON {
  9889. /**
  9890. * Single axis scale gizmo
  9891. */
  9892. class AxisScaleGizmo extends Gizmo {
  9893. private _coloredMaterial;
  9894. /**
  9895. * Drag behavior responsible for the gizmos dragging interactions
  9896. */
  9897. dragBehavior: PointerDragBehavior;
  9898. private _pointerObserver;
  9899. /**
  9900. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9901. */
  9902. snapDistance: number;
  9903. /**
  9904. * Event that fires each time the gizmo snaps to a new location.
  9905. * * snapDistance is the the change in distance
  9906. */
  9907. onSnapObservable: Observable<{
  9908. snapDistance: number;
  9909. }>;
  9910. /**
  9911. * If the scaling operation should be done on all axis (default: false)
  9912. */
  9913. uniformScaling: boolean;
  9914. /**
  9915. * Creates an AxisScaleGizmo
  9916. * @param gizmoLayer The utility layer the gizmo will be added to
  9917. * @param dragAxis The axis which the gizmo will be able to scale on
  9918. * @param color The color of the gizmo
  9919. */
  9920. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9921. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9922. /**
  9923. * Disposes of the gizmo
  9924. */
  9925. dispose(): void;
  9926. /**
  9927. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9928. * @param mesh The mesh to replace the default mesh of the gizmo
  9929. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9930. */
  9931. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9932. }
  9933. }
  9934. declare module BABYLON {
  9935. /**
  9936. * Bounding box gizmo
  9937. */
  9938. class BoundingBoxGizmo extends Gizmo {
  9939. private _lineBoundingBox;
  9940. private _rotateSpheresParent;
  9941. private _scaleBoxesParent;
  9942. private _boundingDimensions;
  9943. private _renderObserver;
  9944. private _pointerObserver;
  9945. private _scaleDragSpeed;
  9946. private _tmpQuaternion;
  9947. private _tmpVector;
  9948. private _tmpRotationMatrix;
  9949. /**
  9950. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  9951. */
  9952. ignoreChildren: boolean;
  9953. /**
  9954. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9955. */
  9956. rotationSphereSize: number;
  9957. /**
  9958. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9959. */
  9960. scaleBoxSize: number;
  9961. /**
  9962. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  9963. */
  9964. fixedDragMeshScreenSize: boolean;
  9965. /**
  9966. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9967. */
  9968. fixedDragMeshScreenSizeDistanceFactor: number;
  9969. /**
  9970. * Fired when a rotation sphere or scale box is dragged
  9971. */
  9972. onDragStartObservable: Observable<{}>;
  9973. /**
  9974. * Fired when a scale box is dragged
  9975. */
  9976. onScaleBoxDragObservable: Observable<{}>;
  9977. /**
  9978. * Fired when a scale box drag is ended
  9979. */
  9980. onScaleBoxDragEndObservable: Observable<{}>;
  9981. /**
  9982. * Fired when a rotation sphere is dragged
  9983. */
  9984. onRotationSphereDragObservable: Observable<{}>;
  9985. /**
  9986. * Fired when a rotation sphere drag is ended
  9987. */
  9988. onRotationSphereDragEndObservable: Observable<{}>;
  9989. /**
  9990. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  9991. */
  9992. scalePivot: Nullable<Vector3>;
  9993. private _anchorMesh;
  9994. private _existingMeshScale;
  9995. private static _PivotCached;
  9996. private static _OldPivotPoint;
  9997. private static _PivotTranslation;
  9998. private static _PivotTmpVector;
  9999. /** @hidden */
  10000. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  10001. /** @hidden */
  10002. static _RestorePivotPoint(mesh: AbstractMesh): void;
  10003. /**
  10004. * Creates an BoundingBoxGizmo
  10005. * @param gizmoLayer The utility layer the gizmo will be added to
  10006. * @param color The color of the gizmo
  10007. */
  10008. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10009. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10010. private _selectNode;
  10011. private _recurseComputeWorld;
  10012. /**
  10013. * Updates the bounding box information for the Gizmo
  10014. */
  10015. updateBoundingBox(): void;
  10016. /**
  10017. * Enables rotation on the specified axis and disables rotation on the others
  10018. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10019. */
  10020. setEnabledRotationAxis(axis: string): void;
  10021. /**
  10022. * Disposes of the gizmo
  10023. */
  10024. dispose(): void;
  10025. /**
  10026. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  10027. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10028. * @returns the bounding box mesh with the passed in mesh as a child
  10029. */
  10030. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10031. /**
  10032. * CustomMeshes are not supported by this gizmo
  10033. * @param mesh The mesh to replace the default mesh of the gizmo
  10034. */
  10035. setCustomMesh(mesh: Mesh): void;
  10036. }
  10037. }
  10038. declare module BABYLON {
  10039. /**
  10040. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10041. */
  10042. class Gizmo implements IDisposable {
  10043. /** The utility layer the gizmo will be added to */
  10044. gizmoLayer: UtilityLayerRenderer;
  10045. /**
  10046. * The root mesh of the gizmo
  10047. */
  10048. protected _rootMesh: Mesh;
  10049. private _attachedMesh;
  10050. /**
  10051. * Ratio for the scale of the gizmo (Default: 1)
  10052. */
  10053. scaleRatio: number;
  10054. private _tmpMatrix;
  10055. /**
  10056. * If a custom mesh has been set (Default: false)
  10057. */
  10058. protected _customMeshSet: boolean;
  10059. /**
  10060. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10061. * * When set, interactions will be enabled
  10062. */
  10063. attachedMesh: Nullable<AbstractMesh>;
  10064. /**
  10065. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10066. * @param mesh The mesh to replace the default mesh of the gizmo
  10067. */
  10068. setCustomMesh(mesh: Mesh): void;
  10069. /**
  10070. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10071. */
  10072. updateGizmoRotationToMatchAttachedMesh: boolean;
  10073. /**
  10074. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10075. */
  10076. updateGizmoPositionToMatchAttachedMesh: boolean;
  10077. /**
  10078. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10079. */
  10080. protected _updateScale: boolean;
  10081. protected _interactionsEnabled: boolean;
  10082. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10083. private _beforeRenderObserver;
  10084. /**
  10085. * Creates a gizmo
  10086. * @param gizmoLayer The utility layer the gizmo will be added to
  10087. */
  10088. constructor(
  10089. /** The utility layer the gizmo will be added to */
  10090. gizmoLayer?: UtilityLayerRenderer);
  10091. private _tempVector;
  10092. /**
  10093. * @hidden
  10094. * Updates the gizmo to match the attached mesh's position/rotation
  10095. */
  10096. protected _update(): void;
  10097. /**
  10098. * Disposes of the gizmo
  10099. */
  10100. dispose(): void;
  10101. }
  10102. }
  10103. declare module BABYLON {
  10104. /**
  10105. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10106. */
  10107. class GizmoManager implements IDisposable {
  10108. private scene;
  10109. /**
  10110. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10111. */
  10112. gizmos: {
  10113. positionGizmo: Nullable<PositionGizmo>;
  10114. rotationGizmo: Nullable<RotationGizmo>;
  10115. scaleGizmo: Nullable<ScaleGizmo>;
  10116. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10117. };
  10118. private _gizmosEnabled;
  10119. private _pointerObserver;
  10120. private _attachedMesh;
  10121. private _boundingBoxColor;
  10122. private _dragBehavior;
  10123. /**
  10124. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10125. */
  10126. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10127. /**
  10128. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10129. */
  10130. usePointerToAttachGizmos: boolean;
  10131. /**
  10132. * Instatiates a gizmo manager
  10133. * @param scene the scene to overlay the gizmos on top of
  10134. */
  10135. constructor(scene: Scene);
  10136. /**
  10137. * Attaches a set of gizmos to the specified mesh
  10138. * @param mesh The mesh the gizmo's should be attached to
  10139. */
  10140. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10141. /**
  10142. * If the position gizmo is enabled
  10143. */
  10144. positionGizmoEnabled: boolean;
  10145. /**
  10146. * If the rotation gizmo is enabled
  10147. */
  10148. rotationGizmoEnabled: boolean;
  10149. /**
  10150. * If the scale gizmo is enabled
  10151. */
  10152. scaleGizmoEnabled: boolean;
  10153. /**
  10154. * If the boundingBox gizmo is enabled
  10155. */
  10156. boundingBoxGizmoEnabled: boolean;
  10157. /**
  10158. * Disposes of the gizmo manager
  10159. */
  10160. dispose(): void;
  10161. }
  10162. }
  10163. declare module BABYLON {
  10164. /**
  10165. * Single plane rotation gizmo
  10166. */
  10167. class PlaneRotationGizmo extends Gizmo {
  10168. /**
  10169. * Drag behavior responsible for the gizmos dragging interactions
  10170. */
  10171. dragBehavior: PointerDragBehavior;
  10172. private _pointerObserver;
  10173. /**
  10174. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10175. */
  10176. snapDistance: number;
  10177. /**
  10178. * Event that fires each time the gizmo snaps to a new location.
  10179. * * snapDistance is the the change in distance
  10180. */
  10181. onSnapObservable: Observable<{
  10182. snapDistance: number;
  10183. }>;
  10184. /**
  10185. * Creates a PlaneRotationGizmo
  10186. * @param gizmoLayer The utility layer the gizmo will be added to
  10187. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10188. * @param color The color of the gizmo
  10189. */
  10190. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10191. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10192. /**
  10193. * Disposes of the gizmo
  10194. */
  10195. dispose(): void;
  10196. }
  10197. }
  10198. declare module BABYLON {
  10199. /**
  10200. * Gizmo that enables dragging a mesh along 3 axis
  10201. */
  10202. class PositionGizmo extends Gizmo {
  10203. /**
  10204. * Internal gizmo used for interactions on the x axis
  10205. */
  10206. xGizmo: AxisDragGizmo;
  10207. /**
  10208. * Internal gizmo used for interactions on the y axis
  10209. */
  10210. yGizmo: AxisDragGizmo;
  10211. /**
  10212. * Internal gizmo used for interactions on the z axis
  10213. */
  10214. zGizmo: AxisDragGizmo;
  10215. attachedMesh: Nullable<AbstractMesh>;
  10216. /**
  10217. * Creates a PositionGizmo
  10218. * @param gizmoLayer The utility layer the gizmo will be added to
  10219. */
  10220. constructor(gizmoLayer?: UtilityLayerRenderer);
  10221. updateGizmoRotationToMatchAttachedMesh: boolean;
  10222. /**
  10223. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10224. */
  10225. snapDistance: number;
  10226. /**
  10227. * Ratio for the scale of the gizmo (Default: 1)
  10228. */
  10229. scaleRatio: number;
  10230. /**
  10231. * Disposes of the gizmo
  10232. */
  10233. dispose(): void;
  10234. /**
  10235. * CustomMeshes are not supported by this gizmo
  10236. * @param mesh The mesh to replace the default mesh of the gizmo
  10237. */
  10238. setCustomMesh(mesh: Mesh): void;
  10239. }
  10240. }
  10241. declare module BABYLON {
  10242. /**
  10243. * Gizmo that enables rotating a mesh along 3 axis
  10244. */
  10245. class RotationGizmo extends Gizmo {
  10246. /**
  10247. * Internal gizmo used for interactions on the x axis
  10248. */
  10249. xGizmo: PlaneRotationGizmo;
  10250. /**
  10251. * Internal gizmo used for interactions on the y axis
  10252. */
  10253. yGizmo: PlaneRotationGizmo;
  10254. /**
  10255. * Internal gizmo used for interactions on the z axis
  10256. */
  10257. zGizmo: PlaneRotationGizmo;
  10258. attachedMesh: Nullable<AbstractMesh>;
  10259. /**
  10260. * Creates a RotationGizmo
  10261. * @param gizmoLayer The utility layer the gizmo will be added to
  10262. */
  10263. constructor(gizmoLayer?: UtilityLayerRenderer);
  10264. updateGizmoRotationToMatchAttachedMesh: boolean;
  10265. /**
  10266. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10267. */
  10268. snapDistance: number;
  10269. /**
  10270. * Ratio for the scale of the gizmo (Default: 1)
  10271. */
  10272. scaleRatio: number;
  10273. /**
  10274. * Disposes of the gizmo
  10275. */
  10276. dispose(): void;
  10277. /**
  10278. * CustomMeshes are not supported by this gizmo
  10279. * @param mesh The mesh to replace the default mesh of the gizmo
  10280. */
  10281. setCustomMesh(mesh: Mesh): void;
  10282. }
  10283. }
  10284. declare module BABYLON {
  10285. /**
  10286. * Gizmo that enables scaling a mesh along 3 axis
  10287. */
  10288. class ScaleGizmo extends Gizmo {
  10289. /**
  10290. * Internal gizmo used for interactions on the x axis
  10291. */
  10292. xGizmo: AxisScaleGizmo;
  10293. /**
  10294. * Internal gizmo used for interactions on the y axis
  10295. */
  10296. yGizmo: AxisScaleGizmo;
  10297. /**
  10298. * Internal gizmo used for interactions on the z axis
  10299. */
  10300. zGizmo: AxisScaleGizmo;
  10301. /**
  10302. * @hidden
  10303. * Internal gizmo used to scale all axis equally
  10304. */
  10305. private _uniformGizmo;
  10306. attachedMesh: Nullable<AbstractMesh>;
  10307. /**
  10308. * Creates a ScaleGizmo
  10309. * @param gizmoLayer The utility layer the gizmo will be added to
  10310. */
  10311. constructor(gizmoLayer?: UtilityLayerRenderer);
  10312. updateGizmoRotationToMatchAttachedMesh: boolean;
  10313. /**
  10314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10315. */
  10316. snapDistance: number;
  10317. /**
  10318. * Ratio for the scale of the gizmo (Default: 1)
  10319. */
  10320. scaleRatio: number;
  10321. /**
  10322. * Disposes of the gizmo
  10323. */
  10324. dispose(): void;
  10325. }
  10326. }
  10327. declare module BABYLON {
  10328. /**
  10329. * Represents the different options available during the creation of
  10330. * a Environment helper.
  10331. *
  10332. * This can control the default ground, skybox and image processing setup of your scene.
  10333. */
  10334. interface IEnvironmentHelperOptions {
  10335. /**
  10336. * Specifies wether or not to create a ground.
  10337. * True by default.
  10338. */
  10339. createGround: boolean;
  10340. /**
  10341. * Specifies the ground size.
  10342. * 15 by default.
  10343. */
  10344. groundSize: number;
  10345. /**
  10346. * The texture used on the ground for the main color.
  10347. * Comes from the BabylonJS CDN by default.
  10348. *
  10349. * Remarks: Can be either a texture or a url.
  10350. */
  10351. groundTexture: string | BaseTexture;
  10352. /**
  10353. * The color mixed in the ground texture by default.
  10354. * BabylonJS clearColor by default.
  10355. */
  10356. groundColor: Color3;
  10357. /**
  10358. * Specifies the ground opacity.
  10359. * 1 by default.
  10360. */
  10361. groundOpacity: number;
  10362. /**
  10363. * Enables the ground to receive shadows.
  10364. * True by default.
  10365. */
  10366. enableGroundShadow: boolean;
  10367. /**
  10368. * Helps preventing the shadow to be fully black on the ground.
  10369. * 0.5 by default.
  10370. */
  10371. groundShadowLevel: number;
  10372. /**
  10373. * Creates a mirror texture attach to the ground.
  10374. * false by default.
  10375. */
  10376. enableGroundMirror: boolean;
  10377. /**
  10378. * Specifies the ground mirror size ratio.
  10379. * 0.3 by default as the default kernel is 64.
  10380. */
  10381. groundMirrorSizeRatio: number;
  10382. /**
  10383. * Specifies the ground mirror blur kernel size.
  10384. * 64 by default.
  10385. */
  10386. groundMirrorBlurKernel: number;
  10387. /**
  10388. * Specifies the ground mirror visibility amount.
  10389. * 1 by default
  10390. */
  10391. groundMirrorAmount: number;
  10392. /**
  10393. * Specifies the ground mirror reflectance weight.
  10394. * This uses the standard weight of the background material to setup the fresnel effect
  10395. * of the mirror.
  10396. * 1 by default.
  10397. */
  10398. groundMirrorFresnelWeight: number;
  10399. /**
  10400. * Specifies the ground mirror Falloff distance.
  10401. * This can helps reducing the size of the reflection.
  10402. * 0 by Default.
  10403. */
  10404. groundMirrorFallOffDistance: number;
  10405. /**
  10406. * Specifies the ground mirror texture type.
  10407. * Unsigned Int by Default.
  10408. */
  10409. groundMirrorTextureType: number;
  10410. /**
  10411. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10412. * the shown objects.
  10413. */
  10414. groundYBias: number;
  10415. /**
  10416. * Specifies wether or not to create a skybox.
  10417. * True by default.
  10418. */
  10419. createSkybox: boolean;
  10420. /**
  10421. * Specifies the skybox size.
  10422. * 20 by default.
  10423. */
  10424. skyboxSize: number;
  10425. /**
  10426. * The texture used on the skybox for the main color.
  10427. * Comes from the BabylonJS CDN by default.
  10428. *
  10429. * Remarks: Can be either a texture or a url.
  10430. */
  10431. skyboxTexture: string | BaseTexture;
  10432. /**
  10433. * The color mixed in the skybox texture by default.
  10434. * BabylonJS clearColor by default.
  10435. */
  10436. skyboxColor: Color3;
  10437. /**
  10438. * The background rotation around the Y axis of the scene.
  10439. * This helps aligning the key lights of your scene with the background.
  10440. * 0 by default.
  10441. */
  10442. backgroundYRotation: number;
  10443. /**
  10444. * Compute automatically the size of the elements to best fit with the scene.
  10445. */
  10446. sizeAuto: boolean;
  10447. /**
  10448. * Default position of the rootMesh if autoSize is not true.
  10449. */
  10450. rootPosition: Vector3;
  10451. /**
  10452. * Sets up the image processing in the scene.
  10453. * true by default.
  10454. */
  10455. setupImageProcessing: boolean;
  10456. /**
  10457. * The texture used as your environment texture in the scene.
  10458. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10459. *
  10460. * Remarks: Can be either a texture or a url.
  10461. */
  10462. environmentTexture: string | BaseTexture;
  10463. /**
  10464. * The value of the exposure to apply to the scene.
  10465. * 0.6 by default if setupImageProcessing is true.
  10466. */
  10467. cameraExposure: number;
  10468. /**
  10469. * The value of the contrast to apply to the scene.
  10470. * 1.6 by default if setupImageProcessing is true.
  10471. */
  10472. cameraContrast: number;
  10473. /**
  10474. * Specifies wether or not tonemapping should be enabled in the scene.
  10475. * true by default if setupImageProcessing is true.
  10476. */
  10477. toneMappingEnabled: boolean;
  10478. }
  10479. /**
  10480. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10481. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10482. * It also helps with the default setup of your imageProcessing configuration.
  10483. */
  10484. class EnvironmentHelper {
  10485. /**
  10486. * Default ground texture URL.
  10487. */
  10488. private static _groundTextureCDNUrl;
  10489. /**
  10490. * Default skybox texture URL.
  10491. */
  10492. private static _skyboxTextureCDNUrl;
  10493. /**
  10494. * Default environment texture URL.
  10495. */
  10496. private static _environmentTextureCDNUrl;
  10497. /**
  10498. * Creates the default options for the helper.
  10499. */
  10500. private static _getDefaultOptions;
  10501. private _rootMesh;
  10502. /**
  10503. * Gets the root mesh created by the helper.
  10504. */
  10505. readonly rootMesh: Mesh;
  10506. private _skybox;
  10507. /**
  10508. * Gets the skybox created by the helper.
  10509. */
  10510. readonly skybox: Nullable<Mesh>;
  10511. private _skyboxTexture;
  10512. /**
  10513. * Gets the skybox texture created by the helper.
  10514. */
  10515. readonly skyboxTexture: Nullable<BaseTexture>;
  10516. private _skyboxMaterial;
  10517. /**
  10518. * Gets the skybox material created by the helper.
  10519. */
  10520. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10521. private _ground;
  10522. /**
  10523. * Gets the ground mesh created by the helper.
  10524. */
  10525. readonly ground: Nullable<Mesh>;
  10526. private _groundTexture;
  10527. /**
  10528. * Gets the ground texture created by the helper.
  10529. */
  10530. readonly groundTexture: Nullable<BaseTexture>;
  10531. private _groundMirror;
  10532. /**
  10533. * Gets the ground mirror created by the helper.
  10534. */
  10535. readonly groundMirror: Nullable<MirrorTexture>;
  10536. /**
  10537. * Gets the ground mirror render list to helps pushing the meshes
  10538. * you wish in the ground reflection.
  10539. */
  10540. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10541. private _groundMaterial;
  10542. /**
  10543. * Gets the ground material created by the helper.
  10544. */
  10545. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10546. /**
  10547. * Stores the creation options.
  10548. */
  10549. private readonly _scene;
  10550. private _options;
  10551. /**
  10552. * This observable will be notified with any error during the creation of the environment,
  10553. * mainly texture creation errors.
  10554. */
  10555. onErrorObservable: Observable<{
  10556. message?: string;
  10557. exception?: any;
  10558. }>;
  10559. /**
  10560. * constructor
  10561. * @param options
  10562. * @param scene The scene to add the material to
  10563. */
  10564. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10565. /**
  10566. * Updates the background according to the new options
  10567. * @param options
  10568. */
  10569. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10570. /**
  10571. * Sets the primary color of all the available elements.
  10572. * @param color the main color to affect to the ground and the background
  10573. */
  10574. setMainColor(color: Color3): void;
  10575. /**
  10576. * Setup the image processing according to the specified options.
  10577. */
  10578. private _setupImageProcessing;
  10579. /**
  10580. * Setup the environment texture according to the specified options.
  10581. */
  10582. private _setupEnvironmentTexture;
  10583. /**
  10584. * Setup the background according to the specified options.
  10585. */
  10586. private _setupBackground;
  10587. /**
  10588. * Get the scene sizes according to the setup.
  10589. */
  10590. private _getSceneSize;
  10591. /**
  10592. * Setup the ground according to the specified options.
  10593. */
  10594. private _setupGround;
  10595. /**
  10596. * Setup the ground material according to the specified options.
  10597. */
  10598. private _setupGroundMaterial;
  10599. /**
  10600. * Setup the ground diffuse texture according to the specified options.
  10601. */
  10602. private _setupGroundDiffuseTexture;
  10603. /**
  10604. * Setup the ground mirror texture according to the specified options.
  10605. */
  10606. private _setupGroundMirrorTexture;
  10607. /**
  10608. * Setup the ground to receive the mirror texture.
  10609. */
  10610. private _setupMirrorInGroundMaterial;
  10611. /**
  10612. * Setup the skybox according to the specified options.
  10613. */
  10614. private _setupSkybox;
  10615. /**
  10616. * Setup the skybox material according to the specified options.
  10617. */
  10618. private _setupSkyboxMaterial;
  10619. /**
  10620. * Setup the skybox reflection texture according to the specified options.
  10621. */
  10622. private _setupSkyboxReflectionTexture;
  10623. private _errorHandler;
  10624. /**
  10625. * Dispose all the elements created by the Helper.
  10626. */
  10627. dispose(): void;
  10628. }
  10629. }
  10630. declare module BABYLON {
  10631. /**
  10632. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10633. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10634. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10635. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10636. */
  10637. class PhotoDome extends TransformNode {
  10638. private _useDirectMapping;
  10639. /**
  10640. * The texture being displayed on the sphere
  10641. */
  10642. protected _photoTexture: Texture;
  10643. /**
  10644. * Gets or sets the texture being displayed on the sphere
  10645. */
  10646. photoTexture: Texture;
  10647. /**
  10648. * Observable raised when an error occured while loading the 360 image
  10649. */
  10650. onLoadErrorObservable: Observable<string>;
  10651. /**
  10652. * The skybox material
  10653. */
  10654. protected _material: BackgroundMaterial;
  10655. /**
  10656. * The surface used for the skybox
  10657. */
  10658. protected _mesh: Mesh;
  10659. /**
  10660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10661. * Also see the options.resolution property.
  10662. */
  10663. fovMultiplier: number;
  10664. /**
  10665. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10666. * @param name Element's name, child elements will append suffixes for their own names.
  10667. * @param urlsOfPhoto defines the url of the photo to display
  10668. * @param options defines an object containing optional or exposed sub element properties
  10669. * @param onError defines a callback called when an error occured while loading the texture
  10670. */
  10671. constructor(name: string, urlOfPhoto: string, options: {
  10672. resolution?: number;
  10673. size?: number;
  10674. useDirectMapping?: boolean;
  10675. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10676. /**
  10677. * Releases resources associated with this node.
  10678. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10679. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10680. */
  10681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10682. }
  10683. }
  10684. declare module BABYLON {
  10685. /**
  10686. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10687. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10688. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10689. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10690. */
  10691. class VideoDome extends TransformNode {
  10692. private _useDirectMapping;
  10693. /**
  10694. * The video texture being displayed on the sphere
  10695. */
  10696. protected _videoTexture: VideoTexture;
  10697. /**
  10698. * Gets the video texture being displayed on the sphere
  10699. */
  10700. readonly videoTexture: VideoTexture;
  10701. /**
  10702. * The skybox material
  10703. */
  10704. protected _material: BackgroundMaterial;
  10705. /**
  10706. * The surface used for the skybox
  10707. */
  10708. protected _mesh: Mesh;
  10709. /**
  10710. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10711. * Also see the options.resolution property.
  10712. */
  10713. fovMultiplier: number;
  10714. /**
  10715. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10716. * @param name Element's name, child elements will append suffixes for their own names.
  10717. * @param urlsOrVideo defines the url(s) or the video element to use
  10718. * @param options An object containing optional or exposed sub element properties
  10719. */
  10720. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10721. resolution?: number;
  10722. clickToPlay?: boolean;
  10723. autoPlay?: boolean;
  10724. loop?: boolean;
  10725. size?: number;
  10726. poster?: string;
  10727. useDirectMapping?: boolean;
  10728. }, scene: Scene);
  10729. /**
  10730. * Releases resources associated with this node.
  10731. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10732. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10733. */
  10734. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10735. }
  10736. }
  10737. declare module BABYLON {
  10738. /**
  10739. * This class can be used to get instrumentation data from a Babylon engine
  10740. */
  10741. class EngineInstrumentation implements IDisposable {
  10742. engine: Engine;
  10743. private _captureGPUFrameTime;
  10744. private _gpuFrameTimeToken;
  10745. private _gpuFrameTime;
  10746. private _captureShaderCompilationTime;
  10747. private _shaderCompilationTime;
  10748. private _onBeginFrameObserver;
  10749. private _onEndFrameObserver;
  10750. private _onBeforeShaderCompilationObserver;
  10751. private _onAfterShaderCompilationObserver;
  10752. /**
  10753. * Gets the perf counter used for GPU frame time
  10754. */
  10755. readonly gpuFrameTimeCounter: PerfCounter;
  10756. /**
  10757. * Gets the GPU frame time capture status
  10758. */
  10759. /**
  10760. * Enable or disable the GPU frame time capture
  10761. */
  10762. captureGPUFrameTime: boolean;
  10763. /**
  10764. * Gets the perf counter used for shader compilation time
  10765. */
  10766. readonly shaderCompilationTimeCounter: PerfCounter;
  10767. /**
  10768. * Gets the shader compilation time capture status
  10769. */
  10770. /**
  10771. * Enable or disable the shader compilation time capture
  10772. */
  10773. captureShaderCompilationTime: boolean;
  10774. constructor(engine: Engine);
  10775. dispose(): void;
  10776. }
  10777. }
  10778. declare module BABYLON {
  10779. /**
  10780. * This class can be used to get instrumentation data from a Babylon engine
  10781. */
  10782. class SceneInstrumentation implements IDisposable {
  10783. scene: Scene;
  10784. private _captureActiveMeshesEvaluationTime;
  10785. private _activeMeshesEvaluationTime;
  10786. private _captureRenderTargetsRenderTime;
  10787. private _renderTargetsRenderTime;
  10788. private _captureFrameTime;
  10789. private _frameTime;
  10790. private _captureRenderTime;
  10791. private _renderTime;
  10792. private _captureInterFrameTime;
  10793. private _interFrameTime;
  10794. private _captureParticlesRenderTime;
  10795. private _particlesRenderTime;
  10796. private _captureSpritesRenderTime;
  10797. private _spritesRenderTime;
  10798. private _capturePhysicsTime;
  10799. private _physicsTime;
  10800. private _captureAnimationsTime;
  10801. private _animationsTime;
  10802. private _captureCameraRenderTime;
  10803. private _cameraRenderTime;
  10804. private _onBeforeActiveMeshesEvaluationObserver;
  10805. private _onAfterActiveMeshesEvaluationObserver;
  10806. private _onBeforeRenderTargetsRenderObserver;
  10807. private _onAfterRenderTargetsRenderObserver;
  10808. private _onAfterRenderObserver;
  10809. private _onBeforeDrawPhaseObserver;
  10810. private _onAfterDrawPhaseObserver;
  10811. private _onBeforeAnimationsObserver;
  10812. private _onBeforeParticlesRenderingObserver;
  10813. private _onAfterParticlesRenderingObserver;
  10814. private _onBeforeSpritesRenderingObserver;
  10815. private _onAfterSpritesRenderingObserver;
  10816. private _onBeforePhysicsObserver;
  10817. private _onAfterPhysicsObserver;
  10818. private _onAfterAnimationsObserver;
  10819. private _onBeforeCameraRenderObserver;
  10820. private _onAfterCameraRenderObserver;
  10821. /**
  10822. * Gets the perf counter used for active meshes evaluation time
  10823. */
  10824. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10825. /**
  10826. * Gets the active meshes evaluation time capture status
  10827. */
  10828. /**
  10829. * Enable or disable the active meshes evaluation time capture
  10830. */
  10831. captureActiveMeshesEvaluationTime: boolean;
  10832. /**
  10833. * Gets the perf counter used for render targets render time
  10834. */
  10835. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10836. /**
  10837. * Gets the render targets render time capture status
  10838. */
  10839. /**
  10840. * Enable or disable the render targets render time capture
  10841. */
  10842. captureRenderTargetsRenderTime: boolean;
  10843. /**
  10844. * Gets the perf counter used for particles render time
  10845. */
  10846. readonly particlesRenderTimeCounter: PerfCounter;
  10847. /**
  10848. * Gets the particles render time capture status
  10849. */
  10850. /**
  10851. * Enable or disable the particles render time capture
  10852. */
  10853. captureParticlesRenderTime: boolean;
  10854. /**
  10855. * Gets the perf counter used for sprites render time
  10856. */
  10857. readonly spritesRenderTimeCounter: PerfCounter;
  10858. /**
  10859. * Gets the sprites render time capture status
  10860. */
  10861. /**
  10862. * Enable or disable the sprites render time capture
  10863. */
  10864. captureSpritesRenderTime: boolean;
  10865. /**
  10866. * Gets the perf counter used for physics time
  10867. */
  10868. readonly physicsTimeCounter: PerfCounter;
  10869. /**
  10870. * Gets the physics time capture status
  10871. */
  10872. /**
  10873. * Enable or disable the physics time capture
  10874. */
  10875. capturePhysicsTime: boolean;
  10876. /**
  10877. * Gets the perf counter used for animations time
  10878. */
  10879. readonly animationsTimeCounter: PerfCounter;
  10880. /**
  10881. * Gets the animations time capture status
  10882. */
  10883. /**
  10884. * Enable or disable the animations time capture
  10885. */
  10886. captureAnimationsTime: boolean;
  10887. /**
  10888. * Gets the perf counter used for frame time capture
  10889. */
  10890. readonly frameTimeCounter: PerfCounter;
  10891. /**
  10892. * Gets the frame time capture status
  10893. */
  10894. /**
  10895. * Enable or disable the frame time capture
  10896. */
  10897. captureFrameTime: boolean;
  10898. /**
  10899. * Gets the perf counter used for inter-frames time capture
  10900. */
  10901. readonly interFrameTimeCounter: PerfCounter;
  10902. /**
  10903. * Gets the inter-frames time capture status
  10904. */
  10905. /**
  10906. * Enable or disable the inter-frames time capture
  10907. */
  10908. captureInterFrameTime: boolean;
  10909. /**
  10910. * Gets the perf counter used for render time capture
  10911. */
  10912. readonly renderTimeCounter: PerfCounter;
  10913. /**
  10914. * Gets the render time capture status
  10915. */
  10916. /**
  10917. * Enable or disable the render time capture
  10918. */
  10919. captureRenderTime: boolean;
  10920. /**
  10921. * Gets the perf counter used for camera render time capture
  10922. */
  10923. readonly cameraRenderTimeCounter: PerfCounter;
  10924. /**
  10925. * Gets the camera render time capture status
  10926. */
  10927. /**
  10928. * Enable or disable the camera render time capture
  10929. */
  10930. captureCameraRenderTime: boolean;
  10931. /**
  10932. * Gets the perf counter used for draw calls
  10933. */
  10934. readonly drawCallsCounter: PerfCounter;
  10935. /**
  10936. * Gets the perf counter used for texture collisions
  10937. */
  10938. readonly textureCollisionsCounter: PerfCounter;
  10939. constructor(scene: Scene);
  10940. dispose(): void;
  10941. }
  10942. }
  10943. declare module BABYLON {
  10944. /**
  10945. * @hidden
  10946. **/
  10947. class _TimeToken {
  10948. _startTimeQuery: Nullable<WebGLQuery>;
  10949. _endTimeQuery: Nullable<WebGLQuery>;
  10950. _timeElapsedQuery: Nullable<WebGLQuery>;
  10951. _timeElapsedQueryEnded: boolean;
  10952. }
  10953. }
  10954. declare module BABYLON {
  10955. /**
  10956. * Effect layer options. This helps customizing the behaviour
  10957. * of the effect layer.
  10958. */
  10959. interface IEffectLayerOptions {
  10960. /**
  10961. * Multiplication factor apply to the canvas size to compute the render target size
  10962. * used to generated the objects (the smaller the faster).
  10963. */
  10964. mainTextureRatio: number;
  10965. /**
  10966. * Enforces a fixed size texture to ensure effect stability across devices.
  10967. */
  10968. mainTextureFixedSize?: number;
  10969. /**
  10970. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10971. */
  10972. alphaBlendingMode: number;
  10973. /**
  10974. * The camera attached to the layer.
  10975. */
  10976. camera: Nullable<Camera>;
  10977. /**
  10978. * The rendering group to draw the layer in.
  10979. */
  10980. renderingGroupId: number;
  10981. }
  10982. /**
  10983. * The effect layer Helps adding post process effect blended with the main pass.
  10984. *
  10985. * This can be for instance use to generate glow or higlight effects on the scene.
  10986. *
  10987. * The effect layer class can not be used directly and is intented to inherited from to be
  10988. * customized per effects.
  10989. */
  10990. abstract class EffectLayer {
  10991. private _vertexBuffers;
  10992. private _indexBuffer;
  10993. private _cachedDefines;
  10994. private _effectLayerMapGenerationEffect;
  10995. private _effectLayerOptions;
  10996. private _mergeEffect;
  10997. protected _scene: Scene;
  10998. protected _engine: Engine;
  10999. protected _maxSize: number;
  11000. protected _mainTextureDesiredSize: ISize;
  11001. protected _mainTexture: RenderTargetTexture;
  11002. protected _shouldRender: boolean;
  11003. protected _postProcesses: PostProcess[];
  11004. protected _textures: BaseTexture[];
  11005. protected _emissiveTextureAndColor: {
  11006. texture: Nullable<BaseTexture>;
  11007. color: Color4;
  11008. };
  11009. /**
  11010. * The name of the layer
  11011. */
  11012. name: string;
  11013. /**
  11014. * The clear color of the texture used to generate the glow map.
  11015. */
  11016. neutralColor: Color4;
  11017. /**
  11018. * Specifies wether the highlight layer is enabled or not.
  11019. */
  11020. isEnabled: boolean;
  11021. /**
  11022. * Gets the camera attached to the layer.
  11023. */
  11024. readonly camera: Nullable<Camera>;
  11025. /**
  11026. * Gets the rendering group id the layer should render in.
  11027. */
  11028. readonly renderingGroupId: number;
  11029. /**
  11030. * An event triggered when the effect layer has been disposed.
  11031. */
  11032. onDisposeObservable: Observable<EffectLayer>;
  11033. /**
  11034. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11035. */
  11036. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11037. /**
  11038. * An event triggered when the generated texture is being merged in the scene.
  11039. */
  11040. onBeforeComposeObservable: Observable<EffectLayer>;
  11041. /**
  11042. * An event triggered when the generated texture has been merged in the scene.
  11043. */
  11044. onAfterComposeObservable: Observable<EffectLayer>;
  11045. /**
  11046. * An event triggered when the efffect layer changes its size.
  11047. */
  11048. onSizeChangedObservable: Observable<EffectLayer>;
  11049. /**
  11050. * Instantiates a new effect Layer and references it in the scene.
  11051. * @param name The name of the layer
  11052. * @param scene The scene to use the layer in
  11053. */
  11054. constructor(
  11055. /** The Friendly of the effect in the scene */
  11056. name: string, scene: Scene);
  11057. /**
  11058. * Get the effect name of the layer.
  11059. * @return The effect name
  11060. */
  11061. abstract getEffectName(): string;
  11062. /**
  11063. * Checks for the readiness of the element composing the layer.
  11064. * @param subMesh the mesh to check for
  11065. * @param useInstances specify wether or not to use instances to render the mesh
  11066. * @return true if ready otherwise, false
  11067. */
  11068. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11069. /**
  11070. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11071. * @returns true if the effect requires stencil during the main canvas render pass.
  11072. */
  11073. abstract needStencil(): boolean;
  11074. /**
  11075. * Create the merge effect. This is the shader use to blit the information back
  11076. * to the main canvas at the end of the scene rendering.
  11077. * @returns The effect containing the shader used to merge the effect on the main canvas
  11078. */
  11079. protected abstract _createMergeEffect(): Effect;
  11080. /**
  11081. * Creates the render target textures and post processes used in the effect layer.
  11082. */
  11083. protected abstract _createTextureAndPostProcesses(): void;
  11084. /**
  11085. * Implementation specific of rendering the generating effect on the main canvas.
  11086. * @param effect The effect used to render through
  11087. */
  11088. protected abstract _internalRender(effect: Effect): void;
  11089. /**
  11090. * Sets the required values for both the emissive texture and and the main color.
  11091. */
  11092. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11093. /**
  11094. * Free any resources and references associated to a mesh.
  11095. * Internal use
  11096. * @param mesh The mesh to free.
  11097. */
  11098. abstract _disposeMesh(mesh: Mesh): void;
  11099. /**
  11100. * Serializes this layer (Glow or Highlight for example)
  11101. * @returns a serialized layer object
  11102. */
  11103. abstract serialize?(): any;
  11104. /**
  11105. * Initializes the effect layer with the required options.
  11106. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11107. */
  11108. protected _init(options: Partial<IEffectLayerOptions>): void;
  11109. /**
  11110. * Generates the index buffer of the full screen quad blending to the main canvas.
  11111. */
  11112. private _generateIndexBuffer;
  11113. /**
  11114. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11115. */
  11116. private _genrateVertexBuffer;
  11117. /**
  11118. * Sets the main texture desired size which is the closest power of two
  11119. * of the engine canvas size.
  11120. */
  11121. private _setMainTextureSize;
  11122. /**
  11123. * Creates the main texture for the effect layer.
  11124. */
  11125. protected _createMainTexture(): void;
  11126. /**
  11127. * Checks for the readiness of the element composing the layer.
  11128. * @param subMesh the mesh to check for
  11129. * @param useInstances specify wether or not to use instances to render the mesh
  11130. * @param emissiveTexture the associated emissive texture used to generate the glow
  11131. * @return true if ready otherwise, false
  11132. */
  11133. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11134. /**
  11135. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11136. */
  11137. render(): void;
  11138. /**
  11139. * Determine if a given mesh will be used in the current effect.
  11140. * @param mesh mesh to test
  11141. * @returns true if the mesh will be used
  11142. */
  11143. hasMesh(mesh: AbstractMesh): boolean;
  11144. /**
  11145. * Returns true if the layer contains information to display, otherwise false.
  11146. * @returns true if the glow layer should be rendered
  11147. */
  11148. shouldRender(): boolean;
  11149. /**
  11150. * Returns true if the mesh should render, otherwise false.
  11151. * @param mesh The mesh to render
  11152. * @returns true if it should render otherwise false
  11153. */
  11154. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11155. /**
  11156. * Returns true if the mesh should render, otherwise false.
  11157. * @param mesh The mesh to render
  11158. * @returns true if it should render otherwise false
  11159. */
  11160. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11161. /**
  11162. * Renders the submesh passed in parameter to the generation map.
  11163. */
  11164. protected _renderSubMesh(subMesh: SubMesh): void;
  11165. /**
  11166. * Rebuild the required buffers.
  11167. * @hidden Internal use only.
  11168. */
  11169. _rebuild(): void;
  11170. /**
  11171. * Dispose only the render target textures and post process.
  11172. */
  11173. private _disposeTextureAndPostProcesses;
  11174. /**
  11175. * Dispose the highlight layer and free resources.
  11176. */
  11177. dispose(): void;
  11178. /**
  11179. * Gets the class name of the effect layer
  11180. * @returns the string with the class name of the effect layer
  11181. */
  11182. getClassName(): string;
  11183. /**
  11184. * Creates an effect layer from parsed effect layer data
  11185. * @param parsedEffectLayer defines effect layer data
  11186. * @param scene defines the current scene
  11187. * @param rootUrl defines the root URL containing the effect layer information
  11188. * @returns a parsed effect Layer
  11189. */
  11190. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11191. }
  11192. }
  11193. declare module BABYLON {
  11194. interface AbstractScene {
  11195. /**
  11196. * The list of effect layers (highlights/glow) added to the scene
  11197. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11198. * @see http://doc.babylonjs.com/how_to/glow_layer
  11199. */
  11200. effectLayers: Array<EffectLayer>;
  11201. /**
  11202. * Removes the given effect layer from this scene.
  11203. * @param toRemove defines the effect layer to remove
  11204. * @returns the index of the removed effect layer
  11205. */
  11206. removeEffectLayer(toRemove: EffectLayer): number;
  11207. /**
  11208. * Adds the given effect layer to this scene
  11209. * @param newEffectLayer defines the effect layer to add
  11210. */
  11211. addEffectLayer(newEffectLayer: EffectLayer): void;
  11212. }
  11213. /**
  11214. * Defines the layer scene component responsible to manage any effect layers
  11215. * in a given scene.
  11216. */
  11217. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11218. /**
  11219. * The component name helpfull to identify the component in the list of scene components.
  11220. */
  11221. readonly name: string;
  11222. /**
  11223. * The scene the component belongs to.
  11224. */
  11225. scene: Scene;
  11226. private _engine;
  11227. private _renderEffects;
  11228. private _needStencil;
  11229. private _previousStencilState;
  11230. /**
  11231. * Creates a new instance of the component for the given scene
  11232. * @param scene Defines the scene to register the component in
  11233. */
  11234. constructor(scene: Scene);
  11235. /**
  11236. * Registers the component in a given scene
  11237. */
  11238. register(): void;
  11239. /**
  11240. * Rebuilds the elements related to this component in case of
  11241. * context lost for instance.
  11242. */
  11243. rebuild(): void;
  11244. /**
  11245. * Serializes the component data to the specified json object
  11246. * @param serializationObject The object to serialize to
  11247. */
  11248. serialize(serializationObject: any): void;
  11249. /**
  11250. * Adds all the element from the container to the scene
  11251. * @param container the container holding the elements
  11252. */
  11253. addFromContainer(container: AbstractScene): void;
  11254. /**
  11255. * Removes all the elements in the container from the scene
  11256. * @param container contains the elements to remove
  11257. */
  11258. removeFromContainer(container: AbstractScene): void;
  11259. /**
  11260. * Disposes the component and the associated ressources.
  11261. */
  11262. dispose(): void;
  11263. private _isReadyForMesh;
  11264. private _renderMainTexture;
  11265. private _setStencil;
  11266. private _setStencilBack;
  11267. private _draw;
  11268. private _drawCamera;
  11269. private _drawRenderingGroup;
  11270. }
  11271. }
  11272. declare module BABYLON {
  11273. interface AbstractScene {
  11274. /**
  11275. * Return a the first highlight layer of the scene with a given name.
  11276. * @param name The name of the highlight layer to look for.
  11277. * @return The highlight layer if found otherwise null.
  11278. */
  11279. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11280. }
  11281. /**
  11282. * Glow layer options. This helps customizing the behaviour
  11283. * of the glow layer.
  11284. */
  11285. interface IGlowLayerOptions {
  11286. /**
  11287. * Multiplication factor apply to the canvas size to compute the render target size
  11288. * used to generated the glowing objects (the smaller the faster).
  11289. */
  11290. mainTextureRatio: number;
  11291. /**
  11292. * Enforces a fixed size texture to ensure resize independant blur.
  11293. */
  11294. mainTextureFixedSize?: number;
  11295. /**
  11296. * How big is the kernel of the blur texture.
  11297. */
  11298. blurKernelSize: number;
  11299. /**
  11300. * The camera attached to the layer.
  11301. */
  11302. camera: Nullable<Camera>;
  11303. /**
  11304. * Enable MSAA by chosing the number of samples.
  11305. */
  11306. mainTextureSamples?: number;
  11307. /**
  11308. * The rendering group to draw the layer in.
  11309. */
  11310. renderingGroupId: number;
  11311. }
  11312. /**
  11313. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11314. *
  11315. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11316. * glowy meshes to your scene.
  11317. *
  11318. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11319. */
  11320. class GlowLayer extends EffectLayer {
  11321. /**
  11322. * Effect Name of the layer.
  11323. */
  11324. static readonly EffectName: string;
  11325. /**
  11326. * The default blur kernel size used for the glow.
  11327. */
  11328. static DefaultBlurKernelSize: number;
  11329. /**
  11330. * The default texture size ratio used for the glow.
  11331. */
  11332. static DefaultTextureRatio: number;
  11333. /**
  11334. * Sets the kernel size of the blur.
  11335. */
  11336. /**
  11337. * Gets the kernel size of the blur.
  11338. */
  11339. blurKernelSize: number;
  11340. /**
  11341. * Sets the glow intensity.
  11342. */
  11343. /**
  11344. * Gets the glow intensity.
  11345. */
  11346. intensity: number;
  11347. private _options;
  11348. private _intensity;
  11349. private _horizontalBlurPostprocess1;
  11350. private _verticalBlurPostprocess1;
  11351. private _horizontalBlurPostprocess2;
  11352. private _verticalBlurPostprocess2;
  11353. private _blurTexture1;
  11354. private _blurTexture2;
  11355. private _postProcesses1;
  11356. private _postProcesses2;
  11357. private _includedOnlyMeshes;
  11358. private _excludedMeshes;
  11359. /**
  11360. * Callback used to let the user override the color selection on a per mesh basis
  11361. */
  11362. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11363. /**
  11364. * Callback used to let the user override the texture selection on a per mesh basis
  11365. */
  11366. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11367. /**
  11368. * Instantiates a new glow Layer and references it to the scene.
  11369. * @param name The name of the layer
  11370. * @param scene The scene to use the layer in
  11371. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11372. */
  11373. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11374. /**
  11375. * Get the effect name of the layer.
  11376. * @return The effect name
  11377. */
  11378. getEffectName(): string;
  11379. /**
  11380. * Create the merge effect. This is the shader use to blit the information back
  11381. * to the main canvas at the end of the scene rendering.
  11382. */
  11383. protected _createMergeEffect(): Effect;
  11384. /**
  11385. * Creates the render target textures and post processes used in the glow layer.
  11386. */
  11387. protected _createTextureAndPostProcesses(): void;
  11388. /**
  11389. * Checks for the readiness of the element composing the layer.
  11390. * @param subMesh the mesh to check for
  11391. * @param useInstances specify wether or not to use instances to render the mesh
  11392. * @param emissiveTexture the associated emissive texture used to generate the glow
  11393. * @return true if ready otherwise, false
  11394. */
  11395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11396. /**
  11397. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11398. */
  11399. needStencil(): boolean;
  11400. /**
  11401. * Implementation specific of rendering the generating effect on the main canvas.
  11402. * @param effect The effect used to render through
  11403. */
  11404. protected _internalRender(effect: Effect): void;
  11405. /**
  11406. * Sets the required values for both the emissive texture and and the main color.
  11407. */
  11408. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11409. /**
  11410. * Returns true if the mesh should render, otherwise false.
  11411. * @param mesh The mesh to render
  11412. * @returns true if it should render otherwise false
  11413. */
  11414. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11415. /**
  11416. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11417. * @param mesh The mesh to exclude from the glow layer
  11418. */
  11419. addExcludedMesh(mesh: Mesh): void;
  11420. /**
  11421. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11422. * @param mesh The mesh to remove
  11423. */
  11424. removeExcludedMesh(mesh: Mesh): void;
  11425. /**
  11426. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11427. * @param mesh The mesh to include in the glow layer
  11428. */
  11429. addIncludedOnlyMesh(mesh: Mesh): void;
  11430. /**
  11431. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11432. * @param mesh The mesh to remove
  11433. */
  11434. removeIncludedOnlyMesh(mesh: Mesh): void;
  11435. /**
  11436. * Determine if a given mesh will be used in the glow layer
  11437. * @param mesh The mesh to test
  11438. * @returns true if the mesh will be highlighted by the current glow layer
  11439. */
  11440. hasMesh(mesh: AbstractMesh): boolean;
  11441. /**
  11442. * Free any resources and references associated to a mesh.
  11443. * Internal use
  11444. * @param mesh The mesh to free.
  11445. * @hidden
  11446. */
  11447. _disposeMesh(mesh: Mesh): void;
  11448. /**
  11449. * Gets the class name of the effect layer
  11450. * @returns the string with the class name of the effect layer
  11451. */
  11452. getClassName(): string;
  11453. /**
  11454. * Serializes this glow layer
  11455. * @returns a serialized glow layer object
  11456. */
  11457. serialize(): any;
  11458. /**
  11459. * Creates a Glow Layer from parsed glow layer data
  11460. * @param parsedGlowLayer defines glow layer data
  11461. * @param scene defines the current scene
  11462. * @param rootUrl defines the root URL containing the glow layer information
  11463. * @returns a parsed Glow Layer
  11464. */
  11465. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11466. }
  11467. }
  11468. declare module BABYLON {
  11469. interface AbstractScene {
  11470. /**
  11471. * Return a the first highlight layer of the scene with a given name.
  11472. * @param name The name of the highlight layer to look for.
  11473. * @return The highlight layer if found otherwise null.
  11474. */
  11475. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11476. }
  11477. /**
  11478. * Highlight layer options. This helps customizing the behaviour
  11479. * of the highlight layer.
  11480. */
  11481. interface IHighlightLayerOptions {
  11482. /**
  11483. * Multiplication factor apply to the canvas size to compute the render target size
  11484. * used to generated the glowing objects (the smaller the faster).
  11485. */
  11486. mainTextureRatio: number;
  11487. /**
  11488. * Enforces a fixed size texture to ensure resize independant blur.
  11489. */
  11490. mainTextureFixedSize?: number;
  11491. /**
  11492. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11493. * of the picture to blur (the smaller the faster).
  11494. */
  11495. blurTextureSizeRatio: number;
  11496. /**
  11497. * How big in texel of the blur texture is the vertical blur.
  11498. */
  11499. blurVerticalSize: number;
  11500. /**
  11501. * How big in texel of the blur texture is the horizontal blur.
  11502. */
  11503. blurHorizontalSize: number;
  11504. /**
  11505. * Alpha blending mode used to apply the blur. Default is combine.
  11506. */
  11507. alphaBlendingMode: number;
  11508. /**
  11509. * The camera attached to the layer.
  11510. */
  11511. camera: Nullable<Camera>;
  11512. /**
  11513. * Should we display highlight as a solid stroke?
  11514. */
  11515. isStroke?: boolean;
  11516. /**
  11517. * The rendering group to draw the layer in.
  11518. */
  11519. renderingGroupId: number;
  11520. }
  11521. /**
  11522. * The highlight layer Helps adding a glow effect around a mesh.
  11523. *
  11524. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11525. * glowy meshes to your scene.
  11526. *
  11527. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11528. */
  11529. class HighlightLayer extends EffectLayer {
  11530. name: string;
  11531. /**
  11532. * Effect Name of the highlight layer.
  11533. */
  11534. static readonly EffectName: string;
  11535. /**
  11536. * The neutral color used during the preparation of the glow effect.
  11537. * This is black by default as the blend operation is a blend operation.
  11538. */
  11539. static NeutralColor: Color4;
  11540. /**
  11541. * Stencil value used for glowing meshes.
  11542. */
  11543. static GlowingMeshStencilReference: number;
  11544. /**
  11545. * Stencil value used for the other meshes in the scene.
  11546. */
  11547. static NormalMeshStencilReference: number;
  11548. /**
  11549. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11550. */
  11551. innerGlow: boolean;
  11552. /**
  11553. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11554. */
  11555. outerGlow: boolean;
  11556. /**
  11557. * Specifies the horizontal size of the blur.
  11558. */
  11559. /**
  11560. * Gets the horizontal size of the blur.
  11561. */
  11562. blurHorizontalSize: number;
  11563. /**
  11564. * Specifies the vertical size of the blur.
  11565. */
  11566. /**
  11567. * Gets the vertical size of the blur.
  11568. */
  11569. blurVerticalSize: number;
  11570. /**
  11571. * An event triggered when the highlight layer is being blurred.
  11572. */
  11573. onBeforeBlurObservable: Observable<HighlightLayer>;
  11574. /**
  11575. * An event triggered when the highlight layer has been blurred.
  11576. */
  11577. onAfterBlurObservable: Observable<HighlightLayer>;
  11578. private _instanceGlowingMeshStencilReference;
  11579. private _options;
  11580. private _downSamplePostprocess;
  11581. private _horizontalBlurPostprocess;
  11582. private _verticalBlurPostprocess;
  11583. private _blurTexture;
  11584. private _meshes;
  11585. private _excludedMeshes;
  11586. /**
  11587. * Instantiates a new highlight Layer and references it to the scene..
  11588. * @param name The name of the layer
  11589. * @param scene The scene to use the layer in
  11590. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11591. */
  11592. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11593. /**
  11594. * Get the effect name of the layer.
  11595. * @return The effect name
  11596. */
  11597. getEffectName(): string;
  11598. /**
  11599. * Create the merge effect. This is the shader use to blit the information back
  11600. * to the main canvas at the end of the scene rendering.
  11601. */
  11602. protected _createMergeEffect(): Effect;
  11603. /**
  11604. * Creates the render target textures and post processes used in the highlight layer.
  11605. */
  11606. protected _createTextureAndPostProcesses(): void;
  11607. /**
  11608. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11609. */
  11610. needStencil(): boolean;
  11611. /**
  11612. * Checks for the readiness of the element composing the layer.
  11613. * @param subMesh the mesh to check for
  11614. * @param useInstances specify wether or not to use instances to render the mesh
  11615. * @param emissiveTexture the associated emissive texture used to generate the glow
  11616. * @return true if ready otherwise, false
  11617. */
  11618. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11619. /**
  11620. * Implementation specific of rendering the generating effect on the main canvas.
  11621. * @param effect The effect used to render through
  11622. */
  11623. protected _internalRender(effect: Effect): void;
  11624. /**
  11625. * Returns true if the layer contains information to display, otherwise false.
  11626. */
  11627. shouldRender(): boolean;
  11628. /**
  11629. * Returns true if the mesh should render, otherwise false.
  11630. * @param mesh The mesh to render
  11631. * @returns true if it should render otherwise false
  11632. */
  11633. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11634. /**
  11635. * Sets the required values for both the emissive texture and and the main color.
  11636. */
  11637. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11638. /**
  11639. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11640. * @param mesh The mesh to exclude from the highlight layer
  11641. */
  11642. addExcludedMesh(mesh: Mesh): void;
  11643. /**
  11644. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11645. * @param mesh The mesh to highlight
  11646. */
  11647. removeExcludedMesh(mesh: Mesh): void;
  11648. /**
  11649. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11650. * @param mesh mesh to test
  11651. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11652. */
  11653. hasMesh(mesh: AbstractMesh): boolean;
  11654. /**
  11655. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11656. * @param mesh The mesh to highlight
  11657. * @param color The color of the highlight
  11658. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11659. */
  11660. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11661. /**
  11662. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11663. * @param mesh The mesh to highlight
  11664. */
  11665. removeMesh(mesh: Mesh): void;
  11666. /**
  11667. * Force the stencil to the normal expected value for none glowing parts
  11668. */
  11669. private _defaultStencilReference;
  11670. /**
  11671. * Free any resources and references associated to a mesh.
  11672. * Internal use
  11673. * @param mesh The mesh to free.
  11674. * @hidden
  11675. */
  11676. _disposeMesh(mesh: Mesh): void;
  11677. /**
  11678. * Dispose the highlight layer and free resources.
  11679. */
  11680. dispose(): void;
  11681. /**
  11682. * Gets the class name of the effect layer
  11683. * @returns the string with the class name of the effect layer
  11684. */
  11685. getClassName(): string;
  11686. /**
  11687. * Serializes this Highlight layer
  11688. * @returns a serialized Highlight layer object
  11689. */
  11690. serialize(): any;
  11691. /**
  11692. * Creates a Highlight layer from parsed Highlight layer data
  11693. * @param parsedHightlightLayer defines the Highlight layer data
  11694. * @param scene defines the current scene
  11695. * @param rootUrl defines the root URL containing the Highlight layer information
  11696. * @returns a parsed Highlight layer
  11697. */
  11698. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. class Layer {
  11703. name: string;
  11704. texture: Nullable<Texture>;
  11705. isBackground: boolean;
  11706. color: Color4;
  11707. scale: Vector2;
  11708. offset: Vector2;
  11709. alphaBlendingMode: number;
  11710. alphaTest: boolean;
  11711. layerMask: number;
  11712. private _scene;
  11713. private _vertexBuffers;
  11714. private _indexBuffer;
  11715. private _effect;
  11716. private _alphaTestEffect;
  11717. /**
  11718. * An event triggered when the layer is disposed.
  11719. */
  11720. onDisposeObservable: Observable<Layer>;
  11721. private _onDisposeObserver;
  11722. onDispose: () => void;
  11723. /**
  11724. * An event triggered before rendering the scene
  11725. */
  11726. onBeforeRenderObservable: Observable<Layer>;
  11727. private _onBeforeRenderObserver;
  11728. onBeforeRender: () => void;
  11729. /**
  11730. * An event triggered after rendering the scene
  11731. */
  11732. onAfterRenderObservable: Observable<Layer>;
  11733. private _onAfterRenderObserver;
  11734. onAfterRender: () => void;
  11735. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11736. private _createIndexBuffer;
  11737. /** @hidden */
  11738. _rebuild(): void;
  11739. render(): void;
  11740. dispose(): void;
  11741. }
  11742. }
  11743. declare module BABYLON {
  11744. interface AbstractScene {
  11745. /**
  11746. * The list of layers (background and foreground) of the scene
  11747. */
  11748. layers: Array<Layer>;
  11749. }
  11750. /**
  11751. * Defines the layer scene component responsible to manage any layers
  11752. * in a given scene.
  11753. */
  11754. class LayerSceneComponent implements ISceneComponent {
  11755. /**
  11756. * The component name helpfull to identify the component in the list of scene components.
  11757. */
  11758. readonly name: string;
  11759. /**
  11760. * The scene the component belongs to.
  11761. */
  11762. scene: Scene;
  11763. private _engine;
  11764. /**
  11765. * Creates a new instance of the component for the given scene
  11766. * @param scene Defines the scene to register the component in
  11767. */
  11768. constructor(scene: Scene);
  11769. /**
  11770. * Registers the component in a given scene
  11771. */
  11772. register(): void;
  11773. /**
  11774. * Rebuilds the elements related to this component in case of
  11775. * context lost for instance.
  11776. */
  11777. rebuild(): void;
  11778. /**
  11779. * Disposes the component and the associated ressources.
  11780. */
  11781. dispose(): void;
  11782. private _draw;
  11783. private _drawBackground;
  11784. private _drawForeground;
  11785. }
  11786. }
  11787. declare module BABYLON {
  11788. class LensFlare {
  11789. size: number;
  11790. position: number;
  11791. color: Color3;
  11792. texture: Nullable<Texture>;
  11793. alphaMode: number;
  11794. private _system;
  11795. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11796. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11797. dispose(): void;
  11798. }
  11799. }
  11800. declare module BABYLON {
  11801. class LensFlareSystem {
  11802. name: string;
  11803. lensFlares: LensFlare[];
  11804. borderLimit: number;
  11805. viewportBorder: number;
  11806. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11807. layerMask: number;
  11808. id: string;
  11809. private _scene;
  11810. private _emitter;
  11811. private _vertexBuffers;
  11812. private _indexBuffer;
  11813. private _effect;
  11814. private _positionX;
  11815. private _positionY;
  11816. private _isEnabled;
  11817. constructor(name: string, emitter: any, scene: Scene);
  11818. isEnabled: boolean;
  11819. getScene(): Scene;
  11820. getEmitter(): any;
  11821. setEmitter(newEmitter: any): void;
  11822. getEmitterPosition(): Vector3;
  11823. computeEffectivePosition(globalViewport: Viewport): boolean;
  11824. /** @hidden */
  11825. _isVisible(): boolean;
  11826. render(): boolean;
  11827. dispose(): void;
  11828. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11829. serialize(): any;
  11830. }
  11831. }
  11832. declare module BABYLON {
  11833. interface AbstractScene {
  11834. /**
  11835. * The list of lens flare system added to the scene
  11836. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11837. */
  11838. lensFlareSystems: Array<LensFlareSystem>;
  11839. /**
  11840. * Removes the given lens flare system from this scene.
  11841. * @param toRemove The lens flare system to remove
  11842. * @returns The index of the removed lens flare system
  11843. */
  11844. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11845. /**
  11846. * Adds the given lens flare system to this scene
  11847. * @param newLensFlareSystem The lens flare system to add
  11848. */
  11849. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11850. /**
  11851. * Gets a lens flare system using its name
  11852. * @param name defines the name to look for
  11853. * @returns the lens flare system or null if not found
  11854. */
  11855. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11856. /**
  11857. * Gets a lens flare system using its id
  11858. * @param id defines the id to look for
  11859. * @returns the lens flare system or null if not found
  11860. */
  11861. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11862. }
  11863. /**
  11864. * Defines the lens flare scene component responsible to manage any lens flares
  11865. * in a given scene.
  11866. */
  11867. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11868. /**
  11869. * The component name helpfull to identify the component in the list of scene components.
  11870. */
  11871. readonly name: string;
  11872. /**
  11873. * The scene the component belongs to.
  11874. */
  11875. scene: Scene;
  11876. /**
  11877. * Creates a new instance of the component for the given scene
  11878. * @param scene Defines the scene to register the component in
  11879. */
  11880. constructor(scene: Scene);
  11881. /**
  11882. * Registers the component in a given scene
  11883. */
  11884. register(): void;
  11885. /**
  11886. * Rebuilds the elements related to this component in case of
  11887. * context lost for instance.
  11888. */
  11889. rebuild(): void;
  11890. /**
  11891. * Adds all the element from the container to the scene
  11892. * @param container the container holding the elements
  11893. */
  11894. addFromContainer(container: AbstractScene): void;
  11895. /**
  11896. * Removes all the elements in the container from the scene
  11897. * @param container contains the elements to remove
  11898. */
  11899. removeFromContainer(container: AbstractScene): void;
  11900. /**
  11901. * Serializes the component data to the specified json object
  11902. * @param serializationObject The object to serialize to
  11903. */
  11904. serialize(serializationObject: any): void;
  11905. /**
  11906. * Disposes the component and the associated ressources.
  11907. */
  11908. dispose(): void;
  11909. private _draw;
  11910. }
  11911. }
  11912. declare module BABYLON {
  11913. /**
  11914. * A directional light is defined by a direction (what a surprise!).
  11915. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11916. * 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.
  11917. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11918. */
  11919. class DirectionalLight extends ShadowLight {
  11920. private _shadowFrustumSize;
  11921. /**
  11922. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11923. */
  11924. /**
  11925. * Specifies a fix frustum size for the shadow generation.
  11926. */
  11927. shadowFrustumSize: number;
  11928. private _shadowOrthoScale;
  11929. /**
  11930. * Gets the shadow projection scale against the optimal computed one.
  11931. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11932. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11933. */
  11934. /**
  11935. * Sets the shadow projection scale against the optimal computed one.
  11936. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11937. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11938. */
  11939. shadowOrthoScale: number;
  11940. /**
  11941. * Automatically compute the projection matrix to best fit (including all the casters)
  11942. * on each frame.
  11943. */
  11944. autoUpdateExtends: boolean;
  11945. private _orthoLeft;
  11946. private _orthoRight;
  11947. private _orthoTop;
  11948. private _orthoBottom;
  11949. /**
  11950. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11951. * The directional light is emitted from everywhere in the given direction.
  11952. * It can cast shawdows.
  11953. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11954. * @param name The friendly name of the light
  11955. * @param direction The direction of the light
  11956. * @param scene The scene the light belongs to
  11957. */
  11958. constructor(name: string, direction: Vector3, scene: Scene);
  11959. /**
  11960. * Returns the string "DirectionalLight".
  11961. * @return The class name
  11962. */
  11963. getClassName(): string;
  11964. /**
  11965. * Returns the integer 1.
  11966. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11967. */
  11968. getTypeID(): number;
  11969. /**
  11970. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11971. * Returns the DirectionalLight Shadow projection matrix.
  11972. */
  11973. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11974. /**
  11975. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11976. * Returns the DirectionalLight Shadow projection matrix.
  11977. */
  11978. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11979. /**
  11980. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11981. * Returns the DirectionalLight Shadow projection matrix.
  11982. */
  11983. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11984. protected _buildUniformLayout(): void;
  11985. /**
  11986. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11987. * @param effect The effect to update
  11988. * @param lightIndex The index of the light in the effect to update
  11989. * @returns The directional light
  11990. */
  11991. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11992. /**
  11993. * Gets the minZ used for shadow according to both the scene and the light.
  11994. *
  11995. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11996. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11997. * @param activeCamera The camera we are returning the min for
  11998. * @returns the depth min z
  11999. */
  12000. getDepthMinZ(activeCamera: Camera): number;
  12001. /**
  12002. * Gets the maxZ used for shadow according to both the scene and the light.
  12003. *
  12004. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12005. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12006. * @param activeCamera The camera we are returning the max for
  12007. * @returns the depth max z
  12008. */
  12009. getDepthMaxZ(activeCamera: Camera): number;
  12010. /**
  12011. * Prepares the list of defines specific to the light type.
  12012. * @param defines the list of defines
  12013. * @param lightIndex defines the index of the light for the effect
  12014. */
  12015. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12016. }
  12017. }
  12018. declare module BABYLON {
  12019. /**
  12020. * The HemisphericLight simulates the ambient environment light,
  12021. * so the passed direction is the light reflection direction, not the incoming direction.
  12022. */
  12023. class HemisphericLight extends Light {
  12024. /**
  12025. * The groundColor is the light in the opposite direction to the one specified during creation.
  12026. * 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.
  12027. */
  12028. groundColor: Color3;
  12029. /**
  12030. * The light reflection direction, not the incoming direction.
  12031. */
  12032. direction: Vector3;
  12033. private _worldMatrix;
  12034. /**
  12035. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12036. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12037. * The HemisphericLight can't cast shadows.
  12038. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12039. * @param name The friendly name of the light
  12040. * @param direction The direction of the light reflection
  12041. * @param scene The scene the light belongs to
  12042. */
  12043. constructor(name: string, direction: Vector3, scene: Scene);
  12044. protected _buildUniformLayout(): void;
  12045. /**
  12046. * Returns the string "HemisphericLight".
  12047. * @return The class name
  12048. */
  12049. getClassName(): string;
  12050. /**
  12051. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12052. * Returns the updated direction.
  12053. * @param target The target the direction should point to
  12054. * @return The computed direction
  12055. */
  12056. setDirectionToTarget(target: Vector3): Vector3;
  12057. /**
  12058. * Returns the shadow generator associated to the light.
  12059. * @returns Always null for hemispheric lights because it does not support shadows.
  12060. */
  12061. getShadowGenerator(): Nullable<ShadowGenerator>;
  12062. /**
  12063. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12064. * @param effect The effect to update
  12065. * @param lightIndex The index of the light in the effect to update
  12066. * @returns The hemispheric light
  12067. */
  12068. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12069. /**
  12070. * @hidden internal use only.
  12071. */
  12072. _getWorldMatrix(): Matrix;
  12073. /**
  12074. * Returns the integer 3.
  12075. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12076. */
  12077. getTypeID(): number;
  12078. /**
  12079. * Prepares the list of defines specific to the light type.
  12080. * @param defines the list of defines
  12081. * @param lightIndex defines the index of the light for the effect
  12082. */
  12083. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12084. }
  12085. }
  12086. declare module BABYLON {
  12087. /**
  12088. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12089. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12090. * 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.
  12091. */
  12092. abstract class Light extends Node {
  12093. /**
  12094. * Falloff Default: light is falling off following the material specification:
  12095. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12096. */
  12097. static readonly FALLOFF_DEFAULT: number;
  12098. /**
  12099. * Falloff Physical: light is falling off following the inverse squared distance law.
  12100. */
  12101. static readonly FALLOFF_PHYSICAL: number;
  12102. /**
  12103. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12104. * to enhance interoperability with other engines.
  12105. */
  12106. static readonly FALLOFF_GLTF: number;
  12107. /**
  12108. * Falloff Standard: light is falling off like in the standard material
  12109. * to enhance interoperability with other materials.
  12110. */
  12111. static readonly FALLOFF_STANDARD: number;
  12112. /**
  12113. * If every light affecting the material is in this lightmapMode,
  12114. * material.lightmapTexture adds or multiplies
  12115. * (depends on material.useLightmapAsShadowmap)
  12116. * after every other light calculations.
  12117. */
  12118. static readonly LIGHTMAP_DEFAULT: number;
  12119. /**
  12120. * material.lightmapTexture as only diffuse lighting from this light
  12121. * adds only specular lighting from this light
  12122. * adds dynamic shadows
  12123. */
  12124. static readonly LIGHTMAP_SPECULAR: number;
  12125. /**
  12126. * material.lightmapTexture as only lighting
  12127. * no light calculation from this light
  12128. * only adds dynamic shadows from this light
  12129. */
  12130. static readonly LIGHTMAP_SHADOWSONLY: number;
  12131. /**
  12132. * Each light type uses the default quantity according to its type:
  12133. * point/spot lights use luminous intensity
  12134. * directional lights use illuminance
  12135. */
  12136. static readonly INTENSITYMODE_AUTOMATIC: number;
  12137. /**
  12138. * lumen (lm)
  12139. */
  12140. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12141. /**
  12142. * candela (lm/sr)
  12143. */
  12144. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12145. /**
  12146. * lux (lm/m^2)
  12147. */
  12148. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12149. /**
  12150. * nit (cd/m^2)
  12151. */
  12152. static readonly INTENSITYMODE_LUMINANCE: number;
  12153. /**
  12154. * Light type const id of the point light.
  12155. */
  12156. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12157. /**
  12158. * Light type const id of the directional light.
  12159. */
  12160. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12161. /**
  12162. * Light type const id of the spot light.
  12163. */
  12164. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12165. /**
  12166. * Light type const id of the hemispheric light.
  12167. */
  12168. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12169. /**
  12170. * Diffuse gives the basic color to an object.
  12171. */
  12172. diffuse: Color3;
  12173. /**
  12174. * Specular produces a highlight color on an object.
  12175. * Note: This is note affecting PBR materials.
  12176. */
  12177. specular: Color3;
  12178. /**
  12179. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12180. * falling off base on range or angle.
  12181. * This can be set to any values in Light.FALLOFF_x.
  12182. *
  12183. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12184. * other types of materials.
  12185. */
  12186. falloffType: number;
  12187. /**
  12188. * Strength of the light.
  12189. * Note: By default it is define in the framework own unit.
  12190. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12191. */
  12192. intensity: number;
  12193. private _range;
  12194. protected _inverseSquaredRange: number;
  12195. /**
  12196. * Defines how far from the source the light is impacting in scene units.
  12197. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12198. */
  12199. /**
  12200. * Defines how far from the source the light is impacting in scene units.
  12201. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12202. */
  12203. range: number;
  12204. /**
  12205. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12206. * of light.
  12207. */
  12208. private _photometricScale;
  12209. private _intensityMode;
  12210. /**
  12211. * Gets the photometric scale used to interpret the intensity.
  12212. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12213. */
  12214. /**
  12215. * Sets the photometric scale used to interpret the intensity.
  12216. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12217. */
  12218. intensityMode: number;
  12219. private _radius;
  12220. /**
  12221. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12222. */
  12223. /**
  12224. * sets the light radius used by PBR Materials to simulate soft area lights.
  12225. */
  12226. radius: number;
  12227. private _renderPriority;
  12228. /**
  12229. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12230. * exceeding the number allowed of the materials.
  12231. */
  12232. renderPriority: number;
  12233. private _shadowEnabled;
  12234. /**
  12235. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12236. * the current shadow generator.
  12237. */
  12238. /**
  12239. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12240. * the current shadow generator.
  12241. */
  12242. shadowEnabled: boolean;
  12243. private _includedOnlyMeshes;
  12244. /**
  12245. * Gets the only meshes impacted by this light.
  12246. */
  12247. /**
  12248. * Sets the only meshes impacted by this light.
  12249. */
  12250. includedOnlyMeshes: AbstractMesh[];
  12251. private _excludedMeshes;
  12252. /**
  12253. * Gets the meshes not impacted by this light.
  12254. */
  12255. /**
  12256. * Sets the meshes not impacted by this light.
  12257. */
  12258. excludedMeshes: AbstractMesh[];
  12259. private _excludeWithLayerMask;
  12260. /**
  12261. * Gets the layer id use to find what meshes are not impacted by the light.
  12262. * Inactive if 0
  12263. */
  12264. /**
  12265. * Sets the layer id use to find what meshes are not impacted by the light.
  12266. * Inactive if 0
  12267. */
  12268. excludeWithLayerMask: number;
  12269. private _includeOnlyWithLayerMask;
  12270. /**
  12271. * Gets the layer id use to find what meshes are impacted by the light.
  12272. * Inactive if 0
  12273. */
  12274. /**
  12275. * Sets the layer id use to find what meshes are impacted by the light.
  12276. * Inactive if 0
  12277. */
  12278. includeOnlyWithLayerMask: number;
  12279. private _lightmapMode;
  12280. /**
  12281. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12282. */
  12283. /**
  12284. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12285. */
  12286. lightmapMode: number;
  12287. private _parentedWorldMatrix;
  12288. /**
  12289. * Shadow generator associted to the light.
  12290. * @hidden Internal use only.
  12291. */
  12292. _shadowGenerator: Nullable<IShadowGenerator>;
  12293. /**
  12294. * @hidden Internal use only.
  12295. */
  12296. _excludedMeshesIds: string[];
  12297. /**
  12298. * @hidden Internal use only.
  12299. */
  12300. _includedOnlyMeshesIds: string[];
  12301. /**
  12302. * The current light unifom buffer.
  12303. * @hidden Internal use only.
  12304. */
  12305. _uniformBuffer: UniformBuffer;
  12306. /**
  12307. * Creates a Light object in the scene.
  12308. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12309. * @param name The firendly name of the light
  12310. * @param scene The scene the light belongs too
  12311. */
  12312. constructor(name: string, scene: Scene);
  12313. protected abstract _buildUniformLayout(): void;
  12314. /**
  12315. * Sets the passed Effect "effect" with the Light information.
  12316. * @param effect The effect to update
  12317. * @param lightIndex The index of the light in the effect to update
  12318. * @returns The light
  12319. */
  12320. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12321. /**
  12322. * @hidden internal use only.
  12323. */
  12324. abstract _getWorldMatrix(): Matrix;
  12325. /**
  12326. * Returns the string "Light".
  12327. * @returns the class name
  12328. */
  12329. getClassName(): string;
  12330. /**
  12331. * Converts the light information to a readable string for debug purpose.
  12332. * @param fullDetails Supports for multiple levels of logging within scene loading
  12333. * @returns the human readable light info
  12334. */
  12335. toString(fullDetails?: boolean): string;
  12336. /**
  12337. * Set the enabled state of this node.
  12338. * @param value - the new enabled state
  12339. */
  12340. setEnabled(value: boolean): void;
  12341. /**
  12342. * Returns the Light associated shadow generator if any.
  12343. * @return the associated shadow generator.
  12344. */
  12345. getShadowGenerator(): Nullable<IShadowGenerator>;
  12346. /**
  12347. * Returns a Vector3, the absolute light position in the World.
  12348. * @returns the world space position of the light
  12349. */
  12350. getAbsolutePosition(): Vector3;
  12351. /**
  12352. * Specifies if the light will affect the passed mesh.
  12353. * @param mesh The mesh to test against the light
  12354. * @return true the mesh is affected otherwise, false.
  12355. */
  12356. canAffectMesh(mesh: AbstractMesh): boolean;
  12357. /**
  12358. * Computes and Returns the light World matrix.
  12359. * @returns the world matrix
  12360. */
  12361. getWorldMatrix(): Matrix;
  12362. /**
  12363. * Sort function to order lights for rendering.
  12364. * @param a First Light object to compare to second.
  12365. * @param b Second Light object to compare first.
  12366. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12367. */
  12368. static CompareLightsPriority(a: Light, b: Light): number;
  12369. /**
  12370. * Releases resources associated with this node.
  12371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12373. */
  12374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12375. /**
  12376. * Returns the light type ID (integer).
  12377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12378. */
  12379. getTypeID(): number;
  12380. /**
  12381. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12382. * @returns the scaled intensity in intensity mode unit
  12383. */
  12384. getScaledIntensity(): number;
  12385. /**
  12386. * Returns a new Light object, named "name", from the current one.
  12387. * @param name The name of the cloned light
  12388. * @returns the new created light
  12389. */
  12390. clone(name: string): Nullable<Light>;
  12391. /**
  12392. * Serializes the current light into a Serialization object.
  12393. * @returns the serialized object.
  12394. */
  12395. serialize(): any;
  12396. /**
  12397. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12398. * This new light is named "name" and added to the passed scene.
  12399. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12400. * @param name The friendly name of the light
  12401. * @param scene The scene the new light will belong to
  12402. * @returns the constructor function
  12403. */
  12404. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12405. /**
  12406. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12407. * @param parsedLight The JSON representation of the light
  12408. * @param scene The scene to create the parsed light in
  12409. * @returns the created light after parsing
  12410. */
  12411. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12412. private _hookArrayForExcluded;
  12413. private _hookArrayForIncludedOnly;
  12414. private _resyncMeshes;
  12415. /**
  12416. * Forces the meshes to update their light related information in their rendering used effects
  12417. * @hidden Internal Use Only
  12418. */
  12419. _markMeshesAsLightDirty(): void;
  12420. /**
  12421. * Recomputes the cached photometric scale if needed.
  12422. */
  12423. private _computePhotometricScale;
  12424. /**
  12425. * Returns the Photometric Scale according to the light type and intensity mode.
  12426. */
  12427. private _getPhotometricScale;
  12428. /**
  12429. * Reorder the light in the scene according to their defined priority.
  12430. * @hidden Internal Use Only
  12431. */
  12432. _reorderLightsInScene(): void;
  12433. /**
  12434. * Prepares the list of defines specific to the light type.
  12435. * @param defines the list of defines
  12436. * @param lightIndex defines the index of the light for the effect
  12437. */
  12438. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12439. }
  12440. }
  12441. declare module BABYLON {
  12442. /**
  12443. * A point light is a light defined by an unique point in world space.
  12444. * The light is emitted in every direction from this point.
  12445. * A good example of a point light is a standard light bulb.
  12446. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12447. */
  12448. class PointLight extends ShadowLight {
  12449. private _shadowAngle;
  12450. /**
  12451. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12452. * This specifies what angle the shadow will use to be created.
  12453. *
  12454. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12455. */
  12456. /**
  12457. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12458. * This specifies what angle the shadow will use to be created.
  12459. *
  12460. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12461. */
  12462. shadowAngle: number;
  12463. /**
  12464. * Gets the direction if it has been set.
  12465. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12466. */
  12467. /**
  12468. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12469. */
  12470. direction: Vector3;
  12471. /**
  12472. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12473. * A PointLight emits the light in every direction.
  12474. * It can cast shadows.
  12475. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12476. * ```javascript
  12477. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12478. * ```
  12479. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12480. * @param name The light friendly name
  12481. * @param position The position of the point light in the scene
  12482. * @param scene The scene the lights belongs to
  12483. */
  12484. constructor(name: string, position: Vector3, scene: Scene);
  12485. /**
  12486. * Returns the string "PointLight"
  12487. * @returns the class name
  12488. */
  12489. getClassName(): string;
  12490. /**
  12491. * Returns the integer 0.
  12492. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12493. */
  12494. getTypeID(): number;
  12495. /**
  12496. * Specifies wether or not the shadowmap should be a cube texture.
  12497. * @returns true if the shadowmap needs to be a cube texture.
  12498. */
  12499. needCube(): boolean;
  12500. /**
  12501. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12502. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12503. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12504. */
  12505. getShadowDirection(faceIndex?: number): Vector3;
  12506. /**
  12507. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12508. * - fov = PI / 2
  12509. * - aspect ratio : 1.0
  12510. * - z-near and far equal to the active camera minZ and maxZ.
  12511. * Returns the PointLight.
  12512. */
  12513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12514. protected _buildUniformLayout(): void;
  12515. /**
  12516. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12517. * @param effect The effect to update
  12518. * @param lightIndex The index of the light in the effect to update
  12519. * @returns The point light
  12520. */
  12521. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12522. /**
  12523. * Prepares the list of defines specific to the light type.
  12524. * @param defines the list of defines
  12525. * @param lightIndex defines the index of the light for the effect
  12526. */
  12527. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12528. }
  12529. }
  12530. declare module BABYLON {
  12531. /**
  12532. * Interface describing all the common properties and methods a shadow light needs to implement.
  12533. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12534. * as well as binding the different shadow properties to the effects.
  12535. */
  12536. interface IShadowLight extends Light {
  12537. /**
  12538. * The light id in the scene (used in scene.findLighById for instance)
  12539. */
  12540. id: string;
  12541. /**
  12542. * The position the shdow will be casted from.
  12543. */
  12544. position: Vector3;
  12545. /**
  12546. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12547. */
  12548. direction: Vector3;
  12549. /**
  12550. * The transformed position. Position of the light in world space taking parenting in account.
  12551. */
  12552. transformedPosition: Vector3;
  12553. /**
  12554. * The transformed direction. Direction of the light in world space taking parenting in account.
  12555. */
  12556. transformedDirection: Vector3;
  12557. /**
  12558. * The friendly name of the light in the scene.
  12559. */
  12560. name: string;
  12561. /**
  12562. * Defines the shadow projection clipping minimum z value.
  12563. */
  12564. shadowMinZ: number;
  12565. /**
  12566. * Defines the shadow projection clipping maximum z value.
  12567. */
  12568. shadowMaxZ: number;
  12569. /**
  12570. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12571. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12572. */
  12573. computeTransformedInformation(): boolean;
  12574. /**
  12575. * Gets the scene the light belongs to.
  12576. * @returns The scene
  12577. */
  12578. getScene(): Scene;
  12579. /**
  12580. * Callback defining a custom Projection Matrix Builder.
  12581. * This can be used to override the default projection matrix computation.
  12582. */
  12583. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12584. /**
  12585. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12586. * @param matrix The materix to updated with the projection information
  12587. * @param viewMatrix The transform matrix of the light
  12588. * @param renderList The list of mesh to render in the map
  12589. * @returns The current light
  12590. */
  12591. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12592. /**
  12593. * Gets the current depth scale used in ESM.
  12594. * @returns The scale
  12595. */
  12596. getDepthScale(): number;
  12597. /**
  12598. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12599. * @returns true if a cube texture needs to be use
  12600. */
  12601. needCube(): boolean;
  12602. /**
  12603. * Detects if the projection matrix requires to be recomputed this frame.
  12604. * @returns true if it requires to be recomputed otherwise, false.
  12605. */
  12606. needProjectionMatrixCompute(): boolean;
  12607. /**
  12608. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12609. */
  12610. forceProjectionMatrixCompute(): void;
  12611. /**
  12612. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12613. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12614. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12615. */
  12616. getShadowDirection(faceIndex?: number): Vector3;
  12617. /**
  12618. * Gets the minZ used for shadow according to both the scene and the light.
  12619. * @param activeCamera The camera we are returning the min for
  12620. * @returns the depth min z
  12621. */
  12622. getDepthMinZ(activeCamera: Camera): number;
  12623. /**
  12624. * Gets the maxZ used for shadow according to both the scene and the light.
  12625. * @param activeCamera The camera we are returning the max for
  12626. * @returns the depth max z
  12627. */
  12628. getDepthMaxZ(activeCamera: Camera): number;
  12629. }
  12630. /**
  12631. * Base implementation IShadowLight
  12632. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12633. */
  12634. abstract class ShadowLight extends Light implements IShadowLight {
  12635. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12636. protected _position: Vector3;
  12637. protected _setPosition(value: Vector3): void;
  12638. /**
  12639. * Sets the position the shadow will be casted from. Also use as the light position for both
  12640. * point and spot lights.
  12641. */
  12642. /**
  12643. * Sets the position the shadow will be casted from. Also use as the light position for both
  12644. * point and spot lights.
  12645. */
  12646. position: Vector3;
  12647. protected _direction: Vector3;
  12648. protected _setDirection(value: Vector3): void;
  12649. /**
  12650. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12651. * Also use as the light direction on spot and directional lights.
  12652. */
  12653. /**
  12654. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12655. * Also use as the light direction on spot and directional lights.
  12656. */
  12657. direction: Vector3;
  12658. private _shadowMinZ;
  12659. /**
  12660. * Gets the shadow projection clipping minimum z value.
  12661. */
  12662. /**
  12663. * Sets the shadow projection clipping minimum z value.
  12664. */
  12665. shadowMinZ: number;
  12666. private _shadowMaxZ;
  12667. /**
  12668. * Sets the shadow projection clipping maximum z value.
  12669. */
  12670. /**
  12671. * Gets the shadow projection clipping maximum z value.
  12672. */
  12673. shadowMaxZ: number;
  12674. /**
  12675. * Callback defining a custom Projection Matrix Builder.
  12676. * This can be used to override the default projection matrix computation.
  12677. */
  12678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12679. /**
  12680. * The transformed position. Position of the light in world space taking parenting in account.
  12681. */
  12682. transformedPosition: Vector3;
  12683. /**
  12684. * The transformed direction. Direction of the light in world space taking parenting in account.
  12685. */
  12686. transformedDirection: Vector3;
  12687. private _worldMatrix;
  12688. private _needProjectionMatrixCompute;
  12689. /**
  12690. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12691. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12692. */
  12693. computeTransformedInformation(): boolean;
  12694. /**
  12695. * Return the depth scale used for the shadow map.
  12696. * @returns the depth scale.
  12697. */
  12698. getDepthScale(): number;
  12699. /**
  12700. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12701. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12702. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12703. */
  12704. getShadowDirection(faceIndex?: number): Vector3;
  12705. /**
  12706. * Returns the ShadowLight absolute position in the World.
  12707. * @returns the position vector in world space
  12708. */
  12709. getAbsolutePosition(): Vector3;
  12710. /**
  12711. * Sets the ShadowLight direction toward the passed target.
  12712. * @param target The point tot target in local space
  12713. * @returns the updated ShadowLight direction
  12714. */
  12715. setDirectionToTarget(target: Vector3): Vector3;
  12716. /**
  12717. * Returns the light rotation in euler definition.
  12718. * @returns the x y z rotation in local space.
  12719. */
  12720. getRotation(): Vector3;
  12721. /**
  12722. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12723. * @returns true if a cube texture needs to be use
  12724. */
  12725. needCube(): boolean;
  12726. /**
  12727. * Detects if the projection matrix requires to be recomputed this frame.
  12728. * @returns true if it requires to be recomputed otherwise, false.
  12729. */
  12730. needProjectionMatrixCompute(): boolean;
  12731. /**
  12732. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12733. */
  12734. forceProjectionMatrixCompute(): void;
  12735. /**
  12736. * Get the world matrix of the sahdow lights.
  12737. * @hidden Internal Use Only
  12738. */
  12739. _getWorldMatrix(): Matrix;
  12740. /**
  12741. * Gets the minZ used for shadow according to both the scene and the light.
  12742. * @param activeCamera The camera we are returning the min for
  12743. * @returns the depth min z
  12744. */
  12745. getDepthMinZ(activeCamera: Camera): number;
  12746. /**
  12747. * Gets the maxZ used for shadow according to both the scene and the light.
  12748. * @param activeCamera The camera we are returning the max for
  12749. * @returns the depth max z
  12750. */
  12751. getDepthMaxZ(activeCamera: Camera): number;
  12752. /**
  12753. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12754. * @param matrix The materix to updated with the projection information
  12755. * @param viewMatrix The transform matrix of the light
  12756. * @param renderList The list of mesh to render in the map
  12757. * @returns The current light
  12758. */
  12759. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12760. }
  12761. }
  12762. declare module BABYLON {
  12763. /**
  12764. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12765. * These values define a cone of light starting from the position, emitting toward the direction.
  12766. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12767. * and the exponent defines the speed of the decay of the light with distance (reach).
  12768. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12769. */
  12770. class SpotLight extends ShadowLight {
  12771. private _angle;
  12772. private _innerAngle;
  12773. private _cosHalfAngle;
  12774. private _lightAngleScale;
  12775. private _lightAngleOffset;
  12776. /**
  12777. * Gets the cone angle of the spot light in Radians.
  12778. */
  12779. /**
  12780. * Sets the cone angle of the spot light in Radians.
  12781. */
  12782. angle: number;
  12783. /**
  12784. * Only used in gltf falloff mode, this defines the angle where
  12785. * the directional falloff will start before cutting at angle which could be seen
  12786. * as outer angle.
  12787. */
  12788. /**
  12789. * Only used in gltf falloff mode, this defines the angle where
  12790. * the directional falloff will start before cutting at angle which could be seen
  12791. * as outer angle.
  12792. */
  12793. innerAngle: number;
  12794. private _shadowAngleScale;
  12795. /**
  12796. * Allows scaling the angle of the light for shadow generation only.
  12797. */
  12798. /**
  12799. * Allows scaling the angle of the light for shadow generation only.
  12800. */
  12801. shadowAngleScale: number;
  12802. /**
  12803. * The light decay speed with the distance from the emission spot.
  12804. */
  12805. exponent: number;
  12806. private _projectionTextureMatrix;
  12807. /**
  12808. * Allows reading the projecton texture
  12809. */
  12810. readonly projectionTextureMatrix: Matrix;
  12811. protected _projectionTextureLightNear: number;
  12812. /**
  12813. * Gets the near clip of the Spotlight for texture projection.
  12814. */
  12815. /**
  12816. * Sets the near clip of the Spotlight for texture projection.
  12817. */
  12818. projectionTextureLightNear: number;
  12819. protected _projectionTextureLightFar: number;
  12820. /**
  12821. * Gets the far clip of the Spotlight for texture projection.
  12822. */
  12823. /**
  12824. * Sets the far clip of the Spotlight for texture projection.
  12825. */
  12826. projectionTextureLightFar: number;
  12827. protected _projectionTextureUpDirection: Vector3;
  12828. /**
  12829. * Gets the Up vector of the Spotlight for texture projection.
  12830. */
  12831. /**
  12832. * Sets the Up vector of the Spotlight for texture projection.
  12833. */
  12834. projectionTextureUpDirection: Vector3;
  12835. private _projectionTexture;
  12836. /**
  12837. * Gets the projection texture of the light.
  12838. */
  12839. /**
  12840. * Sets the projection texture of the light.
  12841. */
  12842. projectionTexture: Nullable<BaseTexture>;
  12843. private _projectionTextureViewLightDirty;
  12844. private _projectionTextureProjectionLightDirty;
  12845. private _projectionTextureDirty;
  12846. private _projectionTextureViewTargetVector;
  12847. private _projectionTextureViewLightMatrix;
  12848. private _projectionTextureProjectionLightMatrix;
  12849. private _projectionTextureScalingMatrix;
  12850. /**
  12851. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12852. * It can cast shadows.
  12853. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12854. * @param name The light friendly name
  12855. * @param position The position of the spot light in the scene
  12856. * @param direction The direction of the light in the scene
  12857. * @param angle The cone angle of the light in Radians
  12858. * @param exponent The light decay speed with the distance from the emission spot
  12859. * @param scene The scene the lights belongs to
  12860. */
  12861. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12862. /**
  12863. * Returns the string "SpotLight".
  12864. * @returns the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Returns the integer 2.
  12869. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12870. */
  12871. getTypeID(): number;
  12872. /**
  12873. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12874. */
  12875. protected _setDirection(value: Vector3): void;
  12876. /**
  12877. * Overrides the position setter to recompute the projection texture view light Matrix.
  12878. */
  12879. protected _setPosition(value: Vector3): void;
  12880. /**
  12881. * 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.
  12882. * Returns the SpotLight.
  12883. */
  12884. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12885. protected _computeProjectionTextureViewLightMatrix(): void;
  12886. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12887. /**
  12888. * Main function for light texture projection matrix computing.
  12889. */
  12890. protected _computeProjectionTextureMatrix(): void;
  12891. protected _buildUniformLayout(): void;
  12892. private _computeAngleValues;
  12893. /**
  12894. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12895. * @param effect The effect to update
  12896. * @param lightIndex The index of the light in the effect to update
  12897. * @returns The spot light
  12898. */
  12899. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12900. /**
  12901. * Disposes the light and the associated resources.
  12902. */
  12903. dispose(): void;
  12904. /**
  12905. * Prepares the list of defines specific to the light type.
  12906. * @param defines the list of defines
  12907. * @param lightIndex defines the index of the light for the effect
  12908. */
  12909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12910. }
  12911. }
  12912. declare module BABYLON {
  12913. interface ILoadingScreen {
  12914. displayLoadingUI: () => void;
  12915. hideLoadingUI: () => void;
  12916. loadingUIBackgroundColor: string;
  12917. loadingUIText: string;
  12918. }
  12919. class DefaultLoadingScreen implements ILoadingScreen {
  12920. private _renderingCanvas;
  12921. private _loadingText;
  12922. private _loadingDivBackgroundColor;
  12923. private _loadingDiv;
  12924. private _loadingTextDiv;
  12925. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12926. displayLoadingUI(): void;
  12927. hideLoadingUI(): void;
  12928. loadingUIText: string;
  12929. loadingUIBackgroundColor: string;
  12930. private _resizeLoadingUI;
  12931. }
  12932. }
  12933. declare module BABYLON {
  12934. class SceneLoaderProgressEvent {
  12935. readonly lengthComputable: boolean;
  12936. readonly loaded: number;
  12937. readonly total: number;
  12938. constructor(lengthComputable: boolean, loaded: number, total: number);
  12939. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12940. }
  12941. interface ISceneLoaderPluginExtensions {
  12942. [extension: string]: {
  12943. isBinary: boolean;
  12944. };
  12945. }
  12946. interface ISceneLoaderPluginFactory {
  12947. name: string;
  12948. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12949. canDirectLoad?: (data: string) => boolean;
  12950. }
  12951. interface ISceneLoaderPlugin {
  12952. /**
  12953. * The friendly name of this plugin.
  12954. */
  12955. name: string;
  12956. /**
  12957. * The file extensions supported by this plugin.
  12958. */
  12959. extensions: string | ISceneLoaderPluginExtensions;
  12960. /**
  12961. * Import meshes into a scene.
  12962. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12963. * @param scene The scene to import into
  12964. * @param data The data to import
  12965. * @param rootUrl The root url for scene and resources
  12966. * @param meshes The meshes array to import into
  12967. * @param particleSystems The particle systems array to import into
  12968. * @param skeletons The skeletons array to import into
  12969. * @param onError The callback when import fails
  12970. * @returns True if successful or false otherwise
  12971. */
  12972. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12973. /**
  12974. * Load into a scene.
  12975. * @param scene The scene to load into
  12976. * @param data The data to import
  12977. * @param rootUrl The root url for scene and resources
  12978. * @param onError The callback when import fails
  12979. * @returns true if successful or false otherwise
  12980. */
  12981. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12982. /**
  12983. * The callback that returns true if the data can be directly loaded.
  12984. */
  12985. canDirectLoad?: (data: string) => boolean;
  12986. /**
  12987. * The callback that allows custom handling of the root url based on the response url.
  12988. */
  12989. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12990. /**
  12991. * Load into an asset container.
  12992. * @param scene The scene to load into
  12993. * @param data The data to import
  12994. * @param rootUrl The root url for scene and resources
  12995. * @param onError The callback when import fails
  12996. * @returns The loaded asset container
  12997. */
  12998. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12999. }
  13000. interface ISceneLoaderPluginAsync {
  13001. /**
  13002. * The friendly name of this plugin.
  13003. */
  13004. name: string;
  13005. /**
  13006. * The file extensions supported by this plugin.
  13007. */
  13008. extensions: string | ISceneLoaderPluginExtensions;
  13009. /**
  13010. * Import meshes into a scene.
  13011. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13012. * @param scene The scene to import into
  13013. * @param data The data to import
  13014. * @param rootUrl The root url for scene and resources
  13015. * @param onProgress The callback when the load progresses
  13016. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13017. */
  13018. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  13019. meshes: AbstractMesh[];
  13020. particleSystems: IParticleSystem[];
  13021. skeletons: Skeleton[];
  13022. animationGroups: AnimationGroup[];
  13023. }>;
  13024. /**
  13025. * Load into a scene.
  13026. * @param scene The scene to load into
  13027. * @param data The data to import
  13028. * @param rootUrl The root url for scene and resources
  13029. * @param onProgress The callback when the load progresses
  13030. * @returns Nothing
  13031. */
  13032. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  13033. /**
  13034. * The callback that returns true if the data can be directly loaded.
  13035. */
  13036. canDirectLoad?: (data: string) => boolean;
  13037. /**
  13038. * The callback that allows custom handling of the root url based on the response url.
  13039. */
  13040. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13041. /**
  13042. * Load into an asset container.
  13043. * @param scene The scene to load into
  13044. * @param data The data to import
  13045. * @param rootUrl The root url for scene and resources
  13046. * @param onProgress The callback when the load progresses
  13047. * @returns The loaded asset container
  13048. */
  13049. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  13050. }
  13051. class SceneLoader {
  13052. private static _ForceFullSceneLoadingForIncremental;
  13053. private static _ShowLoadingScreen;
  13054. private static _CleanBoneMatrixWeights;
  13055. static readonly NO_LOGGING: number;
  13056. static readonly MINIMAL_LOGGING: number;
  13057. static readonly SUMMARY_LOGGING: number;
  13058. static readonly DETAILED_LOGGING: number;
  13059. private static _loggingLevel;
  13060. static ForceFullSceneLoadingForIncremental: boolean;
  13061. static ShowLoadingScreen: boolean;
  13062. static loggingLevel: number;
  13063. static CleanBoneMatrixWeights: boolean;
  13064. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13065. private static _registeredPlugins;
  13066. private static _getDefaultPlugin;
  13067. private static _getPluginForExtension;
  13068. private static _getPluginForDirectLoad;
  13069. private static _getPluginForFilename;
  13070. private static _getDirectLoad;
  13071. private static _loadData;
  13072. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13073. static IsPluginForExtensionAvailable(extension: string): boolean;
  13074. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  13075. /**
  13076. * Import meshes into a scene
  13077. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13078. * @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)
  13079. * @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)
  13080. * @param scene the instance of BABYLON.Scene to append to
  13081. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13082. * @param onProgress a callback with a progress event for each file being loaded
  13083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13084. * @param pluginExtension the extension used to determine the plugin
  13085. * @returns The loaded plugin
  13086. */
  13087. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], 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>;
  13088. /**
  13089. * Import meshes into a scene
  13090. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13091. * @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)
  13092. * @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)
  13093. * @param scene the instance of BABYLON.Scene to append to
  13094. * @param onProgress a callback with a progress event for each file being loaded
  13095. * @param pluginExtension the extension used to determine the plugin
  13096. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13097. */
  13098. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13099. meshes: AbstractMesh[];
  13100. particleSystems: IParticleSystem[];
  13101. skeletons: Skeleton[];
  13102. animationGroups: AnimationGroup[];
  13103. }>;
  13104. /**
  13105. * Load a scene
  13106. * @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)
  13107. * @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)
  13108. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13109. * @param onSuccess a callback with the scene when import succeeds
  13110. * @param onProgress a callback with a progress event for each file being loaded
  13111. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13112. * @param pluginExtension the extension used to determine the plugin
  13113. * @returns The loaded plugin
  13114. */
  13115. 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>;
  13116. /**
  13117. * Load a scene
  13118. * @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)
  13119. * @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)
  13120. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13121. * @param onProgress a callback with a progress event for each file being loaded
  13122. * @param pluginExtension the extension used to determine the plugin
  13123. * @returns The loaded scene
  13124. */
  13125. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13126. /**
  13127. * Append a scene
  13128. * @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)
  13129. * @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)
  13130. * @param scene is the instance of BABYLON.Scene to append to
  13131. * @param onSuccess a callback with the scene when import succeeds
  13132. * @param onProgress a callback with a progress event for each file being loaded
  13133. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13134. * @param pluginExtension the extension used to determine the plugin
  13135. * @returns The loaded plugin
  13136. */
  13137. 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>;
  13138. /**
  13139. * Append a scene
  13140. * @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)
  13141. * @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)
  13142. * @param scene is the instance of BABYLON.Scene to append to
  13143. * @param onProgress a callback with a progress event for each file being loaded
  13144. * @param pluginExtension the extension used to determine the plugin
  13145. * @returns The given scene
  13146. */
  13147. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13148. /**
  13149. * Load a scene into an asset container
  13150. * @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)
  13151. * @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)
  13152. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13153. * @param onSuccess a callback with the scene when import succeeds
  13154. * @param onProgress a callback with a progress event for each file being loaded
  13155. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13156. * @param pluginExtension the extension used to determine the plugin
  13157. * @returns The loaded plugin
  13158. */
  13159. 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>;
  13160. /**
  13161. * Load a scene into an asset container
  13162. * @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)
  13163. * @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)
  13164. * @param scene is the instance of BABYLON.Scene to append to
  13165. * @param onProgress a callback with a progress event for each file being loaded
  13166. * @param pluginExtension the extension used to determine the plugin
  13167. * @returns The loaded asset container
  13168. */
  13169. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13170. }
  13171. }
  13172. declare module BABYLON {
  13173. /**
  13174. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13175. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13176. * 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;
  13177. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13178. */
  13179. class ColorCurves {
  13180. private _dirty;
  13181. private _tempColor;
  13182. private _globalCurve;
  13183. private _highlightsCurve;
  13184. private _midtonesCurve;
  13185. private _shadowsCurve;
  13186. private _positiveCurve;
  13187. private _negativeCurve;
  13188. private _globalHue;
  13189. private _globalDensity;
  13190. private _globalSaturation;
  13191. private _globalExposure;
  13192. /**
  13193. * Gets the global Hue value.
  13194. * 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).
  13195. */
  13196. /**
  13197. * Sets the global Hue value.
  13198. * 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).
  13199. */
  13200. globalHue: number;
  13201. /**
  13202. * Gets the global Density value.
  13203. * 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.
  13204. * Values less than zero provide a filter of opposite hue.
  13205. */
  13206. /**
  13207. * Sets the global Density value.
  13208. * 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.
  13209. * Values less than zero provide a filter of opposite hue.
  13210. */
  13211. globalDensity: number;
  13212. /**
  13213. * Gets the global Saturation value.
  13214. * 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.
  13215. */
  13216. /**
  13217. * Sets the global Saturation value.
  13218. * 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.
  13219. */
  13220. globalSaturation: number;
  13221. /**
  13222. * Gets the global Exposure value.
  13223. * 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.
  13224. */
  13225. /**
  13226. * Sets the global Exposure value.
  13227. * 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.
  13228. */
  13229. globalExposure: number;
  13230. private _highlightsHue;
  13231. private _highlightsDensity;
  13232. private _highlightsSaturation;
  13233. private _highlightsExposure;
  13234. /**
  13235. * Gets the highlights Hue value.
  13236. * 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).
  13237. */
  13238. /**
  13239. * Sets the highlights Hue value.
  13240. * 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).
  13241. */
  13242. highlightsHue: number;
  13243. /**
  13244. * Gets the highlights Density value.
  13245. * 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.
  13246. * Values less than zero provide a filter of opposite hue.
  13247. */
  13248. /**
  13249. * Sets the highlights Density value.
  13250. * 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.
  13251. * Values less than zero provide a filter of opposite hue.
  13252. */
  13253. highlightsDensity: number;
  13254. /**
  13255. * Gets the highlights Saturation value.
  13256. * 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.
  13257. */
  13258. /**
  13259. * Sets the highlights Saturation value.
  13260. * 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.
  13261. */
  13262. highlightsSaturation: number;
  13263. /**
  13264. * Gets the highlights Exposure value.
  13265. * 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.
  13266. */
  13267. /**
  13268. * Sets the highlights Exposure value.
  13269. * 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.
  13270. */
  13271. highlightsExposure: number;
  13272. private _midtonesHue;
  13273. private _midtonesDensity;
  13274. private _midtonesSaturation;
  13275. private _midtonesExposure;
  13276. /**
  13277. * Gets the midtones Hue value.
  13278. * 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).
  13279. */
  13280. /**
  13281. * Sets the midtones Hue value.
  13282. * 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).
  13283. */
  13284. midtonesHue: number;
  13285. /**
  13286. * Gets the midtones Density value.
  13287. * 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.
  13288. * Values less than zero provide a filter of opposite hue.
  13289. */
  13290. /**
  13291. * Sets the midtones Density value.
  13292. * 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.
  13293. * Values less than zero provide a filter of opposite hue.
  13294. */
  13295. midtonesDensity: number;
  13296. /**
  13297. * Gets the midtones Saturation value.
  13298. * 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.
  13299. */
  13300. /**
  13301. * Sets the midtones Saturation value.
  13302. * 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.
  13303. */
  13304. midtonesSaturation: number;
  13305. /**
  13306. * Gets the midtones Exposure value.
  13307. * 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.
  13308. */
  13309. /**
  13310. * Sets the midtones Exposure value.
  13311. * 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.
  13312. */
  13313. midtonesExposure: number;
  13314. private _shadowsHue;
  13315. private _shadowsDensity;
  13316. private _shadowsSaturation;
  13317. private _shadowsExposure;
  13318. /**
  13319. * Gets the shadows Hue value.
  13320. * 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).
  13321. */
  13322. /**
  13323. * Sets the shadows Hue value.
  13324. * 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).
  13325. */
  13326. shadowsHue: number;
  13327. /**
  13328. * Gets the shadows Density value.
  13329. * 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.
  13330. * Values less than zero provide a filter of opposite hue.
  13331. */
  13332. /**
  13333. * Sets the shadows Density value.
  13334. * 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.
  13335. * Values less than zero provide a filter of opposite hue.
  13336. */
  13337. shadowsDensity: number;
  13338. /**
  13339. * Gets the shadows Saturation value.
  13340. * 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.
  13341. */
  13342. /**
  13343. * Sets the shadows Saturation value.
  13344. * 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.
  13345. */
  13346. shadowsSaturation: number;
  13347. /**
  13348. * Gets the shadows Exposure value.
  13349. * 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.
  13350. */
  13351. /**
  13352. * Sets the shadows Exposure value.
  13353. * 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.
  13354. */
  13355. shadowsExposure: number;
  13356. getClassName(): string;
  13357. /**
  13358. * Binds the color curves to the shader.
  13359. * @param colorCurves The color curve to bind
  13360. * @param effect The effect to bind to
  13361. */
  13362. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13363. /**
  13364. * Prepare the list of uniforms associated with the ColorCurves effects.
  13365. * @param uniformsList The list of uniforms used in the effect
  13366. */
  13367. static PrepareUniforms(uniformsList: string[]): void;
  13368. /**
  13369. * Returns color grading data based on a hue, density, saturation and exposure value.
  13370. * @param filterHue The hue of the color filter.
  13371. * @param filterDensity The density of the color filter.
  13372. * @param saturation The saturation.
  13373. * @param exposure The exposure.
  13374. * @param result The result data container.
  13375. */
  13376. private getColorGradingDataToRef;
  13377. /**
  13378. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13379. * @param value The input slider value in range [-100,100].
  13380. * @returns Adjusted value.
  13381. */
  13382. private static applyColorGradingSliderNonlinear;
  13383. /**
  13384. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13385. * @param hue The hue (H) input.
  13386. * @param saturation The saturation (S) input.
  13387. * @param brightness The brightness (B) input.
  13388. * @result An RGBA color represented as Vector4.
  13389. */
  13390. private static fromHSBToRef;
  13391. /**
  13392. * Returns a value clamped between min and max
  13393. * @param value The value to clamp
  13394. * @param min The minimum of value
  13395. * @param max The maximum of value
  13396. * @returns The clamped value.
  13397. */
  13398. private static clamp;
  13399. /**
  13400. * Clones the current color curve instance.
  13401. * @return The cloned curves
  13402. */
  13403. clone(): ColorCurves;
  13404. /**
  13405. * Serializes the current color curve instance to a json representation.
  13406. * @return a JSON representation
  13407. */
  13408. serialize(): any;
  13409. /**
  13410. * Parses the color curve from a json representation.
  13411. * @param source the JSON source to parse
  13412. * @return The parsed curves
  13413. */
  13414. static Parse(source: any): ColorCurves;
  13415. }
  13416. }
  13417. declare module BABYLON {
  13418. /**
  13419. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13420. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13421. */
  13422. class EffectFallbacks {
  13423. private _defines;
  13424. private _currentRank;
  13425. private _maxRank;
  13426. private _mesh;
  13427. /**
  13428. * Removes the fallback from the bound mesh.
  13429. */
  13430. unBindMesh(): void;
  13431. /**
  13432. * Adds a fallback on the specified property.
  13433. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13434. * @param define The name of the define in the shader
  13435. */
  13436. addFallback(rank: number, define: string): void;
  13437. /**
  13438. * Sets the mesh to use CPU skinning when needing to fallback.
  13439. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13440. * @param mesh The mesh to use the fallbacks.
  13441. */
  13442. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13443. /**
  13444. * Checks to see if more fallbacks are still availible.
  13445. */
  13446. readonly isMoreFallbacks: boolean;
  13447. /**
  13448. * Removes the defines that shoould be removed when falling back.
  13449. * @param currentDefines defines the current define statements for the shader.
  13450. * @param effect defines the current effect we try to compile
  13451. * @returns The resulting defines with defines of the current rank removed.
  13452. */
  13453. reduce(currentDefines: string, effect: Effect): string;
  13454. }
  13455. /**
  13456. * Options to be used when creating an effect.
  13457. */
  13458. class EffectCreationOptions {
  13459. /**
  13460. * Atrributes that will be used in the shader.
  13461. */
  13462. attributes: string[];
  13463. /**
  13464. * Uniform varible names that will be set in the shader.
  13465. */
  13466. uniformsNames: string[];
  13467. /**
  13468. * Uniform buffer varible names that will be set in the shader.
  13469. */
  13470. uniformBuffersNames: string[];
  13471. /**
  13472. * Sampler texture variable names that will be set in the shader.
  13473. */
  13474. samplers: string[];
  13475. /**
  13476. * Define statements that will be set in the shader.
  13477. */
  13478. defines: any;
  13479. /**
  13480. * Possible fallbacks for this effect to improve performance when needed.
  13481. */
  13482. fallbacks: Nullable<EffectFallbacks>;
  13483. /**
  13484. * Callback that will be called when the shader is compiled.
  13485. */
  13486. onCompiled: Nullable<(effect: Effect) => void>;
  13487. /**
  13488. * Callback that will be called if an error occurs during shader compilation.
  13489. */
  13490. onError: Nullable<(effect: Effect, errors: string) => void>;
  13491. /**
  13492. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13493. */
  13494. indexParameters: any;
  13495. /**
  13496. * Max number of lights that can be used in the shader.
  13497. */
  13498. maxSimultaneousLights: number;
  13499. /**
  13500. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13501. */
  13502. transformFeedbackVaryings: Nullable<string[]>;
  13503. }
  13504. /**
  13505. * Effect containing vertex and fragment shader that can be executed on an object.
  13506. */
  13507. class Effect {
  13508. /**
  13509. * Name of the effect.
  13510. */
  13511. name: any;
  13512. /**
  13513. * String container all the define statements that should be set on the shader.
  13514. */
  13515. defines: string;
  13516. /**
  13517. * Callback that will be called when the shader is compiled.
  13518. */
  13519. onCompiled: Nullable<(effect: Effect) => void>;
  13520. /**
  13521. * Callback that will be called if an error occurs during shader compilation.
  13522. */
  13523. onError: Nullable<(effect: Effect, errors: string) => void>;
  13524. /**
  13525. * Callback that will be called when effect is bound.
  13526. */
  13527. onBind: Nullable<(effect: Effect) => void>;
  13528. /**
  13529. * Unique ID of the effect.
  13530. */
  13531. uniqueId: number;
  13532. /**
  13533. * Observable that will be called when the shader is compiled.
  13534. */
  13535. onCompileObservable: Observable<Effect>;
  13536. /**
  13537. * Observable that will be called if an error occurs during shader compilation.
  13538. */
  13539. onErrorObservable: Observable<Effect>;
  13540. /** @hidden */
  13541. _onBindObservable: Nullable<Observable<Effect>>;
  13542. /**
  13543. * Observable that will be called when effect is bound.
  13544. */
  13545. readonly onBindObservable: Observable<Effect>;
  13546. /** @hidden */
  13547. _bonesComputationForcedToCPU: boolean;
  13548. private static _uniqueIdSeed;
  13549. private _engine;
  13550. private _uniformBuffersNames;
  13551. private _uniformsNames;
  13552. private _samplers;
  13553. private _isReady;
  13554. private _compilationError;
  13555. private _attributesNames;
  13556. private _attributes;
  13557. private _uniforms;
  13558. /**
  13559. * Key for the effect.
  13560. * @hidden
  13561. */
  13562. _key: string;
  13563. private _indexParameters;
  13564. private _fallbacks;
  13565. private _vertexSourceCode;
  13566. private _fragmentSourceCode;
  13567. private _vertexSourceCodeOverride;
  13568. private _fragmentSourceCodeOverride;
  13569. private _transformFeedbackVaryings;
  13570. /**
  13571. * Compiled shader to webGL program.
  13572. * @hidden
  13573. */
  13574. _program: WebGLProgram;
  13575. private _valueCache;
  13576. private static _baseCache;
  13577. /**
  13578. * Instantiates an effect.
  13579. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13580. * @param baseName Name of the effect.
  13581. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13582. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13583. * @param samplers List of sampler variables that will be passed to the shader.
  13584. * @param engine Engine to be used to render the effect
  13585. * @param defines Define statements to be added to the shader.
  13586. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13587. * @param onCompiled Callback that will be called when the shader is compiled.
  13588. * @param onError Callback that will be called if an error occurs during shader compilation.
  13589. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13590. */
  13591. 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);
  13592. /**
  13593. * Unique key for this effect
  13594. */
  13595. readonly key: string;
  13596. /**
  13597. * If the effect has been compiled and prepared.
  13598. * @returns if the effect is compiled and prepared.
  13599. */
  13600. isReady(): boolean;
  13601. /**
  13602. * The engine the effect was initialized with.
  13603. * @returns the engine.
  13604. */
  13605. getEngine(): Engine;
  13606. /**
  13607. * The compiled webGL program for the effect
  13608. * @returns the webGL program.
  13609. */
  13610. getProgram(): WebGLProgram;
  13611. /**
  13612. * The set of names of attribute variables for the shader.
  13613. * @returns An array of attribute names.
  13614. */
  13615. getAttributesNames(): string[];
  13616. /**
  13617. * Returns the attribute at the given index.
  13618. * @param index The index of the attribute.
  13619. * @returns The location of the attribute.
  13620. */
  13621. getAttributeLocation(index: number): number;
  13622. /**
  13623. * Returns the attribute based on the name of the variable.
  13624. * @param name of the attribute to look up.
  13625. * @returns the attribute location.
  13626. */
  13627. getAttributeLocationByName(name: string): number;
  13628. /**
  13629. * The number of attributes.
  13630. * @returns the numnber of attributes.
  13631. */
  13632. getAttributesCount(): number;
  13633. /**
  13634. * Gets the index of a uniform variable.
  13635. * @param uniformName of the uniform to look up.
  13636. * @returns the index.
  13637. */
  13638. getUniformIndex(uniformName: string): number;
  13639. /**
  13640. * Returns the attribute based on the name of the variable.
  13641. * @param uniformName of the uniform to look up.
  13642. * @returns the location of the uniform.
  13643. */
  13644. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13645. /**
  13646. * Returns an array of sampler variable names
  13647. * @returns The array of sampler variable neames.
  13648. */
  13649. getSamplers(): string[];
  13650. /**
  13651. * The error from the last compilation.
  13652. * @returns the error string.
  13653. */
  13654. getCompilationError(): string;
  13655. /**
  13656. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13657. * @param func The callback to be used.
  13658. */
  13659. executeWhenCompiled(func: (effect: Effect) => void): void;
  13660. /** @hidden */
  13661. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13662. /** @hidden */
  13663. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13664. /** @hidden */
  13665. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13666. private _processShaderConversion;
  13667. private _processIncludes;
  13668. private _processPrecision;
  13669. /**
  13670. * Recompiles the webGL program
  13671. * @param vertexSourceCode The source code for the vertex shader.
  13672. * @param fragmentSourceCode The source code for the fragment shader.
  13673. * @param onCompiled Callback called when completed.
  13674. * @param onError Callback called on error.
  13675. * @hidden
  13676. */
  13677. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13678. /**
  13679. * Gets the uniform locations of the the specified variable names
  13680. * @param names THe names of the variables to lookup.
  13681. * @returns Array of locations in the same order as variable names.
  13682. */
  13683. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13684. /**
  13685. * Prepares the effect
  13686. * @hidden
  13687. */
  13688. _prepareEffect(): void;
  13689. /**
  13690. * Checks if the effect is supported. (Must be called after compilation)
  13691. */
  13692. readonly isSupported: boolean;
  13693. /**
  13694. * Binds a texture to the engine to be used as output of the shader.
  13695. * @param channel Name of the output variable.
  13696. * @param texture Texture to bind.
  13697. * @hidden
  13698. */
  13699. _bindTexture(channel: string, texture: InternalTexture): void;
  13700. /**
  13701. * Sets a texture on the engine to be used in the shader.
  13702. * @param channel Name of the sampler variable.
  13703. * @param texture Texture to set.
  13704. */
  13705. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13706. /**
  13707. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13708. * @param channel Name of the sampler variable.
  13709. * @param texture Texture to set.
  13710. */
  13711. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13712. /**
  13713. * Sets an array of textures on the engine to be used in the shader.
  13714. * @param channel Name of the variable.
  13715. * @param textures Textures to set.
  13716. */
  13717. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13718. /**
  13719. * 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)
  13720. * @param channel Name of the sampler variable.
  13721. * @param postProcess Post process to get the input texture from.
  13722. */
  13723. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13724. /**
  13725. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13726. * 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)
  13727. * @param channel Name of the sampler variable.
  13728. * @param postProcess Post process to get the output texture from.
  13729. */
  13730. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13731. /** @hidden */
  13732. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13733. /** @hidden */
  13734. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13735. /** @hidden */
  13736. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13737. /** @hidden */
  13738. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13739. /**
  13740. * Binds a buffer to a uniform.
  13741. * @param buffer Buffer to bind.
  13742. * @param name Name of the uniform variable to bind to.
  13743. */
  13744. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13745. /**
  13746. * Binds block to a uniform.
  13747. * @param blockName Name of the block to bind.
  13748. * @param index Index to bind.
  13749. */
  13750. bindUniformBlock(blockName: string, index: number): void;
  13751. /**
  13752. * Sets an interger value on a uniform variable.
  13753. * @param uniformName Name of the variable.
  13754. * @param value Value to be set.
  13755. * @returns this effect.
  13756. */
  13757. setInt(uniformName: string, value: number): Effect;
  13758. /**
  13759. * Sets an int array on a uniform variable.
  13760. * @param uniformName Name of the variable.
  13761. * @param array array to be set.
  13762. * @returns this effect.
  13763. */
  13764. setIntArray(uniformName: string, array: Int32Array): Effect;
  13765. /**
  13766. * 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)
  13767. * @param uniformName Name of the variable.
  13768. * @param array array to be set.
  13769. * @returns this effect.
  13770. */
  13771. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13772. /**
  13773. * 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)
  13774. * @param uniformName Name of the variable.
  13775. * @param array array to be set.
  13776. * @returns this effect.
  13777. */
  13778. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13779. /**
  13780. * 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)
  13781. * @param uniformName Name of the variable.
  13782. * @param array array to be set.
  13783. * @returns this effect.
  13784. */
  13785. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13786. /**
  13787. * Sets an float array on a uniform variable.
  13788. * @param uniformName Name of the variable.
  13789. * @param array array to be set.
  13790. * @returns this effect.
  13791. */
  13792. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13793. /**
  13794. * 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)
  13795. * @param uniformName Name of the variable.
  13796. * @param array array to be set.
  13797. * @returns this effect.
  13798. */
  13799. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13800. /**
  13801. * 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)
  13802. * @param uniformName Name of the variable.
  13803. * @param array array to be set.
  13804. * @returns this effect.
  13805. */
  13806. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13807. /**
  13808. * 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)
  13809. * @param uniformName Name of the variable.
  13810. * @param array array to be set.
  13811. * @returns this effect.
  13812. */
  13813. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13814. /**
  13815. * Sets an array on a uniform variable.
  13816. * @param uniformName Name of the variable.
  13817. * @param array array to be set.
  13818. * @returns this effect.
  13819. */
  13820. setArray(uniformName: string, array: number[]): Effect;
  13821. /**
  13822. * 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)
  13823. * @param uniformName Name of the variable.
  13824. * @param array array to be set.
  13825. * @returns this effect.
  13826. */
  13827. setArray2(uniformName: string, array: number[]): Effect;
  13828. /**
  13829. * 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)
  13830. * @param uniformName Name of the variable.
  13831. * @param array array to be set.
  13832. * @returns this effect.
  13833. */
  13834. setArray3(uniformName: string, array: number[]): Effect;
  13835. /**
  13836. * 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)
  13837. * @param uniformName Name of the variable.
  13838. * @param array array to be set.
  13839. * @returns this effect.
  13840. */
  13841. setArray4(uniformName: string, array: number[]): Effect;
  13842. /**
  13843. * Sets matrices on a uniform variable.
  13844. * @param uniformName Name of the variable.
  13845. * @param matrices matrices to be set.
  13846. * @returns this effect.
  13847. */
  13848. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13849. /**
  13850. * Sets matrix on a uniform variable.
  13851. * @param uniformName Name of the variable.
  13852. * @param matrix matrix to be set.
  13853. * @returns this effect.
  13854. */
  13855. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13856. /**
  13857. * 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)
  13858. * @param uniformName Name of the variable.
  13859. * @param matrix matrix to be set.
  13860. * @returns this effect.
  13861. */
  13862. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13863. /**
  13864. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13865. * @param uniformName Name of the variable.
  13866. * @param matrix matrix to be set.
  13867. * @returns this effect.
  13868. */
  13869. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13870. /**
  13871. * Sets a float on a uniform variable.
  13872. * @param uniformName Name of the variable.
  13873. * @param value value to be set.
  13874. * @returns this effect.
  13875. */
  13876. setFloat(uniformName: string, value: number): Effect;
  13877. /**
  13878. * Sets a boolean on a uniform variable.
  13879. * @param uniformName Name of the variable.
  13880. * @param bool value to be set.
  13881. * @returns this effect.
  13882. */
  13883. setBool(uniformName: string, bool: boolean): Effect;
  13884. /**
  13885. * Sets a Vector2 on a uniform variable.
  13886. * @param uniformName Name of the variable.
  13887. * @param vector2 vector2 to be set.
  13888. * @returns this effect.
  13889. */
  13890. setVector2(uniformName: string, vector2: Vector2): Effect;
  13891. /**
  13892. * Sets a float2 on a uniform variable.
  13893. * @param uniformName Name of the variable.
  13894. * @param x First float in float2.
  13895. * @param y Second float in float2.
  13896. * @returns this effect.
  13897. */
  13898. setFloat2(uniformName: string, x: number, y: number): Effect;
  13899. /**
  13900. * Sets a Vector3 on a uniform variable.
  13901. * @param uniformName Name of the variable.
  13902. * @param vector3 Value to be set.
  13903. * @returns this effect.
  13904. */
  13905. setVector3(uniformName: string, vector3: Vector3): Effect;
  13906. /**
  13907. * Sets a float3 on a uniform variable.
  13908. * @param uniformName Name of the variable.
  13909. * @param x First float in float3.
  13910. * @param y Second float in float3.
  13911. * @param z Third float in float3.
  13912. * @returns this effect.
  13913. */
  13914. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13915. /**
  13916. * Sets a Vector4 on a uniform variable.
  13917. * @param uniformName Name of the variable.
  13918. * @param vector4 Value to be set.
  13919. * @returns this effect.
  13920. */
  13921. setVector4(uniformName: string, vector4: Vector4): Effect;
  13922. /**
  13923. * Sets a float4 on a uniform variable.
  13924. * @param uniformName Name of the variable.
  13925. * @param x First float in float4.
  13926. * @param y Second float in float4.
  13927. * @param z Third float in float4.
  13928. * @param w Fourth float in float4.
  13929. * @returns this effect.
  13930. */
  13931. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13932. /**
  13933. * Sets a Color3 on a uniform variable.
  13934. * @param uniformName Name of the variable.
  13935. * @param color3 Value to be set.
  13936. * @returns this effect.
  13937. */
  13938. setColor3(uniformName: string, color3: Color3): Effect;
  13939. /**
  13940. * Sets a Color4 on a uniform variable.
  13941. * @param uniformName Name of the variable.
  13942. * @param color3 Value to be set.
  13943. * @param alpha Alpha value to be set.
  13944. * @returns this effect.
  13945. */
  13946. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13947. /**
  13948. * Sets a Color4 on a uniform variable
  13949. * @param uniformName defines the name of the variable
  13950. * @param color4 defines the value to be set
  13951. * @returns this effect.
  13952. */
  13953. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13954. /**
  13955. * This function will add a new shader to the shader store
  13956. * @param name the name of the shader
  13957. * @param pixelShader optional pixel shader content
  13958. * @param vertexShader optional vertex shader content
  13959. */
  13960. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13961. /**
  13962. * Store of each shader (The can be looked up using effect.key)
  13963. */
  13964. static ShadersStore: {
  13965. [key: string]: string;
  13966. };
  13967. /**
  13968. * Store of each included file for a shader (The can be looked up using effect.key)
  13969. */
  13970. static IncludesShadersStore: {
  13971. [key: string]: string;
  13972. };
  13973. /**
  13974. * Resets the cache of effects.
  13975. */
  13976. static ResetCache(): void;
  13977. }
  13978. }
  13979. declare module BABYLON {
  13980. class FresnelParameters {
  13981. private _isEnabled;
  13982. isEnabled: boolean;
  13983. leftColor: Color3;
  13984. rightColor: Color3;
  13985. bias: number;
  13986. power: number;
  13987. clone(): FresnelParameters;
  13988. serialize(): any;
  13989. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13990. }
  13991. }
  13992. declare module BABYLON {
  13993. /**
  13994. * Interface to follow in your material defines to integrate easily the
  13995. * Image proccessing functions.
  13996. * @hidden
  13997. */
  13998. interface IImageProcessingConfigurationDefines {
  13999. IMAGEPROCESSING: boolean;
  14000. VIGNETTE: boolean;
  14001. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14002. VIGNETTEBLENDMODEOPAQUE: boolean;
  14003. TONEMAPPING: boolean;
  14004. TONEMAPPING_ACES: boolean;
  14005. CONTRAST: boolean;
  14006. EXPOSURE: boolean;
  14007. COLORCURVES: boolean;
  14008. COLORGRADING: boolean;
  14009. COLORGRADING3D: boolean;
  14010. SAMPLER3DGREENDEPTH: boolean;
  14011. SAMPLER3DBGRMAP: boolean;
  14012. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14013. }
  14014. /**
  14015. * @hidden
  14016. */
  14017. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14018. IMAGEPROCESSING: boolean;
  14019. VIGNETTE: boolean;
  14020. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14021. VIGNETTEBLENDMODEOPAQUE: boolean;
  14022. TONEMAPPING: boolean;
  14023. TONEMAPPING_ACES: boolean;
  14024. CONTRAST: boolean;
  14025. COLORCURVES: boolean;
  14026. COLORGRADING: boolean;
  14027. COLORGRADING3D: boolean;
  14028. SAMPLER3DGREENDEPTH: boolean;
  14029. SAMPLER3DBGRMAP: boolean;
  14030. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14031. EXPOSURE: boolean;
  14032. constructor();
  14033. }
  14034. /**
  14035. * This groups together the common properties used for image processing either in direct forward pass
  14036. * or through post processing effect depending on the use of the image processing pipeline in your scene
  14037. * or not.
  14038. */
  14039. class ImageProcessingConfiguration {
  14040. /**
  14041. * Default tone mapping applied in BabylonJS.
  14042. */
  14043. static readonly TONEMAPPING_STANDARD: number;
  14044. /**
  14045. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  14046. * to other engines rendering to increase portability.
  14047. */
  14048. static readonly TONEMAPPING_ACES: number;
  14049. /**
  14050. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  14051. */
  14052. colorCurves: Nullable<ColorCurves>;
  14053. private _colorCurvesEnabled;
  14054. /**
  14055. * Gets wether the color curves effect is enabled.
  14056. */
  14057. /**
  14058. * Sets wether the color curves effect is enabled.
  14059. */
  14060. colorCurvesEnabled: boolean;
  14061. /**
  14062. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14063. */
  14064. colorGradingTexture: Nullable<BaseTexture>;
  14065. private _colorGradingEnabled;
  14066. /**
  14067. * Gets wether the color grading effect is enabled.
  14068. */
  14069. /**
  14070. * Sets wether the color grading effect is enabled.
  14071. */
  14072. colorGradingEnabled: boolean;
  14073. private _colorGradingWithGreenDepth;
  14074. /**
  14075. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  14076. */
  14077. /**
  14078. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  14079. */
  14080. colorGradingWithGreenDepth: boolean;
  14081. private _colorGradingBGR;
  14082. /**
  14083. * Gets wether the color grading texture contains BGR values.
  14084. */
  14085. /**
  14086. * Sets wether the color grading texture contains BGR values.
  14087. */
  14088. colorGradingBGR: boolean;
  14089. /** @hidden */
  14090. _exposure: number;
  14091. /**
  14092. * Gets the Exposure used in the effect.
  14093. */
  14094. /**
  14095. * Sets the Exposure used in the effect.
  14096. */
  14097. exposure: number;
  14098. private _toneMappingEnabled;
  14099. /**
  14100. * Gets wether the tone mapping effect is enabled.
  14101. */
  14102. /**
  14103. * Sets wether the tone mapping effect is enabled.
  14104. */
  14105. toneMappingEnabled: boolean;
  14106. private _toneMappingType;
  14107. /**
  14108. * Gets the type of tone mapping effect.
  14109. */
  14110. /**
  14111. * Sets the type of tone mapping effect used in BabylonJS.
  14112. */
  14113. toneMappingType: number;
  14114. protected _contrast: number;
  14115. /**
  14116. * Gets the contrast used in the effect.
  14117. */
  14118. /**
  14119. * Sets the contrast used in the effect.
  14120. */
  14121. contrast: number;
  14122. /**
  14123. * Vignette stretch size.
  14124. */
  14125. vignetteStretch: number;
  14126. /**
  14127. * Vignette centre X Offset.
  14128. */
  14129. vignetteCentreX: number;
  14130. /**
  14131. * Vignette centre Y Offset.
  14132. */
  14133. vignetteCentreY: number;
  14134. /**
  14135. * Vignette weight or intensity of the vignette effect.
  14136. */
  14137. vignetteWeight: number;
  14138. /**
  14139. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14140. * if vignetteEnabled is set to true.
  14141. */
  14142. vignetteColor: Color4;
  14143. /**
  14144. * Camera field of view used by the Vignette effect.
  14145. */
  14146. vignetteCameraFov: number;
  14147. private _vignetteBlendMode;
  14148. /**
  14149. * Gets the vignette blend mode allowing different kind of effect.
  14150. */
  14151. /**
  14152. * Sets the vignette blend mode allowing different kind of effect.
  14153. */
  14154. vignetteBlendMode: number;
  14155. private _vignetteEnabled;
  14156. /**
  14157. * Gets wether the vignette effect is enabled.
  14158. */
  14159. /**
  14160. * Sets wether the vignette effect is enabled.
  14161. */
  14162. vignetteEnabled: boolean;
  14163. private _applyByPostProcess;
  14164. /**
  14165. * Gets wether the image processing is applied through a post process or not.
  14166. */
  14167. /**
  14168. * Sets wether the image processing is applied through a post process or not.
  14169. */
  14170. applyByPostProcess: boolean;
  14171. private _isEnabled;
  14172. /**
  14173. * Gets wether the image processing is enabled or not.
  14174. */
  14175. /**
  14176. * Sets wether the image processing is enabled or not.
  14177. */
  14178. isEnabled: boolean;
  14179. /**
  14180. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14181. */
  14182. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14183. /**
  14184. * Method called each time the image processing information changes requires to recompile the effect.
  14185. */
  14186. protected _updateParameters(): void;
  14187. getClassName(): string;
  14188. /**
  14189. * Prepare the list of uniforms associated with the Image Processing effects.
  14190. * @param uniformsList The list of uniforms used in the effect
  14191. * @param defines the list of defines currently in use
  14192. */
  14193. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14194. /**
  14195. * Prepare the list of samplers associated with the Image Processing effects.
  14196. * @param uniformsList The list of uniforms used in the effect
  14197. * @param defines the list of defines currently in use
  14198. */
  14199. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14200. /**
  14201. * Prepare the list of defines associated to the shader.
  14202. * @param defines the list of defines to complete
  14203. */
  14204. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14205. /**
  14206. * Returns true if all the image processing information are ready.
  14207. */
  14208. isReady(): boolean;
  14209. /**
  14210. * Binds the image processing to the shader.
  14211. * @param effect The effect to bind to
  14212. */
  14213. bind(effect: Effect, aspectRatio?: number): void;
  14214. /**
  14215. * Clones the current image processing instance.
  14216. * @return The cloned image processing
  14217. */
  14218. clone(): ImageProcessingConfiguration;
  14219. /**
  14220. * Serializes the current image processing instance to a json representation.
  14221. * @return a JSON representation
  14222. */
  14223. serialize(): any;
  14224. /**
  14225. * Parses the image processing from a json representation.
  14226. * @param source the JSON source to parse
  14227. * @return The parsed image processing
  14228. */
  14229. static Parse(source: any): ImageProcessingConfiguration;
  14230. private static _VIGNETTEMODE_MULTIPLY;
  14231. private static _VIGNETTEMODE_OPAQUE;
  14232. /**
  14233. * Used to apply the vignette as a mix with the pixel color.
  14234. */
  14235. static readonly VIGNETTEMODE_MULTIPLY: number;
  14236. /**
  14237. * Used to apply the vignette as a replacement of the pixel color.
  14238. */
  14239. static readonly VIGNETTEMODE_OPAQUE: number;
  14240. }
  14241. }
  14242. declare module BABYLON {
  14243. /**
  14244. * Manages the defines for the Material
  14245. */
  14246. class MaterialDefines {
  14247. private _keys;
  14248. private _isDirty;
  14249. /** @hidden */
  14250. _renderId: number;
  14251. /** @hidden */
  14252. _areLightsDirty: boolean;
  14253. /** @hidden */
  14254. _areAttributesDirty: boolean;
  14255. /** @hidden */
  14256. _areTexturesDirty: boolean;
  14257. /** @hidden */
  14258. _areFresnelDirty: boolean;
  14259. /** @hidden */
  14260. _areMiscDirty: boolean;
  14261. /** @hidden */
  14262. _areImageProcessingDirty: boolean;
  14263. /** @hidden */
  14264. _normals: boolean;
  14265. /** @hidden */
  14266. _uvs: boolean;
  14267. /** @hidden */
  14268. _needNormals: boolean;
  14269. /** @hidden */
  14270. _needUVs: boolean;
  14271. /**
  14272. * Specifies if the material needs to be re-calculated
  14273. */
  14274. readonly isDirty: boolean;
  14275. /**
  14276. * Marks the material to indicate that it has been re-calculated
  14277. */
  14278. markAsProcessed(): void;
  14279. /**
  14280. * Marks the material to indicate that it needs to be re-calculated
  14281. */
  14282. markAsUnprocessed(): void;
  14283. /**
  14284. * Marks the material to indicate all of its defines need to be re-calculated
  14285. */
  14286. markAllAsDirty(): void;
  14287. /**
  14288. * Marks the material to indicate that image processing needs to be re-calculated
  14289. */
  14290. markAsImageProcessingDirty(): void;
  14291. /**
  14292. * Marks the material to indicate the lights need to be re-calculated
  14293. */
  14294. markAsLightDirty(): void;
  14295. /**
  14296. * Marks the attribute state as changed
  14297. */
  14298. markAsAttributesDirty(): void;
  14299. /**
  14300. * Marks the texture state as changed
  14301. */
  14302. markAsTexturesDirty(): void;
  14303. /**
  14304. * Marks the fresnel state as changed
  14305. */
  14306. markAsFresnelDirty(): void;
  14307. /**
  14308. * Marks the misc state as changed
  14309. */
  14310. markAsMiscDirty(): void;
  14311. /**
  14312. * Rebuilds the material defines
  14313. */
  14314. rebuild(): void;
  14315. /**
  14316. * Specifies if two material defines are equal
  14317. * @param other - A material define instance to compare to
  14318. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14319. */
  14320. isEqual(other: MaterialDefines): boolean;
  14321. /**
  14322. * Clones this instance's defines to another instance
  14323. * @param other - material defines to clone values to
  14324. */
  14325. cloneTo(other: MaterialDefines): void;
  14326. /**
  14327. * Resets the material define values
  14328. */
  14329. reset(): void;
  14330. /**
  14331. * Converts the material define values to a string
  14332. * @returns - String of material define information
  14333. */
  14334. toString(): string;
  14335. }
  14336. /**
  14337. * Base class for the main features of a material in Babylon.js
  14338. */
  14339. class Material implements IAnimatable {
  14340. private static _TriangleFillMode;
  14341. private static _WireFrameFillMode;
  14342. private static _PointFillMode;
  14343. private static _PointListDrawMode;
  14344. private static _LineListDrawMode;
  14345. private static _LineLoopDrawMode;
  14346. private static _LineStripDrawMode;
  14347. private static _TriangleStripDrawMode;
  14348. private static _TriangleFanDrawMode;
  14349. /**
  14350. * Returns the triangle fill mode
  14351. */
  14352. static readonly TriangleFillMode: number;
  14353. /**
  14354. * Returns the wireframe mode
  14355. */
  14356. static readonly WireFrameFillMode: number;
  14357. /**
  14358. * Returns the point fill mode
  14359. */
  14360. static readonly PointFillMode: number;
  14361. /**
  14362. * Returns the point list draw mode
  14363. */
  14364. static readonly PointListDrawMode: number;
  14365. /**
  14366. * Returns the line list draw mode
  14367. */
  14368. static readonly LineListDrawMode: number;
  14369. /**
  14370. * Returns the line loop draw mode
  14371. */
  14372. static readonly LineLoopDrawMode: number;
  14373. /**
  14374. * Returns the line strip draw mode
  14375. */
  14376. static readonly LineStripDrawMode: number;
  14377. /**
  14378. * Returns the triangle strip draw mode
  14379. */
  14380. static readonly TriangleStripDrawMode: number;
  14381. /**
  14382. * Returns the triangle fan draw mode
  14383. */
  14384. static readonly TriangleFanDrawMode: number;
  14385. /**
  14386. * Stores the clock-wise side orientation
  14387. */
  14388. private static _ClockWiseSideOrientation;
  14389. /**
  14390. * Stores the counter clock-wise side orientation
  14391. */
  14392. private static _CounterClockWiseSideOrientation;
  14393. /**
  14394. * Returns the clock-wise side orientation
  14395. */
  14396. static readonly ClockWiseSideOrientation: number;
  14397. /**
  14398. * Returns the counter clock-wise side orientation
  14399. */
  14400. static readonly CounterClockWiseSideOrientation: number;
  14401. /**
  14402. * The dirty texture flag value
  14403. */
  14404. private static _TextureDirtyFlag;
  14405. /**
  14406. * The dirty light flag value
  14407. */
  14408. private static _LightDirtyFlag;
  14409. /**
  14410. * The dirty fresnel flag value
  14411. */
  14412. private static _FresnelDirtyFlag;
  14413. /**
  14414. * The dirty attribute flag value
  14415. */
  14416. private static _AttributesDirtyFlag;
  14417. /**
  14418. * The dirty misc flag value
  14419. */
  14420. private static _MiscDirtyFlag;
  14421. /**
  14422. * Returns the dirty texture flag value
  14423. */
  14424. static readonly TextureDirtyFlag: number;
  14425. /**
  14426. * Returns the dirty light flag value
  14427. */
  14428. static readonly LightDirtyFlag: number;
  14429. /**
  14430. * Returns the dirty fresnel flag value
  14431. */
  14432. static readonly FresnelDirtyFlag: number;
  14433. /**
  14434. * Returns the dirty attributes flag value
  14435. */
  14436. static readonly AttributesDirtyFlag: number;
  14437. /**
  14438. * Returns the dirty misc flag value
  14439. */
  14440. static readonly MiscDirtyFlag: number;
  14441. /**
  14442. * The ID of the material
  14443. */
  14444. id: string;
  14445. /**
  14446. * Gets or sets the unique id of the material
  14447. */
  14448. uniqueId: number;
  14449. /**
  14450. * The name of the material
  14451. */
  14452. name: string;
  14453. /**
  14454. * Specifies if the ready state should be checked on each call
  14455. */
  14456. checkReadyOnEveryCall: boolean;
  14457. /**
  14458. * Specifies if the ready state should be checked once
  14459. */
  14460. checkReadyOnlyOnce: boolean;
  14461. /**
  14462. * The state of the material
  14463. */
  14464. state: string;
  14465. /**
  14466. * The alpha value of the material
  14467. */
  14468. protected _alpha: number;
  14469. /**
  14470. * Sets the alpha value of the material
  14471. */
  14472. /**
  14473. * Gets the alpha value of the material
  14474. */
  14475. alpha: number;
  14476. /**
  14477. * Specifies if back face culling is enabled
  14478. */
  14479. protected _backFaceCulling: boolean;
  14480. /**
  14481. * Sets the back-face culling state
  14482. */
  14483. /**
  14484. * Gets the back-face culling state
  14485. */
  14486. backFaceCulling: boolean;
  14487. /**
  14488. * Stores the value for side orientation
  14489. */
  14490. sideOrientation: number;
  14491. /**
  14492. * Callback triggered when the material is compiled
  14493. */
  14494. onCompiled: (effect: Effect) => void;
  14495. /**
  14496. * Callback triggered when an error occurs
  14497. */
  14498. onError: (effect: Effect, errors: string) => void;
  14499. /**
  14500. * Callback triggered to get the render target textures
  14501. */
  14502. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14503. /**
  14504. * Specifies if the material should be serialized
  14505. */
  14506. doNotSerialize: boolean;
  14507. /**
  14508. * Specifies if the effect should be stored on sub meshes
  14509. */
  14510. storeEffectOnSubMeshes: boolean;
  14511. /**
  14512. * Stores the animations for the material
  14513. */
  14514. animations: Array<Animation>;
  14515. /**
  14516. * An event triggered when the material is disposed
  14517. */
  14518. onDisposeObservable: Observable<Material>;
  14519. /**
  14520. * An observer which watches for dispose events
  14521. */
  14522. private _onDisposeObserver;
  14523. private _onUnBindObservable;
  14524. /**
  14525. * Called during a dispose event
  14526. */
  14527. onDispose: () => void;
  14528. private _onBindObservable;
  14529. /**
  14530. * An event triggered when the material is bound
  14531. */
  14532. readonly onBindObservable: Observable<AbstractMesh>;
  14533. /**
  14534. * An observer which watches for bind events
  14535. */
  14536. private _onBindObserver;
  14537. /**
  14538. * Called during a bind event
  14539. */
  14540. onBind: (Mesh: AbstractMesh) => void;
  14541. /**
  14542. * An event triggered when the material is unbound
  14543. */
  14544. readonly onUnBindObservable: Observable<Material>;
  14545. /**
  14546. * Stores the value of the alpha mode
  14547. */
  14548. private _alphaMode;
  14549. /**
  14550. * Sets the value of the alpha mode.
  14551. *
  14552. * | Value | Type | Description |
  14553. * | --- | --- | --- |
  14554. * | 0 | ALPHA_DISABLE | |
  14555. * | 1 | ALPHA_ADD | |
  14556. * | 2 | ALPHA_COMBINE | |
  14557. * | 3 | ALPHA_SUBTRACT | |
  14558. * | 4 | ALPHA_MULTIPLY | |
  14559. * | 5 | ALPHA_MAXIMIZED | |
  14560. * | 6 | ALPHA_ONEONE | |
  14561. * | 7 | ALPHA_PREMULTIPLIED | |
  14562. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14563. * | 9 | ALPHA_INTERPOLATE | |
  14564. * | 10 | ALPHA_SCREENMODE | |
  14565. *
  14566. */
  14567. /**
  14568. * Gets the value of the alpha mode
  14569. */
  14570. alphaMode: number;
  14571. /**
  14572. * Stores the state of the need depth pre-pass value
  14573. */
  14574. private _needDepthPrePass;
  14575. /**
  14576. * Sets the need depth pre-pass value
  14577. */
  14578. /**
  14579. * Gets the depth pre-pass value
  14580. */
  14581. needDepthPrePass: boolean;
  14582. /**
  14583. * Specifies if depth writing should be disabled
  14584. */
  14585. disableDepthWrite: boolean;
  14586. /**
  14587. * Specifies if depth writing should be forced
  14588. */
  14589. forceDepthWrite: boolean;
  14590. /**
  14591. * Specifies if there should be a separate pass for culling
  14592. */
  14593. separateCullingPass: boolean;
  14594. /**
  14595. * Stores the state specifing if fog should be enabled
  14596. */
  14597. private _fogEnabled;
  14598. /**
  14599. * Sets the state for enabling fog
  14600. */
  14601. /**
  14602. * Gets the value of the fog enabled state
  14603. */
  14604. fogEnabled: boolean;
  14605. /**
  14606. * Stores the size of points
  14607. */
  14608. pointSize: number;
  14609. /**
  14610. * Stores the z offset value
  14611. */
  14612. zOffset: number;
  14613. /**
  14614. * Gets a value specifying if wireframe mode is enabled
  14615. */
  14616. /**
  14617. * Sets the state of wireframe mode
  14618. */
  14619. wireframe: boolean;
  14620. /**
  14621. * Gets the value specifying if point clouds are enabled
  14622. */
  14623. /**
  14624. * Sets the state of point cloud mode
  14625. */
  14626. pointsCloud: boolean;
  14627. /**
  14628. * Gets the material fill mode
  14629. */
  14630. /**
  14631. * Sets the material fill mode
  14632. */
  14633. fillMode: number;
  14634. /**
  14635. * @hidden
  14636. * Stores the effects for the material
  14637. */
  14638. _effect: Nullable<Effect>;
  14639. /**
  14640. * @hidden
  14641. * Specifies if the material was previously ready
  14642. */
  14643. _wasPreviouslyReady: boolean;
  14644. /**
  14645. * Specifies if uniform buffers should be used
  14646. */
  14647. private _useUBO;
  14648. /**
  14649. * Stores a reference to the scene
  14650. */
  14651. private _scene;
  14652. /**
  14653. * Stores the fill mode state
  14654. */
  14655. private _fillMode;
  14656. /**
  14657. * Specifies if the depth write state should be cached
  14658. */
  14659. private _cachedDepthWriteState;
  14660. /**
  14661. * Stores the uniform buffer
  14662. */
  14663. protected _uniformBuffer: UniformBuffer;
  14664. /**
  14665. * Creates a material instance
  14666. * @param name defines the name of the material
  14667. * @param scene defines the scene to reference
  14668. * @param doNotAdd specifies if the material should be added to the scene
  14669. */
  14670. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14671. /**
  14672. * Returns a string representation of the current material
  14673. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14674. * @returns a string with material information
  14675. */
  14676. toString(fullDetails?: boolean): string;
  14677. /**
  14678. * Gets the class name of the material
  14679. * @returns a string with the class name of the material
  14680. */
  14681. getClassName(): string;
  14682. /**
  14683. * Specifies if updates for the material been locked
  14684. */
  14685. readonly isFrozen: boolean;
  14686. /**
  14687. * Locks updates for the material
  14688. */
  14689. freeze(): void;
  14690. /**
  14691. * Unlocks updates for the material
  14692. */
  14693. unfreeze(): void;
  14694. /**
  14695. * Specifies if the material is ready to be used
  14696. * @param mesh defines the mesh to check
  14697. * @param useInstances specifies if instances should be used
  14698. * @returns a boolean indicating if the material is ready to be used
  14699. */
  14700. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14701. /**
  14702. * Specifies that the submesh is ready to be used
  14703. * @param mesh defines the mesh to check
  14704. * @param subMesh defines which submesh to check
  14705. * @param useInstances specifies that instances should be used
  14706. * @returns a boolean indicating that the submesh is ready or not
  14707. */
  14708. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14709. /**
  14710. * Returns the material effect
  14711. * @returns the effect associated with the material
  14712. */
  14713. getEffect(): Nullable<Effect>;
  14714. /**
  14715. * Returns the current scene
  14716. * @returns a Scene
  14717. */
  14718. getScene(): Scene;
  14719. /**
  14720. * Specifies if the material will require alpha blending
  14721. * @returns a boolean specifying if alpha blending is needed
  14722. */
  14723. needAlphaBlending(): boolean;
  14724. /**
  14725. * Specifies if the mesh will require alpha blending
  14726. * @param mesh defines the mesh to check
  14727. * @returns a boolean specifying if alpha blending is needed for the mesh
  14728. */
  14729. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14730. /**
  14731. * Specifies if this material should be rendered in alpha test mode
  14732. * @returns a boolean specifying if an alpha test is needed.
  14733. */
  14734. needAlphaTesting(): boolean;
  14735. /**
  14736. * Gets the texture used for the alpha test
  14737. * @returns the texture to use for alpha testing
  14738. */
  14739. getAlphaTestTexture(): Nullable<BaseTexture>;
  14740. /**
  14741. * Marks the material to indicate that it needs to be re-calculated
  14742. */
  14743. markDirty(): void;
  14744. /** @hidden */
  14745. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14746. /**
  14747. * Binds the material to the mesh
  14748. * @param world defines the world transformation matrix
  14749. * @param mesh defines the mesh to bind the material to
  14750. */
  14751. bind(world: Matrix, mesh?: Mesh): void;
  14752. /**
  14753. * Binds the submesh to the material
  14754. * @param world defines the world transformation matrix
  14755. * @param mesh defines the mesh containing the submesh
  14756. * @param subMesh defines the submesh to bind the material to
  14757. */
  14758. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14759. /**
  14760. * Binds the world matrix to the material
  14761. * @param world defines the world transformation matrix
  14762. */
  14763. bindOnlyWorldMatrix(world: Matrix): void;
  14764. /**
  14765. * Binds the scene's uniform buffer to the effect.
  14766. * @param effect defines the effect to bind to the scene uniform buffer
  14767. * @param sceneUbo defines the uniform buffer storing scene data
  14768. */
  14769. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14770. /**
  14771. * Binds the view matrix to the effect
  14772. * @param effect defines the effect to bind the view matrix to
  14773. */
  14774. bindView(effect: Effect): void;
  14775. /**
  14776. * Binds the view projection matrix to the effect
  14777. * @param effect defines the effect to bind the view projection matrix to
  14778. */
  14779. bindViewProjection(effect: Effect): void;
  14780. /**
  14781. * Specifies if material alpha testing should be turned on for the mesh
  14782. * @param mesh defines the mesh to check
  14783. */
  14784. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14785. /**
  14786. * Processes to execute after binding the material to a mesh
  14787. * @param mesh defines the rendered mesh
  14788. */
  14789. protected _afterBind(mesh?: Mesh): void;
  14790. /**
  14791. * Unbinds the material from the mesh
  14792. */
  14793. unbind(): void;
  14794. /**
  14795. * Gets the active textures from the material
  14796. * @returns an array of textures
  14797. */
  14798. getActiveTextures(): BaseTexture[];
  14799. /**
  14800. * Specifies if the material uses a texture
  14801. * @param texture defines the texture to check against the material
  14802. * @returns a boolean specifying if the material uses the texture
  14803. */
  14804. hasTexture(texture: BaseTexture): boolean;
  14805. /**
  14806. * Makes a duplicate of the material, and gives it a new name
  14807. * @param name defines the new name for the duplicated material
  14808. * @returns the cloned material
  14809. */
  14810. clone(name: string): Nullable<Material>;
  14811. /**
  14812. * Gets the meshes bound to the material
  14813. * @returns an array of meshes bound to the material
  14814. */
  14815. getBindedMeshes(): AbstractMesh[];
  14816. /**
  14817. * Force shader compilation
  14818. * @param mesh defines the mesh associated with this material
  14819. * @param onCompiled defines a function to execute once the material is compiled
  14820. * @param options defines the options to configure the compilation
  14821. */
  14822. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14823. clipPlane: boolean;
  14824. }>): void;
  14825. /**
  14826. * Force shader compilation
  14827. * @param mesh defines the mesh that will use this material
  14828. * @param options defines additional options for compiling the shaders
  14829. * @returns a promise that resolves when the compilation completes
  14830. */
  14831. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14832. clipPlane: boolean;
  14833. }>): Promise<void>;
  14834. /**
  14835. * Marks a define in the material to indicate that it needs to be re-computed
  14836. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14837. */
  14838. markAsDirty(flag: number): void;
  14839. /**
  14840. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14841. * @param func defines a function which checks material defines against the submeshes
  14842. */
  14843. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14844. /**
  14845. * Indicates that image processing needs to be re-calculated for all submeshes
  14846. */
  14847. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14848. /**
  14849. * Indicates that textures need to be re-calculated for all submeshes
  14850. */
  14851. protected _markAllSubMeshesAsTexturesDirty(): void;
  14852. /**
  14853. * Indicates that fresnel needs to be re-calculated for all submeshes
  14854. */
  14855. protected _markAllSubMeshesAsFresnelDirty(): void;
  14856. /**
  14857. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14858. */
  14859. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14860. /**
  14861. * Indicates that lights need to be re-calculated for all submeshes
  14862. */
  14863. protected _markAllSubMeshesAsLightsDirty(): void;
  14864. /**
  14865. * Indicates that attributes need to be re-calculated for all submeshes
  14866. */
  14867. protected _markAllSubMeshesAsAttributesDirty(): void;
  14868. /**
  14869. * Indicates that misc needs to be re-calculated for all submeshes
  14870. */
  14871. protected _markAllSubMeshesAsMiscDirty(): void;
  14872. /**
  14873. * Indicates that textures and misc need to be re-calculated for all submeshes
  14874. */
  14875. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14876. /**
  14877. * Disposes the material
  14878. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14879. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14880. */
  14881. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14882. /**
  14883. * Serializes this material
  14884. * @returns the serialized material object
  14885. */
  14886. serialize(): any;
  14887. /**
  14888. * Creates a MultiMaterial from parsed MultiMaterial data.
  14889. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14890. * @param scene defines the hosting scene
  14891. * @returns a new MultiMaterial
  14892. */
  14893. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14894. /**
  14895. * Creates a material from parsed material data
  14896. * @param parsedMaterial defines parsed material data
  14897. * @param scene defines the hosting scene
  14898. * @param rootUrl defines the root URL to use to load textures
  14899. * @returns a new material
  14900. */
  14901. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14902. }
  14903. }
  14904. declare module BABYLON {
  14905. /**
  14906. * "Static Class" containing the most commonly used helper while dealing with material for
  14907. * rendering purpose.
  14908. *
  14909. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14910. *
  14911. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14912. */
  14913. class MaterialHelper {
  14914. /**
  14915. * Bind the current view position to an effect.
  14916. * @param effect The effect to be bound
  14917. * @param scene The scene the eyes position is used from
  14918. */
  14919. static BindEyePosition(effect: Effect, scene: Scene): void;
  14920. /**
  14921. * Helps preparing the defines values about the UVs in used in the effect.
  14922. * UVs are shared as much as we can accross chanels in the shaders.
  14923. * @param texture The texture we are preparing the UVs for
  14924. * @param defines The defines to update
  14925. * @param key The chanel key "diffuse", "specular"... used in the shader
  14926. */
  14927. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14928. /**
  14929. * Binds a texture matrix value to its corrsponding uniform
  14930. * @param texture The texture to bind the matrix for
  14931. * @param uniformBuffer The uniform buffer receivin the data
  14932. * @param key The chanel key "diffuse", "specular"... used in the shader
  14933. */
  14934. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14935. /**
  14936. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14937. * @param mesh defines the current mesh
  14938. * @param scene defines the current scene
  14939. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14940. * @param pointsCloud defines if point cloud rendering has to be turned on
  14941. * @param fogEnabled defines if fog has to be turned on
  14942. * @param alphaTest defines if alpha testing has to be turned on
  14943. * @param defines defines the current list of defines
  14944. */
  14945. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14946. /**
  14947. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14948. * @param scene defines the current scene
  14949. * @param engine defines the current engine
  14950. * @param defines specifies the list of active defines
  14951. * @param useInstances defines if instances have to be turned on
  14952. * @param useClipPlane defines if clip plane have to be turned on
  14953. */
  14954. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14955. /**
  14956. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14957. * @param mesh The mesh containing the geometry data we will draw
  14958. * @param defines The defines to update
  14959. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14960. * @param useBones Precise whether bones should be used or not (override mesh info)
  14961. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14962. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14963. * @returns false if defines are considered not dirty and have not been checked
  14964. */
  14965. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14966. /**
  14967. * Prepares the defines related to the light information passed in parameter
  14968. * @param scene The scene we are intending to draw
  14969. * @param mesh The mesh the effect is compiling for
  14970. * @param defines The defines to update
  14971. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14972. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14973. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14974. * @returns true if normals will be required for the rest of the effect
  14975. */
  14976. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14977. /**
  14978. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14979. * that won t be acctive due to defines being turned off.
  14980. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14981. * @param samplersList The samplers list
  14982. * @param defines The defines helping in the list generation
  14983. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14984. */
  14985. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14986. /**
  14987. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14988. * @param defines The defines to update while falling back
  14989. * @param fallbacks The authorized effect fallbacks
  14990. * @param maxSimultaneousLights The maximum number of lights allowed
  14991. * @param rank the current rank of the Effect
  14992. * @returns The newly affected rank
  14993. */
  14994. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14995. /**
  14996. * Prepares the list of attributes required for morph targets according to the effect defines.
  14997. * @param attribs The current list of supported attribs
  14998. * @param mesh The mesh to prepare the morph targets attributes for
  14999. * @param defines The current Defines of the effect
  15000. */
  15001. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  15002. /**
  15003. * Prepares the list of attributes required for bones according to the effect defines.
  15004. * @param attribs The current list of supported attribs
  15005. * @param mesh The mesh to prepare the bones attributes for
  15006. * @param defines The current Defines of the effect
  15007. * @param fallbacks The current efffect fallback strategy
  15008. */
  15009. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  15010. /**
  15011. * Prepares the list of attributes required for instances according to the effect defines.
  15012. * @param attribs The current list of supported attribs
  15013. * @param defines The current Defines of the effect
  15014. */
  15015. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  15016. /**
  15017. * Binds the light shadow information to the effect for the given mesh.
  15018. * @param light The light containing the generator
  15019. * @param scene The scene the lights belongs to
  15020. * @param mesh The mesh we are binding the information to render
  15021. * @param lightIndex The light index in the effect used to render the mesh
  15022. * @param effect The effect we are binding the data to
  15023. */
  15024. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  15025. /**
  15026. * Binds the light information to the effect.
  15027. * @param light The light containing the generator
  15028. * @param effect The effect we are binding the data to
  15029. * @param lightIndex The light index in the effect used to render
  15030. */
  15031. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  15032. /**
  15033. * Binds the lights information from the scene to the effect for the given mesh.
  15034. * @param scene The scene the lights belongs to
  15035. * @param mesh The mesh we are binding the information to render
  15036. * @param effect The effect we are binding the data to
  15037. * @param defines The generated defines for the effect
  15038. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  15039. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  15040. */
  15041. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  15042. /**
  15043. * Binds the fog information from the scene to the effect for the given mesh.
  15044. * @param scene The scene the lights belongs to
  15045. * @param mesh The mesh we are binding the information to render
  15046. * @param effect The effect we are binding the data to
  15047. */
  15048. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  15049. /**
  15050. * Binds the bones information from the mesh to the effect.
  15051. * @param mesh The mesh we are binding the information to render
  15052. * @param effect The effect we are binding the data to
  15053. */
  15054. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  15055. /**
  15056. * Binds the morph targets information from the mesh to the effect.
  15057. * @param abstractMesh The mesh we are binding the information to render
  15058. * @param effect The effect we are binding the data to
  15059. */
  15060. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  15061. /**
  15062. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  15063. * @param defines The generated defines used in the effect
  15064. * @param effect The effect we are binding the data to
  15065. * @param scene The scene we are willing to render with logarithmic scale for
  15066. */
  15067. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  15068. /**
  15069. * Binds the clip plane information from the scene to the effect.
  15070. * @param scene The scene the clip plane information are extracted from
  15071. * @param effect The effect we are binding the data to
  15072. */
  15073. static BindClipPlane(effect: Effect, scene: Scene): void;
  15074. }
  15075. }
  15076. declare module BABYLON {
  15077. class MultiMaterial extends Material {
  15078. private _subMaterials;
  15079. subMaterials: Nullable<Material>[];
  15080. constructor(name: string, scene: Scene);
  15081. private _hookArray;
  15082. getSubMaterial(index: number): Nullable<Material>;
  15083. getActiveTextures(): BaseTexture[];
  15084. getClassName(): string;
  15085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15086. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  15087. serialize(): any;
  15088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15089. }
  15090. }
  15091. declare module BABYLON {
  15092. class PushMaterial extends Material {
  15093. protected _activeEffect: Effect;
  15094. protected _normalMatrix: Matrix;
  15095. constructor(name: string, scene: Scene);
  15096. getEffect(): Effect;
  15097. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15098. /**
  15099. * Binds the given world matrix to the active effect
  15100. *
  15101. * @param world the matrix to bind
  15102. */
  15103. bindOnlyWorldMatrix(world: Matrix): void;
  15104. /**
  15105. * Binds the given normal matrix to the active effect
  15106. *
  15107. * @param normalMatrix the matrix to bind
  15108. */
  15109. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  15110. bind(world: Matrix, mesh?: Mesh): void;
  15111. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  15112. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  15113. }
  15114. }
  15115. declare module BABYLON {
  15116. class ShaderMaterial extends Material {
  15117. private _shaderPath;
  15118. private _options;
  15119. private _textures;
  15120. private _textureArrays;
  15121. private _floats;
  15122. private _ints;
  15123. private _floatsArrays;
  15124. private _colors3;
  15125. private _colors3Arrays;
  15126. private _colors4;
  15127. private _vectors2;
  15128. private _vectors3;
  15129. private _vectors4;
  15130. private _matrices;
  15131. private _matrices3x3;
  15132. private _matrices2x2;
  15133. private _vectors2Arrays;
  15134. private _vectors3Arrays;
  15135. private _cachedWorldViewMatrix;
  15136. private _renderId;
  15137. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  15138. getClassName(): string;
  15139. needAlphaBlending(): boolean;
  15140. needAlphaTesting(): boolean;
  15141. private _checkUniform;
  15142. setTexture(name: string, texture: Texture): ShaderMaterial;
  15143. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15144. setFloat(name: string, value: number): ShaderMaterial;
  15145. setInt(name: string, value: number): ShaderMaterial;
  15146. setFloats(name: string, value: number[]): ShaderMaterial;
  15147. setColor3(name: string, value: Color3): ShaderMaterial;
  15148. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15149. setColor4(name: string, value: Color4): ShaderMaterial;
  15150. setVector2(name: string, value: Vector2): ShaderMaterial;
  15151. setVector3(name: string, value: Vector3): ShaderMaterial;
  15152. setVector4(name: string, value: Vector4): ShaderMaterial;
  15153. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15154. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15155. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15156. setArray2(name: string, value: number[]): ShaderMaterial;
  15157. setArray3(name: string, value: number[]): ShaderMaterial;
  15158. private _checkCache;
  15159. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15160. bindOnlyWorldMatrix(world: Matrix): void;
  15161. bind(world: Matrix, mesh?: Mesh): void;
  15162. getActiveTextures(): BaseTexture[];
  15163. hasTexture(texture: BaseTexture): boolean;
  15164. clone(name: string): ShaderMaterial;
  15165. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15166. serialize(): any;
  15167. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15168. }
  15169. }
  15170. declare module BABYLON {
  15171. /** @hidden */
  15172. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  15173. MAINUV1: boolean;
  15174. MAINUV2: boolean;
  15175. DIFFUSE: boolean;
  15176. DIFFUSEDIRECTUV: number;
  15177. AMBIENT: boolean;
  15178. AMBIENTDIRECTUV: number;
  15179. OPACITY: boolean;
  15180. OPACITYDIRECTUV: number;
  15181. OPACITYRGB: boolean;
  15182. REFLECTION: boolean;
  15183. EMISSIVE: boolean;
  15184. EMISSIVEDIRECTUV: number;
  15185. SPECULAR: boolean;
  15186. SPECULARDIRECTUV: number;
  15187. BUMP: boolean;
  15188. BUMPDIRECTUV: number;
  15189. PARALLAX: boolean;
  15190. PARALLAXOCCLUSION: boolean;
  15191. SPECULAROVERALPHA: boolean;
  15192. CLIPPLANE: boolean;
  15193. CLIPPLANE2: boolean;
  15194. CLIPPLANE3: boolean;
  15195. CLIPPLANE4: boolean;
  15196. ALPHATEST: boolean;
  15197. DEPTHPREPASS: boolean;
  15198. ALPHAFROMDIFFUSE: boolean;
  15199. POINTSIZE: boolean;
  15200. FOG: boolean;
  15201. SPECULARTERM: boolean;
  15202. DIFFUSEFRESNEL: boolean;
  15203. OPACITYFRESNEL: boolean;
  15204. REFLECTIONFRESNEL: boolean;
  15205. REFRACTIONFRESNEL: boolean;
  15206. EMISSIVEFRESNEL: boolean;
  15207. FRESNEL: boolean;
  15208. NORMAL: boolean;
  15209. UV1: boolean;
  15210. UV2: boolean;
  15211. VERTEXCOLOR: boolean;
  15212. VERTEXALPHA: boolean;
  15213. NUM_BONE_INFLUENCERS: number;
  15214. BonesPerMesh: number;
  15215. INSTANCES: boolean;
  15216. GLOSSINESS: boolean;
  15217. ROUGHNESS: boolean;
  15218. EMISSIVEASILLUMINATION: boolean;
  15219. LINKEMISSIVEWITHDIFFUSE: boolean;
  15220. REFLECTIONFRESNELFROMSPECULAR: boolean;
  15221. LIGHTMAP: boolean;
  15222. LIGHTMAPDIRECTUV: number;
  15223. OBJECTSPACE_NORMALMAP: boolean;
  15224. USELIGHTMAPASSHADOWMAP: boolean;
  15225. REFLECTIONMAP_3D: boolean;
  15226. REFLECTIONMAP_SPHERICAL: boolean;
  15227. REFLECTIONMAP_PLANAR: boolean;
  15228. REFLECTIONMAP_CUBIC: boolean;
  15229. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  15230. REFLECTIONMAP_PROJECTION: boolean;
  15231. REFLECTIONMAP_SKYBOX: boolean;
  15232. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  15233. REFLECTIONMAP_EXPLICIT: boolean;
  15234. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  15235. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15236. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15237. INVERTCUBICMAP: boolean;
  15238. LOGARITHMICDEPTH: boolean;
  15239. REFRACTION: boolean;
  15240. REFRACTIONMAP_3D: boolean;
  15241. REFLECTIONOVERALPHA: boolean;
  15242. TWOSIDEDLIGHTING: boolean;
  15243. SHADOWFLOAT: boolean;
  15244. MORPHTARGETS: boolean;
  15245. MORPHTARGETS_NORMAL: boolean;
  15246. MORPHTARGETS_TANGENT: boolean;
  15247. NUM_MORPH_INFLUENCERS: number;
  15248. NONUNIFORMSCALING: boolean;
  15249. PREMULTIPLYALPHA: boolean;
  15250. IMAGEPROCESSING: boolean;
  15251. VIGNETTE: boolean;
  15252. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15253. VIGNETTEBLENDMODEOPAQUE: boolean;
  15254. TONEMAPPING: boolean;
  15255. TONEMAPPING_ACES: boolean;
  15256. CONTRAST: boolean;
  15257. COLORCURVES: boolean;
  15258. COLORGRADING: boolean;
  15259. COLORGRADING3D: boolean;
  15260. SAMPLER3DGREENDEPTH: boolean;
  15261. SAMPLER3DBGRMAP: boolean;
  15262. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15263. /**
  15264. * If the reflection texture on this material is in linear color space
  15265. * @hidden
  15266. */
  15267. IS_REFLECTION_LINEAR: boolean;
  15268. /**
  15269. * If the refraction texture on this material is in linear color space
  15270. * @hidden
  15271. */
  15272. IS_REFRACTION_LINEAR: boolean;
  15273. EXPOSURE: boolean;
  15274. constructor();
  15275. setReflectionMode(modeToEnable: string): void;
  15276. }
  15277. class StandardMaterial extends PushMaterial {
  15278. private _diffuseTexture;
  15279. diffuseTexture: Nullable<BaseTexture>;
  15280. private _ambientTexture;
  15281. ambientTexture: Nullable<BaseTexture>;
  15282. private _opacityTexture;
  15283. opacityTexture: Nullable<BaseTexture>;
  15284. private _reflectionTexture;
  15285. reflectionTexture: Nullable<BaseTexture>;
  15286. private _emissiveTexture;
  15287. emissiveTexture: Nullable<BaseTexture>;
  15288. private _specularTexture;
  15289. specularTexture: Nullable<BaseTexture>;
  15290. private _bumpTexture;
  15291. bumpTexture: Nullable<BaseTexture>;
  15292. private _lightmapTexture;
  15293. lightmapTexture: Nullable<BaseTexture>;
  15294. private _refractionTexture;
  15295. refractionTexture: Nullable<BaseTexture>;
  15296. ambientColor: Color3;
  15297. diffuseColor: Color3;
  15298. specularColor: Color3;
  15299. emissiveColor: Color3;
  15300. specularPower: number;
  15301. private _useAlphaFromDiffuseTexture;
  15302. useAlphaFromDiffuseTexture: boolean;
  15303. private _useEmissiveAsIllumination;
  15304. useEmissiveAsIllumination: boolean;
  15305. private _linkEmissiveWithDiffuse;
  15306. linkEmissiveWithDiffuse: boolean;
  15307. private _useSpecularOverAlpha;
  15308. useSpecularOverAlpha: boolean;
  15309. private _useReflectionOverAlpha;
  15310. useReflectionOverAlpha: boolean;
  15311. private _disableLighting;
  15312. disableLighting: boolean;
  15313. private _useObjectSpaceNormalMap;
  15314. /**
  15315. * Allows using an object space normal map (instead of tangent space).
  15316. */
  15317. useObjectSpaceNormalMap: boolean;
  15318. private _useParallax;
  15319. useParallax: boolean;
  15320. private _useParallaxOcclusion;
  15321. useParallaxOcclusion: boolean;
  15322. parallaxScaleBias: number;
  15323. private _roughness;
  15324. roughness: number;
  15325. indexOfRefraction: number;
  15326. invertRefractionY: boolean;
  15327. /**
  15328. * Defines the alpha limits in alpha test mode
  15329. */
  15330. alphaCutOff: number;
  15331. private _useLightmapAsShadowmap;
  15332. useLightmapAsShadowmap: boolean;
  15333. private _diffuseFresnelParameters;
  15334. diffuseFresnelParameters: FresnelParameters;
  15335. private _opacityFresnelParameters;
  15336. opacityFresnelParameters: FresnelParameters;
  15337. private _reflectionFresnelParameters;
  15338. reflectionFresnelParameters: FresnelParameters;
  15339. private _refractionFresnelParameters;
  15340. refractionFresnelParameters: FresnelParameters;
  15341. private _emissiveFresnelParameters;
  15342. emissiveFresnelParameters: FresnelParameters;
  15343. private _useReflectionFresnelFromSpecular;
  15344. useReflectionFresnelFromSpecular: boolean;
  15345. private _useGlossinessFromSpecularMapAlpha;
  15346. useGlossinessFromSpecularMapAlpha: boolean;
  15347. private _maxSimultaneousLights;
  15348. maxSimultaneousLights: number;
  15349. /**
  15350. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15351. */
  15352. private _invertNormalMapX;
  15353. invertNormalMapX: boolean;
  15354. /**
  15355. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15356. */
  15357. private _invertNormalMapY;
  15358. invertNormalMapY: boolean;
  15359. /**
  15360. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15361. */
  15362. private _twoSidedLighting;
  15363. twoSidedLighting: boolean;
  15364. /**
  15365. * Default configuration related to image processing available in the standard Material.
  15366. */
  15367. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15368. /**
  15369. * Gets the image processing configuration used either in this material.
  15370. */
  15371. /**
  15372. * Sets the Default image processing configuration used either in the this material.
  15373. *
  15374. * If sets to null, the scene one is in use.
  15375. */
  15376. imageProcessingConfiguration: ImageProcessingConfiguration;
  15377. /**
  15378. * Keep track of the image processing observer to allow dispose and replace.
  15379. */
  15380. private _imageProcessingObserver;
  15381. /**
  15382. * Attaches a new image processing configuration to the Standard Material.
  15383. * @param configuration
  15384. */
  15385. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15386. /**
  15387. * Gets wether the color curves effect is enabled.
  15388. */
  15389. /**
  15390. * Sets wether the color curves effect is enabled.
  15391. */
  15392. cameraColorCurvesEnabled: boolean;
  15393. /**
  15394. * Gets wether the color grading effect is enabled.
  15395. */
  15396. /**
  15397. * Gets wether the color grading effect is enabled.
  15398. */
  15399. cameraColorGradingEnabled: boolean;
  15400. /**
  15401. * Gets wether tonemapping is enabled or not.
  15402. */
  15403. /**
  15404. * Sets wether tonemapping is enabled or not
  15405. */
  15406. cameraToneMappingEnabled: boolean;
  15407. /**
  15408. * The camera exposure used on this material.
  15409. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15410. * This corresponds to a photographic exposure.
  15411. */
  15412. /**
  15413. * The camera exposure used on this material.
  15414. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15415. * This corresponds to a photographic exposure.
  15416. */
  15417. cameraExposure: number;
  15418. /**
  15419. * Gets The camera contrast used on this material.
  15420. */
  15421. /**
  15422. * Sets The camera contrast used on this material.
  15423. */
  15424. cameraContrast: number;
  15425. /**
  15426. * Gets the Color Grading 2D Lookup Texture.
  15427. */
  15428. /**
  15429. * Sets the Color Grading 2D Lookup Texture.
  15430. */
  15431. cameraColorGradingTexture: Nullable<BaseTexture>;
  15432. /**
  15433. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15434. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15435. * 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;
  15436. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15437. */
  15438. /**
  15439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15441. * 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;
  15442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15443. */
  15444. cameraColorCurves: Nullable<ColorCurves>;
  15445. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15446. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15447. protected _worldViewProjectionMatrix: Matrix;
  15448. protected _globalAmbientColor: Color3;
  15449. protected _useLogarithmicDepth: boolean;
  15450. constructor(name: string, scene: Scene);
  15451. getClassName(): string;
  15452. useLogarithmicDepth: boolean;
  15453. needAlphaBlending(): boolean;
  15454. needAlphaTesting(): boolean;
  15455. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15456. getAlphaTestTexture(): Nullable<BaseTexture>;
  15457. /**
  15458. * Child classes can use it to update shaders
  15459. */
  15460. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15461. buildUniformLayout(): void;
  15462. unbind(): void;
  15463. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15464. getAnimatables(): IAnimatable[];
  15465. getActiveTextures(): BaseTexture[];
  15466. hasTexture(texture: BaseTexture): boolean;
  15467. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15468. clone(name: string): StandardMaterial;
  15469. serialize(): any;
  15470. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15471. static _DiffuseTextureEnabled: boolean;
  15472. static DiffuseTextureEnabled: boolean;
  15473. static _AmbientTextureEnabled: boolean;
  15474. static AmbientTextureEnabled: boolean;
  15475. static _OpacityTextureEnabled: boolean;
  15476. static OpacityTextureEnabled: boolean;
  15477. static _ReflectionTextureEnabled: boolean;
  15478. static ReflectionTextureEnabled: boolean;
  15479. static _EmissiveTextureEnabled: boolean;
  15480. static EmissiveTextureEnabled: boolean;
  15481. static _SpecularTextureEnabled: boolean;
  15482. static SpecularTextureEnabled: boolean;
  15483. static _BumpTextureEnabled: boolean;
  15484. static BumpTextureEnabled: boolean;
  15485. static _LightmapTextureEnabled: boolean;
  15486. static LightmapTextureEnabled: boolean;
  15487. static _RefractionTextureEnabled: boolean;
  15488. static RefractionTextureEnabled: boolean;
  15489. static _ColorGradingTextureEnabled: boolean;
  15490. static ColorGradingTextureEnabled: boolean;
  15491. static _FresnelEnabled: boolean;
  15492. static FresnelEnabled: boolean;
  15493. }
  15494. }
  15495. declare module BABYLON {
  15496. class UniformBuffer {
  15497. private _engine;
  15498. private _buffer;
  15499. private _data;
  15500. private _bufferData;
  15501. private _dynamic?;
  15502. private _uniformLocations;
  15503. private _uniformSizes;
  15504. private _uniformLocationPointer;
  15505. private _needSync;
  15506. private _noUBO;
  15507. private _currentEffect;
  15508. private static _MAX_UNIFORM_SIZE;
  15509. private static _tempBuffer;
  15510. /**
  15511. * Wrapper for updateUniform.
  15512. * @method updateMatrix3x3
  15513. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15514. * @param {Float32Array} matrix
  15515. */
  15516. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15517. /**
  15518. * Wrapper for updateUniform.
  15519. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15520. * @param {Float32Array} matrix
  15521. */
  15522. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15523. /**
  15524. * Wrapper for updateUniform.
  15525. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15526. * @param {number} x
  15527. */
  15528. updateFloat: (name: string, x: number) => void;
  15529. /**
  15530. * Wrapper for updateUniform.
  15531. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15532. * @param {number} x
  15533. * @param {number} y
  15534. * @param {string} [suffix] Suffix to add to the uniform name.
  15535. */
  15536. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15537. /**
  15538. * Wrapper for updateUniform.
  15539. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15540. * @param {number} x
  15541. * @param {number} y
  15542. * @param {number} z
  15543. * @param {string} [suffix] Suffix to add to the uniform name.
  15544. */
  15545. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15546. /**
  15547. * Wrapper for updateUniform.
  15548. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15549. * @param {number} x
  15550. * @param {number} y
  15551. * @param {number} z
  15552. * @param {number} w
  15553. * @param {string} [suffix] Suffix to add to the uniform name.
  15554. */
  15555. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15556. /**
  15557. * Wrapper for updateUniform.
  15558. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15559. * @param {Matrix} A 4x4 matrix.
  15560. */
  15561. updateMatrix: (name: string, mat: Matrix) => void;
  15562. /**
  15563. * Wrapper for updateUniform.
  15564. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15565. * @param {Vector3} vector
  15566. */
  15567. updateVector3: (name: string, vector: Vector3) => void;
  15568. /**
  15569. * Wrapper for updateUniform.
  15570. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15571. * @param {Vector4} vector
  15572. */
  15573. updateVector4: (name: string, vector: Vector4) => void;
  15574. /**
  15575. * Wrapper for updateUniform.
  15576. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15577. * @param {Color3} color
  15578. * @param {string} [suffix] Suffix to add to the uniform name.
  15579. */
  15580. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15581. /**
  15582. * Wrapper for updateUniform.
  15583. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15584. * @param {Color3} color
  15585. * @param {number} alpha
  15586. * @param {string} [suffix] Suffix to add to the uniform name.
  15587. */
  15588. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15589. /**
  15590. * Uniform buffer objects.
  15591. *
  15592. * Handles blocks of uniform on the GPU.
  15593. *
  15594. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15595. *
  15596. * For more information, please refer to :
  15597. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15598. */
  15599. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15600. /**
  15601. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15602. * or just falling back on setUniformXXX calls.
  15603. */
  15604. readonly useUbo: boolean;
  15605. /**
  15606. * Indicates if the WebGL underlying uniform buffer is in sync
  15607. * with the javascript cache data.
  15608. */
  15609. readonly isSync: boolean;
  15610. /**
  15611. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15612. * Also, a dynamic UniformBuffer will disable cache verification and always
  15613. * update the underlying WebGL uniform buffer to the GPU.
  15614. */
  15615. isDynamic(): boolean;
  15616. /**
  15617. * The data cache on JS side.
  15618. */
  15619. getData(): Float32Array;
  15620. /**
  15621. * The underlying WebGL Uniform buffer.
  15622. */
  15623. getBuffer(): Nullable<WebGLBuffer>;
  15624. /**
  15625. * std140 layout specifies how to align data within an UBO structure.
  15626. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15627. * for specs.
  15628. */
  15629. private _fillAlignment;
  15630. /**
  15631. * Adds an uniform in the buffer.
  15632. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15633. * for the layout to be correct !
  15634. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15635. * @param {number|number[]} size Data size, or data directly.
  15636. */
  15637. addUniform(name: string, size: number | number[]): void;
  15638. /**
  15639. * Wrapper for addUniform.
  15640. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15641. * @param {Matrix} mat A 4x4 matrix.
  15642. */
  15643. addMatrix(name: string, mat: Matrix): void;
  15644. /**
  15645. * Wrapper for addUniform.
  15646. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15647. * @param {number} x
  15648. * @param {number} y
  15649. */
  15650. addFloat2(name: string, x: number, y: number): void;
  15651. /**
  15652. * Wrapper for addUniform.
  15653. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15654. * @param {number} x
  15655. * @param {number} y
  15656. * @param {number} z
  15657. */
  15658. addFloat3(name: string, x: number, y: number, z: number): void;
  15659. /**
  15660. * Wrapper for addUniform.
  15661. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15662. * @param {Color3} color
  15663. */
  15664. addColor3(name: string, color: Color3): void;
  15665. /**
  15666. * Wrapper for addUniform.
  15667. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15668. * @param {Color3} color
  15669. * @param {number} alpha
  15670. */
  15671. addColor4(name: string, color: Color3, alpha: number): void;
  15672. /**
  15673. * Wrapper for addUniform.
  15674. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15675. * @param {Vector3} vector
  15676. */
  15677. addVector3(name: string, vector: Vector3): void;
  15678. /**
  15679. * Wrapper for addUniform.
  15680. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15681. */
  15682. addMatrix3x3(name: string): void;
  15683. /**
  15684. * Wrapper for addUniform.
  15685. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15686. */
  15687. addMatrix2x2(name: string): void;
  15688. /**
  15689. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15690. */
  15691. create(): void;
  15692. /** @hidden */
  15693. _rebuild(): void;
  15694. /**
  15695. * Updates the WebGL Uniform Buffer on the GPU.
  15696. * If the `dynamic` flag is set to true, no cache comparison is done.
  15697. * Otherwise, the buffer will be updated only if the cache differs.
  15698. */
  15699. update(): void;
  15700. /**
  15701. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15702. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15703. * @param {number[]|Float32Array} data Flattened data
  15704. * @param {number} size Size of the data.
  15705. */
  15706. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15707. private _updateMatrix3x3ForUniform;
  15708. private _updateMatrix3x3ForEffect;
  15709. private _updateMatrix2x2ForEffect;
  15710. private _updateMatrix2x2ForUniform;
  15711. private _updateFloatForEffect;
  15712. private _updateFloatForUniform;
  15713. private _updateFloat2ForEffect;
  15714. private _updateFloat2ForUniform;
  15715. private _updateFloat3ForEffect;
  15716. private _updateFloat3ForUniform;
  15717. private _updateFloat4ForEffect;
  15718. private _updateFloat4ForUniform;
  15719. private _updateMatrixForEffect;
  15720. private _updateMatrixForUniform;
  15721. private _updateVector3ForEffect;
  15722. private _updateVector3ForUniform;
  15723. private _updateVector4ForEffect;
  15724. private _updateVector4ForUniform;
  15725. private _updateColor3ForEffect;
  15726. private _updateColor3ForUniform;
  15727. private _updateColor4ForEffect;
  15728. private _updateColor4ForUniform;
  15729. /**
  15730. * Sets a sampler uniform on the effect.
  15731. * @param {string} name Name of the sampler.
  15732. * @param {Texture} texture
  15733. */
  15734. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15735. /**
  15736. * Directly updates the value of the uniform in the cache AND on the GPU.
  15737. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15738. * @param {number[]|Float32Array} data Flattened data
  15739. */
  15740. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15741. /**
  15742. * Binds this uniform buffer to an effect.
  15743. * @param {Effect} effect
  15744. * @param {string} name Name of the uniform block in the shader.
  15745. */
  15746. bindToEffect(effect: Effect, name: string): void;
  15747. /**
  15748. * Disposes the uniform buffer.
  15749. */
  15750. dispose(): void;
  15751. }
  15752. }
  15753. declare module BABYLON {
  15754. class Scalar {
  15755. /**
  15756. * Two pi constants convenient for computation.
  15757. */
  15758. static TwoPi: number;
  15759. /**
  15760. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15761. */
  15762. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15763. /**
  15764. * Returns a string : the upper case translation of the number i to hexadecimal.
  15765. */
  15766. static ToHex(i: number): string;
  15767. /**
  15768. * Returns -1 if value is negative and +1 is value is positive.
  15769. * Returns the value itself if it's equal to zero.
  15770. */
  15771. static Sign(value: number): number;
  15772. /**
  15773. * Returns the value itself if it's between min and max.
  15774. * Returns min if the value is lower than min.
  15775. * Returns max if the value is greater than max.
  15776. */
  15777. static Clamp(value: number, min?: number, max?: number): number;
  15778. /**
  15779. * Returns the log2 of value.
  15780. */
  15781. static Log2(value: number): number;
  15782. /**
  15783. * Loops the value, so that it is never larger than length and never smaller than 0.
  15784. *
  15785. * This is similar to the modulo operator but it works with floating point numbers.
  15786. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15787. * With t = 5 and length = 2.5, the result would be 0.0.
  15788. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15789. */
  15790. static Repeat(value: number, length: number): number;
  15791. /**
  15792. * Normalize the value between 0.0 and 1.0 using min and max values
  15793. */
  15794. static Normalize(value: number, min: number, max: number): number;
  15795. /**
  15796. * Denormalize the value from 0.0 and 1.0 using min and max values
  15797. */
  15798. static Denormalize(normalized: number, min: number, max: number): number;
  15799. /**
  15800. * Calculates the shortest difference between two given angles given in degrees.
  15801. */
  15802. static DeltaAngle(current: number, target: number): number;
  15803. /**
  15804. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15805. *
  15806. * The returned value will move back and forth between 0 and length
  15807. */
  15808. static PingPong(tx: number, length: number): number;
  15809. /**
  15810. * Interpolates between min and max with smoothing at the limits.
  15811. *
  15812. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15813. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15814. */
  15815. static SmoothStep(from: number, to: number, tx: number): number;
  15816. /**
  15817. * Moves a value current towards target.
  15818. *
  15819. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15820. * Negative values of maxDelta pushes the value away from target.
  15821. */
  15822. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15823. /**
  15824. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15825. *
  15826. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15827. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15828. */
  15829. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15830. /**
  15831. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15832. */
  15833. static Lerp(start: number, end: number, amount: number): number;
  15834. /**
  15835. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15836. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15837. */
  15838. static LerpAngle(start: number, end: number, amount: number): number;
  15839. /**
  15840. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15841. */
  15842. static InverseLerp(a: number, b: number, value: number): number;
  15843. /**
  15844. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15845. */
  15846. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15847. /**
  15848. * Returns a random float number between and min and max values
  15849. */
  15850. static RandomRange(min: number, max: number): number;
  15851. /**
  15852. * This function returns percentage of a number in a given range.
  15853. *
  15854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15856. */
  15857. static RangeToPercent(number: number, min: number, max: number): number;
  15858. /**
  15859. * This function returns number that corresponds to the percentage in a given range.
  15860. *
  15861. * PercentToRange(0.34,0,100) will return 34.
  15862. */
  15863. static PercentToRange(percent: number, min: number, max: number): number;
  15864. /**
  15865. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15866. * @param angle The angle to normalize in radian.
  15867. * @return The converted angle.
  15868. */
  15869. static NormalizeRadians(angle: number): number;
  15870. }
  15871. }
  15872. declare module BABYLON {
  15873. const ToGammaSpace: number;
  15874. const ToLinearSpace = 2.2;
  15875. const Epsilon = 0.001;
  15876. /**
  15877. * Class used to hold a RBG color
  15878. */
  15879. class Color3 {
  15880. /**
  15881. * Defines the red component (between 0 and 1, default is 0)
  15882. */
  15883. r: number;
  15884. /**
  15885. * Defines the green component (between 0 and 1, default is 0)
  15886. */
  15887. g: number;
  15888. /**
  15889. * Defines the blue component (between 0 and 1, default is 0)
  15890. */
  15891. b: number;
  15892. /**
  15893. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15894. * @param r defines the red component (between 0 and 1, default is 0)
  15895. * @param g defines the green component (between 0 and 1, default is 0)
  15896. * @param b defines the blue component (between 0 and 1, default is 0)
  15897. */
  15898. constructor(
  15899. /**
  15900. * Defines the red component (between 0 and 1, default is 0)
  15901. */
  15902. r?: number,
  15903. /**
  15904. * Defines the green component (between 0 and 1, default is 0)
  15905. */
  15906. g?: number,
  15907. /**
  15908. * Defines the blue component (between 0 and 1, default is 0)
  15909. */
  15910. b?: number);
  15911. /**
  15912. * Creates a string with the Color3 current values
  15913. * @returns the string representation of the Color3 object
  15914. */
  15915. toString(): string;
  15916. /**
  15917. * Returns the string "Color3"
  15918. * @returns "Color3"
  15919. */
  15920. getClassName(): string;
  15921. /**
  15922. * Compute the Color3 hash code
  15923. * @returns an unique number that can be used to hash Color3 objects
  15924. */
  15925. getHashCode(): number;
  15926. /**
  15927. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15928. * @param array defines the array where to store the r,g,b components
  15929. * @param index defines an optional index in the target array to define where to start storing values
  15930. * @returns the current Color3 object
  15931. */
  15932. toArray(array: FloatArray, index?: number): Color3;
  15933. /**
  15934. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15935. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15936. * @returns a new {BABYLON.Color4} object
  15937. */
  15938. toColor4(alpha?: number): Color4;
  15939. /**
  15940. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15941. * @returns the new array
  15942. */
  15943. asArray(): number[];
  15944. /**
  15945. * Returns the luminance value
  15946. * @returns a float value
  15947. */
  15948. toLuminance(): number;
  15949. /**
  15950. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15951. * @param otherColor defines the second operand
  15952. * @returns the new Color3 object
  15953. */
  15954. multiply(otherColor: Color3): Color3;
  15955. /**
  15956. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15957. * @param otherColor defines the second operand
  15958. * @param result defines the Color3 object where to store the result
  15959. * @returns the current Color3
  15960. */
  15961. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15962. /**
  15963. * Determines equality between Color3 objects
  15964. * @param otherColor defines the second operand
  15965. * @returns true if the rgb values are equal to the given ones
  15966. */
  15967. equals(otherColor: Color3): boolean;
  15968. /**
  15969. * Determines equality between the current Color3 object and a set of r,b,g values
  15970. * @param r defines the red component to check
  15971. * @param g defines the green component to check
  15972. * @param b defines the blue component to check
  15973. * @returns true if the rgb values are equal to the given ones
  15974. */
  15975. equalsFloats(r: number, g: number, b: number): boolean;
  15976. /**
  15977. * Multiplies in place each rgb value by scale
  15978. * @param scale defines the scaling factor
  15979. * @returns the updated Color3
  15980. */
  15981. scale(scale: number): Color3;
  15982. /**
  15983. * Multiplies the rgb values by scale and stores the result into "result"
  15984. * @param scale defines the scaling factor
  15985. * @param result defines the Color3 object where to store the result
  15986. * @returns the unmodified current Color3
  15987. */
  15988. scaleToRef(scale: number, result: Color3): Color3;
  15989. /**
  15990. * Scale the current Color3 values by a factor and add the result to a given Color3
  15991. * @param scale defines the scale factor
  15992. * @param result defines color to store the result into
  15993. * @returns the unmodified current Color3
  15994. */
  15995. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15996. /**
  15997. * Clamps the rgb values by the min and max values and stores the result into "result"
  15998. * @param min defines minimum clamping value (default is 0)
  15999. * @param max defines maximum clamping value (default is 1)
  16000. * @param result defines color to store the result into
  16001. * @returns the original Color3
  16002. */
  16003. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  16004. /**
  16005. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  16006. * @param otherColor defines the second operand
  16007. * @returns the new Color3
  16008. */
  16009. add(otherColor: Color3): Color3;
  16010. /**
  16011. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  16012. * @param otherColor defines the second operand
  16013. * @param result defines Color3 object to store the result into
  16014. * @returns the unmodified current Color3
  16015. */
  16016. addToRef(otherColor: Color3, result: Color3): Color3;
  16017. /**
  16018. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  16019. * @param otherColor defines the second operand
  16020. * @returns the new Color3
  16021. */
  16022. subtract(otherColor: Color3): Color3;
  16023. /**
  16024. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  16025. * @param otherColor defines the second operand
  16026. * @param result defines Color3 object to store the result into
  16027. * @returns the unmodified current Color3
  16028. */
  16029. subtractToRef(otherColor: Color3, result: Color3): Color3;
  16030. /**
  16031. * Copy the current object
  16032. * @returns a new Color3 copied the current one
  16033. */
  16034. clone(): Color3;
  16035. /**
  16036. * Copies the rgb values from the source in the current Color3
  16037. * @param source defines the source Color3 object
  16038. * @returns the updated Color3 object
  16039. */
  16040. copyFrom(source: Color3): Color3;
  16041. /**
  16042. * Updates the Color3 rgb values from the given floats
  16043. * @param r defines the red component to read from
  16044. * @param g defines the green component to read from
  16045. * @param b defines the blue component to read from
  16046. * @returns the current Color3 object
  16047. */
  16048. copyFromFloats(r: number, g: number, b: number): Color3;
  16049. /**
  16050. * Updates the Color3 rgb values from the given floats
  16051. * @param r defines the red component to read from
  16052. * @param g defines the green component to read from
  16053. * @param b defines the blue component to read from
  16054. * @returns the current Color3 object
  16055. */
  16056. set(r: number, g: number, b: number): Color3;
  16057. /**
  16058. * Compute the Color3 hexadecimal code as a string
  16059. * @returns a string containing the hexadecimal representation of the Color3 object
  16060. */
  16061. toHexString(): string;
  16062. /**
  16063. * Computes a new Color3 converted from the current one to linear space
  16064. * @returns a new Color3 object
  16065. */
  16066. toLinearSpace(): Color3;
  16067. /**
  16068. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  16069. * @param convertedColor defines the Color3 object where to store the linear space version
  16070. * @returns the unmodified Color3
  16071. */
  16072. toLinearSpaceToRef(convertedColor: Color3): Color3;
  16073. /**
  16074. * Computes a new Color3 converted from the current one to gamma space
  16075. * @returns a new Color3 object
  16076. */
  16077. toGammaSpace(): Color3;
  16078. /**
  16079. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  16080. * @param convertedColor defines the Color3 object where to store the gamma space version
  16081. * @returns the unmodified Color3
  16082. */
  16083. toGammaSpaceToRef(convertedColor: Color3): Color3;
  16084. /**
  16085. * Creates a new Color3 from the string containing valid hexadecimal values
  16086. * @param hex defines a string containing valid hexadecimal values
  16087. * @returns a new Color3 object
  16088. */
  16089. static FromHexString(hex: string): Color3;
  16090. /**
  16091. * Creates a new Vector3 from the starting index of the given array
  16092. * @param array defines the source array
  16093. * @param offset defines an offset in the source array
  16094. * @returns a new Color3 object
  16095. */
  16096. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  16097. /**
  16098. * Creates a new Color3 from integer values (< 256)
  16099. * @param r defines the red component to read from (value between 0 and 255)
  16100. * @param g defines the green component to read from (value between 0 and 255)
  16101. * @param b defines the blue component to read from (value between 0 and 255)
  16102. * @returns a new Color3 object
  16103. */
  16104. static FromInts(r: number, g: number, b: number): Color3;
  16105. /**
  16106. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  16107. * @param start defines the start Color3 value
  16108. * @param end defines the end Color3 value
  16109. * @param amount defines the gradient value between start and end
  16110. * @returns a new Color3 object
  16111. */
  16112. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  16113. /**
  16114. * Returns a Color3 value containing a red color
  16115. * @returns a new Color3 object
  16116. */
  16117. static Red(): Color3;
  16118. /**
  16119. * Returns a Color3 value containing a green color
  16120. * @returns a new Color3 object
  16121. */
  16122. static Green(): Color3;
  16123. /**
  16124. * Returns a Color3 value containing a blue color
  16125. * @returns a new Color3 object
  16126. */
  16127. static Blue(): Color3;
  16128. /**
  16129. * Returns a Color3 value containing a black color
  16130. * @returns a new Color3 object
  16131. */
  16132. static Black(): Color3;
  16133. /**
  16134. * Returns a Color3 value containing a white color
  16135. * @returns a new Color3 object
  16136. */
  16137. static White(): Color3;
  16138. /**
  16139. * Returns a Color3 value containing a purple color
  16140. * @returns a new Color3 object
  16141. */
  16142. static Purple(): Color3;
  16143. /**
  16144. * Returns a Color3 value containing a magenta color
  16145. * @returns a new Color3 object
  16146. */
  16147. static Magenta(): Color3;
  16148. /**
  16149. * Returns a Color3 value containing a yellow color
  16150. * @returns a new Color3 object
  16151. */
  16152. static Yellow(): Color3;
  16153. /**
  16154. * Returns a Color3 value containing a gray color
  16155. * @returns a new Color3 object
  16156. */
  16157. static Gray(): Color3;
  16158. /**
  16159. * Returns a Color3 value containing a teal color
  16160. * @returns a new Color3 object
  16161. */
  16162. static Teal(): Color3;
  16163. /**
  16164. * Returns a Color3 value containing a random color
  16165. * @returns a new Color3 object
  16166. */
  16167. static Random(): Color3;
  16168. }
  16169. /**
  16170. * Class used to hold a RBGA color
  16171. */
  16172. class Color4 {
  16173. /**
  16174. * Defines the red component (between 0 and 1, default is 0)
  16175. */
  16176. r: number;
  16177. /**
  16178. * Defines the green component (between 0 and 1, default is 0)
  16179. */
  16180. g: number;
  16181. /**
  16182. * Defines the blue component (between 0 and 1, default is 0)
  16183. */
  16184. b: number;
  16185. /**
  16186. * Defines the alpha component (between 0 and 1, default is 1)
  16187. */
  16188. a: number;
  16189. /**
  16190. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  16191. * @param r defines the red component (between 0 and 1, default is 0)
  16192. * @param g defines the green component (between 0 and 1, default is 0)
  16193. * @param b defines the blue component (between 0 and 1, default is 0)
  16194. * @param a defines the alpha component (between 0 and 1, default is 1)
  16195. */
  16196. constructor(
  16197. /**
  16198. * Defines the red component (between 0 and 1, default is 0)
  16199. */
  16200. r?: number,
  16201. /**
  16202. * Defines the green component (between 0 and 1, default is 0)
  16203. */
  16204. g?: number,
  16205. /**
  16206. * Defines the blue component (between 0 and 1, default is 0)
  16207. */
  16208. b?: number,
  16209. /**
  16210. * Defines the alpha component (between 0 and 1, default is 1)
  16211. */
  16212. a?: number);
  16213. /**
  16214. * Adds in place the given Color4 values to the current Color4 object
  16215. * @param right defines the second operand
  16216. * @returns the current updated Color4 object
  16217. */
  16218. addInPlace(right: Color4): Color4;
  16219. /**
  16220. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  16221. * @returns the new array
  16222. */
  16223. asArray(): number[];
  16224. /**
  16225. * Stores from the starting index in the given array the Color4 successive values
  16226. * @param array defines the array where to store the r,g,b components
  16227. * @param index defines an optional index in the target array to define where to start storing values
  16228. * @returns the current Color4 object
  16229. */
  16230. toArray(array: number[], index?: number): Color4;
  16231. /**
  16232. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  16233. * @param right defines the second operand
  16234. * @returns a new Color4 object
  16235. */
  16236. add(right: Color4): Color4;
  16237. /**
  16238. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  16239. * @param right defines the second operand
  16240. * @returns a new Color4 object
  16241. */
  16242. subtract(right: Color4): Color4;
  16243. /**
  16244. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16245. * @param right defines the second operand
  16246. * @param result defines the Color4 object where to store the result
  16247. * @returns the current Color4 object
  16248. */
  16249. subtractToRef(right: Color4, result: Color4): Color4;
  16250. /**
  16251. * Creates a new Color4 with the current Color4 values multiplied by scale
  16252. * @param scale defines the scaling factor to apply
  16253. * @returns a new Color4 object
  16254. */
  16255. scale(scale: number): Color4;
  16256. /**
  16257. * Multiplies the current Color4 values by scale and stores the result in "result"
  16258. * @param scale defines the scaling factor to apply
  16259. * @param result defines the Color4 object where to store the result
  16260. * @returns the current unmodified Color4
  16261. */
  16262. scaleToRef(scale: number, result: Color4): Color4;
  16263. /**
  16264. * Scale the current Color4 values by a factor and add the result to a given Color4
  16265. * @param scale defines the scale factor
  16266. * @param result defines the Color4 object where to store the result
  16267. * @returns the unmodified current Color4
  16268. */
  16269. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16270. /**
  16271. * Clamps the rgb values by the min and max values and stores the result into "result"
  16272. * @param min defines minimum clamping value (default is 0)
  16273. * @param max defines maximum clamping value (default is 1)
  16274. * @param result defines color to store the result into.
  16275. * @returns the cuurent Color4
  16276. */
  16277. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16278. /**
  16279. * Multipy an Color4 value by another and return a new Color4 object
  16280. * @param color defines the Color4 value to multiply by
  16281. * @returns a new Color4 object
  16282. */
  16283. multiply(color: Color4): Color4;
  16284. /**
  16285. * Multipy a Color4 value by another and push the result in a reference value
  16286. * @param color defines the Color4 value to multiply by
  16287. * @param result defines the Color4 to fill the result in
  16288. * @returns the result Color4
  16289. */
  16290. multiplyToRef(color: Color4, result: Color4): Color4;
  16291. /**
  16292. * Creates a string with the Color4 current values
  16293. * @returns the string representation of the Color4 object
  16294. */
  16295. toString(): string;
  16296. /**
  16297. * Returns the string "Color4"
  16298. * @returns "Color4"
  16299. */
  16300. getClassName(): string;
  16301. /**
  16302. * Compute the Color4 hash code
  16303. * @returns an unique number that can be used to hash Color4 objects
  16304. */
  16305. getHashCode(): number;
  16306. /**
  16307. * Creates a new Color4 copied from the current one
  16308. * @returns a new Color4 object
  16309. */
  16310. clone(): Color4;
  16311. /**
  16312. * Copies the given Color4 values into the current one
  16313. * @param source defines the source Color4 object
  16314. * @returns the current updated Color4 object
  16315. */
  16316. copyFrom(source: Color4): Color4;
  16317. /**
  16318. * Copies the given float values into the current one
  16319. * @param r defines the red component to read from
  16320. * @param g defines the green component to read from
  16321. * @param b defines the blue component to read from
  16322. * @param a defines the alpha component to read from
  16323. * @returns the current updated Color4 object
  16324. */
  16325. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16326. /**
  16327. * Copies the given float values into the current one
  16328. * @param r defines the red component to read from
  16329. * @param g defines the green component to read from
  16330. * @param b defines the blue component to read from
  16331. * @param a defines the alpha component to read from
  16332. * @returns the current updated Color4 object
  16333. */
  16334. set(r: number, g: number, b: number, a: number): Color4;
  16335. /**
  16336. * Compute the Color4 hexadecimal code as a string
  16337. * @returns a string containing the hexadecimal representation of the Color4 object
  16338. */
  16339. toHexString(): string;
  16340. /**
  16341. * Computes a new Color4 converted from the current one to linear space
  16342. * @returns a new Color4 object
  16343. */
  16344. toLinearSpace(): Color4;
  16345. /**
  16346. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16347. * @param convertedColor defines the Color4 object where to store the linear space version
  16348. * @returns the unmodified Color4
  16349. */
  16350. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16351. /**
  16352. * Computes a new Color4 converted from the current one to gamma space
  16353. * @returns a new Color4 object
  16354. */
  16355. toGammaSpace(): Color4;
  16356. /**
  16357. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16358. * @param convertedColor defines the Color4 object where to store the gamma space version
  16359. * @returns the unmodified Color4
  16360. */
  16361. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16362. /**
  16363. * Creates a new Color4 from the string containing valid hexadecimal values
  16364. * @param hex defines a string containing valid hexadecimal values
  16365. * @returns a new Color4 object
  16366. */
  16367. static FromHexString(hex: string): Color4;
  16368. /**
  16369. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16370. * @param left defines the start value
  16371. * @param right defines the end value
  16372. * @param amount defines the gradient factor
  16373. * @returns a new Color4 object
  16374. */
  16375. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16376. /**
  16377. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16378. * @param left defines the start value
  16379. * @param right defines the end value
  16380. * @param amount defines the gradient factor
  16381. * @param result defines the Color4 object where to store data
  16382. */
  16383. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16384. /**
  16385. * Creates a new Color4 from the starting index element of the given array
  16386. * @param array defines the source array to read from
  16387. * @param offset defines the offset in the source array
  16388. * @returns a new Color4 object
  16389. */
  16390. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16391. /**
  16392. * Creates a new Color3 from integer values (< 256)
  16393. * @param r defines the red component to read from (value between 0 and 255)
  16394. * @param g defines the green component to read from (value between 0 and 255)
  16395. * @param b defines the blue component to read from (value between 0 and 255)
  16396. * @param a defines the alpha component to read from (value between 0 and 255)
  16397. * @returns a new Color3 object
  16398. */
  16399. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16400. /**
  16401. * Check the content of a given array and convert it to an array containing RGBA data
  16402. * If the original array was already containing count * 4 values then it is returned directly
  16403. * @param colors defines the array to check
  16404. * @param count defines the number of RGBA data to expect
  16405. * @returns an array containing count * 4 values (RGBA)
  16406. */
  16407. static CheckColors4(colors: number[], count: number): number[];
  16408. }
  16409. /**
  16410. * Class representing a vector containing 2 coordinates
  16411. */
  16412. class Vector2 {
  16413. /** defines the first coordinate */
  16414. x: number;
  16415. /** defines the second coordinate */
  16416. y: number;
  16417. /**
  16418. * Creates a new Vector2 from the given x and y coordinates
  16419. * @param x defines the first coordinate
  16420. * @param y defines the second coordinate
  16421. */
  16422. constructor(
  16423. /** defines the first coordinate */
  16424. x?: number,
  16425. /** defines the second coordinate */
  16426. y?: number);
  16427. /**
  16428. * Gets a string with the Vector2 coordinates
  16429. * @returns a string with the Vector2 coordinates
  16430. */
  16431. toString(): string;
  16432. /**
  16433. * Gets class name
  16434. * @returns the string "Vector2"
  16435. */
  16436. getClassName(): string;
  16437. /**
  16438. * Gets current vector hash code
  16439. * @returns the Vector2 hash code as a number
  16440. */
  16441. getHashCode(): number;
  16442. /**
  16443. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16444. * @param array defines the source array
  16445. * @param index defines the offset in source array
  16446. * @returns the current Vector2
  16447. */
  16448. toArray(array: FloatArray, index?: number): Vector2;
  16449. /**
  16450. * Copy the current vector to an array
  16451. * @returns a new array with 2 elements: the Vector2 coordinates.
  16452. */
  16453. asArray(): number[];
  16454. /**
  16455. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16456. * @param source defines the source Vector2
  16457. * @returns the current updated Vector2
  16458. */
  16459. copyFrom(source: Vector2): Vector2;
  16460. /**
  16461. * Sets the Vector2 coordinates with the given floats
  16462. * @param x defines the first coordinate
  16463. * @param y defines the second coordinate
  16464. * @returns the current updated Vector2
  16465. */
  16466. copyFromFloats(x: number, y: number): Vector2;
  16467. /**
  16468. * Sets the Vector2 coordinates with the given floats
  16469. * @param x defines the first coordinate
  16470. * @param y defines the second coordinate
  16471. * @returns the current updated Vector2
  16472. */
  16473. set(x: number, y: number): Vector2;
  16474. /**
  16475. * Add another vector with the current one
  16476. * @param otherVector defines the other vector
  16477. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16478. */
  16479. add(otherVector: Vector2): Vector2;
  16480. /**
  16481. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16482. * @param otherVector defines the other vector
  16483. * @param result defines the target vector
  16484. * @returns the unmodified current Vector2
  16485. */
  16486. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16487. /**
  16488. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16489. * @param otherVector defines the other vector
  16490. * @returns the current updated Vector2
  16491. */
  16492. addInPlace(otherVector: Vector2): Vector2;
  16493. /**
  16494. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16495. * @param otherVector defines the other vector
  16496. * @returns a new Vector2
  16497. */
  16498. addVector3(otherVector: Vector3): Vector2;
  16499. /**
  16500. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16501. * @param otherVector defines the other vector
  16502. * @returns a new Vector2
  16503. */
  16504. subtract(otherVector: Vector2): Vector2;
  16505. /**
  16506. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16507. * @param otherVector defines the other vector
  16508. * @param result defines the target vector
  16509. * @returns the unmodified current Vector2
  16510. */
  16511. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16512. /**
  16513. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16514. * @param otherVector defines the other vector
  16515. * @returns the current updated Vector2
  16516. */
  16517. subtractInPlace(otherVector: Vector2): Vector2;
  16518. /**
  16519. * Multiplies in place the current Vector2 coordinates by the given ones
  16520. * @param otherVector defines the other vector
  16521. * @returns the current updated Vector2
  16522. */
  16523. multiplyInPlace(otherVector: Vector2): Vector2;
  16524. /**
  16525. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16526. * @param otherVector defines the other vector
  16527. * @returns a new Vector2
  16528. */
  16529. multiply(otherVector: Vector2): Vector2;
  16530. /**
  16531. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16532. * @param otherVector defines the other vector
  16533. * @param result defines the target vector
  16534. * @returns the unmodified current Vector2
  16535. */
  16536. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16537. /**
  16538. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16539. * @param x defines the first coordinate
  16540. * @param y defines the second coordinate
  16541. * @returns a new Vector2
  16542. */
  16543. multiplyByFloats(x: number, y: number): Vector2;
  16544. /**
  16545. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16546. * @param otherVector defines the other vector
  16547. * @returns a new Vector2
  16548. */
  16549. divide(otherVector: Vector2): Vector2;
  16550. /**
  16551. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16552. * @param otherVector defines the other vector
  16553. * @param result defines the target vector
  16554. * @returns the unmodified current Vector2
  16555. */
  16556. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16557. /**
  16558. * Divides the current Vector2 coordinates by the given ones
  16559. * @param otherVector defines the other vector
  16560. * @returns the current updated Vector2
  16561. */
  16562. divideInPlace(otherVector: Vector2): Vector2;
  16563. /**
  16564. * Gets a new Vector2 with current Vector2 negated coordinates
  16565. * @returns a new Vector2
  16566. */
  16567. negate(): Vector2;
  16568. /**
  16569. * Multiply the Vector2 coordinates by scale
  16570. * @param scale defines the scaling factor
  16571. * @returns the current updated Vector2
  16572. */
  16573. scaleInPlace(scale: number): Vector2;
  16574. /**
  16575. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16576. * @param scale defines the scaling factor
  16577. * @returns a new Vector2
  16578. */
  16579. scale(scale: number): Vector2;
  16580. /**
  16581. * Scale the current Vector2 values by a factor to a given Vector2
  16582. * @param scale defines the scale factor
  16583. * @param result defines the Vector2 object where to store the result
  16584. * @returns the unmodified current Vector2
  16585. */
  16586. scaleToRef(scale: number, result: Vector2): Vector2;
  16587. /**
  16588. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16589. * @param scale defines the scale factor
  16590. * @param result defines the Vector2 object where to store the result
  16591. * @returns the unmodified current Vector2
  16592. */
  16593. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16594. /**
  16595. * Gets a boolean if two vectors are equals
  16596. * @param otherVector defines the other vector
  16597. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16598. */
  16599. equals(otherVector: Vector2): boolean;
  16600. /**
  16601. * Gets a boolean if two vectors are equals (using an epsilon value)
  16602. * @param otherVector defines the other vector
  16603. * @param epsilon defines the minimal distance to consider equality
  16604. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16605. */
  16606. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16607. /**
  16608. * Gets a new Vector2 from current Vector2 floored values
  16609. * @returns a new Vector2
  16610. */
  16611. floor(): Vector2;
  16612. /**
  16613. * Gets a new Vector2 from current Vector2 floored values
  16614. * @returns a new Vector2
  16615. */
  16616. fract(): Vector2;
  16617. /**
  16618. * Gets the length of the vector
  16619. * @returns the vector length (float)
  16620. */
  16621. length(): number;
  16622. /**
  16623. * Gets the vector squared length
  16624. * @returns the vector squared length (float)
  16625. */
  16626. lengthSquared(): number;
  16627. /**
  16628. * Normalize the vector
  16629. * @returns the current updated Vector2
  16630. */
  16631. normalize(): Vector2;
  16632. /**
  16633. * Gets a new Vector2 copied from the Vector2
  16634. * @returns a new Vector2
  16635. */
  16636. clone(): Vector2;
  16637. /**
  16638. * Gets a new Vector2(0, 0)
  16639. * @returns a new Vector2
  16640. */
  16641. static Zero(): Vector2;
  16642. /**
  16643. * Gets a new Vector2(1, 1)
  16644. * @returns a new Vector2
  16645. */
  16646. static One(): Vector2;
  16647. /**
  16648. * Gets a new Vector2 set from the given index element of the given array
  16649. * @param array defines the data source
  16650. * @param offset defines the offset in the data source
  16651. * @returns a new Vector2
  16652. */
  16653. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16654. /**
  16655. * Sets "result" from the given index element of the given array
  16656. * @param array defines the data source
  16657. * @param offset defines the offset in the data source
  16658. * @param result defines the target vector
  16659. */
  16660. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16661. /**
  16662. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16663. * @param value1 defines 1st point of control
  16664. * @param value2 defines 2nd point of control
  16665. * @param value3 defines 3rd point of control
  16666. * @param value4 defines 4th point of control
  16667. * @param amount defines the interpolation factor
  16668. * @returns a new Vector2
  16669. */
  16670. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16671. /**
  16672. * 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".
  16673. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16674. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16675. * @param value defines the value to clamp
  16676. * @param min defines the lower limit
  16677. * @param max defines the upper limit
  16678. * @returns a new Vector2
  16679. */
  16680. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16681. /**
  16682. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16683. * @param value1 defines the 1st control point
  16684. * @param tangent1 defines the outgoing tangent
  16685. * @param value2 defines the 2nd control point
  16686. * @param tangent2 defines the incoming tangent
  16687. * @param amount defines the interpolation factor
  16688. * @returns a new Vector2
  16689. */
  16690. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16691. /**
  16692. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16693. * @param start defines the start vector
  16694. * @param end defines the end vector
  16695. * @param amount defines the interpolation factor
  16696. * @returns a new Vector2
  16697. */
  16698. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16699. /**
  16700. * Gets the dot product of the vector "left" and the vector "right"
  16701. * @param left defines first vector
  16702. * @param right defines second vector
  16703. * @returns the dot product (float)
  16704. */
  16705. static Dot(left: Vector2, right: Vector2): number;
  16706. /**
  16707. * Returns a new Vector2 equal to the normalized given vector
  16708. * @param vector defines the vector to normalize
  16709. * @returns a new Vector2
  16710. */
  16711. static Normalize(vector: Vector2): Vector2;
  16712. /**
  16713. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16714. * @param left defines 1st vector
  16715. * @param right defines 2nd vector
  16716. * @returns a new Vector2
  16717. */
  16718. static Minimize(left: Vector2, right: Vector2): Vector2;
  16719. /**
  16720. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16721. * @param left defines 1st vector
  16722. * @param right defines 2nd vector
  16723. * @returns a new Vector2
  16724. */
  16725. static Maximize(left: Vector2, right: Vector2): Vector2;
  16726. /**
  16727. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16728. * @param vector defines the vector to transform
  16729. * @param transformation defines the matrix to apply
  16730. * @returns a new Vector2
  16731. */
  16732. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16733. /**
  16734. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16735. * @param vector defines the vector to transform
  16736. * @param transformation defines the matrix to apply
  16737. * @param result defines the target vector
  16738. */
  16739. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16740. /**
  16741. * Determines if a given vector is included in a triangle
  16742. * @param p defines the vector to test
  16743. * @param p0 defines 1st triangle point
  16744. * @param p1 defines 2nd triangle point
  16745. * @param p2 defines 3rd triangle point
  16746. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16747. */
  16748. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16749. /**
  16750. * Gets the distance between the vectors "value1" and "value2"
  16751. * @param value1 defines first vector
  16752. * @param value2 defines second vector
  16753. * @returns the distance between vectors
  16754. */
  16755. static Distance(value1: Vector2, value2: Vector2): number;
  16756. /**
  16757. * Returns the squared distance between the vectors "value1" and "value2"
  16758. * @param value1 defines first vector
  16759. * @param value2 defines second vector
  16760. * @returns the squared distance between vectors
  16761. */
  16762. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16763. /**
  16764. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16765. * @param value1 defines first vector
  16766. * @param value2 defines second vector
  16767. * @returns a new Vector2
  16768. */
  16769. static Center(value1: Vector2, value2: Vector2): Vector2;
  16770. /**
  16771. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16772. * @param p defines the middle point
  16773. * @param segA defines one point of the segment
  16774. * @param segB defines the other point of the segment
  16775. * @returns the shortest distance
  16776. */
  16777. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16778. }
  16779. /**
  16780. * Classed used to store (x,y,z) vector representation
  16781. * A Vector3 is the main object used in 3D geometry
  16782. * It can represent etiher the coordinates of a point the space, either a direction
  16783. * Reminder: Babylon.js uses a left handed forward facing system
  16784. */
  16785. class Vector3 {
  16786. /**
  16787. * Defines the first coordinates (on X axis)
  16788. */
  16789. x: number;
  16790. /**
  16791. * Defines the second coordinates (on Y axis)
  16792. */
  16793. y: number;
  16794. /**
  16795. * Defines the third coordinates (on Z axis)
  16796. */
  16797. z: number;
  16798. /**
  16799. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16800. * @param x defines the first coordinates (on X axis)
  16801. * @param y defines the second coordinates (on Y axis)
  16802. * @param z defines the third coordinates (on Z axis)
  16803. */
  16804. constructor(
  16805. /**
  16806. * Defines the first coordinates (on X axis)
  16807. */
  16808. x?: number,
  16809. /**
  16810. * Defines the second coordinates (on Y axis)
  16811. */
  16812. y?: number,
  16813. /**
  16814. * Defines the third coordinates (on Z axis)
  16815. */
  16816. z?: number);
  16817. /**
  16818. * Creates a string representation of the Vector3
  16819. * @returns a string with the Vector3 coordinates.
  16820. */
  16821. toString(): string;
  16822. /**
  16823. * Gets the class name
  16824. * @returns the string "Vector3"
  16825. */
  16826. getClassName(): string;
  16827. /**
  16828. * Creates the Vector3 hash code
  16829. * @returns a number which tends to be unique between Vector3 instances
  16830. */
  16831. getHashCode(): number;
  16832. /**
  16833. * Creates an array containing three elements : the coordinates of the Vector3
  16834. * @returns a new array of numbers
  16835. */
  16836. asArray(): number[];
  16837. /**
  16838. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16839. * @param array defines the destination array
  16840. * @param index defines the offset in the destination array
  16841. * @returns the current Vector3
  16842. */
  16843. toArray(array: FloatArray, index?: number): Vector3;
  16844. /**
  16845. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16846. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16847. */
  16848. toQuaternion(): Quaternion;
  16849. /**
  16850. * Adds the given vector to the current Vector3
  16851. * @param otherVector defines the second operand
  16852. * @returns the current updated Vector3
  16853. */
  16854. addInPlace(otherVector: Vector3): Vector3;
  16855. /**
  16856. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16857. * @param otherVector defines the second operand
  16858. * @returns the resulting Vector3
  16859. */
  16860. add(otherVector: Vector3): Vector3;
  16861. /**
  16862. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16863. * @param otherVector defines the second operand
  16864. * @param result defines the Vector3 object where to store the result
  16865. * @returns the current Vector3
  16866. */
  16867. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16868. /**
  16869. * Subtract the given vector from the current Vector3
  16870. * @param otherVector defines the second operand
  16871. * @returns the current updated Vector3
  16872. */
  16873. subtractInPlace(otherVector: Vector3): Vector3;
  16874. /**
  16875. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16876. * @param otherVector defines the second operand
  16877. * @returns the resulting Vector3
  16878. */
  16879. subtract(otherVector: Vector3): Vector3;
  16880. /**
  16881. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16882. * @param otherVector defines the second operand
  16883. * @param result defines the Vector3 object where to store the result
  16884. * @returns the current Vector3
  16885. */
  16886. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16887. /**
  16888. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16889. * @param x defines the x coordinate of the operand
  16890. * @param y defines the y coordinate of the operand
  16891. * @param z defines the z coordinate of the operand
  16892. * @returns the resulting Vector3
  16893. */
  16894. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16895. /**
  16896. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16897. * @param x defines the x coordinate of the operand
  16898. * @param y defines the y coordinate of the operand
  16899. * @param z defines the z coordinate of the operand
  16900. * @param result defines the Vector3 object where to store the result
  16901. * @returns the current Vector3
  16902. */
  16903. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16904. /**
  16905. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16906. * @returns a new Vector3
  16907. */
  16908. negate(): Vector3;
  16909. /**
  16910. * Multiplies the Vector3 coordinates by the float "scale"
  16911. * @param scale defines the multiplier factor
  16912. * @returns the current updated Vector3
  16913. */
  16914. scaleInPlace(scale: number): Vector3;
  16915. /**
  16916. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16917. * @param scale defines the multiplier factor
  16918. * @returns a new Vector3
  16919. */
  16920. scale(scale: number): Vector3;
  16921. /**
  16922. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16923. * @param scale defines the multiplier factor
  16924. * @param result defines the Vector3 object where to store the result
  16925. * @returns the current Vector3
  16926. */
  16927. scaleToRef(scale: number, result: Vector3): Vector3;
  16928. /**
  16929. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16930. * @param scale defines the scale factor
  16931. * @param result defines the Vector3 object where to store the result
  16932. * @returns the unmodified current Vector3
  16933. */
  16934. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16935. /**
  16936. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16937. * @param otherVector defines the second operand
  16938. * @returns true if both vectors are equals
  16939. */
  16940. equals(otherVector: Vector3): boolean;
  16941. /**
  16942. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16943. * @param otherVector defines the second operand
  16944. * @param epsilon defines the minimal distance to define values as equals
  16945. * @returns true if both vectors are distant less than epsilon
  16946. */
  16947. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16948. /**
  16949. * Returns true if the current Vector3 coordinates equals the given floats
  16950. * @param x defines the x coordinate of the operand
  16951. * @param y defines the y coordinate of the operand
  16952. * @param z defines the z coordinate of the operand
  16953. * @returns true if both vectors are equals
  16954. */
  16955. equalsToFloats(x: number, y: number, z: number): boolean;
  16956. /**
  16957. * Multiplies the current Vector3 coordinates by the given ones
  16958. * @param otherVector defines the second operand
  16959. * @returns the current updated Vector3
  16960. */
  16961. multiplyInPlace(otherVector: Vector3): Vector3;
  16962. /**
  16963. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16964. * @param otherVector defines the second operand
  16965. * @returns the new Vector3
  16966. */
  16967. multiply(otherVector: Vector3): Vector3;
  16968. /**
  16969. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16970. * @param otherVector defines the second operand
  16971. * @param result defines the Vector3 object where to store the result
  16972. * @returns the current Vector3
  16973. */
  16974. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16975. /**
  16976. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16977. * @param x defines the x coordinate of the operand
  16978. * @param y defines the y coordinate of the operand
  16979. * @param z defines the z coordinate of the operand
  16980. * @returns the new Vector3
  16981. */
  16982. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16983. /**
  16984. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16985. * @param otherVector defines the second operand
  16986. * @returns the new Vector3
  16987. */
  16988. divide(otherVector: Vector3): Vector3;
  16989. /**
  16990. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16991. * @param otherVector defines the second operand
  16992. * @param result defines the Vector3 object where to store the result
  16993. * @returns the current Vector3
  16994. */
  16995. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16996. /**
  16997. * Divides the current Vector3 coordinates by the given ones.
  16998. * @param otherVector defines the second operand
  16999. * @returns the current updated Vector3
  17000. */
  17001. divideInPlace(otherVector: Vector3): Vector3;
  17002. /**
  17003. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  17004. * @param other defines the second operand
  17005. * @returns the current updated Vector3
  17006. */
  17007. minimizeInPlace(other: Vector3): Vector3;
  17008. /**
  17009. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  17010. * @param other defines the second operand
  17011. * @returns the current updated Vector3
  17012. */
  17013. maximizeInPlace(other: Vector3): Vector3;
  17014. /**
  17015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  17016. */
  17017. readonly isNonUniform: boolean;
  17018. /**
  17019. * Gets a new Vector3 from current Vector3 floored values
  17020. * @returns a new Vector3
  17021. */
  17022. floor(): Vector3;
  17023. /**
  17024. * Gets a new Vector3 from current Vector3 floored values
  17025. * @returns a new Vector3
  17026. */
  17027. fract(): Vector3;
  17028. /**
  17029. * Gets the length of the Vector3
  17030. * @returns the length of the Vecto3
  17031. */
  17032. length(): number;
  17033. /**
  17034. * Gets the squared length of the Vector3
  17035. * @returns squared length of the Vector3
  17036. */
  17037. lengthSquared(): number;
  17038. /**
  17039. * Normalize the current Vector3.
  17040. * Please note that this is an in place operation.
  17041. * @returns the current updated Vector3
  17042. */
  17043. normalize(): Vector3;
  17044. /**
  17045. * Normalize the current Vector3 to a new vector
  17046. * @returns the new Vector3
  17047. */
  17048. normalizeToNew(): Vector3;
  17049. /**
  17050. * Normalize the current Vector3 to the reference
  17051. * @param reference define the Vector3 to update
  17052. * @returns the updated Vector3
  17053. */
  17054. normalizeToRef(reference: Vector3): Vector3;
  17055. /**
  17056. * Creates a new Vector3 copied from the current Vector3
  17057. * @returns the new Vector3
  17058. */
  17059. clone(): Vector3;
  17060. /**
  17061. * Copies the given vector coordinates to the current Vector3 ones
  17062. * @param source defines the source Vector3
  17063. * @returns the current updated Vector3
  17064. */
  17065. copyFrom(source: Vector3): Vector3;
  17066. /**
  17067. * Copies the given floats to the current Vector3 coordinates
  17068. * @param x defines the x coordinate of the operand
  17069. * @param y defines the y coordinate of the operand
  17070. * @param z defines the z coordinate of the operand
  17071. * @returns the current updated Vector3
  17072. */
  17073. copyFromFloats(x: number, y: number, z: number): Vector3;
  17074. /**
  17075. * Copies the given floats to the current Vector3 coordinates
  17076. * @param x defines the x coordinate of the operand
  17077. * @param y defines the y coordinate of the operand
  17078. * @param z defines the z coordinate of the operand
  17079. * @returns the current updated Vector3
  17080. */
  17081. set(x: number, y: number, z: number): Vector3;
  17082. /**
  17083. * Get the clip factor between two vectors
  17084. * @param vector0 defines the first operand
  17085. * @param vector1 defines the second operand
  17086. * @param axis defines the axis to use
  17087. * @param size defines the size along the axis
  17088. * @returns the clip factor
  17089. */
  17090. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  17091. /**
  17092. * Get angle between two vectors
  17093. * @param vector0 angle between vector0 and vector1
  17094. * @param vector1 angle between vector0 and vector1
  17095. * @param normal direction of the normal
  17096. * @return the angle between vector0 and vector1
  17097. */
  17098. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  17099. /**
  17100. * Returns a new Vector3 set from the index "offset" of the given array
  17101. * @param array defines the source array
  17102. * @param offset defines the offset in the source array
  17103. * @returns the new Vector3
  17104. */
  17105. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  17106. /**
  17107. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  17108. * This function is deprecated. Use FromArray instead
  17109. * @param array defines the source array
  17110. * @param offset defines the offset in the source array
  17111. * @returns the new Vector3
  17112. */
  17113. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  17114. /**
  17115. * Sets the given vector "result" with the element values from the index "offset" of the given array
  17116. * @param array defines the source array
  17117. * @param offset defines the offset in the source array
  17118. * @param result defines the Vector3 where to store the result
  17119. */
  17120. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  17121. /**
  17122. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  17123. * This function is deprecated. Use FromArrayToRef instead.
  17124. * @param array defines the source array
  17125. * @param offset defines the offset in the source array
  17126. * @param result defines the Vector3 where to store the result
  17127. */
  17128. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  17129. /**
  17130. * Sets the given vector "result" with the given floats.
  17131. * @param x defines the x coordinate of the source
  17132. * @param y defines the y coordinate of the source
  17133. * @param z defines the z coordinate of the source
  17134. * @param result defines the Vector3 where to store the result
  17135. */
  17136. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  17137. /**
  17138. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  17139. * @returns a new empty Vector3
  17140. */
  17141. static Zero(): Vector3;
  17142. /**
  17143. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  17144. * @returns a new unit Vector3
  17145. */
  17146. static One(): Vector3;
  17147. /**
  17148. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  17149. * @returns a new up Vector3
  17150. */
  17151. static Up(): Vector3;
  17152. /**
  17153. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  17154. * @returns a new down Vector3
  17155. */
  17156. static Down(): Vector3;
  17157. /**
  17158. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  17159. * @returns a new forward Vector3
  17160. */
  17161. static Forward(): Vector3;
  17162. /**
  17163. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  17164. * @returns a new right Vector3
  17165. */
  17166. static Right(): Vector3;
  17167. /**
  17168. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  17169. * @returns a new left Vector3
  17170. */
  17171. static Left(): Vector3;
  17172. /**
  17173. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  17174. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17175. * @param vector defines the Vector3 to transform
  17176. * @param transformation defines the transformation matrix
  17177. * @returns the transformed Vector3
  17178. */
  17179. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  17180. /**
  17181. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  17182. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17183. * @param vector defines the Vector3 to transform
  17184. * @param transformation defines the transformation matrix
  17185. * @param result defines the Vector3 where to store the result
  17186. */
  17187. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17188. /**
  17189. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  17190. * This method computes tranformed coordinates only, not transformed direction vectors
  17191. * @param x define the x coordinate of the source vector
  17192. * @param y define the y coordinate of the source vector
  17193. * @param z define the z coordinate of the source vector
  17194. * @param transformation defines the transformation matrix
  17195. * @param result defines the Vector3 where to store the result
  17196. */
  17197. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17198. /**
  17199. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  17200. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17201. * @param vector defines the Vector3 to transform
  17202. * @param transformation defines the transformation matrix
  17203. * @returns the new Vector3
  17204. */
  17205. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  17206. /**
  17207. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  17208. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17209. * @param vector defines the Vector3 to transform
  17210. * @param transformation defines the transformation matrix
  17211. * @param result defines the Vector3 where to store the result
  17212. */
  17213. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17214. /**
  17215. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  17216. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17217. * @param x define the x coordinate of the source vector
  17218. * @param y define the y coordinate of the source vector
  17219. * @param z define the z coordinate of the source vector
  17220. * @param transformation defines the transformation matrix
  17221. * @param result defines the Vector3 where to store the result
  17222. */
  17223. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17224. /**
  17225. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  17226. * @param value1 defines the first control point
  17227. * @param value2 defines the second control point
  17228. * @param value3 defines the third control point
  17229. * @param value4 defines the fourth control point
  17230. * @param amount defines the amount on the spline to use
  17231. * @returns the new Vector3
  17232. */
  17233. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  17234. /**
  17235. * 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"
  17236. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  17237. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  17238. * @param value defines the current value
  17239. * @param min defines the lower range value
  17240. * @param max defines the upper range value
  17241. * @returns the new Vector3
  17242. */
  17243. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17244. /**
  17245. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17246. * @param value1 defines the first control point
  17247. * @param tangent1 defines the first tangent vector
  17248. * @param value2 defines the second control point
  17249. * @param tangent2 defines the second tangent vector
  17250. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17251. * @returns the new Vector3
  17252. */
  17253. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17254. /**
  17255. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17256. * @param start defines the start value
  17257. * @param end defines the end value
  17258. * @param amount max defines amount between both (between 0 and 1)
  17259. * @returns the new Vector3
  17260. */
  17261. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17262. /**
  17263. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17264. * @param start defines the start value
  17265. * @param end defines the end value
  17266. * @param amount max defines amount between both (between 0 and 1)
  17267. * @param result defines the Vector3 where to store the result
  17268. */
  17269. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17270. /**
  17271. * Returns the dot product (float) between the vectors "left" and "right"
  17272. * @param left defines the left operand
  17273. * @param right defines the right operand
  17274. * @returns the dot product
  17275. */
  17276. static Dot(left: Vector3, right: Vector3): number;
  17277. /**
  17278. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17279. * The cross product is then orthogonal to both "left" and "right"
  17280. * @param left defines the left operand
  17281. * @param right defines the right operand
  17282. * @returns the cross product
  17283. */
  17284. static Cross(left: Vector3, right: Vector3): Vector3;
  17285. /**
  17286. * Sets the given vector "result" with the cross product of "left" and "right"
  17287. * The cross product is then orthogonal to both "left" and "right"
  17288. * @param left defines the left operand
  17289. * @param right defines the right operand
  17290. * @param result defines the Vector3 where to store the result
  17291. */
  17292. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17293. /**
  17294. * Returns a new Vector3 as the normalization of the given vector
  17295. * @param vector defines the Vector3 to normalize
  17296. * @returns the new Vector3
  17297. */
  17298. static Normalize(vector: Vector3): Vector3;
  17299. /**
  17300. * Sets the given vector "result" with the normalization of the given first vector
  17301. * @param vector defines the Vector3 to normalize
  17302. * @param result defines the Vector3 where to store the result
  17303. */
  17304. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17305. private static _viewportMatrixCache;
  17306. /**
  17307. * Project a Vector3 onto screen space
  17308. * @param vector defines the Vector3 to project
  17309. * @param world defines the world matrix to use
  17310. * @param transform defines the transform (view x projection) matrix to use
  17311. * @param viewport defines the screen viewport to use
  17312. * @returns the new Vector3
  17313. */
  17314. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17315. /**
  17316. * Unproject from screen space to object space
  17317. * @param source defines the screen space Vector3 to use
  17318. * @param viewportWidth defines the current width of the viewport
  17319. * @param viewportHeight defines the current height of the viewport
  17320. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17321. * @param transform defines the transform (view x projection) matrix to use
  17322. * @returns the new Vector3
  17323. */
  17324. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17325. /**
  17326. * Unproject from screen space to object space
  17327. * @param source defines the screen space Vector3 to use
  17328. * @param viewportWidth defines the current width of the viewport
  17329. * @param viewportHeight defines the current height of the viewport
  17330. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17331. * @param view defines the view matrix to use
  17332. * @param projection defines the projection matrix to use
  17333. * @returns the new Vector3
  17334. */
  17335. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17336. /**
  17337. * Unproject from screen space to object space
  17338. * @param source defines the screen space Vector3 to use
  17339. * @param viewportWidth defines the current width of the viewport
  17340. * @param viewportHeight defines the current height of the viewport
  17341. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17342. * @param view defines the view matrix to use
  17343. * @param projection defines the projection matrix to use
  17344. * @param result defines the Vector3 where to store the result
  17345. */
  17346. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17347. /**
  17348. * Unproject from screen space to object space
  17349. * @param sourceX defines the screen space x coordinate to use
  17350. * @param sourceY defines the screen space y coordinate to use
  17351. * @param sourceZ defines the screen space z coordinate to use
  17352. * @param viewportWidth defines the current width of the viewport
  17353. * @param viewportHeight defines the current height of the viewport
  17354. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17355. * @param view defines the view matrix to use
  17356. * @param projection defines the projection matrix to use
  17357. * @param result defines the Vector3 where to store the result
  17358. */
  17359. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17360. /**
  17361. * Gets the minimal coordinate values between two Vector3
  17362. * @param left defines the first operand
  17363. * @param right defines the second operand
  17364. * @returns the new Vector3
  17365. */
  17366. static Minimize(left: Vector3, right: Vector3): Vector3;
  17367. /**
  17368. * Gets the maximal coordinate values between two Vector3
  17369. * @param left defines the first operand
  17370. * @param right defines the second operand
  17371. * @returns the new Vector3
  17372. */
  17373. static Maximize(left: Vector3, right: Vector3): Vector3;
  17374. /**
  17375. * Returns the distance between the vectors "value1" and "value2"
  17376. * @param value1 defines the first operand
  17377. * @param value2 defines the second operand
  17378. * @returns the distance
  17379. */
  17380. static Distance(value1: Vector3, value2: Vector3): number;
  17381. /**
  17382. * Returns the squared distance between the vectors "value1" and "value2"
  17383. * @param value1 defines the first operand
  17384. * @param value2 defines the second operand
  17385. * @returns the squared distance
  17386. */
  17387. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17388. /**
  17389. * Returns a new Vector3 located at the center between "value1" and "value2"
  17390. * @param value1 defines the first operand
  17391. * @param value2 defines the second operand
  17392. * @returns the new Vector3
  17393. */
  17394. static Center(value1: Vector3, value2: Vector3): Vector3;
  17395. /**
  17396. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17397. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17398. * to something in order to rotate it from its local system to the given target system
  17399. * Note: axis1, axis2 and axis3 are normalized during this operation
  17400. * @param axis1 defines the first axis
  17401. * @param axis2 defines the second axis
  17402. * @param axis3 defines the third axis
  17403. * @returns a new Vector3
  17404. */
  17405. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17406. /**
  17407. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17408. * @param axis1 defines the first axis
  17409. * @param axis2 defines the second axis
  17410. * @param axis3 defines the third axis
  17411. * @param ref defines the Vector3 where to store the result
  17412. */
  17413. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17414. }
  17415. class Vector4 {
  17416. x: number;
  17417. y: number;
  17418. z: number;
  17419. w: number;
  17420. /**
  17421. * Creates a Vector4 object from the given floats.
  17422. */
  17423. constructor(x: number, y: number, z: number, w: number);
  17424. /**
  17425. * Returns the string with the Vector4 coordinates.
  17426. */
  17427. toString(): string;
  17428. /**
  17429. * Returns the string "Vector4".
  17430. */
  17431. getClassName(): string;
  17432. /**
  17433. * Returns the Vector4 hash code.
  17434. */
  17435. getHashCode(): number;
  17436. /**
  17437. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17438. */
  17439. asArray(): number[];
  17440. /**
  17441. * Populates the given array from the given index with the Vector4 coordinates.
  17442. * Returns the Vector4.
  17443. */
  17444. toArray(array: FloatArray, index?: number): Vector4;
  17445. /**
  17446. * Adds the given vector to the current Vector4.
  17447. * Returns the updated Vector4.
  17448. */
  17449. addInPlace(otherVector: Vector4): Vector4;
  17450. /**
  17451. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17452. */
  17453. add(otherVector: Vector4): Vector4;
  17454. /**
  17455. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17456. * Returns the current Vector4.
  17457. */
  17458. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17459. /**
  17460. * Subtract in place the given vector from the current Vector4.
  17461. * Returns the updated Vector4.
  17462. */
  17463. subtractInPlace(otherVector: Vector4): Vector4;
  17464. /**
  17465. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17466. */
  17467. subtract(otherVector: Vector4): Vector4;
  17468. /**
  17469. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17470. * Returns the current Vector4.
  17471. */
  17472. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17473. /**
  17474. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17475. */
  17476. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17477. /**
  17478. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17479. * Returns the current Vector4.
  17480. */
  17481. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17482. /**
  17483. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17484. */
  17485. negate(): Vector4;
  17486. /**
  17487. * Multiplies the current Vector4 coordinates by scale (float).
  17488. * Returns the updated Vector4.
  17489. */
  17490. scaleInPlace(scale: number): Vector4;
  17491. /**
  17492. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17493. */
  17494. scale(scale: number): Vector4;
  17495. /**
  17496. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17497. * Returns the current Vector4.
  17498. */
  17499. scaleToRef(scale: number, result: Vector4): Vector4;
  17500. /**
  17501. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17502. * @param scale defines the scale factor
  17503. * @param result defines the Vector4 object where to store the result
  17504. * @returns the unmodified current Vector4
  17505. */
  17506. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17507. /**
  17508. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17509. */
  17510. equals(otherVector: Vector4): boolean;
  17511. /**
  17512. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17513. */
  17514. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17515. /**
  17516. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17517. */
  17518. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17519. /**
  17520. * Multiplies in place the current Vector4 by the given one.
  17521. * Returns the updated Vector4.
  17522. */
  17523. multiplyInPlace(otherVector: Vector4): Vector4;
  17524. /**
  17525. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17526. */
  17527. multiply(otherVector: Vector4): Vector4;
  17528. /**
  17529. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17530. * Returns the current Vector4.
  17531. */
  17532. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17533. /**
  17534. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17535. */
  17536. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17537. /**
  17538. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17539. */
  17540. divide(otherVector: Vector4): Vector4;
  17541. /**
  17542. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17543. * Returns the current Vector4.
  17544. */
  17545. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17546. /**
  17547. * Divides the current Vector3 coordinates by the given ones.
  17548. * @returns the updated Vector3.
  17549. */
  17550. divideInPlace(otherVector: Vector4): Vector4;
  17551. /**
  17552. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17553. * @param other defines the second operand
  17554. * @returns the current updated Vector4
  17555. */
  17556. minimizeInPlace(other: Vector4): Vector4;
  17557. /**
  17558. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17559. * @param other defines the second operand
  17560. * @returns the current updated Vector4
  17561. */
  17562. maximizeInPlace(other: Vector4): Vector4;
  17563. /**
  17564. * Gets a new Vector4 from current Vector4 floored values
  17565. * @returns a new Vector4
  17566. */
  17567. floor(): Vector4;
  17568. /**
  17569. * Gets a new Vector4 from current Vector3 floored values
  17570. * @returns a new Vector4
  17571. */
  17572. fract(): Vector4;
  17573. /**
  17574. * Returns the Vector4 length (float).
  17575. */
  17576. length(): number;
  17577. /**
  17578. * Returns the Vector4 squared length (float).
  17579. */
  17580. lengthSquared(): number;
  17581. /**
  17582. * Normalizes in place the Vector4.
  17583. * Returns the updated Vector4.
  17584. */
  17585. normalize(): Vector4;
  17586. /**
  17587. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17588. */
  17589. toVector3(): Vector3;
  17590. /**
  17591. * Returns a new Vector4 copied from the current one.
  17592. */
  17593. clone(): Vector4;
  17594. /**
  17595. * Updates the current Vector4 with the given one coordinates.
  17596. * Returns the updated Vector4.
  17597. */
  17598. copyFrom(source: Vector4): Vector4;
  17599. /**
  17600. * Updates the current Vector4 coordinates with the given floats.
  17601. * Returns the updated Vector4.
  17602. */
  17603. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17604. /**
  17605. * Updates the current Vector4 coordinates with the given floats.
  17606. * Returns the updated Vector4.
  17607. */
  17608. set(x: number, y: number, z: number, w: number): Vector4;
  17609. /**
  17610. * Returns a new Vector4 set from the starting index of the given array.
  17611. */
  17612. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17613. /**
  17614. * Updates the given vector "result" from the starting index of the given array.
  17615. */
  17616. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17617. /**
  17618. * Updates the given vector "result" from the starting index of the given Float32Array.
  17619. */
  17620. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17621. /**
  17622. * Updates the given vector "result" coordinates from the given floats.
  17623. */
  17624. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17625. /**
  17626. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17627. */
  17628. static Zero(): Vector4;
  17629. /**
  17630. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17631. */
  17632. static One(): Vector4;
  17633. /**
  17634. * Returns a new normalized Vector4 from the given one.
  17635. */
  17636. static Normalize(vector: Vector4): Vector4;
  17637. /**
  17638. * Updates the given vector "result" from the normalization of the given one.
  17639. */
  17640. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17641. static Minimize(left: Vector4, right: Vector4): Vector4;
  17642. static Maximize(left: Vector4, right: Vector4): Vector4;
  17643. /**
  17644. * Returns the distance (float) between the vectors "value1" and "value2".
  17645. */
  17646. static Distance(value1: Vector4, value2: Vector4): number;
  17647. /**
  17648. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17649. */
  17650. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17651. /**
  17652. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17653. */
  17654. static Center(value1: Vector4, value2: Vector4): Vector4;
  17655. /**
  17656. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17657. * This methods computes transformed normalized direction vectors only.
  17658. */
  17659. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17660. /**
  17661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17662. * This methods computes transformed normalized direction vectors only.
  17663. */
  17664. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17665. /**
  17666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17667. * This methods computes transformed normalized direction vectors only.
  17668. */
  17669. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17670. }
  17671. interface ISize {
  17672. width: number;
  17673. height: number;
  17674. }
  17675. class Size implements ISize {
  17676. width: number;
  17677. height: number;
  17678. /**
  17679. * Creates a Size object from the given width and height (floats).
  17680. */
  17681. constructor(width: number, height: number);
  17682. toString(): string;
  17683. /**
  17684. * Returns the string "Size"
  17685. */
  17686. getClassName(): string;
  17687. /**
  17688. * Returns the Size hash code.
  17689. */
  17690. getHashCode(): number;
  17691. /**
  17692. * Updates the current size from the given one.
  17693. * Returns the updated Size.
  17694. */
  17695. copyFrom(src: Size): void;
  17696. /**
  17697. * Updates in place the current Size from the given floats.
  17698. * Returns the updated Size.
  17699. */
  17700. copyFromFloats(width: number, height: number): Size;
  17701. /**
  17702. * Updates in place the current Size from the given floats.
  17703. * Returns the updated Size.
  17704. */
  17705. set(width: number, height: number): Size;
  17706. /**
  17707. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17708. */
  17709. multiplyByFloats(w: number, h: number): Size;
  17710. /**
  17711. * Returns a new Size copied from the given one.
  17712. */
  17713. clone(): Size;
  17714. /**
  17715. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17716. */
  17717. equals(other: Size): boolean;
  17718. /**
  17719. * Returns the surface of the Size : width * height (float).
  17720. */
  17721. readonly surface: number;
  17722. /**
  17723. * Returns a new Size set to (0.0, 0.0)
  17724. */
  17725. static Zero(): Size;
  17726. /**
  17727. * Returns a new Size set as the addition result of the current Size and the given one.
  17728. */
  17729. add(otherSize: Size): Size;
  17730. /**
  17731. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17732. */
  17733. subtract(otherSize: Size): Size;
  17734. /**
  17735. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17736. */
  17737. static Lerp(start: Size, end: Size, amount: number): Size;
  17738. }
  17739. /**
  17740. * Class used to store quaternion data
  17741. * @see https://en.wikipedia.org/wiki/Quaternion
  17742. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17743. */
  17744. class Quaternion {
  17745. /** defines the first component (0 by default) */
  17746. x: number;
  17747. /** defines the second component (0 by default) */
  17748. y: number;
  17749. /** defines the third component (0 by default) */
  17750. z: number;
  17751. /** defines the fourth component (1.0 by default) */
  17752. w: number;
  17753. /**
  17754. * Creates a new Quaternion from the given floats
  17755. * @param x defines the first component (0 by default)
  17756. * @param y defines the second component (0 by default)
  17757. * @param z defines the third component (0 by default)
  17758. * @param w defines the fourth component (1.0 by default)
  17759. */
  17760. constructor(
  17761. /** defines the first component (0 by default) */
  17762. x?: number,
  17763. /** defines the second component (0 by default) */
  17764. y?: number,
  17765. /** defines the third component (0 by default) */
  17766. z?: number,
  17767. /** defines the fourth component (1.0 by default) */
  17768. w?: number);
  17769. /**
  17770. * Gets a string representation for the current quaternion
  17771. * @returns a string with the Quaternion coordinates
  17772. */
  17773. toString(): string;
  17774. /**
  17775. * Gets the class name of the quaternion
  17776. * @returns the string "Quaternion"
  17777. */
  17778. getClassName(): string;
  17779. /**
  17780. * Gets a hash code for this quaternion
  17781. * @returns the quaternion hash code
  17782. */
  17783. getHashCode(): number;
  17784. /**
  17785. * Copy the quaternion to an array
  17786. * @returns a new array populated with 4 elements from the quaternion coordinates
  17787. */
  17788. asArray(): number[];
  17789. /**
  17790. * Check if two quaternions are equals
  17791. * @param otherQuaternion defines the second operand
  17792. * @return true if the current quaternion and the given one coordinates are strictly equals
  17793. */
  17794. equals(otherQuaternion: Quaternion): boolean;
  17795. /**
  17796. * Clone the current quaternion
  17797. * @returns a new quaternion copied from the current one
  17798. */
  17799. clone(): Quaternion;
  17800. /**
  17801. * Copy a quaternion to the current one
  17802. * @param other defines the other quaternion
  17803. * @returns the updated current quaternion
  17804. */
  17805. copyFrom(other: Quaternion): Quaternion;
  17806. /**
  17807. * Updates the current quaternion with the given float coordinates
  17808. * @param x defines the x coordinate
  17809. * @param y defines the y coordinate
  17810. * @param z defines the z coordinate
  17811. * @param w defines the w coordinate
  17812. * @returns the updated current quaternion
  17813. */
  17814. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17815. /**
  17816. * Updates the current quaternion from the given float coordinates
  17817. * @param x defines the x coordinate
  17818. * @param y defines the y coordinate
  17819. * @param z defines the z coordinate
  17820. * @param w defines the w coordinate
  17821. * @returns the updated current quaternion
  17822. */
  17823. set(x: number, y: number, z: number, w: number): Quaternion;
  17824. /**
  17825. * Adds two quaternions
  17826. * @param other defines the second operand
  17827. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17828. */
  17829. add(other: Quaternion): Quaternion;
  17830. /**
  17831. * Add a quaternion to the current one
  17832. * @param other defines the quaternion to add
  17833. * @returns the current quaternion
  17834. */
  17835. addInPlace(other: Quaternion): Quaternion;
  17836. /**
  17837. * Subtract two quaternions
  17838. * @param other defines the second operand
  17839. * @returns a new quaternion as the subtraction result of the given one from the current one
  17840. */
  17841. subtract(other: Quaternion): Quaternion;
  17842. /**
  17843. * Multiplies the current quaternion by a scale factor
  17844. * @param value defines the scale factor
  17845. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17846. */
  17847. scale(value: number): Quaternion;
  17848. /**
  17849. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17850. * @param scale defines the scale factor
  17851. * @param result defines the Quaternion object where to store the result
  17852. * @returns the unmodified current quaternion
  17853. */
  17854. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17855. /**
  17856. * Multiplies in place the current quaternion by a scale factor
  17857. * @param value defines the scale factor
  17858. * @returns the current modified quaternion
  17859. */
  17860. scaleInPlace(value: number): Quaternion;
  17861. /**
  17862. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17863. * @param scale defines the scale factor
  17864. * @param result defines the Quaternion object where to store the result
  17865. * @returns the unmodified current quaternion
  17866. */
  17867. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17868. /**
  17869. * Multiplies two quaternions
  17870. * @param q1 defines the second operand
  17871. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17872. */
  17873. multiply(q1: Quaternion): Quaternion;
  17874. /**
  17875. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17876. * @param q1 defines the second operand
  17877. * @param result defines the target quaternion
  17878. * @returns the current quaternion
  17879. */
  17880. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17881. /**
  17882. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17883. * @param q1 defines the second operand
  17884. * @returns the currentupdated quaternion
  17885. */
  17886. multiplyInPlace(q1: Quaternion): Quaternion;
  17887. /**
  17888. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17889. * @param ref defines the target quaternion
  17890. * @returns the current quaternion
  17891. */
  17892. conjugateToRef(ref: Quaternion): Quaternion;
  17893. /**
  17894. * Conjugates in place (1-q) the current quaternion
  17895. * @returns the current updated quaternion
  17896. */
  17897. conjugateInPlace(): Quaternion;
  17898. /**
  17899. * Conjugates in place (1-q) the current quaternion
  17900. * @returns a new quaternion
  17901. */
  17902. conjugate(): Quaternion;
  17903. /**
  17904. * Gets length of current quaternion
  17905. * @returns the quaternion length (float)
  17906. */
  17907. length(): number;
  17908. /**
  17909. * Normalize in place the current quaternion
  17910. * @returns the current updated quaternion
  17911. */
  17912. normalize(): Quaternion;
  17913. /**
  17914. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17915. * @param order is a reserved parameter and is ignore for now
  17916. * @returns a new Vector3 containing the Euler angles
  17917. */
  17918. toEulerAngles(order?: string): Vector3;
  17919. /**
  17920. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17921. * @param result defines the vector which will be filled with the Euler angles
  17922. * @param order is a reserved parameter and is ignore for now
  17923. * @returns the current unchanged quaternion
  17924. */
  17925. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17926. /**
  17927. * Updates the given rotation matrix with the current quaternion values
  17928. * @param result defines the target matrix
  17929. * @returns the current unchanged quaternion
  17930. */
  17931. toRotationMatrix(result: Matrix): Quaternion;
  17932. /**
  17933. * Updates the current quaternion from the given rotation matrix values
  17934. * @param matrix defines the source matrix
  17935. * @returns the current updated quaternion
  17936. */
  17937. fromRotationMatrix(matrix: Matrix): Quaternion;
  17938. /**
  17939. * Creates a new quaternion from a rotation matrix
  17940. * @param matrix defines the source matrix
  17941. * @returns a new quaternion created from the given rotation matrix values
  17942. */
  17943. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17944. /**
  17945. * Updates the given quaternion with the given rotation matrix values
  17946. * @param matrix defines the source matrix
  17947. * @param result defines the target quaternion
  17948. */
  17949. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17950. /**
  17951. * Returns the dot product (float) between the quaternions "left" and "right"
  17952. * @param left defines the left operand
  17953. * @param right defines the right operand
  17954. * @returns the dot product
  17955. */
  17956. static Dot(left: Quaternion, right: Quaternion): number;
  17957. /**
  17958. * Checks if the two quaternions are close to each other
  17959. * @param quat0 defines the first quaternion to check
  17960. * @param quat1 defines the second quaternion to check
  17961. * @returns true if the two quaternions are close to each other
  17962. */
  17963. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17964. /**
  17965. * Creates an empty quaternion
  17966. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17967. */
  17968. static Zero(): Quaternion;
  17969. /**
  17970. * Inverse a given quaternion
  17971. * @param q defines the source quaternion
  17972. * @returns a new quaternion as the inverted current quaternion
  17973. */
  17974. static Inverse(q: Quaternion): Quaternion;
  17975. /**
  17976. * Creates an identity quaternion
  17977. * @returns the identity quaternion
  17978. */
  17979. static Identity(): Quaternion;
  17980. /**
  17981. * Gets a boolean indicating if the given quaternion is identity
  17982. * @param quaternion defines the quaternion to check
  17983. * @returns true if the quaternion is identity
  17984. */
  17985. static IsIdentity(quaternion: Quaternion): boolean;
  17986. /**
  17987. * Creates a quaternion from a rotation around an axis
  17988. * @param axis defines the axis to use
  17989. * @param angle defines the angle to use
  17990. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17991. */
  17992. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17993. /**
  17994. * Creates a rotation around an axis and stores it into the given quaternion
  17995. * @param axis defines the axis to use
  17996. * @param angle defines the angle to use
  17997. * @param result defines the target quaternion
  17998. * @returns the target quaternion
  17999. */
  18000. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  18001. /**
  18002. * Creates a new quaternion from data stored into an array
  18003. * @param array defines the data source
  18004. * @param offset defines the offset in the source array where the data starts
  18005. * @returns a new quaternion
  18006. */
  18007. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  18008. /**
  18009. * Creates a new quaternion from the given Euler float angles (y, x, z)
  18010. * @param yaw defines the rotation around Y axis
  18011. * @param pitch defines the rotation around X axis
  18012. * @param roll defines the rotation around Z axis
  18013. * @returns the new quaternion
  18014. */
  18015. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  18016. /**
  18017. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  18018. * @param yaw defines the rotation around Y axis
  18019. * @param pitch defines the rotation around X axis
  18020. * @param roll defines the rotation around Z axis
  18021. * @param result defines the target quaternion
  18022. */
  18023. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  18024. /**
  18025. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  18026. * @param alpha defines the rotation around first axis
  18027. * @param beta defines the rotation around second axis
  18028. * @param gamma defines the rotation around third axis
  18029. * @returns the new quaternion
  18030. */
  18031. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  18032. /**
  18033. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  18034. * @param alpha defines the rotation around first axis
  18035. * @param beta defines the rotation around second axis
  18036. * @param gamma defines the rotation around third axis
  18037. * @param result defines the target quaternion
  18038. */
  18039. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  18040. /**
  18041. * 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)
  18042. * @param axis1 defines the first axis
  18043. * @param axis2 defines the second axis
  18044. * @param axis3 defines the third axis
  18045. * @returns the new quaternion
  18046. */
  18047. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  18048. /**
  18049. * 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
  18050. * @param axis1 defines the first axis
  18051. * @param axis2 defines the second axis
  18052. * @param axis3 defines the third axis
  18053. * @param ref defines the target quaternion
  18054. */
  18055. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  18056. /**
  18057. * Interpolates between two quaternions
  18058. * @param left defines first quaternion
  18059. * @param right defines second quaternion
  18060. * @param amount defines the gradient to use
  18061. * @returns the new interpolated quaternion
  18062. */
  18063. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  18064. /**
  18065. * Interpolates between two quaternions and stores it into a target quaternion
  18066. * @param left defines first quaternion
  18067. * @param right defines second quaternion
  18068. * @param amount defines the gradient to use
  18069. * @param result defines the target quaternion
  18070. */
  18071. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  18072. /**
  18073. * Interpolate between two quaternions using Hermite interpolation
  18074. * @param value1 defines first quaternion
  18075. * @param tangent1 defines the incoming tangent
  18076. * @param value2 defines second quaternion
  18077. * @param tangent2 defines the outgoing tangent
  18078. * @param amount defines the target quaternion
  18079. * @returns the new interpolated quaternion
  18080. */
  18081. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  18082. }
  18083. /**
  18084. * Class used to store matrix data (4x4)
  18085. */
  18086. class Matrix {
  18087. private static _tempQuaternion;
  18088. private static _xAxis;
  18089. private static _yAxis;
  18090. private static _zAxis;
  18091. private static _updateFlagSeed;
  18092. private static _identityReadOnly;
  18093. private _isIdentity;
  18094. private _isIdentityDirty;
  18095. /**
  18096. * Gets the update flag of the matrix which is an unique number for the matrix.
  18097. * It will be incremented every time the matrix data change.
  18098. * You can use it to speed the comparison between two versions of the same matrix.
  18099. */
  18100. updateFlag: number;
  18101. /**
  18102. * Gets or sets the internal data of the matrix
  18103. */
  18104. m: Float32Array;
  18105. /** @hidden */
  18106. _markAsUpdated(): void;
  18107. /**
  18108. * Creates an empty matrix (filled with zeros)
  18109. */
  18110. constructor();
  18111. /**
  18112. * Check if the current matrix is indentity
  18113. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  18114. * @returns true is the matrix is the identity matrix
  18115. */
  18116. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  18117. /**
  18118. * Gets the determinant of the matrix
  18119. * @returns the matrix determinant
  18120. */
  18121. determinant(): number;
  18122. /**
  18123. * Returns the matrix as a Float32Array
  18124. * @returns the matrix underlying array
  18125. */
  18126. toArray(): Float32Array;
  18127. /**
  18128. * Returns the matrix as a Float32Array
  18129. * @returns the matrix underlying array.
  18130. */
  18131. asArray(): Float32Array;
  18132. /**
  18133. * Inverts the current matrix in place
  18134. * @returns the current inverted matrix
  18135. */
  18136. invert(): Matrix;
  18137. /**
  18138. * Sets all the matrix elements to zero
  18139. * @returns the current matrix
  18140. */
  18141. reset(): Matrix;
  18142. /**
  18143. * Adds the current matrix with a second one
  18144. * @param other defines the matrix to add
  18145. * @returns a new matrix as the addition of the current matrix and the given one
  18146. */
  18147. add(other: Matrix): Matrix;
  18148. /**
  18149. * Sets the given matrix "result" to the addition of the current matrix and the given one
  18150. * @param other defines the matrix to add
  18151. * @param result defines the target matrix
  18152. * @returns the current matrix
  18153. */
  18154. addToRef(other: Matrix, result: Matrix): Matrix;
  18155. /**
  18156. * Adds in place the given matrix to the current matrix
  18157. * @param other defines the second operand
  18158. * @returns the current updated matrix
  18159. */
  18160. addToSelf(other: Matrix): Matrix;
  18161. /**
  18162. * Sets the given matrix to the current inverted Matrix
  18163. * @param other defines the target matrix
  18164. * @returns the unmodified current matrix
  18165. */
  18166. invertToRef(other: Matrix): Matrix;
  18167. /**
  18168. * Inserts the translation vector (using 3 floats) in the current matrix
  18169. * @param x defines the 1st component of the translation
  18170. * @param y defines the 2nd component of the translation
  18171. * @param z defines the 3rd component of the translation
  18172. * @returns the current updated matrix
  18173. */
  18174. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  18175. /**
  18176. * Inserts the translation vector in the current matrix
  18177. * @param vector3 defines the translation to insert
  18178. * @returns the current updated matrix
  18179. */
  18180. setTranslation(vector3: Vector3): Matrix;
  18181. /**
  18182. * Gets the translation value of the current matrix
  18183. * @returns a new Vector3 as the extracted translation from the matrix
  18184. */
  18185. getTranslation(): Vector3;
  18186. /**
  18187. * Fill a Vector3 with the extracted translation from the matrix
  18188. * @param result defines the Vector3 where to store the translation
  18189. * @returns the current matrix
  18190. */
  18191. getTranslationToRef(result: Vector3): Matrix;
  18192. /**
  18193. * Remove rotation and scaling part from the matrix
  18194. * @returns the updated matrix
  18195. */
  18196. removeRotationAndScaling(): Matrix;
  18197. /**
  18198. * Multiply two matrices
  18199. * @param other defines the second operand
  18200. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  18201. */
  18202. multiply(other: Matrix): Matrix;
  18203. /**
  18204. * Copy the current matrix from the given one
  18205. * @param other defines the source matrix
  18206. * @returns the current updated matrix
  18207. */
  18208. copyFrom(other: Matrix): Matrix;
  18209. /**
  18210. * Populates the given array from the starting index with the current matrix values
  18211. * @param array defines the target array
  18212. * @param offset defines the offset in the target array where to start storing values
  18213. * @returns the current matrix
  18214. */
  18215. copyToArray(array: Float32Array, offset?: number): Matrix;
  18216. /**
  18217. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  18218. * @param other defines the second operand
  18219. * @param result defines the matrix where to store the multiplication
  18220. * @returns the current matrix
  18221. */
  18222. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  18223. /**
  18224. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  18225. * @param other defines the second operand
  18226. * @param result defines the array where to store the multiplication
  18227. * @param offset defines the offset in the target array where to start storing values
  18228. * @returns the current matrix
  18229. */
  18230. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  18231. /**
  18232. * Check equality between this matrix and a second one
  18233. * @param value defines the second matrix to compare
  18234. * @returns true is the current matrix and the given one values are strictly equal
  18235. */
  18236. equals(value: Matrix): boolean;
  18237. /**
  18238. * Clone the current matrix
  18239. * @returns a new matrix from the current matrix
  18240. */
  18241. clone(): Matrix;
  18242. /**
  18243. * Returns the name of the current matrix class
  18244. * @returns the string "Matrix"
  18245. */
  18246. getClassName(): string;
  18247. /**
  18248. * Gets the hash code of the current matrix
  18249. * @returns the hash code
  18250. */
  18251. getHashCode(): number;
  18252. /**
  18253. * Decomposes the current Matrix into a translation, rotation and scaling components
  18254. * @param scale defines the scale vector3 given as a reference to update
  18255. * @param rotation defines the rotation quaternion given as a reference to update
  18256. * @param translation defines the translation vector3 given as a reference to update
  18257. * @returns true if operation was successful
  18258. */
  18259. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18260. /**
  18261. * Gets specific row of the matrix
  18262. * @param index defines the number of the row to get
  18263. * @returns the index-th row of the current matrix as a new Vector4
  18264. */
  18265. getRow(index: number): Nullable<Vector4>;
  18266. /**
  18267. * Sets the index-th row of the current matrix to the vector4 values
  18268. * @param index defines the number of the row to set
  18269. * @param row defines the target vector4
  18270. * @returns the updated current matrix
  18271. */
  18272. setRow(index: number, row: Vector4): Matrix;
  18273. /**
  18274. * Compute the transpose of the matrix
  18275. * @returns the new transposed matrix
  18276. */
  18277. transpose(): Matrix;
  18278. /**
  18279. * Compute the transpose of the matrix and store it in a given matrix
  18280. * @param result defines the target matrix
  18281. * @returns the current matrix
  18282. */
  18283. transposeToRef(result: Matrix): Matrix;
  18284. /**
  18285. * Sets the index-th row of the current matrix with the given 4 x float values
  18286. * @param index defines the row index
  18287. * @param x defines the x component to set
  18288. * @param y defines the y component to set
  18289. * @param z defines the z component to set
  18290. * @param w defines the w component to set
  18291. * @returns the updated current matrix
  18292. */
  18293. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18294. /**
  18295. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18296. * @param scale defines the scale factor
  18297. * @returns a new matrix
  18298. */
  18299. scale(scale: number): Matrix;
  18300. /**
  18301. * Scale the current matrix values by a factor to a given result matrix
  18302. * @param scale defines the scale factor
  18303. * @param result defines the matrix to store the result
  18304. * @returns the current matrix
  18305. */
  18306. scaleToRef(scale: number, result: Matrix): Matrix;
  18307. /**
  18308. * Scale the current matrix values by a factor and add the result to a given matrix
  18309. * @param scale defines the scale factor
  18310. * @param result defines the Matrix to store the result
  18311. * @returns the current matrix
  18312. */
  18313. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18314. /**
  18315. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18316. * @param ref matrix to store the result
  18317. */
  18318. toNormalMatrix(ref: Matrix): void;
  18319. /**
  18320. * Gets only rotation part of the current matrix
  18321. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18322. */
  18323. getRotationMatrix(): Matrix;
  18324. /**
  18325. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18326. * @param result defines the target matrix to store data to
  18327. * @returns the current matrix
  18328. */
  18329. getRotationMatrixToRef(result: Matrix): Matrix;
  18330. /**
  18331. * Creates a matrix from an array
  18332. * @param array defines the source array
  18333. * @param offset defines an offset in the source array
  18334. * @returns a new Matrix set from the starting index of the given array
  18335. */
  18336. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18337. /**
  18338. * Copy the content of an array into a given matrix
  18339. * @param array defines the source array
  18340. * @param offset defines an offset in the source array
  18341. * @param result defines the target matrix
  18342. */
  18343. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18344. /**
  18345. * Stores an array into a matrix after having multiplied each component by a given factor
  18346. * @param array defines the source array
  18347. * @param offset defines the offset in the source array
  18348. * @param scale defines the scaling factor
  18349. * @param result defines the target matrix
  18350. */
  18351. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18352. /**
  18353. * Stores a list of values (16) inside a given matrix
  18354. * @param initialM11 defines 1st value of 1st row
  18355. * @param initialM12 defines 2nd value of 1st row
  18356. * @param initialM13 defines 3rd value of 1st row
  18357. * @param initialM14 defines 4th value of 1st row
  18358. * @param initialM21 defines 1st value of 2nd row
  18359. * @param initialM22 defines 2nd value of 2nd row
  18360. * @param initialM23 defines 3rd value of 2nd row
  18361. * @param initialM24 defines 4th value of 2nd row
  18362. * @param initialM31 defines 1st value of 3rd row
  18363. * @param initialM32 defines 2nd value of 3rd row
  18364. * @param initialM33 defines 3rd value of 3rd row
  18365. * @param initialM34 defines 4th value of 3rd row
  18366. * @param initialM41 defines 1st value of 4th row
  18367. * @param initialM42 defines 2nd value of 4th row
  18368. * @param initialM43 defines 3rd value of 4th row
  18369. * @param initialM44 defines 4th value of 4th row
  18370. * @param result defines the target matrix
  18371. */
  18372. 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;
  18373. /**
  18374. * Gets an identity matrix that must not be updated
  18375. */
  18376. static readonly IdentityReadOnly: Matrix;
  18377. /**
  18378. * Creates new matrix from a list of values (16)
  18379. * @param initialM11 defines 1st value of 1st row
  18380. * @param initialM12 defines 2nd value of 1st row
  18381. * @param initialM13 defines 3rd value of 1st row
  18382. * @param initialM14 defines 4th value of 1st row
  18383. * @param initialM21 defines 1st value of 2nd row
  18384. * @param initialM22 defines 2nd value of 2nd row
  18385. * @param initialM23 defines 3rd value of 2nd row
  18386. * @param initialM24 defines 4th value of 2nd row
  18387. * @param initialM31 defines 1st value of 3rd row
  18388. * @param initialM32 defines 2nd value of 3rd row
  18389. * @param initialM33 defines 3rd value of 3rd row
  18390. * @param initialM34 defines 4th value of 3rd row
  18391. * @param initialM41 defines 1st value of 4th row
  18392. * @param initialM42 defines 2nd value of 4th row
  18393. * @param initialM43 defines 3rd value of 4th row
  18394. * @param initialM44 defines 4th value of 4th row
  18395. * @returns the new matrix
  18396. */
  18397. 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;
  18398. /**
  18399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18400. * @param scale defines the scale vector3
  18401. * @param rotation defines the rotation quaternion
  18402. * @param translation defines the translation vector3
  18403. * @returns a new matrix
  18404. */
  18405. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18406. /**
  18407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18408. * @param scale defines the scale vector3
  18409. * @param rotation defines the rotation quaternion
  18410. * @param translation defines the translation vector3
  18411. * @param result defines the target matrix
  18412. */
  18413. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18414. /**
  18415. * Creates a new identity matrix
  18416. * @returns a new identity matrix
  18417. */
  18418. static Identity(): Matrix;
  18419. /**
  18420. * Creates a new identity matrix and stores the result in a given matrix
  18421. * @param result defines the target matrix
  18422. */
  18423. static IdentityToRef(result: Matrix): void;
  18424. /**
  18425. * Creates a new zero matrix
  18426. * @returns a new zero matrix
  18427. */
  18428. static Zero(): Matrix;
  18429. /**
  18430. * Creates a new rotation matrix for "angle" radians around the X axis
  18431. * @param angle defines the angle (in radians) to use
  18432. * @return the new matrix
  18433. */
  18434. static RotationX(angle: number): Matrix;
  18435. /**
  18436. * Creates a new matrix as the invert of a given matrix
  18437. * @param source defines the source matrix
  18438. * @returns the new matrix
  18439. */
  18440. static Invert(source: Matrix): Matrix;
  18441. /**
  18442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18443. * @param angle defines the angle (in radians) to use
  18444. * @param result defines the target matrix
  18445. */
  18446. static RotationXToRef(angle: number, result: Matrix): void;
  18447. /**
  18448. * Creates a new rotation matrix for "angle" radians around the Y axis
  18449. * @param angle defines the angle (in radians) to use
  18450. * @return the new matrix
  18451. */
  18452. static RotationY(angle: number): Matrix;
  18453. /**
  18454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18455. * @param angle defines the angle (in radians) to use
  18456. * @param result defines the target matrix
  18457. */
  18458. static RotationYToRef(angle: number, result: Matrix): void;
  18459. /**
  18460. * Creates a new rotation matrix for "angle" radians around the Z axis
  18461. * @param angle defines the angle (in radians) to use
  18462. * @return the new matrix
  18463. */
  18464. static RotationZ(angle: number): Matrix;
  18465. /**
  18466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18467. * @param angle defines the angle (in radians) to use
  18468. * @param result defines the target matrix
  18469. */
  18470. static RotationZToRef(angle: number, result: Matrix): void;
  18471. /**
  18472. * Creates a new rotation matrix for "angle" radians around the given axis
  18473. * @param axis defines the axis to use
  18474. * @param angle defines the angle (in radians) to use
  18475. * @return the new matrix
  18476. */
  18477. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18478. /**
  18479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18480. * @param axis defines the axis to use
  18481. * @param angle defines the angle (in radians) to use
  18482. * @param result defines the target matrix
  18483. */
  18484. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18485. /**
  18486. * Creates a rotation matrix
  18487. * @param yaw defines the yaw angle in radians (Y axis)
  18488. * @param pitch defines the pitch angle in radians (X axis)
  18489. * @param roll defines the roll angle in radians (X axis)
  18490. * @returns the new rotation matrix
  18491. */
  18492. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18493. /**
  18494. * Creates a rotation matrix and stores it in a given matrix
  18495. * @param yaw defines the yaw angle in radians (Y axis)
  18496. * @param pitch defines the pitch angle in radians (X axis)
  18497. * @param roll defines the roll angle in radians (X axis)
  18498. * @param result defines the target matrix
  18499. */
  18500. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18501. /**
  18502. * Creates a scaling matrix
  18503. * @param x defines the scale factor on X axis
  18504. * @param y defines the scale factor on Y axis
  18505. * @param z defines the scale factor on Z axis
  18506. * @returns the new matrix
  18507. */
  18508. static Scaling(x: number, y: number, z: number): Matrix;
  18509. /**
  18510. * Creates a scaling matrix and stores it in a given matrix
  18511. * @param x defines the scale factor on X axis
  18512. * @param y defines the scale factor on Y axis
  18513. * @param z defines the scale factor on Z axis
  18514. * @param result defines the target matrix
  18515. */
  18516. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18517. /**
  18518. * Creates a translation matrix
  18519. * @param x defines the translation on X axis
  18520. * @param y defines the translation on Y axis
  18521. * @param z defines the translationon Z axis
  18522. * @returns the new matrix
  18523. */
  18524. static Translation(x: number, y: number, z: number): Matrix;
  18525. /**
  18526. * Creates a translation matrix and stores it in a given matrix
  18527. * @param x defines the translation on X axis
  18528. * @param y defines the translation on Y axis
  18529. * @param z defines the translationon Z axis
  18530. * @param result defines the target matrix
  18531. */
  18532. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18533. /**
  18534. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18535. * @param startValue defines the start value
  18536. * @param endValue defines the end value
  18537. * @param gradient defines the gradient factor
  18538. * @returns the new matrix
  18539. */
  18540. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18541. /**
  18542. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18543. * @param startValue defines the start value
  18544. * @param endValue defines the end value
  18545. * @param gradient defines the gradient factor
  18546. * @param result defines the Matrix object where to store data
  18547. */
  18548. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18549. /**
  18550. * Builds a new matrix whose values are computed by:
  18551. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18552. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18553. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18554. * @param startValue defines the first matrix
  18555. * @param endValue defines the second matrix
  18556. * @param gradient defines the gradient between the two matrices
  18557. * @returns the new matrix
  18558. */
  18559. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18560. /**
  18561. * Update a matrix to values which are computed by:
  18562. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18563. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18564. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18565. * @param startValue defines the first matrix
  18566. * @param endValue defines the second matrix
  18567. * @param gradient defines the gradient between the two matrices
  18568. * @param result defines the target matrix
  18569. */
  18570. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18571. /**
  18572. * 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"
  18573. * This function works in left handed mode
  18574. * @param eye defines the final position of the entity
  18575. * @param target defines where the entity should look at
  18576. * @param up defines the up vector for the entity
  18577. * @returns the new matrix
  18578. */
  18579. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18580. /**
  18581. * 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".
  18582. * This function works in left handed mode
  18583. * @param eye defines the final position of the entity
  18584. * @param target defines where the entity should look at
  18585. * @param up defines the up vector for the entity
  18586. * @param result defines the target matrix
  18587. */
  18588. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18589. /**
  18590. * 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"
  18591. * This function works in right handed mode
  18592. * @param eye defines the final position of the entity
  18593. * @param target defines where the entity should look at
  18594. * @param up defines the up vector for the entity
  18595. * @returns the new matrix
  18596. */
  18597. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18598. /**
  18599. * 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".
  18600. * This function works in right handed mode
  18601. * @param eye defines the final position of the entity
  18602. * @param target defines where the entity should look at
  18603. * @param up defines the up vector for the entity
  18604. * @param result defines the target matrix
  18605. */
  18606. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18607. /**
  18608. * Create a left-handed orthographic projection matrix
  18609. * @param width defines the viewport width
  18610. * @param height defines the viewport height
  18611. * @param znear defines the near clip plane
  18612. * @param zfar defines the far clip plane
  18613. * @returns a new matrix as a left-handed orthographic projection matrix
  18614. */
  18615. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18616. /**
  18617. * Store a left-handed orthographic projection to a given matrix
  18618. * @param width defines the viewport width
  18619. * @param height defines the viewport height
  18620. * @param znear defines the near clip plane
  18621. * @param zfar defines the far clip plane
  18622. * @param result defines the target matrix
  18623. */
  18624. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18625. /**
  18626. * Create a left-handed orthographic projection matrix
  18627. * @param left defines the viewport left coordinate
  18628. * @param right defines the viewport right coordinate
  18629. * @param bottom defines the viewport bottom coordinate
  18630. * @param top defines the viewport top coordinate
  18631. * @param znear defines the near clip plane
  18632. * @param zfar defines the far clip plane
  18633. * @returns a new matrix as a left-handed orthographic projection matrix
  18634. */
  18635. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18636. /**
  18637. * Stores a left-handed orthographic projection into a given matrix
  18638. * @param left defines the viewport left coordinate
  18639. * @param right defines the viewport right coordinate
  18640. * @param bottom defines the viewport bottom coordinate
  18641. * @param top defines the viewport top coordinate
  18642. * @param znear defines the near clip plane
  18643. * @param zfar defines the far clip plane
  18644. * @param result defines the target matrix
  18645. */
  18646. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18647. /**
  18648. * Creates a right-handed orthographic projection matrix
  18649. * @param left defines the viewport left coordinate
  18650. * @param right defines the viewport right coordinate
  18651. * @param bottom defines the viewport bottom coordinate
  18652. * @param top defines the viewport top coordinate
  18653. * @param znear defines the near clip plane
  18654. * @param zfar defines the far clip plane
  18655. * @returns a new matrix as a right-handed orthographic projection matrix
  18656. */
  18657. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18658. /**
  18659. * Stores a right-handed orthographic projection into a given matrix
  18660. * @param left defines the viewport left coordinate
  18661. * @param right defines the viewport right coordinate
  18662. * @param bottom defines the viewport bottom coordinate
  18663. * @param top defines the viewport top coordinate
  18664. * @param znear defines the near clip plane
  18665. * @param zfar defines the far clip plane
  18666. * @param result defines the target matrix
  18667. */
  18668. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18669. /**
  18670. * Creates a left-handed perspective projection matrix
  18671. * @param width defines the viewport width
  18672. * @param height defines the viewport height
  18673. * @param znear defines the near clip plane
  18674. * @param zfar defines the far clip plane
  18675. * @returns a new matrix as a left-handed perspective projection matrix
  18676. */
  18677. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18678. /**
  18679. * Creates a left-handed perspective projection matrix
  18680. * @param fov defines the horizontal field of view
  18681. * @param aspect defines the aspect ratio
  18682. * @param znear defines the near clip plane
  18683. * @param zfar defines the far clip plane
  18684. * @returns a new matrix as a left-handed perspective projection matrix
  18685. */
  18686. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18687. /**
  18688. * Stores a left-handed perspective projection into a given matrix
  18689. * @param fov defines the horizontal field of view
  18690. * @param aspect defines the aspect ratio
  18691. * @param znear defines the near clip plane
  18692. * @param zfar defines the far clip plane
  18693. * @param result defines the target matrix
  18694. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18695. */
  18696. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18697. /**
  18698. * Creates a right-handed perspective projection matrix
  18699. * @param fov defines the horizontal field of view
  18700. * @param aspect defines the aspect ratio
  18701. * @param znear defines the near clip plane
  18702. * @param zfar defines the far clip plane
  18703. * @returns a new matrix as a right-handed perspective projection matrix
  18704. */
  18705. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18706. /**
  18707. * Stores a right-handed perspective projection into a given matrix
  18708. * @param fov defines the horizontal field of view
  18709. * @param aspect defines the aspect ratio
  18710. * @param znear defines the near clip plane
  18711. * @param zfar defines the far clip plane
  18712. * @param result defines the target matrix
  18713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18714. */
  18715. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18716. /**
  18717. * Stores a perspective projection for WebVR info a given matrix
  18718. * @param fov defines the field of view
  18719. * @param znear defines the near clip plane
  18720. * @param zfar defines the far clip plane
  18721. * @param result defines the target matrix
  18722. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18723. */
  18724. static PerspectiveFovWebVRToRef(fov: {
  18725. upDegrees: number;
  18726. downDegrees: number;
  18727. leftDegrees: number;
  18728. rightDegrees: number;
  18729. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18730. /**
  18731. * Computes a complete transformation matrix
  18732. * @param viewport defines the viewport to use
  18733. * @param world defines the world matrix
  18734. * @param view defines the view matrix
  18735. * @param projection defines the projection matrix
  18736. * @param zmin defines the near clip plane
  18737. * @param zmax defines the far clip plane
  18738. * @returns the transformation matrix
  18739. */
  18740. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18741. /**
  18742. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18743. * @param matrix defines the matrix to use
  18744. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18745. */
  18746. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18747. /**
  18748. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18749. * @param matrix defines the matrix to use
  18750. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18751. */
  18752. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18753. /**
  18754. * Compute the transpose of a given matrix
  18755. * @param matrix defines the matrix to transpose
  18756. * @returns the new matrix
  18757. */
  18758. static Transpose(matrix: Matrix): Matrix;
  18759. /**
  18760. * Compute the transpose of a matrix and store it in a target matrix
  18761. * @param matrix defines the matrix to transpose
  18762. * @param result defines the target matrix
  18763. */
  18764. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18765. /**
  18766. * Computes a reflection matrix from a plane
  18767. * @param plane defines the reflection plane
  18768. * @returns a new matrix
  18769. */
  18770. static Reflection(plane: Plane): Matrix;
  18771. /**
  18772. * Computes a reflection matrix from a plane
  18773. * @param plane defines the reflection plane
  18774. * @param result defines the target matrix
  18775. */
  18776. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18777. /**
  18778. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18779. * @param xaxis defines the value of the 1st axis
  18780. * @param yaxis defines the value of the 2nd axis
  18781. * @param zaxis defines the value of the 3rd axis
  18782. * @param result defines the target matrix
  18783. */
  18784. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18785. /**
  18786. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18787. * @param quat defines the quaternion to use
  18788. * @param result defines the target matrix
  18789. */
  18790. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18791. }
  18792. class Plane {
  18793. normal: Vector3;
  18794. d: number;
  18795. /**
  18796. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18797. */
  18798. constructor(a: number, b: number, c: number, d: number);
  18799. /**
  18800. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18801. */
  18802. asArray(): number[];
  18803. /**
  18804. * Returns a new plane copied from the current Plane.
  18805. */
  18806. clone(): Plane;
  18807. /**
  18808. * Returns the string "Plane".
  18809. */
  18810. getClassName(): string;
  18811. /**
  18812. * Returns the Plane hash code.
  18813. */
  18814. getHashCode(): number;
  18815. /**
  18816. * Normalize the current Plane in place.
  18817. * Returns the updated Plane.
  18818. */
  18819. normalize(): Plane;
  18820. /**
  18821. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18822. */
  18823. transform(transformation: Matrix): Plane;
  18824. /**
  18825. * Returns the dot product (float) of the point coordinates and the plane normal.
  18826. */
  18827. dotCoordinate(point: Vector3): number;
  18828. /**
  18829. * Updates the current Plane from the plane defined by the three given points.
  18830. * Returns the updated Plane.
  18831. */
  18832. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18833. /**
  18834. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18835. */
  18836. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18837. /**
  18838. * Returns the signed distance (float) from the given point to the Plane.
  18839. */
  18840. signedDistanceTo(point: Vector3): number;
  18841. /**
  18842. * Returns a new Plane from the given array.
  18843. */
  18844. static FromArray(array: ArrayLike<number>): Plane;
  18845. /**
  18846. * Returns a new Plane defined by the three given points.
  18847. */
  18848. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18849. /**
  18850. * Returns a new Plane the normal vector to this plane at the given origin point.
  18851. * Note : the vector "normal" is updated because normalized.
  18852. */
  18853. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18854. /**
  18855. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18856. */
  18857. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18858. }
  18859. class Viewport {
  18860. x: number;
  18861. y: number;
  18862. width: number;
  18863. height: number;
  18864. /**
  18865. * Creates a Viewport object located at (x, y) and sized (width, height).
  18866. */
  18867. constructor(x: number, y: number, width: number, height: number);
  18868. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18869. /**
  18870. * Returns a new Viewport copied from the current one.
  18871. */
  18872. clone(): Viewport;
  18873. }
  18874. class Frustum {
  18875. /**
  18876. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18877. */
  18878. static GetPlanes(transform: Matrix): Plane[];
  18879. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18880. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18881. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18882. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18883. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18884. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18885. /**
  18886. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18887. */
  18888. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18889. }
  18890. /** Defines supported spaces */
  18891. enum Space {
  18892. /** Local (object) space */
  18893. LOCAL = 0,
  18894. /** World space */
  18895. WORLD = 1,
  18896. /** Bone space */
  18897. BONE = 2
  18898. }
  18899. /** Defines the 3 main axes */
  18900. class Axis {
  18901. /** X axis */
  18902. static X: Vector3;
  18903. /** Y axis */
  18904. static Y: Vector3;
  18905. /** Z axis */
  18906. static Z: Vector3;
  18907. }
  18908. class BezierCurve {
  18909. /**
  18910. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18911. */
  18912. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18913. }
  18914. /**
  18915. * Defines potential orientation for back face culling
  18916. */
  18917. enum Orientation {
  18918. /**
  18919. * Clockwise
  18920. */
  18921. CW = 0,
  18922. /** Counter clockwise */
  18923. CCW = 1
  18924. }
  18925. /**
  18926. * Defines angle representation
  18927. */
  18928. class Angle {
  18929. private _radians;
  18930. /**
  18931. * Creates an Angle object of "radians" radians (float).
  18932. */
  18933. constructor(radians: number);
  18934. /**
  18935. * Get value in degrees
  18936. * @returns the Angle value in degrees (float)
  18937. */
  18938. degrees(): number;
  18939. /**
  18940. * Get value in radians
  18941. * @returns the Angle value in radians (float)
  18942. */
  18943. radians(): number;
  18944. /**
  18945. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18946. * @param a defines first vector
  18947. * @param b defines second vector
  18948. * @returns a new Angle
  18949. */
  18950. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18951. /**
  18952. * Gets a new Angle object from the given float in radians
  18953. * @param radians defines the angle value in radians
  18954. * @returns a new Angle
  18955. */
  18956. static FromRadians(radians: number): Angle;
  18957. /**
  18958. * Gets a new Angle object from the given float in degrees
  18959. * @param degrees defines the angle value in degrees
  18960. * @returns a new Angle
  18961. */
  18962. static FromDegrees(degrees: number): Angle;
  18963. }
  18964. class Arc2 {
  18965. startPoint: Vector2;
  18966. midPoint: Vector2;
  18967. endPoint: Vector2;
  18968. centerPoint: Vector2;
  18969. radius: number;
  18970. angle: Angle;
  18971. startAngle: Angle;
  18972. orientation: Orientation;
  18973. /**
  18974. * Creates an Arc object from the three given points : start, middle and end.
  18975. */
  18976. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18977. }
  18978. class Path2 {
  18979. private _points;
  18980. private _length;
  18981. closed: boolean;
  18982. /**
  18983. * Creates a Path2 object from the starting 2D coordinates x and y.
  18984. */
  18985. constructor(x: number, y: number);
  18986. /**
  18987. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18988. * Returns the updated Path2.
  18989. */
  18990. addLineTo(x: number, y: number): Path2;
  18991. /**
  18992. * 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.
  18993. * Returns the updated Path2.
  18994. */
  18995. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18996. /**
  18997. * Closes the Path2.
  18998. * Returns the Path2.
  18999. */
  19000. close(): Path2;
  19001. /**
  19002. * Returns the Path2 total length (float).
  19003. */
  19004. length(): number;
  19005. /**
  19006. * Returns the Path2 internal array of points.
  19007. */
  19008. getPoints(): Vector2[];
  19009. /**
  19010. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  19011. */
  19012. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  19013. /**
  19014. * Returns a new Path2 starting at the coordinates (x, y).
  19015. */
  19016. static StartingAt(x: number, y: number): Path2;
  19017. }
  19018. class Path3D {
  19019. path: Vector3[];
  19020. private _curve;
  19021. private _distances;
  19022. private _tangents;
  19023. private _normals;
  19024. private _binormals;
  19025. private _raw;
  19026. /**
  19027. * new Path3D(path, normal, raw)
  19028. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  19029. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  19030. * path : an array of Vector3, the curve axis of the Path3D
  19031. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  19032. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  19033. */
  19034. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  19035. /**
  19036. * Returns the Path3D array of successive Vector3 designing its curve.
  19037. */
  19038. getCurve(): Vector3[];
  19039. /**
  19040. * Returns an array populated with tangent vectors on each Path3D curve point.
  19041. */
  19042. getTangents(): Vector3[];
  19043. /**
  19044. * Returns an array populated with normal vectors on each Path3D curve point.
  19045. */
  19046. getNormals(): Vector3[];
  19047. /**
  19048. * Returns an array populated with binormal vectors on each Path3D curve point.
  19049. */
  19050. getBinormals(): Vector3[];
  19051. /**
  19052. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  19053. */
  19054. getDistances(): number[];
  19055. /**
  19056. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  19057. * Returns the same object updated.
  19058. */
  19059. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  19060. private _compute;
  19061. private _getFirstNonNullVector;
  19062. private _getLastNonNullVector;
  19063. private _normalVector;
  19064. }
  19065. class Curve3 {
  19066. private _points;
  19067. private _length;
  19068. /**
  19069. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  19070. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  19071. * @param v1 (Vector3) the control point
  19072. * @param v2 (Vector3) the end point of the Quadratic Bezier
  19073. * @param nbPoints (integer) the wanted number of points in the curve
  19074. */
  19075. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  19076. /**
  19077. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  19078. * @param v0 (Vector3) the origin point of the Cubic Bezier
  19079. * @param v1 (Vector3) the first control point
  19080. * @param v2 (Vector3) the second control point
  19081. * @param v3 (Vector3) the end point of the Cubic Bezier
  19082. * @param nbPoints (integer) the wanted number of points in the curve
  19083. */
  19084. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  19085. /**
  19086. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  19087. * @param p1 (Vector3) the origin point of the Hermite Spline
  19088. * @param t1 (Vector3) the tangent vector at the origin point
  19089. * @param p2 (Vector3) the end point of the Hermite Spline
  19090. * @param t2 (Vector3) the tangent vector at the end point
  19091. * @param nbPoints (integer) the wanted number of points in the curve
  19092. */
  19093. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  19094. /**
  19095. * Returns a Curve3 object along a CatmullRom Spline curve :
  19096. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  19097. * @param nbPoints (integer) the wanted number of points between each curve control points
  19098. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  19099. */
  19100. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  19101. /**
  19102. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  19103. * A Curve3 is designed from a series of successive Vector3.
  19104. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  19105. */
  19106. constructor(points: Vector3[]);
  19107. /**
  19108. * Returns the Curve3 stored array of successive Vector3
  19109. */
  19110. getPoints(): Vector3[];
  19111. /**
  19112. * Returns the computed length (float) of the curve.
  19113. */
  19114. length(): number;
  19115. /**
  19116. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  19117. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  19118. * curveA and curveB keep unchanged.
  19119. */
  19120. continue(curve: Curve3): Curve3;
  19121. private _computeLength;
  19122. }
  19123. class PositionNormalVertex {
  19124. position: Vector3;
  19125. normal: Vector3;
  19126. constructor(position?: Vector3, normal?: Vector3);
  19127. clone(): PositionNormalVertex;
  19128. }
  19129. class PositionNormalTextureVertex {
  19130. position: Vector3;
  19131. normal: Vector3;
  19132. uv: Vector2;
  19133. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  19134. clone(): PositionNormalTextureVertex;
  19135. }
  19136. class Tmp {
  19137. static Color3: Color3[];
  19138. static Color4: Color4[];
  19139. static Vector2: Vector2[];
  19140. static Vector3: Vector3[];
  19141. static Vector4: Vector4[];
  19142. static Quaternion: Quaternion[];
  19143. static Matrix: Matrix[];
  19144. }
  19145. }
  19146. declare module BABYLON {
  19147. /**
  19148. * Class representing spherical polynomial coefficients to the 3rd degree
  19149. */
  19150. class SphericalPolynomial {
  19151. /**
  19152. * The x coefficients of the spherical polynomial
  19153. */
  19154. x: Vector3;
  19155. /**
  19156. * The y coefficients of the spherical polynomial
  19157. */
  19158. y: Vector3;
  19159. /**
  19160. * The z coefficients of the spherical polynomial
  19161. */
  19162. z: Vector3;
  19163. /**
  19164. * The xx coefficients of the spherical polynomial
  19165. */
  19166. xx: Vector3;
  19167. /**
  19168. * The yy coefficients of the spherical polynomial
  19169. */
  19170. yy: Vector3;
  19171. /**
  19172. * The zz coefficients of the spherical polynomial
  19173. */
  19174. zz: Vector3;
  19175. /**
  19176. * The xy coefficients of the spherical polynomial
  19177. */
  19178. xy: Vector3;
  19179. /**
  19180. * The yz coefficients of the spherical polynomial
  19181. */
  19182. yz: Vector3;
  19183. /**
  19184. * The zx coefficients of the spherical polynomial
  19185. */
  19186. zx: Vector3;
  19187. /**
  19188. * Adds an ambient color to the spherical polynomial
  19189. * @param color the color to add
  19190. */
  19191. addAmbient(color: Color3): void;
  19192. /**
  19193. * Scales the spherical polynomial by the given amount
  19194. * @param scale the amount to scale
  19195. */
  19196. scale(scale: number): void;
  19197. /**
  19198. * Gets the spherical polynomial from harmonics
  19199. * @param harmonics the spherical harmonics
  19200. * @returns the spherical polynomial
  19201. */
  19202. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  19203. /**
  19204. * Constructs a spherical polynomial from an array.
  19205. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  19206. * @returns the spherical polynomial
  19207. */
  19208. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  19209. }
  19210. /**
  19211. * Class representing spherical harmonics coefficients to the 3rd degree
  19212. */
  19213. class SphericalHarmonics {
  19214. /**
  19215. * The l0,0 coefficients of the spherical harmonics
  19216. */
  19217. l00: Vector3;
  19218. /**
  19219. * The l1,-1 coefficients of the spherical harmonics
  19220. */
  19221. l1_1: Vector3;
  19222. /**
  19223. * The l1,0 coefficients of the spherical harmonics
  19224. */
  19225. l10: Vector3;
  19226. /**
  19227. * The l1,1 coefficients of the spherical harmonics
  19228. */
  19229. l11: Vector3;
  19230. /**
  19231. * The l2,-2 coefficients of the spherical harmonics
  19232. */
  19233. l2_2: Vector3;
  19234. /**
  19235. * The l2,-1 coefficients of the spherical harmonics
  19236. */
  19237. l2_1: Vector3;
  19238. /**
  19239. * The l2,0 coefficients of the spherical harmonics
  19240. */
  19241. l20: Vector3;
  19242. /**
  19243. * The l2,1 coefficients of the spherical harmonics
  19244. */
  19245. l21: Vector3;
  19246. /**
  19247. * The l2,2 coefficients of the spherical harmonics
  19248. */
  19249. lL22: Vector3;
  19250. /**
  19251. * Adds a light to the spherical harmonics
  19252. * @param direction the direction of the light
  19253. * @param color the color of the light
  19254. * @param deltaSolidAngle the delta solid angle of the light
  19255. */
  19256. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19257. /**
  19258. * Scales the spherical harmonics by the given amount
  19259. * @param scale the amount to scale
  19260. */
  19261. scale(scale: number): void;
  19262. /**
  19263. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19264. *
  19265. * ```
  19266. * E_lm = A_l * L_lm
  19267. * ```
  19268. *
  19269. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19270. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19271. * the scaling factors are given in equation 9.
  19272. */
  19273. convertIncidentRadianceToIrradiance(): void;
  19274. /**
  19275. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19276. *
  19277. * ```
  19278. * L = (1/pi) * E * rho
  19279. * ```
  19280. *
  19281. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19282. */
  19283. convertIrradianceToLambertianRadiance(): void;
  19284. /**
  19285. * Gets the spherical harmonics from polynomial
  19286. * @param polynomial the spherical polynomial
  19287. * @returns the spherical harmonics
  19288. */
  19289. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19290. /**
  19291. * Constructs a spherical harmonics from an array.
  19292. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19293. * @returns the spherical harmonics
  19294. */
  19295. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19296. }
  19297. }
  19298. declare module BABYLON {
  19299. /**
  19300. * Class used to store all common mesh properties
  19301. */
  19302. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19303. /** No occlusion */
  19304. static OCCLUSION_TYPE_NONE: number;
  19305. /** Occlusion set to optimisitic */
  19306. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19307. /** Occlusion set to strict */
  19308. static OCCLUSION_TYPE_STRICT: number;
  19309. /** Use an accurante occlusion algorithm */
  19310. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19311. /** Use a conservative occlusion algorithm */
  19312. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19313. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19314. static readonly CULLINGSTRATEGY_STANDARD: number;
  19315. /** Culling strategy with bounding sphere only and then frustum culling */
  19316. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19317. /**
  19318. * No billboard
  19319. */
  19320. static readonly BILLBOARDMODE_NONE: number;
  19321. /** Billboard on X axis */
  19322. static readonly BILLBOARDMODE_X: number;
  19323. /** Billboard on Y axis */
  19324. static readonly BILLBOARDMODE_Y: number;
  19325. /** Billboard on Z axis */
  19326. static readonly BILLBOARDMODE_Z: number;
  19327. /** Billboard on all axes */
  19328. static readonly BILLBOARDMODE_ALL: number;
  19329. private _facetPositions;
  19330. private _facetNormals;
  19331. private _facetPartitioning;
  19332. private _facetNb;
  19333. private _partitioningSubdivisions;
  19334. private _partitioningBBoxRatio;
  19335. private _facetDataEnabled;
  19336. private _facetParameters;
  19337. private _bbSize;
  19338. private _subDiv;
  19339. private _facetDepthSort;
  19340. private _facetDepthSortEnabled;
  19341. private _depthSortedIndices;
  19342. private _depthSortedFacets;
  19343. private _facetDepthSortFunction;
  19344. private _facetDepthSortFrom;
  19345. private _facetDepthSortOrigin;
  19346. private _invertedMatrix;
  19347. /** Gets ot sets the culling strategy to use to find visible meshes */
  19348. cullingStrategy: number;
  19349. /**
  19350. * Gets the number of facets in the mesh
  19351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19352. */
  19353. readonly facetNb: number;
  19354. /**
  19355. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19357. */
  19358. partitioningSubdivisions: number;
  19359. /**
  19360. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19361. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19363. */
  19364. partitioningBBoxRatio: number;
  19365. /**
  19366. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19367. * Works only for updatable meshes.
  19368. * Doesn't work with multi-materials
  19369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19370. */
  19371. mustDepthSortFacets: boolean;
  19372. /**
  19373. * The location (Vector3) where the facet depth sort must be computed from.
  19374. * By default, the active camera position.
  19375. * Used only when facet depth sort is enabled
  19376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19377. */
  19378. facetDepthSortFrom: Vector3;
  19379. /**
  19380. * gets a boolean indicating if facetData is enabled
  19381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19382. */
  19383. readonly isFacetDataEnabled: boolean;
  19384. /** @hidden */
  19385. _updateNonUniformScalingState(value: boolean): boolean;
  19386. /**
  19387. * An event triggered when this mesh collides with another one
  19388. */
  19389. onCollideObservable: Observable<AbstractMesh>;
  19390. private _onCollideObserver;
  19391. /** Set a function to call when this mesh collides with another one */
  19392. onCollide: () => void;
  19393. /**
  19394. * An event triggered when the collision's position changes
  19395. */
  19396. onCollisionPositionChangeObservable: Observable<Vector3>;
  19397. private _onCollisionPositionChangeObserver;
  19398. /** Set a function to call when the collision's position changes */
  19399. onCollisionPositionChange: () => void;
  19400. /**
  19401. * An event triggered when material is changed
  19402. */
  19403. onMaterialChangedObservable: Observable<AbstractMesh>;
  19404. /**
  19405. * Gets or sets the orientation for POV movement & rotation
  19406. */
  19407. definedFacingForward: boolean;
  19408. /**
  19409. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19410. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19411. * * 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.
  19412. * @see http://doc.babylonjs.com/features/occlusionquery
  19413. */
  19414. occlusionQueryAlgorithmType: number;
  19415. /**
  19416. * 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:
  19417. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19418. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19419. * * 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.
  19420. * @see http://doc.babylonjs.com/features/occlusionquery
  19421. */
  19422. occlusionType: number;
  19423. /**
  19424. * 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.
  19425. * The default value is -1 which means don't break the query and wait till the result
  19426. * @see http://doc.babylonjs.com/features/occlusionquery
  19427. */
  19428. occlusionRetryCount: number;
  19429. /** @hidden */
  19430. _occlusionInternalRetryCounter: number;
  19431. /** @hidden */
  19432. _isOccluded: boolean;
  19433. /**
  19434. * 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
  19435. * @see http://doc.babylonjs.com/features/occlusionquery
  19436. */
  19437. isOccluded: boolean;
  19438. /** @hidden */
  19439. _isOcclusionQueryInProgress: boolean;
  19440. /**
  19441. * Flag to check the progress status of the query
  19442. * @see http://doc.babylonjs.com/features/occlusionquery
  19443. */
  19444. readonly isOcclusionQueryInProgress: boolean;
  19445. /** @hidden */
  19446. _occlusionQuery: Nullable<WebGLQuery>;
  19447. private _visibility;
  19448. /**
  19449. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19450. */
  19451. /**
  19452. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19453. */
  19454. visibility: number;
  19455. /** Gets or sets the alpha index used to sort transparent meshes
  19456. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19457. */
  19458. alphaIndex: number;
  19459. /**
  19460. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19461. */
  19462. isVisible: boolean;
  19463. /**
  19464. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19465. */
  19466. isPickable: boolean;
  19467. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19468. showSubMeshesBoundingBox: boolean;
  19469. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19471. */
  19472. isBlocker: boolean;
  19473. /**
  19474. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19475. */
  19476. enablePointerMoveEvents: boolean;
  19477. /**
  19478. * Specifies the rendering group id for this mesh (0 by default)
  19479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19480. */
  19481. renderingGroupId: number;
  19482. private _material;
  19483. /** Gets or sets current material */
  19484. material: Nullable<Material>;
  19485. private _receiveShadows;
  19486. /**
  19487. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19488. * @see http://doc.babylonjs.com/babylon101/shadows
  19489. */
  19490. receiveShadows: boolean;
  19491. /**
  19492. * Gets or sets a boolean indicating if the outline must be rendered as well
  19493. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19494. */
  19495. renderOutline: boolean;
  19496. /** Defines color to use when rendering outline */
  19497. outlineColor: Color3;
  19498. /** Define width to use when rendering outline */
  19499. outlineWidth: number;
  19500. /**
  19501. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19502. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19503. */
  19504. renderOverlay: boolean;
  19505. /** Defines color to use when rendering overlay */
  19506. overlayColor: Color3;
  19507. /** Defines alpha to use when rendering overlay */
  19508. overlayAlpha: number;
  19509. private _hasVertexAlpha;
  19510. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19511. hasVertexAlpha: boolean;
  19512. private _useVertexColors;
  19513. /** 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) */
  19514. useVertexColors: boolean;
  19515. private _computeBonesUsingShaders;
  19516. /**
  19517. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19518. */
  19519. computeBonesUsingShaders: boolean;
  19520. private _numBoneInfluencers;
  19521. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19522. numBoneInfluencers: number;
  19523. private _applyFog;
  19524. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19525. applyFog: boolean;
  19526. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19527. useOctreeForRenderingSelection: boolean;
  19528. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19529. useOctreeForPicking: boolean;
  19530. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19531. useOctreeForCollisions: boolean;
  19532. private _layerMask;
  19533. /**
  19534. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19535. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19536. */
  19537. layerMask: number;
  19538. /**
  19539. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19540. */
  19541. alwaysSelectAsActiveMesh: boolean;
  19542. /**
  19543. * Gets or sets the current action manager
  19544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19545. */
  19546. actionManager: Nullable<ActionManager>;
  19547. /**
  19548. * Gets or sets impostor used for physic simulation
  19549. * @see http://doc.babylonjs.com/features/physics_engine
  19550. */
  19551. physicsImpostor: Nullable<PhysicsImpostor>;
  19552. private _checkCollisions;
  19553. private _collisionMask;
  19554. private _collisionGroup;
  19555. /**
  19556. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19558. */
  19559. ellipsoid: Vector3;
  19560. /**
  19561. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19563. */
  19564. ellipsoidOffset: Vector3;
  19565. private _collider;
  19566. private _oldPositionForCollisions;
  19567. private _diffPositionForCollisions;
  19568. /**
  19569. * Gets or sets a collision mask used to mask collisions (default is -1).
  19570. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19571. */
  19572. collisionMask: number;
  19573. /**
  19574. * Gets or sets the current collision group mask (-1 by default).
  19575. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19576. */
  19577. collisionGroup: number;
  19578. /**
  19579. * Defines edge width used when edgesRenderer is enabled
  19580. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19581. */
  19582. edgesWidth: number;
  19583. /**
  19584. * Defines edge color used when edgesRenderer is enabled
  19585. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19586. */
  19587. edgesColor: Color4;
  19588. /** @hidden */
  19589. _edgesRenderer: Nullable<EdgesRenderer>;
  19590. private _collisionsTransformMatrix;
  19591. private _collisionsScalingMatrix;
  19592. /** @hidden */
  19593. _masterMesh: Nullable<AbstractMesh>;
  19594. /** @hidden */
  19595. _boundingInfo: Nullable<BoundingInfo>;
  19596. /** @hidden */
  19597. _renderId: number;
  19598. /**
  19599. * Gets or sets the list of subMeshes
  19600. * @see http://doc.babylonjs.com/how_to/multi_materials
  19601. */
  19602. subMeshes: SubMesh[];
  19603. /** @hidden */
  19604. _submeshesOctree: Octree<SubMesh>;
  19605. /** @hidden */
  19606. _intersectionsInProgress: AbstractMesh[];
  19607. /** @hidden */
  19608. _unIndexed: boolean;
  19609. /** @hidden */
  19610. _lightSources: Light[];
  19611. /** @hidden */
  19612. readonly _positions: Nullable<Vector3[]>;
  19613. /** @hidden */
  19614. _waitingActions: any;
  19615. /** @hidden */
  19616. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19617. private _skeleton;
  19618. /** @hidden */
  19619. _bonesTransformMatrices: Nullable<Float32Array>;
  19620. /**
  19621. * Gets or sets a skeleton to apply skining transformations
  19622. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19623. */
  19624. skeleton: Nullable<Skeleton>;
  19625. /**
  19626. * Creates a new AbstractMesh
  19627. * @param name defines the name of the mesh
  19628. * @param scene defines the hosting scene
  19629. */
  19630. constructor(name: string, scene?: Nullable<Scene>);
  19631. /**
  19632. * Returns the string "AbstractMesh"
  19633. * @returns "AbstractMesh"
  19634. */
  19635. getClassName(): string;
  19636. /**
  19637. * Gets a string representation of the current mesh
  19638. * @param fullDetails defines a boolean indicating if full details must be included
  19639. * @returns a string representation of the current mesh
  19640. */
  19641. toString(fullDetails?: boolean): string;
  19642. /** @hidden */
  19643. _rebuild(): void;
  19644. /** @hidden */
  19645. _resyncLightSources(): void;
  19646. /** @hidden */
  19647. _resyncLighSource(light: Light): void;
  19648. /** @hidden */
  19649. _unBindEffect(): void;
  19650. /** @hidden */
  19651. _removeLightSource(light: Light): void;
  19652. private _markSubMeshesAsDirty;
  19653. /** @hidden */
  19654. _markSubMeshesAsLightDirty(): void;
  19655. /** @hidden */
  19656. _markSubMeshesAsAttributesDirty(): void;
  19657. /** @hidden */
  19658. _markSubMeshesAsMiscDirty(): void;
  19659. /**
  19660. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19661. */
  19662. scaling: Vector3;
  19663. /**
  19664. * Disables the mesh edge rendering mode
  19665. * @returns the currentAbstractMesh
  19666. */
  19667. disableEdgesRendering(): AbstractMesh;
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the currentAbstractMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19677. /**
  19678. * Gets the edgesRenderer associated with the mesh
  19679. */
  19680. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19681. /**
  19682. * Returns true if the mesh is blocked. Implemented by child classes
  19683. */
  19684. readonly isBlocked: boolean;
  19685. /**
  19686. * Returns the mesh itself by default. Implemented by child classes
  19687. * @param camera defines the camera to use to pick the right LOD level
  19688. * @returns the currentAbstractMesh
  19689. */
  19690. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19691. /**
  19692. * Returns 0 by default. Implemented by child classes
  19693. * @returns an integer
  19694. */
  19695. getTotalVertices(): number;
  19696. /**
  19697. * Returns null by default. Implemented by child classes
  19698. * @returns null
  19699. */
  19700. getIndices(): Nullable<IndicesArray>;
  19701. /**
  19702. * Returns the array of the requested vertex data kind. Implemented by child classes
  19703. * @param kind defines the vertex data kind to use
  19704. * @returns null
  19705. */
  19706. getVerticesData(kind: string): Nullable<FloatArray>;
  19707. /**
  19708. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19709. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19710. * Note that a new underlying VertexBuffer object is created each call.
  19711. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19712. * @param kind defines vertex data kind:
  19713. * * BABYLON.VertexBuffer.PositionKind
  19714. * * BABYLON.VertexBuffer.UVKind
  19715. * * BABYLON.VertexBuffer.UV2Kind
  19716. * * BABYLON.VertexBuffer.UV3Kind
  19717. * * BABYLON.VertexBuffer.UV4Kind
  19718. * * BABYLON.VertexBuffer.UV5Kind
  19719. * * BABYLON.VertexBuffer.UV6Kind
  19720. * * BABYLON.VertexBuffer.ColorKind
  19721. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19722. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19723. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19724. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19725. * @param data defines the data source
  19726. * @param updatable defines if the data must be flagged as updatable (or static)
  19727. * @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
  19728. * @returns the current mesh
  19729. */
  19730. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19731. /**
  19732. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19733. * If the mesh has no geometry, it is simply returned as it is.
  19734. * @param kind defines vertex data kind:
  19735. * * BABYLON.VertexBuffer.PositionKind
  19736. * * BABYLON.VertexBuffer.UVKind
  19737. * * BABYLON.VertexBuffer.UV2Kind
  19738. * * BABYLON.VertexBuffer.UV3Kind
  19739. * * BABYLON.VertexBuffer.UV4Kind
  19740. * * BABYLON.VertexBuffer.UV5Kind
  19741. * * BABYLON.VertexBuffer.UV6Kind
  19742. * * BABYLON.VertexBuffer.ColorKind
  19743. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19744. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19745. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19746. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19747. * @param data defines the data source
  19748. * @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
  19749. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19750. * @returns the current mesh
  19751. */
  19752. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19753. /**
  19754. * Sets the mesh indices,
  19755. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19756. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19757. * @param totalVertices Defines the total number of vertices
  19758. * @returns the current mesh
  19759. */
  19760. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19761. /**
  19762. * Gets a boolean indicating if specific vertex data is present
  19763. * @param kind defines the vertex data kind to use
  19764. * @returns true is data kind is present
  19765. */
  19766. isVerticesDataPresent(kind: string): boolean;
  19767. /**
  19768. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19769. * @returns a BoundingInfo
  19770. */
  19771. getBoundingInfo(): BoundingInfo;
  19772. /**
  19773. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19774. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19775. * @returns the current mesh
  19776. */
  19777. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19778. /**
  19779. * Overwrite the current bounding info
  19780. * @param boundingInfo defines the new bounding info
  19781. * @returns the current mesh
  19782. */
  19783. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19784. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19785. readonly useBones: boolean;
  19786. /** @hidden */
  19787. _preActivate(): void;
  19788. /** @hidden */
  19789. _preActivateForIntermediateRendering(renderId: number): void;
  19790. /** @hidden */
  19791. _activate(renderId: number): void;
  19792. /**
  19793. * Gets the current world matrix
  19794. * @returns a Matrix
  19795. */
  19796. getWorldMatrix(): Matrix;
  19797. /** @hidden */
  19798. _getWorldMatrixDeterminant(): number;
  19799. /**
  19800. * Perform relative position change from the point of view of behind the front of the mesh.
  19801. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19802. * Supports definition of mesh facing forward or backward
  19803. * @param amountRight defines the distance on the right axis
  19804. * @param amountUp defines the distance on the up axis
  19805. * @param amountForward defines the distance on the forward axis
  19806. * @returns the current mesh
  19807. */
  19808. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19809. /**
  19810. * Calculate relative position change from the point of view of behind the front of the mesh.
  19811. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19812. * Supports definition of mesh facing forward or backward
  19813. * @param amountRight defines the distance on the right axis
  19814. * @param amountUp defines the distance on the up axis
  19815. * @param amountForward defines the distance on the forward axis
  19816. * @returns the new displacement vector
  19817. */
  19818. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19819. /**
  19820. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19821. * Supports definition of mesh facing forward or backward
  19822. * @param flipBack defines the flip
  19823. * @param twirlClockwise defines the twirl
  19824. * @param tiltRight defines the tilt
  19825. * @returns the current mesh
  19826. */
  19827. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19828. /**
  19829. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19830. * Supports definition of mesh facing forward or backward.
  19831. * @param flipBack defines the flip
  19832. * @param twirlClockwise defines the twirl
  19833. * @param tiltRight defines the tilt
  19834. * @returns the new rotation vector
  19835. */
  19836. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19837. /**
  19838. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19839. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19840. * @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
  19841. * @returns the new bounding vectors
  19842. */
  19843. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19844. min: Vector3;
  19845. max: Vector3;
  19846. };
  19847. /** @hidden */
  19848. _updateBoundingInfo(): AbstractMesh;
  19849. /** @hidden */
  19850. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19851. /** @hidden */
  19852. protected _afterComputeWorldMatrix(): void;
  19853. /**
  19854. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19855. * A mesh is in the frustum if its bounding box intersects the frustum
  19856. * @param frustumPlanes defines the frustum to test
  19857. * @returns true if the mesh is in the frustum planes
  19858. */
  19859. isInFrustum(frustumPlanes: Plane[]): boolean;
  19860. /**
  19861. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19862. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19863. * @param frustumPlanes defines the frustum to test
  19864. * @returns true if the mesh is completely in the frustum planes
  19865. */
  19866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19867. /**
  19868. * True if the mesh intersects another mesh or a SolidParticle object
  19869. * @param mesh defines a target mesh or SolidParticle to test
  19870. * @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)
  19871. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19872. * @returns true if there is an intersection
  19873. */
  19874. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19875. /**
  19876. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19877. * @param point defines the point to test
  19878. * @returns true if there is an intersection
  19879. */
  19880. intersectsPoint(point: Vector3): boolean;
  19881. /**
  19882. * Gets the current physics impostor
  19883. * @see http://doc.babylonjs.com/features/physics_engine
  19884. * @returns a physics impostor or null
  19885. */
  19886. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19887. /**
  19888. * Gets the position of the current mesh in camera space
  19889. * @param camera defines the camera to use
  19890. * @returns a position
  19891. */
  19892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19893. /**
  19894. * Returns the distance from the mesh to the active camera
  19895. * @param camera defines the camera to use
  19896. * @returns the distance
  19897. */
  19898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19899. /**
  19900. * Apply a physic impulse to the mesh
  19901. * @param force defines the force to apply
  19902. * @param contactPoint defines where to apply the force
  19903. * @returns the current mesh
  19904. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19905. */
  19906. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19907. /**
  19908. * Creates a physic joint between two meshes
  19909. * @param otherMesh defines the other mesh to use
  19910. * @param pivot1 defines the pivot to use on this mesh
  19911. * @param pivot2 defines the pivot to use on the other mesh
  19912. * @param options defines additional options (can be plugin dependent)
  19913. * @returns the current mesh
  19914. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19915. */
  19916. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19917. /**
  19918. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19920. */
  19921. checkCollisions: boolean;
  19922. /**
  19923. * Gets Collider object used to compute collisions (not physics)
  19924. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19925. */
  19926. readonly collider: Collider;
  19927. /**
  19928. * Move the mesh using collision engine
  19929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19930. * @param displacement defines the requested displacement vector
  19931. * @returns the current mesh
  19932. */
  19933. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19934. private _onCollisionPositionChange;
  19935. /**
  19936. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19937. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19938. * @param maxCapacity defines the maximum size of each block (64 by default)
  19939. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19940. * @returns the new octree
  19941. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19943. */
  19944. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19945. /** @hidden */
  19946. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19947. /** @hidden */
  19948. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19949. /** @hidden */
  19950. _checkCollision(collider: Collider): AbstractMesh;
  19951. /** @hidden */
  19952. _generatePointsArray(): boolean;
  19953. /**
  19954. * Checks if the passed Ray intersects with the mesh
  19955. * @param ray defines the ray to use
  19956. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19957. * @returns the picking info
  19958. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19959. */
  19960. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19961. /**
  19962. * Clones the current mesh
  19963. * @param name defines the mesh name
  19964. * @param newParent defines the new mesh parent
  19965. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19966. * @returns the new mesh
  19967. */
  19968. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19969. /**
  19970. * Disposes all the submeshes of the current meshnp
  19971. * @returns the current mesh
  19972. */
  19973. releaseSubMeshes(): AbstractMesh;
  19974. /**
  19975. * Releases resources associated with this abstract mesh.
  19976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19978. */
  19979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19980. /**
  19981. * Adds the passed mesh as a child to the current mesh
  19982. * @param mesh defines the child mesh
  19983. * @returns the current mesh
  19984. */
  19985. addChild(mesh: AbstractMesh): AbstractMesh;
  19986. /**
  19987. * Removes the passed mesh from the current mesh children list
  19988. * @param mesh defines the child mesh
  19989. * @returns the current mesh
  19990. */
  19991. removeChild(mesh: AbstractMesh): AbstractMesh;
  19992. /** @hidden */
  19993. private _initFacetData;
  19994. /**
  19995. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19996. * This method can be called within the render loop.
  19997. * 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
  19998. * @returns the current mesh
  19999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20000. */
  20001. updateFacetData(): AbstractMesh;
  20002. /**
  20003. * Returns the facetLocalNormals array.
  20004. * The normals are expressed in the mesh local spac
  20005. * @returns an array of Vector3
  20006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20007. */
  20008. getFacetLocalNormals(): Vector3[];
  20009. /**
  20010. * Returns the facetLocalPositions array.
  20011. * The facet positions are expressed in the mesh local space
  20012. * @returns an array of Vector3
  20013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20014. */
  20015. getFacetLocalPositions(): Vector3[];
  20016. /**
  20017. * Returns the facetLocalPartioning array
  20018. * @returns an array of array of numbers
  20019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20020. */
  20021. getFacetLocalPartitioning(): number[][];
  20022. /**
  20023. * Returns the i-th facet position in the world system.
  20024. * This method allocates a new Vector3 per call
  20025. * @param i defines the facet index
  20026. * @returns a new Vector3
  20027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20028. */
  20029. getFacetPosition(i: number): Vector3;
  20030. /**
  20031. * Sets the reference Vector3 with the i-th facet position in the world system
  20032. * @param i defines the facet index
  20033. * @param ref defines the target vector
  20034. * @returns the current mesh
  20035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20036. */
  20037. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20038. /**
  20039. * Returns the i-th facet normal in the world system.
  20040. * This method allocates a new Vector3 per call
  20041. * @param i defines the facet index
  20042. * @returns a new Vector3
  20043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20044. */
  20045. getFacetNormal(i: number): Vector3;
  20046. /**
  20047. * Sets the reference Vector3 with the i-th facet normal in the world system
  20048. * @param i defines the facet index
  20049. * @param ref defines the target vector
  20050. * @returns the current mesh
  20051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20052. */
  20053. getFacetNormalToRef(i: number, ref: Vector3): this;
  20054. /**
  20055. * 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)
  20056. * @param x defines x coordinate
  20057. * @param y defines y coordinate
  20058. * @param z defines z coordinate
  20059. * @returns the array of facet indexes
  20060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20061. */
  20062. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20063. /**
  20064. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20065. * @param projected sets as the (x,y,z) world projection on the facet
  20066. * @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
  20067. * @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
  20068. * @param x defines x coordinate
  20069. * @param y defines y coordinate
  20070. * @param z defines z coordinate
  20071. * @returns the face index if found (or null instead)
  20072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20073. */
  20074. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20075. /**
  20076. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20077. * @param projected sets as the (x,y,z) local projection on the facet
  20078. * @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
  20079. * @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
  20080. * @param x defines x coordinate
  20081. * @param y defines y coordinate
  20082. * @param z defines z coordinate
  20083. * @returns the face index if found (or null instead)
  20084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20085. */
  20086. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20087. /**
  20088. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20089. * @returns the parameters
  20090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20091. */
  20092. getFacetDataParameters(): any;
  20093. /**
  20094. * Disables the feature FacetData and frees the related memory
  20095. * @returns the current mesh
  20096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20097. */
  20098. disableFacetData(): AbstractMesh;
  20099. /**
  20100. * Updates the AbstractMesh indices array
  20101. * @param indices defines the data source
  20102. * @returns the current mesh
  20103. */
  20104. updateIndices(indices: IndicesArray): AbstractMesh;
  20105. /**
  20106. * Creates new normals data for the mesh
  20107. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20108. * @returns the current mesh
  20109. */
  20110. createNormals(updatable: boolean): AbstractMesh;
  20111. /**
  20112. * Align the mesh with a normal
  20113. * @param normal defines the normal to use
  20114. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20115. * @returns the current mesh
  20116. */
  20117. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20118. /** @hidden */
  20119. _checkOcclusionQuery(): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. class Buffer {
  20124. private _engine;
  20125. private _buffer;
  20126. /** @hidden */
  20127. _data: Nullable<DataArray>;
  20128. private _updatable;
  20129. private _instanced;
  20130. /**
  20131. * Gets the byte stride.
  20132. */
  20133. readonly byteStride: number;
  20134. /**
  20135. * Constructor
  20136. * @param engine the engine
  20137. * @param data the data to use for this buffer
  20138. * @param updatable whether the data is updatable
  20139. * @param stride the stride (optional)
  20140. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20141. * @param instanced whether the buffer is instanced (optional)
  20142. * @param useBytes set to true if the stride in in bytes (optional)
  20143. */
  20144. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20145. /**
  20146. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20147. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20148. * @param offset defines offset in the buffer (0 by default)
  20149. * @param size defines the size in floats of attributes (position is 3 for instance)
  20150. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20151. * @param instanced defines if the vertex buffer contains indexed data
  20152. * @param useBytes defines if the offset and stride are in bytes
  20153. * @returns the new vertex buffer
  20154. */
  20155. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20156. isUpdatable(): boolean;
  20157. getData(): Nullable<DataArray>;
  20158. getBuffer(): Nullable<WebGLBuffer>;
  20159. /**
  20160. * Gets the stride in float32 units (i.e. byte stride / 4).
  20161. * May not be an integer if the byte stride is not divisible by 4.
  20162. * DEPRECATED. Use byteStride instead.
  20163. * @returns the stride in float32 units
  20164. */
  20165. getStrideSize(): number;
  20166. create(data?: Nullable<DataArray>): void;
  20167. /** @hidden */
  20168. _rebuild(): void;
  20169. update(data: DataArray): void;
  20170. /**
  20171. * Updates the data directly.
  20172. * @param data the new data
  20173. * @param offset the new offset
  20174. * @param vertexCount the vertex count (optional)
  20175. * @param useBytes set to true if the offset is in bytes
  20176. */
  20177. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20178. dispose(): void;
  20179. }
  20180. }
  20181. declare module BABYLON {
  20182. class CSG {
  20183. private polygons;
  20184. matrix: Matrix;
  20185. position: Vector3;
  20186. rotation: Vector3;
  20187. rotationQuaternion: Nullable<Quaternion>;
  20188. scaling: Vector3;
  20189. static FromMesh(mesh: Mesh): CSG;
  20190. private static FromPolygons;
  20191. clone(): CSG;
  20192. union(csg: CSG): CSG;
  20193. unionInPlace(csg: CSG): void;
  20194. subtract(csg: CSG): CSG;
  20195. subtractInPlace(csg: CSG): void;
  20196. intersect(csg: CSG): CSG;
  20197. intersectInPlace(csg: CSG): void;
  20198. inverse(): CSG;
  20199. inverseInPlace(): void;
  20200. copyTransformAttributes(csg: CSG): CSG;
  20201. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20202. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20203. }
  20204. }
  20205. declare module BABYLON {
  20206. /**
  20207. * Class used to store geometry data (vertex buffers + index buffer)
  20208. */
  20209. class Geometry implements IGetSetVerticesData {
  20210. /**
  20211. * Gets or sets the unique ID of the geometry
  20212. */
  20213. id: string;
  20214. /**
  20215. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20216. */
  20217. delayLoadState: number;
  20218. /**
  20219. * Gets the file containing the data to load when running in delay load state
  20220. */
  20221. delayLoadingFile: Nullable<string>;
  20222. /**
  20223. * Callback called when the geometry is updated
  20224. */
  20225. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20226. private _scene;
  20227. private _engine;
  20228. private _meshes;
  20229. private _totalVertices;
  20230. /** @hidden */
  20231. _indices: IndicesArray;
  20232. /** @hidden */
  20233. _vertexBuffers: {
  20234. [key: string]: VertexBuffer;
  20235. };
  20236. private _isDisposed;
  20237. private _extend;
  20238. private _boundingBias;
  20239. /** @hidden */
  20240. _delayInfo: Array<string>;
  20241. private _indexBuffer;
  20242. private _indexBufferIsUpdatable;
  20243. /** @hidden */
  20244. _boundingInfo: Nullable<BoundingInfo>;
  20245. /** @hidden */
  20246. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20247. /** @hidden */
  20248. _softwareSkinningRenderId: number;
  20249. private _vertexArrayObjects;
  20250. private _updatable;
  20251. /** @hidden */
  20252. _positions: Nullable<Vector3[]>;
  20253. /**
  20254. * 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
  20255. */
  20256. /**
  20257. * 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
  20258. */
  20259. boundingBias: Vector2;
  20260. /**
  20261. * Static function used to attach a new empty geometry to a mesh
  20262. * @param mesh defines the mesh to attach the geometry to
  20263. * @returns the new {BABYLON.Geometry}
  20264. */
  20265. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20266. /**
  20267. * Creates a new geometry
  20268. * @param id defines the unique ID
  20269. * @param scene defines the hosting scene
  20270. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20271. * @param updatable defines if geometry must be updatable (false by default)
  20272. * @param mesh defines the mesh that will be associated with the geometry
  20273. */
  20274. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20275. /**
  20276. * Gets the current extend of the geometry
  20277. */
  20278. readonly extend: {
  20279. minimum: Vector3;
  20280. maximum: Vector3;
  20281. };
  20282. /**
  20283. * Gets the hosting scene
  20284. * @returns the hosting {BABYLON.Scene}
  20285. */
  20286. getScene(): Scene;
  20287. /**
  20288. * Gets the hosting engine
  20289. * @returns the hosting {BABYLON.Engine}
  20290. */
  20291. getEngine(): Engine;
  20292. /**
  20293. * Defines if the geometry is ready to use
  20294. * @returns true if the geometry is ready to be used
  20295. */
  20296. isReady(): boolean;
  20297. /**
  20298. * Gets a value indicating that the geometry should not be serialized
  20299. */
  20300. readonly doNotSerialize: boolean;
  20301. /** @hidden */
  20302. _rebuild(): void;
  20303. /**
  20304. * Affects all geometry data in one call
  20305. * @param vertexData defines the geometry data
  20306. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20307. */
  20308. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20309. /**
  20310. * Set specific vertex data
  20311. * @param kind defines the data kind (Position, normal, etc...)
  20312. * @param data defines the vertex data to use
  20313. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20314. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20315. */
  20316. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20317. /**
  20318. * Removes a specific vertex data
  20319. * @param kind defines the data kind (Position, normal, etc...)
  20320. */
  20321. removeVerticesData(kind: string): void;
  20322. /**
  20323. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20324. * @param buffer defines the vertex buffer to use
  20325. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20326. */
  20327. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20328. /**
  20329. * Update a specific vertex buffer
  20330. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20331. * It will do nothing if the buffer is not updatable
  20332. * @param kind defines the data kind (Position, normal, etc...)
  20333. * @param data defines the data to use
  20334. * @param offset defines the offset in the target buffer where to store the data
  20335. * @param useBytes set to true if the offset is in bytes
  20336. */
  20337. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20338. /**
  20339. * Update a specific vertex buffer
  20340. * This function will create a new buffer if the current one is not updatable
  20341. * @param kind defines the data kind (Position, normal, etc...)
  20342. * @param data defines the data to use
  20343. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20344. */
  20345. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20346. private _updateBoundingInfo;
  20347. /** @hidden */
  20348. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20349. /**
  20350. * Gets total number of vertices
  20351. * @returns the total number of vertices
  20352. */
  20353. getTotalVertices(): number;
  20354. /**
  20355. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20356. * @param kind defines the data kind (Position, normal, etc...)
  20357. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20358. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20359. * @returns a float array containing vertex data
  20360. */
  20361. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20362. /**
  20363. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20364. * @param kind defines the data kind (Position, normal, etc...)
  20365. * @returns true if the vertex buffer with the specified kind is updatable
  20366. */
  20367. isVertexBufferUpdatable(kind: string): boolean;
  20368. /**
  20369. * Gets a specific vertex buffer
  20370. * @param kind defines the data kind (Position, normal, etc...)
  20371. * @returns a {BABYLON.VertexBuffer}
  20372. */
  20373. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20374. /**
  20375. * Returns all vertex buffers
  20376. * @return an object holding all vertex buffers indexed by kind
  20377. */
  20378. getVertexBuffers(): Nullable<{
  20379. [key: string]: VertexBuffer;
  20380. }>;
  20381. /**
  20382. * Gets a boolean indicating if specific vertex buffer is present
  20383. * @param kind defines the data kind (Position, normal, etc...)
  20384. * @returns true if data is present
  20385. */
  20386. isVerticesDataPresent(kind: string): boolean;
  20387. /**
  20388. * Gets a list of all attached data kinds (Position, normal, etc...)
  20389. * @returns a list of string containing all kinds
  20390. */
  20391. getVerticesDataKinds(): string[];
  20392. /**
  20393. * Update index buffer
  20394. * @param indices defines the indices to store in the index buffer
  20395. * @param offset defines the offset in the target buffer where to store the data
  20396. */
  20397. updateIndices(indices: IndicesArray, offset?: number): void;
  20398. /**
  20399. * Creates a new index buffer
  20400. * @param indices defines the indices to store in the index buffer
  20401. * @param totalVertices defines the total number of vertices (could be null)
  20402. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20403. */
  20404. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20405. /**
  20406. * Return the total number of indices
  20407. * @returns the total number of indices
  20408. */
  20409. getTotalIndices(): number;
  20410. /**
  20411. * Gets the index buffer array
  20412. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20413. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20414. * @returns the index buffer array
  20415. */
  20416. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20417. /**
  20418. * Gets the index buffer
  20419. * @return the index buffer
  20420. */
  20421. getIndexBuffer(): Nullable<WebGLBuffer>;
  20422. /** @hidden */
  20423. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20424. /**
  20425. * Release the associated resources for a specific mesh
  20426. * @param mesh defines the source mesh
  20427. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20428. */
  20429. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20430. /**
  20431. * Apply current geometry to a given mesh
  20432. * @param mesh defines the mesh to apply geometry to
  20433. */
  20434. applyToMesh(mesh: Mesh): void;
  20435. private _updateExtend;
  20436. private _applyToMesh;
  20437. private notifyUpdate;
  20438. /**
  20439. * Load the geometry if it was flagged as delay loaded
  20440. * @param scene defines the hosting scene
  20441. * @param onLoaded defines a callback called when the geometry is loaded
  20442. */
  20443. load(scene: Scene, onLoaded?: () => void): void;
  20444. private _queueLoad;
  20445. /**
  20446. * Invert the geometry to move from a right handed system to a left handed one.
  20447. */
  20448. toLeftHanded(): void;
  20449. /** @hidden */
  20450. _resetPointsArrayCache(): void;
  20451. /** @hidden */
  20452. _generatePointsArray(): boolean;
  20453. /**
  20454. * Gets a value indicating if the geometry is disposed
  20455. * @returns true if the geometry was disposed
  20456. */
  20457. isDisposed(): boolean;
  20458. private _disposeVertexArrayObjects;
  20459. /**
  20460. * Free all associated resources
  20461. */
  20462. dispose(): void;
  20463. /**
  20464. * Clone the current geometry into a new geometry
  20465. * @param id defines the unique ID of the new geometry
  20466. * @returns a new geometry object
  20467. */
  20468. copy(id: string): Geometry;
  20469. /**
  20470. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20471. * @return a JSON representation of the current geometry data (without the vertices data)
  20472. */
  20473. serialize(): any;
  20474. private toNumberArray;
  20475. /**
  20476. * Serialize all vertices data into a JSON oject
  20477. * @returns a JSON representation of the current geometry data
  20478. */
  20479. serializeVerticeData(): any;
  20480. /**
  20481. * Extracts a clone of a mesh geometry
  20482. * @param mesh defines the source mesh
  20483. * @param id defines the unique ID of the new geometry object
  20484. * @returns the new geometry object
  20485. */
  20486. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20487. /**
  20488. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20489. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20490. * Be aware Math.random() could cause collisions, but:
  20491. * "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"
  20492. * @returns a string containing a new GUID
  20493. */
  20494. static RandomId(): string;
  20495. /** @hidden */
  20496. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20497. private static _CleanMatricesWeights;
  20498. /**
  20499. * Create a new geometry from persisted data (Using .babylon file format)
  20500. * @param parsedVertexData defines the persisted data
  20501. * @param scene defines the hosting scene
  20502. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20503. * @returns the new geometry object
  20504. */
  20505. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20506. }
  20507. /**
  20508. * Abstract class used to provide common services for all typed geometries
  20509. * @hidden
  20510. */
  20511. class _PrimitiveGeometry extends Geometry {
  20512. private _canBeRegenerated;
  20513. private _beingRegenerated;
  20514. /**
  20515. * Creates a new typed geometry
  20516. * @param id defines the unique ID of the geometry
  20517. * @param scene defines the hosting scene
  20518. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20519. * @param mesh defines the hosting mesh (can be null)
  20520. */
  20521. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20522. /**
  20523. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20524. * @returns true if the geometry can be regenerated
  20525. */
  20526. canBeRegenerated(): boolean;
  20527. /**
  20528. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20529. */
  20530. regenerate(): void;
  20531. /**
  20532. * Clone the geometry
  20533. * @param id defines the unique ID of the new geometry
  20534. * @returns the new geometry
  20535. */
  20536. asNewGeometry(id: string): Geometry;
  20537. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20539. /** @hidden */
  20540. _regenerateVertexData(): VertexData;
  20541. copy(id: string): Geometry;
  20542. serialize(): any;
  20543. }
  20544. /**
  20545. * Creates a ribbon geometry
  20546. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20547. */
  20548. class RibbonGeometry extends _PrimitiveGeometry {
  20549. /**
  20550. * Defines the array of paths to use
  20551. */
  20552. pathArray: Vector3[][];
  20553. /**
  20554. * Defines if the last and first points of each path in your pathArray must be joined
  20555. */
  20556. closeArray: boolean;
  20557. /**
  20558. * Defines if the last and first points of each path in your pathArray must be joined
  20559. */
  20560. closePath: boolean;
  20561. /**
  20562. * Defines the offset between points
  20563. */
  20564. offset: number;
  20565. /**
  20566. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20567. */
  20568. side: number;
  20569. /**
  20570. * Creates a ribbon geometry
  20571. * @param id defines the unique ID of the geometry
  20572. * @param scene defines the hosting scene
  20573. * @param pathArray defines the array of paths to use
  20574. * @param closeArray defines if the last path and the first path must be joined
  20575. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20576. * @param offset defines the offset between points
  20577. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20578. * @param mesh defines the hosting mesh (can be null)
  20579. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20580. */
  20581. constructor(id: string, scene: Scene,
  20582. /**
  20583. * Defines the array of paths to use
  20584. */
  20585. pathArray: Vector3[][],
  20586. /**
  20587. * Defines if the last and first points of each path in your pathArray must be joined
  20588. */
  20589. closeArray: boolean,
  20590. /**
  20591. * Defines if the last and first points of each path in your pathArray must be joined
  20592. */
  20593. closePath: boolean,
  20594. /**
  20595. * Defines the offset between points
  20596. */
  20597. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20598. /**
  20599. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20600. */
  20601. side?: number);
  20602. /** @hidden */
  20603. _regenerateVertexData(): VertexData;
  20604. copy(id: string): Geometry;
  20605. }
  20606. /**
  20607. * Creates a box geometry
  20608. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20609. */
  20610. class BoxGeometry extends _PrimitiveGeometry {
  20611. /**
  20612. * Defines the zise of the box (width, height and depth are the same)
  20613. */
  20614. size: number;
  20615. /**
  20616. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20617. */
  20618. side: number;
  20619. /**
  20620. * Creates a box geometry
  20621. * @param id defines the unique ID of the geometry
  20622. * @param scene defines the hosting scene
  20623. * @param size defines the zise of the box (width, height and depth are the same)
  20624. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20625. * @param mesh defines the hosting mesh (can be null)
  20626. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20627. */
  20628. constructor(id: string, scene: Scene,
  20629. /**
  20630. * Defines the zise of the box (width, height and depth are the same)
  20631. */
  20632. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20633. /**
  20634. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20635. */
  20636. side?: number);
  20637. /** @hidden */
  20638. _regenerateVertexData(): VertexData;
  20639. copy(id: string): Geometry;
  20640. serialize(): any;
  20641. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20642. }
  20643. /**
  20644. * Creates a sphere geometry
  20645. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20646. */
  20647. class SphereGeometry extends _PrimitiveGeometry {
  20648. /**
  20649. * Defines the number of segments to use to create the sphere
  20650. */
  20651. segments: number;
  20652. /**
  20653. * Defines the diameter of the sphere
  20654. */
  20655. diameter: number;
  20656. /**
  20657. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20658. */
  20659. side: number;
  20660. /**
  20661. * Create a new sphere geometry
  20662. * @param id defines the unique ID of the geometry
  20663. * @param scene defines the hosting scene
  20664. * @param segments defines the number of segments to use to create the sphere
  20665. * @param diameter defines the diameter of the sphere
  20666. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20667. * @param mesh defines the hosting mesh (can be null)
  20668. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20669. */
  20670. constructor(id: string, scene: Scene,
  20671. /**
  20672. * Defines the number of segments to use to create the sphere
  20673. */
  20674. segments: number,
  20675. /**
  20676. * Defines the diameter of the sphere
  20677. */
  20678. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20679. /**
  20680. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20681. */
  20682. side?: number);
  20683. /** @hidden */
  20684. _regenerateVertexData(): VertexData;
  20685. copy(id: string): Geometry;
  20686. serialize(): any;
  20687. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20688. }
  20689. /**
  20690. * Creates a disc geometry
  20691. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20692. */
  20693. class DiscGeometry extends _PrimitiveGeometry {
  20694. /**
  20695. * Defines the radius of the disc
  20696. */
  20697. radius: number;
  20698. /**
  20699. * Defines the tesselation factor to apply to the disc
  20700. */
  20701. tessellation: number;
  20702. /**
  20703. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20704. */
  20705. side: number;
  20706. /**
  20707. * Creates a new disc geometry
  20708. * @param id defines the unique ID of the geometry
  20709. * @param scene defines the hosting scene
  20710. * @param radius defines the radius of the disc
  20711. * @param tessellation defines the tesselation factor to apply to the disc
  20712. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20713. * @param mesh defines the hosting mesh (can be null)
  20714. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20715. */
  20716. constructor(id: string, scene: Scene,
  20717. /**
  20718. * Defines the radius of the disc
  20719. */
  20720. radius: number,
  20721. /**
  20722. * Defines the tesselation factor to apply to the disc
  20723. */
  20724. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20725. /**
  20726. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20727. */
  20728. side?: number);
  20729. /** @hidden */
  20730. _regenerateVertexData(): VertexData;
  20731. copy(id: string): Geometry;
  20732. }
  20733. /**
  20734. * Creates a new cylinder geometry
  20735. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20736. */
  20737. class CylinderGeometry extends _PrimitiveGeometry {
  20738. /**
  20739. * Defines the height of the cylinder
  20740. */
  20741. height: number;
  20742. /**
  20743. * Defines the diameter of the cylinder's top cap
  20744. */
  20745. diameterTop: number;
  20746. /**
  20747. * Defines the diameter of the cylinder's bottom cap
  20748. */
  20749. diameterBottom: number;
  20750. /**
  20751. * Defines the tessellation factor to apply to the cylinder
  20752. */
  20753. tessellation: number;
  20754. /**
  20755. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20756. */
  20757. subdivisions: number;
  20758. /**
  20759. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20760. */
  20761. side: number;
  20762. /**
  20763. * Creates a new cylinder geometry
  20764. * @param id defines the unique ID of the geometry
  20765. * @param scene defines the hosting scene
  20766. * @param height defines the height of the cylinder
  20767. * @param diameterTop defines the diameter of the cylinder's top cap
  20768. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20769. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20770. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20771. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20772. * @param mesh defines the hosting mesh (can be null)
  20773. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20774. */
  20775. constructor(id: string, scene: Scene,
  20776. /**
  20777. * Defines the height of the cylinder
  20778. */
  20779. height: number,
  20780. /**
  20781. * Defines the diameter of the cylinder's top cap
  20782. */
  20783. diameterTop: number,
  20784. /**
  20785. * Defines the diameter of the cylinder's bottom cap
  20786. */
  20787. diameterBottom: number,
  20788. /**
  20789. * Defines the tessellation factor to apply to the cylinder
  20790. */
  20791. tessellation: number,
  20792. /**
  20793. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20794. */
  20795. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20796. /**
  20797. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20798. */
  20799. side?: number);
  20800. /** @hidden */
  20801. _regenerateVertexData(): VertexData;
  20802. copy(id: string): Geometry;
  20803. serialize(): any;
  20804. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20805. }
  20806. /**
  20807. * Creates a new torus geometry
  20808. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20809. */
  20810. class TorusGeometry extends _PrimitiveGeometry {
  20811. /**
  20812. * Defines the diameter of the torus
  20813. */
  20814. diameter: number;
  20815. /**
  20816. * Defines the thickness of the torus (ie. internal diameter)
  20817. */
  20818. thickness: number;
  20819. /**
  20820. * Defines the tesselation factor to apply to the torus
  20821. */
  20822. tessellation: number;
  20823. /**
  20824. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20825. */
  20826. side: number;
  20827. /**
  20828. * Creates a new torus geometry
  20829. * @param id defines the unique ID of the geometry
  20830. * @param scene defines the hosting scene
  20831. * @param diameter defines the diameter of the torus
  20832. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20833. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20834. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20835. * @param mesh defines the hosting mesh (can be null)
  20836. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20837. */
  20838. constructor(id: string, scene: Scene,
  20839. /**
  20840. * Defines the diameter of the torus
  20841. */
  20842. diameter: number,
  20843. /**
  20844. * Defines the thickness of the torus (ie. internal diameter)
  20845. */
  20846. thickness: number,
  20847. /**
  20848. * Defines the tesselation factor to apply to the torus
  20849. */
  20850. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20851. /**
  20852. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20853. */
  20854. side?: number);
  20855. /** @hidden */
  20856. _regenerateVertexData(): VertexData;
  20857. copy(id: string): Geometry;
  20858. serialize(): any;
  20859. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20860. }
  20861. /**
  20862. * Creates a new ground geometry
  20863. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20864. */
  20865. class GroundGeometry extends _PrimitiveGeometry {
  20866. /**
  20867. * Defines the width of the ground
  20868. */
  20869. width: number;
  20870. /**
  20871. * Defines the height of the ground
  20872. */
  20873. height: number;
  20874. /**
  20875. * Defines the subdivisions to apply to the ground
  20876. */
  20877. subdivisions: number;
  20878. /**
  20879. * Creates a new ground geometry
  20880. * @param id defines the unique ID of the geometry
  20881. * @param scene defines the hosting scene
  20882. * @param width defines the width of the ground
  20883. * @param height defines the height of the ground
  20884. * @param subdivisions defines the subdivisions to apply to the ground
  20885. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20886. * @param mesh defines the hosting mesh (can be null)
  20887. */
  20888. constructor(id: string, scene: Scene,
  20889. /**
  20890. * Defines the width of the ground
  20891. */
  20892. width: number,
  20893. /**
  20894. * Defines the height of the ground
  20895. */
  20896. height: number,
  20897. /**
  20898. * Defines the subdivisions to apply to the ground
  20899. */
  20900. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20901. /** @hidden */
  20902. _regenerateVertexData(): VertexData;
  20903. copy(id: string): Geometry;
  20904. serialize(): any;
  20905. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20906. }
  20907. /**
  20908. * Creates a tiled ground geometry
  20909. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20910. */
  20911. class TiledGroundGeometry extends _PrimitiveGeometry {
  20912. /**
  20913. * Defines the minimum value on X axis
  20914. */
  20915. xmin: number;
  20916. /**
  20917. * Defines the minimum value on Z axis
  20918. */
  20919. zmin: number;
  20920. /**
  20921. * Defines the maximum value on X axis
  20922. */
  20923. xmax: number;
  20924. /**
  20925. * Defines the maximum value on Z axis
  20926. */
  20927. zmax: number;
  20928. /**
  20929. * Defines the subdivisions to apply to the ground
  20930. */
  20931. subdivisions: {
  20932. w: number;
  20933. h: number;
  20934. };
  20935. /**
  20936. * Defines the precision to use when computing the tiles
  20937. */
  20938. precision: {
  20939. w: number;
  20940. h: number;
  20941. };
  20942. /**
  20943. * Creates a tiled ground geometry
  20944. * @param id defines the unique ID of the geometry
  20945. * @param scene defines the hosting scene
  20946. * @param xmin defines the minimum value on X axis
  20947. * @param zmin defines the minimum value on Z axis
  20948. * @param xmax defines the maximum value on X axis
  20949. * @param zmax defines the maximum value on Z axis
  20950. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20951. * @param precision defines the precision to use when computing the tiles
  20952. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20953. * @param mesh defines the hosting mesh (can be null)
  20954. */
  20955. constructor(id: string, scene: Scene,
  20956. /**
  20957. * Defines the minimum value on X axis
  20958. */
  20959. xmin: number,
  20960. /**
  20961. * Defines the minimum value on Z axis
  20962. */
  20963. zmin: number,
  20964. /**
  20965. * Defines the maximum value on X axis
  20966. */
  20967. xmax: number,
  20968. /**
  20969. * Defines the maximum value on Z axis
  20970. */
  20971. zmax: number,
  20972. /**
  20973. * Defines the subdivisions to apply to the ground
  20974. */
  20975. subdivisions: {
  20976. w: number;
  20977. h: number;
  20978. },
  20979. /**
  20980. * Defines the precision to use when computing the tiles
  20981. */
  20982. precision: {
  20983. w: number;
  20984. h: number;
  20985. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20986. /** @hidden */
  20987. _regenerateVertexData(): VertexData;
  20988. copy(id: string): Geometry;
  20989. }
  20990. /**
  20991. * Creates a plane geometry
  20992. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20993. */
  20994. class PlaneGeometry extends _PrimitiveGeometry {
  20995. /**
  20996. * Defines the size of the plane (width === height)
  20997. */
  20998. size: number;
  20999. /**
  21000. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21001. */
  21002. side: number;
  21003. /**
  21004. * Creates a plane geometry
  21005. * @param id defines the unique ID of the geometry
  21006. * @param scene defines the hosting scene
  21007. * @param size defines the size of the plane (width === height)
  21008. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21009. * @param mesh defines the hosting mesh (can be null)
  21010. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21011. */
  21012. constructor(id: string, scene: Scene,
  21013. /**
  21014. * Defines the size of the plane (width === height)
  21015. */
  21016. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21017. /**
  21018. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21019. */
  21020. side?: number);
  21021. /** @hidden */
  21022. _regenerateVertexData(): VertexData;
  21023. copy(id: string): Geometry;
  21024. serialize(): any;
  21025. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21026. }
  21027. /**
  21028. * Creates a torus knot geometry
  21029. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21030. */
  21031. class TorusKnotGeometry extends _PrimitiveGeometry {
  21032. /**
  21033. * Defines the radius of the torus knot
  21034. */
  21035. radius: number;
  21036. /**
  21037. * Defines the thickness of the torus knot tube
  21038. */
  21039. tube: number;
  21040. /**
  21041. * Defines the number of radial segments
  21042. */
  21043. radialSegments: number;
  21044. /**
  21045. * Defines the number of tubular segments
  21046. */
  21047. tubularSegments: number;
  21048. /**
  21049. * Defines the first number of windings
  21050. */
  21051. p: number;
  21052. /**
  21053. * Defines the second number of windings
  21054. */
  21055. q: number;
  21056. /**
  21057. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21058. */
  21059. side: number;
  21060. /**
  21061. * Creates a torus knot geometry
  21062. * @param id defines the unique ID of the geometry
  21063. * @param scene defines the hosting scene
  21064. * @param radius defines the radius of the torus knot
  21065. * @param tube defines the thickness of the torus knot tube
  21066. * @param radialSegments defines the number of radial segments
  21067. * @param tubularSegments defines the number of tubular segments
  21068. * @param p defines the first number of windings
  21069. * @param q defines the second number of windings
  21070. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21071. * @param mesh defines the hosting mesh (can be null)
  21072. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21073. */
  21074. constructor(id: string, scene: Scene,
  21075. /**
  21076. * Defines the radius of the torus knot
  21077. */
  21078. radius: number,
  21079. /**
  21080. * Defines the thickness of the torus knot tube
  21081. */
  21082. tube: number,
  21083. /**
  21084. * Defines the number of radial segments
  21085. */
  21086. radialSegments: number,
  21087. /**
  21088. * Defines the number of tubular segments
  21089. */
  21090. tubularSegments: number,
  21091. /**
  21092. * Defines the first number of windings
  21093. */
  21094. p: number,
  21095. /**
  21096. * Defines the second number of windings
  21097. */
  21098. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21099. /**
  21100. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21101. */
  21102. side?: number);
  21103. /** @hidden */
  21104. _regenerateVertexData(): VertexData;
  21105. copy(id: string): Geometry;
  21106. serialize(): any;
  21107. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21108. }
  21109. }
  21110. declare module BABYLON {
  21111. class GroundMesh extends Mesh {
  21112. generateOctree: boolean;
  21113. private _heightQuads;
  21114. /** @hidden */
  21115. _subdivisionsX: number;
  21116. /** @hidden */
  21117. _subdivisionsY: number;
  21118. /** @hidden */
  21119. _width: number;
  21120. /** @hidden */
  21121. _height: number;
  21122. /** @hidden */
  21123. _minX: number;
  21124. /** @hidden */
  21125. _maxX: number;
  21126. /** @hidden */
  21127. _minZ: number;
  21128. /** @hidden */
  21129. _maxZ: number;
  21130. constructor(name: string, scene: Scene);
  21131. getClassName(): string;
  21132. readonly subdivisions: number;
  21133. readonly subdivisionsX: number;
  21134. readonly subdivisionsY: number;
  21135. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21136. /**
  21137. * Returns a height (y) value in the Worl system :
  21138. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21139. * Returns the ground y position if (x, z) are outside the ground surface.
  21140. */
  21141. getHeightAtCoordinates(x: number, z: number): number;
  21142. /**
  21143. * Returns a normalized vector (Vector3) orthogonal to the ground
  21144. * at the ground coordinates (x, z) expressed in the World system.
  21145. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21146. */
  21147. getNormalAtCoordinates(x: number, z: number): Vector3;
  21148. /**
  21149. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21150. * at the ground coordinates (x, z) expressed in the World system.
  21151. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21152. * Returns the GroundMesh.
  21153. */
  21154. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21155. /**
  21156. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21157. * if the ground has been updated.
  21158. * This can be used in the render loop.
  21159. * Returns the GroundMesh.
  21160. */
  21161. updateCoordinateHeights(): GroundMesh;
  21162. private _getFacetAt;
  21163. private _initHeightQuads;
  21164. private _computeHeightQuads;
  21165. serialize(serializationObject: any): void;
  21166. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21167. }
  21168. }
  21169. declare module BABYLON {
  21170. /**
  21171. * Creates an instance based on a source mesh.
  21172. */
  21173. class InstancedMesh extends AbstractMesh {
  21174. private _sourceMesh;
  21175. private _currentLOD;
  21176. constructor(name: string, source: Mesh);
  21177. /**
  21178. * Returns the string "InstancedMesh".
  21179. */
  21180. getClassName(): string;
  21181. readonly receiveShadows: boolean;
  21182. readonly material: Nullable<Material>;
  21183. readonly visibility: number;
  21184. readonly skeleton: Nullable<Skeleton>;
  21185. renderingGroupId: number;
  21186. /**
  21187. * Returns the total number of vertices (integer).
  21188. */
  21189. getTotalVertices(): number;
  21190. readonly sourceMesh: Mesh;
  21191. /**
  21192. * Is this node ready to be used/rendered
  21193. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21194. * @return {boolean} is it ready
  21195. */
  21196. isReady(completeCheck?: boolean): boolean;
  21197. /**
  21198. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21199. */
  21200. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21201. /**
  21202. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21203. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21204. * The `data` are either a numeric array either a Float32Array.
  21205. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21206. * 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).
  21207. * Note that a new underlying VertexBuffer object is created each call.
  21208. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21209. *
  21210. * Possible `kind` values :
  21211. * - BABYLON.VertexBuffer.PositionKind
  21212. * - BABYLON.VertexBuffer.UVKind
  21213. * - BABYLON.VertexBuffer.UV2Kind
  21214. * - BABYLON.VertexBuffer.UV3Kind
  21215. * - BABYLON.VertexBuffer.UV4Kind
  21216. * - BABYLON.VertexBuffer.UV5Kind
  21217. * - BABYLON.VertexBuffer.UV6Kind
  21218. * - BABYLON.VertexBuffer.ColorKind
  21219. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21220. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21221. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21222. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21223. *
  21224. * Returns the Mesh.
  21225. */
  21226. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21227. /**
  21228. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21229. * If the mesh has no geometry, it is simply returned as it is.
  21230. * The `data` are either a numeric array either a Float32Array.
  21231. * No new underlying VertexBuffer object is created.
  21232. * 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.
  21233. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21234. *
  21235. * Possible `kind` values :
  21236. * - BABYLON.VertexBuffer.PositionKind
  21237. * - BABYLON.VertexBuffer.UVKind
  21238. * - BABYLON.VertexBuffer.UV2Kind
  21239. * - BABYLON.VertexBuffer.UV3Kind
  21240. * - BABYLON.VertexBuffer.UV4Kind
  21241. * - BABYLON.VertexBuffer.UV5Kind
  21242. * - BABYLON.VertexBuffer.UV6Kind
  21243. * - BABYLON.VertexBuffer.ColorKind
  21244. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21245. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21246. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21247. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21248. *
  21249. * Returns the Mesh.
  21250. */
  21251. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21252. /**
  21253. * Sets the mesh indices.
  21254. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21255. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21256. * This method creates a new index buffer each call.
  21257. * Returns the Mesh.
  21258. */
  21259. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21260. /**
  21261. * Boolean : True if the mesh owns the requested kind of data.
  21262. */
  21263. isVerticesDataPresent(kind: string): boolean;
  21264. /**
  21265. * Returns an array of indices (IndicesArray).
  21266. */
  21267. getIndices(): Nullable<IndicesArray>;
  21268. readonly _positions: Nullable<Vector3[]>;
  21269. /**
  21270. * Sets a new updated BoundingInfo to the mesh.
  21271. * Returns the mesh.
  21272. */
  21273. refreshBoundingInfo(): InstancedMesh;
  21274. /** @hidden */
  21275. _preActivate(): InstancedMesh;
  21276. /** @hidden */
  21277. _activate(renderId: number): InstancedMesh;
  21278. /**
  21279. * Returns the current associated LOD AbstractMesh.
  21280. */
  21281. getLOD(camera: Camera): AbstractMesh;
  21282. /** @hidden */
  21283. _syncSubMeshes(): InstancedMesh;
  21284. /** @hidden */
  21285. _generatePointsArray(): boolean;
  21286. /**
  21287. * Creates a new InstancedMesh from the current mesh.
  21288. * - name (string) : the cloned mesh name
  21289. * - newParent (optional Node) : the optional Node to parent the clone to.
  21290. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21291. *
  21292. * Returns the clone.
  21293. */
  21294. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21295. /**
  21296. * Disposes the InstancedMesh.
  21297. * Returns nothing.
  21298. */
  21299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21300. }
  21301. }
  21302. declare module BABYLON {
  21303. class LinesMesh extends Mesh {
  21304. useVertexColor?: boolean | undefined;
  21305. useVertexAlpha?: boolean | undefined;
  21306. color: Color3;
  21307. alpha: number;
  21308. /**
  21309. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21310. * This margin is expressed in world space coordinates, so its value may vary.
  21311. * Default value is 0.1
  21312. * @returns the intersection Threshold value.
  21313. */
  21314. /**
  21315. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21316. * This margin is expressed in world space coordinates, so its value may vary.
  21317. * @param value the new threshold to apply
  21318. */
  21319. intersectionThreshold: number;
  21320. private _intersectionThreshold;
  21321. private _colorShader;
  21322. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21323. /**
  21324. * Returns the string "LineMesh"
  21325. */
  21326. getClassName(): string;
  21327. /**
  21328. * @hidden
  21329. */
  21330. /**
  21331. * @hidden
  21332. */
  21333. material: Material;
  21334. /**
  21335. * @hidden
  21336. */
  21337. readonly checkCollisions: boolean;
  21338. createInstance(name: string): InstancedMesh;
  21339. /** @hidden */
  21340. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21341. /** @hidden */
  21342. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21343. dispose(doNotRecurse?: boolean): void;
  21344. /**
  21345. * Returns a new LineMesh object cloned from the current one.
  21346. */
  21347. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21348. /**
  21349. * Enables the edge rendering mode on the mesh.
  21350. * This mode makes the mesh edges visible
  21351. * @param epsilon defines the maximal distance between two angles to detect a face
  21352. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21353. * @returns the currentAbstractMesh
  21354. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21355. */
  21356. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21357. }
  21358. }
  21359. declare module BABYLON {
  21360. /**
  21361. * @hidden
  21362. **/
  21363. class _InstancesBatch {
  21364. mustReturn: boolean;
  21365. visibleInstances: Nullable<InstancedMesh[]>[];
  21366. renderSelf: boolean[];
  21367. }
  21368. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21369. static _FRONTSIDE: number;
  21370. static _BACKSIDE: number;
  21371. static _DOUBLESIDE: number;
  21372. static _DEFAULTSIDE: number;
  21373. static _NO_CAP: number;
  21374. static _CAP_START: number;
  21375. static _CAP_END: number;
  21376. static _CAP_ALL: number;
  21377. /**
  21378. * Mesh side orientation : usually the external or front surface
  21379. */
  21380. static readonly FRONTSIDE: number;
  21381. /**
  21382. * Mesh side orientation : usually the internal or back surface
  21383. */
  21384. static readonly BACKSIDE: number;
  21385. /**
  21386. * Mesh side orientation : both internal and external or front and back surfaces
  21387. */
  21388. static readonly DOUBLESIDE: number;
  21389. /**
  21390. * Mesh side orientation : by default, `FRONTSIDE`
  21391. */
  21392. static readonly DEFAULTSIDE: number;
  21393. /**
  21394. * Mesh cap setting : no cap
  21395. */
  21396. static readonly NO_CAP: number;
  21397. /**
  21398. * Mesh cap setting : one cap at the beginning of the mesh
  21399. */
  21400. static readonly CAP_START: number;
  21401. /**
  21402. * Mesh cap setting : one cap at the end of the mesh
  21403. */
  21404. static readonly CAP_END: number;
  21405. /**
  21406. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21407. */
  21408. static readonly CAP_ALL: number;
  21409. private _onBeforeRenderObservable;
  21410. private _onAfterRenderObservable;
  21411. private _onBeforeDrawObservable;
  21412. /**
  21413. * An event triggered before rendering the mesh
  21414. */
  21415. readonly onBeforeRenderObservable: Observable<Mesh>;
  21416. /**
  21417. * An event triggered after rendering the mesh
  21418. */
  21419. readonly onAfterRenderObservable: Observable<Mesh>;
  21420. /**
  21421. * An event triggered before drawing the mesh
  21422. */
  21423. readonly onBeforeDrawObservable: Observable<Mesh>;
  21424. private _onBeforeDrawObserver;
  21425. onBeforeDraw: () => void;
  21426. delayLoadState: number;
  21427. instances: InstancedMesh[];
  21428. delayLoadingFile: string;
  21429. /** @hidden */
  21430. _binaryInfo: any;
  21431. private _LODLevels;
  21432. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21433. private _morphTargetManager;
  21434. morphTargetManager: Nullable<MorphTargetManager>;
  21435. /** @hidden */
  21436. _geometry: Nullable<Geometry>;
  21437. /** @hidden */
  21438. _delayInfo: Array<string>;
  21439. /** @hidden */
  21440. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21441. /** @hidden */
  21442. _visibleInstances: any;
  21443. private _renderIdForInstances;
  21444. private _batchCache;
  21445. private _instancesBufferSize;
  21446. private _instancesBuffer;
  21447. private _instancesData;
  21448. private _overridenInstanceCount;
  21449. private _effectiveMaterial;
  21450. /** @hidden */
  21451. _shouldGenerateFlatShading: boolean;
  21452. private _preActivateId;
  21453. /** @hidden */
  21454. _originalBuilderSideOrientation: number;
  21455. overrideMaterialSideOrientation: Nullable<number>;
  21456. private _areNormalsFrozen;
  21457. private _sourcePositions;
  21458. private _sourceNormals;
  21459. private _source;
  21460. readonly source: Nullable<Mesh>;
  21461. isUnIndexed: boolean;
  21462. /**
  21463. * @constructor
  21464. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21465. * @param {Scene} scene The scene to add this mesh to.
  21466. * @param {Node} parent The parent of this mesh, if it has one
  21467. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21468. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21469. * When false, achieved by calling a clone(), also passing False.
  21470. * This will make creation of children, recursive.
  21471. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21472. */
  21473. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21474. /**
  21475. * Returns the string "Mesh".
  21476. */
  21477. getClassName(): string;
  21478. /**
  21479. * Returns a string.
  21480. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21481. */
  21482. toString(fullDetails?: boolean): string;
  21483. /** @hidden */
  21484. _unBindEffect(): void;
  21485. /**
  21486. * True if the mesh has some Levels Of Details (LOD).
  21487. * Returns a boolean.
  21488. */
  21489. readonly hasLODLevels: boolean;
  21490. /**
  21491. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21492. * @returns an array of {BABYLON.MeshLODLevel}
  21493. */
  21494. getLODLevels(): MeshLODLevel[];
  21495. private _sortLODLevels;
  21496. /**
  21497. * Add a mesh as LOD level triggered at the given distance.
  21498. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21499. * @param distance The distance from the center of the object to show this level
  21500. * @param mesh The mesh to be added as LOD level (can be null)
  21501. * @return This mesh (for chaining)
  21502. */
  21503. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21504. /**
  21505. * Returns the LOD level mesh at the passed distance or null if not found.
  21506. * It is related to the method `addLODLevel(distance, mesh)`.
  21507. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21508. * Returns an object Mesh or `null`.
  21509. */
  21510. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21511. /**
  21512. * Remove a mesh from the LOD array
  21513. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21514. * @param {Mesh} mesh The mesh to be removed.
  21515. * @return {Mesh} This mesh (for chaining)
  21516. */
  21517. removeLODLevel(mesh: Mesh): Mesh;
  21518. /**
  21519. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21520. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21521. */
  21522. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21523. /**
  21524. * Returns the mesh internal Geometry object.
  21525. */
  21526. readonly geometry: Nullable<Geometry>;
  21527. /**
  21528. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21529. */
  21530. getTotalVertices(): number;
  21531. /**
  21532. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21533. * 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.
  21534. * You can force the copy with forceCopy === true
  21535. * Returns null if the mesh has no geometry or no vertex buffer.
  21536. * Possible `kind` values :
  21537. * - BABYLON.VertexBuffer.PositionKind
  21538. * - BABYLON.VertexBuffer.UVKind
  21539. * - BABYLON.VertexBuffer.UV2Kind
  21540. * - BABYLON.VertexBuffer.UV3Kind
  21541. * - BABYLON.VertexBuffer.UV4Kind
  21542. * - BABYLON.VertexBuffer.UV5Kind
  21543. * - BABYLON.VertexBuffer.UV6Kind
  21544. * - BABYLON.VertexBuffer.ColorKind
  21545. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21546. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21547. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21548. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21549. */
  21550. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21551. /**
  21552. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21553. * Returns `null` if the mesh has no geometry.
  21554. * Possible `kind` values :
  21555. * - BABYLON.VertexBuffer.PositionKind
  21556. * - BABYLON.VertexBuffer.UVKind
  21557. * - BABYLON.VertexBuffer.UV2Kind
  21558. * - BABYLON.VertexBuffer.UV3Kind
  21559. * - BABYLON.VertexBuffer.UV4Kind
  21560. * - BABYLON.VertexBuffer.UV5Kind
  21561. * - BABYLON.VertexBuffer.UV6Kind
  21562. * - BABYLON.VertexBuffer.ColorKind
  21563. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21564. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21565. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21566. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21567. */
  21568. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21569. isVerticesDataPresent(kind: string): boolean;
  21570. /**
  21571. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21572. * Possible `kind` values :
  21573. * - BABYLON.VertexBuffer.PositionKind
  21574. * - BABYLON.VertexBuffer.UVKind
  21575. * - BABYLON.VertexBuffer.UV2Kind
  21576. * - BABYLON.VertexBuffer.UV3Kind
  21577. * - BABYLON.VertexBuffer.UV4Kind
  21578. * - BABYLON.VertexBuffer.UV5Kind
  21579. * - BABYLON.VertexBuffer.UV6Kind
  21580. * - BABYLON.VertexBuffer.ColorKind
  21581. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21582. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21583. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21584. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21585. */
  21586. isVertexBufferUpdatable(kind: string): boolean;
  21587. /**
  21588. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21589. * Possible `kind` values :
  21590. * - BABYLON.VertexBuffer.PositionKind
  21591. * - BABYLON.VertexBuffer.UVKind
  21592. * - BABYLON.VertexBuffer.UV2Kind
  21593. * - BABYLON.VertexBuffer.UV3Kind
  21594. * - BABYLON.VertexBuffer.UV4Kind
  21595. * - BABYLON.VertexBuffer.UV5Kind
  21596. * - BABYLON.VertexBuffer.UV6Kind
  21597. * - BABYLON.VertexBuffer.ColorKind
  21598. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21599. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21600. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21601. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21602. */
  21603. getVerticesDataKinds(): string[];
  21604. /**
  21605. * Returns a positive integer : the total number of indices in this mesh geometry.
  21606. * Returns zero if the mesh has no geometry.
  21607. */
  21608. getTotalIndices(): number;
  21609. /**
  21610. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21611. * @param copyWhenShared If 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.
  21612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21613. * @returns the indices array or an empty array if the mesh has no geometry
  21614. */
  21615. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21616. readonly isBlocked: boolean;
  21617. /**
  21618. * Determine if the current mesh is ready to be rendered
  21619. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21620. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21621. * @returns true if all associated assets are ready (material, textures, shaders)
  21622. */
  21623. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21624. /**
  21625. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21626. * This property is pertinent only for updatable parametric shapes.
  21627. */
  21628. readonly areNormalsFrozen: boolean;
  21629. /**
  21630. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21631. * It has no effect at all on other shapes.
  21632. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21633. * Returns the Mesh.
  21634. */
  21635. freezeNormals(): Mesh;
  21636. /**
  21637. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21638. * It has no effect at all on other shapes.
  21639. * It reactivates the mesh normals computation if it was previously frozen.
  21640. * Returns the Mesh.
  21641. */
  21642. unfreezeNormals(): Mesh;
  21643. /**
  21644. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21645. */
  21646. overridenInstanceCount: number;
  21647. /** @hidden */
  21648. _preActivate(): Mesh;
  21649. /** @hidden */
  21650. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21651. /** @hidden */
  21652. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21653. /**
  21654. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21655. * This means the mesh underlying bounding box and sphere are recomputed.
  21656. * Returns the Mesh.
  21657. */
  21658. refreshBoundingInfo(): Mesh;
  21659. /** @hidden */
  21660. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21661. private _getPositionData;
  21662. /** @hidden */
  21663. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21664. subdivide(count: number): void;
  21665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21666. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21667. /**
  21668. * Sets the mesh VertexBuffer.
  21669. * Returns the Mesh.
  21670. */
  21671. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21672. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21673. /**
  21674. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21675. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21676. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21677. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21678. * Returns the Mesh.
  21679. */
  21680. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21681. /**
  21682. * Creates a un-shared specific occurence of the geometry for the mesh.
  21683. * Returns the Mesh.
  21684. */
  21685. makeGeometryUnique(): Mesh;
  21686. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21687. /**
  21688. * Update the current index buffer
  21689. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21690. * Returns the Mesh.
  21691. */
  21692. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21693. /**
  21694. * Invert the geometry to move from a right handed system to a left handed one.
  21695. * Returns the Mesh.
  21696. */
  21697. toLeftHanded(): Mesh;
  21698. /** @hidden */
  21699. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21700. /** @hidden */
  21701. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21702. /**
  21703. * Registers for this mesh a javascript function called just before the rendering process.
  21704. * This function is passed the current mesh.
  21705. * Return the Mesh.
  21706. */
  21707. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21708. /**
  21709. * Disposes a previously registered javascript function called before the rendering.
  21710. * This function is passed the current mesh.
  21711. * Returns the Mesh.
  21712. */
  21713. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21714. /**
  21715. * Registers for this mesh a javascript function called just after the rendering is complete.
  21716. * This function is passed the current mesh.
  21717. * Returns the Mesh.
  21718. */
  21719. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21720. /**
  21721. * Disposes a previously registered javascript function called after the rendering.
  21722. * This function is passed the current mesh.
  21723. * Return the Mesh.
  21724. */
  21725. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21726. /** @hidden */
  21727. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21728. /** @hidden */
  21729. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21730. /** @hidden */
  21731. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21732. /**
  21733. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21734. * @param subMesh defines the subMesh to render
  21735. * @param enableAlphaMode defines if alpha mode can be changed
  21736. * @returns the current mesh
  21737. */
  21738. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21739. private _onBeforeDraw;
  21740. /**
  21741. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21742. */
  21743. getEmittedParticleSystems(): IParticleSystem[];
  21744. /**
  21745. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21746. */
  21747. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21748. /**
  21749. * Normalize matrix weights so that all vertices have a total weight set to 1
  21750. */
  21751. cleanMatrixWeights(): void;
  21752. /** @hidden */
  21753. _checkDelayState(): Mesh;
  21754. private _queueLoad;
  21755. /**
  21756. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21757. * A mesh is in the frustum if its bounding box intersects the frustum
  21758. * @param frustumPlanes defines the frustum to test
  21759. * @returns true if the mesh is in the frustum planes
  21760. */
  21761. isInFrustum(frustumPlanes: Plane[]): boolean;
  21762. /**
  21763. * Sets the mesh material by the material or multiMaterial `id` property.
  21764. * The material `id` is a string identifying the material or the multiMaterial.
  21765. * This method returns the Mesh.
  21766. */
  21767. setMaterialByID(id: string): Mesh;
  21768. /**
  21769. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21770. */
  21771. getAnimatables(): IAnimatable[];
  21772. /**
  21773. * Modifies the mesh geometry according to the passed transformation matrix.
  21774. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21775. * The mesh normals are modified using the same transformation.
  21776. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21777. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21778. * Returns the Mesh.
  21779. */
  21780. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21781. /**
  21782. * Modifies the mesh geometry according to its own current World Matrix.
  21783. * The mesh World Matrix is then reset.
  21784. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21785. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21786. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21787. * Returns the Mesh.
  21788. */
  21789. bakeCurrentTransformIntoVertices(): Mesh;
  21790. readonly _positions: Nullable<Vector3[]>;
  21791. /** @hidden */
  21792. _resetPointsArrayCache(): Mesh;
  21793. /** @hidden */
  21794. _generatePointsArray(): boolean;
  21795. /**
  21796. * Returns a new Mesh object generated from the current mesh properties.
  21797. * This method must not get confused with createInstance().
  21798. * The parameter `name` is a string, the name given to the new mesh.
  21799. * The optional parameter `newParent` can be any Node object (default `null`).
  21800. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21801. * 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.
  21802. */
  21803. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21804. /**
  21805. * Releases resources associated with this mesh.
  21806. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21807. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21808. */
  21809. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21810. /**
  21811. * Modifies the mesh geometry according to a displacement map.
  21812. * 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.
  21813. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21814. * This method returns nothing.
  21815. * @param url is a string, the URL from the image file is to be downloaded.
  21816. * @param minHeight is the lower limit of the displacement.
  21817. * @param maxHeight is the upper limit of the displacement.
  21818. * @param 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.
  21819. * @param uvOffset is an optional vector2 used to offset UV.
  21820. * @param uvScale is an optional vector2 used to scale UV.
  21821. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21822. * @returns the Mesh.
  21823. */
  21824. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21825. /**
  21826. * Modifies the mesh geometry according to a displacementMap buffer.
  21827. * 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.
  21828. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21829. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21830. * @param heightMapWidth is the width of the buffer image.
  21831. * @param heightMapHeight is the height of the buffer image.
  21832. * @param minHeight is the lower limit of the displacement.
  21833. * @param maxHeight is the upper limit of the displacement.
  21834. * @param 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.
  21835. * @param uvOffset is an optional vector2 used to offset UV.
  21836. * @param uvScale is an optional vector2 used to scale UV.
  21837. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21838. * @returns the Mesh.
  21839. */
  21840. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21841. /**
  21842. * Modify the mesh to get a flat shading rendering.
  21843. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21844. * This method returns the Mesh.
  21845. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21846. */
  21847. convertToFlatShadedMesh(): Mesh;
  21848. /**
  21849. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21850. * In other words, more vertices, no more indices and a single bigger VBO.
  21851. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21852. * Returns the Mesh.
  21853. */
  21854. convertToUnIndexedMesh(): Mesh;
  21855. /**
  21856. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21857. * This method returns the Mesh.
  21858. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21859. */
  21860. flipFaces(flipNormals?: boolean): Mesh;
  21861. /**
  21862. * Creates a new InstancedMesh object from the mesh model.
  21863. * An instance shares the same properties and the same material than its model.
  21864. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  21865. * Only these properties of each instance can then be set individually :
  21866. * - position
  21867. * - rotation
  21868. * - rotationQuaternion
  21869. * - setPivotMatrix
  21870. * - scaling
  21871. *
  21872. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21873. * Warning : this method is not supported for Line mesh and LineSystem
  21874. */
  21875. createInstance(name: string): InstancedMesh;
  21876. /**
  21877. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21878. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21879. * This method returns the Mesh.
  21880. */
  21881. synchronizeInstances(): Mesh;
  21882. /**
  21883. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21884. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21885. * This should be used together with the simplification to avoid disappearing triangles.
  21886. * Returns the Mesh.
  21887. * @param successCallback an optional success callback to be called after the optimization finished.
  21888. */
  21889. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21890. serialize(serializationObject: any): void;
  21891. /** @hidden */
  21892. _syncGeometryWithMorphTargetManager(): void;
  21893. /**
  21894. * Returns a new Mesh object parsed from the source provided.
  21895. * The parameter `parsedMesh` is the source.
  21896. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21897. */
  21898. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21899. /**
  21900. * Creates a ribbon mesh.
  21901. * Please consider using the same method from the MeshBuilder class instead.
  21902. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21903. *
  21904. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21905. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21906. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21907. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21908. * 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.
  21909. * 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.
  21910. * 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
  21911. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21912. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21913. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21914. */
  21915. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21916. /**
  21917. * Creates a plane polygonal mesh. By default, this is a disc.
  21918. * Please consider using the same method from the MeshBuilder class instead.
  21919. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21920. * 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.
  21921. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21922. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21923. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21924. */
  21925. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21926. /**
  21927. * Creates a box mesh.
  21928. * Please consider using the same method from the MeshBuilder class instead.
  21929. * The parameter `size` sets the size (float) of each box side (default 1).
  21930. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21931. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21932. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21933. */
  21934. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21935. /**
  21936. * Creates a sphere mesh.
  21937. * Please consider using the same method from the MeshBuilder class instead.
  21938. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21939. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21940. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21941. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21942. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21943. */
  21944. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21945. /**
  21946. * Creates a cylinder or a cone mesh.
  21947. * Please consider using the same method from the MeshBuilder class instead.
  21948. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21949. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21950. * 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.
  21951. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21952. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21953. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21954. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21955. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21956. */
  21957. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21958. /**
  21959. * Creates a torus mesh.
  21960. * Please consider using the same method from the MeshBuilder class instead.
  21961. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21962. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21963. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21964. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21965. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21966. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21967. */
  21968. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21969. /**
  21970. * Creates a torus knot mesh.
  21971. * Please consider using the same method from the MeshBuilder class instead.
  21972. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21973. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21974. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21975. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21976. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21977. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21978. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21979. */
  21980. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21981. /**
  21982. * Creates a line mesh.
  21983. * Please consider using the same method from the MeshBuilder class instead.
  21984. * 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.
  21985. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21986. * The parameter `points` is an array successive Vector3.
  21987. * 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
  21988. * When updating an instance, remember that only point positions can change, not the number of points.
  21989. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21990. */
  21991. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21992. /**
  21993. * Creates a dashed line mesh.
  21994. * Please consider using the same method from the MeshBuilder class instead.
  21995. * 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.
  21996. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21997. * The parameter `points` is an array successive Vector3.
  21998. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21999. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22000. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22001. * 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
  22002. * When updating an instance, remember that only point positions can change, not the number of points.
  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. */
  22005. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22006. /**
  22007. * Creates a polygon mesh.
  22008. * Please consider using the same method from the MeshBuilder class instead.
  22009. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22010. * 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.
  22011. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22012. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22013. * Remember you can only change the shape positions, not their number when updating a polygon.
  22014. */
  22015. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22016. /**
  22017. * Creates an extruded polygon mesh, with depth in the Y direction.
  22018. * Please consider using the same method from the MeshBuilder class instead.
  22019. */
  22020. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22021. /**
  22022. * Creates an extruded shape mesh.
  22023. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22024. * Please consider using the same method from the MeshBuilder class instead.
  22025. *
  22026. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22027. * 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
  22028. * extruded along the Z axis.
  22029. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22030. * 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.
  22031. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22032. * 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
  22033. * 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
  22034. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22035. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22036. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22037. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22038. */
  22039. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22040. /**
  22041. * Creates an custom extruded shape mesh.
  22042. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22043. * Please consider using the same method from the MeshBuilder class instead.
  22044. *
  22045. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22046. * 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
  22047. * extruded along the Z axis.
  22048. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22049. * 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
  22050. * and the distance of this point from the begining of the path :
  22051. * ```javascript
  22052. * var rotationFunction = function(i, distance) {
  22053. * // do things
  22054. * return rotationValue; }
  22055. * ```
  22056. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22057. * 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
  22058. * and the distance of this point from the begining of the path :
  22059. * ```javascript
  22060. * var scaleFunction = function(i, distance) {
  22061. * // do things
  22062. * return scaleValue;}
  22063. * ```
  22064. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22065. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22066. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22067. * 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
  22068. * 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
  22069. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22070. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22071. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22072. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22073. */
  22074. 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;
  22075. /**
  22076. * Creates lathe mesh.
  22077. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22078. * Please consider using the same method from the MeshBuilder class instead.
  22079. * 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
  22080. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22081. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22082. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22083. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22084. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22085. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22086. */
  22087. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22088. /**
  22089. * Creates a plane mesh.
  22090. * Please consider using the same method from the MeshBuilder class instead.
  22091. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22092. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22093. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22094. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22095. */
  22096. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22097. /**
  22098. * Creates a ground mesh.
  22099. * Please consider using the same method from the MeshBuilder class instead.
  22100. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22101. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22102. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22103. */
  22104. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22105. /**
  22106. * Creates a tiled ground mesh.
  22107. * Please consider using the same method from the MeshBuilder class instead.
  22108. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22109. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22110. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22111. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22112. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22113. * numbers of subdivisions on the ground width and height of each tile.
  22114. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22115. */
  22116. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22117. w: number;
  22118. h: number;
  22119. }, precision: {
  22120. w: number;
  22121. h: number;
  22122. }, scene: Scene, updatable?: boolean): Mesh;
  22123. /**
  22124. * Creates a ground mesh from a height map.
  22125. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22126. * Please consider using the same method from the MeshBuilder class instead.
  22127. * The parameter `url` sets the URL of the height map image resource.
  22128. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22129. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22130. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22131. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22132. * 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).
  22133. * This function is passed the newly built mesh :
  22134. * ```javascript
  22135. * function(mesh) { // do things
  22136. * return; }
  22137. * ```
  22138. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22139. */
  22140. 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;
  22141. /**
  22142. * Creates a tube mesh.
  22143. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22144. * Please consider using the same method from the MeshBuilder class instead.
  22145. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22146. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22147. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22148. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22149. * 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.
  22150. * It must return a radius value (positive float) :
  22151. * ```javascript
  22152. * var radiusFunction = function(i, distance) {
  22153. * // do things
  22154. * return radius; }
  22155. * ```
  22156. * 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
  22157. * 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
  22158. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22159. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22160. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22161. */
  22162. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22163. (i: number, distance: number): number;
  22164. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22165. /**
  22166. * Creates a polyhedron mesh.
  22167. * Please consider using the same method from the MeshBuilder class instead.
  22168. * 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
  22169. * to choose the wanted type.
  22170. * The parameter `size` (positive float, default 1) sets the polygon size.
  22171. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22172. * 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`.
  22173. * 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
  22174. * 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)`).
  22175. * 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
  22176. * 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.
  22177. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22178. * 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. */
  22181. static CreatePolyhedron(name: string, options: {
  22182. type?: number;
  22183. size?: number;
  22184. sizeX?: number;
  22185. sizeY?: number;
  22186. sizeZ?: number;
  22187. custom?: any;
  22188. faceUV?: Vector4[];
  22189. faceColors?: Color4[];
  22190. updatable?: boolean;
  22191. sideOrientation?: number;
  22192. }, scene: Scene): Mesh;
  22193. /**
  22194. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22195. * Please consider using the same method from the MeshBuilder class instead.
  22196. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22197. * 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`).
  22198. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22199. * 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.
  22200. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22201. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22202. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22203. */
  22204. static CreateIcoSphere(name: string, options: {
  22205. radius?: number;
  22206. flat?: boolean;
  22207. subdivisions?: number;
  22208. sideOrientation?: number;
  22209. updatable?: boolean;
  22210. }, scene: Scene): Mesh;
  22211. /**
  22212. * Creates a decal mesh.
  22213. * Please consider using the same method from the MeshBuilder class instead.
  22214. * 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.
  22215. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22216. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22217. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22218. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22219. */
  22220. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22221. /**
  22222. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22223. */
  22224. setPositionsForCPUSkinning(): Float32Array;
  22225. /**
  22226. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22227. */
  22228. setNormalsForCPUSkinning(): Float32Array;
  22229. /**
  22230. * Updates the vertex buffer by applying transformation from the bones.
  22231. * Returns the Mesh.
  22232. *
  22233. * @param {skeleton} skeleton to apply
  22234. */
  22235. applySkeleton(skeleton: Skeleton): Mesh;
  22236. /**
  22237. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22238. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22239. */
  22240. static MinMax(meshes: AbstractMesh[]): {
  22241. min: Vector3;
  22242. max: Vector3;
  22243. };
  22244. /**
  22245. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22246. */
  22247. static Center(meshesOrMinMaxVector: {
  22248. min: Vector3;
  22249. max: Vector3;
  22250. } | AbstractMesh[]): Vector3;
  22251. /**
  22252. * Merge the array of meshes into a single mesh for performance reasons.
  22253. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22254. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22255. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22256. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22257. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22258. */
  22259. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22260. }
  22261. }
  22262. declare module BABYLON {
  22263. /**
  22264. * Define an interface for all classes that will get and set the data on vertices
  22265. */
  22266. interface IGetSetVerticesData {
  22267. isVerticesDataPresent(kind: string): boolean;
  22268. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22269. /**
  22270. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22271. * @param copyWhenShared If 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.
  22272. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22273. * @returns the indices array or an empty array if the mesh has no geometry
  22274. */
  22275. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22276. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22277. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22278. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22279. }
  22280. /**
  22281. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22282. */
  22283. class VertexData {
  22284. /**
  22285. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22286. */
  22287. positions: Nullable<FloatArray>;
  22288. /**
  22289. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22290. */
  22291. normals: Nullable<FloatArray>;
  22292. /**
  22293. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22294. */
  22295. tangents: Nullable<FloatArray>;
  22296. /**
  22297. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22298. */
  22299. uvs: Nullable<FloatArray>;
  22300. /**
  22301. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22302. */
  22303. uvs2: Nullable<FloatArray>;
  22304. /**
  22305. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22306. */
  22307. uvs3: Nullable<FloatArray>;
  22308. /**
  22309. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22310. */
  22311. uvs4: Nullable<FloatArray>;
  22312. /**
  22313. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22314. */
  22315. uvs5: Nullable<FloatArray>;
  22316. /**
  22317. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22318. */
  22319. uvs6: Nullable<FloatArray>;
  22320. /**
  22321. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22322. */
  22323. colors: Nullable<FloatArray>;
  22324. /**
  22325. * 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).
  22326. */
  22327. matricesIndices: Nullable<FloatArray>;
  22328. /**
  22329. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22330. */
  22331. matricesWeights: Nullable<FloatArray>;
  22332. /**
  22333. * An array extending the number of possible indices
  22334. */
  22335. matricesIndicesExtra: Nullable<FloatArray>;
  22336. /**
  22337. * An array extending the number of possible weights when the number of indices is extended
  22338. */
  22339. matricesWeightsExtra: Nullable<FloatArray>;
  22340. /**
  22341. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22342. */
  22343. indices: Nullable<IndicesArray>;
  22344. /**
  22345. * Uses the passed data array to set the set the values for the specified kind of data
  22346. * @param data a linear array of floating numbers
  22347. * @param kind the type of data that is being set, eg positions, colors etc
  22348. */
  22349. set(data: FloatArray, kind: string): void;
  22350. /**
  22351. * Associates the vertexData to the passed Mesh.
  22352. * Sets it as updatable or not (default `false`)
  22353. * @param mesh the mesh the vertexData is applied to
  22354. * @param updatable when used and having the value true allows new data to update the vertexData
  22355. * @returns the VertexData
  22356. */
  22357. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22358. /**
  22359. * Associates the vertexData to the passed Geometry.
  22360. * Sets it as updatable or not (default `false`)
  22361. * @param geometry the geometry the vertexData is applied to
  22362. * @param updatable when used and having the value true allows new data to update the vertexData
  22363. * @returns VertexData
  22364. */
  22365. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22366. /**
  22367. * Updates the associated mesh
  22368. * @param mesh the mesh to be updated
  22369. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22370. * @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
  22371. * @returns VertexData
  22372. */
  22373. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22374. /**
  22375. * Updates the associated geometry
  22376. * @param geometry the geometry to be updated
  22377. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22378. * @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
  22379. * @returns VertexData.
  22380. */
  22381. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22382. private _applyTo;
  22383. private _update;
  22384. /**
  22385. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22386. * @param matrix the transforming matrix
  22387. * @returns the VertexData
  22388. */
  22389. transform(matrix: Matrix): VertexData;
  22390. /**
  22391. * Merges the passed VertexData into the current one
  22392. * @param other the VertexData to be merged into the current one
  22393. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22394. * @returns the modified VertexData
  22395. */
  22396. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22397. private _mergeElement;
  22398. private _validate;
  22399. /**
  22400. * Serializes the VertexData
  22401. * @returns a serialized object
  22402. */
  22403. serialize(): any;
  22404. /**
  22405. * Extracts the vertexData from a mesh
  22406. * @param mesh the mesh from which to extract the VertexData
  22407. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22408. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22409. * @returns the object VertexData associated to the passed mesh
  22410. */
  22411. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22412. /**
  22413. * Extracts the vertexData from the geometry
  22414. * @param geometry the geometry from which to extract the VertexData
  22415. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22416. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22417. * @returns the object VertexData associated to the passed mesh
  22418. */
  22419. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22420. private static _ExtractFrom;
  22421. /**
  22422. * Creates the VertexData for a Ribbon
  22423. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22424. * * pathArray array of paths, each of which an array of successive Vector3
  22425. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22426. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22427. * * 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
  22428. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22429. * * 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)
  22430. * * 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)
  22431. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22432. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22433. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22434. * @returns the VertexData of the ribbon
  22435. */
  22436. static CreateRibbon(options: {
  22437. pathArray: Vector3[][];
  22438. closeArray?: boolean;
  22439. closePath?: boolean;
  22440. offset?: number;
  22441. sideOrientation?: number;
  22442. frontUVs?: Vector4;
  22443. backUVs?: Vector4;
  22444. invertUV?: boolean;
  22445. uvs?: Vector2[];
  22446. colors?: Color4[];
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a box
  22450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22451. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22452. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22453. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22454. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22455. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22456. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22457. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22458. * * 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)
  22459. * * 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)
  22460. * @returns the VertexData of the box
  22461. */
  22462. static CreateBox(options: {
  22463. size?: number;
  22464. width?: number;
  22465. height?: number;
  22466. depth?: number;
  22467. faceUV?: Vector4[];
  22468. faceColors?: Color4[];
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22475. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22476. * * segments sets the number of horizontal strips optional, default 32
  22477. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22478. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22479. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22480. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22481. * * 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
  22482. * * 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
  22483. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22484. * * 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)
  22485. * * 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)
  22486. * @returns the VertexData of the ellipsoid
  22487. */
  22488. static CreateSphere(options: {
  22489. segments?: number;
  22490. diameter?: number;
  22491. diameterX?: number;
  22492. diameterY?: number;
  22493. diameterZ?: number;
  22494. arc?: number;
  22495. slice?: number;
  22496. sideOrientation?: number;
  22497. frontUVs?: Vector4;
  22498. backUVs?: Vector4;
  22499. }): VertexData;
  22500. /**
  22501. * Creates the VertexData for a cylinder, cone or prism
  22502. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22503. * * height sets the height (y direction) of the cylinder, optional, default 2
  22504. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22505. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22506. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22507. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22508. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22509. * * 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
  22510. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22511. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22512. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22513. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22514. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22515. * * 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)
  22516. * * 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)
  22517. * @returns the VertexData of the cylinder, cone or prism
  22518. */
  22519. static CreateCylinder(options: {
  22520. height?: number;
  22521. diameterTop?: number;
  22522. diameterBottom?: number;
  22523. diameter?: number;
  22524. tessellation?: number;
  22525. subdivisions?: number;
  22526. arc?: number;
  22527. faceColors?: Color4[];
  22528. faceUV?: Vector4[];
  22529. hasRings?: boolean;
  22530. enclose?: boolean;
  22531. sideOrientation?: number;
  22532. frontUVs?: Vector4;
  22533. backUVs?: Vector4;
  22534. }): VertexData;
  22535. /**
  22536. * Creates the VertexData for a torus
  22537. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22538. * * diameter the diameter of the torus, optional default 1
  22539. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22540. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22541. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22542. * * 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)
  22543. * * 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)
  22544. * @returns the VertexData of the torus
  22545. */
  22546. static CreateTorus(options: {
  22547. diameter?: number;
  22548. thickness?: number;
  22549. tessellation?: number;
  22550. sideOrientation?: number;
  22551. frontUVs?: Vector4;
  22552. backUVs?: Vector4;
  22553. }): VertexData;
  22554. /**
  22555. * Creates the VertexData of the LineSystem
  22556. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22557. * - lines an array of lines, each line being an array of successive Vector3
  22558. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22559. * @returns the VertexData of the LineSystem
  22560. */
  22561. static CreateLineSystem(options: {
  22562. lines: Vector3[][];
  22563. colors?: Nullable<Color4[][]>;
  22564. }): VertexData;
  22565. /**
  22566. * Create the VertexData for a DashedLines
  22567. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22568. * - points an array successive Vector3
  22569. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22570. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22571. * - dashNb the intended total number of dashes, optional, default 200
  22572. * @returns the VertexData for the DashedLines
  22573. */
  22574. static CreateDashedLines(options: {
  22575. points: Vector3[];
  22576. dashSize?: number;
  22577. gapSize?: number;
  22578. dashNb?: number;
  22579. }): VertexData;
  22580. /**
  22581. * Creates the VertexData for a Ground
  22582. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22583. * - width the width (x direction) of the ground, optional, default 1
  22584. * - height the height (z direction) of the ground, optional, default 1
  22585. * - subdivisions the number of subdivisions per side, optional, default 1
  22586. * @returns the VertexData of the Ground
  22587. */
  22588. static CreateGround(options: {
  22589. width?: number;
  22590. height?: number;
  22591. subdivisions?: number;
  22592. subdivisionsX?: number;
  22593. subdivisionsY?: number;
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22597. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22598. * * xmin the ground minimum X coordinate, optional, default -1
  22599. * * zmin the ground minimum Z coordinate, optional, default -1
  22600. * * xmax the ground maximum X coordinate, optional, default 1
  22601. * * zmax the ground maximum Z coordinate, optional, default 1
  22602. * * 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}
  22603. * * 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}
  22604. * @returns the VertexData of the TiledGround
  22605. */
  22606. static CreateTiledGround(options: {
  22607. xmin: number;
  22608. zmin: number;
  22609. xmax: number;
  22610. zmax: number;
  22611. subdivisions?: {
  22612. w: number;
  22613. h: number;
  22614. };
  22615. precision?: {
  22616. w: number;
  22617. h: number;
  22618. };
  22619. }): VertexData;
  22620. /**
  22621. * Creates the VertexData of the Ground designed from a heightmap
  22622. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22623. * * width the width (x direction) of the ground
  22624. * * height the height (z direction) of the ground
  22625. * * subdivisions the number of subdivisions per side
  22626. * * minHeight the minimum altitude on the ground, optional, default 0
  22627. * * maxHeight the maximum altitude on the ground, optional default 1
  22628. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22629. * * buffer the array holding the image color data
  22630. * * bufferWidth the width of image
  22631. * * bufferHeight the height of image
  22632. * @returns the VertexData of the Ground designed from a heightmap
  22633. */
  22634. static CreateGroundFromHeightMap(options: {
  22635. width: number;
  22636. height: number;
  22637. subdivisions: number;
  22638. minHeight: number;
  22639. maxHeight: number;
  22640. colorFilter: Color3;
  22641. buffer: Uint8Array;
  22642. bufferWidth: number;
  22643. bufferHeight: number;
  22644. }): VertexData;
  22645. /**
  22646. * Creates the VertexData for a Plane
  22647. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22648. * * size sets the width and height of the plane to the value of size, optional default 1
  22649. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22650. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22651. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22652. * * 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)
  22653. * * 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)
  22654. * @returns the VertexData of the box
  22655. */
  22656. static CreatePlane(options: {
  22657. size?: number;
  22658. width?: number;
  22659. height?: number;
  22660. sideOrientation?: number;
  22661. frontUVs?: Vector4;
  22662. backUVs?: Vector4;
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData of the Disc or regular Polygon
  22666. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22667. * * radius the radius of the disc, optional default 0.5
  22668. * * tessellation the number of polygon sides, optional, default 64
  22669. * * 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
  22670. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22671. * * 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)
  22672. * * 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)
  22673. * @returns the VertexData of the box
  22674. */
  22675. static CreateDisc(options: {
  22676. radius?: number;
  22677. tessellation?: number;
  22678. arc?: number;
  22679. sideOrientation?: number;
  22680. frontUVs?: Vector4;
  22681. backUVs?: Vector4;
  22682. }): VertexData;
  22683. /**
  22684. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22685. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22686. * @param polygon a mesh built from polygonTriangulation.build()
  22687. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22688. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22689. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22690. * @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)
  22691. * @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)
  22692. * @returns the VertexData of the Polygon
  22693. */
  22694. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22695. /**
  22696. * Creates the VertexData of the IcoSphere
  22697. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22698. * * radius the radius of the IcoSphere, optional default 1
  22699. * * radiusX allows stretching in the x direction, optional, default radius
  22700. * * radiusY allows stretching in the y direction, optional, default radius
  22701. * * radiusZ allows stretching in the z direction, optional, default radius
  22702. * * flat when true creates a flat shaded mesh, optional, default true
  22703. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22704. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22705. * * 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)
  22706. * * 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)
  22707. * @returns the VertexData of the IcoSphere
  22708. */
  22709. static CreateIcoSphere(options: {
  22710. radius?: number;
  22711. radiusX?: number;
  22712. radiusY?: number;
  22713. radiusZ?: number;
  22714. flat?: boolean;
  22715. subdivisions?: number;
  22716. sideOrientation?: number;
  22717. frontUVs?: Vector4;
  22718. backUVs?: Vector4;
  22719. }): VertexData;
  22720. /**
  22721. * Creates the VertexData for a Polyhedron
  22722. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22723. * * type provided types are:
  22724. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22725. * * 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)
  22726. * * size the size of the IcoSphere, optional default 1
  22727. * * sizeX allows stretching in the x direction, optional, default size
  22728. * * sizeY allows stretching in the y direction, optional, default size
  22729. * * sizeZ allows stretching in the z direction, optional, default size
  22730. * * 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
  22731. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22732. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22733. * * flat when true creates a flat shaded mesh, optional, default true
  22734. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22735. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22736. * * 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)
  22737. * * 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)
  22738. * @returns the VertexData of the Polyhedron
  22739. */
  22740. static CreatePolyhedron(options: {
  22741. type?: number;
  22742. size?: number;
  22743. sizeX?: number;
  22744. sizeY?: number;
  22745. sizeZ?: number;
  22746. custom?: any;
  22747. faceUV?: Vector4[];
  22748. faceColors?: Color4[];
  22749. flat?: boolean;
  22750. sideOrientation?: number;
  22751. frontUVs?: Vector4;
  22752. backUVs?: Vector4;
  22753. }): VertexData;
  22754. /**
  22755. * Creates the VertexData for a TorusKnot
  22756. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22757. * * radius the radius of the torus knot, optional, default 2
  22758. * * tube the thickness of the tube, optional, default 0.5
  22759. * * radialSegments the number of sides on each tube segments, optional, default 32
  22760. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22761. * * p the number of windings around the z axis, optional, default 2
  22762. * * q the number of windings around the x axis, optional, default 3
  22763. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22764. * * 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)
  22765. * * 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)
  22766. * @returns the VertexData of the Torus Knot
  22767. */
  22768. static CreateTorusKnot(options: {
  22769. radius?: number;
  22770. tube?: number;
  22771. radialSegments?: number;
  22772. tubularSegments?: number;
  22773. p?: number;
  22774. q?: number;
  22775. sideOrientation?: number;
  22776. frontUVs?: Vector4;
  22777. backUVs?: Vector4;
  22778. }): VertexData;
  22779. /**
  22780. * Compute normals for given positions and indices
  22781. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22782. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22783. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22784. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22785. * * facetNormals : optional array of facet normals (vector3)
  22786. * * facetPositions : optional array of facet positions (vector3)
  22787. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22788. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22789. * * bInfo : optional bounding info, required for facetPartitioning computation
  22790. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22791. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22792. * * useRightHandedSystem: optional boolean to for right handed system computation
  22793. * * depthSort : optional boolean to enable the facet depth sort computation
  22794. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22795. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22796. */
  22797. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22798. facetNormals?: any;
  22799. facetPositions?: any;
  22800. facetPartitioning?: any;
  22801. ratio?: number;
  22802. bInfo?: any;
  22803. bbSize?: Vector3;
  22804. subDiv?: any;
  22805. useRightHandedSystem?: boolean;
  22806. depthSort?: boolean;
  22807. distanceTo?: Vector3;
  22808. depthSortedFacets?: any;
  22809. }): void;
  22810. private static _ComputeSides;
  22811. /**
  22812. * Applies VertexData created from the imported parameters to the geometry
  22813. * @param parsedVertexData the parsed data from an imported file
  22814. * @param geometry the geometry to apply the VertexData to
  22815. */
  22816. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22817. }
  22818. }
  22819. declare module BABYLON {
  22820. /**
  22821. * Class containing static functions to help procedurally build meshes
  22822. */
  22823. class MeshBuilder {
  22824. private static updateSideOrientation;
  22825. /**
  22826. * Creates a box mesh
  22827. * * The parameter `size` sets the size (float) of each box side (default 1)
  22828. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22829. * * 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)
  22830. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22832. * * 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
  22833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22834. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22835. * @param name defines the name of the mesh
  22836. * @param options defines the options used to create the mesh
  22837. * @param scene defines the hosting scene
  22838. * @returns the box mesh
  22839. */
  22840. static CreateBox(name: string, options: {
  22841. size?: number;
  22842. width?: number;
  22843. height?: number;
  22844. depth?: number;
  22845. faceUV?: Vector4[];
  22846. faceColors?: Color4[];
  22847. sideOrientation?: number;
  22848. frontUVs?: Vector4;
  22849. backUVs?: Vector4;
  22850. updatable?: boolean;
  22851. }, scene?: Nullable<Scene>): Mesh;
  22852. /**
  22853. * Creates a sphere mesh
  22854. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22855. * * 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`)
  22856. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22857. * * 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
  22858. * * 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)
  22859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22860. * * 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
  22861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22862. * @param name defines the name of the mesh
  22863. * @param options defines the options used to create the mesh
  22864. * @param scene defines the hosting scene
  22865. * @returns the sphere mesh
  22866. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22867. */
  22868. static CreateSphere(name: string, options: {
  22869. segments?: number;
  22870. diameter?: number;
  22871. diameterX?: number;
  22872. diameterY?: number;
  22873. diameterZ?: number;
  22874. arc?: number;
  22875. slice?: number;
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. updatable?: boolean;
  22880. }, scene: any): Mesh;
  22881. /**
  22882. * Creates a plane polygonal mesh. By default, this is a disc
  22883. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22884. * * 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
  22885. * * 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
  22886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22887. * * 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
  22888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22889. * @param name defines the name of the mesh
  22890. * @param options defines the options used to create the mesh
  22891. * @param scene defines the hosting scene
  22892. * @returns the plane polygonal mesh
  22893. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22894. */
  22895. static CreateDisc(name: string, options: {
  22896. radius?: number;
  22897. tessellation?: number;
  22898. arc?: number;
  22899. updatable?: boolean;
  22900. sideOrientation?: number;
  22901. frontUVs?: Vector4;
  22902. backUVs?: Vector4;
  22903. }, scene?: Nullable<Scene>): Mesh;
  22904. /**
  22905. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22906. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22907. * * 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`)
  22908. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22909. * * 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
  22910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22911. * * 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
  22912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22913. * @param name defines the name of the mesh
  22914. * @param options defines the options used to create the mesh
  22915. * @param scene defines the hosting scene
  22916. * @returns the icosahedron mesh
  22917. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22918. */
  22919. static CreateIcoSphere(name: string, options: {
  22920. radius?: number;
  22921. radiusX?: number;
  22922. radiusY?: number;
  22923. radiusZ?: number;
  22924. flat?: boolean;
  22925. subdivisions?: number;
  22926. sideOrientation?: number;
  22927. frontUVs?: Vector4;
  22928. backUVs?: Vector4;
  22929. updatable?: boolean;
  22930. }, scene: Scene): Mesh;
  22931. /**
  22932. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22933. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22934. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22935. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22936. * * 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
  22937. * * 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
  22938. * * 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
  22939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22940. * * 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
  22941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22942. * * 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
  22943. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22944. * * 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
  22945. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22947. * @param name defines the name of the mesh
  22948. * @param options defines the options used to create the mesh
  22949. * @param scene defines the hosting scene
  22950. * @returns the ribbon mesh
  22951. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22952. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22953. */
  22954. static CreateRibbon(name: string, options: {
  22955. pathArray: Vector3[][];
  22956. closeArray?: boolean;
  22957. closePath?: boolean;
  22958. offset?: number;
  22959. updatable?: boolean;
  22960. sideOrientation?: number;
  22961. frontUVs?: Vector4;
  22962. backUVs?: Vector4;
  22963. instance?: Mesh;
  22964. invertUV?: boolean;
  22965. uvs?: Vector2[];
  22966. colors?: Color4[];
  22967. }, scene?: Nullable<Scene>): Mesh;
  22968. /**
  22969. * Creates a cylinder or a cone mesh
  22970. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22971. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22972. * * 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.
  22973. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22974. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22975. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22976. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22977. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22978. * * 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).
  22979. * * 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
  22980. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22981. * * 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
  22982. * * 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.
  22983. * * If `enclose` is false, a ring surface is one element.
  22984. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22985. * * 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
  22986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22987. * * 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
  22988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22989. * @param name defines the name of the mesh
  22990. * @param options defines the options used to create the mesh
  22991. * @param scene defines the hosting scene
  22992. * @returns the cylinder mesh
  22993. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22994. */
  22995. static CreateCylinder(name: string, options: {
  22996. height?: number;
  22997. diameterTop?: number;
  22998. diameterBottom?: number;
  22999. diameter?: number;
  23000. tessellation?: number;
  23001. subdivisions?: number;
  23002. arc?: number;
  23003. faceColors?: Color4[];
  23004. faceUV?: Vector4[];
  23005. updatable?: boolean;
  23006. hasRings?: boolean;
  23007. enclose?: boolean;
  23008. sideOrientation?: number;
  23009. frontUVs?: Vector4;
  23010. backUVs?: Vector4;
  23011. }, scene: any): Mesh;
  23012. /**
  23013. * Creates a torus mesh
  23014. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23015. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23016. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23018. * * 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
  23019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23020. * @param name defines the name of the mesh
  23021. * @param options defines the options used to create the mesh
  23022. * @param scene defines the hosting scene
  23023. * @returns the torus mesh
  23024. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23025. */
  23026. static CreateTorus(name: string, options: {
  23027. diameter?: number;
  23028. thickness?: number;
  23029. tessellation?: number;
  23030. updatable?: boolean;
  23031. sideOrientation?: number;
  23032. frontUVs?: Vector4;
  23033. backUVs?: Vector4;
  23034. }, scene: any): Mesh;
  23035. /**
  23036. * Creates a torus knot mesh
  23037. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23038. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23039. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23040. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23042. * * 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
  23043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23044. * @param name defines the name of the mesh
  23045. * @param options defines the options used to create the mesh
  23046. * @param scene defines the hosting scene
  23047. * @returns the torus knot mesh
  23048. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23049. */
  23050. static CreateTorusKnot(name: string, options: {
  23051. radius?: number;
  23052. tube?: number;
  23053. radialSegments?: number;
  23054. tubularSegments?: number;
  23055. p?: number;
  23056. q?: number;
  23057. updatable?: boolean;
  23058. sideOrientation?: number;
  23059. frontUVs?: Vector4;
  23060. backUVs?: Vector4;
  23061. }, scene: any): Mesh;
  23062. /**
  23063. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23064. * * 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
  23065. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23066. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23067. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23068. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23069. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23070. * * 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
  23071. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23073. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23074. * @param name defines the name of the new line system
  23075. * @param options defines the options used to create the line system
  23076. * @param scene defines the hosting scene
  23077. * @returns a new line system mesh
  23078. */
  23079. static CreateLineSystem(name: string, options: {
  23080. lines: Vector3[][];
  23081. updatable?: boolean;
  23082. instance?: Nullable<LinesMesh>;
  23083. colors?: Nullable<Color4[][]>;
  23084. useVertexAlpha?: boolean;
  23085. }, scene: Nullable<Scene>): LinesMesh;
  23086. /**
  23087. * Creates a line mesh
  23088. * 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
  23089. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23090. * * The parameter `points` is an array successive Vector3
  23091. * * 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
  23092. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23093. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23094. * * When updating an instance, remember that only point positions can change, not the number of points
  23095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23096. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23097. * @param name defines the name of the new line system
  23098. * @param options defines the options used to create the line system
  23099. * @param scene defines the hosting scene
  23100. * @returns a new line mesh
  23101. */
  23102. static CreateLines(name: string, options: {
  23103. points: Vector3[];
  23104. updatable?: boolean;
  23105. instance?: Nullable<LinesMesh>;
  23106. colors?: Color4[];
  23107. useVertexAlpha?: boolean;
  23108. }, scene?: Nullable<Scene>): LinesMesh;
  23109. /**
  23110. * Creates a dashed line mesh
  23111. * * 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
  23112. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23113. * * The parameter `points` is an array successive Vector3
  23114. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23115. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23116. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23117. * * 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
  23118. * * When updating an instance, remember that only point positions can change, not the number of points
  23119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23120. * @param name defines the name of the mesh
  23121. * @param options defines the options used to create the mesh
  23122. * @param scene defines the hosting scene
  23123. * @returns the dashed line mesh
  23124. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23125. */
  23126. static CreateDashedLines(name: string, options: {
  23127. points: Vector3[];
  23128. dashSize?: number;
  23129. gapSize?: number;
  23130. dashNb?: number;
  23131. updatable?: boolean;
  23132. instance?: LinesMesh;
  23133. }, scene?: Nullable<Scene>): LinesMesh;
  23134. /**
  23135. * 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.
  23136. * * 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.
  23137. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23138. * * 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.
  23139. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23140. * * 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
  23141. * * 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
  23142. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23144. * * 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
  23145. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23147. * @param name defines the name of the mesh
  23148. * @param options defines the options used to create the mesh
  23149. * @param scene defines the hosting scene
  23150. * @returns the extruded shape mesh
  23151. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23152. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23153. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23154. */
  23155. static ExtrudeShape(name: string, options: {
  23156. shape: Vector3[];
  23157. path: Vector3[];
  23158. scale?: number;
  23159. rotation?: number;
  23160. cap?: number;
  23161. updatable?: boolean;
  23162. sideOrientation?: number;
  23163. frontUVs?: Vector4;
  23164. backUVs?: Vector4;
  23165. instance?: Mesh;
  23166. invertUV?: boolean;
  23167. }, scene?: Nullable<Scene>): Mesh;
  23168. /**
  23169. * Creates an custom extruded shape mesh.
  23170. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23171. * * 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.
  23172. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23173. * * 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
  23174. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23175. * * 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
  23176. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23177. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23178. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23179. * * 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
  23180. * * 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
  23181. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23183. * * 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
  23184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23186. * @param name defines the name of the mesh
  23187. * @param options defines the options used to create the mesh
  23188. * @param scene defines the hosting scene
  23189. * @returns the custom extruded shape mesh
  23190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23191. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23192. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23193. */
  23194. static ExtrudeShapeCustom(name: string, options: {
  23195. shape: Vector3[];
  23196. path: Vector3[];
  23197. scaleFunction?: any;
  23198. rotationFunction?: any;
  23199. ribbonCloseArray?: boolean;
  23200. ribbonClosePath?: boolean;
  23201. cap?: number;
  23202. updatable?: boolean;
  23203. sideOrientation?: number;
  23204. frontUVs?: Vector4;
  23205. backUVs?: Vector4;
  23206. instance?: Mesh;
  23207. invertUV?: boolean;
  23208. }, scene: Scene): Mesh;
  23209. /**
  23210. * Creates lathe mesh.
  23211. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23212. * * 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
  23213. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23214. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23215. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23216. * * 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
  23217. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23218. * * 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
  23219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23220. * * 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
  23221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23223. * @param name defines the name of the mesh
  23224. * @param options defines the options used to create the mesh
  23225. * @param scene defines the hosting scene
  23226. * @returns the lathe mesh
  23227. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23228. */
  23229. static CreateLathe(name: string, options: {
  23230. shape: Vector3[];
  23231. radius?: number;
  23232. tessellation?: number;
  23233. clip?: number;
  23234. arc?: number;
  23235. closed?: boolean;
  23236. updatable?: boolean;
  23237. sideOrientation?: number;
  23238. frontUVs?: Vector4;
  23239. backUVs?: Vector4;
  23240. cap?: number;
  23241. invertUV?: boolean;
  23242. }, scene: Scene): Mesh;
  23243. /**
  23244. * Creates a plane mesh
  23245. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23246. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23247. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23249. * * 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
  23250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23251. * @param name defines the name of the mesh
  23252. * @param options defines the options used to create the mesh
  23253. * @param scene defines the hosting scene
  23254. * @returns the plane mesh
  23255. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23256. */
  23257. static CreatePlane(name: string, options: {
  23258. size?: number;
  23259. width?: number;
  23260. height?: number;
  23261. sideOrientation?: number;
  23262. frontUVs?: Vector4;
  23263. backUVs?: Vector4;
  23264. updatable?: boolean;
  23265. sourcePlane?: Plane;
  23266. }, scene: Scene): Mesh;
  23267. /**
  23268. * Creates a ground mesh
  23269. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23270. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23272. * @param name defines the name of the mesh
  23273. * @param options defines the options used to create the mesh
  23274. * @param scene defines the hosting scene
  23275. * @returns the ground mesh
  23276. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23277. */
  23278. static CreateGround(name: string, options: {
  23279. width?: number;
  23280. height?: number;
  23281. subdivisions?: number;
  23282. subdivisionsX?: number;
  23283. subdivisionsY?: number;
  23284. updatable?: boolean;
  23285. }, scene: any): Mesh;
  23286. /**
  23287. * Creates a tiled ground mesh
  23288. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23289. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23290. * * 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
  23291. * * 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
  23292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23293. * @param name defines the name of the mesh
  23294. * @param options defines the options used to create the mesh
  23295. * @param scene defines the hosting scene
  23296. * @returns the tiled ground mesh
  23297. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23298. */
  23299. static CreateTiledGround(name: string, options: {
  23300. xmin: number;
  23301. zmin: number;
  23302. xmax: number;
  23303. zmax: number;
  23304. subdivisions?: {
  23305. w: number;
  23306. h: number;
  23307. };
  23308. precision?: {
  23309. w: number;
  23310. h: number;
  23311. };
  23312. updatable?: boolean;
  23313. }, scene: Scene): Mesh;
  23314. /**
  23315. * Creates a ground mesh from a height map
  23316. * * The parameter `url` sets the URL of the height map image resource.
  23317. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23318. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23319. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23320. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23321. * * 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.
  23322. * * 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).
  23323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23324. * @param name defines the name of the mesh
  23325. * @param url defines the url to the height map
  23326. * @param options defines the options used to create the mesh
  23327. * @param scene defines the hosting scene
  23328. * @returns the ground mesh
  23329. * @see http://doc.babylonjs.com/babylon101/height_map
  23330. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23331. */
  23332. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23333. width?: number;
  23334. height?: number;
  23335. subdivisions?: number;
  23336. minHeight?: number;
  23337. maxHeight?: number;
  23338. colorFilter?: Color3;
  23339. updatable?: boolean;
  23340. onReady?: (mesh: GroundMesh) => void;
  23341. }, scene: Scene): GroundMesh;
  23342. /**
  23343. * Creates a polygon mesh
  23344. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23345. * * 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
  23346. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23348. * * 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)
  23349. * * Remember you can only change the shape positions, not their number when updating a polygon
  23350. * @param name defines the name of the mesh
  23351. * @param options defines the options used to create the mesh
  23352. * @param scene defines the hosting scene
  23353. * @returns the polygon mesh
  23354. */
  23355. static CreatePolygon(name: string, options: {
  23356. shape: Vector3[];
  23357. holes?: Vector3[][];
  23358. depth?: number;
  23359. faceUV?: Vector4[];
  23360. faceColors?: Color4[];
  23361. updatable?: boolean;
  23362. sideOrientation?: number;
  23363. frontUVs?: Vector4;
  23364. backUVs?: Vector4;
  23365. }, scene: Scene): Mesh;
  23366. /**
  23367. * Creates an extruded polygon mesh, with depth in the Y direction.
  23368. * * 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)
  23369. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23370. * @param name defines the name of the mesh
  23371. * @param options defines the options used to create the mesh
  23372. * @param scene defines the hosting scene
  23373. * @returns the polygon mesh
  23374. */
  23375. static ExtrudePolygon(name: string, options: {
  23376. shape: Vector3[];
  23377. holes?: Vector3[][];
  23378. depth?: number;
  23379. faceUV?: Vector4[];
  23380. faceColors?: Color4[];
  23381. updatable?: boolean;
  23382. sideOrientation?: number;
  23383. frontUVs?: Vector4;
  23384. backUVs?: Vector4;
  23385. }, scene: Scene): Mesh;
  23386. /**
  23387. * Creates a tube mesh.
  23388. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23389. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23390. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23391. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23392. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23393. * * 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)
  23394. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23395. * * 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
  23396. * * 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
  23397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23398. * * 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
  23399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23401. * @param name defines the name of the mesh
  23402. * @param options defines the options used to create the mesh
  23403. * @param scene defines the hosting scene
  23404. * @returns the tube mesh
  23405. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23406. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23407. */
  23408. static CreateTube(name: string, options: {
  23409. path: Vector3[];
  23410. radius?: number;
  23411. tessellation?: number;
  23412. radiusFunction?: {
  23413. (i: number, distance: number): number;
  23414. };
  23415. cap?: number;
  23416. arc?: number;
  23417. updatable?: boolean;
  23418. sideOrientation?: number;
  23419. frontUVs?: Vector4;
  23420. backUVs?: Vector4;
  23421. instance?: Mesh;
  23422. invertUV?: boolean;
  23423. }, scene: Scene): Mesh;
  23424. /**
  23425. * Creates a polyhedron mesh
  23426. * * 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
  23427. * * The parameter `size` (positive float, default 1) sets the polygon size
  23428. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23429. * * 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`
  23430. * * 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
  23431. * * 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)`)
  23432. * * 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
  23433. * * 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
  23434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23435. * * 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
  23436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23437. * @param name defines the name of the mesh
  23438. * @param options defines the options used to create the mesh
  23439. * @param scene defines the hosting scene
  23440. * @returns the polyhedron mesh
  23441. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23442. */
  23443. static CreatePolyhedron(name: string, options: {
  23444. type?: number;
  23445. size?: number;
  23446. sizeX?: number;
  23447. sizeY?: number;
  23448. sizeZ?: number;
  23449. custom?: any;
  23450. faceUV?: Vector4[];
  23451. faceColors?: Color4[];
  23452. flat?: boolean;
  23453. updatable?: boolean;
  23454. sideOrientation?: number;
  23455. frontUVs?: Vector4;
  23456. backUVs?: Vector4;
  23457. }, scene: Scene): Mesh;
  23458. /**
  23459. * Creates a decal mesh.
  23460. * 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
  23461. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23462. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23463. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23464. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23465. * @param name defines the name of the mesh
  23466. * @param sourceMesh defines the mesh where the decal must be applied
  23467. * @param options defines the options used to create the mesh
  23468. * @param scene defines the hosting scene
  23469. * @returns the decal mesh
  23470. * @see http://doc.babylonjs.com/how_to/decals
  23471. */
  23472. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23473. position?: Vector3;
  23474. normal?: Vector3;
  23475. size?: Vector3;
  23476. angle?: number;
  23477. }): Mesh;
  23478. private static _ExtrudeShapeGeneric;
  23479. }
  23480. }
  23481. declare module BABYLON {
  23482. class MeshLODLevel {
  23483. distance: number;
  23484. mesh: Nullable<Mesh>;
  23485. constructor(distance: number, mesh: Nullable<Mesh>);
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /**
  23490. * A simplifier interface for future simplification implementations.
  23491. */
  23492. interface ISimplifier {
  23493. /**
  23494. * Simplification of a given mesh according to the given settings.
  23495. * Since this requires computation, it is assumed that the function runs async.
  23496. * @param settings The settings of the simplification, including quality and distance
  23497. * @param successCallback A callback that will be called after the mesh was simplified.
  23498. * @param errorCallback in case of an error, this callback will be called. optional.
  23499. */
  23500. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23501. }
  23502. /**
  23503. * Expected simplification settings.
  23504. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23505. */
  23506. interface ISimplificationSettings {
  23507. quality: number;
  23508. distance: number;
  23509. optimizeMesh?: boolean;
  23510. }
  23511. class SimplificationSettings implements ISimplificationSettings {
  23512. quality: number;
  23513. distance: number;
  23514. optimizeMesh?: boolean | undefined;
  23515. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23516. }
  23517. interface ISimplificationTask {
  23518. settings: Array<ISimplificationSettings>;
  23519. simplificationType: SimplificationType;
  23520. mesh: Mesh;
  23521. successCallback?: () => void;
  23522. parallelProcessing: boolean;
  23523. }
  23524. class SimplificationQueue {
  23525. private _simplificationArray;
  23526. running: boolean;
  23527. constructor();
  23528. addTask(task: ISimplificationTask): void;
  23529. executeNext(): void;
  23530. runSimplification(task: ISimplificationTask): void;
  23531. private getSimplifier;
  23532. }
  23533. /**
  23534. * The implemented types of simplification
  23535. * At the moment only Quadratic Error Decimation is implemented
  23536. */
  23537. enum SimplificationType {
  23538. /** Quadratic error decimation */
  23539. QUADRATIC = 0
  23540. }
  23541. class DecimationTriangle {
  23542. vertices: Array<DecimationVertex>;
  23543. normal: Vector3;
  23544. error: Array<number>;
  23545. deleted: boolean;
  23546. isDirty: boolean;
  23547. borderFactor: number;
  23548. deletePending: boolean;
  23549. originalOffset: number;
  23550. constructor(vertices: Array<DecimationVertex>);
  23551. }
  23552. class DecimationVertex {
  23553. position: Vector3;
  23554. id: number;
  23555. q: QuadraticMatrix;
  23556. isBorder: boolean;
  23557. triangleStart: number;
  23558. triangleCount: number;
  23559. originalOffsets: Array<number>;
  23560. constructor(position: Vector3, id: number);
  23561. updatePosition(newPosition: Vector3): void;
  23562. }
  23563. class QuadraticMatrix {
  23564. data: Array<number>;
  23565. constructor(data?: Array<number>);
  23566. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23567. addInPlace(matrix: QuadraticMatrix): void;
  23568. addArrayInPlace(data: Array<number>): void;
  23569. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23570. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23571. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23572. }
  23573. class Reference {
  23574. vertexId: number;
  23575. triangleId: number;
  23576. constructor(vertexId: number, triangleId: number);
  23577. }
  23578. /**
  23579. * An implementation of the Quadratic Error simplification algorithm.
  23580. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23581. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23582. * @author RaananW
  23583. */
  23584. class QuadraticErrorSimplification implements ISimplifier {
  23585. private _mesh;
  23586. private triangles;
  23587. private vertices;
  23588. private references;
  23589. private _reconstructedMesh;
  23590. syncIterations: number;
  23591. aggressiveness: number;
  23592. decimationIterations: number;
  23593. boundingBoxEpsilon: number;
  23594. constructor(_mesh: Mesh);
  23595. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23596. private runDecimation;
  23597. private initWithMesh;
  23598. private init;
  23599. private reconstructMesh;
  23600. private initDecimatedMesh;
  23601. private isFlipped;
  23602. private updateTriangles;
  23603. private identifyBorder;
  23604. private updateMesh;
  23605. private vertexError;
  23606. private calculateError;
  23607. }
  23608. }
  23609. declare module BABYLON {
  23610. interface Scene {
  23611. /** @hidden (Backing field) */
  23612. _simplificationQueue: SimplificationQueue;
  23613. /**
  23614. * Gets or sets the simplification queue attached to the scene
  23615. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23616. */
  23617. simplificationQueue: SimplificationQueue;
  23618. }
  23619. interface Mesh {
  23620. /**
  23621. * Simplify the mesh according to the given array of settings.
  23622. * Function will return immediately and will simplify async. It returns the Mesh.
  23623. * @param settings a collection of simplification settings.
  23624. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23625. * @param type the type of simplification to run.
  23626. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23627. */
  23628. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23629. }
  23630. /**
  23631. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23632. * created in a scene
  23633. */
  23634. class SimplicationQueueSceneComponent implements ISceneComponent {
  23635. /**
  23636. * The component name helpfull to identify the component in the list of scene components.
  23637. */
  23638. readonly name: string;
  23639. /**
  23640. * The scene the component belongs to.
  23641. */
  23642. scene: Scene;
  23643. /**
  23644. * Creates a new instance of the component for the given scene
  23645. * @param scene Defines the scene to register the component in
  23646. */
  23647. constructor(scene: Scene);
  23648. /**
  23649. * Registers the component in a given scene
  23650. */
  23651. register(): void;
  23652. /**
  23653. * Rebuilds the elements related to this component in case of
  23654. * context lost for instance.
  23655. */
  23656. rebuild(): void;
  23657. /**
  23658. * Disposes the component and the associated ressources
  23659. */
  23660. dispose(): void;
  23661. private _beforeCameraUpdate;
  23662. }
  23663. }
  23664. declare module BABYLON {
  23665. class Polygon {
  23666. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23667. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23668. static Parse(input: string): Vector2[];
  23669. static StartingAt(x: number, y: number): Path2;
  23670. }
  23671. class PolygonMeshBuilder {
  23672. private _points;
  23673. private _outlinepoints;
  23674. private _holes;
  23675. private _name;
  23676. private _scene;
  23677. private _epoints;
  23678. private _eholes;
  23679. private _addToepoint;
  23680. constructor(name: string, contours: Path2, scene: Scene);
  23681. constructor(name: string, contours: Vector2[], scene: Scene);
  23682. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23683. build(updatable?: boolean, depth?: number): Mesh;
  23684. private addSide;
  23685. }
  23686. }
  23687. declare module BABYLON {
  23688. class BaseSubMesh {
  23689. /** @hidden */
  23690. _materialDefines: Nullable<MaterialDefines>;
  23691. /** @hidden */
  23692. _materialEffect: Nullable<Effect>;
  23693. readonly effect: Nullable<Effect>;
  23694. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23695. }
  23696. class SubMesh extends BaseSubMesh implements ICullable {
  23697. materialIndex: number;
  23698. verticesStart: number;
  23699. verticesCount: number;
  23700. indexStart: number;
  23701. indexCount: number;
  23702. linesIndexCount: number;
  23703. private _mesh;
  23704. private _renderingMesh;
  23705. private _boundingInfo;
  23706. private _linesIndexBuffer;
  23707. /** @hidden */
  23708. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23709. /** @hidden */
  23710. _trianglePlanes: Plane[];
  23711. /** @hidden */
  23712. _lastColliderTransformMatrix: Matrix;
  23713. /** @hidden */
  23714. _renderId: number;
  23715. /** @hidden */
  23716. _alphaIndex: number;
  23717. /** @hidden */
  23718. _distanceToCamera: number;
  23719. /** @hidden */
  23720. _id: number;
  23721. private _currentMaterial;
  23722. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23723. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23724. readonly IsGlobal: boolean;
  23725. /**
  23726. * Returns the submesh BoudingInfo object.
  23727. */
  23728. getBoundingInfo(): BoundingInfo;
  23729. /**
  23730. * Sets the submesh BoundingInfo.
  23731. * Return the SubMesh.
  23732. */
  23733. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23734. /**
  23735. * Returns the mesh of the current submesh.
  23736. */
  23737. getMesh(): AbstractMesh;
  23738. /**
  23739. * Returns the rendering mesh of the submesh.
  23740. */
  23741. getRenderingMesh(): Mesh;
  23742. /**
  23743. * Returns the submesh material.
  23744. */
  23745. getMaterial(): Nullable<Material>;
  23746. /**
  23747. * Sets a new updated BoundingInfo object to the submesh.
  23748. * Returns the SubMesh.
  23749. */
  23750. refreshBoundingInfo(): SubMesh;
  23751. /** @hidden */
  23752. _checkCollision(collider: Collider): boolean;
  23753. /**
  23754. * Updates the submesh BoundingInfo.
  23755. * Returns the Submesh.
  23756. */
  23757. updateBoundingInfo(world: Matrix): SubMesh;
  23758. /**
  23759. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23760. * Boolean returned.
  23761. */
  23762. isInFrustum(frustumPlanes: Plane[]): boolean;
  23763. /**
  23764. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23765. * Boolean returned.
  23766. */
  23767. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23768. /**
  23769. * Renders the submesh.
  23770. * Returns it.
  23771. */
  23772. render(enableAlphaMode: boolean): SubMesh;
  23773. /**
  23774. * Returns a new Index Buffer.
  23775. * Type returned : WebGLBuffer.
  23776. */
  23777. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23778. /**
  23779. * True is the passed Ray intersects the submesh bounding box.
  23780. * Boolean returned.
  23781. */
  23782. canIntersects(ray: Ray): boolean;
  23783. /**
  23784. * Returns an object IntersectionInfo.
  23785. */
  23786. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23787. /** @hidden */
  23788. _rebuild(): void;
  23789. /**
  23790. * Creates a new Submesh from the passed Mesh.
  23791. */
  23792. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23793. /**
  23794. * Disposes the Submesh.
  23795. * Returns nothing.
  23796. */
  23797. dispose(): void;
  23798. /**
  23799. * Creates a new Submesh from the passed parameters :
  23800. * - materialIndex (integer) : the index of the main mesh material.
  23801. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23802. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23803. * - mesh (Mesh) : the main mesh to create the submesh from.
  23804. * - renderingMesh (optional Mesh) : rendering mesh.
  23805. */
  23806. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. class TransformNode extends Node {
  23811. static BILLBOARDMODE_NONE: number;
  23812. static BILLBOARDMODE_X: number;
  23813. static BILLBOARDMODE_Y: number;
  23814. static BILLBOARDMODE_Z: number;
  23815. static BILLBOARDMODE_ALL: number;
  23816. private _forward;
  23817. private _forwardInverted;
  23818. private _up;
  23819. private _right;
  23820. private _rightInverted;
  23821. private _rotation;
  23822. private _rotationQuaternion;
  23823. protected _scaling: Vector3;
  23824. protected _isDirty: boolean;
  23825. private _transformToBoneReferal;
  23826. /**
  23827. * Set the billboard mode. Default is 0.
  23828. *
  23829. * | Value | Type | Description |
  23830. * | --- | --- | --- |
  23831. * | 0 | BILLBOARDMODE_NONE | |
  23832. * | 1 | BILLBOARDMODE_X | |
  23833. * | 2 | BILLBOARDMODE_Y | |
  23834. * | 4 | BILLBOARDMODE_Z | |
  23835. * | 7 | BILLBOARDMODE_ALL | |
  23836. *
  23837. */
  23838. billboardMode: number;
  23839. scalingDeterminant: number;
  23840. infiniteDistance: boolean;
  23841. /**
  23842. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23843. * By default the system will update normals to compensate
  23844. */
  23845. ignoreNonUniformScaling: boolean;
  23846. position: Vector3;
  23847. /** @hidden */
  23848. _poseMatrix: Matrix;
  23849. private _localWorld;
  23850. /** @hidden */
  23851. _worldMatrix: Matrix;
  23852. /** @hidden */
  23853. _worldMatrixDeterminant: number;
  23854. private _absolutePosition;
  23855. private _pivotMatrix;
  23856. private _pivotMatrixInverse;
  23857. private _postMultiplyPivotMatrix;
  23858. protected _isWorldMatrixFrozen: boolean;
  23859. /**
  23860. * An event triggered after the world matrix is updated
  23861. */
  23862. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23863. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23864. /**
  23865. * Gets a string identifying the name of the class
  23866. * @returns "TransformNode" string
  23867. */
  23868. getClassName(): string;
  23869. /**
  23870. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23871. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23872. * Default : (0.0, 0.0, 0.0)
  23873. */
  23874. rotation: Vector3;
  23875. /**
  23876. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23877. * Default : (1.0, 1.0, 1.0)
  23878. */
  23879. /**
  23880. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23881. * Default : (1.0, 1.0, 1.0)
  23882. */
  23883. scaling: Vector3;
  23884. /**
  23885. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23886. * It's null by default.
  23887. * 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)
  23888. */
  23889. rotationQuaternion: Nullable<Quaternion>;
  23890. /**
  23891. * The forward direction of that transform in world space.
  23892. */
  23893. readonly forward: Vector3;
  23894. /**
  23895. * The up direction of that transform in world space.
  23896. */
  23897. readonly up: Vector3;
  23898. /**
  23899. * The right direction of that transform in world space.
  23900. */
  23901. readonly right: Vector3;
  23902. /**
  23903. * Returns the latest update of the World matrix
  23904. * Returns a Matrix.
  23905. */
  23906. getWorldMatrix(): Matrix;
  23907. /** @hidden */
  23908. _getWorldMatrixDeterminant(): number;
  23909. /**
  23910. * Returns directly the latest state of the mesh World matrix.
  23911. * A Matrix is returned.
  23912. */
  23913. readonly worldMatrixFromCache: Matrix;
  23914. /**
  23915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  23916. * Returns the TransformNode.
  23917. */
  23918. updatePoseMatrix(matrix: Matrix): TransformNode;
  23919. /**
  23920. * Returns the mesh Pose matrix.
  23921. * Returned object : Matrix
  23922. */
  23923. getPoseMatrix(): Matrix;
  23924. /** @hidden */
  23925. _isSynchronized(): boolean;
  23926. /** @hidden */
  23927. _initCache(): void;
  23928. markAsDirty(property: string): TransformNode;
  23929. /**
  23930. * Returns the current mesh absolute position.
  23931. * Returns a Vector3.
  23932. */
  23933. readonly absolutePosition: Vector3;
  23934. /**
  23935. * Sets a new matrix to apply before all other transformation
  23936. * @param matrix defines the transform matrix
  23937. * @returns the current TransformNode
  23938. */
  23939. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23940. /**
  23941. * Sets a new pivot matrix to the current node
  23942. * @param matrix defines the new pivot matrix to use
  23943. * @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
  23944. * @returns the current TransformNode
  23945. */
  23946. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23947. /**
  23948. * Returns the mesh pivot matrix.
  23949. * Default : Identity.
  23950. * A Matrix is returned.
  23951. */
  23952. getPivotMatrix(): Matrix;
  23953. /**
  23954. * Prevents the World matrix to be computed any longer.
  23955. * Returns the TransformNode.
  23956. */
  23957. freezeWorldMatrix(): TransformNode;
  23958. /**
  23959. * Allows back the World matrix computation.
  23960. * Returns the TransformNode.
  23961. */
  23962. unfreezeWorldMatrix(): this;
  23963. /**
  23964. * True if the World matrix has been frozen.
  23965. * Returns a boolean.
  23966. */
  23967. readonly isWorldMatrixFrozen: boolean;
  23968. /**
  23969. * Retuns the mesh absolute position in the World.
  23970. * Returns a Vector3.
  23971. */
  23972. getAbsolutePosition(): Vector3;
  23973. /**
  23974. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23975. * Returns the TransformNode.
  23976. */
  23977. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23978. /**
  23979. * Sets the mesh position in its local space.
  23980. * Returns the TransformNode.
  23981. */
  23982. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23983. /**
  23984. * Returns the mesh position in the local space from the current World matrix values.
  23985. * Returns a new Vector3.
  23986. */
  23987. getPositionExpressedInLocalSpace(): Vector3;
  23988. /**
  23989. * Translates the mesh along the passed Vector3 in its local space.
  23990. * Returns the TransformNode.
  23991. */
  23992. locallyTranslate(vector3: Vector3): TransformNode;
  23993. private static _lookAtVectorCache;
  23994. /**
  23995. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23996. * @param targetPoint the position (must be in same space as current mesh) to look at
  23997. * @param yawCor optional yaw (y-axis) correction in radians
  23998. * @param pitchCor optional pitch (x-axis) correction in radians
  23999. * @param rollCor optional roll (z-axis) correction in radians
  24000. * @param space the choosen space of the target
  24001. * @returns the TransformNode.
  24002. */
  24003. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24004. /**
  24005. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24006. * This Vector3 is expressed in the World space.
  24007. */
  24008. getDirection(localAxis: Vector3): Vector3;
  24009. /**
  24010. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24011. * localAxis is expressed in the mesh local space.
  24012. * result is computed in the Wordl space from the mesh World matrix.
  24013. * Returns the TransformNode.
  24014. */
  24015. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24016. /**
  24017. * Sets a new pivot point to the current node
  24018. * @param point defines the new pivot point to use
  24019. * @param space defines if the point is in world or local space (local by default)
  24020. * @returns the current TransformNode
  24021. */
  24022. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24023. /**
  24024. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24025. */
  24026. getPivotPoint(): Vector3;
  24027. /**
  24028. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24029. * Returns the TransformNode.
  24030. */
  24031. getPivotPointToRef(result: Vector3): TransformNode;
  24032. /**
  24033. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24034. */
  24035. getAbsolutePivotPoint(): Vector3;
  24036. /**
  24037. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24038. * Returns the TransformNode.
  24039. */
  24040. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24041. /**
  24042. * Defines the passed node as the parent of the current node.
  24043. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24044. * Returns the TransformNode.
  24045. */
  24046. setParent(node: Nullable<Node>): TransformNode;
  24047. private _nonUniformScaling;
  24048. readonly nonUniformScaling: boolean;
  24049. /** @hidden */
  24050. _updateNonUniformScalingState(value: boolean): boolean;
  24051. /**
  24052. * Attach the current TransformNode to another TransformNode associated with a bone
  24053. * @param bone Bone affecting the TransformNode
  24054. * @param affectedTransformNode TransformNode associated with the bone
  24055. */
  24056. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24057. detachFromBone(): TransformNode;
  24058. private static _rotationAxisCache;
  24059. /**
  24060. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24061. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24062. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24063. * The passed axis is also normalized.
  24064. * Returns the TransformNode.
  24065. */
  24066. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24067. /**
  24068. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24069. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24070. * The passed axis is also normalized.
  24071. * Returns the TransformNode.
  24072. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24073. */
  24074. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24075. /**
  24076. * Translates the mesh along the axis vector for the passed distance in the given space.
  24077. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24078. * Returns the TransformNode.
  24079. */
  24080. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24081. /**
  24082. * Adds a rotation step to the mesh current rotation.
  24083. * x, y, z are Euler angles expressed in radians.
  24084. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24085. * This means this rotation is made in the mesh local space only.
  24086. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24087. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24088. * ```javascript
  24089. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24090. * ```
  24091. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24092. * 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.
  24093. * Returns the TransformNode.
  24094. */
  24095. addRotation(x: number, y: number, z: number): TransformNode;
  24096. /**
  24097. * Computes the mesh World matrix and returns it.
  24098. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24099. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24100. * If the parameter `force`is set to `true`, the actual computation is done.
  24101. * Returns the mesh World Matrix.
  24102. */
  24103. computeWorldMatrix(force?: boolean): Matrix;
  24104. protected _afterComputeWorldMatrix(): void;
  24105. /**
  24106. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24107. * @param func: callback function to add
  24108. *
  24109. * Returns the TransformNode.
  24110. */
  24111. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24112. /**
  24113. * Removes a registered callback function.
  24114. * Returns the TransformNode.
  24115. */
  24116. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24117. /**
  24118. * Clone the current transform node
  24119. * Returns the new transform node
  24120. * @param name Name of the new clone
  24121. * @param newParent New parent for the clone
  24122. * @param doNotCloneChildren Do not clone children hierarchy
  24123. */
  24124. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24125. serialize(currentSerializationObject?: any): any;
  24126. /**
  24127. * Returns a new TransformNode object parsed from the source provided.
  24128. * The parameter `parsedMesh` is the source.
  24129. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24130. */
  24131. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24132. /**
  24133. * Releases resources associated with this transform node.
  24134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24136. */
  24137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24138. }
  24139. }
  24140. declare module BABYLON {
  24141. class VertexBuffer {
  24142. /** @hidden */
  24143. _buffer: Buffer;
  24144. private _kind;
  24145. private _size;
  24146. private _ownsBuffer;
  24147. private _instanced;
  24148. private _instanceDivisor;
  24149. /**
  24150. * The byte type.
  24151. */
  24152. static readonly BYTE: number;
  24153. /**
  24154. * The unsigned byte type.
  24155. */
  24156. static readonly UNSIGNED_BYTE: number;
  24157. /**
  24158. * The short type.
  24159. */
  24160. static readonly SHORT: number;
  24161. /**
  24162. * The unsigned short type.
  24163. */
  24164. static readonly UNSIGNED_SHORT: number;
  24165. /**
  24166. * The integer type.
  24167. */
  24168. static readonly INT: number;
  24169. /**
  24170. * The unsigned integer type.
  24171. */
  24172. static readonly UNSIGNED_INT: number;
  24173. /**
  24174. * The float type.
  24175. */
  24176. static readonly FLOAT: number;
  24177. /**
  24178. * Gets or sets the instance divisor when in instanced mode
  24179. */
  24180. instanceDivisor: number;
  24181. /**
  24182. * Gets the byte stride.
  24183. */
  24184. readonly byteStride: number;
  24185. /**
  24186. * Gets the byte offset.
  24187. */
  24188. readonly byteOffset: number;
  24189. /**
  24190. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24191. */
  24192. readonly normalized: boolean;
  24193. /**
  24194. * Gets the data type of each component in the array.
  24195. */
  24196. readonly type: number;
  24197. /**
  24198. * Constructor
  24199. * @param engine the engine
  24200. * @param data the data to use for this vertex buffer
  24201. * @param kind the vertex buffer kind
  24202. * @param updatable whether the data is updatable
  24203. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24204. * @param stride the stride (optional)
  24205. * @param instanced whether the buffer is instanced (optional)
  24206. * @param offset the offset of the data (optional)
  24207. * @param size the number of components (optional)
  24208. * @param type the type of the component (optional)
  24209. * @param normalized whether the data contains normalized data (optional)
  24210. * @param useBytes set to true if stride and offset are in bytes (optional)
  24211. */
  24212. 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);
  24213. /** @hidden */
  24214. _rebuild(): void;
  24215. /**
  24216. * Returns the kind of the VertexBuffer (string).
  24217. */
  24218. getKind(): string;
  24219. /**
  24220. * Boolean : is the VertexBuffer updatable ?
  24221. */
  24222. isUpdatable(): boolean;
  24223. /**
  24224. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24225. */
  24226. getData(): Nullable<DataArray>;
  24227. /**
  24228. * Returns the WebGLBuffer associated to the VertexBuffer.
  24229. */
  24230. getBuffer(): Nullable<WebGLBuffer>;
  24231. /**
  24232. * Returns the stride as a multiple of the type byte length.
  24233. * DEPRECATED. Use byteStride instead.
  24234. */
  24235. getStrideSize(): number;
  24236. /**
  24237. * Returns the offset as a multiple of the type byte length.
  24238. * DEPRECATED. Use byteOffset instead.
  24239. */
  24240. getOffset(): number;
  24241. /**
  24242. * Returns the number of components per vertex attribute (integer).
  24243. */
  24244. getSize(): number;
  24245. /**
  24246. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24247. */
  24248. getIsInstanced(): boolean;
  24249. /**
  24250. * Returns the instancing divisor, zero for non-instanced (integer).
  24251. */
  24252. getInstanceDivisor(): number;
  24253. /**
  24254. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24255. * Returns the created WebGLBuffer.
  24256. */
  24257. create(data?: DataArray): void;
  24258. /**
  24259. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24260. * This function will create a new buffer if the current one is not updatable
  24261. * Returns the updated WebGLBuffer.
  24262. */
  24263. update(data: DataArray): void;
  24264. /**
  24265. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24266. * Returns the directly updated WebGLBuffer.
  24267. * @param data the new data
  24268. * @param offset the new offset
  24269. * @param useBytes set to true if the offset is in bytes
  24270. */
  24271. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24272. /**
  24273. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24274. */
  24275. dispose(): void;
  24276. /**
  24277. * Enumerates each value of this vertex buffer as numbers.
  24278. * @param count the number of values to enumerate
  24279. * @param callback the callback function called for each value
  24280. */
  24281. forEach(count: number, callback: (value: number, index: number) => void): void;
  24282. private static _PositionKind;
  24283. private static _NormalKind;
  24284. private static _TangentKind;
  24285. private static _UVKind;
  24286. private static _UV2Kind;
  24287. private static _UV3Kind;
  24288. private static _UV4Kind;
  24289. private static _UV5Kind;
  24290. private static _UV6Kind;
  24291. private static _ColorKind;
  24292. private static _MatricesIndicesKind;
  24293. private static _MatricesWeightsKind;
  24294. private static _MatricesIndicesExtraKind;
  24295. private static _MatricesWeightsExtraKind;
  24296. static readonly PositionKind: string;
  24297. static readonly NormalKind: string;
  24298. static readonly TangentKind: string;
  24299. static readonly UVKind: string;
  24300. static readonly UV2Kind: string;
  24301. static readonly UV3Kind: string;
  24302. static readonly UV4Kind: string;
  24303. static readonly UV5Kind: string;
  24304. static readonly UV6Kind: string;
  24305. static readonly ColorKind: string;
  24306. static readonly MatricesIndicesKind: string;
  24307. static readonly MatricesWeightsKind: string;
  24308. static readonly MatricesIndicesExtraKind: string;
  24309. static readonly MatricesWeightsExtraKind: string;
  24310. /**
  24311. * Deduces the stride given a kind.
  24312. * @param kind The kind string to deduce
  24313. * @returns The deduced stride
  24314. */
  24315. static DeduceStride(kind: string): number;
  24316. /**
  24317. * Gets the byte length of the given type.
  24318. * @param type the type
  24319. * @returns the number of bytes
  24320. */
  24321. static GetTypeByteLength(type: number): number;
  24322. /**
  24323. * Enumerates each value of the given parameters as numbers.
  24324. * @param data the data to enumerate
  24325. * @param byteOffset the byte offset of the data
  24326. * @param byteStride the byte stride of the data
  24327. * @param componentCount the number of components per element
  24328. * @param componentType the type of the component
  24329. * @param count the total number of components
  24330. * @param normalized whether the data is normalized
  24331. * @param callback the callback function called for each value
  24332. */
  24333. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24334. private static _GetFloatValue;
  24335. }
  24336. }
  24337. declare module BABYLON {
  24338. /**
  24339. * Defines a target to use with MorphTargetManager
  24340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24341. */
  24342. class MorphTarget implements IAnimatable {
  24343. /** defines the name of the target */
  24344. name: string;
  24345. /**
  24346. * Gets or sets the list of animations
  24347. */
  24348. animations: Animation[];
  24349. private _scene;
  24350. private _positions;
  24351. private _normals;
  24352. private _tangents;
  24353. private _influence;
  24354. /**
  24355. * Observable raised when the influence changes
  24356. */
  24357. onInfluenceChanged: Observable<boolean>;
  24358. /**
  24359. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24360. */
  24361. influence: number;
  24362. private _animationPropertiesOverride;
  24363. /**
  24364. * Gets or sets the animation properties override
  24365. */
  24366. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24367. /**
  24368. * Creates a new MorphTarget
  24369. * @param name defines the name of the target
  24370. * @param influence defines the influence to use
  24371. */
  24372. constructor(
  24373. /** defines the name of the target */
  24374. name: string, influence?: number, scene?: Nullable<Scene>);
  24375. /**
  24376. * Gets a boolean defining if the target contains position data
  24377. */
  24378. readonly hasPositions: boolean;
  24379. /**
  24380. * Gets a boolean defining if the target contains normal data
  24381. */
  24382. readonly hasNormals: boolean;
  24383. /**
  24384. * Gets a boolean defining if the target contains tangent data
  24385. */
  24386. readonly hasTangents: boolean;
  24387. /**
  24388. * Affects position data to this target
  24389. * @param data defines the position data to use
  24390. */
  24391. setPositions(data: Nullable<FloatArray>): void;
  24392. /**
  24393. * Gets the position data stored in this target
  24394. * @returns a FloatArray containing the position data (or null if not present)
  24395. */
  24396. getPositions(): Nullable<FloatArray>;
  24397. /**
  24398. * Affects normal data to this target
  24399. * @param data defines the normal data to use
  24400. */
  24401. setNormals(data: Nullable<FloatArray>): void;
  24402. /**
  24403. * Gets the normal data stored in this target
  24404. * @returns a FloatArray containing the normal data (or null if not present)
  24405. */
  24406. getNormals(): Nullable<FloatArray>;
  24407. /**
  24408. * Affects tangent data to this target
  24409. * @param data defines the tangent data to use
  24410. */
  24411. setTangents(data: Nullable<FloatArray>): void;
  24412. /**
  24413. * Gets the tangent data stored in this target
  24414. * @returns a FloatArray containing the tangent data (or null if not present)
  24415. */
  24416. getTangents(): Nullable<FloatArray>;
  24417. /**
  24418. * Serializes the current target into a Serialization object
  24419. * @returns the serialized object
  24420. */
  24421. serialize(): any;
  24422. /**
  24423. * Creates a new target from serialized data
  24424. * @param serializationObject defines the serialized data to use
  24425. * @returns a new MorphTarget
  24426. */
  24427. static Parse(serializationObject: any): MorphTarget;
  24428. /**
  24429. * Creates a MorphTarget from mesh data
  24430. * @param mesh defines the source mesh
  24431. * @param name defines the name to use for the new target
  24432. * @param influence defines the influence to attach to the target
  24433. * @returns a new MorphTarget
  24434. */
  24435. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24436. }
  24437. }
  24438. declare module BABYLON {
  24439. /**
  24440. * This class is used to deform meshes using morphing between different targets
  24441. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24442. */
  24443. class MorphTargetManager {
  24444. private _targets;
  24445. private _targetObservable;
  24446. private _activeTargets;
  24447. private _scene;
  24448. private _influences;
  24449. private _supportsNormals;
  24450. private _supportsTangents;
  24451. private _vertexCount;
  24452. private _uniqueId;
  24453. private _tempInfluences;
  24454. /**
  24455. * Creates a new MorphTargetManager
  24456. * @param scene defines the current scene
  24457. */
  24458. constructor(scene?: Nullable<Scene>);
  24459. /**
  24460. * Gets the unique ID of this manager
  24461. */
  24462. readonly uniqueId: number;
  24463. /**
  24464. * Gets the number of vertices handled by this manager
  24465. */
  24466. readonly vertexCount: number;
  24467. /**
  24468. * Gets a boolean indicating if this manager supports morphing of normals
  24469. */
  24470. readonly supportsNormals: boolean;
  24471. /**
  24472. * Gets a boolean indicating if this manager supports morphing of tangents
  24473. */
  24474. readonly supportsTangents: boolean;
  24475. /**
  24476. * Gets the number of targets stored in this manager
  24477. */
  24478. readonly numTargets: number;
  24479. /**
  24480. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24481. */
  24482. readonly numInfluencers: number;
  24483. /**
  24484. * Gets the list of influences (one per target)
  24485. */
  24486. readonly influences: Float32Array;
  24487. /**
  24488. * Gets the active target at specified index. An active target is a target with an influence > 0
  24489. * @param index defines the index to check
  24490. * @returns the requested target
  24491. */
  24492. getActiveTarget(index: number): MorphTarget;
  24493. /**
  24494. * Gets the target at specified index
  24495. * @param index defines the index to check
  24496. * @returns the requested target
  24497. */
  24498. getTarget(index: number): MorphTarget;
  24499. /**
  24500. * Add a new target to this manager
  24501. * @param target defines the target to add
  24502. */
  24503. addTarget(target: MorphTarget): void;
  24504. /**
  24505. * Removes a target from the manager
  24506. * @param target defines the target to remove
  24507. */
  24508. removeTarget(target: MorphTarget): void;
  24509. /**
  24510. * Serializes the current manager into a Serialization object
  24511. * @returns the serialized object
  24512. */
  24513. serialize(): any;
  24514. private _syncActiveTargets;
  24515. /**
  24516. * Syncrhonize the targets with all the meshes using this morph target manager
  24517. */
  24518. synchronize(): void;
  24519. /**
  24520. * Creates a new MorphTargetManager from serialized data
  24521. * @param serializationObject defines the serialized data
  24522. * @param scene defines the hosting scene
  24523. * @returns the new MorphTargetManager
  24524. */
  24525. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24526. }
  24527. }
  24528. declare module BABYLON {
  24529. /**
  24530. * This represents the base class for particle system in Babylon.
  24531. * 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.
  24532. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24533. * @example https://doc.babylonjs.com/babylon101/particles
  24534. */
  24535. class BaseParticleSystem {
  24536. /**
  24537. * Source color is added to the destination color without alpha affecting the result.
  24538. */
  24539. static BLENDMODE_ONEONE: number;
  24540. /**
  24541. * Blend current color and particle color using particle’s alpha.
  24542. */
  24543. static BLENDMODE_STANDARD: number;
  24544. /**
  24545. * Add current color and particle color multiplied by particle’s alpha.
  24546. */
  24547. static BLENDMODE_ADD: number;
  24548. /**
  24549. * Multiply current color with particle color
  24550. */
  24551. static BLENDMODE_MULTIPLY: number;
  24552. /**
  24553. * List of animations used by the particle system.
  24554. */
  24555. animations: Animation[];
  24556. /**
  24557. * The id of the Particle system.
  24558. */
  24559. id: string;
  24560. /**
  24561. * The friendly name of the Particle system.
  24562. */
  24563. name: string;
  24564. /**
  24565. * The rendering group used by the Particle system to chose when to render.
  24566. */
  24567. renderingGroupId: number;
  24568. /**
  24569. * The emitter represents the Mesh or position we are attaching the particle system to.
  24570. */
  24571. emitter: Nullable<AbstractMesh | Vector3>;
  24572. /**
  24573. * The maximum number of particles to emit per frame
  24574. */
  24575. emitRate: number;
  24576. /**
  24577. * If you want to launch only a few particles at once, that can be done, as well.
  24578. */
  24579. manualEmitCount: number;
  24580. /**
  24581. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24582. */
  24583. updateSpeed: number;
  24584. /**
  24585. * The amount of time the particle system is running (depends of the overall update speed).
  24586. */
  24587. targetStopDuration: number;
  24588. /**
  24589. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24590. */
  24591. disposeOnStop: boolean;
  24592. /**
  24593. * Minimum power of emitting particles.
  24594. */
  24595. minEmitPower: number;
  24596. /**
  24597. * Maximum power of emitting particles.
  24598. */
  24599. maxEmitPower: number;
  24600. /**
  24601. * Minimum life time of emitting particles.
  24602. */
  24603. minLifeTime: number;
  24604. /**
  24605. * Maximum life time of emitting particles.
  24606. */
  24607. maxLifeTime: number;
  24608. /**
  24609. * Minimum Size of emitting particles.
  24610. */
  24611. minSize: number;
  24612. /**
  24613. * Maximum Size of emitting particles.
  24614. */
  24615. maxSize: number;
  24616. /**
  24617. * Minimum scale of emitting particles on X axis.
  24618. */
  24619. minScaleX: number;
  24620. /**
  24621. * Maximum scale of emitting particles on X axis.
  24622. */
  24623. maxScaleX: number;
  24624. /**
  24625. * Minimum scale of emitting particles on Y axis.
  24626. */
  24627. minScaleY: number;
  24628. /**
  24629. * Maximum scale of emitting particles on Y axis.
  24630. */
  24631. maxScaleY: number;
  24632. /**
  24633. * Gets or sets the minimal initial rotation in radians.
  24634. */
  24635. minInitialRotation: number;
  24636. /**
  24637. * Gets or sets the maximal initial rotation in radians.
  24638. */
  24639. maxInitialRotation: number;
  24640. /**
  24641. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24642. */
  24643. minAngularSpeed: number;
  24644. /**
  24645. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24646. */
  24647. maxAngularSpeed: number;
  24648. /**
  24649. * The texture used to render each particle. (this can be a spritesheet)
  24650. */
  24651. particleTexture: Nullable<Texture>;
  24652. /**
  24653. * The layer mask we are rendering the particles through.
  24654. */
  24655. layerMask: number;
  24656. /**
  24657. * This can help using your own shader to render the particle system.
  24658. * The according effect will be created
  24659. */
  24660. customShader: any;
  24661. /**
  24662. * By default particle system starts as soon as they are created. This prevents the
  24663. * automatic start to happen and let you decide when to start emitting particles.
  24664. */
  24665. preventAutoStart: boolean;
  24666. /**
  24667. * Gets or sets a texture used to add random noise to particle positions
  24668. */
  24669. noiseTexture: Nullable<BaseTexture>;
  24670. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24671. noiseStrength: Vector3;
  24672. /**
  24673. * Callback triggered when the particle animation is ending.
  24674. */
  24675. onAnimationEnd: Nullable<() => void>;
  24676. /**
  24677. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24678. */
  24679. blendMode: number;
  24680. /**
  24681. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24682. * to override the particles.
  24683. */
  24684. forceDepthWrite: boolean;
  24685. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24686. preWarmCycles: number;
  24687. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24688. preWarmStepOffset: number;
  24689. /**
  24690. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24691. */
  24692. spriteCellChangeSpeed: number;
  24693. /**
  24694. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24695. */
  24696. startSpriteCellID: number;
  24697. /**
  24698. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24699. */
  24700. endSpriteCellID: number;
  24701. /**
  24702. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24703. */
  24704. spriteCellWidth: number;
  24705. /**
  24706. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24707. */
  24708. spriteCellHeight: number;
  24709. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24710. translationPivot: Vector2;
  24711. /** @hidden */
  24712. protected _isAnimationSheetEnabled: boolean;
  24713. /**
  24714. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24715. */
  24716. isAnimationSheetEnabled: boolean;
  24717. /**
  24718. * Get hosting scene
  24719. * @returns the scene
  24720. */
  24721. getScene(): Scene;
  24722. /**
  24723. * You can use gravity if you want to give an orientation to your particles.
  24724. */
  24725. gravity: Vector3;
  24726. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24727. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24728. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24729. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24730. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24731. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24732. protected _dragGradients: Nullable<Array<FactorGradient>>;
  24733. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  24734. /**
  24735. * Gets the current list of drag gradients.
  24736. * You must use addDragGradient and removeDragGradient to udpate this list
  24737. * @returns the list of drag gradients
  24738. */
  24739. getDragGradients(): Nullable<Array<FactorGradient>>;
  24740. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24741. limitVelocityDamping: number;
  24742. /**
  24743. * Gets the current list of limit velocity gradients.
  24744. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24745. * @returns the list of limit velocity gradients
  24746. */
  24747. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24748. /**
  24749. * Gets the current list of color gradients.
  24750. * You must use addColorGradient and removeColorGradient to udpate this list
  24751. * @returns the list of color gradients
  24752. */
  24753. getColorGradients(): Nullable<Array<ColorGradient>>;
  24754. /**
  24755. * Gets the current list of size gradients.
  24756. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24757. * @returns the list of size gradients
  24758. */
  24759. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24760. /**
  24761. * Gets the current list of life time gradients.
  24762. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24763. * @returns the list of life time gradients
  24764. */
  24765. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24766. /**
  24767. * Gets the current list of angular speed gradients.
  24768. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24769. * @returns the list of angular speed gradients
  24770. */
  24771. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24772. /**
  24773. * Gets the current list of velocity gradients.
  24774. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24775. * @returns the list of velocity gradients
  24776. */
  24777. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24778. /**
  24779. * Gets the current list of emit rate gradients.
  24780. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  24781. * @returns the list of emit rate gradients
  24782. */
  24783. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  24784. /**
  24785. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24786. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24787. */
  24788. direction1: Vector3;
  24789. /**
  24790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24791. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24792. */
  24793. direction2: Vector3;
  24794. /**
  24795. * 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.
  24796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24797. */
  24798. minEmitBox: Vector3;
  24799. /**
  24800. * 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.
  24801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24802. */
  24803. maxEmitBox: Vector3;
  24804. /**
  24805. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24806. */
  24807. color1: Color4;
  24808. /**
  24809. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24810. */
  24811. color2: Color4;
  24812. /**
  24813. * Color the particle will have at the end of its lifetime
  24814. */
  24815. colorDead: Color4;
  24816. /**
  24817. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24818. */
  24819. textureMask: Color4;
  24820. /**
  24821. * The particle emitter type defines the emitter used by the particle system.
  24822. * It can be for example box, sphere, or cone...
  24823. */
  24824. particleEmitterType: IParticleEmitterType;
  24825. /**
  24826. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24827. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24828. */
  24829. billboardMode: number;
  24830. protected _isBillboardBased: boolean;
  24831. /**
  24832. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24833. */
  24834. isBillboardBased: boolean;
  24835. /**
  24836. * The scene the particle system belongs to.
  24837. */
  24838. protected _scene: Scene;
  24839. /**
  24840. * Local cache of defines for image processing.
  24841. */
  24842. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  24843. /**
  24844. * Default configuration related to image processing available in the standard Material.
  24845. */
  24846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24847. /**
  24848. * Gets the image processing configuration used either in this material.
  24849. */
  24850. /**
  24851. * Sets the Default image processing configuration used either in the this material.
  24852. *
  24853. * If sets to null, the scene one is in use.
  24854. */
  24855. imageProcessingConfiguration: ImageProcessingConfiguration;
  24856. /**
  24857. * Attaches a new image processing configuration to the Standard Material.
  24858. * @param configuration
  24859. */
  24860. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24861. /** @hidden */
  24862. protected _reset(): void;
  24863. /**
  24864. * Instantiates a particle system.
  24865. * 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.
  24866. * @param name The name of the particle system
  24867. */
  24868. constructor(name: string);
  24869. /**
  24870. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  24871. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24872. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24873. * @returns the emitter
  24874. */
  24875. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  24876. /**
  24877. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  24878. * @param radius The radius of the hemisphere to emit from
  24879. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24880. * @returns the emitter
  24881. */
  24882. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  24883. /**
  24884. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  24885. * @param radius The radius of the sphere to emit from
  24886. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24887. * @returns the emitter
  24888. */
  24889. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  24890. /**
  24891. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  24892. * @param radius The radius of the sphere to emit from
  24893. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24894. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24895. * @returns the emitter
  24896. */
  24897. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24898. /**
  24899. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  24900. * @param radius The radius of the emission cylinder
  24901. * @param height The height of the emission cylinder
  24902. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  24903. * @param directionRandomizer How much to randomize the particle direction [0-1]
  24904. * @returns the emitter
  24905. */
  24906. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  24907. /**
  24908. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  24909. * @param radius The radius of the cone to emit from
  24910. * @param angle The base angle of the cone
  24911. * @returns the emitter
  24912. */
  24913. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24914. /**
  24915. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24916. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24917. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24918. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24919. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24920. * @returns the emitter
  24921. */
  24922. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24923. }
  24924. }
  24925. declare module BABYLON {
  24926. /**
  24927. * This represents a GPU particle system in Babylon
  24928. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24929. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24930. */
  24931. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24932. /**
  24933. * The layer mask we are rendering the particles through.
  24934. */
  24935. layerMask: number;
  24936. private _capacity;
  24937. private _activeCount;
  24938. private _currentActiveCount;
  24939. private _accumulatedCount;
  24940. private _renderEffect;
  24941. private _updateEffect;
  24942. private _buffer0;
  24943. private _buffer1;
  24944. private _spriteBuffer;
  24945. private _updateVAO;
  24946. private _renderVAO;
  24947. private _targetIndex;
  24948. private _sourceBuffer;
  24949. private _targetBuffer;
  24950. private _engine;
  24951. private _currentRenderId;
  24952. private _started;
  24953. private _stopped;
  24954. private _timeDelta;
  24955. private _randomTexture;
  24956. private _randomTexture2;
  24957. private _attributesStrideSize;
  24958. private _updateEffectOptions;
  24959. private _randomTextureSize;
  24960. private _actualFrame;
  24961. private readonly _rawTextureWidth;
  24962. /**
  24963. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24964. */
  24965. static readonly IsSupported: boolean;
  24966. /**
  24967. * An event triggered when the system is disposed.
  24968. */
  24969. onDisposeObservable: Observable<GPUParticleSystem>;
  24970. /**
  24971. * Gets the maximum number of particles active at the same time.
  24972. * @returns The max number of active particles.
  24973. */
  24974. getCapacity(): number;
  24975. /**
  24976. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24977. * to override the particles.
  24978. */
  24979. forceDepthWrite: boolean;
  24980. /**
  24981. * Gets or set the number of active particles
  24982. */
  24983. activeParticleCount: number;
  24984. private _preWarmDone;
  24985. /**
  24986. * Is this system ready to be used/rendered
  24987. * @return true if the system is ready
  24988. */
  24989. isReady(): boolean;
  24990. /**
  24991. * Gets if the system has been started. (Note: this will still be true after stop is called)
  24992. * @returns True if it has been started, otherwise false.
  24993. */
  24994. isStarted(): boolean;
  24995. /**
  24996. * Starts the particle system and begins to emit
  24997. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  24998. */
  24999. start(delay?: number): void;
  25000. /**
  25001. * Stops the particle system.
  25002. */
  25003. stop(): void;
  25004. /**
  25005. * Remove all active particles
  25006. */
  25007. reset(): void;
  25008. /**
  25009. * Returns the string "GPUParticleSystem"
  25010. * @returns a string containing the class name
  25011. */
  25012. getClassName(): string;
  25013. private _colorGradientsTexture;
  25014. private _removeGradient;
  25015. /**
  25016. * Adds a new color gradient
  25017. * @param gradient defines the gradient to use (between 0 and 1)
  25018. * @param color defines the color to affect to the specified gradient
  25019. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25020. * @returns the current particle system
  25021. */
  25022. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  25023. /**
  25024. * Remove a specific color gradient
  25025. * @param gradient defines the gradient to remove
  25026. * @returns the current particle system
  25027. */
  25028. removeColorGradient(gradient: number): GPUParticleSystem;
  25029. private _angularSpeedGradientsTexture;
  25030. private _sizeGradientsTexture;
  25031. private _velocityGradientsTexture;
  25032. private _limitVelocityGradientsTexture;
  25033. private _dragGradientsTexture;
  25034. private _addFactorGradient;
  25035. /**
  25036. * Adds a new size gradient
  25037. * @param gradient defines the gradient to use (between 0 and 1)
  25038. * @param factor defines the size factor to affect to the specified gradient
  25039. * @returns the current particle system
  25040. */
  25041. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  25042. /**
  25043. * Remove a specific size gradient
  25044. * @param gradient defines the gradient to remove
  25045. * @returns the current particle system
  25046. */
  25047. removeSizeGradient(gradient: number): GPUParticleSystem;
  25048. /**
  25049. * Adds a new angular speed gradient
  25050. * @param gradient defines the gradient to use (between 0 and 1)
  25051. * @param factor defines the angular speed to affect to the specified gradient
  25052. * @returns the current particle system
  25053. */
  25054. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25055. /**
  25056. * Remove a specific angular speed gradient
  25057. * @param gradient defines the gradient to remove
  25058. * @returns the current particle system
  25059. */
  25060. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25061. /**
  25062. * Adds a new velocity gradient
  25063. * @param gradient defines the gradient to use (between 0 and 1)
  25064. * @param factor defines the velocity to affect to the specified gradient
  25065. * @returns the current particle system
  25066. */
  25067. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25068. /**
  25069. * Remove a specific velocity gradient
  25070. * @param gradient defines the gradient to remove
  25071. * @returns the current particle system
  25072. */
  25073. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25074. /**
  25075. * Adds a new limit velocity gradient
  25076. * @param gradient defines the gradient to use (between 0 and 1)
  25077. * @param factor defines the limit velocity value to affect to the specified gradient
  25078. * @returns the current particle system
  25079. */
  25080. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25081. /**
  25082. * Remove a specific limit velocity gradient
  25083. * @param gradient defines the gradient to remove
  25084. * @returns the current particle system
  25085. */
  25086. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25087. /**
  25088. * Adds a new drag gradient
  25089. * @param gradient defines the gradient to use (between 0 and 1)
  25090. * @param factor defines the drag value to affect to the specified gradient
  25091. * @returns the current particle system
  25092. */
  25093. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  25094. /**
  25095. * Remove a specific drag gradient
  25096. * @param gradient defines the gradient to remove
  25097. * @returns the current particle system
  25098. */
  25099. removeDragGradient(gradient: number): GPUParticleSystem;
  25100. /**
  25101. * Not supported by GPUParticleSystem
  25102. * @param gradient defines the gradient to use (between 0 and 1)
  25103. * @param factor defines the emit rate value to affect to the specified gradient
  25104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25105. * @returns the current particle system
  25106. */
  25107. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25108. /**
  25109. * Not supported by GPUParticleSystem
  25110. * @param gradient defines the gradient to remove
  25111. * @returns the current particle system
  25112. */
  25113. removeEmitRateGradient(gradient: number): IParticleSystem;
  25114. /**
  25115. * Instantiates a GPU particle system.
  25116. * 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.
  25117. * @param name The name of the particle system
  25118. * @param options The options used to create the system
  25119. * @param scene The scene the particle system belongs to
  25120. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25121. */
  25122. constructor(name: string, options: Partial<{
  25123. capacity: number;
  25124. randomTextureSize: number;
  25125. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25126. protected _reset(): void;
  25127. private _createUpdateVAO;
  25128. private _createRenderVAO;
  25129. private _initialize;
  25130. /** @hidden */
  25131. _recreateUpdateEffect(): void;
  25132. /** @hidden */
  25133. _recreateRenderEffect(): void;
  25134. /**
  25135. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25136. * @param preWarm defines if we are in the pre-warmimg phase
  25137. */
  25138. animate(preWarm?: boolean): void;
  25139. private _createFactorGradientTexture;
  25140. private _createSizeGradientTexture;
  25141. private _createAngularSpeedGradientTexture;
  25142. private _createVelocityGradientTexture;
  25143. private _createColorGradientTexture;
  25144. /**
  25145. * Renders the particle system in its current state
  25146. * @param preWarm defines if the system should only update the particles but not render them
  25147. * @returns the current number of particles
  25148. */
  25149. render(preWarm?: boolean): number;
  25150. /**
  25151. * Rebuilds the particle system
  25152. */
  25153. rebuild(): void;
  25154. private _releaseBuffers;
  25155. private _releaseVAOs;
  25156. /**
  25157. * Disposes the particle system and free the associated resources
  25158. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25159. */
  25160. dispose(disposeTexture?: boolean): void;
  25161. /**
  25162. * Clones the particle system.
  25163. * @param name The name of the cloned object
  25164. * @param newEmitter The new emitter to use
  25165. * @returns the cloned particle system
  25166. */
  25167. clone(name: string, newEmitter: any): GPUParticleSystem;
  25168. /**
  25169. * Serializes the particle system to a JSON object.
  25170. * @returns the JSON object
  25171. */
  25172. serialize(): any;
  25173. /**
  25174. * Parses a JSON object to create a GPU particle system.
  25175. * @param parsedParticleSystem The JSON object to parse
  25176. * @param scene The scene to create the particle system in
  25177. * @param rootUrl The root url to use to load external dependencies like texture
  25178. * @returns the parsed GPU particle system
  25179. */
  25180. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25181. }
  25182. }
  25183. declare module BABYLON {
  25184. /**
  25185. * Interface representing a particle system in Babylon.js.
  25186. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25187. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25188. */
  25189. interface IParticleSystem {
  25190. /**
  25191. * List of animations used by the particle system.
  25192. */
  25193. animations: Animation[];
  25194. /**
  25195. * The id of the Particle system.
  25196. */
  25197. id: string;
  25198. /**
  25199. * The name of the Particle system.
  25200. */
  25201. name: string;
  25202. /**
  25203. * The emitter represents the Mesh or position we are attaching the particle system to.
  25204. */
  25205. emitter: Nullable<AbstractMesh | Vector3>;
  25206. /**
  25207. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25208. */
  25209. isBillboardBased: boolean;
  25210. /**
  25211. * The rendering group used by the Particle system to chose when to render.
  25212. */
  25213. renderingGroupId: number;
  25214. /**
  25215. * The layer mask we are rendering the particles through.
  25216. */
  25217. layerMask: number;
  25218. /**
  25219. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25220. */
  25221. updateSpeed: number;
  25222. /**
  25223. * The amount of time the particle system is running (depends of the overall update speed).
  25224. */
  25225. targetStopDuration: number;
  25226. /**
  25227. * The texture used to render each particle. (this can be a spritesheet)
  25228. */
  25229. particleTexture: Nullable<Texture>;
  25230. /**
  25231. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25232. */
  25233. blendMode: number;
  25234. /**
  25235. * Minimum life time of emitting particles.
  25236. */
  25237. minLifeTime: number;
  25238. /**
  25239. * Maximum life time of emitting particles.
  25240. */
  25241. maxLifeTime: number;
  25242. /**
  25243. * Minimum Size of emitting particles.
  25244. */
  25245. minSize: number;
  25246. /**
  25247. * Maximum Size of emitting particles.
  25248. */
  25249. maxSize: number;
  25250. /**
  25251. * Minimum scale of emitting particles on X axis.
  25252. */
  25253. minScaleX: number;
  25254. /**
  25255. * Maximum scale of emitting particles on X axis.
  25256. */
  25257. maxScaleX: number;
  25258. /**
  25259. * Minimum scale of emitting particles on Y axis.
  25260. */
  25261. minScaleY: number;
  25262. /**
  25263. * Maximum scale of emitting particles on Y axis.
  25264. */
  25265. maxScaleY: number;
  25266. /**
  25267. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25268. */
  25269. color1: Color4;
  25270. /**
  25271. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25272. */
  25273. color2: Color4;
  25274. /**
  25275. * Color the particle will have at the end of its lifetime.
  25276. */
  25277. colorDead: Color4;
  25278. /**
  25279. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25280. */
  25281. emitRate: number;
  25282. /**
  25283. * You can use gravity if you want to give an orientation to your particles.
  25284. */
  25285. gravity: Vector3;
  25286. /**
  25287. * Minimum power of emitting particles.
  25288. */
  25289. minEmitPower: number;
  25290. /**
  25291. * Maximum power of emitting particles.
  25292. */
  25293. maxEmitPower: number;
  25294. /**
  25295. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25296. */
  25297. minAngularSpeed: number;
  25298. /**
  25299. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25300. */
  25301. maxAngularSpeed: number;
  25302. /**
  25303. * Gets or sets the minimal initial rotation in radians.
  25304. */
  25305. minInitialRotation: number;
  25306. /**
  25307. * Gets or sets the maximal initial rotation in radians.
  25308. */
  25309. maxInitialRotation: number;
  25310. /**
  25311. * The particle emitter type defines the emitter used by the particle system.
  25312. * It can be for example box, sphere, or cone...
  25313. */
  25314. particleEmitterType: Nullable<IParticleEmitterType>;
  25315. /**
  25316. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  25317. */
  25318. preWarmCycles: number;
  25319. /**
  25320. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25321. */
  25322. preWarmStepOffset: number;
  25323. /**
  25324. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  25325. */
  25326. spriteCellChangeSpeed: number;
  25327. /**
  25328. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25329. */
  25330. startSpriteCellID: number;
  25331. /**
  25332. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25333. */
  25334. endSpriteCellID: number;
  25335. /**
  25336. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25337. */
  25338. spriteCellWidth: number;
  25339. /**
  25340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25341. */
  25342. spriteCellHeight: number;
  25343. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25344. translationPivot: Vector2;
  25345. /**
  25346. * Gets or sets a texture used to add random noise to particle positions
  25347. */
  25348. noiseTexture: Nullable<BaseTexture>;
  25349. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25350. noiseStrength: Vector3;
  25351. /**
  25352. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25353. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25354. */
  25355. billboardMode: number;
  25356. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25357. limitVelocityDamping: number;
  25358. /**
  25359. * Gets the maximum number of particles active at the same time.
  25360. * @returns The max number of active particles.
  25361. */
  25362. getCapacity(): number;
  25363. /**
  25364. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25365. * @returns True if it has been started, otherwise false.
  25366. */
  25367. isStarted(): boolean;
  25368. /**
  25369. * Animates the particle system for this frame.
  25370. */
  25371. animate(): void;
  25372. /**
  25373. * Renders the particle system in its current state.
  25374. * @returns the current number of particles
  25375. */
  25376. render(): number;
  25377. /**
  25378. * Dispose the particle system and frees its associated resources.
  25379. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25380. */
  25381. dispose(disposeTexture?: boolean): void;
  25382. /**
  25383. * Clones the particle system.
  25384. * @param name The name of the cloned object
  25385. * @param newEmitter The new emitter to use
  25386. * @returns the cloned particle system
  25387. */
  25388. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25389. /**
  25390. * Serializes the particle system to a JSON object.
  25391. * @returns the JSON object
  25392. */
  25393. serialize(): any;
  25394. /**
  25395. * Rebuild the particle system
  25396. */
  25397. rebuild(): void;
  25398. /**
  25399. * Starts the particle system and begins to emit
  25400. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25401. */
  25402. start(delay?: number): void;
  25403. /**
  25404. * Stops the particle system.
  25405. */
  25406. stop(): void;
  25407. /**
  25408. * Remove all active particles
  25409. */
  25410. reset(): void;
  25411. /**
  25412. * Is this system ready to be used/rendered
  25413. * @return true if the system is ready
  25414. */
  25415. isReady(): boolean;
  25416. /**
  25417. * Adds a new color gradient
  25418. * @param gradient defines the gradient to use (between 0 and 1)
  25419. * @param color defines the color to affect to the specified gradient
  25420. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25421. * @returns the current particle system
  25422. */
  25423. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25424. /**
  25425. * Remove a specific color gradient
  25426. * @param gradient defines the gradient to remove
  25427. * @returns the current particle system
  25428. */
  25429. removeColorGradient(gradient: number): IParticleSystem;
  25430. /**
  25431. * Adds a new size gradient
  25432. * @param gradient defines the gradient to use (between 0 and 1)
  25433. * @param factor defines the size factor to affect to the specified gradient
  25434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25435. * @returns the current particle system
  25436. */
  25437. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25438. /**
  25439. * Remove a specific size gradient
  25440. * @param gradient defines the gradient to remove
  25441. * @returns the current particle system
  25442. */
  25443. removeSizeGradient(gradient: number): IParticleSystem;
  25444. /**
  25445. * Gets the current list of color gradients.
  25446. * You must use addColorGradient and removeColorGradient to udpate this list
  25447. * @returns the list of color gradients
  25448. */
  25449. getColorGradients(): Nullable<Array<ColorGradient>>;
  25450. /**
  25451. * Gets the current list of size gradients.
  25452. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25453. * @returns the list of size gradients
  25454. */
  25455. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25456. /**
  25457. * Gets the current list of angular speed gradients.
  25458. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25459. * @returns the list of angular speed gradients
  25460. */
  25461. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25462. /**
  25463. * Adds a new angular speed gradient
  25464. * @param gradient defines the gradient to use (between 0 and 1)
  25465. * @param factor defines the angular speed to affect to the specified gradient
  25466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25467. * @returns the current particle system
  25468. */
  25469. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25470. /**
  25471. * Remove a specific angular speed gradient
  25472. * @param gradient defines the gradient to remove
  25473. * @returns the current particle system
  25474. */
  25475. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25476. /**
  25477. * Gets the current list of velocity gradients.
  25478. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25479. * @returns the list of velocity gradients
  25480. */
  25481. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25482. /**
  25483. * Adds a new velocity gradient
  25484. * @param gradient defines the gradient to use (between 0 and 1)
  25485. * @param factor defines the velocity to affect to the specified gradient
  25486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25487. * @returns the current particle system
  25488. */
  25489. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25490. /**
  25491. * Remove a specific velocity gradient
  25492. * @param gradient defines the gradient to remove
  25493. * @returns the current particle system
  25494. */
  25495. removeVelocityGradient(gradient: number): IParticleSystem;
  25496. /**
  25497. * Gets the current list of limit velocity gradients.
  25498. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25499. * @returns the list of limit velocity gradients
  25500. */
  25501. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25502. /**
  25503. * Adds a new limit velocity gradient
  25504. * @param gradient defines the gradient to use (between 0 and 1)
  25505. * @param factor defines the limit velocity to affect to the specified gradient
  25506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25507. * @returns the current particle system
  25508. */
  25509. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25510. /**
  25511. * Remove a specific limit velocity gradient
  25512. * @param gradient defines the gradient to remove
  25513. * @returns the current particle system
  25514. */
  25515. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25516. /**
  25517. * Adds a new drag gradient
  25518. * @param gradient defines the gradient to use (between 0 and 1)
  25519. * @param factor defines the drag to affect to the specified gradient
  25520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25521. * @returns the current particle system
  25522. */
  25523. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25524. /**
  25525. * Remove a specific drag gradient
  25526. * @param gradient defines the gradient to remove
  25527. * @returns the current particle system
  25528. */
  25529. removeDragGradient(gradient: number): IParticleSystem;
  25530. /**
  25531. * Gets the current list of drag gradients.
  25532. * You must use addDragGradient and removeDragGradient to udpate this list
  25533. * @returns the list of drag gradients
  25534. */
  25535. getDragGradients(): Nullable<Array<FactorGradient>>;
  25536. /**
  25537. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  25538. * @param gradient defines the gradient to use (between 0 and 1)
  25539. * @param factor defines the emit rate to affect to the specified gradient
  25540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25541. * @returns the current particle system
  25542. */
  25543. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25544. /**
  25545. * Remove a specific emit rate gradient
  25546. * @param gradient defines the gradient to remove
  25547. * @returns the current particle system
  25548. */
  25549. removeEmitRateGradient(gradient: number): IParticleSystem;
  25550. /**
  25551. * Gets the current list of emit rate gradients.
  25552. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  25553. * @returns the list of emit rate gradients
  25554. */
  25555. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  25556. /**
  25557. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25560. * @returns the emitter
  25561. */
  25562. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25563. /**
  25564. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25565. * @param radius The radius of the hemisphere to emit from
  25566. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25567. * @returns the emitter
  25568. */
  25569. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  25570. /**
  25571. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25572. * @param radius The radius of the sphere to emit from
  25573. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25574. * @returns the emitter
  25575. */
  25576. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  25577. /**
  25578. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25579. * @param radius The radius of the sphere to emit from
  25580. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25581. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25582. * @returns the emitter
  25583. */
  25584. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25585. /**
  25586. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  25587. * @param radius The radius of the emission cylinder
  25588. * @param height The height of the emission cylinder
  25589. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  25590. * @param directionRandomizer How much to randomize the particle direction [0-1]
  25591. * @returns the emitter
  25592. */
  25593. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  25594. /**
  25595. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25596. * @param radius The radius of the cone to emit from
  25597. * @param angle The base angle of the cone
  25598. * @returns the emitter
  25599. */
  25600. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  25601. /**
  25602. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25605. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25606. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25607. * @returns the emitter
  25608. */
  25609. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25610. /**
  25611. * Get hosting scene
  25612. * @returns the scene
  25613. */
  25614. getScene(): Scene;
  25615. }
  25616. }
  25617. declare module BABYLON {
  25618. /**
  25619. * A particle represents one of the element emitted by a particle system.
  25620. * This is mainly define by its coordinates, direction, velocity and age.
  25621. */
  25622. class Particle {
  25623. /**
  25624. * particleSystem the particle system the particle belongs to.
  25625. */
  25626. particleSystem: ParticleSystem;
  25627. /**
  25628. * The world position of the particle in the scene.
  25629. */
  25630. position: Vector3;
  25631. /**
  25632. * The world direction of the particle in the scene.
  25633. */
  25634. direction: Vector3;
  25635. /**
  25636. * The color of the particle.
  25637. */
  25638. color: Color4;
  25639. /**
  25640. * The color change of the particle per step.
  25641. */
  25642. colorStep: Color4;
  25643. /**
  25644. * Defines how long will the life of the particle be.
  25645. */
  25646. lifeTime: number;
  25647. /**
  25648. * The current age of the particle.
  25649. */
  25650. age: number;
  25651. /**
  25652. * The current size of the particle.
  25653. */
  25654. size: number;
  25655. /**
  25656. * The current scale of the particle.
  25657. */
  25658. scale: Vector2;
  25659. /**
  25660. * The current angle of the particle.
  25661. */
  25662. angle: number;
  25663. /**
  25664. * Defines how fast is the angle changing.
  25665. */
  25666. angularSpeed: number;
  25667. /**
  25668. * Defines the cell index used by the particle to be rendered from a sprite.
  25669. */
  25670. cellIndex: number;
  25671. /** @hidden */
  25672. _initialDirection: Nullable<Vector3>;
  25673. /** @hidden */
  25674. _initialStartSpriteCellID: number;
  25675. _initialEndSpriteCellID: number;
  25676. /** @hidden */
  25677. _currentColorGradient: Nullable<ColorGradient>;
  25678. /** @hidden */
  25679. _currentColor1: Color4;
  25680. /** @hidden */
  25681. _currentColor2: Color4;
  25682. /** @hidden */
  25683. _currentSizeGradient: Nullable<FactorGradient>;
  25684. /** @hidden */
  25685. _currentSize1: number;
  25686. /** @hidden */
  25687. _currentSize2: number;
  25688. /** @hidden */
  25689. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25690. /** @hidden */
  25691. _currentAngularSpeed1: number;
  25692. /** @hidden */
  25693. _currentAngularSpeed2: number;
  25694. /** @hidden */
  25695. _currentVelocityGradient: Nullable<FactorGradient>;
  25696. /** @hidden */
  25697. _currentVelocity1: number;
  25698. /** @hidden */
  25699. _currentVelocity2: number;
  25700. /** @hidden */
  25701. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  25702. /** @hidden */
  25703. _currentLimitVelocity1: number;
  25704. /** @hidden */
  25705. _currentLimitVelocity2: number;
  25706. /** @hidden */
  25707. _currentDragGradient: Nullable<FactorGradient>;
  25708. /** @hidden */
  25709. _currentDrag1: number;
  25710. /** @hidden */
  25711. _currentDrag2: number;
  25712. /**
  25713. * Creates a new instance Particle
  25714. * @param particleSystem the particle system the particle belongs to
  25715. */
  25716. constructor(
  25717. /**
  25718. * particleSystem the particle system the particle belongs to.
  25719. */
  25720. particleSystem: ParticleSystem);
  25721. private updateCellInfoFromSystem;
  25722. /**
  25723. * Defines how the sprite cell index is updated for the particle
  25724. */
  25725. updateCellIndex(): void;
  25726. /**
  25727. * Copy the properties of particle to another one.
  25728. * @param other the particle to copy the information to.
  25729. */
  25730. copyTo(other: Particle): void;
  25731. }
  25732. }
  25733. declare module BABYLON {
  25734. /**
  25735. * This class is made for on one-liner static method to help creating particle system set.
  25736. */
  25737. class ParticleHelper {
  25738. /**
  25739. * Gets or sets base Assets URL
  25740. */
  25741. static BaseAssetsUrl: string;
  25742. /**
  25743. * Create a default particle system that you can tweak
  25744. * @param emitter defines the emitter to use
  25745. * @param capacity defines the system capacity (default is 500 particles)
  25746. * @param scene defines the hosting scene
  25747. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  25748. * @returns the new Particle system
  25749. */
  25750. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  25751. /**
  25752. * This is the main static method (one-liner) of this helper to create different particle systems
  25753. * @param type This string represents the type to the particle system to create
  25754. * @param scene The scene where the particle system should live
  25755. * @param gpu If the system will use gpu
  25756. * @returns the ParticleSystemSet created
  25757. */
  25758. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25759. /**
  25760. * Static function used to export a particle system to a ParticleSystemSet variable.
  25761. * Please note that the emitter shape is not exported
  25762. * @param system defines the particle systems to export
  25763. */
  25764. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25765. }
  25766. }
  25767. declare module BABYLON {
  25768. /**
  25769. * This represents a particle system in Babylon.
  25770. * 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.
  25771. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25772. * @example https://doc.babylonjs.com/babylon101/particles
  25773. */
  25774. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25775. /**
  25776. * This function can be defined to provide custom update for active particles.
  25777. * This function will be called instead of regular update (age, position, color, etc.).
  25778. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25779. */
  25780. updateFunction: (particles: Particle[]) => void;
  25781. private _emitterWorldMatrix;
  25782. /**
  25783. * This function can be defined to specify initial direction for every new particle.
  25784. * It by default use the emitterType defined function
  25785. */
  25786. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25787. /**
  25788. * This function can be defined to specify initial position for every new particle.
  25789. * It by default use the emitterType defined function
  25790. */
  25791. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25792. /**
  25793. * An event triggered when the system is disposed
  25794. */
  25795. onDisposeObservable: Observable<ParticleSystem>;
  25796. private _onDisposeObserver;
  25797. /**
  25798. * Sets a callback that will be triggered when the system is disposed
  25799. */
  25800. onDispose: () => void;
  25801. private _particles;
  25802. private _epsilon;
  25803. private _capacity;
  25804. private _stockParticles;
  25805. private _newPartsExcess;
  25806. private _vertexData;
  25807. private _vertexBuffer;
  25808. private _vertexBuffers;
  25809. private _spriteBuffer;
  25810. private _indexBuffer;
  25811. private _effect;
  25812. private _customEffect;
  25813. private _cachedDefines;
  25814. private _scaledColorStep;
  25815. private _colorDiff;
  25816. private _scaledDirection;
  25817. private _scaledGravity;
  25818. private _currentRenderId;
  25819. private _alive;
  25820. private _useInstancing;
  25821. private _started;
  25822. private _stopped;
  25823. private _actualFrame;
  25824. private _scaledUpdateSpeed;
  25825. private _vertexBufferSize;
  25826. /** @hidden */
  25827. _currentEmitRateGradient: Nullable<FactorGradient>;
  25828. /** @hidden */
  25829. _currentEmitRate1: number;
  25830. /** @hidden */
  25831. _currentEmitRate2: number;
  25832. /**
  25833. * 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.
  25834. */
  25835. subEmitters: ParticleSystem[];
  25836. /**
  25837. * The current active Sub-systems, this property is used by the root particle system only.
  25838. */
  25839. activeSubSystems: Array<ParticleSystem>;
  25840. private _rootParticleSystem;
  25841. /**
  25842. * Gets the current list of active particles
  25843. */
  25844. readonly particles: Particle[];
  25845. /**
  25846. * Returns the string "ParticleSystem"
  25847. * @returns a string containing the class name
  25848. */
  25849. getClassName(): string;
  25850. /**
  25851. * Instantiates a particle system.
  25852. * 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.
  25853. * @param name The name of the particle system
  25854. * @param capacity The max number of particles alive at the same time
  25855. * @param scene The scene the particle system belongs to
  25856. * @param customEffect a custom effect used to change the way particles are rendered by default
  25857. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25858. * @param epsilon Offset used to render the particles
  25859. */
  25860. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25861. private _addFactorGradient;
  25862. private _removeFactorGradient;
  25863. /**
  25864. * Adds a new life time gradient
  25865. * @param gradient defines the gradient to use (between 0 and 1)
  25866. * @param factor defines the life time factor to affect to the specified gradient
  25867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25868. * @returns the current particle system
  25869. */
  25870. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25871. /**
  25872. * Remove a specific life time gradient
  25873. * @param gradient defines the gradient to remove
  25874. * @returns the current particle system
  25875. */
  25876. removeLifeTimeGradient(gradient: number): IParticleSystem;
  25877. /**
  25878. * Adds a new size gradient
  25879. * @param gradient defines the gradient to use (between 0 and 1)
  25880. * @param factor defines the size factor to affect to the specified gradient
  25881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25882. * @returns the current particle system
  25883. */
  25884. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25885. /**
  25886. * Remove a specific size gradient
  25887. * @param gradient defines the gradient to remove
  25888. * @returns the current particle system
  25889. */
  25890. removeSizeGradient(gradient: number): IParticleSystem;
  25891. /**
  25892. * Adds a new angular speed gradient
  25893. * @param gradient defines the gradient to use (between 0 and 1)
  25894. * @param factor defines the angular speed to affect to the specified gradient
  25895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25896. * @returns the current particle system
  25897. */
  25898. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25899. /**
  25900. * Remove a specific angular speed gradient
  25901. * @param gradient defines the gradient to remove
  25902. * @returns the current particle system
  25903. */
  25904. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25905. /**
  25906. * Adds a new velocity gradient
  25907. * @param gradient defines the gradient to use (between 0 and 1)
  25908. * @param factor defines the velocity to affect to the specified gradient
  25909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25910. * @returns the current particle system
  25911. */
  25912. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25913. /**
  25914. * Remove a specific velocity gradient
  25915. * @param gradient defines the gradient to remove
  25916. * @returns the current particle system
  25917. */
  25918. removeVelocityGradient(gradient: number): IParticleSystem;
  25919. /**
  25920. * Adds a new limit velocity gradient
  25921. * @param gradient defines the gradient to use (between 0 and 1)
  25922. * @param factor defines the limit velocity value to affect to the specified gradient
  25923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25924. * @returns the current particle system
  25925. */
  25926. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25927. /**
  25928. * Remove a specific limit velocity gradient
  25929. * @param gradient defines the gradient to remove
  25930. * @returns the current particle system
  25931. */
  25932. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25933. /**
  25934. * Adds a new drag gradient
  25935. * @param gradient defines the gradient to use (between 0 and 1)
  25936. * @param factor defines the drag value to affect to the specified gradient
  25937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25938. * @returns the current particle system
  25939. */
  25940. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25941. /**
  25942. * Remove a specific drag gradient
  25943. * @param gradient defines the gradient to remove
  25944. * @returns the current particle system
  25945. */
  25946. removeDragGradient(gradient: number): IParticleSystem;
  25947. /**
  25948. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  25949. * @param gradient defines the gradient to use (between 0 and 1)
  25950. * @param factor defines the emit rate value to affect to the specified gradient
  25951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25952. * @returns the current particle system
  25953. */
  25954. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25955. /**
  25956. * Remove a specific emit rate gradient
  25957. * @param gradient defines the gradient to remove
  25958. * @returns the current particle system
  25959. */
  25960. removeEmitRateGradient(gradient: number): IParticleSystem;
  25961. /**
  25962. * Adds a new color gradient
  25963. * @param gradient defines the gradient to use (between 0 and 1)
  25964. * @param color defines the color to affect to the specified gradient
  25965. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25966. */
  25967. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  25968. /**
  25969. * Remove a specific color gradient
  25970. * @param gradient defines the gradient to remove
  25971. */
  25972. removeColorGradient(gradient: number): IParticleSystem;
  25973. private _fetchR;
  25974. protected _reset(): void;
  25975. private _resetEffect;
  25976. private _createVertexBuffers;
  25977. private _createIndexBuffer;
  25978. /**
  25979. * Gets the maximum number of particles active at the same time.
  25980. * @returns The max number of active particles.
  25981. */
  25982. getCapacity(): number;
  25983. /**
  25984. * Gets whether there are still active particles in the system.
  25985. * @returns True if it is alive, otherwise false.
  25986. */
  25987. isAlive(): boolean;
  25988. /**
  25989. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25990. * @returns True if it has been started, otherwise false.
  25991. */
  25992. isStarted(): boolean;
  25993. /**
  25994. * Starts the particle system and begins to emit
  25995. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25996. */
  25997. start(delay?: number): void;
  25998. /**
  25999. * Stops the particle system.
  26000. * @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.
  26001. */
  26002. stop(stopSubEmitters?: boolean): void;
  26003. /**
  26004. * Remove all active particles
  26005. */
  26006. reset(): void;
  26007. /**
  26008. * @hidden (for internal use only)
  26009. */
  26010. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  26011. /**
  26012. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  26013. * Its lifetime will start back at 0.
  26014. */
  26015. recycleParticle: (particle: Particle) => void;
  26016. private _stopSubEmitters;
  26017. private _createParticle;
  26018. private _removeFromRoot;
  26019. private _emitFromParticle;
  26020. private _update;
  26021. /** @hidden */
  26022. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  26023. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  26024. private _getEffect;
  26025. /**
  26026. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  26027. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  26028. */
  26029. animate(preWarmOnly?: boolean): void;
  26030. private _appendParticleVertices;
  26031. /**
  26032. * Rebuilds the particle system.
  26033. */
  26034. rebuild(): void;
  26035. /**
  26036. * Is this system ready to be used/rendered
  26037. * @return true if the system is ready
  26038. */
  26039. isReady(): boolean;
  26040. /**
  26041. * Renders the particle system in its current state.
  26042. * @returns the current number of particles
  26043. */
  26044. render(): number;
  26045. /**
  26046. * Disposes the particle system and free the associated resources
  26047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  26048. */
  26049. dispose(disposeTexture?: boolean): void;
  26050. /**
  26051. * Clones the particle system.
  26052. * @param name The name of the cloned object
  26053. * @param newEmitter The new emitter to use
  26054. * @returns the cloned particle system
  26055. */
  26056. clone(name: string, newEmitter: any): ParticleSystem;
  26057. /**
  26058. * Serializes the particle system to a JSON object.
  26059. * @returns the JSON object
  26060. */
  26061. serialize(): any;
  26062. /** @hidden */
  26063. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  26064. /** @hidden */
  26065. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  26066. /**
  26067. * Parses a JSON object to create a particle system.
  26068. * @param parsedParticleSystem The JSON object to parse
  26069. * @param scene The scene to create the particle system in
  26070. * @param rootUrl The root url to use to load external dependencies like texture
  26071. * @returns the Parsed particle system
  26072. */
  26073. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  26074. }
  26075. }
  26076. declare module BABYLON {
  26077. interface Engine {
  26078. /**
  26079. * Create an effect to use with particle systems.
  26080. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  26081. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  26082. * @param uniformsNames defines a list of attribute names
  26083. * @param samplers defines an array of string used to represent textures
  26084. * @param defines defines the string containing the defines to use to compile the shaders
  26085. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26086. * @param onCompiled defines a function to call when the effect creation is successful
  26087. * @param onError defines a function to call when the effect creation has failed
  26088. * @returns the new Effect
  26089. */
  26090. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  26091. }
  26092. }
  26093. declare module BABYLON {
  26094. /**
  26095. * Represents a set of particle systems working together to create a specific effect
  26096. */
  26097. class ParticleSystemSet implements IDisposable {
  26098. private _emitterCreationOptions;
  26099. private _emitterNode;
  26100. /**
  26101. * Gets the particle system list
  26102. */
  26103. systems: IParticleSystem[];
  26104. /**
  26105. * Gets the emitter node used with this set
  26106. */
  26107. readonly emitterNode: Nullable<TransformNode>;
  26108. /**
  26109. * Creates a new emitter mesh as a sphere
  26110. * @param options defines the options used to create the sphere
  26111. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  26112. * @param scene defines the hosting scene
  26113. */
  26114. setEmitterAsSphere(options: {
  26115. diameter: number;
  26116. segments: number;
  26117. color: Color3;
  26118. }, renderingGroupId: number, scene: Scene): void;
  26119. /**
  26120. * Starts all particle systems of the set
  26121. * @param emitter defines an optional mesh to use as emitter for the particle systems
  26122. */
  26123. start(emitter?: AbstractMesh): void;
  26124. /**
  26125. * Release all associated resources
  26126. */
  26127. dispose(): void;
  26128. /**
  26129. * Serialize the set into a JSON compatible object
  26130. * @returns a JSON compatible representation of the set
  26131. */
  26132. serialize(): any;
  26133. /**
  26134. * Parse a new ParticleSystemSet from a serialized source
  26135. * @param data defines a JSON compatible representation of the set
  26136. * @param scene defines the hosting scene
  26137. * @param gpu defines if we want GPU particles or CPU particles
  26138. * @returns a new ParticleSystemSet
  26139. */
  26140. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  26141. }
  26142. }
  26143. declare module BABYLON {
  26144. /**
  26145. * Represents one particle of a solid particle system.
  26146. */
  26147. class SolidParticle {
  26148. /**
  26149. * particle global index
  26150. */
  26151. idx: number;
  26152. /**
  26153. * The color of the particle
  26154. */
  26155. color: Nullable<Color4>;
  26156. /**
  26157. * The world space position of the particle.
  26158. */
  26159. position: Vector3;
  26160. /**
  26161. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26162. */
  26163. rotation: Vector3;
  26164. /**
  26165. * The world space rotation quaternion of the particle.
  26166. */
  26167. rotationQuaternion: Nullable<Quaternion>;
  26168. /**
  26169. * The scaling of the particle.
  26170. */
  26171. scaling: Vector3;
  26172. /**
  26173. * The uvs of the particle.
  26174. */
  26175. uvs: Vector4;
  26176. /**
  26177. * The current speed of the particle.
  26178. */
  26179. velocity: Vector3;
  26180. /**
  26181. * The pivot point in the particle local space.
  26182. */
  26183. pivot: Vector3;
  26184. /**
  26185. * Must the particle be translated from its pivot point in its local space ?
  26186. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26187. * Default : false
  26188. */
  26189. translateFromPivot: boolean;
  26190. /**
  26191. * Is the particle active or not ?
  26192. */
  26193. alive: boolean;
  26194. /**
  26195. * Is the particle visible or not ?
  26196. */
  26197. isVisible: boolean;
  26198. /**
  26199. * Index of this particle in the global "positions" array (Internal use)
  26200. * @hidden
  26201. */
  26202. _pos: number;
  26203. /**
  26204. * @hidden Index of this particle in the global "indices" array (Internal use)
  26205. */
  26206. _ind: number;
  26207. /**
  26208. * @hidden ModelShape of this particle (Internal use)
  26209. */
  26210. _model: ModelShape;
  26211. /**
  26212. * ModelShape id of this particle
  26213. */
  26214. shapeId: number;
  26215. /**
  26216. * Index of the particle in its shape id (Internal use)
  26217. */
  26218. idxInShape: number;
  26219. /**
  26220. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26221. */
  26222. _modelBoundingInfo: BoundingInfo;
  26223. /**
  26224. * @hidden Particle BoundingInfo object (Internal use)
  26225. */
  26226. _boundingInfo: BoundingInfo;
  26227. /**
  26228. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26229. */
  26230. _sps: SolidParticleSystem;
  26231. /**
  26232. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26233. */
  26234. _stillInvisible: boolean;
  26235. /**
  26236. * @hidden Last computed particle rotation matrix
  26237. */
  26238. _rotationMatrix: number[];
  26239. /**
  26240. * Parent particle Id, if any.
  26241. * Default null.
  26242. */
  26243. parentId: Nullable<number>;
  26244. /**
  26245. * @hidden Internal global position in the SPS.
  26246. */
  26247. _globalPosition: Vector3;
  26248. /**
  26249. * Creates a Solid Particle object.
  26250. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26251. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26252. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26253. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26254. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26255. * @param shapeId (integer) is the model shape identifier in the SPS.
  26256. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26257. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26258. */
  26259. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26260. /**
  26261. * Legacy support, changed scale to scaling
  26262. */
  26263. /**
  26264. * Legacy support, changed scale to scaling
  26265. */
  26266. scale: Vector3;
  26267. /**
  26268. * Legacy support, changed quaternion to rotationQuaternion
  26269. */
  26270. /**
  26271. * Legacy support, changed quaternion to rotationQuaternion
  26272. */
  26273. quaternion: Nullable<Quaternion>;
  26274. /**
  26275. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26276. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26277. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26278. * @returns true if it intersects
  26279. */
  26280. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26281. }
  26282. /**
  26283. * Represents the shape of the model used by one particle of a solid particle system.
  26284. * SPS internal tool, don't use it manually.
  26285. */
  26286. class ModelShape {
  26287. /**
  26288. * The shape id
  26289. * @hidden
  26290. */
  26291. shapeID: number;
  26292. /**
  26293. * flat array of model positions (internal use)
  26294. * @hidden
  26295. */
  26296. _shape: Vector3[];
  26297. /**
  26298. * flat array of model UVs (internal use)
  26299. * @hidden
  26300. */
  26301. _shapeUV: number[];
  26302. /**
  26303. * length of the shape in the model indices array (internal use)
  26304. * @hidden
  26305. */
  26306. _indicesLength: number;
  26307. /**
  26308. * Custom position function (internal use)
  26309. * @hidden
  26310. */
  26311. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26312. /**
  26313. * Custom vertex function (internal use)
  26314. * @hidden
  26315. */
  26316. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26317. /**
  26318. * 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.
  26319. * SPS internal tool, don't use it manually.
  26320. * @hidden
  26321. */
  26322. 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>);
  26323. }
  26324. /**
  26325. * Represents a Depth Sorted Particle in the solid particle system.
  26326. */
  26327. class DepthSortedParticle {
  26328. /**
  26329. * Index of the particle in the "indices" array
  26330. */
  26331. ind: number;
  26332. /**
  26333. * Length of the particle shape in the "indices" array
  26334. */
  26335. indicesLength: number;
  26336. /**
  26337. * Squared distance from the particle to the camera
  26338. */
  26339. sqDistance: number;
  26340. }
  26341. }
  26342. declare module BABYLON {
  26343. /**
  26344. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26345. *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.
  26346. * The SPS is also a particle system. It provides some methods to manage the particles.
  26347. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26348. *
  26349. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26350. */
  26351. class SolidParticleSystem implements IDisposable {
  26352. /**
  26353. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26354. * Example : var p = SPS.particles[i];
  26355. */
  26356. particles: SolidParticle[];
  26357. /**
  26358. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26359. */
  26360. nbParticles: number;
  26361. /**
  26362. * If the particles must ever face the camera (default false). Useful for planar particles.
  26363. */
  26364. billboard: boolean;
  26365. /**
  26366. * Recompute normals when adding a shape
  26367. */
  26368. recomputeNormals: boolean;
  26369. /**
  26370. * This a counter ofr your own usage. It's not set by any SPS functions.
  26371. */
  26372. counter: number;
  26373. /**
  26374. * The SPS name. This name is also given to the underlying mesh.
  26375. */
  26376. name: string;
  26377. /**
  26378. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26379. */
  26380. mesh: Mesh;
  26381. /**
  26382. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26383. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26384. */
  26385. vars: any;
  26386. /**
  26387. * This array is populated when the SPS is set as 'pickable'.
  26388. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26389. * Each element of this array is an object `{idx: int, faceId: int}`.
  26390. * `idx` is the picked particle index in the `SPS.particles` array
  26391. * `faceId` is the picked face index counted within this particle.
  26392. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26393. */
  26394. pickedParticles: {
  26395. idx: number;
  26396. faceId: number;
  26397. }[];
  26398. /**
  26399. * This array is populated when `enableDepthSort` is set to true.
  26400. * Each element of this array is an instance of the class DepthSortedParticle.
  26401. */
  26402. depthSortedParticles: DepthSortedParticle[];
  26403. /**
  26404. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26405. * @hidden
  26406. */
  26407. _bSphereOnly: boolean;
  26408. /**
  26409. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26410. * @hidden
  26411. */
  26412. _bSphereRadiusFactor: number;
  26413. private _scene;
  26414. private _positions;
  26415. private _indices;
  26416. private _normals;
  26417. private _colors;
  26418. private _uvs;
  26419. private _indices32;
  26420. private _positions32;
  26421. private _normals32;
  26422. private _fixedNormal32;
  26423. private _colors32;
  26424. private _uvs32;
  26425. private _index;
  26426. private _updatable;
  26427. private _pickable;
  26428. private _isVisibilityBoxLocked;
  26429. private _alwaysVisible;
  26430. private _depthSort;
  26431. private _shapeCounter;
  26432. private _copy;
  26433. private _shape;
  26434. private _shapeUV;
  26435. private _color;
  26436. private _computeParticleColor;
  26437. private _computeParticleTexture;
  26438. private _computeParticleRotation;
  26439. private _computeParticleVertex;
  26440. private _computeBoundingBox;
  26441. private _depthSortParticles;
  26442. private _cam_axisZ;
  26443. private _cam_axisY;
  26444. private _cam_axisX;
  26445. private _axisZ;
  26446. private _camera;
  26447. private _particle;
  26448. private _camDir;
  26449. private _camInvertedPosition;
  26450. private _rotMatrix;
  26451. private _invertMatrix;
  26452. private _rotated;
  26453. private _quaternion;
  26454. private _vertex;
  26455. private _normal;
  26456. private _yaw;
  26457. private _pitch;
  26458. private _roll;
  26459. private _halfroll;
  26460. private _halfpitch;
  26461. private _halfyaw;
  26462. private _sinRoll;
  26463. private _cosRoll;
  26464. private _sinPitch;
  26465. private _cosPitch;
  26466. private _sinYaw;
  26467. private _cosYaw;
  26468. private _mustUnrotateFixedNormals;
  26469. private _minimum;
  26470. private _maximum;
  26471. private _minBbox;
  26472. private _maxBbox;
  26473. private _particlesIntersect;
  26474. private _depthSortFunction;
  26475. private _needs32Bits;
  26476. private _pivotBackTranslation;
  26477. private _scaledPivot;
  26478. private _particleHasParent;
  26479. private _parent;
  26480. /**
  26481. * Creates a SPS (Solid Particle System) object.
  26482. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26483. * @param scene (Scene) is the scene in which the SPS is added.
  26484. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26485. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26486. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26487. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26488. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26489. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26490. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26491. */
  26492. constructor(name: string, scene: Scene, options?: {
  26493. updatable?: boolean;
  26494. isPickable?: boolean;
  26495. enableDepthSort?: boolean;
  26496. particleIntersection?: boolean;
  26497. boundingSphereOnly?: boolean;
  26498. bSphereRadiusFactor?: number;
  26499. });
  26500. /**
  26501. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26502. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26503. * @returns the created mesh
  26504. */
  26505. buildMesh(): Mesh;
  26506. /**
  26507. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26508. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26509. * Thus the particles generated from `digest()` have their property `position` set yet.
  26510. * @param mesh ( Mesh ) is the mesh to be digested
  26511. * @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
  26512. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26513. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26514. * @returns the current SPS
  26515. */
  26516. digest(mesh: Mesh, options?: {
  26517. facetNb?: number;
  26518. number?: number;
  26519. delta?: number;
  26520. }): SolidParticleSystem;
  26521. private _unrotateFixedNormals;
  26522. private _resetCopy;
  26523. private _meshBuilder;
  26524. private _posToShape;
  26525. private _uvsToShapeUV;
  26526. private _addParticle;
  26527. /**
  26528. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26529. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26530. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26531. * @param nb (positive integer) the number of particles to be created from this model
  26532. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26533. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26534. * @returns the number of shapes in the system
  26535. */
  26536. addShape(mesh: Mesh, nb: number, options?: {
  26537. positionFunction?: any;
  26538. vertexFunction?: any;
  26539. }): number;
  26540. private _rebuildParticle;
  26541. /**
  26542. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26543. * @returns the SPS.
  26544. */
  26545. rebuildMesh(): SolidParticleSystem;
  26546. /**
  26547. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26548. * This method calls `updateParticle()` for each particle of the SPS.
  26549. * For an animated SPS, it is usually called within the render loop.
  26550. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26551. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26552. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26553. * @returns the SPS.
  26554. */
  26555. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26556. private _quaternionRotationYPR;
  26557. private _quaternionToRotationMatrix;
  26558. /**
  26559. * Disposes the SPS.
  26560. */
  26561. dispose(): void;
  26562. /**
  26563. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26564. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26565. * @returns the SPS.
  26566. */
  26567. refreshVisibleSize(): SolidParticleSystem;
  26568. /**
  26569. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26570. * @param size the size (float) of the visibility box
  26571. * note : this doesn't lock the SPS mesh bounding box.
  26572. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26573. */
  26574. setVisibilityBox(size: number): void;
  26575. /**
  26576. * Gets whether the SPS as always visible or not
  26577. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26578. */
  26579. /**
  26580. * Sets the SPS as always visible or not
  26581. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26582. */
  26583. isAlwaysVisible: boolean;
  26584. /**
  26585. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26586. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26587. */
  26588. /**
  26589. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26590. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26591. */
  26592. isVisibilityBoxLocked: boolean;
  26593. /**
  26594. * Tells to `setParticles()` to compute the particle rotations or not.
  26595. * Default value : true. The SPS is faster when it's set to false.
  26596. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26597. */
  26598. /**
  26599. * Gets if `setParticles()` computes the particle rotations or not.
  26600. * Default value : true. The SPS is faster when it's set to false.
  26601. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26602. */
  26603. computeParticleRotation: boolean;
  26604. /**
  26605. * Tells to `setParticles()` to compute the particle colors or not.
  26606. * Default value : true. The SPS is faster when it's set to false.
  26607. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26608. */
  26609. /**
  26610. * Gets if `setParticles()` computes the particle colors or not.
  26611. * Default value : true. The SPS is faster when it's set to false.
  26612. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26613. */
  26614. computeParticleColor: boolean;
  26615. /**
  26616. * Gets if `setParticles()` computes the particle textures or not.
  26617. * Default value : true. The SPS is faster when it's set to false.
  26618. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26619. */
  26620. computeParticleTexture: boolean;
  26621. /**
  26622. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26623. * Default value : false. The SPS is faster when it's set to false.
  26624. * Note : the particle custom vertex positions aren't stored values.
  26625. */
  26626. /**
  26627. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26628. * Default value : false. The SPS is faster when it's set to false.
  26629. * Note : the particle custom vertex positions aren't stored values.
  26630. */
  26631. computeParticleVertex: boolean;
  26632. /**
  26633. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26634. */
  26635. /**
  26636. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26637. */
  26638. computeBoundingBox: boolean;
  26639. /**
  26640. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26641. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26642. * Default : `true`
  26643. */
  26644. /**
  26645. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26646. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26647. * Default : `true`
  26648. */
  26649. depthSortParticles: boolean;
  26650. /**
  26651. * This function does nothing. It may be overwritten to set all the particle first values.
  26652. * The SPS doesn't call this function, you may have to call it by your own.
  26653. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26654. */
  26655. initParticles(): void;
  26656. /**
  26657. * This function does nothing. It may be overwritten to recycle a particle.
  26658. * The SPS doesn't call this function, you may have to call it by your own.
  26659. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26660. * @param particle The particle to recycle
  26661. * @returns the recycled particle
  26662. */
  26663. recycleParticle(particle: SolidParticle): SolidParticle;
  26664. /**
  26665. * Updates a particle : this function should be overwritten by the user.
  26666. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26667. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26668. * @example : just set a particle position or velocity and recycle conditions
  26669. * @param particle The particle to update
  26670. * @returns the updated particle
  26671. */
  26672. updateParticle(particle: SolidParticle): SolidParticle;
  26673. /**
  26674. * Updates a vertex of a particle : it can be overwritten by the user.
  26675. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26676. * @param particle the current particle
  26677. * @param vertex the current index of the current particle
  26678. * @param pt the index of the current vertex in the particle shape
  26679. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26680. * @example : just set a vertex particle position
  26681. * @returns the updated vertex
  26682. */
  26683. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26684. /**
  26685. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26686. * This does nothing and may be overwritten by the user.
  26687. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26688. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26689. * @param update the boolean update value actually passed to setParticles()
  26690. */
  26691. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26692. /**
  26693. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26694. * This will be passed three parameters.
  26695. * This does nothing and may be overwritten by the user.
  26696. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26697. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26698. * @param update the boolean update value actually passed to setParticles()
  26699. */
  26700. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26701. }
  26702. }
  26703. declare module BABYLON {
  26704. interface PhysicsImpostorJoint {
  26705. mainImpostor: PhysicsImpostor;
  26706. connectedImpostor: PhysicsImpostor;
  26707. joint: PhysicsJoint;
  26708. }
  26709. class PhysicsEngine {
  26710. private _physicsPlugin;
  26711. gravity: Vector3;
  26712. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  26713. setGravity(gravity: Vector3): void;
  26714. /**
  26715. * Set the time step of the physics engine.
  26716. * default is 1/60.
  26717. * To slow it down, enter 1/600 for example.
  26718. * To speed it up, 1/30
  26719. * @param {number} newTimeStep the new timestep to apply to this world.
  26720. */
  26721. setTimeStep(newTimeStep?: number): void;
  26722. /**
  26723. * Get the time step of the physics engine.
  26724. */
  26725. getTimeStep(): number;
  26726. dispose(): void;
  26727. getPhysicsPluginName(): string;
  26728. static Epsilon: number;
  26729. private _impostors;
  26730. private _joints;
  26731. /**
  26732. * Adding a new impostor for the impostor tracking.
  26733. * This will be done by the impostor itself.
  26734. * @param {PhysicsImpostor} impostor the impostor to add
  26735. */
  26736. addImpostor(impostor: PhysicsImpostor): void;
  26737. /**
  26738. * Remove an impostor from the engine.
  26739. * This impostor and its mesh will not longer be updated by the physics engine.
  26740. * @param {PhysicsImpostor} impostor the impostor to remove
  26741. */
  26742. removeImpostor(impostor: PhysicsImpostor): void;
  26743. /**
  26744. * Add a joint to the physics engine
  26745. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  26746. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  26747. * @param {PhysicsJoint} the joint that will connect both impostors.
  26748. */
  26749. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26750. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26751. /**
  26752. * Called by the scene. no need to call it.
  26753. * @hidden
  26754. */
  26755. _step(delta: number): void;
  26756. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26757. getImpostors(): Array<PhysicsImpostor>;
  26758. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26759. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26760. }
  26761. interface IPhysicsEnginePlugin {
  26762. world: any;
  26763. name: string;
  26764. setGravity(gravity: Vector3): void;
  26765. setTimeStep(timeStep: number): void;
  26766. getTimeStep(): number;
  26767. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26768. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26769. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26770. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26771. removePhysicsBody(impostor: PhysicsImpostor): void;
  26772. generateJoint(joint: PhysicsImpostorJoint): void;
  26773. removeJoint(joint: PhysicsImpostorJoint): void;
  26774. isSupported(): boolean;
  26775. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26776. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26777. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26778. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26779. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26780. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26781. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26782. getBodyMass(impostor: PhysicsImpostor): number;
  26783. getBodyFriction(impostor: PhysicsImpostor): number;
  26784. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26785. getBodyRestitution(impostor: PhysicsImpostor): number;
  26786. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26787. sleepBody(impostor: PhysicsImpostor): void;
  26788. wakeUpBody(impostor: PhysicsImpostor): void;
  26789. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26790. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26791. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26792. getRadius(impostor: PhysicsImpostor): number;
  26793. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26794. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26795. dispose(): void;
  26796. }
  26797. }
  26798. declare module BABYLON {
  26799. class PhysicsHelper {
  26800. private _scene;
  26801. private _physicsEngine;
  26802. constructor(scene: Scene);
  26803. /**
  26804. * @param {Vector3} origin the origin of the explosion
  26805. * @param {number} radius the explosion radius
  26806. * @param {number} strength the explosion strength
  26807. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26808. */
  26809. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26810. /**
  26811. * @param {Vector3} origin the origin of the explosion
  26812. * @param {number} radius the explosion radius
  26813. * @param {number} strength the explosion strength
  26814. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26815. */
  26816. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26817. /**
  26818. * @param {Vector3} origin the origin of the explosion
  26819. * @param {number} radius the explosion radius
  26820. * @param {number} strength the explosion strength
  26821. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26822. */
  26823. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  26824. /**
  26825. * @param {Vector3} origin the origin of the updraft
  26826. * @param {number} radius the radius of the updraft
  26827. * @param {number} strength the strength of the updraft
  26828. * @param {number} height the height of the updraft
  26829. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  26830. */
  26831. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  26832. /**
  26833. * @param {Vector3} origin the of the vortex
  26834. * @param {number} radius the radius of the vortex
  26835. * @param {number} strength the strength of the vortex
  26836. * @param {number} height the height of the vortex
  26837. */
  26838. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  26839. }
  26840. /***** Radial explosion *****/
  26841. class PhysicsRadialExplosionEvent {
  26842. private _scene;
  26843. private _sphere;
  26844. private _sphereOptions;
  26845. private _rays;
  26846. private _dataFetched;
  26847. constructor(scene: Scene);
  26848. /**
  26849. * Returns the data related to the radial explosion event (sphere & rays).
  26850. * @returns {PhysicsRadialExplosionEventData}
  26851. */
  26852. getData(): PhysicsRadialExplosionEventData;
  26853. /**
  26854. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26855. * @param impostor
  26856. * @param {Vector3} origin the origin of the explosion
  26857. * @param {number} radius the explosion radius
  26858. * @param {number} strength the explosion strength
  26859. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26860. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26861. */
  26862. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26863. /**
  26864. * Disposes the sphere.
  26865. * @param {bolean} force
  26866. */
  26867. dispose(force?: boolean): void;
  26868. /*** Helpers ***/
  26869. private _prepareSphere;
  26870. private _intersectsWithSphere;
  26871. }
  26872. /***** Gravitational Field *****/
  26873. class PhysicsGravitationalFieldEvent {
  26874. private _physicsHelper;
  26875. private _scene;
  26876. private _origin;
  26877. private _radius;
  26878. private _strength;
  26879. private _falloff;
  26880. private _tickCallback;
  26881. private _sphere;
  26882. private _dataFetched;
  26883. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26884. /**
  26885. * Returns the data related to the gravitational field event (sphere).
  26886. * @returns {PhysicsGravitationalFieldEventData}
  26887. */
  26888. getData(): PhysicsGravitationalFieldEventData;
  26889. /**
  26890. * Enables the gravitational field.
  26891. */
  26892. enable(): void;
  26893. /**
  26894. * Disables the gravitational field.
  26895. */
  26896. disable(): void;
  26897. /**
  26898. * Disposes the sphere.
  26899. * @param {bolean} force
  26900. */
  26901. dispose(force?: boolean): void;
  26902. private _tick;
  26903. }
  26904. /***** Updraft *****/
  26905. class PhysicsUpdraftEvent {
  26906. private _scene;
  26907. private _origin;
  26908. private _radius;
  26909. private _strength;
  26910. private _height;
  26911. private _updraftMode;
  26912. private _physicsEngine;
  26913. private _originTop;
  26914. private _originDirection;
  26915. private _tickCallback;
  26916. private _cylinder;
  26917. private _cylinderPosition;
  26918. private _dataFetched;
  26919. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26920. /**
  26921. * Returns the data related to the updraft event (cylinder).
  26922. * @returns {PhysicsUpdraftEventData}
  26923. */
  26924. getData(): PhysicsUpdraftEventData;
  26925. /**
  26926. * Enables the updraft.
  26927. */
  26928. enable(): void;
  26929. /**
  26930. * Disables the cortex.
  26931. */
  26932. disable(): void;
  26933. /**
  26934. * Disposes the sphere.
  26935. * @param {bolean} force
  26936. */
  26937. dispose(force?: boolean): void;
  26938. private getImpostorForceAndContactPoint;
  26939. private _tick;
  26940. /*** Helpers ***/
  26941. private _prepareCylinder;
  26942. private _intersectsWithCylinder;
  26943. }
  26944. /***** Vortex *****/
  26945. class PhysicsVortexEvent {
  26946. private _scene;
  26947. private _origin;
  26948. private _radius;
  26949. private _strength;
  26950. private _height;
  26951. private _physicsEngine;
  26952. private _originTop;
  26953. private _centripetalForceThreshold;
  26954. private _updraftMultiplier;
  26955. private _tickCallback;
  26956. private _cylinder;
  26957. private _cylinderPosition;
  26958. private _dataFetched;
  26959. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26960. /**
  26961. * Returns the data related to the vortex event (cylinder).
  26962. * @returns {PhysicsVortexEventData}
  26963. */
  26964. getData(): PhysicsVortexEventData;
  26965. /**
  26966. * Enables the vortex.
  26967. */
  26968. enable(): void;
  26969. /**
  26970. * Disables the cortex.
  26971. */
  26972. disable(): void;
  26973. /**
  26974. * Disposes the sphere.
  26975. * @param {bolean} force
  26976. */
  26977. dispose(force?: boolean): void;
  26978. private getImpostorForceAndContactPoint;
  26979. private _tick;
  26980. /*** Helpers ***/
  26981. private _prepareCylinder;
  26982. private _intersectsWithCylinder;
  26983. }
  26984. /***** Enums *****/
  26985. /**
  26986. * The strenght of the force in correspondence to the distance of the affected object
  26987. */
  26988. enum PhysicsRadialImpulseFalloff {
  26989. /** Defines that impulse is constant in strength across it's whole radius */
  26990. Constant = 0,
  26991. /** DEfines that impulse gets weaker if it's further from the origin */
  26992. Linear = 1
  26993. }
  26994. /**
  26995. * The strenght of the force in correspondence to the distance of the affected object
  26996. */
  26997. enum PhysicsUpdraftMode {
  26998. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26999. Center = 0,
  27000. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  27001. Perpendicular = 1
  27002. }
  27003. /***** Data interfaces *****/
  27004. interface PhysicsForceAndContactPoint {
  27005. force: Vector3;
  27006. contactPoint: Vector3;
  27007. }
  27008. interface PhysicsRadialExplosionEventData {
  27009. sphere: Mesh;
  27010. rays: Array<Ray>;
  27011. }
  27012. interface PhysicsGravitationalFieldEventData {
  27013. sphere: Mesh;
  27014. }
  27015. interface PhysicsUpdraftEventData {
  27016. cylinder: Mesh;
  27017. }
  27018. interface PhysicsVortexEventData {
  27019. cylinder: Mesh;
  27020. }
  27021. }
  27022. declare module BABYLON {
  27023. interface PhysicsImpostorParameters {
  27024. mass: number;
  27025. friction?: number;
  27026. restitution?: number;
  27027. nativeOptions?: any;
  27028. ignoreParent?: boolean;
  27029. disableBidirectionalTransformation?: boolean;
  27030. }
  27031. interface IPhysicsEnabledObject {
  27032. position: Vector3;
  27033. rotationQuaternion: Nullable<Quaternion>;
  27034. scaling: Vector3;
  27035. rotation?: Vector3;
  27036. parent?: any;
  27037. getBoundingInfo(): BoundingInfo;
  27038. computeWorldMatrix(force: boolean): Matrix;
  27039. getWorldMatrix?(): Matrix;
  27040. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27041. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27042. getIndices?(): Nullable<IndicesArray>;
  27043. getScene?(): Scene;
  27044. getAbsolutePosition(): Vector3;
  27045. getAbsolutePivotPoint(): Vector3;
  27046. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27047. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27048. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27049. getClassName(): string;
  27050. }
  27051. class PhysicsImpostor {
  27052. object: IPhysicsEnabledObject;
  27053. type: number;
  27054. private _options;
  27055. private _scene?;
  27056. static DEFAULT_OBJECT_SIZE: Vector3;
  27057. static IDENTITY_QUATERNION: Quaternion;
  27058. private _physicsEngine;
  27059. private _physicsBody;
  27060. private _bodyUpdateRequired;
  27061. private _onBeforePhysicsStepCallbacks;
  27062. private _onAfterPhysicsStepCallbacks;
  27063. private _onPhysicsCollideCallbacks;
  27064. private _deltaPosition;
  27065. private _deltaRotation;
  27066. private _deltaRotationConjugated;
  27067. private _parent;
  27068. private _isDisposed;
  27069. private static _tmpVecs;
  27070. private static _tmpQuat;
  27071. readonly isDisposed: boolean;
  27072. mass: number;
  27073. friction: number;
  27074. restitution: number;
  27075. uniqueId: number;
  27076. private _joints;
  27077. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27078. /**
  27079. * This function will completly initialize this impostor.
  27080. * It will create a new body - but only if this mesh has no parent.
  27081. * If it has, this impostor will not be used other than to define the impostor
  27082. * of the child mesh.
  27083. * @hidden
  27084. */
  27085. _init(): void;
  27086. private _getPhysicsParent;
  27087. /**
  27088. * Should a new body be generated.
  27089. */
  27090. isBodyInitRequired(): boolean;
  27091. setScalingUpdated(updated: boolean): void;
  27092. /**
  27093. * Force a regeneration of this or the parent's impostor's body.
  27094. * Use under cautious - This will remove all joints already implemented.
  27095. */
  27096. forceUpdate(): void;
  27097. /**
  27098. * Gets the body that holds this impostor. Either its own, or its parent.
  27099. */
  27100. /**
  27101. * Set the physics body. Used mainly by the physics engine/plugin
  27102. */
  27103. physicsBody: any;
  27104. parent: Nullable<PhysicsImpostor>;
  27105. resetUpdateFlags(): void;
  27106. getObjectExtendSize(): Vector3;
  27107. getObjectCenter(): Vector3;
  27108. /**
  27109. * Get a specific parametes from the options parameter.
  27110. */
  27111. getParam(paramName: string): any;
  27112. /**
  27113. * Sets a specific parameter in the options given to the physics plugin
  27114. */
  27115. setParam(paramName: string, value: number): void;
  27116. /**
  27117. * Specifically change the body's mass option. Won't recreate the physics body object
  27118. */
  27119. setMass(mass: number): void;
  27120. getLinearVelocity(): Nullable<Vector3>;
  27121. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27122. getAngularVelocity(): Nullable<Vector3>;
  27123. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27124. /**
  27125. * Execute a function with the physics plugin native code.
  27126. * Provide a function the will have two variables - the world object and the physics body object.
  27127. */
  27128. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27129. /**
  27130. * Register a function that will be executed before the physics world is stepping forward.
  27131. */
  27132. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27133. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27134. /**
  27135. * Register a function that will be executed after the physics step
  27136. */
  27137. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27138. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27139. /**
  27140. * register a function that will be executed when this impostor collides against a different body.
  27141. */
  27142. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27143. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27144. private _tmpQuat;
  27145. private _tmpQuat2;
  27146. getParentsRotation(): Quaternion;
  27147. /**
  27148. * this function is executed by the physics engine.
  27149. */
  27150. beforeStep: () => void;
  27151. /**
  27152. * this function is executed by the physics engine.
  27153. */
  27154. afterStep: () => void;
  27155. /**
  27156. * Legacy collision detection event support
  27157. */
  27158. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27159. onCollide: (e: {
  27160. body: any;
  27161. }) => void;
  27162. /**
  27163. * Apply a force
  27164. */
  27165. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27166. /**
  27167. * Apply an impulse
  27168. */
  27169. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27170. /**
  27171. * A help function to create a joint.
  27172. */
  27173. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27174. /**
  27175. * Add a joint to this impostor with a different impostor.
  27176. */
  27177. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27178. /**
  27179. * Will keep this body still, in a sleep mode.
  27180. */
  27181. sleep(): PhysicsImpostor;
  27182. /**
  27183. * Wake the body up.
  27184. */
  27185. wakeUp(): PhysicsImpostor;
  27186. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27187. dispose(): void;
  27188. setDeltaPosition(position: Vector3): void;
  27189. setDeltaRotation(rotation: Quaternion): void;
  27190. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27191. getRadius(): number;
  27192. /**
  27193. * Sync a bone with this impostor
  27194. * @param bone The bone to sync to the impostor.
  27195. * @param boneMesh The mesh that the bone is influencing.
  27196. * @param jointPivot The pivot of the joint / bone in local space.
  27197. * @param distToJoint Optional distance from the impostor to the joint.
  27198. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27199. */
  27200. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27201. /**
  27202. * Sync impostor to a bone
  27203. * @param bone The bone that the impostor will be synced to.
  27204. * @param boneMesh The mesh that the bone is influencing.
  27205. * @param jointPivot The pivot of the joint / bone in local space.
  27206. * @param distToJoint Optional distance from the impostor to the joint.
  27207. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27208. * @param boneAxis Optional vector3 axis the bone is aligned with
  27209. */
  27210. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27211. static NoImpostor: number;
  27212. static SphereImpostor: number;
  27213. static BoxImpostor: number;
  27214. static PlaneImpostor: number;
  27215. static MeshImpostor: number;
  27216. static CylinderImpostor: number;
  27217. static ParticleImpostor: number;
  27218. static HeightmapImpostor: number;
  27219. }
  27220. }
  27221. declare module BABYLON {
  27222. interface PhysicsJointData {
  27223. mainPivot?: Vector3;
  27224. connectedPivot?: Vector3;
  27225. mainAxis?: Vector3;
  27226. connectedAxis?: Vector3;
  27227. collision?: boolean;
  27228. nativeParams?: any;
  27229. }
  27230. /**
  27231. * This is a holder class for the physics joint created by the physics plugin.
  27232. * It holds a set of functions to control the underlying joint.
  27233. */
  27234. class PhysicsJoint {
  27235. type: number;
  27236. jointData: PhysicsJointData;
  27237. private _physicsJoint;
  27238. protected _physicsPlugin: IPhysicsEnginePlugin;
  27239. constructor(type: number, jointData: PhysicsJointData);
  27240. physicsJoint: any;
  27241. physicsPlugin: IPhysicsEnginePlugin;
  27242. /**
  27243. * Execute a function that is physics-plugin specific.
  27244. * @param {Function} func the function that will be executed.
  27245. * It accepts two parameters: the physics world and the physics joint.
  27246. */
  27247. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27248. static DistanceJoint: number;
  27249. static HingeJoint: number;
  27250. static BallAndSocketJoint: number;
  27251. static WheelJoint: number;
  27252. static SliderJoint: number;
  27253. static PrismaticJoint: number;
  27254. static UniversalJoint: number;
  27255. static Hinge2Joint: number;
  27256. static PointToPointJoint: number;
  27257. static SpringJoint: number;
  27258. static LockJoint: number;
  27259. }
  27260. /**
  27261. * A class representing a physics distance joint.
  27262. */
  27263. class DistanceJoint extends PhysicsJoint {
  27264. constructor(jointData: DistanceJointData);
  27265. /**
  27266. * Update the predefined distance.
  27267. */
  27268. updateDistance(maxDistance: number, minDistance?: number): void;
  27269. }
  27270. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27271. constructor(type: number, jointData: PhysicsJointData);
  27272. /**
  27273. * Set the motor values.
  27274. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27275. * @param {number} force the force to apply
  27276. * @param {number} maxForce max force for this motor.
  27277. */
  27278. setMotor(force?: number, maxForce?: number): void;
  27279. /**
  27280. * Set the motor's limits.
  27281. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27282. */
  27283. setLimit(upperLimit: number, lowerLimit?: number): void;
  27284. }
  27285. /**
  27286. * This class represents a single hinge physics joint
  27287. */
  27288. class HingeJoint extends MotorEnabledJoint {
  27289. constructor(jointData: PhysicsJointData);
  27290. /**
  27291. * Set the motor values.
  27292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27293. * @param {number} force the force to apply
  27294. * @param {number} maxForce max force for this motor.
  27295. */
  27296. setMotor(force?: number, maxForce?: number): void;
  27297. /**
  27298. * Set the motor's limits.
  27299. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27300. */
  27301. setLimit(upperLimit: number, lowerLimit?: number): void;
  27302. }
  27303. /**
  27304. * This class represents a dual hinge physics joint (same as wheel joint)
  27305. */
  27306. class Hinge2Joint extends MotorEnabledJoint {
  27307. constructor(jointData: PhysicsJointData);
  27308. /**
  27309. * Set the motor values.
  27310. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27311. * @param {number} force the force to apply
  27312. * @param {number} maxForce max force for this motor.
  27313. * @param {motorIndex} the motor's index, 0 or 1.
  27314. */
  27315. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27316. /**
  27317. * Set the motor limits.
  27318. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27319. * @param {number} upperLimit the upper limit
  27320. * @param {number} lowerLimit lower limit
  27321. * @param {motorIndex} the motor's index, 0 or 1.
  27322. */
  27323. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27324. }
  27325. interface IMotorEnabledJoint {
  27326. physicsJoint: any;
  27327. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27328. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27329. }
  27330. interface DistanceJointData extends PhysicsJointData {
  27331. maxDistance: number;
  27332. }
  27333. interface SpringJointData extends PhysicsJointData {
  27334. length: number;
  27335. stiffness: number;
  27336. damping: number;
  27337. }
  27338. }
  27339. declare module BABYLON {
  27340. /**
  27341. * Postprocess used to generate anaglyphic rendering
  27342. */
  27343. class AnaglyphPostProcess extends PostProcess {
  27344. private _passedProcess;
  27345. /**
  27346. * Creates a new AnaglyphPostProcess
  27347. * @param name defines postprocess name
  27348. * @param options defines creation options or target ratio scale
  27349. * @param rigCameras defines cameras using this postprocess
  27350. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27351. * @param engine defines hosting engine
  27352. * @param reusable defines if the postprocess will be reused multiple times per frame
  27353. */
  27354. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27355. }
  27356. }
  27357. declare module BABYLON {
  27358. class BlackAndWhitePostProcess extends PostProcess {
  27359. degree: number;
  27360. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27361. }
  27362. }
  27363. declare module BABYLON {
  27364. /**
  27365. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27366. */
  27367. class BloomEffect extends PostProcessRenderEffect {
  27368. private bloomScale;
  27369. /**
  27370. * @hidden Internal
  27371. */
  27372. _effects: Array<PostProcess>;
  27373. /**
  27374. * @hidden Internal
  27375. */
  27376. _downscale: ExtractHighlightsPostProcess;
  27377. private _blurX;
  27378. private _blurY;
  27379. private _merge;
  27380. /**
  27381. * The luminance threshold to find bright areas of the image to bloom.
  27382. */
  27383. threshold: number;
  27384. /**
  27385. * The strength of the bloom.
  27386. */
  27387. weight: number;
  27388. /**
  27389. * Specifies the size of the bloom blur kernel, relative to the final output size
  27390. */
  27391. kernel: number;
  27392. /**
  27393. * Creates a new instance of @see BloomEffect
  27394. * @param scene The scene the effect belongs to.
  27395. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27396. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27397. * @param bloomWeight The the strength of bloom.
  27398. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27399. * @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)
  27400. */
  27401. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27402. /**
  27403. * Disposes each of the internal effects for a given camera.
  27404. * @param camera The camera to dispose the effect on.
  27405. */
  27406. disposeEffects(camera: Camera): void;
  27407. /**
  27408. * @hidden Internal
  27409. */
  27410. _updateEffects(): void;
  27411. /**
  27412. * Internal
  27413. * @returns if all the contained post processes are ready.
  27414. * @hidden
  27415. */
  27416. _isReady(): boolean;
  27417. }
  27418. }
  27419. declare module BABYLON {
  27420. /**
  27421. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27422. */
  27423. class BloomMergePostProcess extends PostProcess {
  27424. /** Weight of the bloom to be added to the original input. */
  27425. weight: number;
  27426. /**
  27427. * Creates a new instance of @see BloomMergePostProcess
  27428. * @param name The name of the effect.
  27429. * @param originalFromInput Post process which's input will be used for the merge.
  27430. * @param blurred Blurred highlights post process which's output will be used.
  27431. * @param weight Weight of the bloom to be added to the original input.
  27432. * @param options The required width/height ratio to downsize to before computing the render pass.
  27433. * @param camera The camera to apply the render pass to.
  27434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27435. * @param engine The engine which the post process will be applied. (default: current engine)
  27436. * @param reusable If the post process can be reused on the same frame. (default: false)
  27437. * @param textureType Type of textures used when performing the post process. (default: 0)
  27438. * @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)
  27439. */
  27440. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27441. /** Weight of the bloom to be added to the original input. */
  27442. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27443. }
  27444. }
  27445. declare module BABYLON {
  27446. /**
  27447. * The Blur Post Process which blurs an image based on a kernel and direction.
  27448. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27449. */
  27450. class BlurPostProcess extends PostProcess {
  27451. /** The direction in which to blur the image. */
  27452. direction: Vector2;
  27453. private blockCompilation;
  27454. protected _kernel: number;
  27455. protected _idealKernel: number;
  27456. protected _packedFloat: boolean;
  27457. private _staticDefines;
  27458. /**
  27459. * Sets the length in pixels of the blur sample region
  27460. */
  27461. /**
  27462. * Gets the length in pixels of the blur sample region
  27463. */
  27464. kernel: number;
  27465. /**
  27466. * Sets wether or not the blur needs to unpack/repack floats
  27467. */
  27468. /**
  27469. * Gets wether or not the blur is unpacking/repacking floats
  27470. */
  27471. packedFloat: boolean;
  27472. /**
  27473. * Creates a new instance BlurPostProcess
  27474. * @param name The name of the effect.
  27475. * @param direction The direction in which to blur the image.
  27476. * @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.
  27477. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27478. * @param camera The camera to apply the render pass to.
  27479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27480. * @param engine The engine which the post process will be applied. (default: current engine)
  27481. * @param reusable If the post process can be reused on the same frame. (default: false)
  27482. * @param textureType Type of textures used when performing the post process. (default: 0)
  27483. * @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)
  27484. */
  27485. constructor(name: string,
  27486. /** The direction in which to blur the image. */
  27487. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27488. /**
  27489. * Updates the effect with the current post process compile time values and recompiles the shader.
  27490. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27491. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27492. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27493. * @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
  27494. * @param onCompiled Called when the shader has been compiled.
  27495. * @param onError Called if there is an error when compiling a shader.
  27496. */
  27497. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27498. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27499. /**
  27500. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27501. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27502. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27503. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27504. * The gaps between physical kernels are compensated for in the weighting of the samples
  27505. * @param idealKernel Ideal blur kernel.
  27506. * @return Nearest best kernel.
  27507. */
  27508. protected _nearestBestKernel(idealKernel: number): number;
  27509. /**
  27510. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27511. * @param x The point on the Gaussian distribution to sample.
  27512. * @return the value of the Gaussian function at x.
  27513. */
  27514. protected _gaussianWeight(x: number): number;
  27515. /**
  27516. * Generates a string that can be used as a floating point number in GLSL.
  27517. * @param x Value to print.
  27518. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27519. * @return GLSL float string.
  27520. */
  27521. protected _glslFloat(x: number, decimalFigures?: number): string;
  27522. }
  27523. }
  27524. declare module BABYLON {
  27525. /**
  27526. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27527. */
  27528. class ChromaticAberrationPostProcess extends PostProcess {
  27529. /**
  27530. * The amount of seperation of rgb channels (default: 30)
  27531. */
  27532. aberrationAmount: number;
  27533. /**
  27534. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27535. */
  27536. radialIntensity: number;
  27537. /**
  27538. * 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))
  27539. */
  27540. direction: Vector2;
  27541. /**
  27542. * 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))
  27543. */
  27544. centerPosition: Vector2;
  27545. /**
  27546. * Creates a new instance ChromaticAberrationPostProcess
  27547. * @param name The name of the effect.
  27548. * @param screenWidth The width of the screen to apply the effect on.
  27549. * @param screenHeight The height of the screen to apply the effect on.
  27550. * @param options The required width/height ratio to downsize to before computing the render pass.
  27551. * @param camera The camera to apply the render pass to.
  27552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27553. * @param engine The engine which the post process will be applied. (default: current engine)
  27554. * @param reusable If the post process can be reused on the same frame. (default: false)
  27555. * @param textureType Type of textures used when performing the post process. (default: 0)
  27556. * @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)
  27557. */
  27558. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27559. }
  27560. }
  27561. declare module BABYLON {
  27562. /**
  27563. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27564. */
  27565. class CircleOfConfusionPostProcess extends PostProcess {
  27566. /**
  27567. * 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.
  27568. */
  27569. lensSize: number;
  27570. /**
  27571. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27572. */
  27573. fStop: number;
  27574. /**
  27575. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27576. */
  27577. focusDistance: number;
  27578. /**
  27579. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27580. */
  27581. focalLength: number;
  27582. private _depthTexture;
  27583. /**
  27584. * Creates a new instance CircleOfConfusionPostProcess
  27585. * @param name The name of the effect.
  27586. * @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.
  27587. * @param options The required width/height ratio to downsize to before computing the render pass.
  27588. * @param camera The camera to apply the render pass to.
  27589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27590. * @param engine The engine which the post process will be applied. (default: current engine)
  27591. * @param reusable If the post process can be reused on the same frame. (default: false)
  27592. * @param textureType Type of textures used when performing the post process. (default: 0)
  27593. * @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)
  27594. */
  27595. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27596. /**
  27597. * 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.
  27598. */
  27599. depthTexture: RenderTargetTexture;
  27600. }
  27601. }
  27602. declare module BABYLON {
  27603. class ColorCorrectionPostProcess extends PostProcess {
  27604. private _colorTableTexture;
  27605. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27606. }
  27607. }
  27608. declare module BABYLON {
  27609. /**
  27610. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27611. * input texture to perform effects such as edge detection or sharpening
  27612. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27613. */
  27614. class ConvolutionPostProcess extends PostProcess {
  27615. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27616. kernel: number[];
  27617. /**
  27618. * Creates a new instance ConvolutionPostProcess
  27619. * @param name The name of the effect.
  27620. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27621. * @param options The required width/height ratio to downsize to before computing the render pass.
  27622. * @param camera The camera to apply the render pass to.
  27623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27624. * @param engine The engine which the post process will be applied. (default: current engine)
  27625. * @param reusable If the post process can be reused on the same frame. (default: false)
  27626. * @param textureType Type of textures used when performing the post process. (default: 0)
  27627. */
  27628. constructor(name: string,
  27629. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27630. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27631. /**
  27632. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27633. */
  27634. static EdgeDetect0Kernel: number[];
  27635. /**
  27636. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27637. */
  27638. static EdgeDetect1Kernel: number[];
  27639. /**
  27640. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27641. */
  27642. static EdgeDetect2Kernel: number[];
  27643. /**
  27644. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27645. */
  27646. static SharpenKernel: number[];
  27647. /**
  27648. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27649. */
  27650. static EmbossKernel: number[];
  27651. /**
  27652. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27653. */
  27654. static GaussianKernel: number[];
  27655. }
  27656. }
  27657. declare module BABYLON {
  27658. /**
  27659. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27660. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27661. * based on samples that have a large difference in distance than the center pixel.
  27662. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27663. */
  27664. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27665. direction: Vector2;
  27666. /**
  27667. * Creates a new instance CircleOfConfusionPostProcess
  27668. * @param name The name of the effect.
  27669. * @param scene The scene the effect belongs to.
  27670. * @param direction The direction the blur should be applied.
  27671. * @param kernel The size of the kernel used to blur.
  27672. * @param options The required width/height ratio to downsize to before computing the render pass.
  27673. * @param camera The camera to apply the render pass to.
  27674. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27675. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27677. * @param engine The engine which the post process will be applied. (default: current engine)
  27678. * @param reusable If the post process can be reused on the same frame. (default: false)
  27679. * @param textureType Type of textures used when performing the post process. (default: 0)
  27680. * @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)
  27681. */
  27682. 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);
  27683. }
  27684. }
  27685. declare module BABYLON {
  27686. /**
  27687. * Specifies the level of max blur that should be applied when using the depth of field effect
  27688. */
  27689. enum DepthOfFieldEffectBlurLevel {
  27690. /**
  27691. * Subtle blur
  27692. */
  27693. Low = 0,
  27694. /**
  27695. * Medium blur
  27696. */
  27697. Medium = 1,
  27698. /**
  27699. * Large blur
  27700. */
  27701. High = 2
  27702. }
  27703. /**
  27704. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27705. */
  27706. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27707. private _circleOfConfusion;
  27708. /**
  27709. * @hidden Internal, blurs from high to low
  27710. */
  27711. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27712. private _depthOfFieldBlurY;
  27713. private _dofMerge;
  27714. /**
  27715. * @hidden Internal post processes in depth of field effect
  27716. */
  27717. _effects: Array<PostProcess>;
  27718. /**
  27719. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27720. */
  27721. focalLength: number;
  27722. /**
  27723. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27724. */
  27725. fStop: number;
  27726. /**
  27727. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27728. */
  27729. focusDistance: number;
  27730. /**
  27731. * 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.
  27732. */
  27733. lensSize: number;
  27734. /**
  27735. * Creates a new instance DepthOfFieldEffect
  27736. * @param scene The scene the effect belongs to.
  27737. * @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.
  27738. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27739. * @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)
  27740. */
  27741. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27742. /**
  27743. * 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.
  27744. */
  27745. depthTexture: RenderTargetTexture;
  27746. /**
  27747. * Disposes each of the internal effects for a given camera.
  27748. * @param camera The camera to dispose the effect on.
  27749. */
  27750. disposeEffects(camera: Camera): void;
  27751. /**
  27752. * @hidden Internal
  27753. */
  27754. _updateEffects(): void;
  27755. /**
  27756. * Internal
  27757. * @returns if all the contained post processes are ready.
  27758. * @hidden
  27759. */
  27760. _isReady(): boolean;
  27761. }
  27762. }
  27763. declare module BABYLON {
  27764. /**
  27765. * Options to be set when merging outputs from the default pipeline.
  27766. */
  27767. class DepthOfFieldMergePostProcessOptions {
  27768. /**
  27769. * The original image to merge on top of
  27770. */
  27771. originalFromInput: PostProcess;
  27772. /**
  27773. * Parameters to perform the merge of the depth of field effect
  27774. */
  27775. depthOfField?: {
  27776. circleOfConfusion: PostProcess;
  27777. blurSteps: Array<PostProcess>;
  27778. };
  27779. /**
  27780. * Parameters to perform the merge of bloom effect
  27781. */
  27782. bloom?: {
  27783. blurred: PostProcess;
  27784. weight: number;
  27785. };
  27786. }
  27787. /**
  27788. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27789. */
  27790. class DepthOfFieldMergePostProcess extends PostProcess {
  27791. private blurSteps;
  27792. /**
  27793. * Creates a new instance of DepthOfFieldMergePostProcess
  27794. * @param name The name of the effect.
  27795. * @param originalFromInput Post process which's input will be used for the merge.
  27796. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27797. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27798. * @param options The required width/height ratio to downsize to before computing the render pass.
  27799. * @param camera The camera to apply the render pass to.
  27800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27801. * @param engine The engine which the post process will be applied. (default: current engine)
  27802. * @param reusable If the post process can be reused on the same frame. (default: false)
  27803. * @param textureType Type of textures used when performing the post process. (default: 0)
  27804. * @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)
  27805. */
  27806. 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);
  27807. /**
  27808. * Updates the effect with the current post process compile time values and recompiles the shader.
  27809. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27810. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27811. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27812. * @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
  27813. * @param onCompiled Called when the shader has been compiled.
  27814. * @param onError Called if there is an error when compiling a shader.
  27815. */
  27816. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27817. }
  27818. }
  27819. declare module BABYLON {
  27820. class DisplayPassPostProcess extends PostProcess {
  27821. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27822. }
  27823. }
  27824. declare module BABYLON {
  27825. /**
  27826. * 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.
  27827. */
  27828. class ExtractHighlightsPostProcess extends PostProcess {
  27829. /**
  27830. * The luminance threshold, pixels below this value will be set to black.
  27831. */
  27832. threshold: number;
  27833. /** @hidden */
  27834. _exposure: number;
  27835. /**
  27836. * Post process which has the input texture to be used when performing highlight extraction
  27837. * @hidden
  27838. */
  27839. _inputPostProcess: Nullable<PostProcess>;
  27840. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27841. }
  27842. }
  27843. declare module BABYLON {
  27844. class FilterPostProcess extends PostProcess {
  27845. kernelMatrix: Matrix;
  27846. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27847. }
  27848. }
  27849. declare module BABYLON {
  27850. class FxaaPostProcess extends PostProcess {
  27851. texelWidth: number;
  27852. texelHeight: number;
  27853. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27854. private _getDefines;
  27855. }
  27856. }
  27857. declare module BABYLON {
  27858. /**
  27859. * The GrainPostProcess adds noise to the image at mid luminance levels
  27860. */
  27861. class GrainPostProcess extends PostProcess {
  27862. /**
  27863. * The intensity of the grain added (default: 30)
  27864. */
  27865. intensity: number;
  27866. /**
  27867. * If the grain should be randomized on every frame
  27868. */
  27869. animated: boolean;
  27870. /**
  27871. * Creates a new instance of @see GrainPostProcess
  27872. * @param name The name of the effect.
  27873. * @param options The required width/height ratio to downsize to before computing the render pass.
  27874. * @param camera The camera to apply the render pass to.
  27875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27876. * @param engine The engine which the post process will be applied. (default: current engine)
  27877. * @param reusable If the post process can be reused on the same frame. (default: false)
  27878. * @param textureType Type of textures used when performing the post process. (default: 0)
  27879. * @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)
  27880. */
  27881. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27882. }
  27883. }
  27884. declare module BABYLON {
  27885. class HighlightsPostProcess extends PostProcess {
  27886. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27887. }
  27888. }
  27889. declare module BABYLON {
  27890. class ImageProcessingPostProcess extends PostProcess {
  27891. /**
  27892. * Default configuration related to image processing available in the PBR Material.
  27893. */
  27894. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27895. /**
  27896. * Gets the image processing configuration used either in this material.
  27897. */
  27898. /**
  27899. * Sets the Default image processing configuration used either in the this material.
  27900. *
  27901. * If sets to null, the scene one is in use.
  27902. */
  27903. imageProcessingConfiguration: ImageProcessingConfiguration;
  27904. /**
  27905. * Keep track of the image processing observer to allow dispose and replace.
  27906. */
  27907. private _imageProcessingObserver;
  27908. /**
  27909. * Attaches a new image processing configuration to the PBR Material.
  27910. * @param configuration
  27911. */
  27912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27913. /**
  27914. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27915. */
  27916. /**
  27917. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27918. */
  27919. colorCurves: Nullable<ColorCurves>;
  27920. /**
  27921. * Gets wether the color curves effect is enabled.
  27922. */
  27923. /**
  27924. * Sets wether the color curves effect is enabled.
  27925. */
  27926. colorCurvesEnabled: boolean;
  27927. /**
  27928. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27929. */
  27930. /**
  27931. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27932. */
  27933. colorGradingTexture: Nullable<BaseTexture>;
  27934. /**
  27935. * Gets wether the color grading effect is enabled.
  27936. */
  27937. /**
  27938. * Gets wether the color grading effect is enabled.
  27939. */
  27940. colorGradingEnabled: boolean;
  27941. /**
  27942. * Gets exposure used in the effect.
  27943. */
  27944. /**
  27945. * Sets exposure used in the effect.
  27946. */
  27947. exposure: number;
  27948. /**
  27949. * Gets wether tonemapping is enabled or not.
  27950. */
  27951. /**
  27952. * Sets wether tonemapping is enabled or not
  27953. */
  27954. toneMappingEnabled: boolean;
  27955. /**
  27956. * Gets contrast used in the effect.
  27957. */
  27958. /**
  27959. * Sets contrast used in the effect.
  27960. */
  27961. contrast: number;
  27962. /**
  27963. * Gets Vignette stretch size.
  27964. */
  27965. /**
  27966. * Sets Vignette stretch size.
  27967. */
  27968. vignetteStretch: number;
  27969. /**
  27970. * Gets Vignette centre X Offset.
  27971. */
  27972. /**
  27973. * Sets Vignette centre X Offset.
  27974. */
  27975. vignetteCentreX: number;
  27976. /**
  27977. * Gets Vignette centre Y Offset.
  27978. */
  27979. /**
  27980. * Sets Vignette centre Y Offset.
  27981. */
  27982. vignetteCentreY: number;
  27983. /**
  27984. * Gets Vignette weight or intensity of the vignette effect.
  27985. */
  27986. /**
  27987. * Sets Vignette weight or intensity of the vignette effect.
  27988. */
  27989. vignetteWeight: number;
  27990. /**
  27991. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27992. * if vignetteEnabled is set to true.
  27993. */
  27994. /**
  27995. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27996. * if vignetteEnabled is set to true.
  27997. */
  27998. vignetteColor: Color4;
  27999. /**
  28000. * Gets Camera field of view used by the Vignette effect.
  28001. */
  28002. /**
  28003. * Sets Camera field of view used by the Vignette effect.
  28004. */
  28005. vignetteCameraFov: number;
  28006. /**
  28007. * Gets the vignette blend mode allowing different kind of effect.
  28008. */
  28009. /**
  28010. * Sets the vignette blend mode allowing different kind of effect.
  28011. */
  28012. vignetteBlendMode: number;
  28013. /**
  28014. * Gets wether the vignette effect is enabled.
  28015. */
  28016. /**
  28017. * Sets wether the vignette effect is enabled.
  28018. */
  28019. vignetteEnabled: boolean;
  28020. private _fromLinearSpace;
  28021. /**
  28022. * Gets wether the input of the processing is in Gamma or Linear Space.
  28023. */
  28024. /**
  28025. * Sets wether the input of the processing is in Gamma or Linear Space.
  28026. */
  28027. fromLinearSpace: boolean;
  28028. /**
  28029. * Defines cache preventing GC.
  28030. */
  28031. private _defines;
  28032. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  28033. getClassName(): string;
  28034. protected _updateParameters(): void;
  28035. dispose(camera?: Camera): void;
  28036. }
  28037. }
  28038. declare module BABYLON {
  28039. class PassPostProcess extends PostProcess {
  28040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28041. }
  28042. }
  28043. declare module BABYLON {
  28044. type PostProcessOptions = {
  28045. width: number;
  28046. height: number;
  28047. };
  28048. /**
  28049. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28050. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28051. */
  28052. class PostProcess {
  28053. /** Name of the PostProcess. */
  28054. name: string;
  28055. /**
  28056. * Width of the texture to apply the post process on
  28057. */
  28058. width: number;
  28059. /**
  28060. * Height of the texture to apply the post process on
  28061. */
  28062. height: number;
  28063. /**
  28064. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28065. * @hidden
  28066. */
  28067. _outputTexture: Nullable<InternalTexture>;
  28068. /**
  28069. * Sampling mode used by the shader
  28070. * See https://doc.babylonjs.com/classes/3.1/texture
  28071. */
  28072. renderTargetSamplingMode: number;
  28073. /**
  28074. * Clear color to use when screen clearing
  28075. */
  28076. clearColor: Color4;
  28077. /**
  28078. * If the buffer needs to be cleared before applying the post process. (default: true)
  28079. * Should be set to false if shader will overwrite all previous pixels.
  28080. */
  28081. autoClear: boolean;
  28082. /**
  28083. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28084. */
  28085. alphaMode: number;
  28086. /**
  28087. * Sets the setAlphaBlendConstants of the babylon engine
  28088. */
  28089. alphaConstants: Color4;
  28090. /**
  28091. * Animations to be used for the post processing
  28092. */
  28093. animations: Animation[];
  28094. /**
  28095. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28096. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28097. */
  28098. enablePixelPerfectMode: boolean;
  28099. /**
  28100. * Force the postprocess to be applied without taking in account viewport
  28101. */
  28102. forceFullscreenViewport: boolean;
  28103. /**
  28104. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28105. *
  28106. * | Value | Type | Description |
  28107. * | ----- | ----------------------------------- | ----------- |
  28108. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28109. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28110. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28111. *
  28112. */
  28113. scaleMode: number;
  28114. /**
  28115. * Force textures to be a power of two (default: false)
  28116. */
  28117. alwaysForcePOT: boolean;
  28118. private _samples;
  28119. /**
  28120. * Number of sample textures (default: 1)
  28121. */
  28122. samples: number;
  28123. /**
  28124. * Modify the scale of the post process to be the same as the viewport (default: false)
  28125. */
  28126. adaptScaleToCurrentViewport: boolean;
  28127. private _camera;
  28128. private _scene;
  28129. private _engine;
  28130. private _options;
  28131. private _reusable;
  28132. private _textureType;
  28133. /**
  28134. * Smart array of input and output textures for the post process.
  28135. * @hidden
  28136. */
  28137. _textures: SmartArray<InternalTexture>;
  28138. /**
  28139. * The index in _textures that corresponds to the output texture.
  28140. * @hidden
  28141. */
  28142. _currentRenderTextureInd: number;
  28143. private _effect;
  28144. private _samplers;
  28145. private _fragmentUrl;
  28146. private _vertexUrl;
  28147. private _parameters;
  28148. private _scaleRatio;
  28149. protected _indexParameters: any;
  28150. private _shareOutputWithPostProcess;
  28151. private _texelSize;
  28152. private _forcedOutputTexture;
  28153. /**
  28154. * An event triggered when the postprocess is activated.
  28155. */
  28156. onActivateObservable: Observable<Camera>;
  28157. private _onActivateObserver;
  28158. /**
  28159. * A function that is added to the onActivateObservable
  28160. */
  28161. onActivate: Nullable<(camera: Camera) => void>;
  28162. /**
  28163. * An event triggered when the postprocess changes its size.
  28164. */
  28165. onSizeChangedObservable: Observable<PostProcess>;
  28166. private _onSizeChangedObserver;
  28167. /**
  28168. * A function that is added to the onSizeChangedObservable
  28169. */
  28170. onSizeChanged: (postProcess: PostProcess) => void;
  28171. /**
  28172. * An event triggered when the postprocess applies its effect.
  28173. */
  28174. onApplyObservable: Observable<Effect>;
  28175. private _onApplyObserver;
  28176. /**
  28177. * A function that is added to the onApplyObservable
  28178. */
  28179. onApply: (effect: Effect) => void;
  28180. /**
  28181. * An event triggered before rendering the postprocess
  28182. */
  28183. onBeforeRenderObservable: Observable<Effect>;
  28184. private _onBeforeRenderObserver;
  28185. /**
  28186. * A function that is added to the onBeforeRenderObservable
  28187. */
  28188. onBeforeRender: (effect: Effect) => void;
  28189. /**
  28190. * An event triggered after rendering the postprocess
  28191. */
  28192. onAfterRenderObservable: Observable<Effect>;
  28193. private _onAfterRenderObserver;
  28194. /**
  28195. * A function that is added to the onAfterRenderObservable
  28196. */
  28197. onAfterRender: (efect: Effect) => void;
  28198. /**
  28199. * 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
  28200. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28201. */
  28202. inputTexture: InternalTexture;
  28203. /**
  28204. * Gets the camera which post process is applied to.
  28205. * @returns The camera the post process is applied to.
  28206. */
  28207. getCamera(): Camera;
  28208. /**
  28209. * Gets the texel size of the postprocess.
  28210. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28211. */
  28212. readonly texelSize: Vector2;
  28213. /**
  28214. * Creates a new instance PostProcess
  28215. * @param name The name of the PostProcess.
  28216. * @param fragmentUrl The url of the fragment shader to be used.
  28217. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28218. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28219. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28220. * @param camera The camera to apply the render pass to.
  28221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28222. * @param engine The engine which the post process will be applied. (default: current engine)
  28223. * @param reusable If the post process can be reused on the same frame. (default: false)
  28224. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28225. * @param textureType Type of textures used when performing the post process. (default: 0)
  28226. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28227. * @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
  28228. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28229. */
  28230. constructor(
  28231. /** Name of the PostProcess. */
  28232. 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);
  28233. /**
  28234. * Gets the engine which this post process belongs to.
  28235. * @returns The engine the post process was enabled with.
  28236. */
  28237. getEngine(): Engine;
  28238. /**
  28239. * The effect that is created when initializing the post process.
  28240. * @returns The created effect corrisponding the the postprocess.
  28241. */
  28242. getEffect(): Effect;
  28243. /**
  28244. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28245. * @param postProcess The post process to share the output with.
  28246. * @returns This post process.
  28247. */
  28248. shareOutputWith(postProcess: PostProcess): PostProcess;
  28249. /**
  28250. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28251. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28252. */
  28253. useOwnOutput(): void;
  28254. /**
  28255. * Updates the effect with the current post process compile time values and recompiles the shader.
  28256. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28257. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28258. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28259. * @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
  28260. * @param onCompiled Called when the shader has been compiled.
  28261. * @param onError Called if there is an error when compiling a shader.
  28262. */
  28263. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28264. /**
  28265. * The post process is reusable if it can be used multiple times within one frame.
  28266. * @returns If the post process is reusable
  28267. */
  28268. isReusable(): boolean;
  28269. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28270. markTextureDirty(): void;
  28271. /**
  28272. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28273. * 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.
  28274. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28275. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28276. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28277. * @returns The target texture that was bound to be written to.
  28278. */
  28279. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28280. /**
  28281. * If the post process is supported.
  28282. */
  28283. readonly isSupported: boolean;
  28284. /**
  28285. * The aspect ratio of the output texture.
  28286. */
  28287. readonly aspectRatio: number;
  28288. /**
  28289. * Get a value indicating if the post-process is ready to be used
  28290. * @returns true if the post-process is ready (shader is compiled)
  28291. */
  28292. isReady(): boolean;
  28293. /**
  28294. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28295. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28296. */
  28297. apply(): Nullable<Effect>;
  28298. private _disposeTextures;
  28299. /**
  28300. * Disposes the post process.
  28301. * @param camera The camera to dispose the post process on.
  28302. */
  28303. dispose(camera?: Camera): void;
  28304. }
  28305. }
  28306. declare module BABYLON {
  28307. /**
  28308. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28309. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28310. */
  28311. class PostProcessManager {
  28312. private _scene;
  28313. private _indexBuffer;
  28314. private _vertexBuffers;
  28315. /**
  28316. * Creates a new instance PostProcess
  28317. * @param scene The scene that the post process is associated with.
  28318. */
  28319. constructor(scene: Scene);
  28320. private _prepareBuffers;
  28321. private _buildIndexBuffer;
  28322. /**
  28323. * Rebuilds the vertex buffers of the manager.
  28324. * @hidden
  28325. */
  28326. _rebuild(): void;
  28327. /**
  28328. * Prepares a frame to be run through a post process.
  28329. * @param sourceTexture The input texture to the post procesess. (default: null)
  28330. * @param postProcesses An array of post processes to be run. (default: null)
  28331. * @returns True if the post processes were able to be run.
  28332. * @hidden
  28333. */
  28334. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28335. /**
  28336. * Manually render a set of post processes to a texture.
  28337. * @param postProcesses An array of post processes to be run.
  28338. * @param targetTexture The target texture to render to.
  28339. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28340. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28341. * @param lodLevel defines which lod of the texture to render to
  28342. */
  28343. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28344. /**
  28345. * Finalize the result of the output of the postprocesses.
  28346. * @param doNotPresent If true the result will not be displayed to the screen.
  28347. * @param targetTexture The target texture to render to.
  28348. * @param faceIndex The index of the face to bind the target texture to.
  28349. * @param postProcesses The array of post processes to render.
  28350. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28351. * @hidden
  28352. */
  28353. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28354. /**
  28355. * Disposes of the post process manager.
  28356. */
  28357. dispose(): void;
  28358. }
  28359. }
  28360. declare module BABYLON {
  28361. class RefractionPostProcess extends PostProcess {
  28362. color: Color3;
  28363. depth: number;
  28364. colorLevel: number;
  28365. private _refTexture;
  28366. private _ownRefractionTexture;
  28367. /**
  28368. * Gets or sets the refraction texture
  28369. * Please note that you are responsible for disposing the texture if you set it manually
  28370. */
  28371. refractionTexture: Texture;
  28372. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28373. dispose(camera: Camera): void;
  28374. }
  28375. }
  28376. declare module BABYLON {
  28377. /**
  28378. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28379. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28380. */
  28381. class SharpenPostProcess extends PostProcess {
  28382. /**
  28383. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28384. */
  28385. colorAmount: number;
  28386. /**
  28387. * How much sharpness should be applied (default: 0.3)
  28388. */
  28389. edgeAmount: number;
  28390. /**
  28391. * Creates a new instance ConvolutionPostProcess
  28392. * @param name The name of the effect.
  28393. * @param options The required width/height ratio to downsize to before computing the render pass.
  28394. * @param camera The camera to apply the render pass to.
  28395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28396. * @param engine The engine which the post process will be applied. (default: current engine)
  28397. * @param reusable If the post process can be reused on the same frame. (default: false)
  28398. * @param textureType Type of textures used when performing the post process. (default: 0)
  28399. * @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)
  28400. */
  28401. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28402. }
  28403. }
  28404. declare module BABYLON {
  28405. class StereoscopicInterlacePostProcess extends PostProcess {
  28406. private _stepSize;
  28407. private _passedProcess;
  28408. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28409. }
  28410. }
  28411. declare module BABYLON {
  28412. /** Defines operator used for tonemapping */
  28413. enum TonemappingOperator {
  28414. /** Hable */
  28415. Hable = 0,
  28416. /** Reinhard */
  28417. Reinhard = 1,
  28418. /** HejiDawson */
  28419. HejiDawson = 2,
  28420. /** Photographic */
  28421. Photographic = 3
  28422. }
  28423. /**
  28424. * Defines a post process to apply tone mapping
  28425. */
  28426. class TonemapPostProcess extends PostProcess {
  28427. private _operator;
  28428. /** Defines the required exposure adjustement */
  28429. exposureAdjustment: number;
  28430. /**
  28431. * Creates a new TonemapPostProcess
  28432. * @param name defines the name of the postprocess
  28433. * @param _operator defines the operator to use
  28434. * @param exposureAdjustment defines the required exposure adjustement
  28435. * @param camera defines the camera to use (can be null)
  28436. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28437. * @param engine defines the hosting engine (can be ignore if camera is set)
  28438. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28439. */
  28440. constructor(name: string, _operator: TonemappingOperator,
  28441. /** Defines the required exposure adjustement */
  28442. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28443. }
  28444. }
  28445. declare module BABYLON {
  28446. class VolumetricLightScatteringPostProcess extends PostProcess {
  28447. private _volumetricLightScatteringPass;
  28448. private _volumetricLightScatteringRTT;
  28449. private _viewPort;
  28450. private _screenCoordinates;
  28451. private _cachedDefines;
  28452. /**
  28453. * If not undefined, the mesh position is computed from the attached node position
  28454. */
  28455. attachedNode: {
  28456. position: Vector3;
  28457. };
  28458. /**
  28459. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28460. */
  28461. customMeshPosition: Vector3;
  28462. /**
  28463. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28464. */
  28465. useCustomMeshPosition: boolean;
  28466. /**
  28467. * If the post-process should inverse the light scattering direction
  28468. */
  28469. invert: boolean;
  28470. /**
  28471. * The internal mesh used by the post-process
  28472. */
  28473. mesh: Mesh;
  28474. useDiffuseColor: boolean;
  28475. /**
  28476. * Array containing the excluded meshes not rendered in the internal pass
  28477. */
  28478. excludedMeshes: AbstractMesh[];
  28479. /**
  28480. * Controls the overall intensity of the post-process
  28481. */
  28482. exposure: number;
  28483. /**
  28484. * Dissipates each sample's contribution in range [0, 1]
  28485. */
  28486. decay: number;
  28487. /**
  28488. * Controls the overall intensity of each sample
  28489. */
  28490. weight: number;
  28491. /**
  28492. * Controls the density of each sample
  28493. */
  28494. density: number;
  28495. /**
  28496. * @constructor
  28497. * @param {string} name - The post-process name
  28498. * @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)
  28499. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28500. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28501. * @param {number} samples - The post-process quality, default 100
  28502. * @param {number} samplingMode - The post-process filtering mode
  28503. * @param {BABYLON.Engine} engine - The babylon engine
  28504. * @param {boolean} reusable - If the post-process is reusable
  28505. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28506. */
  28507. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28508. getClassName(): string;
  28509. private _isReady;
  28510. /**
  28511. * Sets the new light position for light scattering effect
  28512. * @param {BABYLON.Vector3} The new custom light position
  28513. */
  28514. setCustomMeshPosition(position: Vector3): void;
  28515. /**
  28516. * Returns the light position for light scattering effect
  28517. * @return {BABYLON.Vector3} The custom light position
  28518. */
  28519. getCustomMeshPosition(): Vector3;
  28520. /**
  28521. * Disposes the internal assets and detaches the post-process from the camera
  28522. */
  28523. dispose(camera: Camera): void;
  28524. /**
  28525. * Returns the render target texture used by the post-process
  28526. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28527. */
  28528. getPass(): RenderTargetTexture;
  28529. private _meshExcluded;
  28530. private _createPass;
  28531. private _updateMeshScreenCoordinates;
  28532. /**
  28533. * Creates a default mesh for the Volumeric Light Scattering post-process
  28534. * @param {string} The mesh name
  28535. * @param {BABYLON.Scene} The scene where to create the mesh
  28536. * @return {BABYLON.Mesh} the default mesh
  28537. */
  28538. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28539. }
  28540. }
  28541. declare module BABYLON {
  28542. class VRDistortionCorrectionPostProcess extends PostProcess {
  28543. private _isRightEye;
  28544. private _distortionFactors;
  28545. private _postProcessScaleFactor;
  28546. private _lensCenterOffset;
  28547. private _scaleIn;
  28548. private _scaleFactor;
  28549. private _lensCenter;
  28550. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28551. }
  28552. }
  28553. declare module BABYLON {
  28554. /**
  28555. * Class used to generate realtime reflection / refraction cube textures
  28556. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  28557. */
  28558. class ReflectionProbe {
  28559. /** defines the name of the probe */
  28560. name: string;
  28561. private _scene;
  28562. private _renderTargetTexture;
  28563. private _projectionMatrix;
  28564. private _viewMatrix;
  28565. private _target;
  28566. private _add;
  28567. private _attachedMesh;
  28568. private _invertYAxis;
  28569. /** Gets or sets probe position (center of the cube map) */
  28570. position: Vector3;
  28571. /**
  28572. * Creates a new reflection probe
  28573. * @param name defines the name of the probe
  28574. * @param size defines the texture resolution (for each face)
  28575. * @param scene defines the hosting scene
  28576. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  28577. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  28578. */
  28579. constructor(
  28580. /** defines the name of the probe */
  28581. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  28582. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  28583. samples: number;
  28584. /** Gets or sets the refresh rate to use (on every frame by default) */
  28585. refreshRate: number;
  28586. /**
  28587. * Gets the hosting scene
  28588. * @returns a Scene
  28589. */
  28590. getScene(): Scene;
  28591. /** Gets the internal CubeTexture used to render to */
  28592. readonly cubeTexture: RenderTargetTexture;
  28593. /** Gets the list of meshes to render */
  28594. readonly renderList: Nullable<AbstractMesh[]>;
  28595. /**
  28596. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  28597. * @param mesh defines the mesh to attach to
  28598. */
  28599. attachToMesh(mesh: AbstractMesh): void;
  28600. /**
  28601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  28602. * @param renderingGroupId The rendering group id corresponding to its index
  28603. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28604. */
  28605. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28606. /**
  28607. * Clean all associated resources
  28608. */
  28609. dispose(): void;
  28610. }
  28611. }
  28612. declare module BABYLON {
  28613. interface Scene {
  28614. /** @hidden (Backing field) */
  28615. _boundingBoxRenderer: BoundingBoxRenderer;
  28616. /** @hidden (Backing field) */
  28617. _forceShowBoundingBoxes: boolean;
  28618. /**
  28619. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28620. */
  28621. forceShowBoundingBoxes: boolean;
  28622. /**
  28623. * Gets the bounding box renderer associated with the scene
  28624. * @returns a BoundingBoxRenderer
  28625. */
  28626. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28627. }
  28628. interface AbstractMesh {
  28629. /** @hidden (Backing field) */
  28630. _showBoundingBox: boolean;
  28631. /**
  28632. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28633. */
  28634. showBoundingBox: boolean;
  28635. }
  28636. class BoundingBoxRenderer implements ISceneComponent {
  28637. /**
  28638. * The component name helpfull to identify the component in the list of scene components.
  28639. */
  28640. readonly name: string;
  28641. /**
  28642. * The scene the component belongs to.
  28643. */
  28644. scene: Scene;
  28645. frontColor: Color3;
  28646. backColor: Color3;
  28647. showBackLines: boolean;
  28648. renderList: SmartArray<BoundingBox>;
  28649. private _colorShader;
  28650. private _vertexBuffers;
  28651. private _indexBuffer;
  28652. constructor(scene: Scene);
  28653. /**
  28654. * Registers the component in a given scene
  28655. */
  28656. register(): void;
  28657. private _evaluateSubMesh;
  28658. private _activeMesh;
  28659. private _prepareRessources;
  28660. private _createIndexBuffer;
  28661. /**
  28662. * Rebuilds the elements related to this component in case of
  28663. * context lost for instance.
  28664. */
  28665. rebuild(): void;
  28666. reset(): void;
  28667. render(): void;
  28668. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28669. dispose(): void;
  28670. }
  28671. }
  28672. declare module BABYLON {
  28673. /**
  28674. * This represents a depth renderer in Babylon.
  28675. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28676. */
  28677. class DepthRenderer {
  28678. private _scene;
  28679. private _depthMap;
  28680. private _effect;
  28681. private _cachedDefines;
  28682. private _camera;
  28683. /**
  28684. * Instantiates a depth renderer
  28685. * @param scene The scene the renderer belongs to
  28686. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28687. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28688. */
  28689. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28690. /**
  28691. * Creates the depth rendering effect and checks if the effect is ready.
  28692. * @param subMesh The submesh to be used to render the depth map of
  28693. * @param useInstances If multiple world instances should be used
  28694. * @returns if the depth renderer is ready to render the depth map
  28695. */
  28696. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28697. /**
  28698. * Gets the texture which the depth map will be written to.
  28699. * @returns The depth map texture
  28700. */
  28701. getDepthMap(): RenderTargetTexture;
  28702. /**
  28703. * Disposes of the depth renderer.
  28704. */
  28705. dispose(): void;
  28706. }
  28707. }
  28708. declare module BABYLON {
  28709. interface Scene {
  28710. /** @hidden (Backing field) */
  28711. _depthRenderer: {
  28712. [id: string]: DepthRenderer;
  28713. };
  28714. /**
  28715. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  28716. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  28717. * @returns the created depth renderer
  28718. */
  28719. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  28720. /**
  28721. * Disables a depth renderer for a given camera
  28722. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  28723. */
  28724. disableDepthRenderer(camera?: Nullable<Camera>): void;
  28725. }
  28726. /**
  28727. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  28728. * in several rendering techniques.
  28729. */
  28730. class DepthRendererSceneComponent implements ISceneComponent {
  28731. /**
  28732. * The component name helpfull to identify the component in the list of scene components.
  28733. */
  28734. readonly name: string;
  28735. /**
  28736. * The scene the component belongs to.
  28737. */
  28738. scene: Scene;
  28739. /**
  28740. * Creates a new instance of the component for the given scene
  28741. * @param scene Defines the scene to register the component in
  28742. */
  28743. constructor(scene: Scene);
  28744. /**
  28745. * Registers the component in a given scene
  28746. */
  28747. register(): void;
  28748. /**
  28749. * Rebuilds the elements related to this component in case of
  28750. * context lost for instance.
  28751. */
  28752. rebuild(): void;
  28753. /**
  28754. * Disposes the component and the associated ressources
  28755. */
  28756. dispose(): void;
  28757. private _gatherRenderTargets;
  28758. }
  28759. }
  28760. declare module BABYLON {
  28761. /**
  28762. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28763. */
  28764. class EdgesRenderer {
  28765. edgesWidthScalerForOrthographic: number;
  28766. edgesWidthScalerForPerspective: number;
  28767. protected _source: AbstractMesh;
  28768. protected _linesPositions: number[];
  28769. protected _linesNormals: number[];
  28770. protected _linesIndices: number[];
  28771. protected _epsilon: number;
  28772. protected _indicesCount: number;
  28773. protected _lineShader: ShaderMaterial;
  28774. protected _ib: WebGLBuffer;
  28775. protected _buffers: {
  28776. [key: string]: Nullable<VertexBuffer>;
  28777. };
  28778. protected _checkVerticesInsteadOfIndices: boolean;
  28779. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28780. isEnabled: boolean;
  28781. /**
  28782. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28783. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28784. * @param source Mesh used to create edges
  28785. * @param epsilon sum of angles in adjacency to check for edge
  28786. * @param checkVerticesInsteadOfIndices
  28787. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28788. */
  28789. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  28790. protected _prepareRessources(): void;
  28791. /** @hidden */
  28792. _rebuild(): void;
  28793. /**
  28794. * Releases the required resources for the edges renderer
  28795. */
  28796. dispose(): void;
  28797. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28798. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28799. /**
  28800. * Checks if the pair of p0 and p1 is en edge
  28801. * @param faceIndex
  28802. * @param edge
  28803. * @param faceNormals
  28804. * @param p0
  28805. * @param p1
  28806. * @private
  28807. */
  28808. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28809. /**
  28810. * Generates lines edges from adjacencjes
  28811. * @private
  28812. */
  28813. _generateEdgesLines(): void;
  28814. render(): void;
  28815. }
  28816. }
  28817. declare module BABYLON {
  28818. /**
  28819. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28820. */
  28821. class GeometryBufferRenderer {
  28822. private _scene;
  28823. private _multiRenderTarget;
  28824. private _ratio;
  28825. private _enablePosition;
  28826. protected _effect: Effect;
  28827. protected _cachedDefines: string;
  28828. /**
  28829. * Set the render list (meshes to be rendered) used in the G buffer.
  28830. */
  28831. renderList: Mesh[];
  28832. /**
  28833. * Gets wether or not G buffer are supported by the running hardware.
  28834. * This requires draw buffer supports
  28835. */
  28836. readonly isSupported: boolean;
  28837. /**
  28838. * Gets wether or not position are enabled for the G buffer.
  28839. */
  28840. /**
  28841. * Sets wether or not position are enabled for the G buffer.
  28842. */
  28843. enablePosition: boolean;
  28844. /**
  28845. * Gets the scene associated with the buffer.
  28846. */
  28847. readonly scene: Scene;
  28848. /**
  28849. * Gets the ratio used by the buffer during its creation.
  28850. * How big is the buffer related to the main canvas.
  28851. */
  28852. readonly ratio: number;
  28853. /**
  28854. * Creates a new G Buffer for the scene
  28855. * @param scene The scene the buffer belongs to
  28856. * @param ratio How big is the buffer related to the main canvas.
  28857. */
  28858. constructor(scene: Scene, ratio?: number);
  28859. /**
  28860. * Checks wether everything is ready to render a submesh to the G buffer.
  28861. * @param subMesh the submesh to check readiness for
  28862. * @param useInstances is the mesh drawn using instance or not
  28863. * @returns true if ready otherwise false
  28864. */
  28865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28866. /**
  28867. * Gets the current underlying G Buffer.
  28868. * @returns the buffer
  28869. */
  28870. getGBuffer(): MultiRenderTarget;
  28871. /**
  28872. * Gets the number of samples used to render the buffer (anti aliasing).
  28873. */
  28874. /**
  28875. * Sets the number of samples used to render the buffer (anti aliasing).
  28876. */
  28877. samples: number;
  28878. /**
  28879. * Disposes the renderer and frees up associated resources.
  28880. */
  28881. dispose(): void;
  28882. protected _createRenderTargets(): void;
  28883. }
  28884. }
  28885. declare module BABYLON {
  28886. interface Scene {
  28887. /** @hidden (Backing field) */
  28888. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28889. /**
  28890. * Gets or Sets the current geometry buffer associated to the scene.
  28891. */
  28892. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28893. /**
  28894. * Enables a GeometryBufferRender and associates it with the scene
  28895. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  28896. * @returns the GeometryBufferRenderer
  28897. */
  28898. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  28899. /**
  28900. * Disables the GeometryBufferRender associated with the scene
  28901. */
  28902. disableGeometryBufferRenderer(): void;
  28903. }
  28904. /**
  28905. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  28906. * in several rendering techniques.
  28907. */
  28908. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  28909. /**
  28910. * The component name helpfull to identify the component in the list of scene components.
  28911. */
  28912. readonly name: string;
  28913. /**
  28914. * The scene the component belongs to.
  28915. */
  28916. scene: Scene;
  28917. /**
  28918. * Creates a new instance of the component for the given scene
  28919. * @param scene Defines the scene to register the component in
  28920. */
  28921. constructor(scene: Scene);
  28922. /**
  28923. * Registers the component in a given scene
  28924. */
  28925. register(): void;
  28926. /**
  28927. * Rebuilds the elements related to this component in case of
  28928. * context lost for instance.
  28929. */
  28930. rebuild(): void;
  28931. /**
  28932. * Disposes the component and the associated ressources
  28933. */
  28934. dispose(): void;
  28935. private _gatherRenderTargets;
  28936. }
  28937. }
  28938. declare module BABYLON {
  28939. /**
  28940. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28941. */
  28942. class LineEdgesRenderer extends EdgesRenderer {
  28943. /**
  28944. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28945. * @param source LineMesh used to generate edges
  28946. * @param epsilon not important (specified angle for edge detection)
  28947. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28948. */
  28949. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28950. /**
  28951. * Always create the edge since its a line so only important things are p0 and p1
  28952. * @param faceIndex not important for LineMesh
  28953. * @param edge not important for LineMesh
  28954. * @param faceNormals not important for LineMesh
  28955. * @param p0 beginnig of line
  28956. * @param p1 end of line
  28957. */
  28958. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28959. /**
  28960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28961. */
  28962. _generateEdgesLines(): void;
  28963. }
  28964. }
  28965. declare module BABYLON {
  28966. class OutlineRenderer {
  28967. private _scene;
  28968. private _effect;
  28969. private _cachedDefines;
  28970. zOffset: number;
  28971. constructor(scene: Scene);
  28972. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  28973. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. class RenderingGroup {
  28978. index: number;
  28979. private _scene;
  28980. private _opaqueSubMeshes;
  28981. private _transparentSubMeshes;
  28982. private _alphaTestSubMeshes;
  28983. private _depthOnlySubMeshes;
  28984. private _particleSystems;
  28985. private _spriteManagers;
  28986. private _opaqueSortCompareFn;
  28987. private _alphaTestSortCompareFn;
  28988. private _transparentSortCompareFn;
  28989. private _renderOpaque;
  28990. private _renderAlphaTest;
  28991. private _renderTransparent;
  28992. private _edgesRenderers;
  28993. onBeforeTransparentRendering: () => void;
  28994. /**
  28995. * Set the opaque sort comparison function.
  28996. * If null the sub meshes will be render in the order they were created
  28997. */
  28998. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28999. /**
  29000. * Set the alpha test sort comparison function.
  29001. * If null the sub meshes will be render in the order they were created
  29002. */
  29003. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29004. /**
  29005. * Set the transparent sort comparison function.
  29006. * If null the sub meshes will be render in the order they were created
  29007. */
  29008. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29009. /**
  29010. * Creates a new rendering group.
  29011. * @param index The rendering group index
  29012. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29013. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29014. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29015. */
  29016. 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>);
  29017. /**
  29018. * Render all the sub meshes contained in the group.
  29019. * @param customRenderFunction Used to override the default render behaviour of the group.
  29020. * @returns true if rendered some submeshes.
  29021. */
  29022. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29023. /**
  29024. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29025. * @param subMeshes The submeshes to render
  29026. */
  29027. private renderOpaqueSorted;
  29028. /**
  29029. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29030. * @param subMeshes The submeshes to render
  29031. */
  29032. private renderAlphaTestSorted;
  29033. /**
  29034. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29035. * @param subMeshes The submeshes to render
  29036. */
  29037. private renderTransparentSorted;
  29038. /**
  29039. * Renders the submeshes in a specified order.
  29040. * @param subMeshes The submeshes to sort before render
  29041. * @param sortCompareFn The comparison function use to sort
  29042. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29043. * @param transparent Specifies to activate blending if true
  29044. */
  29045. private static renderSorted;
  29046. /**
  29047. * Renders the submeshes in the order they were dispatched (no sort applied).
  29048. * @param subMeshes The submeshes to render
  29049. */
  29050. private static renderUnsorted;
  29051. /**
  29052. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29053. * are rendered back to front if in the same alpha index.
  29054. *
  29055. * @param a The first submesh
  29056. * @param b The second submesh
  29057. * @returns The result of the comparison
  29058. */
  29059. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29060. /**
  29061. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29062. * are rendered back to front.
  29063. *
  29064. * @param a The first submesh
  29065. * @param b The second submesh
  29066. * @returns The result of the comparison
  29067. */
  29068. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29069. /**
  29070. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29071. * are rendered front to back (prevent overdraw).
  29072. *
  29073. * @param a The first submesh
  29074. * @param b The second submesh
  29075. * @returns The result of the comparison
  29076. */
  29077. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29078. /**
  29079. * Resets the different lists of submeshes to prepare a new frame.
  29080. */
  29081. prepare(): void;
  29082. dispose(): void;
  29083. /**
  29084. * Inserts the submesh in its correct queue depending on its material.
  29085. * @param subMesh The submesh to dispatch
  29086. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29087. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29088. */
  29089. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29090. dispatchSprites(spriteManager: ISpriteManager): void;
  29091. dispatchParticles(particleSystem: IParticleSystem): void;
  29092. private _renderParticles;
  29093. private _renderSprites;
  29094. }
  29095. }
  29096. declare module BABYLON {
  29097. /**
  29098. * Interface describing the different options available in the rendering manager
  29099. * regarding Auto Clear between groups.
  29100. */
  29101. interface IRenderingManagerAutoClearSetup {
  29102. /**
  29103. * Defines whether or not autoclear is enable.
  29104. */
  29105. autoClear: boolean;
  29106. /**
  29107. * Defines whether or not to autoclear the depth buffer.
  29108. */
  29109. depth: boolean;
  29110. /**
  29111. * Defines whether or not to autoclear the stencil buffer.
  29112. */
  29113. stencil: boolean;
  29114. }
  29115. class RenderingManager {
  29116. /**
  29117. * The max id used for rendering groups (not included)
  29118. */
  29119. static MAX_RENDERINGGROUPS: number;
  29120. /**
  29121. * The min id used for rendering groups (included)
  29122. */
  29123. static MIN_RENDERINGGROUPS: number;
  29124. /**
  29125. * Used to globally prevent autoclearing scenes.
  29126. */
  29127. static AUTOCLEAR: boolean;
  29128. /**
  29129. * @hidden
  29130. */
  29131. _useSceneAutoClearSetup: boolean;
  29132. private _scene;
  29133. private _renderingGroups;
  29134. private _depthStencilBufferAlreadyCleaned;
  29135. private _autoClearDepthStencil;
  29136. private _customOpaqueSortCompareFn;
  29137. private _customAlphaTestSortCompareFn;
  29138. private _customTransparentSortCompareFn;
  29139. private _renderingGroupInfo;
  29140. constructor(scene: Scene);
  29141. private _clearDepthStencilBuffer;
  29142. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29143. reset(): void;
  29144. dispose(): void;
  29145. /**
  29146. * Clear the info related to rendering groups preventing retention points during dispose.
  29147. */
  29148. freeRenderingGroups(): void;
  29149. private _prepareRenderingGroup;
  29150. dispatchSprites(spriteManager: ISpriteManager): void;
  29151. dispatchParticles(particleSystem: IParticleSystem): void;
  29152. /**
  29153. * @param subMesh The submesh to dispatch
  29154. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29155. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29156. */
  29157. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29158. /**
  29159. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29160. * This allowed control for front to back rendering or reversly depending of the special needs.
  29161. *
  29162. * @param renderingGroupId The rendering group id corresponding to its index
  29163. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29164. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29165. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29166. */
  29167. 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;
  29168. /**
  29169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29170. *
  29171. * @param renderingGroupId The rendering group id corresponding to its index
  29172. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29173. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29174. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29175. */
  29176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29177. /**
  29178. * Gets the current auto clear configuration for one rendering group of the rendering
  29179. * manager.
  29180. * @param index the rendering group index to get the information for
  29181. * @returns The auto clear setup for the requested rendering group
  29182. */
  29183. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29184. }
  29185. }
  29186. declare module BABYLON {
  29187. /**
  29188. * Renders a layer on top of an existing scene
  29189. */
  29190. class UtilityLayerRenderer implements IDisposable {
  29191. /** the original scene that will be rendered on top of */
  29192. originalScene: Scene;
  29193. private _pointerCaptures;
  29194. private _lastPointerEvents;
  29195. private static _DefaultUtilityLayer;
  29196. private static _DefaultKeepDepthUtilityLayer;
  29197. /**
  29198. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  29199. */
  29200. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29201. /**
  29202. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  29203. */
  29204. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29205. /**
  29206. * The scene that is rendered on top of the original scene
  29207. */
  29208. utilityLayerScene: Scene;
  29209. /**
  29210. * If the utility layer should automatically be rendered on top of existing scene
  29211. */
  29212. shouldRender: boolean;
  29213. /**
  29214. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29215. */
  29216. onlyCheckPointerDownEvents: boolean;
  29217. /**
  29218. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29219. */
  29220. processAllEvents: boolean;
  29221. /**
  29222. * Observable raised when the pointer move from the utility layer scene to the main scene
  29223. */
  29224. onPointerOutObservable: Observable<number>;
  29225. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29226. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29227. private _afterRenderObserver;
  29228. private _sceneDisposeObserver;
  29229. private _originalPointerObserver;
  29230. /**
  29231. * Instantiates a UtilityLayerRenderer
  29232. * @param originalScene the original scene that will be rendered on top of
  29233. */
  29234. constructor(
  29235. /** the original scene that will be rendered on top of */
  29236. originalScene: Scene);
  29237. private _notifyObservers;
  29238. /**
  29239. * Renders the utility layers scene on top of the original scene
  29240. */
  29241. render(): void;
  29242. /**
  29243. * Disposes of the renderer
  29244. */
  29245. dispose(): void;
  29246. private _updateCamera;
  29247. }
  29248. }
  29249. declare module BABYLON {
  29250. class Sprite {
  29251. name: string;
  29252. position: Vector3;
  29253. color: Color4;
  29254. width: number;
  29255. height: number;
  29256. angle: number;
  29257. cellIndex: number;
  29258. invertU: number;
  29259. invertV: number;
  29260. disposeWhenFinishedAnimating: boolean;
  29261. animations: Animation[];
  29262. isPickable: boolean;
  29263. actionManager: ActionManager;
  29264. private _animationStarted;
  29265. private _loopAnimation;
  29266. private _fromIndex;
  29267. private _toIndex;
  29268. private _delay;
  29269. private _direction;
  29270. private _manager;
  29271. private _time;
  29272. private _onAnimationEnd;
  29273. /**
  29274. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  29275. */
  29276. isVisible: boolean;
  29277. size: number;
  29278. constructor(name: string, manager: ISpriteManager);
  29279. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29280. stopAnimation(): void;
  29281. /** @hidden */
  29282. _animate(deltaTime: number): void;
  29283. dispose(): void;
  29284. }
  29285. }
  29286. declare module BABYLON {
  29287. /**
  29288. * Defines the minimum interface to fullfil in order to be a sprite manager.
  29289. */
  29290. interface ISpriteManager extends IDisposable {
  29291. /**
  29292. * Restricts the camera to viewing objects with the same layerMask.
  29293. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  29294. */
  29295. layerMask: number;
  29296. /**
  29297. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29298. */
  29299. isPickable: boolean;
  29300. /**
  29301. * Specifies the rendering group id for this mesh (0 by default)
  29302. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29303. */
  29304. renderingGroupId: number;
  29305. /**
  29306. * Defines the list of sprites managed by the manager.
  29307. */
  29308. sprites: Array<Sprite>;
  29309. /**
  29310. * Tests the intersection of a sprite with a specific ray.
  29311. * @param ray The ray we are sending to test the collision
  29312. * @param camera The camera space we are sending rays in
  29313. * @param predicate A predicate allowing excluding sprites from the list of object to test
  29314. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  29315. * @returns picking info or null.
  29316. */
  29317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29318. /**
  29319. * Renders the list of sprites on screen.
  29320. */
  29321. render(): void;
  29322. }
  29323. class SpriteManager implements ISpriteManager {
  29324. name: string;
  29325. sprites: Sprite[];
  29326. renderingGroupId: number;
  29327. layerMask: number;
  29328. fogEnabled: boolean;
  29329. isPickable: boolean;
  29330. cellWidth: number;
  29331. cellHeight: number;
  29332. /**
  29333. * An event triggered when the manager is disposed.
  29334. */
  29335. onDisposeObservable: Observable<SpriteManager>;
  29336. private _onDisposeObserver;
  29337. onDispose: () => void;
  29338. private _capacity;
  29339. private _spriteTexture;
  29340. private _epsilon;
  29341. private _scene;
  29342. private _vertexData;
  29343. private _buffer;
  29344. private _vertexBuffers;
  29345. private _indexBuffer;
  29346. private _effectBase;
  29347. private _effectFog;
  29348. texture: Texture;
  29349. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29350. private _appendSpriteVertex;
  29351. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29352. render(): void;
  29353. dispose(): void;
  29354. }
  29355. }
  29356. declare module BABYLON {
  29357. interface Scene {
  29358. /** @hidden */
  29359. _pointerOverSprite: Nullable<Sprite>;
  29360. /** @hidden */
  29361. _pickedDownSprite: Nullable<Sprite>;
  29362. /** @hidden */
  29363. _tempSpritePickingRay: Nullable<Ray>;
  29364. /**
  29365. * All of the sprite managers added to this scene
  29366. * @see http://doc.babylonjs.com/babylon101/sprites
  29367. */
  29368. spriteManagers: Array<ISpriteManager>;
  29369. /**
  29370. * An event triggered when sprites rendering is about to start
  29371. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29372. */
  29373. onBeforeSpritesRenderingObservable: Observable<Scene>;
  29374. /**
  29375. * An event triggered when sprites rendering is done
  29376. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29377. */
  29378. onAfterSpritesRenderingObservable: Observable<Scene>;
  29379. /** @hidden */
  29380. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29381. /** Launch a ray to try to pick a sprite in the scene
  29382. * @param x position on screen
  29383. * @param y position on screen
  29384. * @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
  29385. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29386. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  29387. * @returns a PickingInfo
  29388. */
  29389. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29390. /** Use the given ray to pick a sprite in the scene
  29391. * @param ray The ray (in world space) to use to pick meshes
  29392. * @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
  29393. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29394. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  29395. * @returns a PickingInfo
  29396. */
  29397. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29398. /**
  29399. * Force the sprite under the pointer
  29400. * @param sprite defines the sprite to use
  29401. */
  29402. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  29403. /**
  29404. * Gets the sprite under the pointer
  29405. * @returns a Sprite or null if no sprite is under the pointer
  29406. */
  29407. getPointerOverSprite(): Nullable<Sprite>;
  29408. }
  29409. /**
  29410. * Defines the sprite scene component responsible to manage sprites
  29411. * in a given scene.
  29412. */
  29413. class SpriteSceneComponent implements ISceneComponent {
  29414. /**
  29415. * The component name helpfull to identify the component in the list of scene components.
  29416. */
  29417. readonly name: string;
  29418. /**
  29419. * The scene the component belongs to.
  29420. */
  29421. scene: Scene;
  29422. /** @hidden */
  29423. private _spritePredicate;
  29424. /**
  29425. * Creates a new instance of the component for the given scene
  29426. * @param scene Defines the scene to register the component in
  29427. */
  29428. constructor(scene: Scene);
  29429. /**
  29430. * Registers the component in a given scene
  29431. */
  29432. register(): void;
  29433. /**
  29434. * Rebuilds the elements related to this component in case of
  29435. * context lost for instance.
  29436. */
  29437. rebuild(): void;
  29438. /**
  29439. * Disposes the component and the associated ressources.
  29440. */
  29441. dispose(): void;
  29442. private _pickSpriteButKeepRay;
  29443. private _pointerMove;
  29444. private _pointerDown;
  29445. private _pointerUp;
  29446. }
  29447. }
  29448. declare module BABYLON {
  29449. /**
  29450. * @hidden
  29451. **/
  29452. class _AlphaState {
  29453. private _isAlphaBlendDirty;
  29454. private _isBlendFunctionParametersDirty;
  29455. private _isBlendEquationParametersDirty;
  29456. private _isBlendConstantsDirty;
  29457. private _alphaBlend;
  29458. private _blendFunctionParameters;
  29459. private _blendEquationParameters;
  29460. private _blendConstants;
  29461. /**
  29462. * Initializes the state.
  29463. */
  29464. constructor();
  29465. readonly isDirty: boolean;
  29466. alphaBlend: boolean;
  29467. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29468. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29469. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29470. reset(): void;
  29471. apply(gl: WebGLRenderingContext): void;
  29472. }
  29473. }
  29474. declare module BABYLON {
  29475. /**
  29476. * @hidden
  29477. **/
  29478. class _DepthCullingState {
  29479. private _isDepthTestDirty;
  29480. private _isDepthMaskDirty;
  29481. private _isDepthFuncDirty;
  29482. private _isCullFaceDirty;
  29483. private _isCullDirty;
  29484. private _isZOffsetDirty;
  29485. private _isFrontFaceDirty;
  29486. private _depthTest;
  29487. private _depthMask;
  29488. private _depthFunc;
  29489. private _cull;
  29490. private _cullFace;
  29491. private _zOffset;
  29492. private _frontFace;
  29493. /**
  29494. * Initializes the state.
  29495. */
  29496. constructor();
  29497. readonly isDirty: boolean;
  29498. zOffset: number;
  29499. cullFace: Nullable<number>;
  29500. cull: Nullable<boolean>;
  29501. depthFunc: Nullable<number>;
  29502. depthMask: boolean;
  29503. depthTest: boolean;
  29504. frontFace: Nullable<number>;
  29505. reset(): void;
  29506. apply(gl: WebGLRenderingContext): void;
  29507. }
  29508. }
  29509. declare module BABYLON {
  29510. /**
  29511. * @hidden
  29512. **/
  29513. class _StencilState {
  29514. private _isStencilTestDirty;
  29515. private _isStencilMaskDirty;
  29516. private _isStencilFuncDirty;
  29517. private _isStencilOpDirty;
  29518. private _stencilTest;
  29519. private _stencilMask;
  29520. private _stencilFunc;
  29521. private _stencilFuncRef;
  29522. private _stencilFuncMask;
  29523. private _stencilOpStencilFail;
  29524. private _stencilOpDepthFail;
  29525. private _stencilOpStencilDepthPass;
  29526. readonly isDirty: boolean;
  29527. stencilFunc: number;
  29528. stencilFuncRef: number;
  29529. stencilFuncMask: number;
  29530. stencilOpStencilFail: number;
  29531. stencilOpDepthFail: number;
  29532. stencilOpStencilDepthPass: number;
  29533. stencilMask: number;
  29534. stencilTest: boolean;
  29535. constructor();
  29536. reset(): void;
  29537. apply(gl: WebGLRenderingContext): void;
  29538. }
  29539. }
  29540. declare module BABYLON {
  29541. /**
  29542. * Class used to evalaute queries containing `and` and `or` operators
  29543. */
  29544. class AndOrNotEvaluator {
  29545. /**
  29546. * Evaluate a query
  29547. * @param query defines the query to evaluate
  29548. * @param evaluateCallback defines the callback used to filter result
  29549. * @returns true if the query matches
  29550. */
  29551. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29552. private static _HandleParenthesisContent;
  29553. private static _SimplifyNegation;
  29554. }
  29555. }
  29556. declare module BABYLON {
  29557. /**
  29558. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29559. */
  29560. enum AssetTaskState {
  29561. /**
  29562. * Initialization
  29563. */
  29564. INIT = 0,
  29565. /**
  29566. * Running
  29567. */
  29568. RUNNING = 1,
  29569. /**
  29570. * Done
  29571. */
  29572. DONE = 2,
  29573. /**
  29574. * Error
  29575. */
  29576. ERROR = 3
  29577. }
  29578. /**
  29579. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29580. */
  29581. abstract class AbstractAssetTask {
  29582. /**
  29583. * Task name
  29584. */ name: string;
  29585. /**
  29586. * Callback called when the task is successful
  29587. */
  29588. onSuccess: (task: any) => void;
  29589. /**
  29590. * Callback called when the task is not successful
  29591. */
  29592. onError: (task: any, message?: string, exception?: any) => void;
  29593. /**
  29594. * Creates a new {BABYLON.AssetsManager}
  29595. * @param name defines the name of the task
  29596. */
  29597. constructor(
  29598. /**
  29599. * Task name
  29600. */ name: string);
  29601. private _isCompleted;
  29602. private _taskState;
  29603. private _errorObject;
  29604. /**
  29605. * Get if the task is completed
  29606. */
  29607. readonly isCompleted: boolean;
  29608. /**
  29609. * Gets the current state of the task
  29610. */
  29611. readonly taskState: AssetTaskState;
  29612. /**
  29613. * Gets the current error object (if task is in error)
  29614. */
  29615. readonly errorObject: {
  29616. message?: string;
  29617. exception?: any;
  29618. };
  29619. /**
  29620. * Internal only
  29621. * @hidden
  29622. */
  29623. _setErrorObject(message?: string, exception?: any): void;
  29624. /**
  29625. * Execute the current task
  29626. * @param scene defines the scene where you want your assets to be loaded
  29627. * @param onSuccess is a callback called when the task is successfully executed
  29628. * @param onError is a callback called if an error occurs
  29629. */
  29630. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29631. /**
  29632. * Execute the current task
  29633. * @param scene defines the scene where you want your assets to be loaded
  29634. * @param onSuccess is a callback called when the task is successfully executed
  29635. * @param onError is a callback called if an error occurs
  29636. */
  29637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29638. /**
  29639. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  29640. * This can be used with failed tasks that have the reason for failure fixed.
  29641. */
  29642. reset(): void;
  29643. private onErrorCallback;
  29644. private onDoneCallback;
  29645. }
  29646. /**
  29647. * Define the interface used by progress events raised during assets loading
  29648. */
  29649. interface IAssetsProgressEvent {
  29650. /**
  29651. * Defines the number of remaining tasks to process
  29652. */
  29653. remainingCount: number;
  29654. /**
  29655. * Defines the total number of tasks
  29656. */
  29657. totalCount: number;
  29658. /**
  29659. * Defines the task that was just processed
  29660. */
  29661. task: AbstractAssetTask;
  29662. }
  29663. /**
  29664. * Class used to share progress information about assets loading
  29665. */
  29666. class AssetsProgressEvent implements IAssetsProgressEvent {
  29667. /**
  29668. * Defines the number of remaining tasks to process
  29669. */
  29670. remainingCount: number;
  29671. /**
  29672. * Defines the total number of tasks
  29673. */
  29674. totalCount: number;
  29675. /**
  29676. * Defines the task that was just processed
  29677. */
  29678. task: AbstractAssetTask;
  29679. /**
  29680. * Creates a {BABYLON.AssetsProgressEvent}
  29681. * @param remainingCount defines the number of remaining tasks to process
  29682. * @param totalCount defines the total number of tasks
  29683. * @param task defines the task that was just processed
  29684. */
  29685. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  29686. }
  29687. /**
  29688. * Define a task used by {BABYLON.AssetsManager} to load meshes
  29689. */
  29690. class MeshAssetTask extends AbstractAssetTask {
  29691. /**
  29692. * Defines the name of the task
  29693. */
  29694. name: string;
  29695. /**
  29696. * Defines the list of mesh's names you want to load
  29697. */
  29698. meshesNames: any;
  29699. /**
  29700. * Defines the root url to use as a base to load your meshes and associated resources
  29701. */
  29702. rootUrl: string;
  29703. /**
  29704. * Defines the filename of the scene to load from
  29705. */
  29706. sceneFilename: string;
  29707. /**
  29708. * Gets the list of loaded meshes
  29709. */
  29710. loadedMeshes: Array<AbstractMesh>;
  29711. /**
  29712. * Gets the list of loaded particle systems
  29713. */
  29714. loadedParticleSystems: Array<IParticleSystem>;
  29715. /**
  29716. * Gets the list of loaded skeletons
  29717. */
  29718. loadedSkeletons: Array<Skeleton>;
  29719. /**
  29720. * Callback called when the task is successful
  29721. */
  29722. onSuccess: (task: MeshAssetTask) => void;
  29723. /**
  29724. * Callback called when the task is successful
  29725. */
  29726. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  29727. /**
  29728. * Creates a new {BABYLON.MeshAssetTask}
  29729. * @param name defines the name of the task
  29730. * @param meshesNames defines the list of mesh's names you want to load
  29731. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  29732. * @param sceneFilename defines the filename of the scene to load from
  29733. */
  29734. constructor(
  29735. /**
  29736. * Defines the name of the task
  29737. */
  29738. name: string,
  29739. /**
  29740. * Defines the list of mesh's names you want to load
  29741. */
  29742. meshesNames: any,
  29743. /**
  29744. * Defines the root url to use as a base to load your meshes and associated resources
  29745. */
  29746. rootUrl: string,
  29747. /**
  29748. * Defines the filename of the scene to load from
  29749. */
  29750. sceneFilename: string);
  29751. /**
  29752. * Execute the current task
  29753. * @param scene defines the scene where you want your assets to be loaded
  29754. * @param onSuccess is a callback called when the task is successfully executed
  29755. * @param onError is a callback called if an error occurs
  29756. */
  29757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29758. }
  29759. /**
  29760. * Define a task used by {BABYLON.AssetsManager} to load text content
  29761. */
  29762. class TextFileAssetTask extends AbstractAssetTask {
  29763. /**
  29764. * Defines the name of the task
  29765. */
  29766. name: string;
  29767. /**
  29768. * Defines the location of the file to load
  29769. */
  29770. url: string;
  29771. /**
  29772. * Gets the loaded text string
  29773. */
  29774. text: string;
  29775. /**
  29776. * Callback called when the task is successful
  29777. */
  29778. onSuccess: (task: TextFileAssetTask) => void;
  29779. /**
  29780. * Callback called when the task is successful
  29781. */
  29782. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  29783. /**
  29784. * Creates a new TextFileAssetTask object
  29785. * @param name defines the name of the task
  29786. * @param url defines the location of the file to load
  29787. */
  29788. constructor(
  29789. /**
  29790. * Defines the name of the task
  29791. */
  29792. name: string,
  29793. /**
  29794. * Defines the location of the file to load
  29795. */
  29796. url: string);
  29797. /**
  29798. * Execute the current task
  29799. * @param scene defines the scene where you want your assets to be loaded
  29800. * @param onSuccess is a callback called when the task is successfully executed
  29801. * @param onError is a callback called if an error occurs
  29802. */
  29803. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29804. }
  29805. /**
  29806. * Define a task used by {BABYLON.AssetsManager} to load binary data
  29807. */
  29808. class BinaryFileAssetTask extends AbstractAssetTask {
  29809. /**
  29810. * Defines the name of the task
  29811. */
  29812. name: string;
  29813. /**
  29814. * Defines the location of the file to load
  29815. */
  29816. url: string;
  29817. /**
  29818. * Gets the lodaded data (as an array buffer)
  29819. */
  29820. data: ArrayBuffer;
  29821. /**
  29822. * Callback called when the task is successful
  29823. */
  29824. onSuccess: (task: BinaryFileAssetTask) => void;
  29825. /**
  29826. * Callback called when the task is successful
  29827. */
  29828. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  29829. /**
  29830. * Creates a new BinaryFileAssetTask object
  29831. * @param name defines the name of the new task
  29832. * @param url defines the location of the file to load
  29833. */
  29834. constructor(
  29835. /**
  29836. * Defines the name of the task
  29837. */
  29838. name: string,
  29839. /**
  29840. * Defines the location of the file to load
  29841. */
  29842. url: string);
  29843. /**
  29844. * Execute the current task
  29845. * @param scene defines the scene where you want your assets to be loaded
  29846. * @param onSuccess is a callback called when the task is successfully executed
  29847. * @param onError is a callback called if an error occurs
  29848. */
  29849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29850. }
  29851. /**
  29852. * Define a task used by {BABYLON.AssetsManager} to load images
  29853. */
  29854. class ImageAssetTask extends AbstractAssetTask {
  29855. /**
  29856. * Defines the name of the task
  29857. */
  29858. name: string;
  29859. /**
  29860. * Defines the location of the image to load
  29861. */
  29862. url: string;
  29863. /**
  29864. * Gets the loaded images
  29865. */
  29866. image: HTMLImageElement;
  29867. /**
  29868. * Callback called when the task is successful
  29869. */
  29870. onSuccess: (task: ImageAssetTask) => void;
  29871. /**
  29872. * Callback called when the task is successful
  29873. */
  29874. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  29875. /**
  29876. * Creates a new ImageAssetTask
  29877. * @param name defines the name of the task
  29878. * @param url defines the location of the image to load
  29879. */
  29880. constructor(
  29881. /**
  29882. * Defines the name of the task
  29883. */
  29884. name: string,
  29885. /**
  29886. * Defines the location of the image to load
  29887. */
  29888. url: string);
  29889. /**
  29890. * Execute the current task
  29891. * @param scene defines the scene where you want your assets to be loaded
  29892. * @param onSuccess is a callback called when the task is successfully executed
  29893. * @param onError is a callback called if an error occurs
  29894. */
  29895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29896. }
  29897. /**
  29898. * Defines the interface used by texture loading tasks
  29899. */
  29900. interface ITextureAssetTask<TEX extends BaseTexture> {
  29901. /**
  29902. * Gets the loaded texture
  29903. */
  29904. texture: TEX;
  29905. }
  29906. /**
  29907. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  29908. */
  29909. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  29910. /**
  29911. * Defines the name of the task
  29912. */
  29913. name: string;
  29914. /**
  29915. * Defines the location of the file to load
  29916. */
  29917. url: string;
  29918. /**
  29919. * Defines if mipmap should not be generated (default is false)
  29920. */
  29921. noMipmap?: boolean | undefined;
  29922. /**
  29923. * Defines if texture must be inverted on Y axis (default is false)
  29924. */
  29925. invertY?: boolean | undefined;
  29926. /**
  29927. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29928. */
  29929. samplingMode: number;
  29930. /**
  29931. * Gets the loaded texture
  29932. */
  29933. texture: Texture;
  29934. /**
  29935. * Callback called when the task is successful
  29936. */
  29937. onSuccess: (task: TextureAssetTask) => void;
  29938. /**
  29939. * Callback called when the task is successful
  29940. */
  29941. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  29942. /**
  29943. * Creates a new TextureAssetTask object
  29944. * @param name defines the name of the task
  29945. * @param url defines the location of the file to load
  29946. * @param noMipmap defines if mipmap should not be generated (default is false)
  29947. * @param invertY defines if texture must be inverted on Y axis (default is false)
  29948. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29949. */
  29950. constructor(
  29951. /**
  29952. * Defines the name of the task
  29953. */
  29954. name: string,
  29955. /**
  29956. * Defines the location of the file to load
  29957. */
  29958. url: string,
  29959. /**
  29960. * Defines if mipmap should not be generated (default is false)
  29961. */
  29962. noMipmap?: boolean | undefined,
  29963. /**
  29964. * Defines if texture must be inverted on Y axis (default is false)
  29965. */
  29966. invertY?: boolean | undefined,
  29967. /**
  29968. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29969. */
  29970. samplingMode?: number);
  29971. /**
  29972. * Execute the current task
  29973. * @param scene defines the scene where you want your assets to be loaded
  29974. * @param onSuccess is a callback called when the task is successfully executed
  29975. * @param onError is a callback called if an error occurs
  29976. */
  29977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29978. }
  29979. /**
  29980. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  29981. */
  29982. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  29983. /**
  29984. * Defines the name of the task
  29985. */
  29986. name: string;
  29987. /**
  29988. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29989. */
  29990. url: string;
  29991. /**
  29992. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29993. */
  29994. extensions?: string[] | undefined;
  29995. /**
  29996. * Defines if mipmaps should not be generated (default is false)
  29997. */
  29998. noMipmap?: boolean | undefined;
  29999. /**
  30000. * Defines the explicit list of files (undefined by default)
  30001. */
  30002. files?: string[] | undefined;
  30003. /**
  30004. * Gets the loaded texture
  30005. */
  30006. texture: CubeTexture;
  30007. /**
  30008. * Callback called when the task is successful
  30009. */
  30010. onSuccess: (task: CubeTextureAssetTask) => void;
  30011. /**
  30012. * Callback called when the task is successful
  30013. */
  30014. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  30015. /**
  30016. * Creates a new CubeTextureAssetTask
  30017. * @param name defines the name of the task
  30018. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30019. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30020. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30021. * @param files defines the explicit list of files (undefined by default)
  30022. */
  30023. constructor(
  30024. /**
  30025. * Defines the name of the task
  30026. */
  30027. name: string,
  30028. /**
  30029. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30030. */
  30031. url: string,
  30032. /**
  30033. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30034. */
  30035. extensions?: string[] | undefined,
  30036. /**
  30037. * Defines if mipmaps should not be generated (default is false)
  30038. */
  30039. noMipmap?: boolean | undefined,
  30040. /**
  30041. * Defines the explicit list of files (undefined by default)
  30042. */
  30043. files?: string[] | undefined);
  30044. /**
  30045. * Execute the current task
  30046. * @param scene defines the scene where you want your assets to be loaded
  30047. * @param onSuccess is a callback called when the task is successfully executed
  30048. * @param onError is a callback called if an error occurs
  30049. */
  30050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30051. }
  30052. /**
  30053. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  30054. */
  30055. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  30056. /**
  30057. * Defines the name of the task
  30058. */
  30059. name: string;
  30060. /**
  30061. * Defines the location of the file to load
  30062. */
  30063. url: string;
  30064. /**
  30065. * Defines the desired size (the more it increases the longer the generation will be)
  30066. */
  30067. size: number;
  30068. /**
  30069. * Defines if mipmaps should not be generated (default is false)
  30070. */
  30071. noMipmap: boolean;
  30072. /**
  30073. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30074. */
  30075. generateHarmonics: boolean;
  30076. /**
  30077. * 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)
  30078. */
  30079. gammaSpace: boolean;
  30080. /**
  30081. * Internal Use Only
  30082. */
  30083. reserved: boolean;
  30084. /**
  30085. * Gets the loaded texture
  30086. */
  30087. texture: HDRCubeTexture;
  30088. /**
  30089. * Callback called when the task is successful
  30090. */
  30091. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  30092. /**
  30093. * Callback called when the task is successful
  30094. */
  30095. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  30096. /**
  30097. * Creates a new HDRCubeTextureAssetTask object
  30098. * @param name defines the name of the task
  30099. * @param url defines the location of the file to load
  30100. * @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.
  30101. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30102. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30103. * @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)
  30104. * @param reserved Internal use only
  30105. */
  30106. constructor(
  30107. /**
  30108. * Defines the name of the task
  30109. */
  30110. name: string,
  30111. /**
  30112. * Defines the location of the file to load
  30113. */
  30114. url: string,
  30115. /**
  30116. * Defines the desired size (the more it increases the longer the generation will be)
  30117. */
  30118. size: number,
  30119. /**
  30120. * Defines if mipmaps should not be generated (default is false)
  30121. */
  30122. noMipmap?: boolean,
  30123. /**
  30124. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30125. */
  30126. generateHarmonics?: boolean,
  30127. /**
  30128. * 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)
  30129. */
  30130. gammaSpace?: boolean,
  30131. /**
  30132. * Internal Use Only
  30133. */
  30134. reserved?: boolean);
  30135. /**
  30136. * Execute the current task
  30137. * @param scene defines the scene where you want your assets to be loaded
  30138. * @param onSuccess is a callback called when the task is successfully executed
  30139. * @param onError is a callback called if an error occurs
  30140. */
  30141. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30142. }
  30143. /**
  30144. * This class can be used to easily import assets into a scene
  30145. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  30146. */
  30147. class AssetsManager {
  30148. private _scene;
  30149. private _isLoading;
  30150. protected _tasks: AbstractAssetTask[];
  30151. protected _waitingTasksCount: number;
  30152. protected _totalTasksCount: number;
  30153. /**
  30154. * Callback called when all tasks are processed
  30155. */
  30156. onFinish: (tasks: AbstractAssetTask[]) => void;
  30157. /**
  30158. * Callback called when a task is successful
  30159. */
  30160. onTaskSuccess: (task: AbstractAssetTask) => void;
  30161. /**
  30162. * Callback called when a task had an error
  30163. */
  30164. onTaskError: (task: AbstractAssetTask) => void;
  30165. /**
  30166. * Callback called when a task is done (whatever the result is)
  30167. */
  30168. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  30169. /**
  30170. * Observable called when all tasks are processed
  30171. */
  30172. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  30173. /**
  30174. * Observable called when a task had an error
  30175. */
  30176. onTaskErrorObservable: Observable<AbstractAssetTask>;
  30177. /**
  30178. * Observable called when a task is successful
  30179. */
  30180. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  30181. /**
  30182. * Observable called when a task is done (whatever the result is)
  30183. */
  30184. onProgressObservable: Observable<IAssetsProgressEvent>;
  30185. /**
  30186. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  30187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30188. */
  30189. useDefaultLoadingScreen: boolean;
  30190. /**
  30191. * Creates a new AssetsManager
  30192. * @param scene defines the scene to work on
  30193. */
  30194. constructor(scene: Scene);
  30195. /**
  30196. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  30197. * @param taskName defines the name of the new task
  30198. * @param meshesNames defines the name of meshes to load
  30199. * @param rootUrl defines the root url to use to locate files
  30200. * @param sceneFilename defines the filename of the scene file
  30201. * @returns a new {BABYLON.MeshAssetTask} object
  30202. */
  30203. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  30204. /**
  30205. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  30206. * @param taskName defines the name of the new task
  30207. * @param url defines the url of the file to load
  30208. * @returns a new {BABYLON.TextFileAssetTask} object
  30209. */
  30210. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  30211. /**
  30212. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  30213. * @param taskName defines the name of the new task
  30214. * @param url defines the url of the file to load
  30215. * @returns a new {BABYLON.BinaryFileAssetTask} object
  30216. */
  30217. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  30218. /**
  30219. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  30220. * @param taskName defines the name of the new task
  30221. * @param url defines the url of the file to load
  30222. * @returns a new {BABYLON.ImageAssetTask} object
  30223. */
  30224. addImageTask(taskName: string, url: string): ImageAssetTask;
  30225. /**
  30226. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  30227. * @param taskName defines the name of the new task
  30228. * @param url defines the url of the file to load
  30229. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30230. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  30231. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  30232. * @returns a new {BABYLON.TextureAssetTask} object
  30233. */
  30234. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  30235. /**
  30236. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  30237. * @param taskName defines the name of the new task
  30238. * @param url defines the url of the file to load
  30239. * @param extensions defines the extension to use to load the cube map (can be null)
  30240. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30241. * @param files defines the list of files to load (can be null)
  30242. * @returns a new {BABYLON.CubeTextureAssetTask} object
  30243. */
  30244. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  30245. /**
  30246. *
  30247. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  30248. * @param taskName defines the name of the new task
  30249. * @param url defines the url of the file to load
  30250. * @param size defines the size you want for the cubemap (can be null)
  30251. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30252. * @param generateHarmonics defines if you want to automatically generate (true by default)
  30253. * @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)
  30254. * @param reserved Internal use only
  30255. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  30256. */
  30257. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  30258. /**
  30259. * Remove a task from the assets manager.
  30260. * @param task the task to remove
  30261. */
  30262. removeTask(task: AbstractAssetTask): void;
  30263. private _decreaseWaitingTasksCount;
  30264. private _runTask;
  30265. /**
  30266. * Reset the {BABYLON.AssetsManager} and remove all tasks
  30267. * @return the current instance of the {BABYLON.AssetsManager}
  30268. */
  30269. reset(): AssetsManager;
  30270. /**
  30271. * Start the loading process
  30272. * @return the current instance of the {BABYLON.AssetsManager}
  30273. */
  30274. load(): AssetsManager;
  30275. }
  30276. }
  30277. declare module BABYLON {
  30278. /**
  30279. * Class used to enable access to IndexedDB
  30280. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  30281. */
  30282. class Database {
  30283. private callbackManifestChecked;
  30284. private currentSceneUrl;
  30285. private db;
  30286. private _enableSceneOffline;
  30287. private _enableTexturesOffline;
  30288. private manifestVersionFound;
  30289. private mustUpdateRessources;
  30290. private hasReachedQuota;
  30291. private isSupported;
  30292. private idbFactory;
  30293. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30294. static IsUASupportingBlobStorage: boolean;
  30295. /** Gets a boolean indicating if Database storate is enabled */
  30296. static IDBStorageEnabled: boolean;
  30297. /**
  30298. * Gets a boolean indicating if scene must be saved in the database
  30299. */
  30300. readonly enableSceneOffline: boolean;
  30301. /**
  30302. * Gets a boolean indicating if textures must be saved in the database
  30303. */
  30304. readonly enableTexturesOffline: boolean;
  30305. /**
  30306. * Creates a new Database
  30307. * @param urlToScene defines the url to load the scene
  30308. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30309. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30310. */
  30311. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30312. private static _ParseURL;
  30313. private static _ReturnFullUrlLocation;
  30314. private _checkManifestFile;
  30315. /**
  30316. * Open the database and make it available
  30317. * @param successCallback defines the callback to call on success
  30318. * @param errorCallback defines the callback to call on error
  30319. */
  30320. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30321. /**
  30322. * Loads an image from the database
  30323. * @param url defines the url to load from
  30324. * @param image defines the target DOM image
  30325. */
  30326. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30327. private _loadImageFromDBAsync;
  30328. private _saveImageIntoDBAsync;
  30329. private _checkVersionFromDB;
  30330. private _loadVersionFromDBAsync;
  30331. private _saveVersionIntoDBAsync;
  30332. /**
  30333. * Loads a file from database
  30334. * @param url defines the URL to load from
  30335. * @param sceneLoaded defines a callback to call on success
  30336. * @param progressCallBack defines a callback to call when progress changed
  30337. * @param errorCallback defines a callback to call on error
  30338. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30339. */
  30340. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30341. private _loadFileFromDBAsync;
  30342. private _saveFileIntoDBAsync;
  30343. }
  30344. }
  30345. declare module BABYLON {
  30346. interface DDSInfo {
  30347. width: number;
  30348. height: number;
  30349. mipmapCount: number;
  30350. isFourCC: boolean;
  30351. isRGB: boolean;
  30352. isLuminance: boolean;
  30353. isCube: boolean;
  30354. isCompressed: boolean;
  30355. dxgiFormat: number;
  30356. textureType: number;
  30357. /** Sphericle polynomial created for the dds texture */
  30358. sphericalPolynomial?: SphericalPolynomial;
  30359. }
  30360. class DDSTools {
  30361. static StoreLODInAlphaChannel: boolean;
  30362. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30363. private static _FloatView;
  30364. private static _Int32View;
  30365. private static _ToHalfFloat;
  30366. private static _FromHalfFloat;
  30367. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30368. private static _GetHalfFloatRGBAArrayBuffer;
  30369. private static _GetFloatRGBAArrayBuffer;
  30370. private static _GetFloatAsUIntRGBAArrayBuffer;
  30371. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30372. private static _GetRGBAArrayBuffer;
  30373. private static _ExtractLongWordOrder;
  30374. private static _GetRGBArrayBuffer;
  30375. private static _GetLuminanceArrayBuffer;
  30376. /**
  30377. * Uploads DDS Levels to a Babylon Texture
  30378. * @hidden
  30379. */
  30380. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30381. }
  30382. }
  30383. declare module BABYLON {
  30384. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30385. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30386. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30387. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30388. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30389. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30390. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30391. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30392. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30393. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30394. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30395. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30396. /**
  30397. * Decorator used to define property that can be serialized as reference to a camera
  30398. * @param sourceName defines the name of the property to decorate
  30399. */
  30400. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30401. class SerializationHelper {
  30402. static Serialize<T>(entity: T, serializationObject?: any): any;
  30403. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30404. static Clone<T>(creationFunction: () => T, source: T): T;
  30405. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30406. }
  30407. }
  30408. declare module BABYLON {
  30409. /**
  30410. * Wrapper class for promise with external resolve and reject.
  30411. */
  30412. class Deferred<T> {
  30413. /**
  30414. * The promise associated with this deferred object.
  30415. */
  30416. readonly promise: Promise<T>;
  30417. private _resolve;
  30418. private _reject;
  30419. /**
  30420. * The resolve method of the promise associated with this deferred object.
  30421. */
  30422. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30423. /**
  30424. * The reject method of the promise associated with this deferred object.
  30425. */
  30426. readonly reject: (reason?: any) => void;
  30427. /**
  30428. * Constructor for this deferred object.
  30429. */
  30430. constructor();
  30431. }
  30432. }
  30433. declare module BABYLON {
  30434. /**
  30435. * Raw texture data and descriptor sufficient for WebGL texture upload
  30436. */
  30437. interface EnvironmentTextureInfo {
  30438. /**
  30439. * Version of the environment map
  30440. */
  30441. version: number;
  30442. /**
  30443. * Width of image
  30444. */
  30445. width: number;
  30446. /**
  30447. * Irradiance information stored in the file.
  30448. */
  30449. irradiance: any;
  30450. /**
  30451. * Specular information stored in the file.
  30452. */
  30453. specular: any;
  30454. }
  30455. /**
  30456. * Sets of helpers addressing the serialization and deserialization of environment texture
  30457. * stored in a BabylonJS env file.
  30458. * Those files are usually stored as .env files.
  30459. */
  30460. class EnvironmentTextureTools {
  30461. /**
  30462. * Magic number identifying the env file.
  30463. */
  30464. private static _MagicBytes;
  30465. /**
  30466. * Gets the environment info from an env file.
  30467. * @param data The array buffer containing the .env bytes.
  30468. * @returns the environment file info (the json header) if successfully parsed.
  30469. */
  30470. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30471. /**
  30472. * Creates an environment texture from a loaded cube texture.
  30473. * @param texture defines the cube texture to convert in env file
  30474. * @return a promise containing the environment data if succesfull.
  30475. */
  30476. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30477. /**
  30478. * Creates a JSON representation of the spherical data.
  30479. * @param texture defines the texture containing the polynomials
  30480. * @return the JSON representation of the spherical info
  30481. */
  30482. private static _CreateEnvTextureIrradiance;
  30483. /**
  30484. * Uploads the texture info contained in the env file to the GPU.
  30485. * @param texture defines the internal texture to upload to
  30486. * @param arrayBuffer defines the buffer cotaining the data to load
  30487. * @param info defines the texture info retrieved through the GetEnvInfo method
  30488. * @returns a promise
  30489. */
  30490. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30491. /**
  30492. * Uploads the levels of image data to the GPU.
  30493. * @param texture defines the internal texture to upload to
  30494. * @param imageData defines the array buffer views of image data [mipmap][face]
  30495. * @returns a promise
  30496. */
  30497. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30498. /**
  30499. * Uploads spherical polynomials information to the texture.
  30500. * @param texture defines the texture we are trying to upload the information to
  30501. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30502. */
  30503. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30504. }
  30505. }
  30506. declare module BABYLON {
  30507. class FilesInput {
  30508. static FilesToLoad: {
  30509. [key: string]: File;
  30510. };
  30511. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30512. private _engine;
  30513. private _currentScene;
  30514. private _sceneLoadedCallback;
  30515. private _progressCallback;
  30516. private _additionalRenderLoopLogicCallback;
  30517. private _textureLoadingCallback;
  30518. private _startingProcessingFilesCallback;
  30519. private _onReloadCallback;
  30520. private _errorCallback;
  30521. private _elementToMonitor;
  30522. private _sceneFileToLoad;
  30523. private _filesToLoad;
  30524. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  30525. private _dragEnterHandler;
  30526. private _dragOverHandler;
  30527. private _dropHandler;
  30528. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30529. dispose(): void;
  30530. private renderFunction;
  30531. private drag;
  30532. private drop;
  30533. private _traverseFolder;
  30534. private _processFiles;
  30535. loadFiles(event: any): void;
  30536. private _processReload;
  30537. reload(): void;
  30538. }
  30539. }
  30540. declare module BABYLON {
  30541. /**
  30542. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30543. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30544. */
  30545. class KhronosTextureContainer {
  30546. arrayBuffer: any;
  30547. static HEADER_LEN: number;
  30548. static COMPRESSED_2D: number;
  30549. static COMPRESSED_3D: number;
  30550. static TEX_2D: number;
  30551. static TEX_3D: number;
  30552. glType: number;
  30553. glTypeSize: number;
  30554. glFormat: number;
  30555. glInternalFormat: number;
  30556. glBaseInternalFormat: number;
  30557. pixelWidth: number;
  30558. pixelHeight: number;
  30559. pixelDepth: number;
  30560. numberOfArrayElements: number;
  30561. numberOfFaces: number;
  30562. numberOfMipmapLevels: number;
  30563. bytesOfKeyValueData: number;
  30564. loadType: number;
  30565. /**
  30566. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  30567. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  30568. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  30569. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  30570. */
  30571. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  30572. switchEndainness(val: number): number;
  30573. /**
  30574. * Uploads KTX content to a Babylon Texture.
  30575. * It is assumed that the texture has already been created & is currently bound
  30576. * @hidden
  30577. */
  30578. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  30579. private _upload2DCompressedLevels;
  30580. }
  30581. }
  30582. declare module BABYLON {
  30583. /**
  30584. * A class serves as a medium between the observable and its observers
  30585. */
  30586. class EventState {
  30587. /**
  30588. * Create a new EventState
  30589. * @param mask defines the mask associated with this state
  30590. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30591. * @param target defines the original target of the state
  30592. * @param currentTarget defines the current target of the state
  30593. */
  30594. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  30595. /**
  30596. * Initialize the current event state
  30597. * @param mask defines the mask associated with this state
  30598. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30599. * @param target defines the original target of the state
  30600. * @param currentTarget defines the current target of the state
  30601. * @returns the current event state
  30602. */
  30603. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  30604. /**
  30605. * An Observer can set this property to true to prevent subsequent observers of being notified
  30606. */
  30607. skipNextObservers: boolean;
  30608. /**
  30609. * Get the mask value that were used to trigger the event corresponding to this EventState object
  30610. */
  30611. mask: number;
  30612. /**
  30613. * The object that originally notified the event
  30614. */
  30615. target?: any;
  30616. /**
  30617. * The current object in the bubbling phase
  30618. */
  30619. currentTarget?: any;
  30620. /**
  30621. * This will be populated with the return value of the last function that was executed.
  30622. * If it is the first function in the callback chain it will be the event data.
  30623. */
  30624. lastReturnValue?: any;
  30625. }
  30626. /**
  30627. * Represent an Observer registered to a given Observable object.
  30628. */
  30629. class Observer<T> {
  30630. /**
  30631. * Defines the callback to call when the observer is notified
  30632. */
  30633. callback: (eventData: T, eventState: EventState) => void;
  30634. /**
  30635. * Defines the mask of the observer (used to filter notifications)
  30636. */
  30637. mask: number;
  30638. /**
  30639. * Defines the current scope used to restore the JS context
  30640. */
  30641. scope: any;
  30642. /** @hidden */
  30643. _willBeUnregistered: boolean;
  30644. /**
  30645. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  30646. */
  30647. unregisterOnNextCall: boolean;
  30648. /**
  30649. * Creates a new observer
  30650. * @param callback defines the callback to call when the observer is notified
  30651. * @param mask defines the mask of the observer (used to filter notifications)
  30652. * @param scope defines the current scope used to restore the JS context
  30653. */
  30654. constructor(
  30655. /**
  30656. * Defines the callback to call when the observer is notified
  30657. */
  30658. callback: (eventData: T, eventState: EventState) => void,
  30659. /**
  30660. * Defines the mask of the observer (used to filter notifications)
  30661. */
  30662. mask: number,
  30663. /**
  30664. * Defines the current scope used to restore the JS context
  30665. */
  30666. scope?: any);
  30667. }
  30668. /**
  30669. * Represent a list of observers registered to multiple Observables object.
  30670. */
  30671. class MultiObserver<T> {
  30672. private _observers;
  30673. private _observables;
  30674. /**
  30675. * Release associated resources
  30676. */
  30677. dispose(): void;
  30678. /**
  30679. * Raise a callback when one of the observable will notify
  30680. * @param observables defines a list of observables to watch
  30681. * @param callback defines the callback to call on notification
  30682. * @param mask defines the mask used to filter notifications
  30683. * @param scope defines the current scope used to restore the JS context
  30684. * @returns the new MultiObserver
  30685. */
  30686. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  30687. }
  30688. /**
  30689. * The Observable class is a simple implementation of the Observable pattern.
  30690. *
  30691. * 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.
  30692. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  30693. * 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).
  30694. * 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.
  30695. */
  30696. class Observable<T> {
  30697. private _observers;
  30698. private _eventState;
  30699. private _onObserverAdded;
  30700. /**
  30701. * Creates a new observable
  30702. * @param onObserverAdded defines a callback to call when a new observer is added
  30703. */
  30704. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  30705. /**
  30706. * Create a new Observer with the specified callback
  30707. * @param callback the callback that will be executed for that Observer
  30708. * @param mask the mask used to filter observers
  30709. * @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.
  30710. * @param scope optional scope for the callback to be called from
  30711. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  30712. * @returns the new observer created for the callback
  30713. */
  30714. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  30715. /**
  30716. * Create a new Observer with the specified callback and unregisters after the next notification
  30717. * @param callback the callback that will be executed for that Observer
  30718. * @returns the new observer created for the callback
  30719. */
  30720. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  30721. /**
  30722. * Remove an Observer from the Observable object
  30723. * @param observer the instance of the Observer to remove
  30724. * @returns false if it doesn't belong to this Observable
  30725. */
  30726. remove(observer: Nullable<Observer<T>>): boolean;
  30727. /**
  30728. * Remove a callback from the Observable object
  30729. * @param callback the callback to remove
  30730. * @param scope optional scope. If used only the callbacks with this scope will be removed
  30731. * @returns false if it doesn't belong to this Observable
  30732. */
  30733. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  30734. private _deferUnregister;
  30735. private _remove;
  30736. /**
  30737. * Notify all Observers by calling their respective callback with the given data
  30738. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  30739. * @param eventData defines the data to send to all observers
  30740. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  30741. * @param target defines the original target of the state
  30742. * @param currentTarget defines the current target of the state
  30743. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  30744. */
  30745. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  30746. /**
  30747. * Calling this will execute each callback, expecting it to be a promise or return a value.
  30748. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  30749. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  30750. * and it is crucial that all callbacks will be executed.
  30751. * The order of the callbacks is kept, callbacks are not executed parallel.
  30752. *
  30753. * @param eventData The data to be sent to each callback
  30754. * @param mask is used to filter observers defaults to -1
  30755. * @param target defines the callback target (see EventState)
  30756. * @param currentTarget defines he current object in the bubbling phase
  30757. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  30758. */
  30759. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  30760. /**
  30761. * Notify a specific observer
  30762. * @param observer defines the observer to notify
  30763. * @param eventData defines the data to be sent to each callback
  30764. * @param mask is used to filter observers defaults to -1
  30765. */
  30766. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  30767. /**
  30768. * Gets a boolean indicating if the observable has at least one observer
  30769. * @returns true is the Observable has at least one Observer registered
  30770. */
  30771. hasObservers(): boolean;
  30772. /**
  30773. * Clear the list of observers
  30774. */
  30775. clear(): void;
  30776. /**
  30777. * Clone the current observable
  30778. * @returns a new observable
  30779. */
  30780. clone(): Observable<T>;
  30781. /**
  30782. * Does this observable handles observer registered with a given mask
  30783. * @param mask defines the mask to be tested
  30784. * @return whether or not one observer registered with the given mask is handeled
  30785. **/
  30786. hasSpecificMask(mask?: number): boolean;
  30787. }
  30788. }
  30789. declare module BABYLON {
  30790. /**
  30791. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30792. */
  30793. class PerformanceMonitor {
  30794. private _enabled;
  30795. private _rollingFrameTime;
  30796. private _lastFrameTimeMs;
  30797. /**
  30798. * constructor
  30799. * @param frameSampleSize The number of samples required to saturate the sliding window
  30800. */
  30801. constructor(frameSampleSize?: number);
  30802. /**
  30803. * Samples current frame
  30804. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30805. */
  30806. sampleFrame(timeMs?: number): void;
  30807. /**
  30808. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30809. * @return Average frame time in milliseconds
  30810. */
  30811. readonly averageFrameTime: number;
  30812. /**
  30813. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30814. * @return Frame time variance in milliseconds squared
  30815. */
  30816. readonly averageFrameTimeVariance: number;
  30817. /**
  30818. * Returns the frame time of the most recent frame
  30819. * @return Frame time in milliseconds
  30820. */
  30821. readonly instantaneousFrameTime: number;
  30822. /**
  30823. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30824. * @return Framerate in frames per second
  30825. */
  30826. readonly averageFPS: number;
  30827. /**
  30828. * Returns the average framerate in frames per second using the most recent frame time
  30829. * @return Framerate in frames per second
  30830. */
  30831. readonly instantaneousFPS: number;
  30832. /**
  30833. * Returns true if enough samples have been taken to completely fill the sliding window
  30834. * @return true if saturated
  30835. */
  30836. readonly isSaturated: boolean;
  30837. /**
  30838. * Enables contributions to the sliding window sample set
  30839. */
  30840. enable(): void;
  30841. /**
  30842. * Disables contributions to the sliding window sample set
  30843. * Samples will not be interpolated over the disabled period
  30844. */
  30845. disable(): void;
  30846. /**
  30847. * Returns true if sampling is enabled
  30848. * @return true if enabled
  30849. */
  30850. readonly isEnabled: boolean;
  30851. /**
  30852. * Resets performance monitor
  30853. */
  30854. reset(): void;
  30855. }
  30856. /**
  30857. * RollingAverage
  30858. *
  30859. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30860. */
  30861. class RollingAverage {
  30862. /**
  30863. * Current average
  30864. */
  30865. average: number;
  30866. /**
  30867. * Current variance
  30868. */
  30869. variance: number;
  30870. protected _samples: Array<number>;
  30871. protected _sampleCount: number;
  30872. protected _pos: number;
  30873. protected _m2: number;
  30874. /**
  30875. * constructor
  30876. * @param length The number of samples required to saturate the sliding window
  30877. */
  30878. constructor(length: number);
  30879. /**
  30880. * Adds a sample to the sample set
  30881. * @param v The sample value
  30882. */
  30883. add(v: number): void;
  30884. /**
  30885. * Returns previously added values or null if outside of history or outside the sliding window domain
  30886. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30887. * @return Value previously recorded with add() or null if outside of range
  30888. */
  30889. history(i: number): number;
  30890. /**
  30891. * Returns true if enough samples have been taken to completely fill the sliding window
  30892. * @return true if sample-set saturated
  30893. */
  30894. isSaturated(): boolean;
  30895. /**
  30896. * Resets the rolling average (equivalent to 0 samples taken so far)
  30897. */
  30898. reset(): void;
  30899. /**
  30900. * Wraps a value around the sample range boundaries
  30901. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30902. * @return Wrapped position in sample range
  30903. */
  30904. protected _wrapPosition(i: number): number;
  30905. }
  30906. }
  30907. declare module BABYLON {
  30908. /**
  30909. * Helper class that provides a small promise polyfill
  30910. */
  30911. class PromisePolyfill {
  30912. /**
  30913. * Static function used to check if the polyfill is required
  30914. * If this is the case then the function will inject the polyfill to window.Promise
  30915. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30916. */
  30917. static Apply(force?: boolean): void;
  30918. }
  30919. }
  30920. declare module BABYLON {
  30921. /**
  30922. * Defines the root class used to create scene optimization to use with SceneOptimizer
  30923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30924. */
  30925. class SceneOptimization {
  30926. /**
  30927. * Defines the priority of this optimization (0 by default which means first in the list)
  30928. */
  30929. priority: number;
  30930. /**
  30931. * Gets a string describing the action executed by the current optimization
  30932. * @returns description string
  30933. */
  30934. getDescription(): string;
  30935. /**
  30936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30937. * @param scene defines the current scene where to apply this optimization
  30938. * @param optimizer defines the current optimizer
  30939. * @returns true if everything that can be done was applied
  30940. */
  30941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30942. /**
  30943. * Creates the SceneOptimization object
  30944. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30945. * @param desc defines the description associated with the optimization
  30946. */
  30947. constructor(
  30948. /**
  30949. * Defines the priority of this optimization (0 by default which means first in the list)
  30950. */
  30951. priority?: number);
  30952. }
  30953. /**
  30954. * Defines an optimization used to reduce the size of render target textures
  30955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30956. */
  30957. class TextureOptimization extends SceneOptimization {
  30958. /**
  30959. * Defines the priority of this optimization (0 by default which means first in the list)
  30960. */
  30961. priority: number;
  30962. /**
  30963. * 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
  30964. */
  30965. maximumSize: number;
  30966. /**
  30967. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30968. */
  30969. step: number;
  30970. /**
  30971. * Gets a string describing the action executed by the current optimization
  30972. * @returns description string
  30973. */
  30974. getDescription(): string;
  30975. /**
  30976. * Creates the TextureOptimization object
  30977. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30978. * @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
  30979. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30980. */
  30981. constructor(
  30982. /**
  30983. * Defines the priority of this optimization (0 by default which means first in the list)
  30984. */
  30985. priority?: number,
  30986. /**
  30987. * 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
  30988. */
  30989. maximumSize?: number,
  30990. /**
  30991. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30992. */
  30993. step?: number);
  30994. /**
  30995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30996. * @param scene defines the current scene where to apply this optimization
  30997. * @param optimizer defines the current optimizer
  30998. * @returns true if everything that can be done was applied
  30999. */
  31000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31001. }
  31002. /**
  31003. * Defines an optimization used to increase or decrease the rendering resolution
  31004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31005. */
  31006. class HardwareScalingOptimization extends SceneOptimization {
  31007. /**
  31008. * Defines the priority of this optimization (0 by default which means first in the list)
  31009. */
  31010. priority: number;
  31011. /**
  31012. * Defines the maximum scale to use (2 by default)
  31013. */
  31014. maximumScale: number;
  31015. /**
  31016. * Defines the step to use between two passes (0.5 by default)
  31017. */
  31018. step: number;
  31019. private _currentScale;
  31020. private _directionOffset;
  31021. /**
  31022. * Gets a string describing the action executed by the current optimization
  31023. * @return description string
  31024. */
  31025. getDescription(): string;
  31026. /**
  31027. * Creates the HardwareScalingOptimization object
  31028. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31029. * @param maximumScale defines the maximum scale to use (2 by default)
  31030. * @param step defines the step to use between two passes (0.5 by default)
  31031. */
  31032. constructor(
  31033. /**
  31034. * Defines the priority of this optimization (0 by default which means first in the list)
  31035. */
  31036. priority?: number,
  31037. /**
  31038. * Defines the maximum scale to use (2 by default)
  31039. */
  31040. maximumScale?: number,
  31041. /**
  31042. * Defines the step to use between two passes (0.5 by default)
  31043. */
  31044. step?: number);
  31045. /**
  31046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31047. * @param scene defines the current scene where to apply this optimization
  31048. * @param optimizer defines the current optimizer
  31049. * @returns true if everything that can be done was applied
  31050. */
  31051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31052. }
  31053. /**
  31054. * Defines an optimization used to remove shadows
  31055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31056. */
  31057. class ShadowsOptimization extends SceneOptimization {
  31058. /**
  31059. * Gets a string describing the action executed by the current optimization
  31060. * @return description string
  31061. */
  31062. getDescription(): string;
  31063. /**
  31064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31065. * @param scene defines the current scene where to apply this optimization
  31066. * @param optimizer defines the current optimizer
  31067. * @returns true if everything that can be done was applied
  31068. */
  31069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31070. }
  31071. /**
  31072. * Defines an optimization used to turn post-processes off
  31073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31074. */
  31075. class PostProcessesOptimization extends SceneOptimization {
  31076. /**
  31077. * Gets a string describing the action executed by the current optimization
  31078. * @return description string
  31079. */
  31080. getDescription(): string;
  31081. /**
  31082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31083. * @param scene defines the current scene where to apply this optimization
  31084. * @param optimizer defines the current optimizer
  31085. * @returns true if everything that can be done was applied
  31086. */
  31087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31088. }
  31089. /**
  31090. * Defines an optimization used to turn lens flares off
  31091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31092. */
  31093. class LensFlaresOptimization extends SceneOptimization {
  31094. /**
  31095. * Gets a string describing the action executed by the current optimization
  31096. * @return description string
  31097. */
  31098. getDescription(): string;
  31099. /**
  31100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31101. * @param scene defines the current scene where to apply this optimization
  31102. * @param optimizer defines the current optimizer
  31103. * @returns true if everything that can be done was applied
  31104. */
  31105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31106. }
  31107. /**
  31108. * Defines an optimization based on user defined callback.
  31109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31110. */
  31111. class CustomOptimization extends SceneOptimization {
  31112. /**
  31113. * Callback called to apply the custom optimization.
  31114. */
  31115. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  31116. /**
  31117. * Callback called to get custom description
  31118. */
  31119. onGetDescription: () => string;
  31120. /**
  31121. * Gets a string describing the action executed by the current optimization
  31122. * @returns description string
  31123. */
  31124. getDescription(): string;
  31125. /**
  31126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31127. * @param scene defines the current scene where to apply this optimization
  31128. * @param optimizer defines the current optimizer
  31129. * @returns true if everything that can be done was applied
  31130. */
  31131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31132. }
  31133. /**
  31134. * Defines an optimization used to turn particles off
  31135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31136. */
  31137. class ParticlesOptimization extends SceneOptimization {
  31138. /**
  31139. * Gets a string describing the action executed by the current optimization
  31140. * @return description string
  31141. */
  31142. getDescription(): string;
  31143. /**
  31144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31145. * @param scene defines the current scene where to apply this optimization
  31146. * @param optimizer defines the current optimizer
  31147. * @returns true if everything that can be done was applied
  31148. */
  31149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31150. }
  31151. /**
  31152. * Defines an optimization used to turn render targets off
  31153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31154. */
  31155. class RenderTargetsOptimization extends SceneOptimization {
  31156. /**
  31157. * Gets a string describing the action executed by the current optimization
  31158. * @return description string
  31159. */
  31160. getDescription(): string;
  31161. /**
  31162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31163. * @param scene defines the current scene where to apply this optimization
  31164. * @param optimizer defines the current optimizer
  31165. * @returns true if everything that can be done was applied
  31166. */
  31167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31168. }
  31169. /**
  31170. * Defines an optimization used to merge meshes with compatible materials
  31171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31172. */
  31173. class MergeMeshesOptimization extends SceneOptimization {
  31174. private static _UpdateSelectionTree;
  31175. /**
  31176. * Gets or sets a boolean which defines if optimization octree has to be updated
  31177. */
  31178. /**
  31179. * Gets or sets a boolean which defines if optimization octree has to be updated
  31180. */
  31181. static UpdateSelectionTree: boolean;
  31182. /**
  31183. * Gets a string describing the action executed by the current optimization
  31184. * @return description string
  31185. */
  31186. getDescription(): string;
  31187. private _canBeMerged;
  31188. /**
  31189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31190. * @param scene defines the current scene where to apply this optimization
  31191. * @param optimizer defines the current optimizer
  31192. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  31193. * @returns true if everything that can be done was applied
  31194. */
  31195. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  31196. }
  31197. /**
  31198. * Defines a list of options used by SceneOptimizer
  31199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31200. */
  31201. class SceneOptimizerOptions {
  31202. /**
  31203. * Defines the target frame rate to reach (60 by default)
  31204. */
  31205. targetFrameRate: number;
  31206. /**
  31207. * Defines the interval between two checkes (2000ms by default)
  31208. */
  31209. trackerDuration: number;
  31210. /**
  31211. * Gets the list of optimizations to apply
  31212. */
  31213. optimizations: SceneOptimization[];
  31214. /**
  31215. * Creates a new list of options used by SceneOptimizer
  31216. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  31217. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  31218. */
  31219. constructor(
  31220. /**
  31221. * Defines the target frame rate to reach (60 by default)
  31222. */
  31223. targetFrameRate?: number,
  31224. /**
  31225. * Defines the interval between two checkes (2000ms by default)
  31226. */
  31227. trackerDuration?: number);
  31228. /**
  31229. * Add a new optimization
  31230. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  31231. * @returns the current SceneOptimizerOptions
  31232. */
  31233. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  31234. /**
  31235. * Add a new custom optimization
  31236. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  31237. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  31238. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31239. * @returns the current SceneOptimizerOptions
  31240. */
  31241. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  31242. /**
  31243. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  31244. * @param targetFrameRate defines the target frame rate (60 by default)
  31245. * @returns a SceneOptimizerOptions object
  31246. */
  31247. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31248. /**
  31249. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  31250. * @param targetFrameRate defines the target frame rate (60 by default)
  31251. * @returns a SceneOptimizerOptions object
  31252. */
  31253. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31254. /**
  31255. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  31256. * @param targetFrameRate defines the target frame rate (60 by default)
  31257. * @returns a SceneOptimizerOptions object
  31258. */
  31259. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31260. }
  31261. /**
  31262. * Class used to run optimizations in order to reach a target frame rate
  31263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31264. */
  31265. class SceneOptimizer implements IDisposable {
  31266. private _isRunning;
  31267. private _options;
  31268. private _scene;
  31269. private _currentPriorityLevel;
  31270. private _targetFrameRate;
  31271. private _trackerDuration;
  31272. private _currentFrameRate;
  31273. private _sceneDisposeObserver;
  31274. private _improvementMode;
  31275. /**
  31276. * Defines an observable called when the optimizer reaches the target frame rate
  31277. */
  31278. onSuccessObservable: Observable<SceneOptimizer>;
  31279. /**
  31280. * Defines an observable called when the optimizer enables an optimization
  31281. */
  31282. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  31283. /**
  31284. * Defines an observable called when the optimizer is not able to reach the target frame rate
  31285. */
  31286. onFailureObservable: Observable<SceneOptimizer>;
  31287. /**
  31288. * Gets a boolean indicating if the optimizer is in improvement mode
  31289. */
  31290. readonly isInImprovementMode: boolean;
  31291. /**
  31292. * Gets the current priority level (0 at start)
  31293. */
  31294. readonly currentPriorityLevel: number;
  31295. /**
  31296. * Gets the current frame rate checked by the SceneOptimizer
  31297. */
  31298. readonly currentFrameRate: number;
  31299. /**
  31300. * Gets or sets the current target frame rate (60 by default)
  31301. */
  31302. /**
  31303. * Gets or sets the current target frame rate (60 by default)
  31304. */
  31305. targetFrameRate: number;
  31306. /**
  31307. * Gets or sets the current interval between two checks (every 2000ms by default)
  31308. */
  31309. /**
  31310. * Gets or sets the current interval between two checks (every 2000ms by default)
  31311. */
  31312. trackerDuration: number;
  31313. /**
  31314. * Gets the list of active optimizations
  31315. */
  31316. readonly optimizations: SceneOptimization[];
  31317. /**
  31318. * Creates a new SceneOptimizer
  31319. * @param scene defines the scene to work on
  31320. * @param options defines the options to use with the SceneOptimizer
  31321. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31322. * @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)
  31323. */
  31324. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31325. /**
  31326. * Stops the current optimizer
  31327. */
  31328. stop(): void;
  31329. /**
  31330. * Reset the optimizer to initial step (current priority level = 0)
  31331. */
  31332. reset(): void;
  31333. /**
  31334. * Start the optimizer. By default it will try to reach a specific framerate
  31335. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31336. */
  31337. start(): void;
  31338. private _checkCurrentState;
  31339. /**
  31340. * Release all resources
  31341. */
  31342. dispose(): void;
  31343. /**
  31344. * Helper function to create a SceneOptimizer with one single line of code
  31345. * @param scene defines the scene to work on
  31346. * @param options defines the options to use with the SceneOptimizer
  31347. * @param onSuccess defines a callback to call on success
  31348. * @param onFailure defines a callback to call on failure
  31349. * @returns the new SceneOptimizer object
  31350. */
  31351. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31352. }
  31353. }
  31354. declare module BABYLON {
  31355. class SceneSerializer {
  31356. static ClearCache(): void;
  31357. static Serialize(scene: Scene): any;
  31358. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31359. }
  31360. }
  31361. declare module BABYLON {
  31362. class SmartArray<T> {
  31363. data: Array<T>;
  31364. length: number;
  31365. protected _id: number;
  31366. [index: number]: T;
  31367. constructor(capacity: number);
  31368. push(value: T): void;
  31369. forEach(func: (content: T) => void): void;
  31370. sort(compareFn: (a: T, b: T) => number): void;
  31371. reset(): void;
  31372. dispose(): void;
  31373. concat(array: any): void;
  31374. indexOf(value: T): number;
  31375. contains(value: T): boolean;
  31376. private static _GlobalId;
  31377. }
  31378. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31379. private _duplicateId;
  31380. [index: number]: T;
  31381. push(value: T): void;
  31382. pushNoDuplicate(value: T): boolean;
  31383. reset(): void;
  31384. concatWithNoDuplicate(array: any): void;
  31385. }
  31386. }
  31387. declare module BABYLON {
  31388. /**
  31389. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31390. * The underlying implementation relies on an associative array to ensure the best performances.
  31391. * The value can be anything including 'null' but except 'undefined'
  31392. */
  31393. class StringDictionary<T> {
  31394. /**
  31395. * This will clear this dictionary and copy the content from the 'source' one.
  31396. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31397. * @param source the dictionary to take the content from and copy to this dictionary
  31398. */
  31399. copyFrom(source: StringDictionary<T>): void;
  31400. /**
  31401. * Get a value based from its key
  31402. * @param key the given key to get the matching value from
  31403. * @return the value if found, otherwise undefined is returned
  31404. */
  31405. get(key: string): T | undefined;
  31406. /**
  31407. * Get a value from its key or add it if it doesn't exist.
  31408. * This method will ensure you that a given key/data will be present in the dictionary.
  31409. * @param key the given key to get the matching value from
  31410. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31411. * The factory will only be invoked if there's no data for the given key.
  31412. * @return the value corresponding to the key.
  31413. */
  31414. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31415. /**
  31416. * Get a value from its key if present in the dictionary otherwise add it
  31417. * @param key the key to get the value from
  31418. * @param val if there's no such key/value pair in the dictionary add it with this value
  31419. * @return the value corresponding to the key
  31420. */
  31421. getOrAdd(key: string, val: T): T;
  31422. /**
  31423. * Check if there's a given key in the dictionary
  31424. * @param key the key to check for
  31425. * @return true if the key is present, false otherwise
  31426. */
  31427. contains(key: string): boolean;
  31428. /**
  31429. * Add a new key and its corresponding value
  31430. * @param key the key to add
  31431. * @param value the value corresponding to the key
  31432. * @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
  31433. */
  31434. add(key: string, value: T): boolean;
  31435. set(key: string, value: T): boolean;
  31436. /**
  31437. * Get the element of the given key and remove it from the dictionary
  31438. * @param key
  31439. */
  31440. getAndRemove(key: string): Nullable<T>;
  31441. /**
  31442. * Remove a key/value from the dictionary.
  31443. * @param key the key to remove
  31444. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31445. */
  31446. remove(key: string): boolean;
  31447. /**
  31448. * Clear the whole content of the dictionary
  31449. */
  31450. clear(): void;
  31451. readonly count: number;
  31452. /**
  31453. * Execute a callback on each key/val of the dictionary.
  31454. * Note that you can remove any element in this dictionary in the callback implementation
  31455. * @param callback the callback to execute on a given key/value pair
  31456. */
  31457. forEach(callback: (key: string, val: T) => void): void;
  31458. /**
  31459. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31460. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31461. * Note that you can remove any element in this dictionary in the callback implementation
  31462. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31463. */
  31464. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31465. private _count;
  31466. private _data;
  31467. }
  31468. }
  31469. declare module BABYLON {
  31470. class Tags {
  31471. static EnableFor(obj: any): void;
  31472. static DisableFor(obj: any): void;
  31473. static HasTags(obj: any): boolean;
  31474. static GetTags(obj: any, asString?: boolean): any;
  31475. static AddTagsTo(obj: any, tagsString: string): void;
  31476. static _AddTagTo(obj: any, tag: string): void;
  31477. static RemoveTagsFrom(obj: any, tagsString: string): void;
  31478. static _RemoveTagFrom(obj: any, tag: string): void;
  31479. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  31480. }
  31481. }
  31482. declare module BABYLON {
  31483. class TextureTools {
  31484. /**
  31485. * Uses the GPU to create a copy texture rescaled at a given size
  31486. * @param texture Texture to copy from
  31487. * @param width Desired width
  31488. * @param height Desired height
  31489. * @return Generated texture
  31490. */
  31491. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  31492. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  31493. private static _environmentBRDFBase64Texture;
  31494. }
  31495. }
  31496. declare module BABYLON {
  31497. class TGATools {
  31498. private static _TYPE_INDEXED;
  31499. private static _TYPE_RGB;
  31500. private static _TYPE_GREY;
  31501. private static _TYPE_RLE_INDEXED;
  31502. private static _TYPE_RLE_RGB;
  31503. private static _TYPE_RLE_GREY;
  31504. private static _ORIGIN_MASK;
  31505. private static _ORIGIN_SHIFT;
  31506. private static _ORIGIN_BL;
  31507. private static _ORIGIN_BR;
  31508. private static _ORIGIN_UL;
  31509. private static _ORIGIN_UR;
  31510. static GetTGAHeader(data: Uint8Array): any;
  31511. /**
  31512. * Uploads TGA content to a Babylon Texture
  31513. * @hidden
  31514. */
  31515. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  31516. 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;
  31517. 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;
  31518. 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;
  31519. 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;
  31520. 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;
  31521. 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;
  31522. }
  31523. }
  31524. declare module BABYLON {
  31525. interface IAnimatable {
  31526. animations: Array<Animation>;
  31527. }
  31528. /** Interface used by value gradients (color, factor, ...) */
  31529. interface IValueGradient {
  31530. /**
  31531. * Gets or sets the gradient value (between 0 and 1)
  31532. */
  31533. gradient: number;
  31534. }
  31535. /** Class used to store color gradient */
  31536. class ColorGradient implements IValueGradient {
  31537. /**
  31538. * Gets or sets the gradient value (between 0 and 1)
  31539. */
  31540. gradient: number;
  31541. /**
  31542. * Gets or sets first associated color
  31543. */
  31544. color1: Color4;
  31545. /**
  31546. * Gets or sets second associated color
  31547. */
  31548. color2?: Color4;
  31549. /**
  31550. * Will get a color picked randomly between color1 and color2.
  31551. * If color2 is undefined then color1 will be used
  31552. * @param result defines the target Color4 to store the result in
  31553. */
  31554. getColorToRef(result: Color4): void;
  31555. }
  31556. /** Class used to store factor gradient */
  31557. class FactorGradient implements IValueGradient {
  31558. /**
  31559. * Gets or sets the gradient value (between 0 and 1)
  31560. */
  31561. gradient: number;
  31562. /**
  31563. * Gets or sets first associated factor
  31564. */
  31565. factor1: number;
  31566. /**
  31567. * Gets or sets second associated factor
  31568. */
  31569. factor2?: number;
  31570. /**
  31571. * Will get a number picked randomly between factor1 and factor2.
  31572. * If factor2 is undefined then factor1 will be used
  31573. * @returns the picked number
  31574. */
  31575. getFactor(): number;
  31576. }
  31577. class LoadFileError extends Error {
  31578. request?: XMLHttpRequest | undefined;
  31579. private static _setPrototypeOf;
  31580. constructor(message: string, request?: XMLHttpRequest | undefined);
  31581. }
  31582. class RetryStrategy {
  31583. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31584. }
  31585. interface IFileRequest {
  31586. /**
  31587. * Raised when the request is complete (success or error).
  31588. */
  31589. onCompleteObservable: Observable<IFileRequest>;
  31590. /**
  31591. * Aborts the request for a file.
  31592. */
  31593. abort: () => void;
  31594. }
  31595. class Tools {
  31596. static BaseUrl: string;
  31597. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31598. /**
  31599. * Default behaviour for cors in the application.
  31600. * It can be a string if the expected behavior is identical in the entire app.
  31601. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31602. */
  31603. static CorsBehavior: string | ((url: string | string[]) => string);
  31604. static UseFallbackTexture: boolean;
  31605. /**
  31606. * Use this object to register external classes like custom textures or material
  31607. * to allow the laoders to instantiate them
  31608. */
  31609. static RegisteredExternalClasses: {
  31610. [key: string]: Object;
  31611. };
  31612. static fallbackTexture: string;
  31613. /**
  31614. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31615. * @param u defines the coordinate on X axis
  31616. * @param v defines the coordinate on Y axis
  31617. * @param width defines the width of the source data
  31618. * @param height defines the height of the source data
  31619. * @param pixels defines the source byte array
  31620. * @param color defines the output color
  31621. */
  31622. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31623. /**
  31624. * Interpolates between a and b via alpha
  31625. * @param a The lower value (returned when alpha = 0)
  31626. * @param b The upper value (returned when alpha = 1)
  31627. * @param alpha The interpolation-factor
  31628. * @return The mixed value
  31629. */
  31630. static Mix(a: number, b: number, alpha: number): number;
  31631. static Instantiate(className: string): any;
  31632. /**
  31633. * Provides a slice function that will work even on IE
  31634. * @param data defines the array to slice
  31635. * @param start defines the start of the data (optional)
  31636. * @param end defines the end of the data (optional)
  31637. * @returns the new sliced array
  31638. */
  31639. static Slice<T>(data: T, start?: number, end?: number): T;
  31640. static SetImmediate(action: () => void): void;
  31641. static IsExponentOfTwo(value: number): boolean;
  31642. private static _tmpFloatArray;
  31643. /**
  31644. * Returns the nearest 32-bit single precision float representation of a Number
  31645. * @param value A Number. If the parameter is of a different type, it will get converted
  31646. * to a number or to NaN if it cannot be converted
  31647. * @returns number
  31648. */
  31649. static FloatRound(value: number): number;
  31650. /**
  31651. * Find the next highest power of two.
  31652. * @param x Number to start search from.
  31653. * @return Next highest power of two.
  31654. */
  31655. static CeilingPOT(x: number): number;
  31656. /**
  31657. * Find the next lowest power of two.
  31658. * @param x Number to start search from.
  31659. * @return Next lowest power of two.
  31660. */
  31661. static FloorPOT(x: number): number;
  31662. /**
  31663. * Find the nearest power of two.
  31664. * @param x Number to start search from.
  31665. * @return Next nearest power of two.
  31666. */
  31667. static NearestPOT(x: number): number;
  31668. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31669. static GetFilename(path: string): string;
  31670. /**
  31671. * Extracts the "folder" part of a path (everything before the filename).
  31672. * @param uri The URI to extract the info from
  31673. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31674. * @returns The "folder" part of the path
  31675. */
  31676. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31677. static GetDOMTextContent(element: HTMLElement): string;
  31678. static ToDegrees(angle: number): number;
  31679. static ToRadians(angle: number): number;
  31680. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31681. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31682. minimum: Vector3;
  31683. maximum: Vector3;
  31684. };
  31685. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31686. minimum: Vector3;
  31687. maximum: Vector3;
  31688. };
  31689. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  31690. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  31691. minimum: Vector2;
  31692. maximum: Vector2;
  31693. };
  31694. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31695. static GetPointerPrefix(): string;
  31696. /**
  31697. * @param func - the function to be called
  31698. * @param requester - the object that will request the next frame. Falls back to window.
  31699. */
  31700. static QueueNewFrame(func: () => void, requester?: any): number;
  31701. static RequestFullscreen(element: HTMLElement): void;
  31702. static ExitFullscreen(): void;
  31703. static SetCorsBehavior(url: string | string[], element: {
  31704. crossOrigin: string | null;
  31705. }): void;
  31706. static CleanUrl(url: string): string;
  31707. static PreprocessUrl: (url: string) => string;
  31708. /**
  31709. * Loads an image as an HTMLImageElement.
  31710. * @param input url string, ArrayBuffer, or Blob to load
  31711. * @param onLoad callback called when the image successfully loads
  31712. * @param onError callback called when the image fails to load
  31713. * @param database database for caching
  31714. * @returns the HTMLImageElement of the loaded image
  31715. */
  31716. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  31717. 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;
  31718. /**
  31719. * Load a script (identified by an url). When the url returns, the
  31720. * content of this file is added into a new script element, attached to the DOM (body element)
  31721. */
  31722. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31723. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31724. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31725. static FileAsURL(content: string): string;
  31726. static Format(value: number, decimals?: number): string;
  31727. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31728. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31729. static IsEmpty(obj: any): boolean;
  31730. static RegisterTopRootEvents(events: {
  31731. name: string;
  31732. handler: Nullable<(e: FocusEvent) => any>;
  31733. }[]): void;
  31734. static UnregisterTopRootEvents(events: {
  31735. name: string;
  31736. handler: Nullable<(e: FocusEvent) => any>;
  31737. }[]): void;
  31738. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31739. /**
  31740. * Converts the canvas data to blob.
  31741. * This acts as a polyfill for browsers not supporting the to blob function.
  31742. * @param canvas Defines the canvas to extract the data from
  31743. * @param successCallback Defines the callback triggered once the data are available
  31744. * @param mimeType Defines the mime type of the result
  31745. */
  31746. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31747. /**
  31748. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31749. * @param successCallback Defines the callback triggered once the data are available
  31750. * @param mimeType Defines the mime type of the result
  31751. * @param fileName The filename to download. If present, the result will automatically be downloaded
  31752. */
  31753. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31754. /**
  31755. * Downloads a blob in the browser
  31756. * @param blob defines the blob to download
  31757. * @param fileName defines the name of the downloaded file
  31758. */
  31759. static Download(blob: Blob, fileName: string): void;
  31760. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31761. /**
  31762. * Generates an image screenshot from the specified camera.
  31763. *
  31764. * @param engine The engine to use for rendering
  31765. * @param camera The camera to use for rendering
  31766. * @param size This parameter can be set to a single number or to an object with the
  31767. * following (optional) properties: precision, width, height. If a single number is passed,
  31768. * it will be used for both width and height. If an object is passed, the screenshot size
  31769. * will be derived from the parameters. The precision property is a multiplier allowing
  31770. * rendering at a higher or lower resolution.
  31771. * @param successCallback The callback receives a single parameter which contains the
  31772. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31773. * src parameter of an <img> to display it.
  31774. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31775. * Check your browser for supported MIME types.
  31776. * @param samples Texture samples (default: 1)
  31777. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31778. * @param fileName A name for for the downloaded file.
  31779. * @constructor
  31780. */
  31781. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31782. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  31783. /**
  31784. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31785. * Be aware Math.random() could cause collisions, but:
  31786. * "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"
  31787. */
  31788. static RandomId(): string;
  31789. /**
  31790. * Test if the given uri is a base64 string.
  31791. * @param uri The uri to test
  31792. * @return True if the uri is a base64 string or false otherwise.
  31793. */
  31794. static IsBase64(uri: string): boolean;
  31795. /**
  31796. * Decode the given base64 uri.
  31797. * @param uri The uri to decode
  31798. * @return The decoded base64 data.
  31799. */
  31800. static DecodeBase64(uri: string): ArrayBuffer;
  31801. private static _NoneLogLevel;
  31802. private static _MessageLogLevel;
  31803. private static _WarningLogLevel;
  31804. private static _ErrorLogLevel;
  31805. private static _LogCache;
  31806. static errorsCount: number;
  31807. static OnNewCacheEntry: (entry: string) => void;
  31808. static readonly NoneLogLevel: number;
  31809. static readonly MessageLogLevel: number;
  31810. static readonly WarningLogLevel: number;
  31811. static readonly ErrorLogLevel: number;
  31812. static readonly AllLogLevel: number;
  31813. private static _AddLogEntry;
  31814. private static _FormatMessage;
  31815. private static _LogDisabled;
  31816. private static _LogEnabled;
  31817. private static _WarnDisabled;
  31818. private static _WarnEnabled;
  31819. private static _ErrorDisabled;
  31820. private static _ErrorEnabled;
  31821. static Log: (message: string) => void;
  31822. static Warn: (message: string) => void;
  31823. static Error: (message: string) => void;
  31824. static readonly LogCache: string;
  31825. static ClearLogCache(): void;
  31826. static LogLevels: number;
  31827. /**
  31828. * Check if the loaded document was accessed via `file:`-Protocol.
  31829. * @returns boolean
  31830. */
  31831. static IsFileURL(): boolean;
  31832. static IsWindowObjectExist(): boolean;
  31833. private static _PerformanceNoneLogLevel;
  31834. private static _PerformanceUserMarkLogLevel;
  31835. private static _PerformanceConsoleLogLevel;
  31836. private static _performance;
  31837. static readonly PerformanceNoneLogLevel: number;
  31838. static readonly PerformanceUserMarkLogLevel: number;
  31839. static readonly PerformanceConsoleLogLevel: number;
  31840. static PerformanceLogLevel: number;
  31841. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31842. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31843. static _StartUserMark(counterName: string, condition?: boolean): void;
  31844. static _EndUserMark(counterName: string, condition?: boolean): void;
  31845. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  31846. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  31847. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31848. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31849. static readonly Now: number;
  31850. /**
  31851. * This method will return the name of the class used to create the instance of the given object.
  31852. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31853. * @param object the object to get the class name from
  31854. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  31855. */
  31856. static GetClassName(object: any, isType?: boolean): string;
  31857. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31858. /**
  31859. * This method will return the name of the full name of the class, including its owning module (if any).
  31860. * 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).
  31861. * @param object the object to get the class name from
  31862. * @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.
  31863. */
  31864. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31865. /**
  31866. * 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.
  31867. * @param array
  31868. */
  31869. static arrayOrStringFeeder(array: any): (i: number) => number;
  31870. /**
  31871. * Compute the hashCode of a stream of number
  31872. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  31873. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  31874. * @return the hash code computed
  31875. */
  31876. static hashCodeFromStream(feeder: (index: number) => number): number;
  31877. /**
  31878. * Returns a promise that resolves after the given amount of time.
  31879. * @param delay Number of milliseconds to delay
  31880. * @returns Promise that resolves after the given amount of time
  31881. */
  31882. static DelayAsync(delay: number): Promise<void>;
  31883. /**
  31884. * Gets the current gradient from an array of IValueGradient
  31885. * @param ratio defines the current ratio to get
  31886. * @param gradients defines the array of IValueGradient
  31887. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31888. */
  31889. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31890. }
  31891. /**
  31892. * This class is used to track a performance counter which is number based.
  31893. * The user has access to many properties which give statistics of different nature
  31894. *
  31895. * The implementer can track two kinds of Performance Counter: time and count
  31896. * 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.
  31897. * 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.
  31898. */
  31899. class PerfCounter {
  31900. static Enabled: boolean;
  31901. /**
  31902. * Returns the smallest value ever
  31903. */
  31904. readonly min: number;
  31905. /**
  31906. * Returns the biggest value ever
  31907. */
  31908. readonly max: number;
  31909. /**
  31910. * Returns the average value since the performance counter is running
  31911. */
  31912. readonly average: number;
  31913. /**
  31914. * Returns the average value of the last second the counter was monitored
  31915. */
  31916. readonly lastSecAverage: number;
  31917. /**
  31918. * Returns the current value
  31919. */
  31920. readonly current: number;
  31921. readonly total: number;
  31922. readonly count: number;
  31923. constructor();
  31924. /**
  31925. * Call this method to start monitoring a new frame.
  31926. * 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.
  31927. */
  31928. fetchNewFrame(): void;
  31929. /**
  31930. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31931. * @param newCount the count value to add to the monitored count
  31932. * @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.
  31933. */
  31934. addCount(newCount: number, fetchResult: boolean): void;
  31935. /**
  31936. * Start monitoring this performance counter
  31937. */
  31938. beginMonitoring(): void;
  31939. /**
  31940. * Compute the time lapsed since the previous beginMonitoring() call.
  31941. * @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
  31942. */
  31943. endMonitoring(newFrame?: boolean): void;
  31944. private _fetchResult;
  31945. private _startMonitoringTime;
  31946. private _min;
  31947. private _max;
  31948. private _average;
  31949. private _current;
  31950. private _totalValueCount;
  31951. private _totalAccumulated;
  31952. private _lastSecAverage;
  31953. private _lastSecAccumulated;
  31954. private _lastSecTime;
  31955. private _lastSecValueCount;
  31956. }
  31957. /**
  31958. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31959. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31960. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31961. * @param name The name of the class, case should be preserved
  31962. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31963. */
  31964. function className(name: string, module?: string): (target: Object) => void;
  31965. /**
  31966. * An implementation of a loop for asynchronous functions.
  31967. */
  31968. class AsyncLoop {
  31969. iterations: number;
  31970. private _fn;
  31971. private _successCallback;
  31972. index: number;
  31973. private _done;
  31974. /**
  31975. * Constroctor.
  31976. * @param iterations the number of iterations.
  31977. * @param _fn the function to run each iteration
  31978. * @param _successCallback the callback that will be called upon succesful execution
  31979. * @param offset starting offset.
  31980. */
  31981. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  31982. /**
  31983. * Execute the next iteration. Must be called after the last iteration was finished.
  31984. */
  31985. executeNext(): void;
  31986. /**
  31987. * Break the loop and run the success callback.
  31988. */
  31989. breakLoop(): void;
  31990. /**
  31991. * Helper function
  31992. */
  31993. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  31994. /**
  31995. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31996. * @param iterations total number of iterations
  31997. * @param syncedIterations number of synchronous iterations in each async iteration.
  31998. * @param fn the function to call each iteration.
  31999. * @param callback a success call back that will be called when iterating stops.
  32000. * @param breakFunction a break condition (optional)
  32001. * @param timeout timeout settings for the setTimeout function. default - 0.
  32002. * @constructor
  32003. */
  32004. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  32005. }
  32006. }
  32007. interface HTMLCanvasElement {
  32008. /** Track wether a record is in progress */
  32009. isRecording: boolean;
  32010. /** Capture Stream method defined by some browsers */
  32011. captureStream(fps?: number): MediaStream;
  32012. }
  32013. interface MediaRecorder {
  32014. /** Starts recording */
  32015. start(timeSlice: number): void;
  32016. /** Stops recording */
  32017. stop(): void;
  32018. /** Event raised when an error arised. */
  32019. onerror: (event: ErrorEvent) => void;
  32020. /** Event raised when the recording stops. */
  32021. onstop: (event: Event) => void;
  32022. /** Event raised when a new chunk of data is available and should be tracked. */
  32023. ondataavailable: (event: Event) => void;
  32024. }
  32025. interface MediaRecorderOptions {
  32026. /** The mime type you want to use as the recording container for the new MediaRecorder */
  32027. mimeType?: string;
  32028. /** The chosen bitrate for the audio component of the media. */
  32029. audioBitsPerSecond?: number;
  32030. /** The chosen bitrate for the video component of the media. */
  32031. videoBitsPerSecond?: number;
  32032. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  32033. bitsPerSecond?: number;
  32034. }
  32035. interface MediaRecorderConstructor {
  32036. /**
  32037. * A reference to the prototype.
  32038. */
  32039. readonly prototype: MediaRecorder;
  32040. /**
  32041. * Creates a new MediaRecorder.
  32042. * @param stream Defines the stream to record.
  32043. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  32044. */
  32045. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  32046. }
  32047. /**
  32048. * MediaRecoreder object available in some browsers.
  32049. */
  32050. declare var MediaRecorder: MediaRecorderConstructor;
  32051. declare module BABYLON {
  32052. /**
  32053. * This represents the different options avilable for the video capture.
  32054. */
  32055. interface VideoRecorderOptions {
  32056. /** Defines the mime type of the video */
  32057. mimeType: string;
  32058. /** Defines the video the video should be recorded at */
  32059. fps: number;
  32060. /** Defines the chunk size for the recording data */
  32061. recordChunckSize: number;
  32062. }
  32063. /**
  32064. * This can helps recording videos from BabylonJS.
  32065. * This is based on the available WebRTC functionalities of the browser.
  32066. *
  32067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  32068. */
  32069. class VideoRecorder {
  32070. private static readonly _defaultOptions;
  32071. /**
  32072. * Returns wehther or not the VideoRecorder is available in your browser.
  32073. * @param engine Defines the Babylon Engine to check the support for
  32074. * @returns true if supported otherwise false
  32075. */
  32076. static IsSupported(engine: Engine): boolean;
  32077. private readonly _options;
  32078. private _canvas;
  32079. private _mediaRecorder;
  32080. private _recordedChunks;
  32081. private _fileName;
  32082. private _resolve;
  32083. private _reject;
  32084. /**
  32085. * True wether a recording is already in progress.
  32086. */
  32087. readonly isRecording: boolean;
  32088. /**
  32089. * Create a new VideoCapture object which can help converting what you see in Babylon to
  32090. * a video file.
  32091. * @param engine Defines the BabylonJS Engine you wish to record
  32092. * @param options Defines options that can be used to customized the capture
  32093. */
  32094. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  32095. /**
  32096. * Stops the current recording before the default capture timeout passed in the startRecording
  32097. * functions.
  32098. */
  32099. stopRecording(): void;
  32100. /**
  32101. * Starts recording the canvas for a max duration specified in parameters.
  32102. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  32103. * @param maxDuration Defines the maximum recording time in seconds.
  32104. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  32105. * @return a promise callback at the end of the recording with the video data in Blob.
  32106. */
  32107. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  32108. /**
  32109. * Releases internal resources used during the recording.
  32110. */
  32111. dispose(): void;
  32112. private _handleDataAvailable;
  32113. private _handleError;
  32114. private _handleStop;
  32115. }
  32116. }
  32117. declare module BABYLON {
  32118. /**
  32119. * Defines the potential axis of a Joystick
  32120. */
  32121. enum JoystickAxis {
  32122. /** X axis */
  32123. X = 0,
  32124. /** Y axis */
  32125. Y = 1,
  32126. /** Z axis */
  32127. Z = 2
  32128. }
  32129. /**
  32130. * Class used to define virtual joystick (used in touch mode)
  32131. */
  32132. class VirtualJoystick {
  32133. /**
  32134. * Gets or sets a boolean indicating that left and right values must be inverted
  32135. */
  32136. reverseLeftRight: boolean;
  32137. /**
  32138. * Gets or sets a boolean indicating that up and down values must be inverted
  32139. */
  32140. reverseUpDown: boolean;
  32141. /**
  32142. * Gets the offset value for the position (ie. the change of the position value)
  32143. */
  32144. deltaPosition: Vector3;
  32145. /**
  32146. * Gets a boolean indicating if the virtual joystick was pressed
  32147. */
  32148. pressed: boolean;
  32149. private static _globalJoystickIndex;
  32150. private static vjCanvas;
  32151. private static vjCanvasContext;
  32152. private static vjCanvasWidth;
  32153. private static vjCanvasHeight;
  32154. private static halfWidth;
  32155. private _action;
  32156. private _axisTargetedByLeftAndRight;
  32157. private _axisTargetedByUpAndDown;
  32158. private _joystickSensibility;
  32159. private _inversedSensibility;
  32160. private _joystickPointerID;
  32161. private _joystickColor;
  32162. private _joystickPointerPos;
  32163. private _joystickPreviousPointerPos;
  32164. private _joystickPointerStartPos;
  32165. private _deltaJoystickVector;
  32166. private _leftJoystick;
  32167. private _touches;
  32168. private _onPointerDownHandlerRef;
  32169. private _onPointerMoveHandlerRef;
  32170. private _onPointerUpHandlerRef;
  32171. private _onResize;
  32172. /**
  32173. * Creates a new virtual joystick
  32174. * @param leftJoystick defines that the joystick is for left hand (false by default)
  32175. */
  32176. constructor(leftJoystick?: boolean);
  32177. /**
  32178. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  32179. * @param newJoystickSensibility defines the new sensibility
  32180. */
  32181. setJoystickSensibility(newJoystickSensibility: number): void;
  32182. private _onPointerDown;
  32183. private _onPointerMove;
  32184. private _onPointerUp;
  32185. /**
  32186. * Change the color of the virtual joystick
  32187. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  32188. */
  32189. setJoystickColor(newColor: string): void;
  32190. /**
  32191. * Defines a callback to call when the joystick is touched
  32192. * @param action defines the callback
  32193. */
  32194. setActionOnTouch(action: () => any): void;
  32195. /**
  32196. * Defines which axis you'd like to control for left & right
  32197. * @param axis defines the axis to use
  32198. */
  32199. setAxisForLeftRight(axis: JoystickAxis): void;
  32200. /**
  32201. * Defines which axis you'd like to control for up & down
  32202. * @param axis defines the axis to use
  32203. */
  32204. setAxisForUpDown(axis: JoystickAxis): void;
  32205. private _drawVirtualJoystick;
  32206. /**
  32207. * Release internal HTML canvas
  32208. */
  32209. releaseCanvas(): void;
  32210. }
  32211. }
  32212. declare module BABYLON {
  32213. /**
  32214. * Helper class to push actions to a pool of workers.
  32215. */
  32216. class WorkerPool implements IDisposable {
  32217. private _workerInfos;
  32218. private _pendingActions;
  32219. /**
  32220. * Constructor
  32221. * @param workers Array of workers to use for actions
  32222. */
  32223. constructor(workers: Array<Worker>);
  32224. /**
  32225. * Terminates all workers and clears any pending actions.
  32226. */
  32227. dispose(): void;
  32228. /**
  32229. * Pushes an action to the worker pool. If all the workers are active, the action will be
  32230. * pended until a worker has completed its action.
  32231. * @param action The action to perform. Call onComplete when the action is complete.
  32232. */
  32233. push(action: (worker: Worker, onComplete: () => void) => void): void;
  32234. private _execute;
  32235. }
  32236. }
  32237. declare module BABYLON {
  32238. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  32239. readonly name: string;
  32240. private _zoomStopsAnimation;
  32241. private _idleRotationSpeed;
  32242. private _idleRotationWaitTime;
  32243. private _idleRotationSpinupTime;
  32244. /**
  32245. * Sets the flag that indicates if user zooming should stop animation.
  32246. */
  32247. /**
  32248. * Gets the flag that indicates if user zooming should stop animation.
  32249. */
  32250. zoomStopsAnimation: boolean;
  32251. /**
  32252. * Sets the default speed at which the camera rotates around the model.
  32253. */
  32254. /**
  32255. * Gets the default speed at which the camera rotates around the model.
  32256. */
  32257. idleRotationSpeed: number;
  32258. /**
  32259. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  32260. */
  32261. /**
  32262. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  32263. */
  32264. idleRotationWaitTime: number;
  32265. /**
  32266. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32267. */
  32268. /**
  32269. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32270. */
  32271. idleRotationSpinupTime: number;
  32272. /**
  32273. * Gets a value indicating if the camera is currently rotating because of this behavior
  32274. */
  32275. readonly rotationInProgress: boolean;
  32276. private _onPrePointerObservableObserver;
  32277. private _onAfterCheckInputsObserver;
  32278. private _attachedCamera;
  32279. private _isPointerDown;
  32280. private _lastFrameTime;
  32281. private _lastInteractionTime;
  32282. private _cameraRotationSpeed;
  32283. init(): void;
  32284. attach(camera: ArcRotateCamera): void;
  32285. detach(): void;
  32286. /**
  32287. * Returns true if user is scrolling.
  32288. * @return true if user is scrolling.
  32289. */
  32290. private _userIsZooming;
  32291. private _lastFrameRadius;
  32292. private _shouldAnimationStopForInteraction;
  32293. /**
  32294. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32295. */
  32296. private _applyUserInteraction;
  32297. private _userIsMoving;
  32298. }
  32299. }
  32300. declare module BABYLON {
  32301. /**
  32302. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32303. */
  32304. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32305. readonly name: string;
  32306. /**
  32307. * The easing function used by animations
  32308. */
  32309. static EasingFunction: BackEase;
  32310. /**
  32311. * The easing mode used by animations
  32312. */
  32313. static EasingMode: number;
  32314. /**
  32315. * The duration of the animation, in milliseconds
  32316. */
  32317. transitionDuration: number;
  32318. /**
  32319. * Length of the distance animated by the transition when lower radius is reached
  32320. */
  32321. lowerRadiusTransitionRange: number;
  32322. /**
  32323. * Length of the distance animated by the transition when upper radius is reached
  32324. */
  32325. upperRadiusTransitionRange: number;
  32326. private _autoTransitionRange;
  32327. /**
  32328. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32329. */
  32330. /**
  32331. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32332. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32333. */
  32334. autoTransitionRange: boolean;
  32335. private _attachedCamera;
  32336. private _onAfterCheckInputsObserver;
  32337. private _onMeshTargetChangedObserver;
  32338. init(): void;
  32339. attach(camera: ArcRotateCamera): void;
  32340. detach(): void;
  32341. private _radiusIsAnimating;
  32342. private _radiusBounceTransition;
  32343. private _animatables;
  32344. private _cachedWheelPrecision;
  32345. /**
  32346. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32347. * @param radiusLimit The limit to check against.
  32348. * @return Bool to indicate if at limit.
  32349. */
  32350. private _isRadiusAtLimit;
  32351. /**
  32352. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32353. * @param radiusDelta The delta by which to animate to. Can be negative.
  32354. */
  32355. private _applyBoundRadiusAnimation;
  32356. /**
  32357. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32358. */
  32359. protected _clearAnimationLocks(): void;
  32360. /**
  32361. * Stops and removes all animations that have been applied to the camera
  32362. */
  32363. stopAllAnimations(): void;
  32364. }
  32365. }
  32366. declare module BABYLON {
  32367. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32368. readonly name: string;
  32369. private _mode;
  32370. private _radiusScale;
  32371. private _positionScale;
  32372. private _defaultElevation;
  32373. private _elevationReturnTime;
  32374. private _elevationReturnWaitTime;
  32375. private _zoomStopsAnimation;
  32376. private _framingTime;
  32377. /**
  32378. * The easing function used by animations
  32379. */
  32380. static EasingFunction: ExponentialEase;
  32381. /**
  32382. * The easing mode used by animations
  32383. */
  32384. static EasingMode: number;
  32385. /**
  32386. * Sets the current mode used by the behavior
  32387. */
  32388. /**
  32389. * Gets current mode used by the behavior.
  32390. */
  32391. mode: number;
  32392. /**
  32393. * Sets the scale applied to the radius (1 by default)
  32394. */
  32395. /**
  32396. * Gets the scale applied to the radius
  32397. */
  32398. radiusScale: number;
  32399. /**
  32400. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32401. */
  32402. /**
  32403. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32404. */
  32405. positionScale: number;
  32406. /**
  32407. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32408. * behaviour is triggered, in radians.
  32409. */
  32410. /**
  32411. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32412. * behaviour is triggered, in radians.
  32413. */
  32414. defaultElevation: number;
  32415. /**
  32416. * Sets the time (in milliseconds) taken to return to the default beta position.
  32417. * Negative value indicates camera should not return to default.
  32418. */
  32419. /**
  32420. * Gets the time (in milliseconds) taken to return to the default beta position.
  32421. * Negative value indicates camera should not return to default.
  32422. */
  32423. elevationReturnTime: number;
  32424. /**
  32425. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32426. */
  32427. /**
  32428. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32429. */
  32430. elevationReturnWaitTime: number;
  32431. /**
  32432. * Sets the flag that indicates if user zooming should stop animation.
  32433. */
  32434. /**
  32435. * Gets the flag that indicates if user zooming should stop animation.
  32436. */
  32437. zoomStopsAnimation: boolean;
  32438. /**
  32439. * Sets the transition time when framing the mesh, in milliseconds
  32440. */
  32441. /**
  32442. * Gets the transition time when framing the mesh, in milliseconds
  32443. */
  32444. framingTime: number;
  32445. private _onPrePointerObservableObserver;
  32446. private _onAfterCheckInputsObserver;
  32447. private _onMeshTargetChangedObserver;
  32448. private _attachedCamera;
  32449. private _isPointerDown;
  32450. private _lastInteractionTime;
  32451. init(): void;
  32452. attach(camera: ArcRotateCamera): void;
  32453. detach(): void;
  32454. private _animatables;
  32455. private _betaIsAnimating;
  32456. private _betaTransition;
  32457. private _radiusTransition;
  32458. private _vectorTransition;
  32459. /**
  32460. * Targets the given mesh and updates zoom level accordingly.
  32461. * @param mesh The mesh to target.
  32462. * @param radius Optional. If a cached radius position already exists, overrides default.
  32463. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32464. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32465. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32466. */
  32467. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32468. /**
  32469. * Targets the given mesh with its children and updates zoom level accordingly.
  32470. * @param mesh The mesh to target.
  32471. * @param radius Optional. If a cached radius position already exists, overrides default.
  32472. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32473. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32474. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32475. */
  32476. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32477. /**
  32478. * Targets the given meshes with their children and updates zoom level accordingly.
  32479. * @param meshes The mesh to target.
  32480. * @param radius Optional. If a cached radius position already exists, overrides default.
  32481. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32482. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32483. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32484. */
  32485. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32486. /**
  32487. * Targets the given mesh and updates zoom level accordingly.
  32488. * @param mesh The mesh to target.
  32489. * @param radius Optional. If a cached radius position already exists, overrides default.
  32490. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32491. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32492. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32493. */
  32494. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32495. /**
  32496. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  32497. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  32498. * frustum width.
  32499. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  32500. * to fully enclose the mesh in the viewing frustum.
  32501. */
  32502. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  32503. /**
  32504. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  32505. * is automatically returned to its default position (expected to be above ground plane).
  32506. */
  32507. private _maintainCameraAboveGround;
  32508. /**
  32509. * Returns the frustum slope based on the canvas ratio and camera FOV
  32510. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  32511. */
  32512. private _getFrustumSlope;
  32513. /**
  32514. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  32515. */
  32516. private _clearAnimationLocks;
  32517. /**
  32518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32519. */
  32520. private _applyUserInteraction;
  32521. /**
  32522. * Stops and removes all animations that have been applied to the camera
  32523. */
  32524. stopAllAnimations(): void;
  32525. /**
  32526. * Gets a value indicating if the user is moving the camera
  32527. */
  32528. readonly isUserIsMoving: boolean;
  32529. /**
  32530. * The camera can move all the way towards the mesh.
  32531. */
  32532. static IgnoreBoundsSizeMode: number;
  32533. /**
  32534. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  32535. */
  32536. static FitFrustumSidesMode: number;
  32537. }
  32538. }
  32539. declare module BABYLON {
  32540. /**
  32541. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  32542. */
  32543. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  32544. private ui;
  32545. /**
  32546. * The name of the behavior
  32547. */
  32548. name: string;
  32549. /**
  32550. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  32551. */
  32552. distanceAwayFromFace: number;
  32553. /**
  32554. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  32555. */
  32556. distanceAwayFromBottomOfFace: number;
  32557. private _faceVectors;
  32558. private _target;
  32559. private _scene;
  32560. private _onRenderObserver;
  32561. private _tmpMatrix;
  32562. private _tmpVector;
  32563. /**
  32564. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  32565. * @param ui The transform node that should be attched to the mesh
  32566. */
  32567. constructor(ui: BABYLON.TransformNode);
  32568. /**
  32569. * Initializes the behavior
  32570. */
  32571. init(): void;
  32572. private _closestFace;
  32573. private _zeroVector;
  32574. private _lookAtTmpMatrix;
  32575. private _lookAtToRef;
  32576. /**
  32577. * Attaches the AttachToBoxBehavior to the passed in mesh
  32578. * @param target The mesh that the specified node will be attached to
  32579. */
  32580. attach(target: BABYLON.Mesh): void;
  32581. /**
  32582. * Detaches the behavior from the mesh
  32583. */
  32584. detach(): void;
  32585. }
  32586. }
  32587. declare module BABYLON {
  32588. /**
  32589. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  32590. */
  32591. class FadeInOutBehavior implements Behavior<Mesh> {
  32592. /**
  32593. * Time in milliseconds to delay before fading in (Default: 0)
  32594. */
  32595. delay: number;
  32596. /**
  32597. * Time in milliseconds for the mesh to fade in (Default: 300)
  32598. */
  32599. fadeInTime: number;
  32600. private _millisecondsPerFrame;
  32601. private _hovered;
  32602. private _hoverValue;
  32603. private _ownerNode;
  32604. /**
  32605. * Instatiates the FadeInOutBehavior
  32606. */
  32607. constructor();
  32608. /**
  32609. * The name of the behavior
  32610. */
  32611. readonly name: string;
  32612. /**
  32613. * Initializes the behavior
  32614. */
  32615. init(): void;
  32616. /**
  32617. * Attaches the fade behavior on the passed in mesh
  32618. * @param ownerNode The mesh that will be faded in/out once attached
  32619. */
  32620. attach(ownerNode: Mesh): void;
  32621. /**
  32622. * Detaches the behavior from the mesh
  32623. */
  32624. detach(): void;
  32625. /**
  32626. * Triggers the mesh to begin fading in or out
  32627. * @param value if the object should fade in or out (true to fade in)
  32628. */
  32629. fadeIn(value: boolean): void;
  32630. private _update;
  32631. private _setAllVisibility;
  32632. }
  32633. }
  32634. declare module BABYLON {
  32635. /**
  32636. * A behavior that when attached to a mesh will allow the mesh to be scaled
  32637. */
  32638. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  32639. private _dragBehaviorA;
  32640. private _dragBehaviorB;
  32641. private _startDistance;
  32642. private _initialScale;
  32643. private _targetScale;
  32644. private _ownerNode;
  32645. private _sceneRenderObserver;
  32646. constructor();
  32647. /**
  32648. * The name of the behavior
  32649. */
  32650. readonly name: string;
  32651. /**
  32652. * Initializes the behavior
  32653. */
  32654. init(): void;
  32655. private _getCurrentDistance;
  32656. /**
  32657. * Attaches the scale behavior the passed in mesh
  32658. * @param ownerNode The mesh that will be scaled around once attached
  32659. */
  32660. attach(ownerNode: Mesh): void;
  32661. /**
  32662. * Detaches the behavior from the mesh
  32663. */
  32664. detach(): void;
  32665. }
  32666. }
  32667. declare module BABYLON {
  32668. /**
  32669. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  32670. */
  32671. class PointerDragBehavior implements Behavior<Mesh> {
  32672. private _attachedNode;
  32673. private _dragPlane;
  32674. private _scene;
  32675. private _pointerObserver;
  32676. private _beforeRenderObserver;
  32677. private static _planeScene;
  32678. /**
  32679. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  32680. */
  32681. maxDragAngle: number;
  32682. /**
  32683. * @hidden
  32684. */
  32685. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  32686. /**
  32687. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32688. */
  32689. currentDraggingPointerID: number;
  32690. /**
  32691. * The last position where the pointer hit the drag plane in world space
  32692. */
  32693. lastDragPosition: Vector3;
  32694. /**
  32695. * If the behavior is currently in a dragging state
  32696. */
  32697. dragging: boolean;
  32698. /**
  32699. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32700. */
  32701. dragDeltaRatio: number;
  32702. /**
  32703. * If the drag plane orientation should be updated during the dragging (Default: true)
  32704. */
  32705. updateDragPlane: boolean;
  32706. private _debugMode;
  32707. private _moving;
  32708. /**
  32709. * Fires each time the attached mesh is dragged with the pointer
  32710. * * delta between last drag position and current drag position in world space
  32711. * * dragDistance along the drag axis
  32712. * * dragPlaneNormal normal of the current drag plane used during the drag
  32713. * * dragPlanePoint in world space where the drag intersects the drag plane
  32714. */
  32715. onDragObservable: Observable<{
  32716. delta: Vector3;
  32717. dragPlanePoint: Vector3;
  32718. dragPlaneNormal: Vector3;
  32719. dragDistance: number;
  32720. pointerId: number;
  32721. }>;
  32722. /**
  32723. * Fires each time a drag begins (eg. mouse down on mesh)
  32724. */
  32725. onDragStartObservable: Observable<{
  32726. dragPlanePoint: Vector3;
  32727. pointerId: number;
  32728. }>;
  32729. /**
  32730. * Fires each time a drag ends (eg. mouse release after drag)
  32731. */
  32732. onDragEndObservable: Observable<{
  32733. dragPlanePoint: Vector3;
  32734. pointerId: number;
  32735. }>;
  32736. /**
  32737. * If the attached mesh should be moved when dragged
  32738. */
  32739. moveAttached: boolean;
  32740. /**
  32741. * If the drag behavior will react to drag events (Default: true)
  32742. */
  32743. enabled: boolean;
  32744. /**
  32745. * If camera controls should be detached during the drag
  32746. */
  32747. detachCameraControls: boolean;
  32748. /**
  32749. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32750. */
  32751. useObjectOrienationForDragging: boolean;
  32752. private _options;
  32753. /**
  32754. * Creates a pointer drag behavior that can be attached to a mesh
  32755. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  32756. */
  32757. constructor(options?: {
  32758. dragAxis?: Vector3;
  32759. dragPlaneNormal?: Vector3;
  32760. });
  32761. /**
  32762. * The name of the behavior
  32763. */
  32764. readonly name: string;
  32765. /**
  32766. * Initializes the behavior
  32767. */
  32768. init(): void;
  32769. private _tmpVector;
  32770. private _alternatePickedPoint;
  32771. private _worldDragAxis;
  32772. private _targetPosition;
  32773. private _attachedElement;
  32774. /**
  32775. * Attaches the drag behavior the passed in mesh
  32776. * @param ownerNode The mesh that will be dragged around once attached
  32777. */
  32778. attach(ownerNode: Mesh): void;
  32779. releaseDrag(): void;
  32780. private _startDragRay;
  32781. private _lastPointerRay;
  32782. /**
  32783. * Simulates the start of a pointer drag event on the behavior
  32784. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  32785. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  32786. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  32787. */
  32788. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  32789. private _startDrag;
  32790. private _dragDelta;
  32791. private _moveDrag;
  32792. private _pickWithRayOnDragPlane;
  32793. private _pointA;
  32794. private _pointB;
  32795. private _pointC;
  32796. private _lineA;
  32797. private _lineB;
  32798. private _localAxis;
  32799. private _lookAt;
  32800. private _updateDragPlanePosition;
  32801. /**
  32802. * Detaches the behavior from the mesh
  32803. */
  32804. detach(): void;
  32805. }
  32806. }
  32807. declare module BABYLON {
  32808. /**
  32809. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  32810. */
  32811. class SixDofDragBehavior implements Behavior<Mesh> {
  32812. private static _virtualScene;
  32813. private _ownerNode;
  32814. private _sceneRenderObserver;
  32815. private _scene;
  32816. private _targetPosition;
  32817. private _virtualOriginMesh;
  32818. private _virtualDragMesh;
  32819. private _pointerObserver;
  32820. private _moving;
  32821. private _startingOrientation;
  32822. /**
  32823. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  32824. */
  32825. private zDragFactor;
  32826. /**
  32827. * If the behavior is currently in a dragging state
  32828. */
  32829. dragging: boolean;
  32830. /**
  32831. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32832. */
  32833. dragDeltaRatio: number;
  32834. /**
  32835. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32836. */
  32837. currentDraggingPointerID: number;
  32838. /**
  32839. * If camera controls should be detached during the drag
  32840. */
  32841. detachCameraControls: boolean;
  32842. constructor();
  32843. /**
  32844. * The name of the behavior
  32845. */
  32846. readonly name: string;
  32847. /**
  32848. * Initializes the behavior
  32849. */
  32850. init(): void;
  32851. /**
  32852. * Attaches the scale behavior the passed in mesh
  32853. * @param ownerNode The mesh that will be scaled around once attached
  32854. */
  32855. attach(ownerNode: Mesh): void;
  32856. /**
  32857. * Detaches the behavior from the mesh
  32858. */
  32859. detach(): void;
  32860. }
  32861. }
  32862. declare module BABYLON {
  32863. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  32864. camera: ArcRotateCamera;
  32865. gamepad: Nullable<Gamepad>;
  32866. private _onGamepadConnectedObserver;
  32867. private _onGamepadDisconnectedObserver;
  32868. gamepadRotationSensibility: number;
  32869. gamepadMoveSensibility: number;
  32870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32871. detachControl(element: Nullable<HTMLElement>): void;
  32872. checkInputs(): void;
  32873. getClassName(): string;
  32874. getSimpleName(): string;
  32875. }
  32876. }
  32877. declare module BABYLON {
  32878. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  32879. camera: ArcRotateCamera;
  32880. private _keys;
  32881. keysUp: number[];
  32882. keysDown: number[];
  32883. keysLeft: number[];
  32884. keysRight: number[];
  32885. keysReset: number[];
  32886. panningSensibility: number;
  32887. zoomingSensibility: number;
  32888. useAltToZoom: boolean;
  32889. private _ctrlPressed;
  32890. private _altPressed;
  32891. private _onCanvasBlurObserver;
  32892. private _onKeyboardObserver;
  32893. private _engine;
  32894. private _scene;
  32895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32896. detachControl(element: Nullable<HTMLElement>): void;
  32897. checkInputs(): void;
  32898. getClassName(): string;
  32899. getSimpleName(): string;
  32900. }
  32901. }
  32902. declare module BABYLON {
  32903. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  32904. camera: ArcRotateCamera;
  32905. private _wheel;
  32906. private _observer;
  32907. wheelPrecision: number;
  32908. /**
  32909. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  32910. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  32911. */
  32912. wheelDeltaPercentage: number;
  32913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32914. detachControl(element: Nullable<HTMLElement>): void;
  32915. getClassName(): string;
  32916. getSimpleName(): string;
  32917. }
  32918. }
  32919. declare module BABYLON {
  32920. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  32921. camera: ArcRotateCamera;
  32922. buttons: number[];
  32923. angularSensibilityX: number;
  32924. angularSensibilityY: number;
  32925. pinchPrecision: number;
  32926. /**
  32927. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  32928. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  32929. */
  32930. pinchDeltaPercentage: number;
  32931. panningSensibility: number;
  32932. multiTouchPanning: boolean;
  32933. multiTouchPanAndZoom: boolean;
  32934. private _isPanClick;
  32935. pinchInwards: boolean;
  32936. private _pointerInput;
  32937. private _observer;
  32938. private _onMouseMove;
  32939. private _onGestureStart;
  32940. private _onGesture;
  32941. private _MSGestureHandler;
  32942. private _onLostFocus;
  32943. private _onContextMenu;
  32944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32945. detachControl(element: Nullable<HTMLElement>): void;
  32946. getClassName(): string;
  32947. getSimpleName(): string;
  32948. }
  32949. }
  32950. declare module BABYLON {
  32951. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  32952. camera: ArcRotateCamera;
  32953. alphaCorrection: number;
  32954. betaCorrection: number;
  32955. gammaCorrection: number;
  32956. private _alpha;
  32957. private _gamma;
  32958. private _dirty;
  32959. private _deviceOrientationHandler;
  32960. constructor();
  32961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32962. /** @hidden */
  32963. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  32964. checkInputs(): void;
  32965. detachControl(element: Nullable<HTMLElement>): void;
  32966. getClassName(): string;
  32967. getSimpleName(): string;
  32968. }
  32969. }
  32970. declare module BABYLON {
  32971. /**
  32972. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  32973. * Screen rotation is taken into account.
  32974. */
  32975. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  32976. private _camera;
  32977. private _screenOrientationAngle;
  32978. private _constantTranform;
  32979. private _screenQuaternion;
  32980. private _alpha;
  32981. private _beta;
  32982. private _gamma;
  32983. constructor();
  32984. camera: FreeCamera;
  32985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32986. private _orientationChanged;
  32987. private _deviceOrientation;
  32988. detachControl(element: Nullable<HTMLElement>): void;
  32989. checkInputs(): void;
  32990. getClassName(): string;
  32991. getSimpleName(): string;
  32992. }
  32993. }
  32994. declare module BABYLON {
  32995. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  32996. camera: FreeCamera;
  32997. gamepad: Nullable<Gamepad>;
  32998. private _onGamepadConnectedObserver;
  32999. private _onGamepadDisconnectedObserver;
  33000. gamepadAngularSensibility: number;
  33001. gamepadMoveSensibility: number;
  33002. private _cameraTransform;
  33003. private _deltaTransform;
  33004. private _vector3;
  33005. private _vector2;
  33006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33007. detachControl(element: Nullable<HTMLElement>): void;
  33008. checkInputs(): void;
  33009. getClassName(): string;
  33010. getSimpleName(): string;
  33011. }
  33012. }
  33013. declare module BABYLON {
  33014. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  33015. camera: FreeCamera;
  33016. private _keys;
  33017. private _onCanvasBlurObserver;
  33018. private _onKeyboardObserver;
  33019. private _engine;
  33020. private _scene;
  33021. keysUp: number[];
  33022. keysDown: number[];
  33023. keysLeft: number[];
  33024. keysRight: number[];
  33025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33026. detachControl(element: Nullable<HTMLElement>): void;
  33027. checkInputs(): void;
  33028. getClassName(): string;
  33029. /** @hidden */
  33030. _onLostFocus(e: FocusEvent): void;
  33031. getSimpleName(): string;
  33032. }
  33033. }
  33034. declare module BABYLON {
  33035. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  33036. touchEnabled: boolean;
  33037. camera: FreeCamera;
  33038. buttons: number[];
  33039. angularSensibility: number;
  33040. private _pointerInput;
  33041. private _onMouseMove;
  33042. private _observer;
  33043. private previousPosition;
  33044. constructor(touchEnabled?: boolean);
  33045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33046. detachControl(element: Nullable<HTMLElement>): void;
  33047. getClassName(): string;
  33048. getSimpleName(): string;
  33049. }
  33050. }
  33051. declare module BABYLON {
  33052. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  33053. camera: FreeCamera;
  33054. private _offsetX;
  33055. private _offsetY;
  33056. private _pointerPressed;
  33057. private _pointerInput;
  33058. private _observer;
  33059. private _onLostFocus;
  33060. touchAngularSensibility: number;
  33061. touchMoveSensibility: number;
  33062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33063. detachControl(element: Nullable<HTMLElement>): void;
  33064. checkInputs(): void;
  33065. getClassName(): string;
  33066. getSimpleName(): string;
  33067. }
  33068. }
  33069. declare module BABYLON {
  33070. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  33071. camera: FreeCamera;
  33072. private _leftjoystick;
  33073. private _rightjoystick;
  33074. getLeftJoystick(): VirtualJoystick;
  33075. getRightJoystick(): VirtualJoystick;
  33076. checkInputs(): void;
  33077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33078. detachControl(element: Nullable<HTMLElement>): void;
  33079. getClassName(): string;
  33080. getSimpleName(): string;
  33081. }
  33082. }
  33083. declare module BABYLON {
  33084. /**
  33085. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  33086. */
  33087. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  33088. /**
  33089. * Creates a new AnaglyphArcRotateCamera
  33090. * @param name defines camera name
  33091. * @param alpha defines alpha angle (in radians)
  33092. * @param beta defines beta angle (in radians)
  33093. * @param radius defines radius
  33094. * @param target defines camera target
  33095. * @param interaxialDistance defines distance between each color axis
  33096. * @param scene defines the hosting scene
  33097. */
  33098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  33099. /**
  33100. * Gets camera class name
  33101. * @returns AnaglyphArcRotateCamera
  33102. */
  33103. getClassName(): string;
  33104. }
  33105. }
  33106. declare module BABYLON {
  33107. /**
  33108. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  33109. */
  33110. class AnaglyphFreeCamera extends FreeCamera {
  33111. /**
  33112. * Creates a new AnaglyphFreeCamera
  33113. * @param name defines camera name
  33114. * @param position defines initial position
  33115. * @param interaxialDistance defines distance between each color axis
  33116. * @param scene defines the hosting scene
  33117. */
  33118. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33119. /**
  33120. * Gets camera class name
  33121. * @returns AnaglyphFreeCamera
  33122. */
  33123. getClassName(): string;
  33124. }
  33125. }
  33126. declare module BABYLON {
  33127. /**
  33128. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  33129. */
  33130. class AnaglyphGamepadCamera extends GamepadCamera {
  33131. /**
  33132. * Creates a new AnaglyphGamepadCamera
  33133. * @param name defines camera name
  33134. * @param position defines initial position
  33135. * @param interaxialDistance defines distance between each color axis
  33136. * @param scene defines the hosting scene
  33137. */
  33138. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33139. /**
  33140. * Gets camera class name
  33141. * @returns AnaglyphGamepadCamera
  33142. */
  33143. getClassName(): string;
  33144. }
  33145. }
  33146. declare module BABYLON {
  33147. /**
  33148. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  33149. */
  33150. class AnaglyphUniversalCamera extends UniversalCamera {
  33151. /**
  33152. * Creates a new AnaglyphUniversalCamera
  33153. * @param name defines camera name
  33154. * @param position defines initial position
  33155. * @param interaxialDistance defines distance between each color axis
  33156. * @param scene defines the hosting scene
  33157. */
  33158. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33159. /**
  33160. * Gets camera class name
  33161. * @returns AnaglyphUniversalCamera
  33162. */
  33163. getClassName(): string;
  33164. }
  33165. }
  33166. declare module BABYLON {
  33167. /**
  33168. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  33169. */
  33170. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  33171. /**
  33172. * Creates a new StereoscopicArcRotateCamera
  33173. * @param name defines camera name
  33174. * @param alpha defines alpha angle (in radians)
  33175. * @param beta defines beta angle (in radians)
  33176. * @param radius defines radius
  33177. * @param target defines camera target
  33178. * @param interaxialDistance defines distance between each color axis
  33179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33180. * @param scene defines the hosting scene
  33181. */
  33182. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33183. /**
  33184. * Gets camera class name
  33185. * @returns StereoscopicArcRotateCamera
  33186. */
  33187. getClassName(): string;
  33188. }
  33189. }
  33190. declare module BABYLON {
  33191. /**
  33192. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  33193. */
  33194. class StereoscopicFreeCamera extends FreeCamera {
  33195. /**
  33196. * Creates a new StereoscopicFreeCamera
  33197. * @param name defines camera name
  33198. * @param position defines initial position
  33199. * @param interaxialDistance defines distance between each color axis
  33200. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33201. * @param scene defines the hosting scene
  33202. */
  33203. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33204. /**
  33205. * Gets camera class name
  33206. * @returns StereoscopicFreeCamera
  33207. */
  33208. getClassName(): string;
  33209. }
  33210. }
  33211. declare module BABYLON {
  33212. /**
  33213. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  33214. */
  33215. class StereoscopicGamepadCamera extends GamepadCamera {
  33216. /**
  33217. * Creates a new StereoscopicGamepadCamera
  33218. * @param name defines camera name
  33219. * @param position defines initial position
  33220. * @param interaxialDistance defines distance between each color axis
  33221. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33222. * @param scene defines the hosting scene
  33223. */
  33224. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33225. /**
  33226. * Gets camera class name
  33227. * @returns StereoscopicGamepadCamera
  33228. */
  33229. getClassName(): string;
  33230. }
  33231. }
  33232. declare module BABYLON {
  33233. /**
  33234. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  33235. */
  33236. class StereoscopicUniversalCamera extends UniversalCamera {
  33237. /**
  33238. * Creates a new StereoscopicUniversalCamera
  33239. * @param name defines camera name
  33240. * @param position defines initial position
  33241. * @param interaxialDistance defines distance between each color axis
  33242. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33243. * @param scene defines the hosting scene
  33244. */
  33245. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33246. /**
  33247. * Gets camera class name
  33248. * @returns StereoscopicUniversalCamera
  33249. */
  33250. getClassName(): string;
  33251. }
  33252. }
  33253. declare module BABYLON {
  33254. class VRCameraMetrics {
  33255. hResolution: number;
  33256. vResolution: number;
  33257. hScreenSize: number;
  33258. vScreenSize: number;
  33259. vScreenCenter: number;
  33260. eyeToScreenDistance: number;
  33261. lensSeparationDistance: number;
  33262. interpupillaryDistance: number;
  33263. distortionK: number[];
  33264. chromaAbCorrection: number[];
  33265. postProcessScaleFactor: number;
  33266. lensCenterOffset: number;
  33267. compensateDistortion: boolean;
  33268. readonly aspectRatio: number;
  33269. readonly aspectRatioFov: number;
  33270. readonly leftHMatrix: Matrix;
  33271. readonly rightHMatrix: Matrix;
  33272. readonly leftPreViewMatrix: Matrix;
  33273. readonly rightPreViewMatrix: Matrix;
  33274. static GetDefault(): VRCameraMetrics;
  33275. }
  33276. }
  33277. declare module BABYLON {
  33278. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  33279. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33280. getClassName(): string;
  33281. }
  33282. }
  33283. declare module BABYLON {
  33284. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  33285. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33286. getClassName(): string;
  33287. }
  33288. }
  33289. declare module BABYLON {
  33290. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  33291. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33292. getClassName(): string;
  33293. }
  33294. }
  33295. declare module BABYLON {
  33296. /**
  33297. * Options to modify the vr teleportation behavior.
  33298. */
  33299. interface VRTeleportationOptions {
  33300. /**
  33301. * The name of the mesh which should be used as the teleportation floor. (default: null)
  33302. */
  33303. floorMeshName?: string;
  33304. /**
  33305. * A list of meshes to be used as the teleportation floor. (default: empty)
  33306. */
  33307. floorMeshes?: Mesh[];
  33308. }
  33309. /**
  33310. * Options to modify the vr experience helper's behavior.
  33311. */
  33312. interface VRExperienceHelperOptions extends WebVROptions {
  33313. /**
  33314. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  33315. */
  33316. createDeviceOrientationCamera?: boolean;
  33317. /**
  33318. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  33319. */
  33320. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  33321. /**
  33322. * Uses the main button on the controller to toggle the laser casted. (default: true)
  33323. */
  33324. laserToggle?: boolean;
  33325. /**
  33326. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  33327. */
  33328. floorMeshes?: Mesh[];
  33329. }
  33330. /**
  33331. * Helps to quickly add VR support to an existing scene.
  33332. * See http://doc.babylonjs.com/how_to/webvr_helper
  33333. */
  33334. class VRExperienceHelper {
  33335. /** Options to modify the vr experience helper's behavior. */
  33336. webVROptions: VRExperienceHelperOptions;
  33337. private _scene;
  33338. private _position;
  33339. private _btnVR;
  33340. private _btnVRDisplayed;
  33341. private _webVRsupported;
  33342. private _webVRready;
  33343. private _webVRrequesting;
  33344. private _webVRpresenting;
  33345. private _hasEnteredVR;
  33346. private _fullscreenVRpresenting;
  33347. private _canvas;
  33348. private _webVRCamera;
  33349. private _vrDeviceOrientationCamera;
  33350. private _deviceOrientationCamera;
  33351. private _existingCamera;
  33352. private _onKeyDown;
  33353. private _onVrDisplayPresentChange;
  33354. private _onVRDisplayChanged;
  33355. private _onVRRequestPresentStart;
  33356. private _onVRRequestPresentComplete;
  33357. /**
  33358. * Observable raised when entering VR.
  33359. */
  33360. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33361. /**
  33362. * Observable raised when exiting VR.
  33363. */
  33364. onExitingVRObservable: Observable<VRExperienceHelper>;
  33365. /**
  33366. * Observable raised when controller mesh is loaded.
  33367. */
  33368. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33369. /** Return this.onEnteringVRObservable
  33370. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33371. */
  33372. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33373. /** Return this.onExitingVRObservable
  33374. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33375. */
  33376. readonly onExitingVR: Observable<VRExperienceHelper>;
  33377. /** Return this.onControllerMeshLoadedObservable
  33378. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33379. */
  33380. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33381. private _rayLength;
  33382. private _useCustomVRButton;
  33383. private _teleportationRequested;
  33384. private _teleportActive;
  33385. private _floorMeshName;
  33386. private _floorMeshesCollection;
  33387. private _rotationAllowed;
  33388. private _teleportBackwardsVector;
  33389. private _teleportationTarget;
  33390. private _isDefaultTeleportationTarget;
  33391. private _postProcessMove;
  33392. private _teleportationFillColor;
  33393. private _teleportationBorderColor;
  33394. private _rotationAngle;
  33395. private _haloCenter;
  33396. private _cameraGazer;
  33397. private _padSensibilityUp;
  33398. private _padSensibilityDown;
  33399. private _leftController;
  33400. private _rightController;
  33401. /**
  33402. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  33403. */
  33404. onNewMeshSelected: Observable<AbstractMesh>;
  33405. /**
  33406. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  33407. */
  33408. onNewMeshPicked: Observable<PickingInfo>;
  33409. private _circleEase;
  33410. /**
  33411. * Observable raised before camera teleportation
  33412. */
  33413. onBeforeCameraTeleport: Observable<Vector3>;
  33414. /**
  33415. * Observable raised after camera teleportation
  33416. */
  33417. onAfterCameraTeleport: Observable<Vector3>;
  33418. /**
  33419. * Observable raised when current selected mesh gets unselected
  33420. */
  33421. onSelectedMeshUnselected: Observable<AbstractMesh>;
  33422. private _raySelectionPredicate;
  33423. /**
  33424. * To be optionaly changed by user to define custom ray selection
  33425. */
  33426. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  33427. /**
  33428. * To be optionaly changed by user to define custom selection logic (after ray selection)
  33429. */
  33430. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  33431. /**
  33432. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  33433. */
  33434. teleportationEnabled: boolean;
  33435. private _defaultHeight;
  33436. private _teleportationInitialized;
  33437. private _interactionsEnabled;
  33438. private _interactionsRequested;
  33439. private _displayGaze;
  33440. private _displayLaserPointer;
  33441. /**
  33442. * The mesh used to display where the user is going to teleport.
  33443. */
  33444. /**
  33445. * Sets the mesh to be used to display where the user is going to teleport.
  33446. */
  33447. teleportationTarget: Mesh;
  33448. /**
  33449. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  33450. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  33451. * See http://doc.babylonjs.com/resources/baking_transformations
  33452. */
  33453. gazeTrackerMesh: Mesh;
  33454. /**
  33455. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  33456. */
  33457. updateGazeTrackerScale: boolean;
  33458. /**
  33459. * The gaze tracking mesh corresponding to the left controller
  33460. */
  33461. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  33462. /**
  33463. * The gaze tracking mesh corresponding to the right controller
  33464. */
  33465. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  33466. /**
  33467. * If the ray of the gaze should be displayed.
  33468. */
  33469. /**
  33470. * Sets if the ray of the gaze should be displayed.
  33471. */
  33472. displayGaze: boolean;
  33473. /**
  33474. * If the ray of the LaserPointer should be displayed.
  33475. */
  33476. /**
  33477. * Sets if the ray of the LaserPointer should be displayed.
  33478. */
  33479. displayLaserPointer: boolean;
  33480. /**
  33481. * The deviceOrientationCamera used as the camera when not in VR.
  33482. */
  33483. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  33484. /**
  33485. * Based on the current WebVR support, returns the current VR camera used.
  33486. */
  33487. readonly currentVRCamera: Nullable<Camera>;
  33488. /**
  33489. * The webVRCamera which is used when in VR.
  33490. */
  33491. readonly webVRCamera: WebVRFreeCamera;
  33492. /**
  33493. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  33494. */
  33495. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  33496. private readonly _teleportationRequestInitiated;
  33497. /**
  33498. * Instantiates a VRExperienceHelper.
  33499. * Helps to quickly add VR support to an existing scene.
  33500. * @param scene The scene the VRExperienceHelper belongs to.
  33501. * @param webVROptions Options to modify the vr experience helper's behavior.
  33502. */
  33503. constructor(scene: Scene,
  33504. /** Options to modify the vr experience helper's behavior. */
  33505. webVROptions?: VRExperienceHelperOptions);
  33506. private _onDefaultMeshLoaded;
  33507. private _onResize;
  33508. private _onFullscreenChange;
  33509. /**
  33510. * Gets a value indicating if we are currently in VR mode.
  33511. */
  33512. readonly isInVRMode: boolean;
  33513. private onVrDisplayPresentChange;
  33514. private onVRDisplayChanged;
  33515. private moveButtonToBottomRight;
  33516. private displayVRButton;
  33517. private updateButtonVisibility;
  33518. /**
  33519. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  33520. * Otherwise, will use the fullscreen API.
  33521. */
  33522. enterVR(): void;
  33523. /**
  33524. * Attempt to exit VR, or fullscreen.
  33525. */
  33526. exitVR(): void;
  33527. /**
  33528. * The position of the vr experience helper.
  33529. */
  33530. /**
  33531. * Sets the position of the vr experience helper.
  33532. */
  33533. position: Vector3;
  33534. /**
  33535. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  33536. */
  33537. enableInteractions(): void;
  33538. private readonly _noControllerIsActive;
  33539. private beforeRender;
  33540. private _isTeleportationFloor;
  33541. /**
  33542. * Adds a floor mesh to be used for teleportation.
  33543. * @param floorMesh the mesh to be used for teleportation.
  33544. */
  33545. addFloorMesh(floorMesh: Mesh): void;
  33546. /**
  33547. * Removes a floor mesh from being used for teleportation.
  33548. * @param floorMesh the mesh to be removed.
  33549. */
  33550. removeFloorMesh(floorMesh: Mesh): void;
  33551. /**
  33552. * Enables interactions and teleportation using the VR controllers and gaze.
  33553. * @param vrTeleportationOptions options to modify teleportation behavior.
  33554. */
  33555. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  33556. private _onNewGamepadConnected;
  33557. private _tryEnableInteractionOnController;
  33558. private _onNewGamepadDisconnected;
  33559. private _enableInteractionOnController;
  33560. private _checkTeleportWithRay;
  33561. private _checkRotate;
  33562. private _checkTeleportBackwards;
  33563. private _enableTeleportationOnController;
  33564. private _createTeleportationCircles;
  33565. private _displayTeleportationTarget;
  33566. private _hideTeleportationTarget;
  33567. private _rotateCamera;
  33568. private _moveTeleportationSelectorTo;
  33569. private _workingVector;
  33570. private _workingQuaternion;
  33571. private _workingMatrix;
  33572. private _teleportCamera;
  33573. private _convertNormalToDirectionOfRay;
  33574. private _castRayAndSelectObject;
  33575. private _notifySelectedMeshUnselected;
  33576. /**
  33577. * Sets the color of the laser ray from the vr controllers.
  33578. * @param color new color for the ray.
  33579. */
  33580. changeLaserColor(color: Color3): void;
  33581. /**
  33582. * Sets the color of the ray from the vr headsets gaze.
  33583. * @param color new color for the ray.
  33584. */
  33585. changeGazeColor(color: Color3): void;
  33586. /**
  33587. * Exits VR and disposes of the vr experience helper
  33588. */
  33589. dispose(): void;
  33590. /**
  33591. * Gets the name of the VRExperienceHelper class
  33592. * @returns "VRExperienceHelper"
  33593. */
  33594. getClassName(): string;
  33595. }
  33596. }
  33597. declare module BABYLON {
  33598. /**
  33599. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  33600. * IMPORTANT!! The data is right-hand data.
  33601. * @export
  33602. * @interface DevicePose
  33603. */
  33604. interface DevicePose {
  33605. /**
  33606. * The position of the device, values in array are [x,y,z].
  33607. */
  33608. readonly position: Nullable<Float32Array>;
  33609. /**
  33610. * The linearVelocity of the device, values in array are [x,y,z].
  33611. */
  33612. readonly linearVelocity: Nullable<Float32Array>;
  33613. /**
  33614. * The linearAcceleration of the device, values in array are [x,y,z].
  33615. */
  33616. readonly linearAcceleration: Nullable<Float32Array>;
  33617. /**
  33618. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  33619. */
  33620. readonly orientation: Nullable<Float32Array>;
  33621. /**
  33622. * The angularVelocity of the device, values in array are [x,y,z].
  33623. */
  33624. readonly angularVelocity: Nullable<Float32Array>;
  33625. /**
  33626. * The angularAcceleration of the device, values in array are [x,y,z].
  33627. */
  33628. readonly angularAcceleration: Nullable<Float32Array>;
  33629. }
  33630. /**
  33631. * Interface representing a pose controlled object in Babylon.
  33632. * A pose controlled object has both regular pose values as well as pose values
  33633. * from an external device such as a VR head mounted display
  33634. */
  33635. interface PoseControlled {
  33636. /**
  33637. * The position of the object in babylon space.
  33638. */
  33639. position: Vector3;
  33640. /**
  33641. * The rotation quaternion of the object in babylon space.
  33642. */
  33643. rotationQuaternion: Quaternion;
  33644. /**
  33645. * The position of the device in babylon space.
  33646. */
  33647. devicePosition?: Vector3;
  33648. /**
  33649. * The rotation quaternion of the device in babylon space.
  33650. */
  33651. deviceRotationQuaternion: Quaternion;
  33652. /**
  33653. * The raw pose coming from the device.
  33654. */
  33655. rawPose: Nullable<DevicePose>;
  33656. /**
  33657. * The scale of the device to be used when translating from device space to babylon space.
  33658. */
  33659. deviceScaleFactor: number;
  33660. /**
  33661. * Updates the poseControlled values based on the input device pose.
  33662. * @param poseData the pose data to update the object with
  33663. */
  33664. updateFromDevice(poseData: DevicePose): void;
  33665. }
  33666. /**
  33667. * Set of options to customize the webVRCamera
  33668. */
  33669. interface WebVROptions {
  33670. /**
  33671. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  33672. */
  33673. trackPosition?: boolean;
  33674. /**
  33675. * Sets the scale of the vrDevice in babylon space. (default: 1)
  33676. */
  33677. positionScale?: number;
  33678. /**
  33679. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  33680. */
  33681. displayName?: string;
  33682. /**
  33683. * Should the native controller meshes be initialized. (default: true)
  33684. */
  33685. controllerMeshes?: boolean;
  33686. /**
  33687. * Creating a default HemiLight only on controllers. (default: true)
  33688. */
  33689. defaultLightingOnControllers?: boolean;
  33690. /**
  33691. * If you don't want to use the default VR button of the helper. (default: false)
  33692. */
  33693. useCustomVRButton?: boolean;
  33694. /**
  33695. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  33696. */
  33697. customVRButton?: HTMLButtonElement;
  33698. /**
  33699. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  33700. */
  33701. rayLength?: number;
  33702. /**
  33703. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  33704. */
  33705. defaultHeight?: number;
  33706. }
  33707. /**
  33708. * This represents a WebVR camera.
  33709. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  33710. * @example http://doc.babylonjs.com/how_to/webvr_camera
  33711. */
  33712. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  33713. private webVROptions;
  33714. /**
  33715. * @hidden
  33716. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  33717. */
  33718. _vrDevice: any;
  33719. /**
  33720. * The rawPose of the vrDevice.
  33721. */
  33722. rawPose: Nullable<DevicePose>;
  33723. private _onVREnabled;
  33724. private _specsVersion;
  33725. private _attached;
  33726. private _frameData;
  33727. protected _descendants: Array<Node>;
  33728. private _deviceRoomPosition;
  33729. /** @hidden */
  33730. _deviceRoomRotationQuaternion: Quaternion;
  33731. private _standingMatrix;
  33732. /**
  33733. * Represents device position in babylon space.
  33734. */
  33735. devicePosition: Vector3;
  33736. /**
  33737. * Represents device rotation in babylon space.
  33738. */
  33739. deviceRotationQuaternion: Quaternion;
  33740. /**
  33741. * The scale of the device to be used when translating from device space to babylon space.
  33742. */
  33743. deviceScaleFactor: number;
  33744. private _deviceToWorld;
  33745. private _worldToDevice;
  33746. /**
  33747. * References to the webVR controllers for the vrDevice.
  33748. */
  33749. controllers: Array<WebVRController>;
  33750. /**
  33751. * Emits an event when a controller is attached.
  33752. */
  33753. onControllersAttachedObservable: Observable<WebVRController[]>;
  33754. /**
  33755. * Emits an event when a controller's mesh has been loaded;
  33756. */
  33757. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33758. /**
  33759. * Emits an event when the HMD's pose has been updated.
  33760. */
  33761. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33762. private _poseSet;
  33763. /**
  33764. * If the rig cameras be used as parent instead of this camera.
  33765. */
  33766. rigParenting: boolean;
  33767. private _lightOnControllers;
  33768. private _defaultHeight?;
  33769. /**
  33770. * Instantiates a WebVRFreeCamera.
  33771. * @param name The name of the WebVRFreeCamera
  33772. * @param position The starting anchor position for the camera
  33773. * @param scene The scene the camera belongs to
  33774. * @param webVROptions a set of customizable options for the webVRCamera
  33775. */
  33776. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  33777. /**
  33778. * Gets the device distance from the ground in meters.
  33779. * @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.
  33780. */
  33781. deviceDistanceToRoomGround(): number;
  33782. /**
  33783. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33784. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  33785. */
  33786. useStandingMatrix(callback?: (bool: boolean) => void): void;
  33787. /**
  33788. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33789. * @returns A promise with a boolean set to if the standing matrix is supported.
  33790. */
  33791. useStandingMatrixAsync(): Promise<boolean>;
  33792. /**
  33793. * Disposes the camera
  33794. */
  33795. dispose(): void;
  33796. /**
  33797. * Gets a vrController by name.
  33798. * @param name The name of the controller to retreive
  33799. * @returns the controller matching the name specified or null if not found
  33800. */
  33801. getControllerByName(name: string): Nullable<WebVRController>;
  33802. private _leftController;
  33803. /**
  33804. * The controller corrisponding to the users left hand.
  33805. */
  33806. readonly leftController: Nullable<WebVRController>;
  33807. private _rightController;
  33808. /**
  33809. * The controller corrisponding to the users right hand.
  33810. */
  33811. readonly rightController: Nullable<WebVRController>;
  33812. /**
  33813. * Casts a ray forward from the vrCamera's gaze.
  33814. * @param length Length of the ray (default: 100)
  33815. * @returns the ray corrisponding to the gaze
  33816. */
  33817. getForwardRay(length?: number): Ray;
  33818. /**
  33819. * @hidden
  33820. * Updates the camera based on device's frame data
  33821. */
  33822. _checkInputs(): void;
  33823. /**
  33824. * Updates the poseControlled values based on the input device pose.
  33825. * @param poseData Pose coming from the device
  33826. */
  33827. updateFromDevice(poseData: DevicePose): void;
  33828. private _htmlElementAttached;
  33829. private _detachIfAttached;
  33830. /**
  33831. * WebVR's attach control will start broadcasting frames to the device.
  33832. * Note that in certain browsers (chrome for example) this function must be called
  33833. * within a user-interaction callback. Example:
  33834. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  33835. *
  33836. * @param element html element to attach the vrDevice to
  33837. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  33838. */
  33839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33840. /**
  33841. * Detaches the camera from the html element and disables VR
  33842. *
  33843. * @param element html element to detach from
  33844. */
  33845. detachControl(element: HTMLElement): void;
  33846. /**
  33847. * @returns the name of this class
  33848. */
  33849. getClassName(): string;
  33850. /**
  33851. * Calls resetPose on the vrDisplay
  33852. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  33853. */
  33854. resetToCurrentRotation(): void;
  33855. /**
  33856. * @hidden
  33857. * Updates the rig cameras (left and right eye)
  33858. */
  33859. _updateRigCameras(): void;
  33860. private _workingVector;
  33861. private _oneVector;
  33862. private _workingMatrix;
  33863. private updateCacheCalled;
  33864. private _correctPositionIfNotTrackPosition;
  33865. /**
  33866. * @hidden
  33867. * Updates the cached values of the camera
  33868. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  33869. */
  33870. _updateCache(ignoreParentClass?: boolean): void;
  33871. /**
  33872. * Updates the current device position and rotation in the babylon world
  33873. */
  33874. update(): void;
  33875. /**
  33876. * @hidden
  33877. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  33878. * @returns an identity matrix
  33879. */
  33880. _getViewMatrix(): Matrix;
  33881. private _tmpMatrix;
  33882. /**
  33883. * This function is called by the two RIG cameras.
  33884. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  33885. */
  33886. protected _getWebVRViewMatrix(): Matrix;
  33887. protected _getWebVRProjectionMatrix(): Matrix;
  33888. private _onGamepadConnectedObserver;
  33889. private _onGamepadDisconnectedObserver;
  33890. /**
  33891. * Initializes the controllers and their meshes
  33892. */
  33893. initControllers(): void;
  33894. }
  33895. }
  33896. declare module BABYLON {
  33897. interface IOctreeContainer<T> {
  33898. blocks: Array<OctreeBlock<T>>;
  33899. }
  33900. class Octree<T> {
  33901. maxDepth: number;
  33902. blocks: Array<OctreeBlock<T>>;
  33903. dynamicContent: T[];
  33904. private _maxBlockCapacity;
  33905. private _selectionContent;
  33906. private _creationFunc;
  33907. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  33908. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  33909. addMesh(entry: T): void;
  33910. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  33911. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  33912. intersectsRay(ray: Ray): SmartArray<T>;
  33913. 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;
  33914. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  33915. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  33916. }
  33917. }
  33918. declare module BABYLON {
  33919. class OctreeBlock<T> {
  33920. entries: T[];
  33921. blocks: Array<OctreeBlock<T>>;
  33922. private _depth;
  33923. private _maxDepth;
  33924. private _capacity;
  33925. private _minPoint;
  33926. private _maxPoint;
  33927. private _boundingVectors;
  33928. private _creationFunc;
  33929. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  33930. readonly capacity: number;
  33931. readonly minPoint: Vector3;
  33932. readonly maxPoint: Vector3;
  33933. addEntry(entry: T): void;
  33934. addEntries(entries: T[]): void;
  33935. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33936. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33937. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  33938. createInnerBlocks(): void;
  33939. }
  33940. }
  33941. declare module BABYLON {
  33942. interface Engine {
  33943. /**
  33944. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  33945. * @return the new query
  33946. */
  33947. createQuery(): WebGLQuery;
  33948. /**
  33949. * Delete and release a webGL query
  33950. * @param query defines the query to delete
  33951. * @return the current engine
  33952. */
  33953. deleteQuery(query: WebGLQuery): Engine;
  33954. /**
  33955. * Check if a given query has resolved and got its value
  33956. * @param query defines the query to check
  33957. * @returns true if the query got its value
  33958. */
  33959. isQueryResultAvailable(query: WebGLQuery): boolean;
  33960. /**
  33961. * Gets the value of a given query
  33962. * @param query defines the query to check
  33963. * @returns the value of the query
  33964. */
  33965. getQueryResult(query: WebGLQuery): number;
  33966. /**
  33967. * Initiates an occlusion query
  33968. * @param algorithmType defines the algorithm to use
  33969. * @param query defines the query to use
  33970. * @returns the current engine
  33971. * @see http://doc.babylonjs.com/features/occlusionquery
  33972. */
  33973. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  33974. /**
  33975. * Ends an occlusion query
  33976. * @see http://doc.babylonjs.com/features/occlusionquery
  33977. * @param algorithmType defines the algorithm to use
  33978. * @returns the current engine
  33979. */
  33980. endOcclusionQuery(algorithmType: number): Engine;
  33981. /**
  33982. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  33983. * Please note that only one query can be issued at a time
  33984. * @returns a time token used to track the time span
  33985. */
  33986. startTimeQuery(): Nullable<_TimeToken>;
  33987. /**
  33988. * Ends a time query
  33989. * @param token defines the token used to measure the time span
  33990. * @returns the time spent (in ns)
  33991. */
  33992. endTimeQuery(token: _TimeToken): int;
  33993. /** @hidden */
  33994. _currentNonTimestampToken: Nullable<_TimeToken>;
  33995. /** @hidden */
  33996. _createTimeQuery(): WebGLQuery;
  33997. /** @hidden */
  33998. _deleteTimeQuery(query: WebGLQuery): void;
  33999. /** @hidden */
  34000. _getGlAlgorithmType(algorithmType: number): number;
  34001. /** @hidden */
  34002. _getTimeQueryResult(query: WebGLQuery): any;
  34003. /** @hidden */
  34004. _getTimeQueryAvailability(query: WebGLQuery): any;
  34005. }
  34006. }
  34007. declare module BABYLON {
  34008. interface Engine {
  34009. /**
  34010. * Creates a webGL transform feedback object
  34011. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  34012. * @returns the webGL transform feedback object
  34013. */
  34014. createTransformFeedback(): WebGLTransformFeedback;
  34015. /**
  34016. * Delete a webGL transform feedback object
  34017. * @param value defines the webGL transform feedback object to delete
  34018. */
  34019. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  34020. /**
  34021. * Bind a webGL transform feedback object to the webgl context
  34022. * @param value defines the webGL transform feedback object to bind
  34023. */
  34024. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  34025. /**
  34026. * Begins a transform feedback operation
  34027. * @param usePoints defines if points or triangles must be used
  34028. */
  34029. beginTransformFeedback(usePoints: boolean): void;
  34030. /**
  34031. * Ends a transform feedback operation
  34032. */
  34033. endTransformFeedback(): void;
  34034. /**
  34035. * Specify the varyings to use with transform feedback
  34036. * @param program defines the associated webGL program
  34037. * @param value defines the list of strings representing the varying names
  34038. */
  34039. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  34040. /**
  34041. * Bind a webGL buffer for a transform feedback operation
  34042. * @param value defines the webGL buffer to bind
  34043. */
  34044. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  34045. }
  34046. }
  34047. declare module BABYLON {
  34048. /**
  34049. * Google Daydream controller
  34050. */
  34051. class DaydreamController extends WebVRController {
  34052. /**
  34053. * Base Url for the controller model.
  34054. */
  34055. static MODEL_BASE_URL: string;
  34056. /**
  34057. * File name for the controller model.
  34058. */
  34059. static MODEL_FILENAME: string;
  34060. /**
  34061. * Gamepad Id prefix used to identify Daydream Controller.
  34062. */
  34063. static readonly GAMEPAD_ID_PREFIX: string;
  34064. /**
  34065. * Creates a new DaydreamController from a gamepad
  34066. * @param vrGamepad the gamepad that the controller should be created from
  34067. */
  34068. constructor(vrGamepad: any);
  34069. /**
  34070. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34071. * @param scene scene in which to add meshes
  34072. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34073. */
  34074. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34075. /**
  34076. * Called once for each button that changed state since the last frame
  34077. * @param buttonIdx Which button index changed
  34078. * @param state New state of the button
  34079. * @param changes Which properties on the state changed since last frame
  34080. */
  34081. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34082. }
  34083. }
  34084. declare module BABYLON {
  34085. /**
  34086. * Gear VR Controller
  34087. */
  34088. class GearVRController extends WebVRController {
  34089. /**
  34090. * Base Url for the controller model.
  34091. */
  34092. static MODEL_BASE_URL: string;
  34093. /**
  34094. * File name for the controller model.
  34095. */
  34096. static MODEL_FILENAME: string;
  34097. private _maxRotationDistFromHeadset;
  34098. private _draggedRoomRotation;
  34099. private _tmpVector;
  34100. /**
  34101. * Gamepad Id prefix used to identify this controller.
  34102. */
  34103. static readonly GAMEPAD_ID_PREFIX: string;
  34104. private readonly _buttonIndexToObservableNameMap;
  34105. /**
  34106. * Creates a new GearVRController from a gamepad
  34107. * @param vrGamepad the gamepad that the controller should be created from
  34108. */
  34109. constructor(vrGamepad: any);
  34110. /**
  34111. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34112. * @param poseData raw pose fromthe device
  34113. */
  34114. updateFromDevice(poseData: DevicePose): void;
  34115. /**
  34116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34117. * @param scene scene in which to add meshes
  34118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34119. */
  34120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34121. /**
  34122. * Called once for each button that changed state since the last frame
  34123. * @param buttonIdx Which button index changed
  34124. * @param state New state of the button
  34125. * @param changes Which properties on the state changed since last frame
  34126. */
  34127. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34128. }
  34129. }
  34130. declare module BABYLON {
  34131. /**
  34132. * Generic Controller
  34133. */
  34134. class GenericController extends WebVRController {
  34135. /**
  34136. * Base Url for the controller model.
  34137. */
  34138. static readonly MODEL_BASE_URL: string;
  34139. /**
  34140. * File name for the controller model.
  34141. */
  34142. static readonly MODEL_FILENAME: string;
  34143. /**
  34144. * Creates a new GenericController from a gamepad
  34145. * @param vrGamepad the gamepad that the controller should be created from
  34146. */
  34147. constructor(vrGamepad: any);
  34148. /**
  34149. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34150. * @param scene scene in which to add meshes
  34151. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34152. */
  34153. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34154. /**
  34155. * Called once for each button that changed state since the last frame
  34156. * @param buttonIdx Which button index changed
  34157. * @param state New state of the button
  34158. * @param changes Which properties on the state changed since last frame
  34159. */
  34160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34161. }
  34162. }
  34163. declare module BABYLON {
  34164. /**
  34165. * Oculus Touch Controller
  34166. */
  34167. class OculusTouchController extends WebVRController {
  34168. /**
  34169. * Base Url for the controller model.
  34170. */
  34171. static MODEL_BASE_URL: string;
  34172. /**
  34173. * File name for the left controller model.
  34174. */
  34175. static MODEL_LEFT_FILENAME: string;
  34176. /**
  34177. * File name for the right controller model.
  34178. */
  34179. static MODEL_RIGHT_FILENAME: string;
  34180. /**
  34181. * Fired when the secondary trigger on this controller is modified
  34182. */
  34183. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34184. /**
  34185. * Fired when the thumb rest on this controller is modified
  34186. */
  34187. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  34188. /**
  34189. * Creates a new OculusTouchController from a gamepad
  34190. * @param vrGamepad the gamepad that the controller should be created from
  34191. */
  34192. constructor(vrGamepad: any);
  34193. /**
  34194. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34195. * @param scene scene in which to add meshes
  34196. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34197. */
  34198. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34199. /**
  34200. * Fired when the A button on this controller is modified
  34201. */
  34202. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34203. /**
  34204. * Fired when the B button on this controller is modified
  34205. */
  34206. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34207. /**
  34208. * Fired when the X button on this controller is modified
  34209. */
  34210. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34211. /**
  34212. * Fired when the Y button on this controller is modified
  34213. */
  34214. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34215. /**
  34216. * Called once for each button that changed state since the last frame
  34217. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34218. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34219. * 2) secondary trigger (same)
  34220. * 3) A (right) X (left), touch, pressed = value
  34221. * 4) B / Y
  34222. * 5) thumb rest
  34223. * @param buttonIdx Which button index changed
  34224. * @param state New state of the button
  34225. * @param changes Which properties on the state changed since last frame
  34226. */
  34227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34228. }
  34229. }
  34230. declare module BABYLON {
  34231. /**
  34232. * Defines the types of pose enabled controllers that are supported
  34233. */
  34234. enum PoseEnabledControllerType {
  34235. /**
  34236. * HTC Vive
  34237. */
  34238. VIVE = 0,
  34239. /**
  34240. * Oculus Rift
  34241. */
  34242. OCULUS = 1,
  34243. /**
  34244. * Windows mixed reality
  34245. */
  34246. WINDOWS = 2,
  34247. /**
  34248. * Samsung gear VR
  34249. */
  34250. GEAR_VR = 3,
  34251. /**
  34252. * Google Daydream
  34253. */
  34254. DAYDREAM = 4,
  34255. /**
  34256. * Generic
  34257. */
  34258. GENERIC = 5
  34259. }
  34260. /**
  34261. * Defines the MutableGamepadButton interface for the state of a gamepad button
  34262. */
  34263. interface MutableGamepadButton {
  34264. /**
  34265. * Value of the button/trigger
  34266. */
  34267. value: number;
  34268. /**
  34269. * If the button/trigger is currently touched
  34270. */
  34271. touched: boolean;
  34272. /**
  34273. * If the button/trigger is currently pressed
  34274. */
  34275. pressed: boolean;
  34276. }
  34277. /**
  34278. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  34279. * @hidden
  34280. */
  34281. interface ExtendedGamepadButton extends GamepadButton {
  34282. /**
  34283. * If the button/trigger is currently pressed
  34284. */
  34285. readonly pressed: boolean;
  34286. /**
  34287. * If the button/trigger is currently touched
  34288. */
  34289. readonly touched: boolean;
  34290. /**
  34291. * Value of the button/trigger
  34292. */
  34293. readonly value: number;
  34294. }
  34295. /**
  34296. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34297. */
  34298. class PoseEnabledControllerHelper {
  34299. /**
  34300. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34301. * @param vrGamepad the gamepad to initialized
  34302. * @returns a vr controller of the type the gamepad identified as
  34303. */
  34304. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  34305. }
  34306. /**
  34307. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34308. */
  34309. class PoseEnabledController extends Gamepad implements PoseControlled {
  34310. private _deviceRoomPosition;
  34311. private _deviceRoomRotationQuaternion;
  34312. /**
  34313. * The device position in babylon space
  34314. */
  34315. devicePosition: Vector3;
  34316. /**
  34317. * The device rotation in babylon space
  34318. */
  34319. deviceRotationQuaternion: Quaternion;
  34320. /**
  34321. * The scale factor of the device in babylon space
  34322. */
  34323. deviceScaleFactor: number;
  34324. /**
  34325. * (Likely devicePosition should be used instead) The device position in its room space
  34326. */
  34327. position: Vector3;
  34328. /**
  34329. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  34330. */
  34331. rotationQuaternion: Quaternion;
  34332. /**
  34333. * The type of controller (Eg. Windows mixed reality)
  34334. */
  34335. controllerType: PoseEnabledControllerType;
  34336. protected _calculatedPosition: Vector3;
  34337. private _calculatedRotation;
  34338. /**
  34339. * The raw pose from the device
  34340. */
  34341. rawPose: DevicePose;
  34342. /**
  34343. * Internal, the mesh attached to the controller
  34344. * @hidden
  34345. */
  34346. _mesh: Nullable<AbstractMesh>;
  34347. private _poseControlledCamera;
  34348. private _leftHandSystemQuaternion;
  34349. /**
  34350. * Internal, matrix used to convert room space to babylon space
  34351. * @hidden
  34352. */
  34353. _deviceToWorld: Matrix;
  34354. /**
  34355. * Node to be used when casting a ray from the controller
  34356. * @hidden
  34357. */
  34358. _pointingPoseNode: Nullable<AbstractMesh>;
  34359. /**
  34360. * Name of the child mesh that can be used to cast a ray from the controller
  34361. */
  34362. static readonly POINTING_POSE: string;
  34363. /**
  34364. * Creates a new PoseEnabledController from a gamepad
  34365. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34366. */
  34367. constructor(browserGamepad: any);
  34368. private _workingMatrix;
  34369. /**
  34370. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34371. */
  34372. update(): void;
  34373. /**
  34374. * Updates only the pose device and mesh without doing any button event checking
  34375. */
  34376. protected _updatePoseAndMesh(): void;
  34377. /**
  34378. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34379. * @param poseData raw pose fromthe device
  34380. */
  34381. updateFromDevice(poseData: DevicePose): void;
  34382. /**
  34383. * @hidden
  34384. */
  34385. _meshAttachedObservable: Observable<AbstractMesh>;
  34386. /**
  34387. * Attaches a mesh to the controller
  34388. * @param mesh the mesh to be attached
  34389. */
  34390. attachToMesh(mesh: AbstractMesh): void;
  34391. /**
  34392. * Attaches the controllers mesh to a camera
  34393. * @param camera the camera the mesh should be attached to
  34394. */
  34395. attachToPoseControlledCamera(camera: TargetCamera): void;
  34396. /**
  34397. * Disposes of the controller
  34398. */
  34399. dispose(): void;
  34400. /**
  34401. * The mesh that is attached to the controller
  34402. */
  34403. readonly mesh: Nullable<AbstractMesh>;
  34404. /**
  34405. * Gets the ray of the controller in the direction the controller is pointing
  34406. * @param length the length the resulting ray should be
  34407. * @returns a ray in the direction the controller is pointing
  34408. */
  34409. getForwardRay(length?: number): Ray;
  34410. }
  34411. }
  34412. declare module BABYLON {
  34413. /**
  34414. * Vive Controller
  34415. */
  34416. class ViveController extends WebVRController {
  34417. /**
  34418. * Base Url for the controller model.
  34419. */
  34420. static MODEL_BASE_URL: string;
  34421. /**
  34422. * File name for the controller model.
  34423. */
  34424. static MODEL_FILENAME: string;
  34425. /**
  34426. * Creates a new ViveController from a gamepad
  34427. * @param vrGamepad the gamepad that the controller should be created from
  34428. */
  34429. constructor(vrGamepad: any);
  34430. /**
  34431. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34432. * @param scene scene in which to add meshes
  34433. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34434. */
  34435. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34436. /**
  34437. * Fired when the left button on this controller is modified
  34438. */
  34439. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34440. /**
  34441. * Fired when the right button on this controller is modified
  34442. */
  34443. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34444. /**
  34445. * Fired when the menu button on this controller is modified
  34446. */
  34447. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34448. /**
  34449. * Called once for each button that changed state since the last frame
  34450. * Vive mapping:
  34451. * 0: touchpad
  34452. * 1: trigger
  34453. * 2: left AND right buttons
  34454. * 3: menu button
  34455. * @param buttonIdx Which button index changed
  34456. * @param state New state of the button
  34457. * @param changes Which properties on the state changed since last frame
  34458. */
  34459. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34460. }
  34461. }
  34462. declare module BABYLON {
  34463. /**
  34464. * Defines the WebVRController object that represents controllers tracked in 3D space
  34465. */
  34466. abstract class WebVRController extends PoseEnabledController {
  34467. /**
  34468. * Internal, the default controller model for the controller
  34469. */
  34470. protected _defaultModel: AbstractMesh;
  34471. /**
  34472. * Fired when the trigger state has changed
  34473. */
  34474. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34475. /**
  34476. * Fired when the main button state has changed
  34477. */
  34478. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34479. /**
  34480. * Fired when the secondary button state has changed
  34481. */
  34482. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34483. /**
  34484. * Fired when the pad state has changed
  34485. */
  34486. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  34487. /**
  34488. * Fired when controllers stick values have changed
  34489. */
  34490. onPadValuesChangedObservable: Observable<StickValues>;
  34491. /**
  34492. * Array of button availible on the controller
  34493. */
  34494. protected _buttons: Array<MutableGamepadButton>;
  34495. private _onButtonStateChange;
  34496. /**
  34497. * Fired when a controller button's state has changed
  34498. * @param callback the callback containing the button that was modified
  34499. */
  34500. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  34501. /**
  34502. * X and Y axis corrisponding to the controllers joystick
  34503. */
  34504. pad: StickValues;
  34505. /**
  34506. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  34507. */
  34508. hand: string;
  34509. /**
  34510. * The default controller model for the controller
  34511. */
  34512. readonly defaultModel: AbstractMesh;
  34513. /**
  34514. * Creates a new WebVRController from a gamepad
  34515. * @param vrGamepad the gamepad that the WebVRController should be created from
  34516. */
  34517. constructor(vrGamepad: any);
  34518. /**
  34519. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34520. */
  34521. update(): void;
  34522. /**
  34523. * Function to be called when a button is modified
  34524. */
  34525. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34526. /**
  34527. * Loads a mesh and attaches it to the controller
  34528. * @param scene the scene the mesh should be added to
  34529. * @param meshLoaded callback for when the mesh has been loaded
  34530. */
  34531. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34532. private _setButtonValue;
  34533. private _changes;
  34534. private _checkChanges;
  34535. /**
  34536. * Disposes of th webVRCOntroller
  34537. */
  34538. dispose(): void;
  34539. }
  34540. }
  34541. declare module BABYLON {
  34542. /**
  34543. * Defines the WindowsMotionController object that the state of the windows motion controller
  34544. */
  34545. class WindowsMotionController extends WebVRController {
  34546. /**
  34547. * The base url used to load the left and right controller models
  34548. */
  34549. static MODEL_BASE_URL: string;
  34550. /**
  34551. * The name of the left controller model file
  34552. */
  34553. static MODEL_LEFT_FILENAME: string;
  34554. /**
  34555. * The name of the right controller model file
  34556. */
  34557. static MODEL_RIGHT_FILENAME: string;
  34558. /**
  34559. * The controller name prefix for this controller type
  34560. */
  34561. static readonly GAMEPAD_ID_PREFIX: string;
  34562. /**
  34563. * The controller id pattern for this controller type
  34564. */
  34565. private static readonly GAMEPAD_ID_PATTERN;
  34566. private _loadedMeshInfo;
  34567. private readonly _mapping;
  34568. /**
  34569. * Fired when the trackpad on this controller is clicked
  34570. */
  34571. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  34572. /**
  34573. * Fired when the trackpad on this controller is modified
  34574. */
  34575. onTrackpadValuesChangedObservable: Observable<StickValues>;
  34576. /**
  34577. * The current x and y values of this controller's trackpad
  34578. */
  34579. trackpad: StickValues;
  34580. /**
  34581. * Creates a new WindowsMotionController from a gamepad
  34582. * @param vrGamepad the gamepad that the controller should be created from
  34583. */
  34584. constructor(vrGamepad: any);
  34585. /**
  34586. * Fired when the trigger on this controller is modified
  34587. */
  34588. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34589. /**
  34590. * Fired when the menu button on this controller is modified
  34591. */
  34592. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34593. /**
  34594. * Fired when the grip button on this controller is modified
  34595. */
  34596. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34597. /**
  34598. * Fired when the thumbstick button on this controller is modified
  34599. */
  34600. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34601. /**
  34602. * Fired when the touchpad button on this controller is modified
  34603. */
  34604. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34605. /**
  34606. * Fired when the touchpad values on this controller are modified
  34607. */
  34608. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  34609. private _updateTrackpad;
  34610. /**
  34611. * Called once per frame by the engine.
  34612. */
  34613. update(): void;
  34614. /**
  34615. * Called once for each button that changed state since the last frame
  34616. * @param buttonIdx Which button index changed
  34617. * @param state New state of the button
  34618. * @param changes Which properties on the state changed since last frame
  34619. */
  34620. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34621. /**
  34622. * Moves the buttons on the controller mesh based on their current state
  34623. * @param buttonName the name of the button to move
  34624. * @param buttonValue the value of the button which determines the buttons new position
  34625. */
  34626. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  34627. /**
  34628. * Moves the axis on the controller mesh based on its current state
  34629. * @param axis the index of the axis
  34630. * @param axisValue the value of the axis which determines the meshes new position
  34631. * @hidden
  34632. */
  34633. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  34634. /**
  34635. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34636. * @param scene scene in which to add meshes
  34637. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34638. */
  34639. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  34640. /**
  34641. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  34642. * can be transformed by button presses and axes values, based on this._mapping.
  34643. *
  34644. * @param scene scene in which the meshes exist
  34645. * @param meshes list of meshes that make up the controller model to process
  34646. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  34647. */
  34648. private processModel;
  34649. private createMeshInfo;
  34650. /**
  34651. * Gets the ray of the controller in the direction the controller is pointing
  34652. * @param length the length the resulting ray should be
  34653. * @returns a ray in the direction the controller is pointing
  34654. */
  34655. getForwardRay(length?: number): Ray;
  34656. /**
  34657. * Disposes of the controller
  34658. */
  34659. dispose(): void;
  34660. }
  34661. }
  34662. declare module BABYLON {
  34663. /**
  34664. * Interface to implement to create a shadow generator compatible with BJS.
  34665. */
  34666. interface IShadowGenerator {
  34667. /**
  34668. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34669. * @returns The render target texture if present otherwise, null
  34670. */
  34671. getShadowMap(): Nullable<RenderTargetTexture>;
  34672. /**
  34673. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34674. * @returns The render target texture if the shadow map is present otherwise, null
  34675. */
  34676. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34677. /**
  34678. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34679. * @param subMesh The submesh we want to render in the shadow map
  34680. * @param useInstances Defines wether will draw in the map using instances
  34681. * @returns true if ready otherwise, false
  34682. */
  34683. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34684. /**
  34685. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34686. * @param defines Defines of the material we want to update
  34687. * @param lightIndex Index of the light in the enabled light list of the material
  34688. */
  34689. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34690. /**
  34691. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34692. * defined in the generator but impacting the effect).
  34693. * It implies the unifroms available on the materials are the standard BJS ones.
  34694. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34695. * @param effect The effect we are binfing the information for
  34696. */
  34697. bindShadowLight(lightIndex: string, effect: Effect): void;
  34698. /**
  34699. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34700. * (eq to shadow prjection matrix * light transform matrix)
  34701. * @returns The transform matrix used to create the shadow map
  34702. */
  34703. getTransformMatrix(): Matrix;
  34704. /**
  34705. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34706. * Cube and 2D textures for instance.
  34707. */
  34708. recreateShadowMap(): void;
  34709. /**
  34710. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34711. * @param onCompiled Callback triggered at the and of the effects compilation
  34712. * @param options Sets of optional options forcing the compilation with different modes
  34713. */
  34714. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34715. useInstances: boolean;
  34716. }>): void;
  34717. /**
  34718. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34719. * @param options Sets of optional options forcing the compilation with different modes
  34720. * @returns A promise that resolves when the compilation completes
  34721. */
  34722. forceCompilationAsync(options?: Partial<{
  34723. useInstances: boolean;
  34724. }>): Promise<void>;
  34725. /**
  34726. * Serializes the shadow generator setup to a json object.
  34727. * @returns The serialized JSON object
  34728. */
  34729. serialize(): any;
  34730. /**
  34731. * Disposes the Shadow map and related Textures and effects.
  34732. */
  34733. dispose(): void;
  34734. }
  34735. /**
  34736. * Default implementation IShadowGenerator.
  34737. * This is the main object responsible of generating shadows in the framework.
  34738. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34739. */
  34740. class ShadowGenerator implements IShadowGenerator {
  34741. /**
  34742. * Shadow generator mode None: no filtering applied.
  34743. */
  34744. static readonly FILTER_NONE: number;
  34745. /**
  34746. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34747. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34748. */
  34749. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34750. /**
  34751. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34752. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34753. */
  34754. static readonly FILTER_POISSONSAMPLING: number;
  34755. /**
  34756. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34757. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34758. */
  34759. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34760. /**
  34761. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34762. * edge artifacts on steep falloff.
  34763. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34764. */
  34765. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34766. /**
  34767. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34768. * edge artifacts on steep falloff.
  34769. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34770. */
  34771. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34772. /**
  34773. * Shadow generator mode PCF: Percentage Closer Filtering
  34774. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34775. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34776. */
  34777. static readonly FILTER_PCF: number;
  34778. /**
  34779. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34780. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34781. * Contact Hardening
  34782. */
  34783. static readonly FILTER_PCSS: number;
  34784. /**
  34785. * Reserved for PCF and PCSS
  34786. * Highest Quality.
  34787. *
  34788. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34789. *
  34790. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34791. */
  34792. static readonly QUALITY_HIGH: number;
  34793. /**
  34794. * Reserved for PCF and PCSS
  34795. * Good tradeoff for quality/perf cross devices
  34796. *
  34797. * Execute PCF on a 3*3 kernel.
  34798. *
  34799. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34800. */
  34801. static readonly QUALITY_MEDIUM: number;
  34802. /**
  34803. * Reserved for PCF and PCSS
  34804. * The lowest quality but the fastest.
  34805. *
  34806. * Execute PCF on a 1*1 kernel.
  34807. *
  34808. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34809. */
  34810. static readonly QUALITY_LOW: number;
  34811. private _bias;
  34812. /**
  34813. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34814. */
  34815. /**
  34816. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34817. */
  34818. bias: number;
  34819. private _normalBias;
  34820. /**
  34821. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34822. */
  34823. /**
  34824. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34825. */
  34826. normalBias: number;
  34827. private _blurBoxOffset;
  34828. /**
  34829. * Gets the blur box offset: offset applied during the blur pass.
  34830. * Only usefull if useKernelBlur = false
  34831. */
  34832. /**
  34833. * Sets the blur box offset: offset applied during the blur pass.
  34834. * Only usefull if useKernelBlur = false
  34835. */
  34836. blurBoxOffset: number;
  34837. private _blurScale;
  34838. /**
  34839. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  34840. * 2 means half of the size.
  34841. */
  34842. /**
  34843. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  34844. * 2 means half of the size.
  34845. */
  34846. blurScale: number;
  34847. private _blurKernel;
  34848. /**
  34849. * Gets the blur kernel: kernel size of the blur pass.
  34850. * Only usefull if useKernelBlur = true
  34851. */
  34852. /**
  34853. * Sets the blur kernel: kernel size of the blur pass.
  34854. * Only usefull if useKernelBlur = true
  34855. */
  34856. blurKernel: number;
  34857. private _useKernelBlur;
  34858. /**
  34859. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  34860. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34861. */
  34862. /**
  34863. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  34864. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34865. */
  34866. useKernelBlur: boolean;
  34867. private _depthScale;
  34868. /**
  34869. * Gets the depth scale used in ESM mode.
  34870. */
  34871. /**
  34872. * Sets the depth scale used in ESM mode.
  34873. * This can override the scale stored on the light.
  34874. */
  34875. depthScale: number;
  34876. private _filter;
  34877. /**
  34878. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  34879. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34880. */
  34881. /**
  34882. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  34883. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34884. */
  34885. filter: number;
  34886. /**
  34887. * Gets if the current filter is set to Poisson Sampling.
  34888. */
  34889. /**
  34890. * Sets the current filter to Poisson Sampling.
  34891. */
  34892. usePoissonSampling: boolean;
  34893. /**
  34894. * Gets if the current filter is set to VSM.
  34895. * DEPRECATED. Should use useExponentialShadowMap instead.
  34896. */
  34897. /**
  34898. * Sets the current filter is to VSM.
  34899. * DEPRECATED. Should use useExponentialShadowMap instead.
  34900. */
  34901. useVarianceShadowMap: boolean;
  34902. /**
  34903. * Gets if the current filter is set to blurred VSM.
  34904. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34905. */
  34906. /**
  34907. * Sets the current filter is to blurred VSM.
  34908. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34909. */
  34910. useBlurVarianceShadowMap: boolean;
  34911. /**
  34912. * Gets if the current filter is set to ESM.
  34913. */
  34914. /**
  34915. * Sets the current filter is to ESM.
  34916. */
  34917. useExponentialShadowMap: boolean;
  34918. /**
  34919. * Gets if the current filter is set to filtered ESM.
  34920. */
  34921. /**
  34922. * Gets if the current filter is set to filtered ESM.
  34923. */
  34924. useBlurExponentialShadowMap: boolean;
  34925. /**
  34926. * Gets if the current filter is set to "close ESM" (using the inverse of the
  34927. * exponential to prevent steep falloff artifacts).
  34928. */
  34929. /**
  34930. * Sets the current filter to "close ESM" (using the inverse of the
  34931. * exponential to prevent steep falloff artifacts).
  34932. */
  34933. useCloseExponentialShadowMap: boolean;
  34934. /**
  34935. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  34936. * exponential to prevent steep falloff artifacts).
  34937. */
  34938. /**
  34939. * Sets the current filter to filtered "close ESM" (using the inverse of the
  34940. * exponential to prevent steep falloff artifacts).
  34941. */
  34942. useBlurCloseExponentialShadowMap: boolean;
  34943. /**
  34944. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  34945. */
  34946. /**
  34947. * Sets the current filter to "PCF" (percentage closer filtering).
  34948. */
  34949. usePercentageCloserFiltering: boolean;
  34950. private _filteringQuality;
  34951. /**
  34952. * Gets the PCF or PCSS Quality.
  34953. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34954. */
  34955. /**
  34956. * Sets the PCF or PCSS Quality.
  34957. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34958. */
  34959. filteringQuality: number;
  34960. /**
  34961. * Gets if the current filter is set to "PCSS" (contact hardening).
  34962. */
  34963. /**
  34964. * Sets the current filter to "PCSS" (contact hardening).
  34965. */
  34966. useContactHardeningShadow: boolean;
  34967. private _contactHardeningLightSizeUVRatio;
  34968. /**
  34969. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34970. * Using a ratio helps keeping shape stability independently of the map size.
  34971. *
  34972. * It does not account for the light projection as it was having too much
  34973. * instability during the light setup or during light position changes.
  34974. *
  34975. * Only valid if useContactHardeningShadow is true.
  34976. */
  34977. /**
  34978. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34979. * Using a ratio helps keeping shape stability independently of the map size.
  34980. *
  34981. * It does not account for the light projection as it was having too much
  34982. * instability during the light setup or during light position changes.
  34983. *
  34984. * Only valid if useContactHardeningShadow is true.
  34985. */
  34986. contactHardeningLightSizeUVRatio: number;
  34987. private _darkness;
  34988. /**
  34989. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34990. * 0 means strongest and 1 would means no shadow.
  34991. * @returns the darkness.
  34992. */
  34993. getDarkness(): number;
  34994. /**
  34995. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34996. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34997. * @returns the shadow generator allowing fluent coding.
  34998. */
  34999. setDarkness(darkness: number): ShadowGenerator;
  35000. private _transparencyShadow;
  35001. /**
  35002. * Sets the ability to have transparent shadow (boolean).
  35003. * @param transparent True if transparent else False
  35004. * @returns the shadow generator allowing fluent coding
  35005. */
  35006. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  35007. private _shadowMap;
  35008. private _shadowMap2;
  35009. /**
  35010. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35011. * @returns The render target texture if present otherwise, null
  35012. */
  35013. getShadowMap(): Nullable<RenderTargetTexture>;
  35014. /**
  35015. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35016. * @returns The render target texture if the shadow map is present otherwise, null
  35017. */
  35018. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35019. /**
  35020. * Helper function to add a mesh and its descendants to the list of shadow casters.
  35021. * @param mesh Mesh to add
  35022. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  35023. * @returns the Shadow Generator itself
  35024. */
  35025. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35026. /**
  35027. * Helper function to remove a mesh and its descendants from the list of shadow casters
  35028. * @param mesh Mesh to remove
  35029. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  35030. * @returns the Shadow Generator itself
  35031. */
  35032. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35033. /**
  35034. * Controls the extent to which the shadows fade out at the edge of the frustum
  35035. * Used only by directionals and spots
  35036. */
  35037. frustumEdgeFalloff: number;
  35038. private _light;
  35039. /**
  35040. * Returns the associated light object.
  35041. * @returns the light generating the shadow
  35042. */
  35043. getLight(): IShadowLight;
  35044. /**
  35045. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  35046. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  35047. * It might on the other hand introduce peter panning.
  35048. */
  35049. forceBackFacesOnly: boolean;
  35050. private _scene;
  35051. private _lightDirection;
  35052. private _effect;
  35053. private _viewMatrix;
  35054. private _projectionMatrix;
  35055. private _transformMatrix;
  35056. private _cachedPosition;
  35057. private _cachedDirection;
  35058. private _cachedDefines;
  35059. private _currentRenderID;
  35060. private _boxBlurPostprocess;
  35061. private _kernelBlurXPostprocess;
  35062. private _kernelBlurYPostprocess;
  35063. private _blurPostProcesses;
  35064. private _mapSize;
  35065. private _currentFaceIndex;
  35066. private _currentFaceIndexCache;
  35067. private _textureType;
  35068. private _defaultTextureMatrix;
  35069. /**
  35070. * Creates a ShadowGenerator object.
  35071. * A ShadowGenerator is the required tool to use the shadows.
  35072. * Each light casting shadows needs to use its own ShadowGenerator.
  35073. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  35074. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  35075. * @param light The light object generating the shadows.
  35076. * @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.
  35077. */
  35078. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  35079. private _initializeGenerator;
  35080. private _initializeShadowMap;
  35081. private _initializeBlurRTTAndPostProcesses;
  35082. private _renderForShadowMap;
  35083. private _renderSubMeshForShadowMap;
  35084. private _applyFilterValues;
  35085. /**
  35086. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35087. * @param onCompiled Callback triggered at the and of the effects compilation
  35088. * @param options Sets of optional options forcing the compilation with different modes
  35089. */
  35090. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35091. useInstances: boolean;
  35092. }>): void;
  35093. /**
  35094. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35095. * @param options Sets of optional options forcing the compilation with different modes
  35096. * @returns A promise that resolves when the compilation completes
  35097. */
  35098. forceCompilationAsync(options?: Partial<{
  35099. useInstances: boolean;
  35100. }>): Promise<void>;
  35101. /**
  35102. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35103. * @param subMesh The submesh we want to render in the shadow map
  35104. * @param useInstances Defines wether will draw in the map using instances
  35105. * @returns true if ready otherwise, false
  35106. */
  35107. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35108. /**
  35109. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35110. * @param defines Defines of the material we want to update
  35111. * @param lightIndex Index of the light in the enabled light list of the material
  35112. */
  35113. prepareDefines(defines: any, lightIndex: number): void;
  35114. /**
  35115. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35116. * defined in the generator but impacting the effect).
  35117. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35118. * @param effect The effect we are binfing the information for
  35119. */
  35120. bindShadowLight(lightIndex: string, effect: Effect): void;
  35121. /**
  35122. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35123. * (eq to shadow prjection matrix * light transform matrix)
  35124. * @returns The transform matrix used to create the shadow map
  35125. */
  35126. getTransformMatrix(): Matrix;
  35127. /**
  35128. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35129. * Cube and 2D textures for instance.
  35130. */
  35131. recreateShadowMap(): void;
  35132. private _disposeBlurPostProcesses;
  35133. private _disposeRTTandPostProcesses;
  35134. /**
  35135. * Disposes the ShadowGenerator.
  35136. * Returns nothing.
  35137. */
  35138. dispose(): void;
  35139. /**
  35140. * Serializes the shadow generator setup to a json object.
  35141. * @returns The serialized JSON object
  35142. */
  35143. serialize(): any;
  35144. /**
  35145. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  35146. * @param parsedShadowGenerator The JSON object to parse
  35147. * @param scene The scene to create the shadow map for
  35148. * @returns The parsed shadow generator
  35149. */
  35150. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  35151. }
  35152. }
  35153. declare module BABYLON {
  35154. }
  35155. declare module BABYLON {
  35156. /**
  35157. * Background material used to create an efficient environement around your scene.
  35158. */
  35159. class BackgroundMaterial extends PushMaterial {
  35160. /**
  35161. * Standard reflectance value at parallel view angle.
  35162. */
  35163. static StandardReflectance0: number;
  35164. /**
  35165. * Standard reflectance value at grazing angle.
  35166. */
  35167. static StandardReflectance90: number;
  35168. protected _primaryColor: Color3;
  35169. /**
  35170. * Key light Color (multiply against the environement texture)
  35171. */
  35172. primaryColor: Color3;
  35173. protected __perceptualColor: Nullable<Color3>;
  35174. /**
  35175. * Experimental Internal Use Only.
  35176. *
  35177. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  35178. * This acts as a helper to set the primary color to a more "human friendly" value.
  35179. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  35180. * output color as close as possible from the chosen value.
  35181. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  35182. * part of lighting setup.)
  35183. */
  35184. _perceptualColor: Nullable<Color3>;
  35185. protected _primaryColorShadowLevel: float;
  35186. /**
  35187. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  35188. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  35189. */
  35190. primaryColorShadowLevel: float;
  35191. protected _primaryColorHighlightLevel: float;
  35192. /**
  35193. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  35194. * The primary color is used at the level chosen to define what the white area would look.
  35195. */
  35196. primaryColorHighlightLevel: float;
  35197. protected _reflectionTexture: Nullable<BaseTexture>;
  35198. /**
  35199. * Reflection Texture used in the material.
  35200. * Should be author in a specific way for the best result (refer to the documentation).
  35201. */
  35202. reflectionTexture: Nullable<BaseTexture>;
  35203. protected _reflectionBlur: float;
  35204. /**
  35205. * Reflection Texture level of blur.
  35206. *
  35207. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  35208. * texture twice.
  35209. */
  35210. reflectionBlur: float;
  35211. protected _diffuseTexture: Nullable<BaseTexture>;
  35212. /**
  35213. * Diffuse Texture used in the material.
  35214. * Should be author in a specific way for the best result (refer to the documentation).
  35215. */
  35216. diffuseTexture: Nullable<BaseTexture>;
  35217. protected _shadowLights: Nullable<IShadowLight[]>;
  35218. /**
  35219. * Specify the list of lights casting shadow on the material.
  35220. * All scene shadow lights will be included if null.
  35221. */
  35222. shadowLights: Nullable<IShadowLight[]>;
  35223. protected _shadowLevel: float;
  35224. /**
  35225. * Helps adjusting the shadow to a softer level if required.
  35226. * 0 means black shadows and 1 means no shadows.
  35227. */
  35228. shadowLevel: float;
  35229. protected _sceneCenter: Vector3;
  35230. /**
  35231. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  35232. * It is usually zero but might be interesting to modify according to your setup.
  35233. */
  35234. sceneCenter: Vector3;
  35235. protected _opacityFresnel: boolean;
  35236. /**
  35237. * This helps specifying that the material is falling off to the sky box at grazing angle.
  35238. * This helps ensuring a nice transition when the camera goes under the ground.
  35239. */
  35240. opacityFresnel: boolean;
  35241. protected _reflectionFresnel: boolean;
  35242. /**
  35243. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  35244. * This helps adding a mirror texture on the ground.
  35245. */
  35246. reflectionFresnel: boolean;
  35247. protected _reflectionFalloffDistance: number;
  35248. /**
  35249. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  35250. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  35251. */
  35252. reflectionFalloffDistance: number;
  35253. protected _reflectionAmount: number;
  35254. /**
  35255. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  35256. */
  35257. reflectionAmount: number;
  35258. protected _reflectionReflectance0: number;
  35259. /**
  35260. * This specifies the weight of the reflection at grazing angle.
  35261. */
  35262. reflectionReflectance0: number;
  35263. protected _reflectionReflectance90: number;
  35264. /**
  35265. * This specifies the weight of the reflection at a perpendicular point of view.
  35266. */
  35267. reflectionReflectance90: number;
  35268. /**
  35269. * Sets the reflection reflectance fresnel values according to the default standard
  35270. * empirically know to work well :-)
  35271. */
  35272. reflectionStandardFresnelWeight: number;
  35273. protected _useRGBColor: boolean;
  35274. /**
  35275. * Helps to directly use the maps channels instead of their level.
  35276. */
  35277. useRGBColor: boolean;
  35278. protected _enableNoise: boolean;
  35279. /**
  35280. * This helps reducing the banding effect that could occur on the background.
  35281. */
  35282. enableNoise: boolean;
  35283. /**
  35284. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  35285. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  35286. * Recommended to be keep at 1.0 except for special cases.
  35287. */
  35288. fovMultiplier: number;
  35289. private _fovMultiplier;
  35290. /**
  35291. * Enable the FOV adjustment feature controlled by fovMultiplier.
  35292. */
  35293. useEquirectangularFOV: boolean;
  35294. private _maxSimultaneousLights;
  35295. /**
  35296. * Number of Simultaneous lights allowed on the material.
  35297. */
  35298. maxSimultaneousLights: int;
  35299. /**
  35300. * Default configuration related to image processing available in the Background Material.
  35301. */
  35302. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35303. /**
  35304. * Keep track of the image processing observer to allow dispose and replace.
  35305. */
  35306. private _imageProcessingObserver;
  35307. /**
  35308. * Attaches a new image processing configuration to the PBR Material.
  35309. * @param configuration (if null the scene configuration will be use)
  35310. */
  35311. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35312. /**
  35313. * Gets the image processing configuration used either in this material.
  35314. */
  35315. /**
  35316. * Sets the Default image processing configuration used either in the this material.
  35317. *
  35318. * If sets to null, the scene one is in use.
  35319. */
  35320. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  35321. /**
  35322. * Gets wether the color curves effect is enabled.
  35323. */
  35324. /**
  35325. * Sets wether the color curves effect is enabled.
  35326. */
  35327. cameraColorCurvesEnabled: boolean;
  35328. /**
  35329. * Gets wether the color grading effect is enabled.
  35330. */
  35331. /**
  35332. * Gets wether the color grading effect is enabled.
  35333. */
  35334. cameraColorGradingEnabled: boolean;
  35335. /**
  35336. * Gets wether tonemapping is enabled or not.
  35337. */
  35338. /**
  35339. * Sets wether tonemapping is enabled or not
  35340. */
  35341. cameraToneMappingEnabled: boolean;
  35342. /**
  35343. * The camera exposure used on this material.
  35344. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35345. * This corresponds to a photographic exposure.
  35346. */
  35347. /**
  35348. * The camera exposure used on this material.
  35349. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35350. * This corresponds to a photographic exposure.
  35351. */
  35352. cameraExposure: float;
  35353. /**
  35354. * Gets The camera contrast used on this material.
  35355. */
  35356. /**
  35357. * Sets The camera contrast used on this material.
  35358. */
  35359. cameraContrast: float;
  35360. /**
  35361. * Gets the Color Grading 2D Lookup Texture.
  35362. */
  35363. /**
  35364. * Sets the Color Grading 2D Lookup Texture.
  35365. */
  35366. cameraColorGradingTexture: Nullable<BaseTexture>;
  35367. /**
  35368. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35369. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35370. * 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;
  35371. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35372. */
  35373. /**
  35374. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35375. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35376. * 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;
  35377. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35378. */
  35379. cameraColorCurves: Nullable<ColorCurves>;
  35380. /**
  35381. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  35382. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  35383. */
  35384. switchToBGR: boolean;
  35385. private _renderTargets;
  35386. private _reflectionControls;
  35387. private _white;
  35388. private _primaryShadowColor;
  35389. private _primaryHighlightColor;
  35390. /**
  35391. * Instantiates a Background Material in the given scene
  35392. * @param name The friendly name of the material
  35393. * @param scene The scene to add the material to
  35394. */
  35395. constructor(name: string, scene: Scene);
  35396. /**
  35397. * The entire material has been created in order to prevent overdraw.
  35398. * @returns false
  35399. */
  35400. needAlphaTesting(): boolean;
  35401. /**
  35402. * The entire material has been created in order to prevent overdraw.
  35403. * @returns true if blending is enable
  35404. */
  35405. needAlphaBlending(): boolean;
  35406. /**
  35407. * Checks wether the material is ready to be rendered for a given mesh.
  35408. * @param mesh The mesh to render
  35409. * @param subMesh The submesh to check against
  35410. * @param useInstances Specify wether or not the material is used with instances
  35411. * @returns true if all the dependencies are ready (Textures, Effects...)
  35412. */
  35413. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35414. /**
  35415. * Compute the primary color according to the chosen perceptual color.
  35416. */
  35417. private _computePrimaryColorFromPerceptualColor;
  35418. /**
  35419. * Compute the highlights and shadow colors according to their chosen levels.
  35420. */
  35421. private _computePrimaryColors;
  35422. /**
  35423. * Build the uniform buffer used in the material.
  35424. */
  35425. buildUniformLayout(): void;
  35426. /**
  35427. * Unbind the material.
  35428. */
  35429. unbind(): void;
  35430. /**
  35431. * Bind only the world matrix to the material.
  35432. * @param world The world matrix to bind.
  35433. */
  35434. bindOnlyWorldMatrix(world: Matrix): void;
  35435. /**
  35436. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  35437. * @param world The world matrix to bind.
  35438. * @param subMesh The submesh to bind for.
  35439. */
  35440. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35441. /**
  35442. * Dispose the material.
  35443. * @param forceDisposeEffect Force disposal of the associated effect.
  35444. * @param forceDisposeTextures Force disposal of the associated textures.
  35445. */
  35446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35447. /**
  35448. * Clones the material.
  35449. * @param name The cloned name.
  35450. * @returns The cloned material.
  35451. */
  35452. clone(name: string): BackgroundMaterial;
  35453. /**
  35454. * Serializes the current material to its JSON representation.
  35455. * @returns The JSON representation.
  35456. */
  35457. serialize(): any;
  35458. /**
  35459. * Gets the class name of the material
  35460. * @returns "BackgroundMaterial"
  35461. */
  35462. getClassName(): string;
  35463. /**
  35464. * Parse a JSON input to create back a background material.
  35465. * @param source The JSON data to parse
  35466. * @param scene The scene to create the parsed material in
  35467. * @param rootUrl The root url of the assets the material depends upon
  35468. * @returns the instantiated BackgroundMaterial.
  35469. */
  35470. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  35471. }
  35472. }
  35473. declare module BABYLON {
  35474. /**
  35475. * The Physically based material base class of BJS.
  35476. *
  35477. * This offers the main features of a standard PBR material.
  35478. * For more information, please refer to the documentation :
  35479. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35480. */
  35481. abstract class PBRBaseMaterial extends PushMaterial {
  35482. /**
  35483. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  35484. */
  35485. static readonly LIGHTFALLOFF_PHYSICAL: number;
  35486. /**
  35487. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  35488. * to enhance interoperability with other engines.
  35489. */
  35490. static readonly LIGHTFALLOFF_GLTF: number;
  35491. /**
  35492. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  35493. * to enhance interoperability with other materials.
  35494. */
  35495. static readonly LIGHTFALLOFF_STANDARD: number;
  35496. /**
  35497. * Intensity of the direct lights e.g. the four lights available in your scene.
  35498. * This impacts both the direct diffuse and specular highlights.
  35499. */
  35500. protected _directIntensity: number;
  35501. /**
  35502. * Intensity of the emissive part of the material.
  35503. * This helps controlling the emissive effect without modifying the emissive color.
  35504. */
  35505. protected _emissiveIntensity: number;
  35506. /**
  35507. * Intensity of the environment e.g. how much the environment will light the object
  35508. * either through harmonics for rough material or through the refelction for shiny ones.
  35509. */
  35510. protected _environmentIntensity: number;
  35511. /**
  35512. * This is a special control allowing the reduction of the specular highlights coming from the
  35513. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35514. */
  35515. protected _specularIntensity: number;
  35516. /**
  35517. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  35518. */
  35519. private _lightingInfos;
  35520. /**
  35521. * Debug Control allowing disabling the bump map on this material.
  35522. */
  35523. protected _disableBumpMap: boolean;
  35524. /**
  35525. * AKA Diffuse Texture in standard nomenclature.
  35526. */
  35527. protected _albedoTexture: BaseTexture;
  35528. /**
  35529. * AKA Occlusion Texture in other nomenclature.
  35530. */
  35531. protected _ambientTexture: BaseTexture;
  35532. /**
  35533. * AKA Occlusion Texture Intensity in other nomenclature.
  35534. */
  35535. protected _ambientTextureStrength: number;
  35536. /**
  35537. * Defines how much the AO map is occluding the analytical lights (point spot...).
  35538. * 1 means it completely occludes it
  35539. * 0 mean it has no impact
  35540. */
  35541. protected _ambientTextureImpactOnAnalyticalLights: number;
  35542. /**
  35543. * Stores the alpha values in a texture.
  35544. */
  35545. protected _opacityTexture: BaseTexture;
  35546. /**
  35547. * Stores the reflection values in a texture.
  35548. */
  35549. protected _reflectionTexture: BaseTexture;
  35550. /**
  35551. * Stores the refraction values in a texture.
  35552. */
  35553. protected _refractionTexture: BaseTexture;
  35554. /**
  35555. * Stores the emissive values in a texture.
  35556. */
  35557. protected _emissiveTexture: BaseTexture;
  35558. /**
  35559. * AKA Specular texture in other nomenclature.
  35560. */
  35561. protected _reflectivityTexture: BaseTexture;
  35562. /**
  35563. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35564. */
  35565. protected _metallicTexture: BaseTexture;
  35566. /**
  35567. * Specifies the metallic scalar of the metallic/roughness workflow.
  35568. * Can also be used to scale the metalness values of the metallic texture.
  35569. */
  35570. protected _metallic: Nullable<number>;
  35571. /**
  35572. * Specifies the roughness scalar of the metallic/roughness workflow.
  35573. * Can also be used to scale the roughness values of the metallic texture.
  35574. */
  35575. protected _roughness: Nullable<number>;
  35576. /**
  35577. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35578. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35579. */
  35580. protected _microSurfaceTexture: BaseTexture;
  35581. /**
  35582. * Stores surface normal data used to displace a mesh in a texture.
  35583. */
  35584. protected _bumpTexture: BaseTexture;
  35585. /**
  35586. * Stores the pre-calculated light information of a mesh in a texture.
  35587. */
  35588. protected _lightmapTexture: BaseTexture;
  35589. /**
  35590. * The color of a material in ambient lighting.
  35591. */
  35592. protected _ambientColor: Color3;
  35593. /**
  35594. * AKA Diffuse Color in other nomenclature.
  35595. */
  35596. protected _albedoColor: Color3;
  35597. /**
  35598. * AKA Specular Color in other nomenclature.
  35599. */
  35600. protected _reflectivityColor: Color3;
  35601. /**
  35602. * The color applied when light is reflected from a material.
  35603. */
  35604. protected _reflectionColor: Color3;
  35605. /**
  35606. * The color applied when light is emitted from a material.
  35607. */
  35608. protected _emissiveColor: Color3;
  35609. /**
  35610. * AKA Glossiness in other nomenclature.
  35611. */
  35612. protected _microSurface: number;
  35613. /**
  35614. * source material index of refraction (IOR)' / 'destination material IOR.
  35615. */
  35616. protected _indexOfRefraction: number;
  35617. /**
  35618. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35619. */
  35620. protected _invertRefractionY: boolean;
  35621. /**
  35622. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35623. * Materials half opaque for instance using refraction could benefit from this control.
  35624. */
  35625. protected _linkRefractionWithTransparency: boolean;
  35626. /**
  35627. * Specifies that the material will use the light map as a show map.
  35628. */
  35629. protected _useLightmapAsShadowmap: boolean;
  35630. /**
  35631. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35632. * makes the reflect vector face the model (under horizon).
  35633. */
  35634. protected _useHorizonOcclusion: boolean;
  35635. /**
  35636. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35637. * too much the area relying on ambient texture to define their ambient occlusion.
  35638. */
  35639. protected _useRadianceOcclusion: boolean;
  35640. /**
  35641. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35642. */
  35643. protected _useAlphaFromAlbedoTexture: boolean;
  35644. /**
  35645. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35646. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35647. */
  35648. protected _useSpecularOverAlpha: boolean;
  35649. /**
  35650. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35651. */
  35652. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35653. /**
  35654. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35655. */
  35656. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  35657. /**
  35658. * Specifies if the metallic texture contains the roughness information in its green channel.
  35659. */
  35660. protected _useRoughnessFromMetallicTextureGreen: boolean;
  35661. /**
  35662. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35663. */
  35664. protected _useMetallnessFromMetallicTextureBlue: boolean;
  35665. /**
  35666. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35667. */
  35668. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  35669. /**
  35670. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35671. */
  35672. protected _useAmbientInGrayScale: boolean;
  35673. /**
  35674. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35675. * The material will try to infer what glossiness each pixel should be.
  35676. */
  35677. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  35678. /**
  35679. * Defines the falloff type used in this material.
  35680. * It by default is Physical.
  35681. */
  35682. protected _lightFalloff: number;
  35683. /**
  35684. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35685. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35686. */
  35687. protected _useRadianceOverAlpha: boolean;
  35688. /**
  35689. * Allows using an object space normal map (instead of tangent space).
  35690. */
  35691. protected _useObjectSpaceNormalMap: boolean;
  35692. /**
  35693. * Allows using the bump map in parallax mode.
  35694. */
  35695. protected _useParallax: boolean;
  35696. /**
  35697. * Allows using the bump map in parallax occlusion mode.
  35698. */
  35699. protected _useParallaxOcclusion: boolean;
  35700. /**
  35701. * Controls the scale bias of the parallax mode.
  35702. */
  35703. protected _parallaxScaleBias: number;
  35704. /**
  35705. * If sets to true, disables all the lights affecting the material.
  35706. */
  35707. protected _disableLighting: boolean;
  35708. /**
  35709. * Number of Simultaneous lights allowed on the material.
  35710. */
  35711. protected _maxSimultaneousLights: number;
  35712. /**
  35713. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  35714. */
  35715. protected _invertNormalMapX: boolean;
  35716. /**
  35717. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  35718. */
  35719. protected _invertNormalMapY: boolean;
  35720. /**
  35721. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35722. */
  35723. protected _twoSidedLighting: boolean;
  35724. /**
  35725. * Defines the alpha limits in alpha test mode.
  35726. */
  35727. protected _alphaCutOff: number;
  35728. /**
  35729. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35730. */
  35731. protected _forceAlphaTest: boolean;
  35732. /**
  35733. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35734. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35735. */
  35736. protected _useAlphaFresnel: boolean;
  35737. /**
  35738. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35739. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35740. */
  35741. protected _useLinearAlphaFresnel: boolean;
  35742. /**
  35743. * The transparency mode of the material.
  35744. */
  35745. protected _transparencyMode: Nullable<number>;
  35746. /**
  35747. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  35748. * from cos thetav and roughness:
  35749. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  35750. */
  35751. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  35752. /**
  35753. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35754. */
  35755. protected _forceIrradianceInFragment: boolean;
  35756. /**
  35757. * Force normal to face away from face.
  35758. */
  35759. protected _forceNormalForward: boolean;
  35760. /**
  35761. * Enables specular anti aliasing in the PBR shader.
  35762. * It will both interacts on the Geometry for analytical and IBL lighting.
  35763. * It also prefilter the roughness map based on the bump values.
  35764. */
  35765. protected _enableSpecularAntiAliasing: boolean;
  35766. /**
  35767. * Default configuration related to image processing available in the PBR Material.
  35768. */
  35769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35770. /**
  35771. * Keep track of the image processing observer to allow dispose and replace.
  35772. */
  35773. private _imageProcessingObserver;
  35774. /**
  35775. * Attaches a new image processing configuration to the PBR Material.
  35776. * @param configuration
  35777. */
  35778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35779. /**
  35780. * Stores the available render targets.
  35781. */
  35782. private _renderTargets;
  35783. /**
  35784. * Sets the global ambient color for the material used in lighting calculations.
  35785. */
  35786. private _globalAmbientColor;
  35787. /**
  35788. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  35789. */
  35790. private _useLogarithmicDepth;
  35791. /**
  35792. * If set to true, no lighting calculations will be applied.
  35793. */
  35794. private _unlit;
  35795. /**
  35796. * Instantiates a new PBRMaterial instance.
  35797. *
  35798. * @param name The material name
  35799. * @param scene The scene the material will be use in.
  35800. */
  35801. constructor(name: string, scene: Scene);
  35802. /**
  35803. * Gets the name of the material class.
  35804. */
  35805. getClassName(): string;
  35806. /**
  35807. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35808. */
  35809. /**
  35810. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35811. */
  35812. useLogarithmicDepth: boolean;
  35813. /**
  35814. * Gets the current transparency mode.
  35815. */
  35816. /**
  35817. * Sets the transparency mode of the material.
  35818. *
  35819. * | Value | Type | Description |
  35820. * | ----- | ----------------------------------- | ----------- |
  35821. * | 0 | OPAQUE | |
  35822. * | 1 | ALPHATEST | |
  35823. * | 2 | ALPHABLEND | |
  35824. * | 3 | ALPHATESTANDBLEND | |
  35825. *
  35826. */
  35827. transparencyMode: Nullable<number>;
  35828. /**
  35829. * Returns true if alpha blending should be disabled.
  35830. */
  35831. private readonly _disableAlphaBlending;
  35832. /**
  35833. * Specifies whether or not this material should be rendered in alpha blend mode.
  35834. */
  35835. needAlphaBlending(): boolean;
  35836. /**
  35837. * Specifies if the mesh will require alpha blending.
  35838. * @param mesh - BJS mesh.
  35839. */
  35840. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  35841. /**
  35842. * Specifies whether or not this material should be rendered in alpha test mode.
  35843. */
  35844. needAlphaTesting(): boolean;
  35845. /**
  35846. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  35847. */
  35848. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  35849. /**
  35850. * Gets the texture used for the alpha test.
  35851. */
  35852. getAlphaTestTexture(): BaseTexture;
  35853. /**
  35854. * Stores the reflectivity values based on metallic roughness workflow.
  35855. */
  35856. private static _scaledReflectivity;
  35857. /**
  35858. * Specifies that the submesh is ready to be used.
  35859. * @param mesh - BJS mesh.
  35860. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  35861. * @param useInstances - Specifies that instances should be used.
  35862. * @returns - boolean indicating that the submesh is ready or not.
  35863. */
  35864. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35865. /**
  35866. * Specifies if the material uses metallic roughness workflow.
  35867. * @returns boolean specifiying if the material uses metallic roughness workflow.
  35868. */
  35869. isMetallicWorkflow(): boolean;
  35870. private _prepareEffect;
  35871. private _prepareDefines;
  35872. /**
  35873. * Force shader compilation
  35874. */
  35875. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  35876. clipPlane: boolean;
  35877. }>): void;
  35878. /**
  35879. * Initializes the uniform buffer layout for the shader.
  35880. */
  35881. buildUniformLayout(): void;
  35882. /**
  35883. * Unbinds the textures.
  35884. */
  35885. unbind(): void;
  35886. /**
  35887. * Binds the submesh data.
  35888. * @param world - The world matrix.
  35889. * @param mesh - The BJS mesh.
  35890. * @param subMesh - A submesh of the BJS mesh.
  35891. */
  35892. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35893. /**
  35894. * Returns the animatable textures.
  35895. * @returns - Array of animatable textures.
  35896. */
  35897. getAnimatables(): IAnimatable[];
  35898. /**
  35899. * Returns the texture used for reflections.
  35900. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  35901. */
  35902. private _getReflectionTexture;
  35903. /**
  35904. * Returns the texture used for refraction or null if none is used.
  35905. * @returns - Refection texture if present. If no refraction texture and refraction
  35906. * is linked with transparency, returns environment texture. Otherwise, returns null.
  35907. */
  35908. private _getRefractionTexture;
  35909. /**
  35910. * Disposes the resources of the material.
  35911. * @param forceDisposeEffect - Forces the disposal of effects.
  35912. * @param forceDisposeTextures - Forces the disposal of all textures.
  35913. */
  35914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35915. }
  35916. }
  35917. declare module BABYLON {
  35918. /**
  35919. * The Physically based simple base material of BJS.
  35920. *
  35921. * This enables better naming and convention enforcements on top of the pbrMaterial.
  35922. * It is used as the base class for both the specGloss and metalRough conventions.
  35923. */
  35924. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  35925. /**
  35926. * Number of Simultaneous lights allowed on the material.
  35927. */
  35928. maxSimultaneousLights: number;
  35929. /**
  35930. * If sets to true, disables all the lights affecting the material.
  35931. */
  35932. disableLighting: boolean;
  35933. /**
  35934. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  35935. */
  35936. environmentTexture: BaseTexture;
  35937. /**
  35938. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35939. */
  35940. invertNormalMapX: boolean;
  35941. /**
  35942. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35943. */
  35944. invertNormalMapY: boolean;
  35945. /**
  35946. * Normal map used in the model.
  35947. */
  35948. normalTexture: BaseTexture;
  35949. /**
  35950. * Emissivie color used to self-illuminate the model.
  35951. */
  35952. emissiveColor: Color3;
  35953. /**
  35954. * Emissivie texture used to self-illuminate the model.
  35955. */
  35956. emissiveTexture: BaseTexture;
  35957. /**
  35958. * Occlusion Channel Strenght.
  35959. */
  35960. occlusionStrength: number;
  35961. /**
  35962. * Occlusion Texture of the material (adding extra occlusion effects).
  35963. */
  35964. occlusionTexture: BaseTexture;
  35965. /**
  35966. * Defines the alpha limits in alpha test mode.
  35967. */
  35968. alphaCutOff: number;
  35969. /**
  35970. * Gets the current double sided mode.
  35971. */
  35972. /**
  35973. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35974. */
  35975. doubleSided: boolean;
  35976. lightmapTexture: BaseTexture;
  35977. useLightmapAsShadowmap: boolean;
  35978. /**
  35979. * Return the active textures of the material.
  35980. */
  35981. getActiveTextures(): BaseTexture[];
  35982. hasTexture(texture: BaseTexture): boolean;
  35983. /**
  35984. * Instantiates a new PBRMaterial instance.
  35985. *
  35986. * @param name The material name
  35987. * @param scene The scene the material will be use in.
  35988. */
  35989. constructor(name: string, scene: Scene);
  35990. getClassName(): string;
  35991. }
  35992. }
  35993. declare module BABYLON {
  35994. /**
  35995. * The Physically based material of BJS.
  35996. *
  35997. * This offers the main features of a standard PBR material.
  35998. * For more information, please refer to the documentation :
  35999. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36000. */
  36001. class PBRMaterial extends PBRBaseMaterial {
  36002. /**
  36003. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  36004. */
  36005. static readonly PBRMATERIAL_OPAQUE: number;
  36006. /**
  36007. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  36008. */
  36009. static readonly PBRMATERIAL_ALPHATEST: number;
  36010. /**
  36011. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36012. */
  36013. static readonly PBRMATERIAL_ALPHABLEND: number;
  36014. /**
  36015. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36016. * They are also discarded below the alpha cutoff threshold to improve performances.
  36017. */
  36018. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  36019. /**
  36020. * Defines the default value of how much AO map is occluding the analytical lights
  36021. * (point spot...).
  36022. */
  36023. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  36024. /**
  36025. * Intensity of the direct lights e.g. the four lights available in your scene.
  36026. * This impacts both the direct diffuse and specular highlights.
  36027. */
  36028. directIntensity: number;
  36029. /**
  36030. * Intensity of the emissive part of the material.
  36031. * This helps controlling the emissive effect without modifying the emissive color.
  36032. */
  36033. emissiveIntensity: number;
  36034. /**
  36035. * Intensity of the environment e.g. how much the environment will light the object
  36036. * either through harmonics for rough material or through the refelction for shiny ones.
  36037. */
  36038. environmentIntensity: number;
  36039. /**
  36040. * This is a special control allowing the reduction of the specular highlights coming from the
  36041. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36042. */
  36043. specularIntensity: number;
  36044. /**
  36045. * Debug Control allowing disabling the bump map on this material.
  36046. */
  36047. disableBumpMap: boolean;
  36048. /**
  36049. * AKA Diffuse Texture in standard nomenclature.
  36050. */
  36051. albedoTexture: BaseTexture;
  36052. /**
  36053. * AKA Occlusion Texture in other nomenclature.
  36054. */
  36055. ambientTexture: BaseTexture;
  36056. /**
  36057. * AKA Occlusion Texture Intensity in other nomenclature.
  36058. */
  36059. ambientTextureStrength: number;
  36060. /**
  36061. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36062. * 1 means it completely occludes it
  36063. * 0 mean it has no impact
  36064. */
  36065. ambientTextureImpactOnAnalyticalLights: number;
  36066. /**
  36067. * Stores the alpha values in a texture.
  36068. */
  36069. opacityTexture: BaseTexture;
  36070. /**
  36071. * Stores the reflection values in a texture.
  36072. */
  36073. reflectionTexture: Nullable<BaseTexture>;
  36074. /**
  36075. * Stores the emissive values in a texture.
  36076. */
  36077. emissiveTexture: BaseTexture;
  36078. /**
  36079. * AKA Specular texture in other nomenclature.
  36080. */
  36081. reflectivityTexture: BaseTexture;
  36082. /**
  36083. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36084. */
  36085. metallicTexture: BaseTexture;
  36086. /**
  36087. * Specifies the metallic scalar of the metallic/roughness workflow.
  36088. * Can also be used to scale the metalness values of the metallic texture.
  36089. */
  36090. metallic: Nullable<number>;
  36091. /**
  36092. * Specifies the roughness scalar of the metallic/roughness workflow.
  36093. * Can also be used to scale the roughness values of the metallic texture.
  36094. */
  36095. roughness: Nullable<number>;
  36096. /**
  36097. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36098. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36099. */
  36100. microSurfaceTexture: BaseTexture;
  36101. /**
  36102. * Stores surface normal data used to displace a mesh in a texture.
  36103. */
  36104. bumpTexture: BaseTexture;
  36105. /**
  36106. * Stores the pre-calculated light information of a mesh in a texture.
  36107. */
  36108. lightmapTexture: BaseTexture;
  36109. /**
  36110. * Stores the refracted light information in a texture.
  36111. */
  36112. refractionTexture: BaseTexture;
  36113. /**
  36114. * The color of a material in ambient lighting.
  36115. */
  36116. ambientColor: Color3;
  36117. /**
  36118. * AKA Diffuse Color in other nomenclature.
  36119. */
  36120. albedoColor: Color3;
  36121. /**
  36122. * AKA Specular Color in other nomenclature.
  36123. */
  36124. reflectivityColor: Color3;
  36125. /**
  36126. * The color reflected from the material.
  36127. */
  36128. reflectionColor: Color3;
  36129. /**
  36130. * The color emitted from the material.
  36131. */
  36132. emissiveColor: Color3;
  36133. /**
  36134. * AKA Glossiness in other nomenclature.
  36135. */
  36136. microSurface: number;
  36137. /**
  36138. * source material index of refraction (IOR)' / 'destination material IOR.
  36139. */
  36140. indexOfRefraction: number;
  36141. /**
  36142. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36143. */
  36144. invertRefractionY: boolean;
  36145. /**
  36146. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36147. * Materials half opaque for instance using refraction could benefit from this control.
  36148. */
  36149. linkRefractionWithTransparency: boolean;
  36150. useLightmapAsShadowmap: boolean;
  36151. /**
  36152. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36153. */
  36154. useAlphaFromAlbedoTexture: boolean;
  36155. /**
  36156. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36157. */
  36158. forceAlphaTest: boolean;
  36159. /**
  36160. * Defines the alpha limits in alpha test mode.
  36161. */
  36162. alphaCutOff: number;
  36163. /**
  36164. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36165. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36166. */
  36167. useSpecularOverAlpha: boolean;
  36168. /**
  36169. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36170. */
  36171. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36172. /**
  36173. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36174. */
  36175. useRoughnessFromMetallicTextureAlpha: boolean;
  36176. /**
  36177. * Specifies if the metallic texture contains the roughness information in its green channel.
  36178. */
  36179. useRoughnessFromMetallicTextureGreen: boolean;
  36180. /**
  36181. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36182. */
  36183. useMetallnessFromMetallicTextureBlue: boolean;
  36184. /**
  36185. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36186. */
  36187. useAmbientOcclusionFromMetallicTextureRed: boolean;
  36188. /**
  36189. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36190. */
  36191. useAmbientInGrayScale: boolean;
  36192. /**
  36193. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36194. * The material will try to infer what glossiness each pixel should be.
  36195. */
  36196. useAutoMicroSurfaceFromReflectivityMap: boolean;
  36197. /**
  36198. * BJS is using an harcoded light falloff based on a manually sets up range.
  36199. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36200. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36201. */
  36202. /**
  36203. * BJS is using an harcoded light falloff based on a manually sets up range.
  36204. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36205. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36206. */
  36207. usePhysicalLightFalloff: boolean;
  36208. /**
  36209. * In order to support the falloff compatibility with gltf, a special mode has been added
  36210. * to reproduce the gltf light falloff.
  36211. */
  36212. /**
  36213. * In order to support the falloff compatibility with gltf, a special mode has been added
  36214. * to reproduce the gltf light falloff.
  36215. */
  36216. useGLTFLightFalloff: boolean;
  36217. /**
  36218. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36219. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36220. */
  36221. useRadianceOverAlpha: boolean;
  36222. /**
  36223. * Allows using an object space normal map (instead of tangent space).
  36224. */
  36225. useObjectSpaceNormalMap: boolean;
  36226. /**
  36227. * Allows using the bump map in parallax mode.
  36228. */
  36229. useParallax: boolean;
  36230. /**
  36231. * Allows using the bump map in parallax occlusion mode.
  36232. */
  36233. useParallaxOcclusion: boolean;
  36234. /**
  36235. * Controls the scale bias of the parallax mode.
  36236. */
  36237. parallaxScaleBias: number;
  36238. /**
  36239. * If sets to true, disables all the lights affecting the material.
  36240. */
  36241. disableLighting: boolean;
  36242. /**
  36243. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36244. */
  36245. forceIrradianceInFragment: boolean;
  36246. /**
  36247. * Number of Simultaneous lights allowed on the material.
  36248. */
  36249. maxSimultaneousLights: number;
  36250. /**
  36251. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36252. */
  36253. invertNormalMapX: boolean;
  36254. /**
  36255. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36256. */
  36257. invertNormalMapY: boolean;
  36258. /**
  36259. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36260. */
  36261. twoSidedLighting: boolean;
  36262. /**
  36263. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36264. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36265. */
  36266. useAlphaFresnel: boolean;
  36267. /**
  36268. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36269. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36270. */
  36271. useLinearAlphaFresnel: boolean;
  36272. /**
  36273. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36274. * And/Or occlude the blended part.
  36275. */
  36276. environmentBRDFTexture: Nullable<BaseTexture>;
  36277. /**
  36278. * Force normal to face away from face.
  36279. */
  36280. forceNormalForward: boolean;
  36281. /**
  36282. * Enables specular anti aliasing in the PBR shader.
  36283. * It will both interacts on the Geometry for analytical and IBL lighting.
  36284. * It also prefilter the roughness map based on the bump values.
  36285. */
  36286. enableSpecularAntiAliasing: boolean;
  36287. /**
  36288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36289. * makes the reflect vector face the model (under horizon).
  36290. */
  36291. useHorizonOcclusion: boolean;
  36292. /**
  36293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36294. * too much the area relying on ambient texture to define their ambient occlusion.
  36295. */
  36296. useRadianceOcclusion: boolean;
  36297. /**
  36298. * If set to true, no lighting calculations will be applied.
  36299. */
  36300. unlit: boolean;
  36301. /**
  36302. * Gets the image processing configuration used either in this material.
  36303. */
  36304. /**
  36305. * Sets the Default image processing configuration used either in the this material.
  36306. *
  36307. * If sets to null, the scene one is in use.
  36308. */
  36309. imageProcessingConfiguration: ImageProcessingConfiguration;
  36310. /**
  36311. * Gets wether the color curves effect is enabled.
  36312. */
  36313. /**
  36314. * Sets wether the color curves effect is enabled.
  36315. */
  36316. cameraColorCurvesEnabled: boolean;
  36317. /**
  36318. * Gets wether the color grading effect is enabled.
  36319. */
  36320. /**
  36321. * Gets wether the color grading effect is enabled.
  36322. */
  36323. cameraColorGradingEnabled: boolean;
  36324. /**
  36325. * Gets wether tonemapping is enabled or not.
  36326. */
  36327. /**
  36328. * Sets wether tonemapping is enabled or not
  36329. */
  36330. cameraToneMappingEnabled: boolean;
  36331. /**
  36332. * The camera exposure used on this material.
  36333. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36334. * This corresponds to a photographic exposure.
  36335. */
  36336. /**
  36337. * The camera exposure used on this material.
  36338. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36339. * This corresponds to a photographic exposure.
  36340. */
  36341. cameraExposure: number;
  36342. /**
  36343. * Gets The camera contrast used on this material.
  36344. */
  36345. /**
  36346. * Sets The camera contrast used on this material.
  36347. */
  36348. cameraContrast: number;
  36349. /**
  36350. * Gets the Color Grading 2D Lookup Texture.
  36351. */
  36352. /**
  36353. * Sets the Color Grading 2D Lookup Texture.
  36354. */
  36355. cameraColorGradingTexture: Nullable<BaseTexture>;
  36356. /**
  36357. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36358. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36359. * 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;
  36360. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36361. */
  36362. /**
  36363. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36364. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36365. * 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;
  36366. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36367. */
  36368. cameraColorCurves: Nullable<ColorCurves>;
  36369. /**
  36370. * Instantiates a new PBRMaterial instance.
  36371. *
  36372. * @param name The material name
  36373. * @param scene The scene the material will be use in.
  36374. */
  36375. constructor(name: string, scene: Scene);
  36376. /**
  36377. * Returns the name of this material class.
  36378. */
  36379. getClassName(): string;
  36380. /**
  36381. * Returns an array of the actively used textures.
  36382. * @returns - Array of BaseTextures
  36383. */
  36384. getActiveTextures(): BaseTexture[];
  36385. /**
  36386. * Checks to see if a texture is used in the material.
  36387. * @param texture - Base texture to use.
  36388. * @returns - Boolean specifying if a texture is used in the material.
  36389. */
  36390. hasTexture(texture: BaseTexture): boolean;
  36391. /**
  36392. * Makes a duplicate of the current material.
  36393. * @param name - name to use for the new material.
  36394. */
  36395. clone(name: string): PBRMaterial;
  36396. /**
  36397. * Serializes this PBR Material.
  36398. * @returns - An object with the serialized material.
  36399. */
  36400. serialize(): any;
  36401. /**
  36402. * Parses a PBR Material from a serialized object.
  36403. * @param source - Serialized object.
  36404. * @param scene - BJS scene instance.
  36405. * @param rootUrl - url for the scene object
  36406. * @returns - PBRMaterial
  36407. */
  36408. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  36409. }
  36410. }
  36411. declare module BABYLON {
  36412. /**
  36413. * The PBR material of BJS following the metal roughness convention.
  36414. *
  36415. * This fits to the PBR convention in the GLTF definition:
  36416. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  36417. */
  36418. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  36419. /**
  36420. * The base color has two different interpretations depending on the value of metalness.
  36421. * When the material is a metal, the base color is the specific measured reflectance value
  36422. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  36423. * of the material.
  36424. */
  36425. baseColor: Color3;
  36426. /**
  36427. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  36428. * well as opacity information in the alpha channel.
  36429. */
  36430. baseTexture: BaseTexture;
  36431. /**
  36432. * Specifies the metallic scalar value of the material.
  36433. * Can also be used to scale the metalness values of the metallic texture.
  36434. */
  36435. metallic: number;
  36436. /**
  36437. * Specifies the roughness scalar value of the material.
  36438. * Can also be used to scale the roughness values of the metallic texture.
  36439. */
  36440. roughness: number;
  36441. /**
  36442. * Texture containing both the metallic value in the B channel and the
  36443. * roughness value in the G channel to keep better precision.
  36444. */
  36445. metallicRoughnessTexture: BaseTexture;
  36446. /**
  36447. * Instantiates a new PBRMetalRoughnessMaterial instance.
  36448. *
  36449. * @param name The material name
  36450. * @param scene The scene the material will be use in.
  36451. */
  36452. constructor(name: string, scene: Scene);
  36453. /**
  36454. * Return the currrent class name of the material.
  36455. */
  36456. getClassName(): string;
  36457. /**
  36458. * Return the active textures of the material.
  36459. */
  36460. getActiveTextures(): BaseTexture[];
  36461. /**
  36462. * Checks to see if a texture is used in the material.
  36463. * @param texture - Base texture to use.
  36464. * @returns - Boolean specifying if a texture is used in the material.
  36465. */
  36466. hasTexture(texture: BaseTexture): boolean;
  36467. /**
  36468. * Makes a duplicate of the current material.
  36469. * @param name - name to use for the new material.
  36470. */
  36471. clone(name: string): PBRMetallicRoughnessMaterial;
  36472. /**
  36473. * Serialize the material to a parsable JSON object.
  36474. */
  36475. serialize(): any;
  36476. /**
  36477. * Parses a JSON object correponding to the serialize function.
  36478. */
  36479. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  36480. }
  36481. }
  36482. declare module BABYLON {
  36483. /**
  36484. * The PBR material of BJS following the specular glossiness convention.
  36485. *
  36486. * This fits to the PBR convention in the GLTF definition:
  36487. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  36488. */
  36489. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  36490. /**
  36491. * Specifies the diffuse color of the material.
  36492. */
  36493. diffuseColor: Color3;
  36494. /**
  36495. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  36496. * channel.
  36497. */
  36498. diffuseTexture: BaseTexture;
  36499. /**
  36500. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  36501. */
  36502. specularColor: Color3;
  36503. /**
  36504. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  36505. */
  36506. glossiness: number;
  36507. /**
  36508. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  36509. */
  36510. specularGlossinessTexture: BaseTexture;
  36511. /**
  36512. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  36513. *
  36514. * @param name The material name
  36515. * @param scene The scene the material will be use in.
  36516. */
  36517. constructor(name: string, scene: Scene);
  36518. /**
  36519. * Return the currrent class name of the material.
  36520. */
  36521. getClassName(): string;
  36522. /**
  36523. * Return the active textures of the material.
  36524. */
  36525. getActiveTextures(): BaseTexture[];
  36526. /**
  36527. * Checks to see if a texture is used in the material.
  36528. * @param texture - Base texture to use.
  36529. * @returns - Boolean specifying if a texture is used in the material.
  36530. */
  36531. hasTexture(texture: BaseTexture): boolean;
  36532. /**
  36533. * Makes a duplicate of the current material.
  36534. * @param name - name to use for the new material.
  36535. */
  36536. clone(name: string): PBRSpecularGlossinessMaterial;
  36537. /**
  36538. * Serialize the material to a parsable JSON object.
  36539. */
  36540. serialize(): any;
  36541. /**
  36542. * Parses a JSON object correponding to the serialize function.
  36543. */
  36544. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  36545. }
  36546. }
  36547. declare module BABYLON {
  36548. class BaseTexture {
  36549. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36550. name: string;
  36551. private _hasAlpha;
  36552. hasAlpha: boolean;
  36553. getAlphaFromRGB: boolean;
  36554. level: number;
  36555. coordinatesIndex: number;
  36556. private _coordinatesMode;
  36557. /**
  36558. * How a texture is mapped.
  36559. *
  36560. * | Value | Type | Description |
  36561. * | ----- | ----------------------------------- | ----------- |
  36562. * | 0 | EXPLICIT_MODE | |
  36563. * | 1 | SPHERICAL_MODE | |
  36564. * | 2 | PLANAR_MODE | |
  36565. * | 3 | CUBIC_MODE | |
  36566. * | 4 | PROJECTION_MODE | |
  36567. * | 5 | SKYBOX_MODE | |
  36568. * | 6 | INVCUBIC_MODE | |
  36569. * | 7 | EQUIRECTANGULAR_MODE | |
  36570. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  36571. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  36572. */
  36573. coordinatesMode: number;
  36574. /**
  36575. * | Value | Type | Description |
  36576. * | ----- | ------------------ | ----------- |
  36577. * | 0 | CLAMP_ADDRESSMODE | |
  36578. * | 1 | WRAP_ADDRESSMODE | |
  36579. * | 2 | MIRROR_ADDRESSMODE | |
  36580. */
  36581. wrapU: number;
  36582. /**
  36583. * | Value | Type | Description |
  36584. * | ----- | ------------------ | ----------- |
  36585. * | 0 | CLAMP_ADDRESSMODE | |
  36586. * | 1 | WRAP_ADDRESSMODE | |
  36587. * | 2 | MIRROR_ADDRESSMODE | |
  36588. */
  36589. wrapV: number;
  36590. /**
  36591. * | Value | Type | Description |
  36592. * | ----- | ------------------ | ----------- |
  36593. * | 0 | CLAMP_ADDRESSMODE | |
  36594. * | 1 | WRAP_ADDRESSMODE | |
  36595. * | 2 | MIRROR_ADDRESSMODE | |
  36596. */
  36597. wrapR: number;
  36598. anisotropicFilteringLevel: number;
  36599. isCube: boolean;
  36600. is3D: boolean;
  36601. gammaSpace: boolean;
  36602. /**
  36603. * Gets whether or not the texture contains RGBD data.
  36604. */
  36605. readonly isRGBD: boolean;
  36606. invertZ: boolean;
  36607. lodLevelInAlpha: boolean;
  36608. lodGenerationOffset: number;
  36609. lodGenerationScale: number;
  36610. isRenderTarget: boolean;
  36611. readonly uid: string;
  36612. toString(): string;
  36613. getClassName(): string;
  36614. animations: Animation[];
  36615. /**
  36616. * An event triggered when the texture is disposed.
  36617. */
  36618. onDisposeObservable: Observable<BaseTexture>;
  36619. private _onDisposeObserver;
  36620. onDispose: () => void;
  36621. delayLoadState: number;
  36622. private _scene;
  36623. /** @hidden */
  36624. _texture: Nullable<InternalTexture>;
  36625. private _uid;
  36626. readonly isBlocking: boolean;
  36627. constructor(scene: Nullable<Scene>);
  36628. getScene(): Nullable<Scene>;
  36629. getTextureMatrix(): Matrix;
  36630. getReflectionTextureMatrix(): Matrix;
  36631. getInternalTexture(): Nullable<InternalTexture>;
  36632. isReadyOrNotBlocking(): boolean;
  36633. isReady(): boolean;
  36634. private _cachedSize;
  36635. getSize(): ISize;
  36636. getBaseSize(): ISize;
  36637. scale(ratio: number): void;
  36638. readonly canRescale: boolean;
  36639. /** @hidden */
  36640. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  36641. /** @hidden */
  36642. _rebuild(): void;
  36643. delayLoad(): void;
  36644. clone(): Nullable<BaseTexture>;
  36645. readonly textureType: number;
  36646. readonly textureFormat: number;
  36647. /**
  36648. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  36649. * This will returns an RGBA array buffer containing either in values (0-255) or
  36650. * float values (0-1) depending of the underlying buffer type.
  36651. * @param faceIndex The face of the texture to read (in case of cube texture)
  36652. * @param level The LOD level of the texture to read (in case of Mip Maps)
  36653. * @returns The Array buffer containing the pixels data.
  36654. */
  36655. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  36656. releaseInternalTexture(): void;
  36657. sphericalPolynomial: Nullable<SphericalPolynomial>;
  36658. readonly _lodTextureHigh: Nullable<BaseTexture>;
  36659. readonly _lodTextureMid: Nullable<BaseTexture>;
  36660. readonly _lodTextureLow: Nullable<BaseTexture>;
  36661. dispose(): void;
  36662. serialize(): any;
  36663. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  36664. }
  36665. }
  36666. declare module BABYLON {
  36667. /**
  36668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  36669. * It can help converting any input color in a desired output one. This can then be used to create effects
  36670. * from sepia, black and white to sixties or futuristic rendering...
  36671. *
  36672. * The only supported format is currently 3dl.
  36673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  36674. */
  36675. class ColorGradingTexture extends BaseTexture {
  36676. /**
  36677. * The current texture matrix. (will always be identity in color grading texture)
  36678. */
  36679. private _textureMatrix;
  36680. /**
  36681. * The texture URL.
  36682. */
  36683. url: string;
  36684. /**
  36685. * Empty line regex stored for GC.
  36686. */
  36687. private static _noneEmptyLineRegex;
  36688. private _engine;
  36689. /**
  36690. * Instantiates a ColorGradingTexture from the following parameters.
  36691. *
  36692. * @param url The location of the color gradind data (currently only supporting 3dl)
  36693. * @param scene The scene the texture will be used in
  36694. */
  36695. constructor(url: string, scene: Scene);
  36696. /**
  36697. * Returns the texture matrix used in most of the material.
  36698. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  36699. */
  36700. getTextureMatrix(): Matrix;
  36701. /**
  36702. * Occurs when the file being loaded is a .3dl LUT file.
  36703. */
  36704. private load3dlTexture;
  36705. /**
  36706. * Starts the loading process of the texture.
  36707. */
  36708. private loadTexture;
  36709. /**
  36710. * Clones the color gradind texture.
  36711. */
  36712. clone(): ColorGradingTexture;
  36713. /**
  36714. * Called during delayed load for textures.
  36715. */
  36716. delayLoad(): void;
  36717. /**
  36718. * Parses a color grading texture serialized by Babylon.
  36719. * @param parsedTexture The texture information being parsedTexture
  36720. * @param scene The scene to load the texture in
  36721. * @param rootUrl The root url of the data assets to load
  36722. * @return A color gradind texture
  36723. */
  36724. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  36725. /**
  36726. * Serializes the LUT texture to json format.
  36727. */
  36728. serialize(): any;
  36729. }
  36730. }
  36731. declare module BABYLON {
  36732. class CubeTexture extends BaseTexture {
  36733. url: string;
  36734. /**
  36735. * Gets or sets the center of the bounding box associated with the cube texture
  36736. * It must define where the camera used to render the texture was set
  36737. */
  36738. boundingBoxPosition: Vector3;
  36739. private _boundingBoxSize;
  36740. /**
  36741. * Gets or sets the size of the bounding box associated with the cube texture
  36742. * When defined, the cubemap will switch to local mode
  36743. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36744. * @example https://www.babylonjs-playground.com/#RNASML
  36745. */
  36746. boundingBoxSize: Vector3;
  36747. protected _rotationY: number;
  36748. /**
  36749. * Sets texture matrix rotation angle around Y axis in radians.
  36750. */
  36751. /**
  36752. * Gets texture matrix rotation angle around Y axis radians.
  36753. */
  36754. rotationY: number;
  36755. private _noMipmap;
  36756. private _files;
  36757. private _extensions;
  36758. private _textureMatrix;
  36759. private _format;
  36760. private _createPolynomials;
  36761. /** @hidden */
  36762. readonly _prefiltered: boolean;
  36763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  36764. /**
  36765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  36766. * @param url defines the url of the prefiltered texture
  36767. * @param scene defines the scene the texture is attached to
  36768. * @param forcedExtension defines the extension of the file if different from the url
  36769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36770. * @return the prefiltered texture
  36771. */
  36772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  36773. /**
  36774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  36775. * as prefiltered data.
  36776. * @param rootUrl defines the url of the texture or the root name of the six images
  36777. * @param scene defines the scene the texture is attached to
  36778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  36779. * @param noMipmap defines if mipmaps should be created or not
  36780. * @param files defines the six files to load for the different faces
  36781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  36782. * @param onError defines a callback triggered in case of error during load
  36783. * @param format defines the internal format to use for the texture once loaded
  36784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  36785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  36786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36789. * @return the cube texture
  36790. */
  36791. 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, lodScale?: number, lodOffset?: number);
  36792. delayLoad(): void;
  36793. getReflectionTextureMatrix(): Matrix;
  36794. setReflectionTextureMatrix(value: Matrix): void;
  36795. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  36796. clone(): CubeTexture;
  36797. }
  36798. }
  36799. declare module BABYLON {
  36800. /**
  36801. * A class extending {BABYLON.Texture} allowing drawing on a texture
  36802. * @see http://doc.babylonjs.com/how_to/dynamictexture
  36803. */
  36804. class DynamicTexture extends Texture {
  36805. private _generateMipMaps;
  36806. private _canvas;
  36807. private _context;
  36808. private _engine;
  36809. /**
  36810. * Creates a {BABYLON.DynamicTexture}
  36811. * @param name defines the name of the texture
  36812. * @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
  36813. * @param scene defines the scene where you want the texture
  36814. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  36815. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36816. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  36817. */
  36818. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  36819. /**
  36820. * Gets the current state of canRescale
  36821. */
  36822. readonly canRescale: boolean;
  36823. private _recreate;
  36824. /**
  36825. * Scales the texture
  36826. * @param ratio the scale factor to apply to both width and height
  36827. */
  36828. scale(ratio: number): void;
  36829. /**
  36830. * Resizes the texture
  36831. * @param width the new width
  36832. * @param height the new height
  36833. */
  36834. scaleTo(width: number, height: number): void;
  36835. /**
  36836. * Gets the context of the canvas used by the texture
  36837. * @returns the canvas context of the dynamic texture
  36838. */
  36839. getContext(): CanvasRenderingContext2D;
  36840. /**
  36841. * Clears the texture
  36842. */
  36843. clear(): void;
  36844. /**
  36845. * Updates the texture
  36846. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36847. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  36848. */
  36849. update(invertY?: boolean, premulAlpha?: boolean): void;
  36850. /**
  36851. * Draws text onto the texture
  36852. * @param text defines the text to be drawn
  36853. * @param x defines the placement of the text from the left
  36854. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  36855. * @param font defines the font to be used with font-style, font-size, font-name
  36856. * @param color defines the color used for the text
  36857. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  36858. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36859. * @param update defines whether texture is immediately update (default is true)
  36860. */
  36861. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  36862. /**
  36863. * Clones the texture
  36864. * @returns the clone of the texture.
  36865. */
  36866. clone(): DynamicTexture;
  36867. /**
  36868. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  36869. * @returns a serialized dynamic texture object
  36870. */
  36871. serialize(): any;
  36872. /** @hidden */
  36873. _rebuild(): void;
  36874. }
  36875. }
  36876. declare module BABYLON {
  36877. /**
  36878. * This represents a texture coming from an HDR input.
  36879. *
  36880. * The only supported format is currently panorama picture stored in RGBE format.
  36881. * Example of such files can be found on HDRLib: http://hdrlib.com/
  36882. */
  36883. class HDRCubeTexture extends BaseTexture {
  36884. private static _facesMapping;
  36885. private _generateHarmonics;
  36886. private _noMipmap;
  36887. private _textureMatrix;
  36888. private _size;
  36889. private _onLoad;
  36890. private _onError;
  36891. /**
  36892. * The texture URL.
  36893. */
  36894. url: string;
  36895. /**
  36896. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  36897. */
  36898. coordinatesMode: number;
  36899. protected _isBlocking: boolean;
  36900. /**
  36901. * Sets wether or not the texture is blocking during loading.
  36902. */
  36903. /**
  36904. * Gets wether or not the texture is blocking during loading.
  36905. */
  36906. isBlocking: boolean;
  36907. protected _rotationY: number;
  36908. /**
  36909. * Sets texture matrix rotation angle around Y axis in radians.
  36910. */
  36911. /**
  36912. * Gets texture matrix rotation angle around Y axis radians.
  36913. */
  36914. rotationY: number;
  36915. /**
  36916. * Gets or sets the center of the bounding box associated with the cube texture
  36917. * It must define where the camera used to render the texture was set
  36918. */
  36919. boundingBoxPosition: Vector3;
  36920. private _boundingBoxSize;
  36921. /**
  36922. * Gets or sets the size of the bounding box associated with the cube texture
  36923. * When defined, the cubemap will switch to local mode
  36924. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36925. * @example https://www.babylonjs-playground.com/#RNASML
  36926. */
  36927. boundingBoxSize: Vector3;
  36928. /**
  36929. * Instantiates an HDRTexture from the following parameters.
  36930. *
  36931. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  36932. * @param scene The scene the texture will be used in
  36933. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  36934. * @param noMipmap Forces to not generate the mipmap if true
  36935. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  36936. * @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)
  36937. * @param reserved Reserved flag for internal use.
  36938. */
  36939. 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>);
  36940. /**
  36941. * Occurs when the file is raw .hdr file.
  36942. */
  36943. private loadTexture;
  36944. clone(): HDRCubeTexture;
  36945. delayLoad(): void;
  36946. getReflectionTextureMatrix(): Matrix;
  36947. setReflectionTextureMatrix(value: Matrix): void;
  36948. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  36949. serialize(): any;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. /**
  36954. * Class used to store data associated with WebGL texture data for the engine
  36955. * This class should not be used directly
  36956. */
  36957. class InternalTexture implements IInternalTextureTracker {
  36958. /**
  36959. * The source of the texture data is unknown
  36960. */
  36961. static DATASOURCE_UNKNOWN: number;
  36962. /**
  36963. * Texture data comes from an URL
  36964. */
  36965. static DATASOURCE_URL: number;
  36966. /**
  36967. * Texture data is only used for temporary storage
  36968. */
  36969. static DATASOURCE_TEMP: number;
  36970. /**
  36971. * Texture data comes from raw data (ArrayBuffer)
  36972. */
  36973. static DATASOURCE_RAW: number;
  36974. /**
  36975. * Texture content is dynamic (video or dynamic texture)
  36976. */
  36977. static DATASOURCE_DYNAMIC: number;
  36978. /**
  36979. * Texture content is generated by rendering to it
  36980. */
  36981. static DATASOURCE_RENDERTARGET: number;
  36982. /**
  36983. * Texture content is part of a multi render target process
  36984. */
  36985. static DATASOURCE_MULTIRENDERTARGET: number;
  36986. /**
  36987. * Texture data comes from a cube data file
  36988. */
  36989. static DATASOURCE_CUBE: number;
  36990. /**
  36991. * Texture data comes from a raw cube data
  36992. */
  36993. static DATASOURCE_CUBERAW: number;
  36994. /**
  36995. * Texture data come from a prefiltered cube data file
  36996. */
  36997. static DATASOURCE_CUBEPREFILTERED: number;
  36998. /**
  36999. * Texture content is raw 3D data
  37000. */
  37001. static DATASOURCE_RAW3D: number;
  37002. /**
  37003. * Texture content is a depth texture
  37004. */
  37005. static DATASOURCE_DEPTHTEXTURE: number;
  37006. /**
  37007. * Texture data comes from a raw cube data encoded with RGBD
  37008. */
  37009. static DATASOURCE_CUBERAW_RGBD: number;
  37010. /**
  37011. * Defines if the texture is ready
  37012. */
  37013. isReady: boolean;
  37014. /**
  37015. * Defines if the texture is a cube texture
  37016. */
  37017. isCube: boolean;
  37018. /**
  37019. * Defines if the texture contains 3D data
  37020. */
  37021. is3D: boolean;
  37022. /**
  37023. * Gets the URL used to load this texture
  37024. */
  37025. url: string;
  37026. /**
  37027. * Gets the sampling mode of the texture
  37028. */
  37029. samplingMode: number;
  37030. /**
  37031. * Gets a boolean indicating if the texture needs mipmaps generation
  37032. */
  37033. generateMipMaps: boolean;
  37034. /**
  37035. * Gets the number of samples used by the texture (WebGL2+ only)
  37036. */
  37037. samples: number;
  37038. /**
  37039. * Gets the type of the texture
  37040. */
  37041. type: number;
  37042. /**
  37043. * Gets the format of the texture
  37044. */
  37045. format: number;
  37046. /**
  37047. * Observable called when the texture is loaded
  37048. */
  37049. onLoadedObservable: Observable<InternalTexture>;
  37050. /**
  37051. * Gets the width of the texture
  37052. */
  37053. width: number;
  37054. /**
  37055. * Gets the height of the texture
  37056. */
  37057. height: number;
  37058. /**
  37059. * Gets the depth of the texture
  37060. */
  37061. depth: number;
  37062. /**
  37063. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37064. */
  37065. baseWidth: number;
  37066. /**
  37067. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37068. */
  37069. baseHeight: number;
  37070. /**
  37071. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37072. */
  37073. baseDepth: number;
  37074. /**
  37075. * Gets a boolean indicating if the texture is inverted on Y axis
  37076. */
  37077. invertY: boolean;
  37078. /**
  37079. * Gets or set the previous tracker in the list
  37080. */
  37081. previous: Nullable<IInternalTextureTracker>;
  37082. /**
  37083. * Gets or set the next tracker in the list
  37084. */
  37085. next: Nullable<IInternalTextureTracker>;
  37086. /** @hidden */
  37087. _initialSlot: number;
  37088. /** @hidden */
  37089. _designatedSlot: number;
  37090. /** @hidden */
  37091. _dataSource: number;
  37092. /** @hidden */
  37093. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37094. /** @hidden */
  37095. _bufferView: Nullable<ArrayBufferView>;
  37096. /** @hidden */
  37097. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37098. /** @hidden */
  37099. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37100. /** @hidden */
  37101. _size: number;
  37102. /** @hidden */
  37103. _extension: string;
  37104. /** @hidden */
  37105. _files: Nullable<string[]>;
  37106. /** @hidden */
  37107. _workingCanvas: HTMLCanvasElement;
  37108. /** @hidden */
  37109. _workingContext: CanvasRenderingContext2D;
  37110. /** @hidden */
  37111. _framebuffer: Nullable<WebGLFramebuffer>;
  37112. /** @hidden */
  37113. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37114. /** @hidden */
  37115. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37116. /** @hidden */
  37117. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37118. /** @hidden */
  37119. _attachments: Nullable<number[]>;
  37120. /** @hidden */
  37121. _cachedCoordinatesMode: Nullable<number>;
  37122. /** @hidden */
  37123. _cachedWrapU: Nullable<number>;
  37124. /** @hidden */
  37125. _cachedWrapV: Nullable<number>;
  37126. /** @hidden */
  37127. _cachedWrapR: Nullable<number>;
  37128. /** @hidden */
  37129. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37130. /** @hidden */
  37131. _isDisabled: boolean;
  37132. /** @hidden */
  37133. _compression: Nullable<string>;
  37134. /** @hidden */
  37135. _generateStencilBuffer: boolean;
  37136. /** @hidden */
  37137. _generateDepthBuffer: boolean;
  37138. /** @hidden */
  37139. _comparisonFunction: number;
  37140. /** @hidden */
  37141. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37142. /** @hidden */
  37143. _lodGenerationScale: number;
  37144. /** @hidden */
  37145. _lodGenerationOffset: number;
  37146. /** @hidden */
  37147. _lodTextureHigh: BaseTexture;
  37148. /** @hidden */
  37149. _lodTextureMid: BaseTexture;
  37150. /** @hidden */
  37151. _lodTextureLow: BaseTexture;
  37152. /** @hidden */
  37153. _isRGBD: boolean;
  37154. /** @hidden */
  37155. _webGLTexture: Nullable<WebGLTexture>;
  37156. /** @hidden */
  37157. _references: number;
  37158. private _engine;
  37159. /**
  37160. * Gets the Engine the texture belongs to.
  37161. * @returns The babylon engine
  37162. */
  37163. getEngine(): Engine;
  37164. /**
  37165. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  37166. */
  37167. readonly dataSource: number;
  37168. /**
  37169. * Creates a new InternalTexture
  37170. * @param engine defines the engine to use
  37171. * @param dataSource defines the type of data that will be used
  37172. */
  37173. constructor(engine: Engine, dataSource: number);
  37174. /**
  37175. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  37176. */
  37177. incrementReferences(): void;
  37178. /**
  37179. * Change the size of the texture (not the size of the content)
  37180. * @param width defines the new width
  37181. * @param height defines the new height
  37182. * @param depth defines the new depth (1 by default)
  37183. */
  37184. updateSize(width: int, height: int, depth?: int): void;
  37185. /** @hidden */
  37186. _rebuild(): void;
  37187. /** @hidden */
  37188. _swapAndDie(target: InternalTexture): void;
  37189. /**
  37190. * Dispose the current allocated resources
  37191. */
  37192. dispose(): void;
  37193. }
  37194. }
  37195. declare module BABYLON {
  37196. /**
  37197. * This represents the required contract to create a new type of texture loader.
  37198. */
  37199. interface IInternalTextureLoader {
  37200. /**
  37201. * Defines wether the loader supports cascade loading the different faces.
  37202. */
  37203. supportCascades: boolean;
  37204. /**
  37205. * This returns if the loader support the current file information.
  37206. * @param extension defines the file extension of the file being loaded
  37207. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37208. * @param fallback defines the fallback internal texture if any
  37209. * @param isBase64 defines whether the texture is encoded as a base64
  37210. * @param isBuffer defines whether the texture data are stored as a buffer
  37211. * @returns true if the loader can load the specified file
  37212. */
  37213. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  37214. /**
  37215. * Transform the url before loading if required.
  37216. * @param rootUrl the url of the texture
  37217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37218. * @returns the transformed texture
  37219. */
  37220. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  37221. /**
  37222. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  37223. * @param rootUrl the url of the texture
  37224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37225. * @returns the fallback texture
  37226. */
  37227. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  37228. /**
  37229. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  37230. * @param data contains the texture data
  37231. * @param texture defines the BabylonJS internal texture
  37232. * @param createPolynomials will be true if polynomials have been requested
  37233. * @param onLoad defines the callback to trigger once the texture is ready
  37234. * @param onError defines the callback to trigger in case of error
  37235. */
  37236. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  37237. /**
  37238. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  37239. * @param data contains the texture data
  37240. * @param texture defines the BabylonJS internal texture
  37241. * @param callback defines the method to call once ready to upload
  37242. */
  37243. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  37244. }
  37245. }
  37246. declare module BABYLON {
  37247. /**
  37248. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  37249. */
  37250. interface IInternalTextureTracker {
  37251. /**
  37252. * Gets or set the previous tracker in the list
  37253. */
  37254. previous: Nullable<IInternalTextureTracker>;
  37255. /**
  37256. * Gets or set the next tracker in the list
  37257. */
  37258. next: Nullable<IInternalTextureTracker>;
  37259. }
  37260. /**
  37261. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  37262. */
  37263. class DummyInternalTextureTracker {
  37264. /**
  37265. * Gets or set the previous tracker in the list
  37266. */
  37267. previous: Nullable<IInternalTextureTracker>;
  37268. /**
  37269. * Gets or set the next tracker in the list
  37270. */
  37271. next: Nullable<IInternalTextureTracker>;
  37272. }
  37273. }
  37274. declare module BABYLON {
  37275. class MirrorTexture extends RenderTargetTexture {
  37276. private scene;
  37277. mirrorPlane: Plane;
  37278. private _transformMatrix;
  37279. private _mirrorMatrix;
  37280. private _savedViewMatrix;
  37281. private _blurX;
  37282. private _blurY;
  37283. private _adaptiveBlurKernel;
  37284. private _blurKernelX;
  37285. private _blurKernelY;
  37286. private _blurRatio;
  37287. blurRatio: number;
  37288. adaptiveBlurKernel: number;
  37289. blurKernel: number;
  37290. blurKernelX: number;
  37291. blurKernelY: number;
  37292. private _autoComputeBlurKernel;
  37293. protected _onRatioRescale(): void;
  37294. private _updateGammaSpace;
  37295. private _imageProcessingConfigChangeObserver;
  37296. constructor(name: string, size: number | {
  37297. width: number;
  37298. height: number;
  37299. } | {
  37300. ratio: number;
  37301. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  37302. private _preparePostProcesses;
  37303. clone(): MirrorTexture;
  37304. serialize(): any;
  37305. dispose(): void;
  37306. }
  37307. }
  37308. declare module BABYLON {
  37309. interface IMultiRenderTargetOptions {
  37310. generateMipMaps?: boolean;
  37311. types?: number[];
  37312. samplingModes?: number[];
  37313. generateDepthBuffer?: boolean;
  37314. generateStencilBuffer?: boolean;
  37315. generateDepthTexture?: boolean;
  37316. textureCount?: number;
  37317. doNotChangeAspectRatio?: boolean;
  37318. defaultType?: number;
  37319. }
  37320. class MultiRenderTarget extends RenderTargetTexture {
  37321. private _internalTextures;
  37322. private _textures;
  37323. readonly isSupported: boolean;
  37324. private _multiRenderTargetOptions;
  37325. readonly textures: Texture[];
  37326. readonly depthTexture: Texture;
  37327. wrapU: number;
  37328. wrapV: number;
  37329. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  37330. /** @hidden */
  37331. _rebuild(): void;
  37332. private _createInternalTextures;
  37333. private _createTextures;
  37334. samples: number;
  37335. resize(size: any): void;
  37336. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37337. dispose(): void;
  37338. releaseInternalTextures(): void;
  37339. }
  37340. }
  37341. declare module BABYLON {
  37342. /**
  37343. * Raw cube texture where the raw buffers are passed in
  37344. */
  37345. class RawCubeTexture extends CubeTexture {
  37346. /**
  37347. * Creates a cube texture where the raw buffers are passed in.
  37348. * @param scene defines the scene the texture is attached to
  37349. * @param data defines the array of data to use to create each face
  37350. * @param size defines the size of the textures
  37351. * @param format defines the format of the data
  37352. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  37353. * @param generateMipMaps defines if the engine should generate the mip levels
  37354. * @param invertY defines if data must be stored with Y axis inverted
  37355. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  37356. * @param compression defines the compression used (null by default)
  37357. */
  37358. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  37359. /**
  37360. * Updates the raw cube texture.
  37361. * @param data defines the data to store
  37362. * @param format defines the data format
  37363. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  37364. * @param invertY defines if data must be stored with Y axis inverted
  37365. * @param compression defines the compression used (null by default)
  37366. * @param level defines which level of the texture to update
  37367. */
  37368. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  37369. /**
  37370. * Updates a raw cube texture with RGBD encoded data.
  37371. * @param data defines the array of data [mipmap][face] to use to create each face
  37372. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  37373. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37374. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37375. * @returns a promsie that resolves when the operation is complete
  37376. */
  37377. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  37378. /**
  37379. * Clones the raw cube texture.
  37380. * @return a new cube texture
  37381. */
  37382. clone(): CubeTexture;
  37383. /** @hidden */
  37384. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  37385. }
  37386. }
  37387. declare module BABYLON {
  37388. class RawTexture extends Texture {
  37389. format: number;
  37390. private _engine;
  37391. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  37392. update(data: ArrayBufferView): void;
  37393. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37394. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37395. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37396. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37397. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37398. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37399. }
  37400. }
  37401. declare module BABYLON {
  37402. /**
  37403. * Class used to store 3D textures containing user data
  37404. */
  37405. class RawTexture3D extends Texture {
  37406. /** Gets or sets the texture format to use */
  37407. format: number;
  37408. private _engine;
  37409. /**
  37410. * Create a new RawTexture3D
  37411. * @param data defines the data of the texture
  37412. * @param width defines the width of the texture
  37413. * @param height defines the height of the texture
  37414. * @param depth defines the depth of the texture
  37415. * @param format defines the texture format to use
  37416. * @param scene defines the hosting scene
  37417. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  37418. * @param invertY defines if texture must be stored with Y axis inverted
  37419. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37420. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  37421. */
  37422. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  37423. /** Gets or sets the texture format to use */
  37424. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  37425. /**
  37426. * Update the texture with new data
  37427. * @param data defines the data to store in the texture
  37428. */
  37429. update(data: ArrayBufferView): void;
  37430. }
  37431. }
  37432. declare module BABYLON {
  37433. /**
  37434. * Creates a refraction texture used by refraction channel of the standard material.
  37435. * @param name the texture name
  37436. * @param size size of the underlying texture
  37437. * @param scene root scene
  37438. */
  37439. class RefractionTexture extends RenderTargetTexture {
  37440. refractionPlane: Plane;
  37441. depth: number;
  37442. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  37443. clone(): RefractionTexture;
  37444. serialize(): any;
  37445. }
  37446. }
  37447. declare module BABYLON {
  37448. class RenderTargetTexture extends Texture {
  37449. isCube: boolean;
  37450. static _REFRESHRATE_RENDER_ONCE: number;
  37451. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37452. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37453. static readonly REFRESHRATE_RENDER_ONCE: number;
  37454. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37455. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37456. /**
  37457. * Use this predicate to dynamically define the list of mesh you want to render.
  37458. * If set, the renderList property will be overwritten.
  37459. */
  37460. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37461. private _renderList;
  37462. /**
  37463. * Use this list to define the list of mesh you want to render.
  37464. */
  37465. renderList: Nullable<Array<AbstractMesh>>;
  37466. private _hookArray;
  37467. renderParticles: boolean;
  37468. renderSprites: boolean;
  37469. coordinatesMode: number;
  37470. activeCamera: Nullable<Camera>;
  37471. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37472. useCameraPostProcesses: boolean;
  37473. ignoreCameraViewport: boolean;
  37474. private _postProcessManager;
  37475. private _postProcesses;
  37476. private _resizeObserver;
  37477. /**
  37478. * An event triggered when the texture is unbind.
  37479. */
  37480. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37481. /**
  37482. * An event triggered when the texture is unbind.
  37483. */
  37484. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37485. private _onAfterUnbindObserver;
  37486. onAfterUnbind: () => void;
  37487. /**
  37488. * An event triggered before rendering the texture
  37489. */
  37490. onBeforeRenderObservable: Observable<number>;
  37491. private _onBeforeRenderObserver;
  37492. onBeforeRender: (faceIndex: number) => void;
  37493. /**
  37494. * An event triggered after rendering the texture
  37495. */
  37496. onAfterRenderObservable: Observable<number>;
  37497. private _onAfterRenderObserver;
  37498. onAfterRender: (faceIndex: number) => void;
  37499. /**
  37500. * An event triggered after the texture clear
  37501. */
  37502. onClearObservable: Observable<Engine>;
  37503. private _onClearObserver;
  37504. onClear: (Engine: Engine) => void;
  37505. clearColor: Color4;
  37506. protected _size: number | {
  37507. width: number;
  37508. height: number;
  37509. };
  37510. protected _initialSizeParameter: number | {
  37511. width: number;
  37512. height: number;
  37513. } | {
  37514. ratio: number;
  37515. };
  37516. protected _sizeRatio: Nullable<number>;
  37517. /** @hidden */
  37518. _generateMipMaps: boolean;
  37519. protected _renderingManager: RenderingManager;
  37520. /** @hidden */
  37521. _waitingRenderList: string[];
  37522. protected _doNotChangeAspectRatio: boolean;
  37523. protected _currentRefreshId: number;
  37524. protected _refreshRate: number;
  37525. protected _textureMatrix: Matrix;
  37526. protected _samples: number;
  37527. protected _renderTargetOptions: RenderTargetCreationOptions;
  37528. readonly renderTargetOptions: RenderTargetCreationOptions;
  37529. protected _engine: Engine;
  37530. protected _onRatioRescale(): void;
  37531. /**
  37532. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37533. * It must define where the camera used to render the texture is set
  37534. */
  37535. boundingBoxPosition: Vector3;
  37536. private _boundingBoxSize;
  37537. /**
  37538. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37539. * When defined, the cubemap will switch to local mode
  37540. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37541. * @example https://www.babylonjs-playground.com/#RNASML
  37542. */
  37543. boundingBoxSize: Vector3;
  37544. /**
  37545. * In case the RTT has been created with a depth texture, get the associated
  37546. * depth texture.
  37547. * Otherwise, return null.
  37548. */
  37549. depthStencilTexture: Nullable<InternalTexture>;
  37550. /**
  37551. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  37552. * or used a shadow, depth texture...
  37553. * @param name The friendly name of the texture
  37554. * @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)
  37555. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37556. * @param generateMipMaps True if mip maps need to be generated after render.
  37557. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37558. * @param type The type of the buffer in the RTT (int, half float, float...)
  37559. * @param isCube True if a cube texture needs to be created
  37560. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37561. * @param generateDepthBuffer True to generate a depth buffer
  37562. * @param generateStencilBuffer True to generate a stencil buffer
  37563. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37564. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37565. */
  37566. constructor(name: string, size: number | {
  37567. width: number;
  37568. height: number;
  37569. } | {
  37570. ratio: number;
  37571. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  37572. /**
  37573. * Creates a depth stencil texture.
  37574. * This is only available in WebGL 2 or with the depth texture extension available.
  37575. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37576. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37577. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37578. */
  37579. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37580. private _processSizeParameter;
  37581. samples: number;
  37582. resetRefreshCounter(): void;
  37583. refreshRate: number;
  37584. addPostProcess(postProcess: PostProcess): void;
  37585. clearPostProcesses(dispose?: boolean): void;
  37586. removePostProcess(postProcess: PostProcess): void;
  37587. /** @hidden */
  37588. _shouldRender(): boolean;
  37589. getRenderSize(): number;
  37590. getRenderWidth(): number;
  37591. getRenderHeight(): number;
  37592. readonly canRescale: boolean;
  37593. scale(ratio: number): void;
  37594. getReflectionTextureMatrix(): Matrix;
  37595. resize(size: number | {
  37596. width: number;
  37597. height: number;
  37598. } | {
  37599. ratio: number;
  37600. }): void;
  37601. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37602. private _bestReflectionRenderTargetDimension;
  37603. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37604. private renderToTarget;
  37605. /**
  37606. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37607. * This allowed control for front to back rendering or reversly depending of the special needs.
  37608. *
  37609. * @param renderingGroupId The rendering group id corresponding to its index
  37610. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37611. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37612. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37613. */
  37614. 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;
  37615. /**
  37616. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37617. *
  37618. * @param renderingGroupId The rendering group id corresponding to its index
  37619. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37620. */
  37621. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37622. clone(): RenderTargetTexture;
  37623. serialize(): any;
  37624. disposeFramebufferObjects(): void;
  37625. dispose(): void;
  37626. /** @hidden */
  37627. _rebuild(): void;
  37628. /**
  37629. * Clear the info related to rendering groups preventing retention point in material dispose.
  37630. */
  37631. freeRenderingGroups(): void;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. class Texture extends BaseTexture {
  37636. static NEAREST_SAMPLINGMODE: number;
  37637. static NEAREST_NEAREST_MIPLINEAR: number;
  37638. static BILINEAR_SAMPLINGMODE: number;
  37639. static LINEAR_LINEAR_MIPNEAREST: number;
  37640. static TRILINEAR_SAMPLINGMODE: number;
  37641. static LINEAR_LINEAR_MIPLINEAR: number;
  37642. static NEAREST_NEAREST_MIPNEAREST: number;
  37643. static NEAREST_LINEAR_MIPNEAREST: number;
  37644. static NEAREST_LINEAR_MIPLINEAR: number;
  37645. static NEAREST_LINEAR: number;
  37646. static NEAREST_NEAREST: number;
  37647. static LINEAR_NEAREST_MIPNEAREST: number;
  37648. static LINEAR_NEAREST_MIPLINEAR: number;
  37649. static LINEAR_LINEAR: number;
  37650. static LINEAR_NEAREST: number;
  37651. static EXPLICIT_MODE: number;
  37652. static SPHERICAL_MODE: number;
  37653. static PLANAR_MODE: number;
  37654. static CUBIC_MODE: number;
  37655. static PROJECTION_MODE: number;
  37656. static SKYBOX_MODE: number;
  37657. static INVCUBIC_MODE: number;
  37658. static EQUIRECTANGULAR_MODE: number;
  37659. static FIXED_EQUIRECTANGULAR_MODE: number;
  37660. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37661. static readonly CLAMP_ADDRESSMODE: number;
  37662. static readonly WRAP_ADDRESSMODE: number;
  37663. static readonly MIRROR_ADDRESSMODE: number;
  37664. /**
  37665. * 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
  37666. */
  37667. static UseSerializedUrlIfAny: boolean;
  37668. url: Nullable<string>;
  37669. uOffset: number;
  37670. vOffset: number;
  37671. uScale: number;
  37672. vScale: number;
  37673. uAng: number;
  37674. vAng: number;
  37675. wAng: number;
  37676. /**
  37677. * Defines the center of rotation (U)
  37678. */
  37679. uRotationCenter: number;
  37680. /**
  37681. * Defines the center of rotation (V)
  37682. */
  37683. vRotationCenter: number;
  37684. /**
  37685. * Defines the center of rotation (W)
  37686. */
  37687. wRotationCenter: number;
  37688. readonly noMipmap: boolean;
  37689. private _noMipmap;
  37690. /** @hidden */
  37691. _invertY: boolean;
  37692. private _rowGenerationMatrix;
  37693. private _cachedTextureMatrix;
  37694. private _projectionModeMatrix;
  37695. private _t0;
  37696. private _t1;
  37697. private _t2;
  37698. private _cachedUOffset;
  37699. private _cachedVOffset;
  37700. private _cachedUScale;
  37701. private _cachedVScale;
  37702. private _cachedUAng;
  37703. private _cachedVAng;
  37704. private _cachedWAng;
  37705. private _cachedProjectionMatrixId;
  37706. private _cachedCoordinatesMode;
  37707. /** @hidden */
  37708. _samplingMode: number;
  37709. /** @hidden */
  37710. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37711. private _deleteBuffer;
  37712. protected _format: Nullable<number>;
  37713. private _delayedOnLoad;
  37714. private _delayedOnError;
  37715. protected _onLoadObservable: Nullable<Observable<Texture>>;
  37716. protected _isBlocking: boolean;
  37717. isBlocking: boolean;
  37718. readonly samplingMode: number;
  37719. 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);
  37720. /**
  37721. * Update the url (and optional buffer) of this texture if url was null during construction.
  37722. * @param url the url of the texture
  37723. * @param buffer the buffer of the texture (defaults to null)
  37724. */
  37725. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  37726. delayLoad(): void;
  37727. /**
  37728. * Default is Trilinear mode.
  37729. *
  37730. * | Value | Type | Description |
  37731. * | ----- | ------------------ | ----------- |
  37732. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37733. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37734. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37735. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37736. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37737. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37738. * | 7 | NEAREST_LINEAR | |
  37739. * | 8 | NEAREST_NEAREST | |
  37740. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37741. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37742. * | 11 | LINEAR_LINEAR | |
  37743. * | 12 | LINEAR_NEAREST | |
  37744. *
  37745. * > _mag_: magnification filter (close to the viewer)
  37746. * > _min_: minification filter (far from the viewer)
  37747. * > _mip_: filter used between mip map levels
  37748. *
  37749. */
  37750. updateSamplingMode(samplingMode: number): void;
  37751. private _prepareRowForTextureGeneration;
  37752. getTextureMatrix(): Matrix;
  37753. getReflectionTextureMatrix(): Matrix;
  37754. clone(): Texture;
  37755. readonly onLoadObservable: Observable<Texture>;
  37756. serialize(): any;
  37757. getClassName(): string;
  37758. dispose(): void;
  37759. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  37760. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  37761. 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;
  37762. }
  37763. }
  37764. declare module BABYLON {
  37765. /**
  37766. * Settings for finer control over video usage
  37767. */
  37768. interface VideoTextureSettings {
  37769. /**
  37770. * Applies `autoplay` to video, if specified
  37771. */
  37772. autoPlay?: boolean;
  37773. /**
  37774. * Applies `loop` to video, if specified
  37775. */
  37776. loop?: boolean;
  37777. /**
  37778. * Automatically updates internal texture from video at every frame in the render loop
  37779. */
  37780. autoUpdateTexture: boolean;
  37781. /**
  37782. * Image src displayed during the video loading or until the user interacts with the video.
  37783. */
  37784. poster?: string;
  37785. }
  37786. class VideoTexture extends Texture {
  37787. /**
  37788. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  37789. */
  37790. readonly autoUpdateTexture: boolean;
  37791. /**
  37792. * The video instance used by the texture internally
  37793. */
  37794. readonly video: HTMLVideoElement;
  37795. private _onUserActionRequestedObservable;
  37796. readonly onUserActionRequestedObservable: Observable<Texture>;
  37797. private _generateMipMaps;
  37798. private _engine;
  37799. private _stillImageCaptured;
  37800. private _poster;
  37801. /**
  37802. * Creates a video texture.
  37803. * Sample : https://doc.babylonjs.com/how_to/video_texture
  37804. * @param {string | null} name optional name, will detect from video source, if not defined
  37805. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  37806. * @param {BABYLON.Scene} scene is obviously the current scene.
  37807. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  37808. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  37809. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  37810. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  37811. */
  37812. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  37813. private _getName;
  37814. private _getVideo;
  37815. private _createInternalTexture;
  37816. private reset;
  37817. /**
  37818. * @hidden Internal method to initiate `update`.
  37819. */
  37820. _rebuild(): void;
  37821. /**
  37822. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  37823. */
  37824. update(): void;
  37825. /**
  37826. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  37827. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  37828. */
  37829. updateTexture(isVisible: boolean): void;
  37830. protected _updateInternalTexture: (e?: Event | undefined) => void;
  37831. /**
  37832. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  37833. * @param url New url.
  37834. */
  37835. updateURL(url: string): void;
  37836. dispose(): void;
  37837. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  37838. minWidth: number;
  37839. maxWidth: number;
  37840. minHeight: number;
  37841. maxHeight: number;
  37842. deviceId: string;
  37843. }): void;
  37844. }
  37845. }
  37846. declare var DracoDecoderModule: any;
  37847. declare var WebAssembly: any;
  37848. declare module BABYLON {
  37849. /**
  37850. * Configuration for Draco compression
  37851. */
  37852. interface IDracoCompressionConfiguration {
  37853. /**
  37854. * Configuration for the decoder.
  37855. */
  37856. decoder?: {
  37857. /**
  37858. * The url to the WebAssembly module.
  37859. */
  37860. wasmUrl?: string;
  37861. /**
  37862. * The url to the WebAssembly binary.
  37863. */
  37864. wasmBinaryUrl?: string;
  37865. /**
  37866. * The url to the fallback JavaScript module.
  37867. */
  37868. fallbackUrl?: string;
  37869. };
  37870. }
  37871. /**
  37872. * Draco compression (https://google.github.io/draco/)
  37873. *
  37874. * This class wraps the Draco module.
  37875. *
  37876. * **Encoder**
  37877. *
  37878. * The encoder is not currently implemented.
  37879. *
  37880. * **Decoder**
  37881. *
  37882. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  37883. *
  37884. * To update the configuration, use the following code:
  37885. * ```javascript
  37886. * BABYLON.DracoCompression.Configuration = {
  37887. * decoder: {
  37888. * wasmUrl: "<url to the WebAssembly library>",
  37889. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  37890. * fallbackUrl: "<url to the fallback JavaScript library>",
  37891. * }
  37892. * };
  37893. * ```
  37894. *
  37895. * 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.
  37896. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  37897. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  37898. *
  37899. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  37900. * ```javascript
  37901. * var dracoCompression = new BABYLON.DracoCompression();
  37902. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  37903. * [BABYLON.VertexBuffer.PositionKind]: 0
  37904. * });
  37905. * ```
  37906. *
  37907. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  37908. */
  37909. class DracoCompression implements IDisposable {
  37910. private static _DecoderModulePromise;
  37911. /**
  37912. * The configuration. Defaults to the following urls:
  37913. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  37914. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  37915. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  37916. */
  37917. static Configuration: IDracoCompressionConfiguration;
  37918. /**
  37919. * Returns true if the decoder is available.
  37920. */
  37921. static readonly DecoderAvailable: boolean;
  37922. /**
  37923. * Constructor
  37924. */
  37925. constructor();
  37926. /**
  37927. * Stop all async operations and release resources.
  37928. */
  37929. dispose(): void;
  37930. /**
  37931. * Decode Draco compressed mesh data to vertex data.
  37932. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  37933. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  37934. * @returns A promise that resolves with the decoded vertex data
  37935. */
  37936. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  37937. [kind: string]: number;
  37938. }): Promise<VertexData>;
  37939. private static _GetDecoderModule;
  37940. private static _LoadScriptAsync;
  37941. private static _LoadFileAsync;
  37942. }
  37943. }
  37944. declare module BABYLON {
  37945. /**
  37946. * Particle emitter emitting particles from the inside of a box.
  37947. * It emits the particles randomly between 2 given directions.
  37948. */
  37949. class BoxParticleEmitter implements IParticleEmitterType {
  37950. /**
  37951. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37952. */
  37953. direction1: Vector3;
  37954. /**
  37955. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37956. */
  37957. direction2: Vector3;
  37958. /**
  37959. * 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.
  37960. */
  37961. minEmitBox: Vector3;
  37962. /**
  37963. * 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.
  37964. */
  37965. maxEmitBox: Vector3;
  37966. /**
  37967. * Creates a new instance BoxParticleEmitter
  37968. */
  37969. constructor();
  37970. /**
  37971. * Called by the particle System when the direction is computed for the created particle.
  37972. * @param worldMatrix is the world matrix of the particle system
  37973. * @param directionToUpdate is the direction vector to update with the result
  37974. * @param particle is the particle we are computed the direction for
  37975. */
  37976. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37977. /**
  37978. * Called by the particle System when the position is computed for the created particle.
  37979. * @param worldMatrix is the world matrix of the particle system
  37980. * @param positionToUpdate is the position vector to update with the result
  37981. * @param particle is the particle we are computed the position for
  37982. */
  37983. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37984. /**
  37985. * Clones the current emitter and returns a copy of it
  37986. * @returns the new emitter
  37987. */
  37988. clone(): BoxParticleEmitter;
  37989. /**
  37990. * Called by the GPUParticleSystem to setup the update shader
  37991. * @param effect defines the update shader
  37992. */
  37993. applyToShader(effect: Effect): void;
  37994. /**
  37995. * Returns a string to use to update the GPU particles update shader
  37996. * @returns a string containng the defines string
  37997. */
  37998. getEffectDefines(): string;
  37999. /**
  38000. * Returns the string "BoxParticleEmitter"
  38001. * @returns a string containing the class name
  38002. */
  38003. getClassName(): string;
  38004. /**
  38005. * Serializes the particle system to a JSON object.
  38006. * @returns the JSON object
  38007. */
  38008. serialize(): any;
  38009. /**
  38010. * Parse properties from a JSON object
  38011. * @param serializationObject defines the JSON object
  38012. */
  38013. parse(serializationObject: any): void;
  38014. }
  38015. }
  38016. declare module BABYLON {
  38017. /**
  38018. * Particle emitter emitting particles from the inside of a cone.
  38019. * It emits the particles alongside the cone volume from the base to the particle.
  38020. * The emission direction might be randomized.
  38021. */
  38022. class ConeParticleEmitter implements IParticleEmitterType {
  38023. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38024. directionRandomizer: number;
  38025. private _radius;
  38026. private _angle;
  38027. private _height;
  38028. /**
  38029. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  38030. */
  38031. radiusRange: number;
  38032. /**
  38033. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  38034. */
  38035. heightRange: number;
  38036. /**
  38037. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  38038. */
  38039. emitFromSpawnPointOnly: boolean;
  38040. /**
  38041. * Gets or sets the radius of the emission cone
  38042. */
  38043. radius: number;
  38044. /**
  38045. * Gets or sets the angle of the emission cone
  38046. */
  38047. angle: number;
  38048. private _buildHeight;
  38049. /**
  38050. * Creates a new instance ConeParticleEmitter
  38051. * @param radius the radius of the emission cone (1 by default)
  38052. * @param angles the cone base angle (PI by default)
  38053. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  38054. */
  38055. constructor(radius?: number, angle?: number,
  38056. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38057. directionRandomizer?: number);
  38058. /**
  38059. * Called by the particle System when the direction is computed for the created particle.
  38060. * @param worldMatrix is the world matrix of the particle system
  38061. * @param directionToUpdate is the direction vector to update with the result
  38062. * @param particle is the particle we are computed the direction for
  38063. */
  38064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38065. /**
  38066. * Called by the particle System when the position is computed for the created particle.
  38067. * @param worldMatrix is the world matrix of the particle system
  38068. * @param positionToUpdate is the position vector to update with the result
  38069. * @param particle is the particle we are computed the position for
  38070. */
  38071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38072. /**
  38073. * Clones the current emitter and returns a copy of it
  38074. * @returns the new emitter
  38075. */
  38076. clone(): ConeParticleEmitter;
  38077. /**
  38078. * Called by the GPUParticleSystem to setup the update shader
  38079. * @param effect defines the update shader
  38080. */
  38081. applyToShader(effect: Effect): void;
  38082. /**
  38083. * Returns a string to use to update the GPU particles update shader
  38084. * @returns a string containng the defines string
  38085. */
  38086. getEffectDefines(): string;
  38087. /**
  38088. * Returns the string "ConeParticleEmitter"
  38089. * @returns a string containing the class name
  38090. */
  38091. getClassName(): string;
  38092. /**
  38093. * Serializes the particle system to a JSON object.
  38094. * @returns the JSON object
  38095. */
  38096. serialize(): any;
  38097. /**
  38098. * Parse properties from a JSON object
  38099. * @param serializationObject defines the JSON object
  38100. */
  38101. parse(serializationObject: any): void;
  38102. }
  38103. }
  38104. declare module BABYLON {
  38105. /**
  38106. * Particle emitter emitting particles from the inside of a cylinder.
  38107. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  38108. */
  38109. class CylinderParticleEmitter implements IParticleEmitterType {
  38110. /**
  38111. * The radius of the emission cylinder.
  38112. */
  38113. radius: number;
  38114. /**
  38115. * The height of the emission cylinder.
  38116. */
  38117. height: number;
  38118. /**
  38119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38120. */
  38121. radiusRange: number;
  38122. /**
  38123. * How much to randomize the particle direction [0-1].
  38124. */
  38125. directionRandomizer: number;
  38126. /**
  38127. * Creates a new instance CylinderParticleEmitter
  38128. * @param radius the radius of the emission cylinder (1 by default)
  38129. * @param height the height of the emission cylinder (1 by default)
  38130. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38131. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38132. */
  38133. constructor(
  38134. /**
  38135. * The radius of the emission cylinder.
  38136. */
  38137. radius?: number,
  38138. /**
  38139. * The height of the emission cylinder.
  38140. */
  38141. height?: number,
  38142. /**
  38143. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38144. */
  38145. radiusRange?: number,
  38146. /**
  38147. * How much to randomize the particle direction [0-1].
  38148. */
  38149. directionRandomizer?: number);
  38150. /**
  38151. * Called by the particle System when the direction is computed for the created particle.
  38152. * @param worldMatrix is the world matrix of the particle system
  38153. * @param directionToUpdate is the direction vector to update with the result
  38154. * @param particle is the particle we are computed the direction for
  38155. */
  38156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38157. /**
  38158. * Called by the particle System when the position is computed for the created particle.
  38159. * @param worldMatrix is the world matrix of the particle system
  38160. * @param positionToUpdate is the position vector to update with the result
  38161. * @param particle is the particle we are computed the position for
  38162. */
  38163. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38164. /**
  38165. * Clones the current emitter and returns a copy of it
  38166. * @returns the new emitter
  38167. */
  38168. clone(): CylinderParticleEmitter;
  38169. /**
  38170. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38171. * @param effect defines the update shader
  38172. */
  38173. applyToShader(effect: Effect): void;
  38174. /**
  38175. * Returns a string to use to update the GPU particles update shader
  38176. * @returns a string containng the defines string
  38177. */
  38178. getEffectDefines(): string;
  38179. /**
  38180. * Returns the string "CylinderParticleEmitter"
  38181. * @returns a string containing the class name
  38182. */
  38183. getClassName(): string;
  38184. /**
  38185. * Serializes the particle system to a JSON object.
  38186. * @returns the JSON object
  38187. */
  38188. serialize(): any;
  38189. /**
  38190. * Parse properties from a JSON object
  38191. * @param serializationObject defines the JSON object
  38192. */
  38193. parse(serializationObject: any): void;
  38194. }
  38195. }
  38196. declare module BABYLON {
  38197. /**
  38198. * Particle emitter emitting particles from the inside of a hemisphere.
  38199. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  38200. */
  38201. class HemisphericParticleEmitter implements IParticleEmitterType {
  38202. /**
  38203. * The radius of the emission hemisphere.
  38204. */
  38205. radius: number;
  38206. /**
  38207. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38208. */
  38209. radiusRange: number;
  38210. /**
  38211. * How much to randomize the particle direction [0-1].
  38212. */
  38213. directionRandomizer: number;
  38214. /**
  38215. * Creates a new instance HemisphericParticleEmitter
  38216. * @param radius the radius of the emission hemisphere (1 by default)
  38217. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38218. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38219. */
  38220. constructor(
  38221. /**
  38222. * The radius of the emission hemisphere.
  38223. */
  38224. radius?: number,
  38225. /**
  38226. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38227. */
  38228. radiusRange?: number,
  38229. /**
  38230. * How much to randomize the particle direction [0-1].
  38231. */
  38232. directionRandomizer?: number);
  38233. /**
  38234. * Called by the particle System when the direction is computed for the created particle.
  38235. * @param worldMatrix is the world matrix of the particle system
  38236. * @param directionToUpdate is the direction vector to update with the result
  38237. * @param particle is the particle we are computed the direction for
  38238. */
  38239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38240. /**
  38241. * Called by the particle System when the position is computed for the created particle.
  38242. * @param worldMatrix is the world matrix of the particle system
  38243. * @param positionToUpdate is the position vector to update with the result
  38244. * @param particle is the particle we are computed the position for
  38245. */
  38246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38247. /**
  38248. * Clones the current emitter and returns a copy of it
  38249. * @returns the new emitter
  38250. */
  38251. clone(): HemisphericParticleEmitter;
  38252. /**
  38253. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38254. * @param effect defines the update shader
  38255. */
  38256. applyToShader(effect: Effect): void;
  38257. /**
  38258. * Returns a string to use to update the GPU particles update shader
  38259. * @returns a string containng the defines string
  38260. */
  38261. getEffectDefines(): string;
  38262. /**
  38263. * Returns the string "HemisphericParticleEmitter"
  38264. * @returns a string containing the class name
  38265. */
  38266. getClassName(): string;
  38267. /**
  38268. * Serializes the particle system to a JSON object.
  38269. * @returns the JSON object
  38270. */
  38271. serialize(): any;
  38272. /**
  38273. * Parse properties from a JSON object
  38274. * @param serializationObject defines the JSON object
  38275. */
  38276. parse(serializationObject: any): void;
  38277. }
  38278. }
  38279. declare module BABYLON {
  38280. /**
  38281. * Particle emitter represents a volume emitting particles.
  38282. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  38283. */
  38284. interface IParticleEmitterType {
  38285. /**
  38286. * Called by the particle System when the direction is computed for the created particle.
  38287. * @param worldMatrix is the world matrix of the particle system
  38288. * @param directionToUpdate is the direction vector to update with the result
  38289. * @param particle is the particle we are computed the direction for
  38290. */
  38291. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38292. /**
  38293. * Called by the particle System when the position is computed for the created particle.
  38294. * @param worldMatrix is the world matrix of the particle system
  38295. * @param positionToUpdate is the position vector to update with the result
  38296. * @param particle is the particle we are computed the position for
  38297. */
  38298. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38299. /**
  38300. * Clones the current emitter and returns a copy of it
  38301. * @returns the new emitter
  38302. */
  38303. clone(): IParticleEmitterType;
  38304. /**
  38305. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38306. * @param effect defines the update shader
  38307. */
  38308. applyToShader(effect: Effect): void;
  38309. /**
  38310. * Returns a string to use to update the GPU particles update shader
  38311. * @returns the effect defines string
  38312. */
  38313. getEffectDefines(): string;
  38314. /**
  38315. * Returns a string representing the class name
  38316. * @returns a string containing the class name
  38317. */
  38318. getClassName(): string;
  38319. /**
  38320. * Serializes the particle system to a JSON object.
  38321. * @returns the JSON object
  38322. */
  38323. serialize(): any;
  38324. /**
  38325. * Parse properties from a JSON object
  38326. * @param serializationObject defines the JSON object
  38327. */
  38328. parse(serializationObject: any): void;
  38329. }
  38330. }
  38331. declare module BABYLON {
  38332. /**
  38333. * Particle emitter emitting particles from a point.
  38334. * It emits the particles randomly between 2 given directions.
  38335. */
  38336. class PointParticleEmitter implements IParticleEmitterType {
  38337. /**
  38338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38339. */
  38340. direction1: Vector3;
  38341. /**
  38342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38343. */
  38344. direction2: Vector3;
  38345. /**
  38346. * Creates a new instance PointParticleEmitter
  38347. */
  38348. constructor();
  38349. /**
  38350. * Called by the particle System when the direction is computed for the created particle.
  38351. * @param worldMatrix is the world matrix of the particle system
  38352. * @param directionToUpdate is the direction vector to update with the result
  38353. * @param particle is the particle we are computed the direction for
  38354. */
  38355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38356. /**
  38357. * Called by the particle System when the position is computed for the created particle.
  38358. * @param worldMatrix is the world matrix of the particle system
  38359. * @param positionToUpdate is the position vector to update with the result
  38360. * @param particle is the particle we are computed the position for
  38361. */
  38362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38363. /**
  38364. * Clones the current emitter and returns a copy of it
  38365. * @returns the new emitter
  38366. */
  38367. clone(): PointParticleEmitter;
  38368. /**
  38369. * Called by the GPUParticleSystem to setup the update shader
  38370. * @param effect defines the update shader
  38371. */
  38372. applyToShader(effect: Effect): void;
  38373. /**
  38374. * Returns a string to use to update the GPU particles update shader
  38375. * @returns a string containng the defines string
  38376. */
  38377. getEffectDefines(): string;
  38378. /**
  38379. * Returns the string "PointParticleEmitter"
  38380. * @returns a string containing the class name
  38381. */
  38382. getClassName(): string;
  38383. /**
  38384. * Serializes the particle system to a JSON object.
  38385. * @returns the JSON object
  38386. */
  38387. serialize(): any;
  38388. /**
  38389. * Parse properties from a JSON object
  38390. * @param serializationObject defines the JSON object
  38391. */
  38392. parse(serializationObject: any): void;
  38393. }
  38394. }
  38395. declare module BABYLON {
  38396. /**
  38397. * Particle emitter emitting particles from the inside of a sphere.
  38398. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  38399. */
  38400. class SphereParticleEmitter implements IParticleEmitterType {
  38401. /**
  38402. * The radius of the emission sphere.
  38403. */
  38404. radius: number;
  38405. /**
  38406. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38407. */
  38408. radiusRange: number;
  38409. /**
  38410. * How much to randomize the particle direction [0-1].
  38411. */
  38412. directionRandomizer: number;
  38413. /**
  38414. * Creates a new instance SphereParticleEmitter
  38415. * @param radius the radius of the emission sphere (1 by default)
  38416. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38417. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38418. */
  38419. constructor(
  38420. /**
  38421. * The radius of the emission sphere.
  38422. */
  38423. radius?: number,
  38424. /**
  38425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38426. */
  38427. radiusRange?: number,
  38428. /**
  38429. * How much to randomize the particle direction [0-1].
  38430. */
  38431. directionRandomizer?: number);
  38432. /**
  38433. * Called by the particle System when the direction is computed for the created particle.
  38434. * @param worldMatrix is the world matrix of the particle system
  38435. * @param directionToUpdate is the direction vector to update with the result
  38436. * @param particle is the particle we are computed the direction for
  38437. */
  38438. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38439. /**
  38440. * Called by the particle System when the position is computed for the created particle.
  38441. * @param worldMatrix is the world matrix of the particle system
  38442. * @param positionToUpdate is the position vector to update with the result
  38443. * @param particle is the particle we are computed the position for
  38444. */
  38445. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38446. /**
  38447. * Clones the current emitter and returns a copy of it
  38448. * @returns the new emitter
  38449. */
  38450. clone(): SphereParticleEmitter;
  38451. /**
  38452. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38453. * @param effect defines the update shader
  38454. */
  38455. applyToShader(effect: Effect): void;
  38456. /**
  38457. * Returns a string to use to update the GPU particles update shader
  38458. * @returns a string containng the defines string
  38459. */
  38460. getEffectDefines(): string;
  38461. /**
  38462. * Returns the string "SphereParticleEmitter"
  38463. * @returns a string containing the class name
  38464. */
  38465. getClassName(): string;
  38466. /**
  38467. * Serializes the particle system to a JSON object.
  38468. * @returns the JSON object
  38469. */
  38470. serialize(): any;
  38471. /**
  38472. * Parse properties from a JSON object
  38473. * @param serializationObject defines the JSON object
  38474. */
  38475. parse(serializationObject: any): void;
  38476. }
  38477. /**
  38478. * Particle emitter emitting particles from the inside of a sphere.
  38479. * It emits the particles randomly between two vectors.
  38480. */
  38481. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  38482. /**
  38483. * The min limit of the emission direction.
  38484. */
  38485. direction1: Vector3;
  38486. /**
  38487. * The max limit of the emission direction.
  38488. */
  38489. direction2: Vector3;
  38490. /**
  38491. * Creates a new instance SphereDirectedParticleEmitter
  38492. * @param radius the radius of the emission sphere (1 by default)
  38493. * @param direction1 the min limit of the emission direction (up vector by default)
  38494. * @param direction2 the max limit of the emission direction (up vector by default)
  38495. */
  38496. constructor(radius?: number,
  38497. /**
  38498. * The min limit of the emission direction.
  38499. */
  38500. direction1?: Vector3,
  38501. /**
  38502. * The max limit of the emission direction.
  38503. */
  38504. direction2?: Vector3);
  38505. /**
  38506. * Called by the particle System when the direction is computed for the created particle.
  38507. * @param worldMatrix is the world matrix of the particle system
  38508. * @param directionToUpdate is the direction vector to update with the result
  38509. * @param particle is the particle we are computed the direction for
  38510. */
  38511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38512. /**
  38513. * Clones the current emitter and returns a copy of it
  38514. * @returns the new emitter
  38515. */
  38516. clone(): SphereDirectedParticleEmitter;
  38517. /**
  38518. * Called by the GPUParticleSystem to setup the update shader
  38519. * @param effect defines the update shader
  38520. */
  38521. applyToShader(effect: Effect): void;
  38522. /**
  38523. * Returns a string to use to update the GPU particles update shader
  38524. * @returns a string containng the defines string
  38525. */
  38526. getEffectDefines(): string;
  38527. /**
  38528. * Returns the string "SphereDirectedParticleEmitter"
  38529. * @returns a string containing the class name
  38530. */
  38531. getClassName(): string;
  38532. /**
  38533. * Serializes the particle system to a JSON object.
  38534. * @returns the JSON object
  38535. */
  38536. serialize(): any;
  38537. /**
  38538. * Parse properties from a JSON object
  38539. * @param serializationObject defines the JSON object
  38540. */
  38541. parse(serializationObject: any): void;
  38542. }
  38543. }
  38544. declare module BABYLON {
  38545. class CannonJSPlugin implements IPhysicsEnginePlugin {
  38546. private _useDeltaForWorldStep;
  38547. world: any;
  38548. name: string;
  38549. private _physicsMaterials;
  38550. private _fixedTimeStep;
  38551. BJSCANNON: any;
  38552. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  38553. setGravity(gravity: Vector3): void;
  38554. setTimeStep(timeStep: number): void;
  38555. getTimeStep(): number;
  38556. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38557. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38558. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38559. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38560. private _processChildMeshes;
  38561. removePhysicsBody(impostor: PhysicsImpostor): void;
  38562. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38563. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38564. private _addMaterial;
  38565. private _checkWithEpsilon;
  38566. private _createShape;
  38567. private _createHeightmap;
  38568. private _minus90X;
  38569. private _plus90X;
  38570. private _tmpPosition;
  38571. private _tmpDeltaPosition;
  38572. private _tmpUnityRotation;
  38573. private _updatePhysicsBodyTransformation;
  38574. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38576. isSupported(): boolean;
  38577. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38578. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38579. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38580. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38581. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38582. getBodyMass(impostor: PhysicsImpostor): number;
  38583. getBodyFriction(impostor: PhysicsImpostor): number;
  38584. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38585. getBodyRestitution(impostor: PhysicsImpostor): number;
  38586. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38587. sleepBody(impostor: PhysicsImpostor): void;
  38588. wakeUpBody(impostor: PhysicsImpostor): void;
  38589. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38590. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  38591. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  38592. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38593. getRadius(impostor: PhysicsImpostor): number;
  38594. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38595. dispose(): void;
  38596. private _extendNamespace;
  38597. }
  38598. }
  38599. declare module BABYLON {
  38600. class OimoJSPlugin implements IPhysicsEnginePlugin {
  38601. world: any;
  38602. name: string;
  38603. BJSOIMO: any;
  38604. constructor(iterations?: number);
  38605. setGravity(gravity: Vector3): void;
  38606. setTimeStep(timeStep: number): void;
  38607. getTimeStep(): number;
  38608. private _tmpImpostorsArray;
  38609. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38610. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38611. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38612. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38613. private _tmpPositionVector;
  38614. removePhysicsBody(impostor: PhysicsImpostor): void;
  38615. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38616. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38617. isSupported(): boolean;
  38618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38619. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38625. getBodyMass(impostor: PhysicsImpostor): number;
  38626. getBodyFriction(impostor: PhysicsImpostor): number;
  38627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38628. getBodyRestitution(impostor: PhysicsImpostor): number;
  38629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38630. sleepBody(impostor: PhysicsImpostor): void;
  38631. wakeUpBody(impostor: PhysicsImpostor): void;
  38632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38633. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  38634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  38635. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38636. getRadius(impostor: PhysicsImpostor): number;
  38637. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38638. dispose(): void;
  38639. }
  38640. }
  38641. declare module BABYLON {
  38642. /**
  38643. * This represents a set of one or more post processes in Babylon.
  38644. * A post process can be used to apply a shader to a texture after it is rendered.
  38645. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38646. */
  38647. class PostProcessRenderEffect {
  38648. private _postProcesses;
  38649. private _getPostProcesses;
  38650. private _singleInstance;
  38651. private _cameras;
  38652. private _indicesForCamera;
  38653. /**
  38654. * Name of the effect
  38655. * @hidden
  38656. */
  38657. _name: string;
  38658. /**
  38659. * Instantiates a post process render effect.
  38660. * A post process can be used to apply a shader to a texture after it is rendered.
  38661. * @param engine The engine the effect is tied to
  38662. * @param name The name of the effect
  38663. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  38664. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  38665. */
  38666. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  38667. /**
  38668. * Checks if all the post processes in the effect are supported.
  38669. */
  38670. readonly isSupported: boolean;
  38671. /**
  38672. * Updates the current state of the effect
  38673. * @hidden
  38674. */
  38675. _update(): void;
  38676. /**
  38677. * Attaches the effect on cameras
  38678. * @param cameras The camera to attach to.
  38679. * @hidden
  38680. */
  38681. _attachCameras(cameras: Camera): void;
  38682. /**
  38683. * Attaches the effect on cameras
  38684. * @param cameras The camera to attach to.
  38685. * @hidden
  38686. */
  38687. _attachCameras(cameras: Camera[]): void;
  38688. /**
  38689. * Detatches the effect on cameras
  38690. * @param cameras The camera to detatch from.
  38691. * @hidden
  38692. */
  38693. _detachCameras(cameras: Camera): void;
  38694. /**
  38695. * Detatches the effect on cameras
  38696. * @param cameras The camera to detatch from.
  38697. * @hidden
  38698. */
  38699. _detachCameras(cameras: Camera[]): void;
  38700. /**
  38701. * Enables the effect on given cameras
  38702. * @param cameras The camera to enable.
  38703. * @hidden
  38704. */
  38705. _enable(cameras: Camera): void;
  38706. /**
  38707. * Enables the effect on given cameras
  38708. * @param cameras The camera to enable.
  38709. * @hidden
  38710. */
  38711. _enable(cameras: Nullable<Camera[]>): void;
  38712. /**
  38713. * Disables the effect on the given cameras
  38714. * @param cameras The camera to disable.
  38715. * @hidden
  38716. */
  38717. _disable(cameras: Camera): void;
  38718. /**
  38719. * Disables the effect on the given cameras
  38720. * @param cameras The camera to disable.
  38721. * @hidden
  38722. */
  38723. _disable(cameras: Nullable<Camera[]>): void;
  38724. /**
  38725. * Gets a list of the post processes contained in the effect.
  38726. * @param camera The camera to get the post processes on.
  38727. * @returns The list of the post processes in the effect.
  38728. */
  38729. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  38730. }
  38731. }
  38732. declare module BABYLON {
  38733. class PostProcessRenderPipeline {
  38734. private engine;
  38735. private _renderEffects;
  38736. private _renderEffectsForIsolatedPass;
  38737. protected _cameras: Camera[];
  38738. /** @hidden */
  38739. _name: string;
  38740. constructor(engine: Engine, name: string);
  38741. getClassName(): string;
  38742. readonly isSupported: boolean;
  38743. addEffect(renderEffect: PostProcessRenderEffect): void;
  38744. /** @hidden */
  38745. _rebuild(): void;
  38746. /** @hidden */
  38747. _enableEffect(renderEffectName: string, cameras: Camera): void;
  38748. /** @hidden */
  38749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  38750. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38752. /** @hidden */
  38753. _attachCameras(cameras: Camera, unique: boolean): void;
  38754. /** @hidden */
  38755. _attachCameras(cameras: Camera[], unique: boolean): void;
  38756. /** @hidden */
  38757. _detachCameras(cameras: Camera): void;
  38758. /** @hidden */
  38759. _detachCameras(cameras: Nullable<Camera[]>): void;
  38760. /** @hidden */
  38761. _update(): void;
  38762. /** @hidden */
  38763. _reset(): void;
  38764. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  38765. dispose(): void;
  38766. }
  38767. }
  38768. declare module BABYLON {
  38769. class PostProcessRenderPipelineManager {
  38770. private _renderPipelines;
  38771. constructor();
  38772. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  38773. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  38774. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  38775. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  38776. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  38777. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38778. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38779. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38780. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38781. update(): void;
  38782. /** @hidden */
  38783. _rebuild(): void;
  38784. dispose(): void;
  38785. }
  38786. }
  38787. declare module BABYLON {
  38788. interface Scene {
  38789. /** @hidden (Backing field) */
  38790. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38791. /**
  38792. * Gets the postprocess render pipeline manager
  38793. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38794. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38795. */
  38796. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38797. }
  38798. /**
  38799. * Defines the Render Pipeline scene component responsible to rendering pipelines
  38800. */
  38801. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  38802. /**
  38803. * The component name helpfull to identify the component in the list of scene components.
  38804. */
  38805. readonly name: string;
  38806. /**
  38807. * The scene the component belongs to.
  38808. */
  38809. scene: Scene;
  38810. /**
  38811. * Creates a new instance of the component for the given scene
  38812. * @param scene Defines the scene to register the component in
  38813. */
  38814. constructor(scene: Scene);
  38815. /**
  38816. * Registers the component in a given scene
  38817. */
  38818. register(): void;
  38819. /**
  38820. * Rebuilds the elements related to this component in case of
  38821. * context lost for instance.
  38822. */
  38823. rebuild(): void;
  38824. /**
  38825. * Disposes the component and the associated ressources
  38826. */
  38827. dispose(): void;
  38828. private _gatherRenderTargets;
  38829. private _rebuildGeometry;
  38830. }
  38831. }
  38832. declare module BABYLON {
  38833. /**
  38834. * Helper class dealing with the extraction of spherical polynomial dataArray
  38835. * from a cube map.
  38836. */
  38837. class CubeMapToSphericalPolynomialTools {
  38838. private static FileFaces;
  38839. /**
  38840. * Converts a texture to the according Spherical Polynomial data.
  38841. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38842. *
  38843. * @param texture The texture to extract the information from.
  38844. * @return The Spherical Polynomial data.
  38845. */
  38846. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  38847. /**
  38848. * Converts a cubemap to the according Spherical Polynomial data.
  38849. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38850. *
  38851. * @param cubeInfo The Cube map to extract the information from.
  38852. * @return The Spherical Polynomial data.
  38853. */
  38854. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  38855. }
  38856. }
  38857. declare module BABYLON {
  38858. /**
  38859. * Header information of HDR texture files.
  38860. */
  38861. interface HDRInfo {
  38862. /**
  38863. * The height of the texture in pixels.
  38864. */
  38865. height: number;
  38866. /**
  38867. * The width of the texture in pixels.
  38868. */
  38869. width: number;
  38870. /**
  38871. * The index of the beginning of the data in the binary file.
  38872. */
  38873. dataPosition: number;
  38874. }
  38875. /**
  38876. * This groups tools to convert HDR texture to native colors array.
  38877. */
  38878. class HDRTools {
  38879. private static Ldexp;
  38880. private static Rgbe2float;
  38881. private static readStringLine;
  38882. /**
  38883. * Reads header information from an RGBE texture stored in a native array.
  38884. * More information on this format are available here:
  38885. * https://en.wikipedia.org/wiki/RGBE_image_format
  38886. *
  38887. * @param uint8array The binary file stored in native array.
  38888. * @return The header information.
  38889. */
  38890. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  38891. /**
  38892. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  38893. * This RGBE texture needs to store the information as a panorama.
  38894. *
  38895. * More information on this format are available here:
  38896. * https://en.wikipedia.org/wiki/RGBE_image_format
  38897. *
  38898. * @param buffer The binary file stored in an array buffer.
  38899. * @param size The expected size of the extracted cubemap.
  38900. * @return The Cube Map information.
  38901. */
  38902. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  38903. /**
  38904. * Returns the pixels data extracted from an RGBE texture.
  38905. * This pixels will be stored left to right up to down in the R G B order in one array.
  38906. *
  38907. * More information on this format are available here:
  38908. * https://en.wikipedia.org/wiki/RGBE_image_format
  38909. *
  38910. * @param uint8array The binary file stored in an array buffer.
  38911. * @param hdrInfo The header information of the file.
  38912. * @return The pixels data in RGB right to left up to down order.
  38913. */
  38914. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  38915. private static RGBE_ReadPixels_RLE;
  38916. }
  38917. }
  38918. declare module BABYLON {
  38919. /**
  38920. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  38921. */
  38922. interface CubeMapInfo {
  38923. /**
  38924. * The pixel array for the front face.
  38925. * This is stored in format, left to right, up to down format.
  38926. */
  38927. front: Nullable<ArrayBufferView>;
  38928. /**
  38929. * The pixel array for the back face.
  38930. * This is stored in format, left to right, up to down format.
  38931. */
  38932. back: Nullable<ArrayBufferView>;
  38933. /**
  38934. * The pixel array for the left face.
  38935. * This is stored in format, left to right, up to down format.
  38936. */
  38937. left: Nullable<ArrayBufferView>;
  38938. /**
  38939. * The pixel array for the right face.
  38940. * This is stored in format, left to right, up to down format.
  38941. */
  38942. right: Nullable<ArrayBufferView>;
  38943. /**
  38944. * The pixel array for the up face.
  38945. * This is stored in format, left to right, up to down format.
  38946. */
  38947. up: Nullable<ArrayBufferView>;
  38948. /**
  38949. * The pixel array for the down face.
  38950. * This is stored in format, left to right, up to down format.
  38951. */
  38952. down: Nullable<ArrayBufferView>;
  38953. /**
  38954. * The size of the cubemap stored.
  38955. *
  38956. * Each faces will be size * size pixels.
  38957. */
  38958. size: number;
  38959. /**
  38960. * The format of the texture.
  38961. *
  38962. * RGBA, RGB.
  38963. */
  38964. format: number;
  38965. /**
  38966. * The type of the texture data.
  38967. *
  38968. * UNSIGNED_INT, FLOAT.
  38969. */
  38970. type: number;
  38971. /**
  38972. * Specifies whether the texture is in gamma space.
  38973. */
  38974. gammaSpace: boolean;
  38975. }
  38976. /**
  38977. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  38978. */
  38979. class PanoramaToCubeMapTools {
  38980. private static FACE_FRONT;
  38981. private static FACE_BACK;
  38982. private static FACE_RIGHT;
  38983. private static FACE_LEFT;
  38984. private static FACE_DOWN;
  38985. private static FACE_UP;
  38986. /**
  38987. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  38988. *
  38989. * @param float32Array The source data.
  38990. * @param inputWidth The width of the input panorama.
  38991. * @param inputhHeight The height of the input panorama.
  38992. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  38993. * @return The cubemap data
  38994. */
  38995. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  38996. private static CreateCubemapTexture;
  38997. private static CalcProjectionSpherical;
  38998. }
  38999. }
  39000. declare module BABYLON {
  39001. }
  39002. declare module BABYLON {
  39003. }
  39004. declare module BABYLON {
  39005. }
  39006. declare module BABYLON {
  39007. }
  39008. declare module BABYLON {
  39009. class CustomProceduralTexture extends ProceduralTexture {
  39010. private _animate;
  39011. private _time;
  39012. private _config;
  39013. private _texturePath;
  39014. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39015. private loadJson;
  39016. isReady(): boolean;
  39017. render(useCameraPostProcess?: boolean): void;
  39018. updateTextures(): void;
  39019. updateShaderUniforms(): void;
  39020. animate: boolean;
  39021. }
  39022. }
  39023. declare module BABYLON {
  39024. /**
  39025. * Class used to generate noise procedural textures
  39026. */
  39027. class NoiseProceduralTexture extends ProceduralTexture {
  39028. private _time;
  39029. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  39030. brightness: number;
  39031. /** Defines the number of octaves to process */
  39032. octaves: number;
  39033. /** Defines the level of persistence (0.8 by default) */
  39034. persistence: number;
  39035. /** Gets or sets animation speed factor (default is 1) */
  39036. animationSpeedFactor: number;
  39037. /**
  39038. * Creates a new NoiseProceduralTexture
  39039. * @param name defines the name fo the texture
  39040. * @param size defines the size of the texture (default is 256)
  39041. * @param scene defines the hosting scene
  39042. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  39043. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  39044. */
  39045. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39046. private _updateShaderUniforms;
  39047. protected _getDefines(): string;
  39048. /** Generate the current state of the procedural texture */
  39049. render(useCameraPostProcess?: boolean): void;
  39050. /**
  39051. * Serializes this noise procedural texture
  39052. * @returns a serialized noise procedural texture object
  39053. */
  39054. serialize(): any;
  39055. /**
  39056. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  39057. * @param parsedTexture defines parsed texture data
  39058. * @param scene defines the current scene
  39059. * @param rootUrl defines the root URL containing noise procedural texture information
  39060. * @returns a parsed NoiseProceduralTexture
  39061. */
  39062. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  39063. }
  39064. }
  39065. declare module BABYLON {
  39066. class ProceduralTexture extends Texture {
  39067. isCube: boolean;
  39068. private _size;
  39069. /** @hidden */
  39070. _generateMipMaps: boolean;
  39071. isEnabled: boolean;
  39072. private _currentRefreshId;
  39073. private _refreshRate;
  39074. onGenerated: () => void;
  39075. private _vertexBuffers;
  39076. private _indexBuffer;
  39077. private _effect;
  39078. private _uniforms;
  39079. private _samplers;
  39080. private _fragment;
  39081. /** @hidden */
  39082. _textures: {
  39083. [key: string]: Texture;
  39084. };
  39085. private _floats;
  39086. private _ints;
  39087. private _floatsArrays;
  39088. private _colors3;
  39089. private _colors4;
  39090. private _vectors2;
  39091. private _vectors3;
  39092. private _matrices;
  39093. private _fallbackTexture;
  39094. private _fallbackTextureUsed;
  39095. private _engine;
  39096. private _cachedDefines;
  39097. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  39098. private _createIndexBuffer;
  39099. /** @hidden */
  39100. _rebuild(): void;
  39101. reset(): void;
  39102. protected _getDefines(): string;
  39103. isReady(): boolean;
  39104. resetRefreshCounter(): void;
  39105. setFragment(fragment: any): void;
  39106. refreshRate: number;
  39107. /** @hidden */
  39108. _shouldRender(): boolean;
  39109. getRenderSize(): number;
  39110. resize(size: number, generateMipMaps: boolean): void;
  39111. private _checkUniform;
  39112. setTexture(name: string, texture: Texture): ProceduralTexture;
  39113. setFloat(name: string, value: number): ProceduralTexture;
  39114. /**
  39115. * Set the value of an uniform to an integer value
  39116. * @param name defines the name of the uniform
  39117. * @param value defines the value to set
  39118. * @returns the current procedural texture
  39119. */
  39120. setInt(name: string, value: number): ProceduralTexture;
  39121. setFloats(name: string, value: number[]): ProceduralTexture;
  39122. setColor3(name: string, value: Color3): ProceduralTexture;
  39123. setColor4(name: string, value: Color4): ProceduralTexture;
  39124. setVector2(name: string, value: Vector2): ProceduralTexture;
  39125. setVector3(name: string, value: Vector3): ProceduralTexture;
  39126. setMatrix(name: string, value: Matrix): ProceduralTexture;
  39127. render(useCameraPostProcess?: boolean): void;
  39128. clone(): ProceduralTexture;
  39129. dispose(): void;
  39130. }
  39131. }
  39132. declare module BABYLON {
  39133. /**
  39134. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  39135. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39136. */
  39137. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39138. private _scene;
  39139. private _camerasToBeAttached;
  39140. /**
  39141. * ID of the sharpen post process,
  39142. */
  39143. private readonly SharpenPostProcessId;
  39144. /**
  39145. * ID of the image processing post process;
  39146. */
  39147. readonly ImageProcessingPostProcessId: string;
  39148. /**
  39149. * ID of the Fast Approximate Anti-Aliasing post process;
  39150. */
  39151. readonly FxaaPostProcessId: string;
  39152. /**
  39153. * ID of the chromatic aberration post process,
  39154. */
  39155. private readonly ChromaticAberrationPostProcessId;
  39156. /**
  39157. * ID of the grain post process
  39158. */
  39159. private readonly GrainPostProcessId;
  39160. /**
  39161. * Sharpen post process which will apply a sharpen convolution to enhance edges
  39162. */
  39163. sharpen: SharpenPostProcess;
  39164. private _sharpenEffect;
  39165. private bloom;
  39166. /**
  39167. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  39168. */
  39169. depthOfField: DepthOfFieldEffect;
  39170. /**
  39171. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  39172. */
  39173. fxaa: FxaaPostProcess;
  39174. /**
  39175. * Image post processing pass used to perform operations such as tone mapping or color grading.
  39176. */
  39177. imageProcessing: ImageProcessingPostProcess;
  39178. /**
  39179. * Chromatic aberration post process which will shift rgb colors in the image
  39180. */
  39181. chromaticAberration: ChromaticAberrationPostProcess;
  39182. private _chromaticAberrationEffect;
  39183. /**
  39184. * Grain post process which add noise to the image
  39185. */
  39186. grain: GrainPostProcess;
  39187. private _grainEffect;
  39188. /**
  39189. * Glow post process which adds a glow to emmisive areas of the image
  39190. */
  39191. private _glowLayer;
  39192. /**
  39193. * Animations which can be used to tweak settings over a period of time
  39194. */
  39195. animations: Animation[];
  39196. private _imageProcessingConfigurationObserver;
  39197. private _sharpenEnabled;
  39198. private _bloomEnabled;
  39199. private _depthOfFieldEnabled;
  39200. private _depthOfFieldBlurLevel;
  39201. private _fxaaEnabled;
  39202. private _imageProcessingEnabled;
  39203. private _defaultPipelineTextureType;
  39204. private _bloomScale;
  39205. private _chromaticAberrationEnabled;
  39206. private _grainEnabled;
  39207. private _buildAllowed;
  39208. /**
  39209. * Enable or disable the sharpen process from the pipeline
  39210. */
  39211. sharpenEnabled: boolean;
  39212. private _resizeObserver;
  39213. private _hardwareScaleLevel;
  39214. private _bloomKernel;
  39215. /**
  39216. * Specifies the size of the bloom blur kernel, relative to the final output size
  39217. */
  39218. bloomKernel: number;
  39219. /**
  39220. * Specifies the weight of the bloom in the final rendering
  39221. */
  39222. private _bloomWeight;
  39223. /**
  39224. * Specifies the luma threshold for the area that will be blurred by the bloom
  39225. */
  39226. private _bloomThreshold;
  39227. private _hdr;
  39228. /**
  39229. * The strength of the bloom.
  39230. */
  39231. bloomWeight: number;
  39232. /**
  39233. * The strength of the bloom.
  39234. */
  39235. bloomThreshold: number;
  39236. /**
  39237. * The scale of the bloom, lower value will provide better performance.
  39238. */
  39239. bloomScale: number;
  39240. /**
  39241. * Enable or disable the bloom from the pipeline
  39242. */
  39243. bloomEnabled: boolean;
  39244. private _rebuildBloom;
  39245. /**
  39246. * If the depth of field is enabled.
  39247. */
  39248. depthOfFieldEnabled: boolean;
  39249. /**
  39250. * Blur level of the depth of field effect. (Higher blur will effect performance)
  39251. */
  39252. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  39253. /**
  39254. * If the anti aliasing is enabled.
  39255. */
  39256. fxaaEnabled: boolean;
  39257. private _samples;
  39258. /**
  39259. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  39260. */
  39261. samples: number;
  39262. /**
  39263. * If image processing is enabled.
  39264. */
  39265. imageProcessingEnabled: boolean;
  39266. /**
  39267. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  39268. */
  39269. glowLayerEnabled: boolean;
  39270. /**
  39271. * Enable or disable the chromaticAberration process from the pipeline
  39272. */
  39273. chromaticAberrationEnabled: boolean;
  39274. /**
  39275. * Enable or disable the grain process from the pipeline
  39276. */
  39277. grainEnabled: boolean;
  39278. /**
  39279. * @constructor
  39280. * @param {string} name - The rendering pipeline name (default: "")
  39281. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  39282. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  39283. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  39284. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  39285. */
  39286. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  39287. /**
  39288. * Force the compilation of the entire pipeline.
  39289. */
  39290. prepare(): void;
  39291. private _hasCleared;
  39292. private _prevPostProcess;
  39293. private _prevPrevPostProcess;
  39294. private _setAutoClearAndTextureSharing;
  39295. private _buildPipeline;
  39296. private _disposePostProcesses;
  39297. /**
  39298. * Adds a camera to the pipeline
  39299. * @param camera the camera to be added
  39300. */
  39301. addCamera(camera: Camera): void;
  39302. /**
  39303. * Removes a camera from the pipeline
  39304. * @param camera the camera to remove
  39305. */
  39306. removeCamera(camera: Camera): void;
  39307. /**
  39308. * Dispose of the pipeline and stop all post processes
  39309. */
  39310. dispose(): void;
  39311. /**
  39312. * Serialize the rendering pipeline (Used when exporting)
  39313. * @returns the serialized object
  39314. */
  39315. serialize(): any;
  39316. /**
  39317. * Parse the serialized pipeline
  39318. * @param source Source pipeline.
  39319. * @param scene The scene to load the pipeline to.
  39320. * @param rootUrl The URL of the serialized pipeline.
  39321. * @returns An instantiated pipeline from the serialized object.
  39322. */
  39323. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. class LensRenderingPipeline extends PostProcessRenderPipeline {
  39328. /**
  39329. * The chromatic aberration PostProcess id in the pipeline
  39330. */
  39331. LensChromaticAberrationEffect: string;
  39332. /**
  39333. * The highlights enhancing PostProcess id in the pipeline
  39334. */
  39335. HighlightsEnhancingEffect: string;
  39336. /**
  39337. * The depth-of-field PostProcess id in the pipeline
  39338. */
  39339. LensDepthOfFieldEffect: string;
  39340. private _scene;
  39341. private _depthTexture;
  39342. private _grainTexture;
  39343. private _chromaticAberrationPostProcess;
  39344. private _highlightsPostProcess;
  39345. private _depthOfFieldPostProcess;
  39346. private _edgeBlur;
  39347. private _grainAmount;
  39348. private _chromaticAberration;
  39349. private _distortion;
  39350. private _highlightsGain;
  39351. private _highlightsThreshold;
  39352. private _dofDistance;
  39353. private _dofAperture;
  39354. private _dofDarken;
  39355. private _dofPentagon;
  39356. private _blurNoise;
  39357. /**
  39358. * @constructor
  39359. *
  39360. * Effect parameters are as follow:
  39361. * {
  39362. * chromatic_aberration: number; // from 0 to x (1 for realism)
  39363. * edge_blur: number; // from 0 to x (1 for realism)
  39364. * distortion: number; // from 0 to x (1 for realism)
  39365. * grain_amount: number; // from 0 to 1
  39366. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  39367. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  39368. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  39369. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  39370. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  39371. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  39372. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  39373. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  39374. * }
  39375. * Note: if an effect parameter is unset, effect is disabled
  39376. *
  39377. * @param {string} name - The rendering pipeline name
  39378. * @param {object} parameters - An object containing all parameters (see above)
  39379. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39380. * @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)
  39381. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39382. */
  39383. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  39384. setEdgeBlur(amount: number): void;
  39385. disableEdgeBlur(): void;
  39386. setGrainAmount(amount: number): void;
  39387. disableGrain(): void;
  39388. setChromaticAberration(amount: number): void;
  39389. disableChromaticAberration(): void;
  39390. setEdgeDistortion(amount: number): void;
  39391. disableEdgeDistortion(): void;
  39392. setFocusDistance(amount: number): void;
  39393. disableDepthOfField(): void;
  39394. setAperture(amount: number): void;
  39395. setDarkenOutOfFocus(amount: number): void;
  39396. enablePentagonBokeh(): void;
  39397. disablePentagonBokeh(): void;
  39398. enableNoiseBlur(): void;
  39399. disableNoiseBlur(): void;
  39400. setHighlightsGain(amount: number): void;
  39401. setHighlightsThreshold(amount: number): void;
  39402. disableHighlights(): void;
  39403. /**
  39404. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  39405. */
  39406. dispose(disableDepthRender?: boolean): void;
  39407. private _createChromaticAberrationPostProcess;
  39408. private _createHighlightsPostProcess;
  39409. private _createDepthOfFieldPostProcess;
  39410. private _createGrainTexture;
  39411. }
  39412. }
  39413. declare module BABYLON {
  39414. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  39415. /**
  39416. * The PassPostProcess id in the pipeline that contains the original scene color
  39417. */
  39418. SSAOOriginalSceneColorEffect: string;
  39419. /**
  39420. * The SSAO PostProcess id in the pipeline
  39421. */
  39422. SSAORenderEffect: string;
  39423. /**
  39424. * The horizontal blur PostProcess id in the pipeline
  39425. */
  39426. SSAOBlurHRenderEffect: string;
  39427. /**
  39428. * The vertical blur PostProcess id in the pipeline
  39429. */
  39430. SSAOBlurVRenderEffect: string;
  39431. /**
  39432. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39433. */
  39434. SSAOCombineRenderEffect: string;
  39435. /**
  39436. * The output strength of the SSAO post-process. Default value is 1.0.
  39437. */
  39438. totalStrength: number;
  39439. /**
  39440. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  39441. */
  39442. maxZ: number;
  39443. /**
  39444. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  39445. */
  39446. minZAspect: number;
  39447. private _samples;
  39448. /**
  39449. * Number of samples used for the SSAO calculations. Default value is 8
  39450. */
  39451. samples: number;
  39452. private _textureSamples;
  39453. /**
  39454. * Number of samples to use for antialiasing
  39455. */
  39456. textureSamples: number;
  39457. /**
  39458. * Ratio object used for SSAO ratio and blur ratio
  39459. */
  39460. private _ratio;
  39461. /**
  39462. * Dynamically generated sphere sampler.
  39463. */
  39464. private _sampleSphere;
  39465. /**
  39466. * Blur filter offsets
  39467. */
  39468. private _samplerOffsets;
  39469. /**
  39470. * Are we using bilateral blur ?
  39471. */
  39472. private _expensiveBlur;
  39473. expensiveBlur: boolean;
  39474. /**
  39475. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  39476. */
  39477. radius: number;
  39478. /**
  39479. * The base color of the SSAO post-process
  39480. * The final result is "base + ssao" between [0, 1]
  39481. */
  39482. base: number;
  39483. /**
  39484. * Support test.
  39485. */
  39486. static readonly IsSupported: boolean;
  39487. private _scene;
  39488. private _depthTexture;
  39489. private _normalTexture;
  39490. private _randomTexture;
  39491. private _originalColorPostProcess;
  39492. private _ssaoPostProcess;
  39493. private _blurHPostProcess;
  39494. private _blurVPostProcess;
  39495. private _ssaoCombinePostProcess;
  39496. private _firstUpdate;
  39497. /**
  39498. * @constructor
  39499. * @param {string} name - The rendering pipeline name
  39500. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39501. * @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 }
  39502. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39503. */
  39504. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39505. /**
  39506. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39507. */
  39508. dispose(disableGeometryBufferRenderer?: boolean): void;
  39509. private _createBlurPostProcess;
  39510. /** @hidden */
  39511. _rebuild(): void;
  39512. private _bits;
  39513. private _radicalInverse_VdC;
  39514. private _hammersley;
  39515. private _hemisphereSample_uniform;
  39516. private _generateHemisphere;
  39517. private _createSSAOPostProcess;
  39518. private _createSSAOCombinePostProcess;
  39519. private _createRandomTexture;
  39520. /**
  39521. * Serialize the rendering pipeline (Used when exporting)
  39522. * @returns the serialized object
  39523. */
  39524. serialize(): any;
  39525. /**
  39526. * Parse the serialized pipeline
  39527. * @param source Source pipeline.
  39528. * @param scene The scene to load the pipeline to.
  39529. * @param rootUrl The URL of the serialized pipeline.
  39530. * @returns An instantiated pipeline from the serialized object.
  39531. */
  39532. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  39533. }
  39534. }
  39535. declare module BABYLON {
  39536. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  39537. /**
  39538. * The PassPostProcess id in the pipeline that contains the original scene color
  39539. */
  39540. SSAOOriginalSceneColorEffect: string;
  39541. /**
  39542. * The SSAO PostProcess id in the pipeline
  39543. */
  39544. SSAORenderEffect: string;
  39545. /**
  39546. * The horizontal blur PostProcess id in the pipeline
  39547. */
  39548. SSAOBlurHRenderEffect: string;
  39549. /**
  39550. * The vertical blur PostProcess id in the pipeline
  39551. */
  39552. SSAOBlurVRenderEffect: string;
  39553. /**
  39554. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39555. */
  39556. SSAOCombineRenderEffect: string;
  39557. /**
  39558. * The output strength of the SSAO post-process. Default value is 1.0.
  39559. */
  39560. totalStrength: number;
  39561. /**
  39562. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  39563. */
  39564. radius: number;
  39565. /**
  39566. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  39567. * Must not be equal to fallOff and superior to fallOff.
  39568. * Default value is 0.975
  39569. */
  39570. area: number;
  39571. /**
  39572. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  39573. * Must not be equal to area and inferior to area.
  39574. * Default value is 0.0
  39575. */
  39576. fallOff: number;
  39577. /**
  39578. * The base color of the SSAO post-process
  39579. * The final result is "base + ssao" between [0, 1]
  39580. */
  39581. base: number;
  39582. private _scene;
  39583. private _depthTexture;
  39584. private _randomTexture;
  39585. private _originalColorPostProcess;
  39586. private _ssaoPostProcess;
  39587. private _blurHPostProcess;
  39588. private _blurVPostProcess;
  39589. private _ssaoCombinePostProcess;
  39590. private _firstUpdate;
  39591. /**
  39592. * @constructor
  39593. * @param {string} name - The rendering pipeline name
  39594. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39595. * @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 }
  39596. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39597. */
  39598. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39599. /**
  39600. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39601. */
  39602. dispose(disableDepthRender?: boolean): void;
  39603. private _createBlurPostProcess;
  39604. /** @hidden */
  39605. _rebuild(): void;
  39606. private _createSSAOPostProcess;
  39607. private _createSSAOCombinePostProcess;
  39608. private _createRandomTexture;
  39609. }
  39610. }
  39611. declare module BABYLON {
  39612. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39613. /**
  39614. * Public members
  39615. */
  39616. originalPostProcess: Nullable<PostProcess>;
  39617. downSampleX4PostProcess: Nullable<PostProcess>;
  39618. brightPassPostProcess: Nullable<PostProcess>;
  39619. blurHPostProcesses: PostProcess[];
  39620. blurVPostProcesses: PostProcess[];
  39621. textureAdderPostProcess: Nullable<PostProcess>;
  39622. volumetricLightPostProcess: Nullable<PostProcess>;
  39623. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  39624. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  39625. volumetricLightMergePostProces: Nullable<PostProcess>;
  39626. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  39627. luminancePostProcess: Nullable<PostProcess>;
  39628. luminanceDownSamplePostProcesses: PostProcess[];
  39629. hdrPostProcess: Nullable<PostProcess>;
  39630. textureAdderFinalPostProcess: Nullable<PostProcess>;
  39631. lensFlareFinalPostProcess: Nullable<PostProcess>;
  39632. hdrFinalPostProcess: Nullable<PostProcess>;
  39633. lensFlarePostProcess: Nullable<PostProcess>;
  39634. lensFlareComposePostProcess: Nullable<PostProcess>;
  39635. motionBlurPostProcess: Nullable<PostProcess>;
  39636. depthOfFieldPostProcess: Nullable<PostProcess>;
  39637. brightThreshold: number;
  39638. blurWidth: number;
  39639. horizontalBlur: boolean;
  39640. exposure: number;
  39641. lensTexture: Nullable<Texture>;
  39642. volumetricLightCoefficient: number;
  39643. volumetricLightPower: number;
  39644. volumetricLightBlurScale: number;
  39645. sourceLight: Nullable<SpotLight | DirectionalLight>;
  39646. hdrMinimumLuminance: number;
  39647. hdrDecreaseRate: number;
  39648. hdrIncreaseRate: number;
  39649. lensColorTexture: Nullable<Texture>;
  39650. lensFlareStrength: number;
  39651. lensFlareGhostDispersal: number;
  39652. lensFlareHaloWidth: number;
  39653. lensFlareDistortionStrength: number;
  39654. lensStarTexture: Nullable<Texture>;
  39655. lensFlareDirtTexture: Nullable<Texture>;
  39656. depthOfFieldDistance: number;
  39657. depthOfFieldBlurWidth: number;
  39658. motionStrength: number;
  39659. animations: Animation[];
  39660. /**
  39661. * Private members
  39662. */
  39663. private _scene;
  39664. private _currentDepthOfFieldSource;
  39665. private _basePostProcess;
  39666. private _hdrCurrentLuminance;
  39667. private _floatTextureType;
  39668. private _ratio;
  39669. private _bloomEnabled;
  39670. private _depthOfFieldEnabled;
  39671. private _vlsEnabled;
  39672. private _lensFlareEnabled;
  39673. private _hdrEnabled;
  39674. private _motionBlurEnabled;
  39675. private _motionBlurSamples;
  39676. private _volumetricLightStepsCount;
  39677. BloomEnabled: boolean;
  39678. DepthOfFieldEnabled: boolean;
  39679. LensFlareEnabled: boolean;
  39680. HDREnabled: boolean;
  39681. VLSEnabled: boolean;
  39682. MotionBlurEnabled: boolean;
  39683. volumetricLightStepsCount: number;
  39684. motionBlurSamples: number;
  39685. /**
  39686. * @constructor
  39687. * @param {string} name - The rendering pipeline name
  39688. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39689. * @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)
  39690. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  39691. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39692. */
  39693. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  39694. private _buildPipeline;
  39695. private _createDownSampleX4PostProcess;
  39696. private _createBrightPassPostProcess;
  39697. private _createBlurPostProcesses;
  39698. private _createTextureAdderPostProcess;
  39699. private _createVolumetricLightPostProcess;
  39700. private _createLuminancePostProcesses;
  39701. private _createHdrPostProcess;
  39702. private _createLensFlarePostProcess;
  39703. private _createDepthOfFieldPostProcess;
  39704. private _createMotionBlurPostProcess;
  39705. private _getDepthTexture;
  39706. private _disposePostProcesses;
  39707. /**
  39708. * Dispose of the pipeline and stop all post processes
  39709. */
  39710. dispose(): void;
  39711. /**
  39712. * Serialize the rendering pipeline (Used when exporting)
  39713. * @returns the serialized object
  39714. */
  39715. serialize(): any;
  39716. /**
  39717. * Parse the serialized pipeline
  39718. * @param source Source pipeline.
  39719. * @param scene The scene to load the pipeline to.
  39720. * @param rootUrl The URL of the serialized pipeline.
  39721. * @returns An instantiated pipeline from the serialized object.
  39722. */
  39723. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  39724. static LuminanceSteps: number;
  39725. }
  39726. }