babylon.d.ts 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. /**
  182. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. R16F: number;
  239. RG16F: number;
  240. RGB16F: number;
  241. RED: number;
  242. RG: number;
  243. R8: number;
  244. RG8: number;
  245. UNSIGNED_INT_24_8: number;
  246. DEPTH24_STENCIL8: number;
  247. drawBuffers(buffers: number[]): void;
  248. readBuffer(src: number): void;
  249. readonly COLOR_ATTACHMENT0: number;
  250. readonly COLOR_ATTACHMENT1: number;
  251. readonly COLOR_ATTACHMENT2: number;
  252. readonly COLOR_ATTACHMENT3: number;
  253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  254. ANY_SAMPLES_PASSED: number;
  255. QUERY_RESULT_AVAILABLE: number;
  256. QUERY_RESULT: number;
  257. }
  258. interface Document {
  259. mozCancelFullScreen(): void;
  260. msCancelFullScreen(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. fullscreen: boolean;
  264. mozPointerLockElement: HTMLElement;
  265. msPointerLockElement: HTMLElement;
  266. webkitPointerLockElement: HTMLElement;
  267. }
  268. interface HTMLCanvasElement {
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  284. }
  285. interface MouseEvent {
  286. mozMovementX: number;
  287. mozMovementY: number;
  288. webkitMovementX: number;
  289. webkitMovementY: number;
  290. msMovementX: number;
  291. msMovementY: number;
  292. }
  293. interface Navigator {
  294. mozGetVRDevices: (any: any) => any;
  295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. webkitGetGamepads(): Gamepad[];
  299. msGetGamepads(): Gamepad[];
  300. webkitGamepads(): Gamepad[];
  301. }
  302. interface HTMLVideoElement {
  303. mozSrcObject: any;
  304. }
  305. interface Screen {
  306. orientation: string;
  307. mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Node is the basic class for all scene objects (Mesh, Light Camera).
  333. */
  334. class Node implements IBehaviorAware<Node> {
  335. /**
  336. * Gets or sets the name of the node
  337. */
  338. name: string;
  339. /**
  340. * Gets or sets the id of the node
  341. */
  342. id: string;
  343. /**
  344. * Gets or sets the unique id of the node
  345. */
  346. uniqueId: number;
  347. /**
  348. * Gets or sets a string used to store user defined state for the node
  349. */
  350. state: string;
  351. /**
  352. * Gets or sets an object used to store user defined information for the node
  353. */
  354. metadata: any;
  355. /**
  356. * Gets or sets a boolean used to define if the node must be serialized
  357. */
  358. doNotSerialize: boolean;
  359. /** @hidden */
  360. _isDisposed: boolean;
  361. /**
  362. * Gets a list of Animations associated with the node
  363. */
  364. animations: Animation[];
  365. private _ranges;
  366. /**
  367. * Callback raised when the node is ready to be used
  368. */
  369. onReady: (node: Node) => void;
  370. private _isEnabled;
  371. private _isReady;
  372. /** @hidden */
  373. _currentRenderId: number;
  374. private _parentRenderId;
  375. protected _childRenderId: number;
  376. /** @hidden */
  377. _waitingParentId: Nullable<string>;
  378. private _scene;
  379. /** @hidden */
  380. _cache: any;
  381. private _parentNode;
  382. private _children;
  383. /**
  384. * Gets a boolean indicating if the node has been disposed
  385. * @returns true if the node was disposed
  386. */
  387. isDisposed(): boolean;
  388. /**
  389. * Gets or sets the parent of the node
  390. */
  391. parent: Nullable<Node>;
  392. private _animationPropertiesOverride;
  393. /**
  394. * Gets or sets the animation properties override
  395. */
  396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  397. /**
  398. * Gets a string idenfifying the name of the class
  399. * @returns "Node" string
  400. */
  401. getClassName(): string;
  402. /**
  403. * An event triggered when the mesh is disposed
  404. */
  405. onDisposeObservable: Observable<Node>;
  406. private _onDisposeObserver;
  407. /**
  408. * Sets a callback that will be raised when the node will be disposed
  409. */
  410. onDispose: () => void;
  411. /**
  412. * Creates a new Node
  413. * @param {string} name - the name and id to be given to this node
  414. * @param {BABYLON.Scene} the scene this node will be added to
  415. */
  416. constructor(name: string, scene?: Nullable<Scene>);
  417. /**
  418. * Gets the scene of the node
  419. * @returns a {BABYLON.Scene}
  420. */
  421. getScene(): Scene;
  422. /**
  423. * Gets the engine of the node
  424. * @returns a {BABYLON.Engine}
  425. */
  426. getEngine(): Engine;
  427. private _behaviors;
  428. /**
  429. * Attach a behavior to the node
  430. * @see http://doc.babylonjs.com/features/behaviour
  431. * @param behavior defines the behavior to attach
  432. * @returns the current Node
  433. */
  434. addBehavior(behavior: Behavior<Node>): Node;
  435. /**
  436. * Remove an attached behavior
  437. * @see http://doc.babylonjs.com/features/behaviour
  438. * @param behavior defines the behavior to attach
  439. * @returns the current Node
  440. */
  441. removeBehavior(behavior: Behavior<Node>): Node;
  442. /**
  443. * Gets the list of attached behaviors
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. */
  446. readonly behaviors: Behavior<Node>[];
  447. /**
  448. * Gets an attached behavior by name
  449. * @param name defines the name of the behavior to look for
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. * @returns null if behavior was not found else the requested behavior
  452. */
  453. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  454. /**
  455. * Returns the world matrix of the node
  456. * @returns a matrix containing the node's world matrix
  457. */
  458. getWorldMatrix(): Matrix;
  459. /** @hidden */
  460. _getWorldMatrixDeterminant(): number;
  461. /** @hidden */
  462. _initCache(): void;
  463. /** @hidden */
  464. updateCache(force?: boolean): void;
  465. /** @hidden */
  466. _updateCache(ignoreParentClass?: boolean): void;
  467. /** @hidden */
  468. _isSynchronized(): boolean;
  469. /** @hidden */
  470. _markSyncedWithParent(): void;
  471. /** @hidden */
  472. isSynchronizedWithParent(): boolean;
  473. /** @hidden */
  474. isSynchronized(updateCache?: boolean): boolean;
  475. /** @hidden */
  476. hasNewParent(update?: boolean): boolean;
  477. /**
  478. * Is this node ready to be used/rendered
  479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  480. * @return true if the node is ready
  481. */
  482. isReady(completeCheck?: boolean): boolean;
  483. /**
  484. * Is this node enabled?
  485. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  486. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  487. * @return whether this node (and its parent) is enabled
  488. */
  489. isEnabled(checkAncestors?: boolean): boolean;
  490. /**
  491. * Set the enabled state of this node
  492. * @param value defines the new enabled state
  493. */
  494. setEnabled(value: boolean): void;
  495. /**
  496. * Is this node a descendant of the given node?
  497. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  498. * @param ancestor defines the parent node to inspect
  499. * @returns a boolean indicating if this node is a descendant of the given node
  500. */
  501. isDescendantOf(ancestor: Node): boolean;
  502. /** @hidden */
  503. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  504. /**
  505. * Will return all nodes that have this node as ascendant
  506. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  507. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  508. * @return all children nodes of all types
  509. */
  510. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  511. /**
  512. * Get all child-meshes of this node
  513. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  514. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  515. * @returns an array of {BABYLON.AbstractMesh}
  516. */
  517. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  518. /**
  519. * Get all child-transformNodes of this node
  520. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  521. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  522. * @returns an array of {BABYLON.TransformNode}
  523. */
  524. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  525. /**
  526. * Get all direct children of this node
  527. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  528. * @returns an array of {BABYLON.Node}
  529. */
  530. getChildren(predicate?: (node: Node) => boolean): Node[];
  531. /** @hidden */
  532. _setReady(state: boolean): void;
  533. /**
  534. * Get an animation by name
  535. * @param name defines the name of the animation to look for
  536. * @returns null if not found else the requested animation
  537. */
  538. getAnimationByName(name: string): Nullable<Animation>;
  539. /**
  540. * Creates an animation range for this node
  541. * @param name defines the name of the range
  542. * @param from defines the starting key
  543. * @param to defines the end key
  544. */
  545. createAnimationRange(name: string, from: number, to: number): void;
  546. /**
  547. * Delete a specific animation range
  548. * @param name defines the name of the range to delete
  549. * @param deleteFrames defines if animation frames from the range must be deleted as well
  550. */
  551. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  552. /**
  553. * Get an animation range by name
  554. * @param name defines the name of the animation range to look for
  555. * @returns null if not found else the requested animation range
  556. */
  557. getAnimationRange(name: string): Nullable<AnimationRange>;
  558. /**
  559. * Will start the animation sequence
  560. * @param name defines the range frames for animation sequence
  561. * @param loop defines if the animation should loop (false by default)
  562. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  563. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  564. * @returns the object created for this animation. If range does not exist, it will return null
  565. */
  566. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  567. /**
  568. * Serialize animation ranges into a JSON compatible object
  569. * @returns serialization object
  570. */
  571. serializeAnimationRanges(): any;
  572. /**
  573. * Computes the world matrix of the node
  574. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  575. * @returns the world matrix
  576. */
  577. computeWorldMatrix(force?: boolean): Matrix;
  578. /**
  579. * Releases resources associated with this node.
  580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  582. */
  583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  584. /**
  585. * Parse animation range data from a serialization object and store them into a given node
  586. * @param node defines where to store the animation ranges
  587. * @param parsedNode defines the serialization object to read data from
  588. * @param scene defines the hosting scene
  589. */
  590. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  591. }
  592. }
  593. declare module BABYLON {
  594. /**
  595. * Define an interface for all classes that will hold resources
  596. */
  597. interface IDisposable {
  598. /**
  599. * Releases all held resources
  600. */
  601. dispose(): void;
  602. }
  603. /**
  604. * Interface used to let developers provide their own mesh selection mechanism
  605. */
  606. interface IActiveMeshCandidateProvider {
  607. /**
  608. * Return the list of active meshes
  609. * @param scene defines the current scene
  610. * @returns the list of active meshes
  611. */
  612. getMeshes(scene: Scene): AbstractMesh[];
  613. /**
  614. * Indicates if the meshes have been checked to make sure they are isEnabled()
  615. */
  616. readonly checksIsEnabled: boolean;
  617. }
  618. /**
  619. * This class is used by the onRenderingGroupObservable
  620. */
  621. class RenderingGroupInfo {
  622. /**
  623. * The Scene that being rendered
  624. */
  625. scene: Scene;
  626. /**
  627. * The camera currently used for the rendering pass
  628. */
  629. camera: Nullable<Camera>;
  630. /**
  631. * The ID of the renderingGroup being processed
  632. */
  633. renderingGroupId: number;
  634. /**
  635. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  636. */
  637. renderStage: number;
  638. /**
  639. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  640. * This stage will be fired no matter what
  641. */
  642. static STAGE_PRECLEAR: number;
  643. /**
  644. * Called before opaque object are rendered.
  645. * This stage will be fired only if there's 3D Opaque content to render
  646. */
  647. static STAGE_PREOPAQUE: number;
  648. /**
  649. * Called after the opaque objects are rendered and before the transparent ones
  650. * This stage will be fired only if there's 3D transparent content to render
  651. */
  652. static STAGE_PRETRANSPARENT: number;
  653. /**
  654. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  655. * This stage will be fired no matter what
  656. */
  657. static STAGE_POSTTRANSPARENT: number;
  658. }
  659. /**
  660. * Represents a scene to be rendered by the engine.
  661. * @see http://doc.babylonjs.com/features/scene
  662. */
  663. class Scene implements IAnimatable {
  664. private static _FOGMODE_NONE;
  665. private static _FOGMODE_EXP;
  666. private static _FOGMODE_EXP2;
  667. private static _FOGMODE_LINEAR;
  668. private static _uniqueIdCounter;
  669. /**
  670. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MinDeltaTime: number;
  674. /**
  675. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  677. */
  678. static MaxDeltaTime: number;
  679. /** The fog is deactivated */
  680. static readonly FOGMODE_NONE: number;
  681. /** The fog density is following an exponential function */
  682. static readonly FOGMODE_EXP: number;
  683. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  684. static readonly FOGMODE_EXP2: number;
  685. /** The fog density is following a linear function. */
  686. static readonly FOGMODE_LINEAR: number;
  687. /**
  688. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  689. */
  690. autoClear: boolean;
  691. /**
  692. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  693. */
  694. autoClearDepthAndStencil: boolean;
  695. /**
  696. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  697. */
  698. clearColor: Color4;
  699. /**
  700. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  701. */
  702. ambientColor: Color3;
  703. /** @hidden */
  704. _environmentBRDFTexture: BaseTexture;
  705. /** @hidden */
  706. protected _environmentTexture: BaseTexture;
  707. /**
  708. * Texture used in all pbr material as the reflection texture.
  709. * As in the majority of the scene they are the same (exception for multi room and so on),
  710. * this is easier to reference from here than from all the materials.
  711. */
  712. /**
  713. * Texture used in all pbr material as the reflection texture.
  714. * As in the majority of the scene they are the same (exception for multi room and so on),
  715. * this is easier to set here than in all the materials.
  716. */
  717. environmentTexture: BaseTexture;
  718. /** @hidden */
  719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  720. /**
  721. * Default image processing configuration used either in the rendering
  722. * Forward main pass or through the imageProcessingPostProcess if present.
  723. * As in the majority of the scene they are the same (exception for multi camera),
  724. * this is easier to reference from here than from all the materials and post process.
  725. *
  726. * No setter as we it is a shared configuration, you can set the values instead.
  727. */
  728. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  729. private _forceWireframe;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  732. */
  733. forceWireframe: boolean;
  734. private _forcePointsCloud;
  735. /**
  736. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  737. */
  738. forcePointsCloud: boolean;
  739. /**
  740. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  741. */
  742. forceShowBoundingBoxes: boolean;
  743. /**
  744. * Gets or sets the active clipplane
  745. */
  746. clipPlane: Nullable<Plane>;
  747. /**
  748. * Gets or sets a boolean indicating if animations are enabled
  749. */
  750. animationsEnabled: boolean;
  751. private _animationPropertiesOverride;
  752. /**
  753. * Gets or sets the animation properties override
  754. */
  755. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  756. /**
  757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  759. */
  760. useConstantAnimationDeltaTime: boolean;
  761. /**
  762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  763. * Please note that it requires to run a ray cast through the scene on every frame
  764. */
  765. constantlyUpdateMeshUnderPointer: boolean;
  766. /**
  767. * Defines the HTML cursor to use when hovering over interactive elements
  768. */
  769. hoverCursor: string;
  770. /**
  771. * Defines the HTML default cursor to use (empty by default)
  772. */
  773. defaultCursor: string;
  774. /**
  775. * This is used to call preventDefault() on pointer down
  776. * in order to block unwanted artifacts like system double clicks
  777. */
  778. preventDefaultOnPointerDown: boolean;
  779. /**
  780. * Gets or sets user defined metadata
  781. */
  782. metadata: any;
  783. /**
  784. * Gets the name of the plugin used to load this scene (null by default)
  785. */
  786. loadingPluginName: string;
  787. /**
  788. * Use this array to add regular expressions used to disable offline support for specific urls
  789. */
  790. disableOfflineSupportExceptionRules: RegExp[];
  791. private _spritePredicate;
  792. /**
  793. * An event triggered when the scene is disposed.
  794. */
  795. onDisposeObservable: Observable<Scene>;
  796. private _onDisposeObserver;
  797. /** Sets a function to be executed when this scene is disposed. */
  798. onDispose: () => void;
  799. /**
  800. * An event triggered before rendering the scene (right after animations and physics)
  801. */
  802. onBeforeRenderObservable: Observable<Scene>;
  803. private _onBeforeRenderObserver;
  804. /** Sets a function to be executed before rendering this scene */
  805. beforeRender: Nullable<() => void>;
  806. /**
  807. * An event triggered after rendering the scene
  808. */
  809. onAfterRenderObservable: Observable<Scene>;
  810. private _onAfterRenderObserver;
  811. /** Sets a function to be executed after rendering this scene */
  812. afterRender: Nullable<() => void>;
  813. /**
  814. * An event triggered before animating the scene
  815. */
  816. onBeforeAnimationsObservable: Observable<Scene>;
  817. /**
  818. * An event triggered after animations processing
  819. */
  820. onAfterAnimationsObservable: Observable<Scene>;
  821. /**
  822. * An event triggered before draw calls are ready to be sent
  823. */
  824. onBeforeDrawPhaseObservable: Observable<Scene>;
  825. /**
  826. * An event triggered after draw calls have been sent
  827. */
  828. onAfterDrawPhaseObservable: Observable<Scene>;
  829. /**
  830. * An event triggered when physic simulation is about to be run
  831. */
  832. onBeforePhysicsObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when physic simulation has been done
  835. */
  836. onAfterPhysicsObservable: Observable<Scene>;
  837. /**
  838. * An event triggered when the scene is ready
  839. */
  840. onReadyObservable: Observable<Scene>;
  841. /**
  842. * An event triggered before rendering a camera
  843. */
  844. onBeforeCameraRenderObservable: Observable<Camera>;
  845. private _onBeforeCameraRenderObserver;
  846. /** Sets a function to be executed before rendering a camera*/
  847. beforeCameraRender: () => void;
  848. /**
  849. * An event triggered after rendering a camera
  850. */
  851. onAfterCameraRenderObservable: Observable<Camera>;
  852. private _onAfterCameraRenderObserver;
  853. /** Sets a function to be executed after rendering a camera*/
  854. afterCameraRender: () => void;
  855. /**
  856. * An event triggered when active meshes evaluation is about to start
  857. */
  858. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when active meshes evaluation is done
  861. */
  862. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  866. */
  867. onBeforeParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when particles rendering is done
  870. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  871. */
  872. onAfterParticlesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is about to start
  875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  876. */
  877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when sprites rendering is done
  880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  881. */
  882. onAfterSpritesRenderingObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  885. */
  886. onDataLoadedObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when a camera is created
  889. */
  890. onNewCameraAddedObservable: Observable<Camera>;
  891. /**
  892. * An event triggered when a camera is removed
  893. */
  894. onCameraRemovedObservable: Observable<Camera>;
  895. /**
  896. * An event triggered when a light is created
  897. */
  898. onNewLightAddedObservable: Observable<Light>;
  899. /**
  900. * An event triggered when a light is removed
  901. */
  902. onLightRemovedObservable: Observable<Light>;
  903. /**
  904. * An event triggered when a geometry is created
  905. */
  906. onNewGeometryAddedObservable: Observable<Geometry>;
  907. /**
  908. * An event triggered when a geometry is removed
  909. */
  910. onGeometryRemovedObservable: Observable<Geometry>;
  911. /**
  912. * An event triggered when a transform node is created
  913. */
  914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  915. /**
  916. * An event triggered when a transform node is removed
  917. */
  918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  919. /**
  920. * An event triggered when a mesh is created
  921. */
  922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  923. /**
  924. * An event triggered when a mesh is removed
  925. */
  926. onMeshRemovedObservable: Observable<AbstractMesh>;
  927. /**
  928. * An event triggered when render targets are about to be rendered
  929. * Can happen multiple times per frame.
  930. */
  931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered when render targets were rendered.
  934. * Can happen multiple times per frame.
  935. */
  936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  937. /**
  938. * An event triggered before calculating deterministic simulation step
  939. */
  940. onBeforeStepObservable: Observable<Scene>;
  941. /**
  942. * An event triggered after calculating deterministic simulation step
  943. */
  944. onAfterStepObservable: Observable<Scene>;
  945. /**
  946. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  948. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  949. */
  950. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  951. /**
  952. * Gets a list of Animations associated with the scene
  953. */
  954. animations: Animation[];
  955. private _registeredForLateAnimationBindings;
  956. /**
  957. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  958. */
  959. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  960. /**
  961. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  962. */
  963. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  964. /**
  965. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  966. */
  967. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  968. private _onPointerMove;
  969. private _onPointerDown;
  970. private _onPointerUp;
  971. /** Deprecated. Use onPointerObservable instead */
  972. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  973. /** Deprecated. Use onPointerObservable instead */
  974. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  975. /** Deprecated. Use onPointerObservable instead */
  976. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  977. /** Deprecated. Use onPointerObservable instead */
  978. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  979. private _gamepadManager;
  980. /**
  981. * Gets the gamepad manager associated with the scene
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  983. */
  984. readonly gamepadManager: GamepadManager;
  985. /**
  986. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  987. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  988. */
  989. onPrePointerObservable: Observable<PointerInfoPre>;
  990. /**
  991. * Observable event triggered each time an input event is received from the rendering canvas
  992. */
  993. onPointerObservable: Observable<PointerInfo>;
  994. /**
  995. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  996. */
  997. readonly unTranslatedPointer: Vector2;
  998. /** The distance in pixel that you have to move to prevent some events */
  999. static DragMovementThreshold: number;
  1000. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1001. static LongPressDelay: number;
  1002. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1003. static DoubleClickDelay: number;
  1004. /** If you need to check double click without raising a single click at first click, enable this flag */
  1005. static ExclusiveDoubleClickMode: boolean;
  1006. private _initClickEvent;
  1007. private _initActionManager;
  1008. private _delayedSimpleClick;
  1009. private _delayedSimpleClickTimeout;
  1010. private _previousDelayedSimpleClickTimeout;
  1011. private _meshPickProceed;
  1012. private _previousButtonPressed;
  1013. private _currentPickResult;
  1014. private _previousPickResult;
  1015. private _totalPointersPressed;
  1016. private _doubleClickOccured;
  1017. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1018. cameraToUseForPointers: Nullable<Camera>;
  1019. private _pointerX;
  1020. private _pointerY;
  1021. private _unTranslatedPointerX;
  1022. private _unTranslatedPointerY;
  1023. private _startingPointerPosition;
  1024. private _previousStartingPointerPosition;
  1025. private _startingPointerTime;
  1026. private _previousStartingPointerTime;
  1027. private _pointerCaptures;
  1028. private _timeAccumulator;
  1029. private _currentStepId;
  1030. private _currentInternalStep;
  1031. /** @hidden */
  1032. _mirroredCameraPosition: Nullable<Vector3>;
  1033. /**
  1034. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1035. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1036. */
  1037. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1038. /**
  1039. * Observable event triggered each time an keyboard event is received from the hosting window
  1040. */
  1041. onKeyboardObservable: Observable<KeyboardInfo>;
  1042. private _onKeyDown;
  1043. private _onKeyUp;
  1044. private _onCanvasFocusObserver;
  1045. private _onCanvasBlurObserver;
  1046. private _useRightHandedSystem;
  1047. /**
  1048. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1049. */
  1050. useRightHandedSystem: boolean;
  1051. /**
  1052. * Sets the step Id used by deterministic lock step
  1053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1054. * @param newStepId defines the step Id
  1055. */
  1056. setStepId(newStepId: number): void;
  1057. /**
  1058. * Gets the step Id used by deterministic lock step
  1059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1060. * @returns the step Id
  1061. */
  1062. getStepId(): number;
  1063. /**
  1064. * Gets the internal step used by deterministic lock step
  1065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1066. * @returns the internal step
  1067. */
  1068. getInternalStep(): number;
  1069. private _fogEnabled;
  1070. /**
  1071. * Gets or sets a boolean indicating if fog is enabled on this scene
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogEnabled: boolean;
  1075. private _fogMode;
  1076. /**
  1077. * Gets or sets the fog mode to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogMode: number;
  1081. /**
  1082. * Gets or sets the fog color to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogColor: Color3;
  1086. /**
  1087. * Gets or sets the fog density to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogDensity: number;
  1091. /**
  1092. * Gets or sets the fog start distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogStart: number;
  1096. /**
  1097. * Gets or sets the fog end distance to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. */
  1100. fogEnd: number;
  1101. private _shadowsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1104. */
  1105. shadowsEnabled: boolean;
  1106. private _lightsEnabled;
  1107. /**
  1108. * Gets or sets a boolean indicating if lights are enabled on this scene
  1109. */
  1110. lightsEnabled: boolean;
  1111. /**
  1112. * All of the lights added to this scene
  1113. * @see http://doc.babylonjs.com/babylon101/lights
  1114. */
  1115. lights: Light[];
  1116. /** All of the cameras added to this scene.
  1117. * @see http://doc.babylonjs.com/babylon101/cameras
  1118. */
  1119. cameras: Camera[];
  1120. /** All of the active cameras added to this scene. */
  1121. activeCameras: Camera[];
  1122. /** The current active camera */
  1123. activeCamera: Nullable<Camera>;
  1124. /**
  1125. * All of the tranform nodes added to this scene
  1126. * @see http://doc.babylonjs.com/how_to/transformnode
  1127. */
  1128. transformNodes: TransformNode[];
  1129. /**
  1130. * All of the (abstract) meshes added to this scene
  1131. */
  1132. meshes: AbstractMesh[];
  1133. /**
  1134. * All of the animation groups added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/group
  1136. */
  1137. animationGroups: AnimationGroup[];
  1138. private _geometries;
  1139. /**
  1140. * All of the materials added to this scene
  1141. * @see http://doc.babylonjs.com/babylon101/materials
  1142. */
  1143. materials: Material[];
  1144. /**
  1145. * All of the multi-materials added to this scene
  1146. * @see http://doc.babylonjs.com/how_to/multi_materials
  1147. */
  1148. multiMaterials: MultiMaterial[];
  1149. private _defaultMaterial;
  1150. /** The default material used on meshes when no material is affected */
  1151. /** The default material used on meshes when no material is affected */
  1152. defaultMaterial: Material;
  1153. private _texturesEnabled;
  1154. /**
  1155. * Gets or sets a boolean indicating if textures are enabled on this scene
  1156. */
  1157. texturesEnabled: boolean;
  1158. /**
  1159. * All of the textures added to this scene
  1160. */
  1161. textures: BaseTexture[];
  1162. /**
  1163. * Gets or sets a boolean indicating if particles are enabled on this scene
  1164. */
  1165. particlesEnabled: boolean;
  1166. /**
  1167. * All of the particle systems added to this scene
  1168. * @see http://doc.babylonjs.com/babylon101/particles
  1169. */
  1170. particleSystems: IParticleSystem[];
  1171. /**
  1172. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1173. */
  1174. spritesEnabled: boolean;
  1175. /**
  1176. * All of the sprite managers added to this scene
  1177. * @see http://doc.babylonjs.com/babylon101/sprites
  1178. */
  1179. spriteManagers: SpriteManager[];
  1180. /**
  1181. * The list of layers (background and foreground) of the scene
  1182. */
  1183. layers: Layer[];
  1184. /**
  1185. * The list of effect layers (highlights/glow) added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1187. * @see http://doc.babylonjs.com/how_to/glow_layer
  1188. */
  1189. effectLayers: EffectLayer[];
  1190. private _skeletonsEnabled;
  1191. /**
  1192. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1193. */
  1194. skeletonsEnabled: boolean;
  1195. /**
  1196. * The list of skeletons added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1198. */
  1199. skeletons: Skeleton[];
  1200. /**
  1201. * The list of morph target managers added to the scene
  1202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1203. */
  1204. morphTargetManagers: MorphTargetManager[];
  1205. /**
  1206. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1207. */
  1208. lensFlaresEnabled: boolean;
  1209. /**
  1210. * The list of lens flare system added to the scene
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1212. */
  1213. lensFlareSystems: LensFlareSystem[];
  1214. /**
  1215. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1217. */
  1218. collisionsEnabled: boolean;
  1219. private _workerCollisions;
  1220. /** @hidden */
  1221. collisionCoordinator: ICollisionCoordinator;
  1222. /**
  1223. * Defines the gravity applied to this scene (used only for collisions)
  1224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1225. */
  1226. gravity: Vector3;
  1227. /**
  1228. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1229. */
  1230. postProcessesEnabled: boolean;
  1231. /**
  1232. * The list of postprocesses added to the scene
  1233. */
  1234. postProcesses: PostProcess[];
  1235. /**
  1236. * Gets the current postprocess manager
  1237. */
  1238. postProcessManager: PostProcessManager;
  1239. private _postProcessRenderPipelineManager;
  1240. /**
  1241. * Gets the postprocess render pipeline manager
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1243. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1244. */
  1245. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * The list of reflection probes added to the scene
  1274. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1275. */
  1276. reflectionProbes: ReflectionProbe[];
  1277. /**
  1278. * @hidden
  1279. */
  1280. database: Database;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. /** @hidden */
  1287. _actionManagers: ActionManager[];
  1288. private _meshesForIntersections;
  1289. /**
  1290. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1291. */
  1292. proceduralTexturesEnabled: boolean;
  1293. /**
  1294. * The list of procedural textures added to the scene
  1295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1296. */
  1297. proceduralTextures: ProceduralTexture[];
  1298. private _mainSoundTrack;
  1299. /**
  1300. * The list of sound tracks added to the scene
  1301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1302. */
  1303. soundTracks: SoundTrack[];
  1304. private _audioEnabled;
  1305. private _headphone;
  1306. /**
  1307. * Gets the main soundtrack associated with the scene
  1308. */
  1309. readonly mainSoundTrack: SoundTrack;
  1310. /**
  1311. * Gets or sets the VRExperienceHelper attached to the scene
  1312. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1313. * @ignorenaming
  1314. */
  1315. VRHelper: VRExperienceHelper;
  1316. /**
  1317. * Gets or sets the simplification queue attached to the scene
  1318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1319. */
  1320. simplificationQueue: SimplificationQueue;
  1321. private _engine;
  1322. private _totalVertices;
  1323. /** @hidden */
  1324. _activeIndices: PerfCounter;
  1325. /** @hidden */
  1326. _activeParticles: PerfCounter;
  1327. /** @hidden */
  1328. _activeBones: PerfCounter;
  1329. private _animationRatio;
  1330. private _animationTimeLast;
  1331. private _animationTime;
  1332. /**
  1333. * Gets or sets a general scale for animation speed
  1334. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1335. */
  1336. animationTimeScale: number;
  1337. /** @hidden */
  1338. _cachedMaterial: Nullable<Material>;
  1339. /** @hidden */
  1340. _cachedEffect: Nullable<Effect>;
  1341. /** @hidden */
  1342. _cachedVisibility: Nullable<number>;
  1343. private _renderId;
  1344. private _executeWhenReadyTimeoutId;
  1345. private _intermediateRendering;
  1346. private _viewUpdateFlag;
  1347. private _projectionUpdateFlag;
  1348. private _alternateViewUpdateFlag;
  1349. private _alternateProjectionUpdateFlag;
  1350. /** @hidden */
  1351. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1352. private _activeRequests;
  1353. private _pendingData;
  1354. private _isDisposed;
  1355. /**
  1356. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1357. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1358. */
  1359. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1360. private _activeMeshes;
  1361. private _processedMaterials;
  1362. private _renderTargets;
  1363. /** @hidden */
  1364. _activeParticleSystems: SmartArray<IParticleSystem>;
  1365. private _activeSkeletons;
  1366. private _softwareSkinnedMeshes;
  1367. private _renderingManager;
  1368. private _physicsEngine;
  1369. /** @hidden */
  1370. _activeAnimatables: Animatable[];
  1371. private _transformMatrix;
  1372. private _sceneUbo;
  1373. private _alternateSceneUbo;
  1374. private _pickWithRayInverseMatrix;
  1375. private _boundingBoxRenderer;
  1376. private _outlineRenderer;
  1377. private _viewMatrix;
  1378. private _projectionMatrix;
  1379. private _alternateViewMatrix;
  1380. private _alternateProjectionMatrix;
  1381. private _alternateTransformMatrix;
  1382. private _useAlternateCameraConfiguration;
  1383. private _alternateRendering;
  1384. /** @hidden */
  1385. _forcedViewPosition: Nullable<Vector3>;
  1386. /** @hidden */
  1387. readonly _isAlternateRenderingEnabled: boolean;
  1388. private _frustumPlanes;
  1389. /**
  1390. * Gets the list of frustum planes (built from the active camera)
  1391. */
  1392. readonly frustumPlanes: Plane[];
  1393. /**
  1394. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1395. * This is useful if there are more lights that the maximum simulteanous authorized
  1396. */
  1397. requireLightSorting: boolean;
  1398. private _selectionOctree;
  1399. private _pointerOverMesh;
  1400. private _pointerOverSprite;
  1401. private _debugLayer;
  1402. private _depthRenderer;
  1403. private _geometryBufferRenderer;
  1404. /**
  1405. * Gets the current geometry buffer associated to the scene.
  1406. */
  1407. /**
  1408. * Sets the current geometry buffer for the scene.
  1409. */
  1410. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1411. private _pickedDownMesh;
  1412. private _pickedUpMesh;
  1413. private _pickedDownSprite;
  1414. private _externalData;
  1415. private _uid;
  1416. /**
  1417. * Creates a new Scene
  1418. * @param engine defines the engine to use to render this scene
  1419. */
  1420. constructor(engine: Engine);
  1421. /**
  1422. * Gets the debug layer (aka Inspector) associated with the scene
  1423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1424. */
  1425. readonly debugLayer: DebugLayer;
  1426. /**
  1427. * Gets a boolean indicating if collisions are processed on a web worker
  1428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1429. */
  1430. workerCollisions: boolean;
  1431. /**
  1432. * Gets the octree used to boost mesh selection (picking)
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1434. */
  1435. readonly selectionOctree: Octree<AbstractMesh>;
  1436. /**
  1437. * Gets the mesh that is currently under the pointer
  1438. */
  1439. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1440. /**
  1441. * Gets the current on-screen X position of the pointer
  1442. */
  1443. readonly pointerX: number;
  1444. /**
  1445. * Gets the current on-screen Y position of the pointer
  1446. */
  1447. readonly pointerY: number;
  1448. /**
  1449. * Gets the cached material (ie. the latest rendered one)
  1450. * @returns the cached material
  1451. */
  1452. getCachedMaterial(): Nullable<Material>;
  1453. /**
  1454. * Gets the cached effect (ie. the latest rendered one)
  1455. * @returns the cached effect
  1456. */
  1457. getCachedEffect(): Nullable<Effect>;
  1458. /**
  1459. * Gets the cached visibility state (ie. the latest rendered one)
  1460. * @returns the cached visibility state
  1461. */
  1462. getCachedVisibility(): Nullable<number>;
  1463. /**
  1464. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1465. * @param material defines the current material
  1466. * @param effect defines the current effect
  1467. * @param visibility defines the current visibility state
  1468. * @returns true if one parameter is not cached
  1469. */
  1470. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1471. /**
  1472. * Gets the bounding box renderer associated with the scene
  1473. * @returns a BoundingBoxRenderer
  1474. */
  1475. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1476. /**
  1477. * Gets the outline renderer associated with the scene
  1478. * @returns a OutlineRenderer
  1479. */
  1480. getOutlineRenderer(): OutlineRenderer;
  1481. /**
  1482. * Gets the engine associated with the scene
  1483. * @returns an Engine
  1484. */
  1485. getEngine(): Engine;
  1486. /**
  1487. * Gets the total number of vertices rendered per frame
  1488. * @returns the total number of vertices rendered per frame
  1489. */
  1490. getTotalVertices(): number;
  1491. /**
  1492. * Gets the performance counter for total vertices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalVerticesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1498. * @returns the total number of active indices rendered per frame
  1499. */
  1500. getActiveIndices(): number;
  1501. /**
  1502. * Gets the performance counter for active indices
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active particles rendered per frame
  1508. * @returns the total number of active particles rendered per frame
  1509. */
  1510. getActiveParticles(): number;
  1511. /**
  1512. * Gets the performance counter for active particles
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeParticlesPerfCounter: PerfCounter;
  1516. /**
  1517. * Gets the total number of active bones rendered per frame
  1518. * @returns the total number of active bones rendered per frame
  1519. */
  1520. getActiveBones(): number;
  1521. /**
  1522. * Gets the performance counter for active bones
  1523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1524. */
  1525. readonly activeBonesPerfCounter: PerfCounter;
  1526. /** @hidden */
  1527. getInterFramePerfCounter(): number;
  1528. /** @hidden */
  1529. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getLastFrameDuration(): number;
  1532. /** @hidden */
  1533. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1534. /** @hidden */
  1535. getEvaluateActiveMeshesDuration(): number;
  1536. /** @hidden */
  1537. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1538. /**
  1539. * Gets the array of active meshes
  1540. * @returns an array of AbstractMesh
  1541. */
  1542. getActiveMeshes(): SmartArray<AbstractMesh>;
  1543. /** @hidden */
  1544. getRenderTargetsDuration(): number;
  1545. /** @hidden */
  1546. getRenderDuration(): number;
  1547. /** @hidden */
  1548. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1549. /** @hidden */
  1550. getParticlesDuration(): number;
  1551. /** @hidden */
  1552. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1553. /** @hidden */
  1554. getSpritesDuration(): number;
  1555. /** @hidden */
  1556. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1557. /**
  1558. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1559. * @returns a number
  1560. */
  1561. getAnimationRatio(): number;
  1562. /**
  1563. * Gets an unique Id for the current frame
  1564. * @returns a number
  1565. */
  1566. getRenderId(): number;
  1567. /** Call this function if you want to manually increment the render Id*/
  1568. incrementRenderId(): void;
  1569. private _updatePointerPosition(evt);
  1570. private _createUbo();
  1571. private _createAlternateUbo();
  1572. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1573. private _setRayOnPointerInfo(pointerInfo);
  1574. /**
  1575. * Use this method to simulate a pointer move on a mesh
  1576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1579. * @returns the current scene
  1580. */
  1581. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerMove(pickResult, evt);
  1583. private _checkPrePointerObservable(pickResult, evt, type);
  1584. /**
  1585. * Use this method to simulate a pointer down on a mesh
  1586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1589. * @returns the current scene
  1590. */
  1591. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1592. private _processPointerDown(pickResult, evt);
  1593. /**
  1594. * Use this method to simulate a pointer up on a mesh
  1595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1598. * @returns the current scene
  1599. */
  1600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1601. private _processPointerUp(pickResult, evt, clickInfo);
  1602. /**
  1603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1605. * @returns true if the pointer was captured
  1606. */
  1607. isPointerCaptured(pointerId?: number): boolean;
  1608. /**
  1609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1610. * @param attachUp defines if you want to attach events to pointerup
  1611. * @param attachDown defines if you want to attach events to pointerdown
  1612. * @param attachMove defines if you want to attach events to pointermove
  1613. */
  1614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1615. /** Detaches all event handlers*/
  1616. detachControl(): void;
  1617. /**
  1618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1619. * Delay loaded resources are not taking in account
  1620. * @return true if all required resources are ready
  1621. */
  1622. isReady(): boolean;
  1623. /** Resets all cached information relative to material (including effect and visibility) */
  1624. resetCachedMaterial(): void;
  1625. /**
  1626. * Registers a function to be called before every frame render
  1627. * @param func defines the function to register
  1628. */
  1629. registerBeforeRender(func: () => void): void;
  1630. /**
  1631. * Unregisters a function called before every frame render
  1632. * @param func defines the function to unregister
  1633. */
  1634. unregisterBeforeRender(func: () => void): void;
  1635. /**
  1636. * Registers a function to be called after every frame render
  1637. * @param func defines the function to register
  1638. */
  1639. registerAfterRender(func: () => void): void;
  1640. /**
  1641. * Unregisters a function called after every frame render
  1642. * @param func defines the function to unregister
  1643. */
  1644. unregisterAfterRender(func: () => void): void;
  1645. private _executeOnceBeforeRender(func);
  1646. /**
  1647. * The provided function will run before render once and will be disposed afterwards.
  1648. * A timeout delay can be provided so that the function will be executed in N ms.
  1649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1650. * @param func The function to be executed.
  1651. * @param timeout optional delay in ms
  1652. */
  1653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1654. /** @hidden */
  1655. _addPendingData(data: any): void;
  1656. /** @hidden */
  1657. _removePendingData(data: any): void;
  1658. /**
  1659. * Returns the number of items waiting to be loaded
  1660. * @returns the number of items waiting to be loaded
  1661. */
  1662. getWaitingItemsCount(): number;
  1663. /**
  1664. * Returns a boolean indicating if the scene is still loading data
  1665. */
  1666. readonly isLoading: boolean;
  1667. /**
  1668. * Registers a function to be executed when the scene is ready
  1669. * @param {Function} func - the function to be executed
  1670. */
  1671. executeWhenReady(func: () => void): void;
  1672. /**
  1673. * Returns a promise that resolves when the scene is ready
  1674. * @returns A promise that resolves when the scene is ready
  1675. */
  1676. whenReadyAsync(): Promise<void>;
  1677. /** @hidden */
  1678. _checkIsReady(): void;
  1679. /**
  1680. * Will start the animation sequence of a given target
  1681. * @param target defines the target
  1682. * @param from defines from which frame should animation start
  1683. * @param to defines until which frame should animation run.
  1684. * @param weight defines the weight to apply to the animation (1.0 by default)
  1685. * @param loop defines if the animation loops
  1686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1687. * @param onAnimationEnd defines the function to be executed when the animation ends
  1688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1689. * @returns the animatable object created for this animation
  1690. */
  1691. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1692. /**
  1693. * Will start the animation sequence of a given target
  1694. * @param target defines the target
  1695. * @param from defines from which frame should animation start
  1696. * @param to defines until which frame should animation run.
  1697. * @param loop defines if the animation loops
  1698. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1699. * @param onAnimationEnd defines the function to be executed when the animation ends
  1700. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1701. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1702. * @returns the animatable object created for this animation
  1703. */
  1704. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1705. /**
  1706. * Begin a new animation on a given node
  1707. * @param target defines the target where the animation will take place
  1708. * @param animations defines the list of animations to start
  1709. * @param from defines the initial value
  1710. * @param to defines the final value
  1711. * @param loop defines if you want animation to loop (off by default)
  1712. * @param speedRatio defines the speed ratio to apply to all animations
  1713. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1714. * @returns the list of created animatables
  1715. */
  1716. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1717. /**
  1718. * Begin a new animation on a given node and its hierarchy
  1719. * @param target defines the root node where the animation will take place
  1720. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1721. * @param animations defines the list of animations to start
  1722. * @param from defines the initial value
  1723. * @param to defines the final value
  1724. * @param loop defines if you want animation to loop (off by default)
  1725. * @param speedRatio defines the speed ratio to apply to all animations
  1726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1727. * @returns the list of animatables created for all nodes
  1728. */
  1729. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1730. /**
  1731. * Gets the animatable associated with a specific target
  1732. * @param target defines the target of the animatable
  1733. * @returns the required animatable if found
  1734. */
  1735. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1736. /**
  1737. * Gets all animatables associated with a given target
  1738. * @param target defines the target to look animatables for
  1739. * @returns an array of Animatables
  1740. */
  1741. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1742. /**
  1743. * Gets all animatable attached to the scene
  1744. */
  1745. readonly animatables: Animatable[];
  1746. /**
  1747. * Will stop the animation of the given target
  1748. * @param target - the target
  1749. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1750. */
  1751. stopAnimation(target: any, animationName?: string): void;
  1752. /**
  1753. * Stops and removes all animations that have been applied to the scene
  1754. */
  1755. stopAllAnimations(): void;
  1756. private _animate();
  1757. /** @hidden */
  1758. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1759. private _processLateAnimationBindingsForMatrices(holder);
  1760. private _processLateAnimationBindingsForQuaternions(holder);
  1761. private _processLateAnimationBindings();
  1762. /** @hidden */
  1763. _switchToAlternateCameraConfiguration(active: boolean): void;
  1764. /**
  1765. * Gets the current view matrix
  1766. * @returns a Matrix
  1767. */
  1768. getViewMatrix(): Matrix;
  1769. /**
  1770. * Gets the current projection matrix
  1771. * @returns a Matrix
  1772. */
  1773. getProjectionMatrix(): Matrix;
  1774. /**
  1775. * Gets the current transform matrix
  1776. * @returns a Matrix made of View * Projection
  1777. */
  1778. getTransformMatrix(): Matrix;
  1779. /**
  1780. * Sets the current transform matrix
  1781. * @param view defines the View matrix to use
  1782. * @param projection defines the Projection matrix to use
  1783. */
  1784. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1785. /** @hidden */
  1786. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1787. /**
  1788. * Gets the uniform buffer used to store scene data
  1789. * @returns a UniformBuffer
  1790. */
  1791. getSceneUniformBuffer(): UniformBuffer;
  1792. /**
  1793. * Gets an unique (relatively to the current scene) Id
  1794. * @returns an unique number for the scene
  1795. */
  1796. getUniqueId(): number;
  1797. /**
  1798. * Add a mesh to the list of scene's meshes
  1799. * @param newMesh defines the mesh to add
  1800. * @param recursive if all child meshes should also be added to the scene
  1801. */
  1802. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1803. /**
  1804. * Remove a mesh for the list of scene's meshes
  1805. * @param toRemove defines the mesh to remove
  1806. * @param recursive if all child meshes should also be removed from the scene
  1807. * @returns the index where the mesh was in the mesh list
  1808. */
  1809. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1810. /**
  1811. * Add a transform node to the list of scene's transform nodes
  1812. * @param newTransformNode defines the transform node to add
  1813. */
  1814. addTransformNode(newTransformNode: TransformNode): void;
  1815. /**
  1816. * Remove a transform node for the list of scene's transform nodes
  1817. * @param toRemove defines the transform node to remove
  1818. * @returns the index where the transform node was in the transform node list
  1819. */
  1820. removeTransformNode(toRemove: TransformNode): number;
  1821. /**
  1822. * Remove a skeleton for the list of scene's skeletons
  1823. * @param toRemove defines the skeleton to remove
  1824. * @returns the index where the skeleton was in the skeleton list
  1825. */
  1826. removeSkeleton(toRemove: Skeleton): number;
  1827. /**
  1828. * Remove a morph target for the list of scene's morph targets
  1829. * @param toRemove defines the morph target to remove
  1830. * @returns the index where the morph target was in the morph target list
  1831. */
  1832. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1833. /**
  1834. * Remove a light for the list of scene's lights
  1835. * @param toRemove defines the light to remove
  1836. * @returns the index where the light was in the light list
  1837. */
  1838. removeLight(toRemove: Light): number;
  1839. /**
  1840. * Remove a camera for the list of scene's cameras
  1841. * @param toRemove defines the camera to remove
  1842. * @returns the index where the camera was in the camera list
  1843. */
  1844. removeCamera(toRemove: Camera): number;
  1845. /**
  1846. * Remove a particle system for the list of scene's particle systems
  1847. * @param toRemove defines the particle system to remove
  1848. * @returns the index where the particle system was in the particle system list
  1849. */
  1850. removeParticleSystem(toRemove: IParticleSystem): number;
  1851. /**
  1852. * Remove a animation for the list of scene's animations
  1853. * @param toRemove defines the animation to remove
  1854. * @returns the index where the animation was in the animation list
  1855. */
  1856. removeAnimation(toRemove: Animation): number;
  1857. /**
  1858. * Removes the given animation group from this scene.
  1859. * @param toRemove The animation group to remove
  1860. * @returns The index of the removed animation group
  1861. */
  1862. removeAnimationGroup(toRemove: AnimationGroup): number;
  1863. /**
  1864. * Removes the given multi-material from this scene.
  1865. * @param toRemove The multi-material to remove
  1866. * @returns The index of the removed multi-material
  1867. */
  1868. removeMultiMaterial(toRemove: MultiMaterial): number;
  1869. /**
  1870. * Removes the given material from this scene.
  1871. * @param toRemove The material to remove
  1872. * @returns The index of the removed material
  1873. */
  1874. removeMaterial(toRemove: Material): number;
  1875. /**
  1876. * Removes the given lens flare system from this scene.
  1877. * @param toRemove The lens flare system to remove
  1878. * @returns The index of the removed lens flare system
  1879. */
  1880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1881. /**
  1882. * Removes the given action manager from this scene.
  1883. * @param toRemove The action manager to remove
  1884. * @returns The index of the removed action manager
  1885. */
  1886. removeActionManager(toRemove: ActionManager): number;
  1887. /**
  1888. * Removes the given effect layer from this scene.
  1889. * @param toRemove defines the effect layer to remove
  1890. * @returns the index of the removed effect layer
  1891. */
  1892. removeEffectLayer(toRemove: EffectLayer): number;
  1893. /**
  1894. * Removes the given texture from this scene.
  1895. * @param toRemove The texture to remove
  1896. * @returns The index of the removed texture
  1897. */
  1898. removeTexture(toRemove: BaseTexture): number;
  1899. /**
  1900. * Adds the given light to this scene
  1901. * @param newLight The light to add
  1902. */
  1903. addLight(newLight: Light): void;
  1904. /**
  1905. * Sorts the list list based on light priorities
  1906. */
  1907. sortLightsByPriority(): void;
  1908. /**
  1909. * Adds the given camera to this scene
  1910. * @param newCamera The camera to add
  1911. */
  1912. addCamera(newCamera: Camera): void;
  1913. /**
  1914. * Adds the given skeleton to this scene
  1915. * @param newSkeleton The skeleton to add
  1916. */
  1917. addSkeleton(newSkeleton: Skeleton): void;
  1918. /**
  1919. * Adds the given particle system to this scene
  1920. * @param newParticleSystem The particle system to add
  1921. */
  1922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1923. /**
  1924. * Adds the given animation to this scene
  1925. * @param newAnimation The animation to add
  1926. */
  1927. addAnimation(newAnimation: Animation): void;
  1928. /**
  1929. * Adds the given animation group to this scene.
  1930. * @param newAnimationGroup The animation group to add
  1931. */
  1932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1933. /**
  1934. * Adds the given multi-material to this scene
  1935. * @param newMultiMaterial The multi-material to add
  1936. */
  1937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1938. /**
  1939. * Adds the given material to this scene
  1940. * @param newMaterial The material to add
  1941. */
  1942. addMaterial(newMaterial: Material): void;
  1943. /**
  1944. * Adds the given morph target to this scene
  1945. * @param newMorphTargetManager The morph target to add
  1946. */
  1947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1948. /**
  1949. * Adds the given geometry to this scene
  1950. * @param newGeometry The geometry to add
  1951. */
  1952. addGeometry(newGeometry: Geometry): void;
  1953. /**
  1954. * Adds the given lens flare system to this scene
  1955. * @param newLensFlareSystem The lens flare system to add
  1956. */
  1957. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1958. /**
  1959. * Adds the given effect layer to this scene
  1960. * @param newEffectLayer defines the effect layer to add
  1961. */
  1962. addEffectLayer(newEffectLayer: EffectLayer): void;
  1963. /**
  1964. * Adds the given action manager to this scene
  1965. * @param newActionManager The action manager to add
  1966. */
  1967. addActionManager(newActionManager: ActionManager): void;
  1968. /**
  1969. * Adds the given texture to this scene.
  1970. * @param newTexture The texture to add
  1971. */
  1972. addTexture(newTexture: BaseTexture): void;
  1973. /**
  1974. * Switch active camera
  1975. * @param newCamera defines the new active camera
  1976. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1977. */
  1978. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1979. /**
  1980. * sets the active camera of the scene using its ID
  1981. * @param id defines the camera's ID
  1982. * @return the new active camera or null if none found.
  1983. */
  1984. setActiveCameraByID(id: string): Nullable<Camera>;
  1985. /**
  1986. * sets the active camera of the scene using its name
  1987. * @param name defines the camera's name
  1988. * @returns the new active camera or null if none found.
  1989. */
  1990. setActiveCameraByName(name: string): Nullable<Camera>;
  1991. /**
  1992. * get an animation group using its name
  1993. * @param name defines the material's name
  1994. * @return the animation group or null if none found.
  1995. */
  1996. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1997. /**
  1998. * get a material using its id
  1999. * @param id defines the material's ID
  2000. * @return the material or null if none found.
  2001. */
  2002. getMaterialByID(id: string): Nullable<Material>;
  2003. /**
  2004. * Gets a material using its name
  2005. * @param name defines the material's name
  2006. * @return the material or null if none found.
  2007. */
  2008. getMaterialByName(name: string): Nullable<Material>;
  2009. /**
  2010. * Gets a lens flare system using its name
  2011. * @param name defines the name to look for
  2012. * @returns the lens flare system or null if not found
  2013. */
  2014. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2015. /**
  2016. * Gets a lens flare system using its id
  2017. * @param id defines the id to look for
  2018. * @returns the lens flare system or null if not found
  2019. */
  2020. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2021. /**
  2022. * Gets a camera using its id
  2023. * @param id defines the id to look for
  2024. * @returns the camera or null if not found
  2025. */
  2026. getCameraByID(id: string): Nullable<Camera>;
  2027. /**
  2028. * Gets a camera using its unique id
  2029. * @param uniqueId defines the unique id to look for
  2030. * @returns the camera or null if not found
  2031. */
  2032. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2033. /**
  2034. * Gets a camera using its name
  2035. * @param name defines the camera's name
  2036. * @return the camera or null if none found.
  2037. */
  2038. getCameraByName(name: string): Nullable<Camera>;
  2039. /**
  2040. * Gets a bone using its id
  2041. * @param id defines the bone's id
  2042. * @return the bone or null if not found
  2043. */
  2044. getBoneByID(id: string): Nullable<Bone>;
  2045. /**
  2046. * Gets a bone using its id
  2047. * @param name defines the bone's name
  2048. * @return the bone or null if not found
  2049. */
  2050. getBoneByName(name: string): Nullable<Bone>;
  2051. /**
  2052. * Gets a light node using its name
  2053. * @param name defines the the light's name
  2054. * @return the light or null if none found.
  2055. */
  2056. getLightByName(name: string): Nullable<Light>;
  2057. /**
  2058. * Gets a light node using its id
  2059. * @param id defines the light's id
  2060. * @return the light or null if none found.
  2061. */
  2062. getLightByID(id: string): Nullable<Light>;
  2063. /**
  2064. * Gets a light node using its scene-generated unique ID
  2065. * @param uniqueId defines the light's unique id
  2066. * @return the light or null if none found.
  2067. */
  2068. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2069. /**
  2070. * Gets a particle system by id
  2071. * @param id defines the particle system id
  2072. * @return the corresponding system or null if none found
  2073. */
  2074. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2075. /**
  2076. * Gets a geometry using its ID
  2077. * @param id defines the geometry's id
  2078. * @return the geometry or null if none found.
  2079. */
  2080. getGeometryByID(id: string): Nullable<Geometry>;
  2081. /**
  2082. * Add a new geometry to this scene
  2083. * @param geometry defines the geometry to be added to the scene.
  2084. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2085. * @return a boolean defining if the geometry was added or not
  2086. */
  2087. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2088. /**
  2089. * Removes an existing geometry
  2090. * @param geometry defines the geometry to be removed from the scene
  2091. * @return a boolean defining if the geometry was removed or not
  2092. */
  2093. removeGeometry(geometry: Geometry): boolean;
  2094. /**
  2095. * Gets the list of geometries attached to the scene
  2096. * @returns an array of Geometry
  2097. */
  2098. getGeometries(): Geometry[];
  2099. /**
  2100. * Gets the first added mesh found of a given ID
  2101. * @param id defines the id to search for
  2102. * @return the mesh found or null if not found at all
  2103. */
  2104. getMeshByID(id: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a list of meshes using their id
  2107. * @param id defines the id to search for
  2108. * @returns a list of meshes
  2109. */
  2110. getMeshesByID(id: string): Array<AbstractMesh>;
  2111. /**
  2112. * Gets the first added transform node found of a given ID
  2113. * @param id defines the id to search for
  2114. * @return the found transform node or null if not found at all.
  2115. */
  2116. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2117. /**
  2118. * Gets a list of transform nodes using their id
  2119. * @param id defines the id to search for
  2120. * @returns a list of transform nodes
  2121. */
  2122. getTransformNodesByID(id: string): Array<TransformNode>;
  2123. /**
  2124. * Gets a mesh with its auto-generated unique id
  2125. * @param uniqueId defines the unique id to search for
  2126. * @return the found mesh or null if not found at all.
  2127. */
  2128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2129. /**
  2130. * Gets a the last added mesh using a given id
  2131. * @param id defines the id to search for
  2132. * @return the found mesh or null if not found at all.
  2133. */
  2134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2135. /**
  2136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2137. * @param id defines the id to search for
  2138. * @return the found node or null if not found at all
  2139. */
  2140. getLastEntryByID(id: string): Nullable<Node>;
  2141. /**
  2142. * Gets a node (Mesh, Camera, Light) using a given id
  2143. * @param id defines the id to search for
  2144. * @return the found node or null if not found at all
  2145. */
  2146. getNodeByID(id: string): Nullable<Node>;
  2147. /**
  2148. * Gets a node (Mesh, Camera, Light) using a given name
  2149. * @param name defines the name to search for
  2150. * @return the found node or null if not found at all.
  2151. */
  2152. getNodeByName(name: string): Nullable<Node>;
  2153. /**
  2154. * Gets a mesh using a given name
  2155. * @param name defines the name to search for
  2156. * @return the found mesh or null if not found at all.
  2157. */
  2158. getMeshByName(name: string): Nullable<AbstractMesh>;
  2159. /**
  2160. * Gets a transform node using a given name
  2161. * @param name defines the name to search for
  2162. * @return the found transform node or null if not found at all.
  2163. */
  2164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2165. /**
  2166. * Gets a sound using a given name
  2167. * @param name defines the name to search for
  2168. * @return the found sound or null if not found at all.
  2169. */
  2170. getSoundByName(name: string): Nullable<Sound>;
  2171. /**
  2172. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2173. * @param id defines the id to search for
  2174. * @return the found skeleton or null if not found at all.
  2175. */
  2176. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2177. /**
  2178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2179. * @param id defines the id to search for
  2180. * @return the found skeleton or null if not found at all.
  2181. */
  2182. getSkeletonById(id: string): Nullable<Skeleton>;
  2183. /**
  2184. * Gets a skeleton using a given name
  2185. * @param name defines the name to search for
  2186. * @return the found skeleton or null if not found at all.
  2187. */
  2188. getSkeletonByName(name: string): Nullable<Skeleton>;
  2189. /**
  2190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2191. * @param id defines the id to search for
  2192. * @return the found morph target manager or null if not found at all.
  2193. */
  2194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2195. /**
  2196. * Gets a boolean indicating if the given mesh is active
  2197. * @param mesh defines the mesh to look for
  2198. * @returns true if the mesh is in the active list
  2199. */
  2200. isActiveMesh(mesh: AbstractMesh): boolean;
  2201. /**
  2202. * Return a the first highlight layer of the scene with a given name.
  2203. * @param name The name of the highlight layer to look for.
  2204. * @return The highlight layer if found otherwise null.
  2205. */
  2206. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2207. /**
  2208. * Return a the first highlight layer of the scene with a given name.
  2209. * @param name The name of the highlight layer to look for.
  2210. * @return The highlight layer if found otherwise null.
  2211. */
  2212. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2213. /**
  2214. * Return a unique id as a string which can serve as an identifier for the scene
  2215. */
  2216. readonly uid: string;
  2217. /**
  2218. * Add an externaly attached data from its key.
  2219. * This method call will fail and return false, if such key already exists.
  2220. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2221. * @param key the unique key that identifies the data
  2222. * @param data the data object to associate to the key for this Engine instance
  2223. * @return true if no such key were already present and the data was added successfully, false otherwise
  2224. */
  2225. addExternalData<T>(key: string, data: T): boolean;
  2226. /**
  2227. * Get an externaly attached data from its key
  2228. * @param key the unique key that identifies the data
  2229. * @return the associated data, if present (can be null), or undefined if not present
  2230. */
  2231. getExternalData<T>(key: string): Nullable<T>;
  2232. /**
  2233. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2234. * @param key the unique key that identifies the data
  2235. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2236. * @return the associated data, can be null if the factory returned null.
  2237. */
  2238. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2239. /**
  2240. * Remove an externaly attached data from the Engine instance
  2241. * @param key the unique key that identifies the data
  2242. * @return true if the data was successfully removed, false if it doesn't exist
  2243. */
  2244. removeExternalData(key: string): boolean;
  2245. private _evaluateSubMesh(subMesh, mesh);
  2246. /**
  2247. * Clear the processed materials smart array preventing retention point in material dispose.
  2248. */
  2249. freeProcessedMaterials(): void;
  2250. /**
  2251. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2252. */
  2253. freeActiveMeshes(): void;
  2254. /**
  2255. * Clear the info related to rendering groups preventing retention points during dispose.
  2256. */
  2257. freeRenderingGroups(): void;
  2258. /** @hidden */
  2259. _isInIntermediateRendering(): boolean;
  2260. private _activeMeshCandidateProvider;
  2261. /**
  2262. * Defines the current active mesh candidate provider
  2263. * @param provider defines the provider to use
  2264. */
  2265. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2266. /**
  2267. * Gets the current active mesh candidate provider
  2268. * @returns the current active mesh candidate provider
  2269. */
  2270. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2271. private _activeMeshesFrozen;
  2272. /**
  2273. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2274. * @returns the current scene
  2275. */
  2276. freezeActiveMeshes(): Scene;
  2277. /**
  2278. * Use this function to restart evaluating active meshes on every frame
  2279. * @returns the current scene
  2280. */
  2281. unfreezeActiveMeshes(): Scene;
  2282. private _evaluateActiveMeshes();
  2283. private _activeMesh(sourceMesh, mesh);
  2284. /**
  2285. * Update the transform matrix to update from the current active camera
  2286. * @param force defines a boolean used to force the update even if cache is up to date
  2287. */
  2288. updateTransformMatrix(force?: boolean): void;
  2289. /**
  2290. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2291. * @param alternateCamera defines the camera to use
  2292. */
  2293. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2294. private _renderForCamera(camera, rigParent?);
  2295. private _processSubCameras(camera);
  2296. private _checkIntersections();
  2297. /**
  2298. * Render the scene
  2299. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2300. */
  2301. render(updateCameras?: boolean): void;
  2302. private _updateAudioParameters();
  2303. /**
  2304. * Gets or sets if audio support is enabled
  2305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2306. */
  2307. audioEnabled: boolean;
  2308. private _disableAudio();
  2309. private _enableAudio();
  2310. /**
  2311. * Gets or sets if audio will be output to headphones
  2312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2313. */
  2314. headphone: boolean;
  2315. private _switchAudioModeForHeadphones();
  2316. private _switchAudioModeForNormalSpeakers();
  2317. /**
  2318. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2319. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2320. * @returns the created depth renderer
  2321. */
  2322. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2323. /**
  2324. * Disables a depth renderer for a given camera
  2325. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2326. */
  2327. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2328. /**
  2329. * Enables a GeometryBufferRender and associates it with the scene
  2330. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2331. * @returns the GeometryBufferRenderer
  2332. */
  2333. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2334. /**
  2335. * Disables the GeometryBufferRender associated with the scene
  2336. */
  2337. disableGeometryBufferRenderer(): void;
  2338. /**
  2339. * Freeze all materials
  2340. * A frozen material will not be updatable but should be faster to render
  2341. */
  2342. freezeMaterials(): void;
  2343. /**
  2344. * Unfreeze all materials
  2345. * A frozen material will not be updatable but should be faster to render
  2346. */
  2347. unfreezeMaterials(): void;
  2348. /**
  2349. * Releases all held ressources
  2350. */
  2351. dispose(): void;
  2352. /**
  2353. * Gets if the scene is already disposed
  2354. */
  2355. readonly isDisposed: boolean;
  2356. /**
  2357. * Releases sounds & soundtracks
  2358. */
  2359. disposeSounds(): void;
  2360. /**
  2361. * Call this function to reduce memory footprint of the scene.
  2362. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2363. */
  2364. clearCachedVertexData(): void;
  2365. /**
  2366. * This function will remove the local cached buffer data from texture.
  2367. * It will save memory but will prevent the texture from being rebuilt
  2368. */
  2369. cleanCachedTextureBuffer(): void;
  2370. /**
  2371. * Get the world extend vectors with an optional filter
  2372. *
  2373. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2374. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2375. */
  2376. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2377. min: Vector3;
  2378. max: Vector3;
  2379. };
  2380. /**
  2381. * Creates or updates the octree used to boost selection (picking)
  2382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2383. * @param maxCapacity defines the maximum capacity per leaf
  2384. * @param maxDepth defines the maximum depth of the octree
  2385. * @returns an octree of AbstractMesh
  2386. */
  2387. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2388. /**
  2389. * Creates a ray that can be used to pick in the scene
  2390. * @param x defines the x coordinate of the origin (on-screen)
  2391. * @param y defines the y coordinate of the origin (on-screen)
  2392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2393. * @param camera defines the camera to use for the picking
  2394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2395. * @returns a Ray
  2396. */
  2397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2398. /**
  2399. * Creates a ray that can be used to pick in the scene
  2400. * @param x defines the x coordinate of the origin (on-screen)
  2401. * @param y defines the y coordinate of the origin (on-screen)
  2402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2403. * @param result defines the ray where to store the picking ray
  2404. * @param camera defines the camera to use for the picking
  2405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2406. * @returns the current scene
  2407. */
  2408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2409. /**
  2410. * Creates a ray that can be used to pick in the scene
  2411. * @param x defines the x coordinate of the origin (on-screen)
  2412. * @param y defines the y coordinate of the origin (on-screen)
  2413. * @param camera defines the camera to use for the picking
  2414. * @returns a Ray
  2415. */
  2416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2417. /**
  2418. * Creates a ray that can be used to pick in the scene
  2419. * @param x defines the x coordinate of the origin (on-screen)
  2420. * @param y defines the y coordinate of the origin (on-screen)
  2421. * @param result defines the ray where to store the picking ray
  2422. * @param camera defines the camera to use for the picking
  2423. * @returns the current scene
  2424. */
  2425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2426. private _internalPick(rayFunction, predicate?, fastCheck?);
  2427. private _internalMultiPick(rayFunction, predicate?);
  2428. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2429. private _tempPickingRay;
  2430. /** Launch a ray to try to pick a mesh in the scene
  2431. * @param x position on screen
  2432. * @param y position on screen
  2433. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2435. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2436. * @returns a PickingInfo
  2437. */
  2438. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2439. /** Launch a ray to try to pick a sprite in the scene
  2440. * @param x position on screen
  2441. * @param y position on screen
  2442. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  2443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2445. * @returns a PickingInfo
  2446. */
  2447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2448. private _cachedRayForTransform;
  2449. /** Use the given ray to pick a mesh in the scene
  2450. * @param ray The ray to use to pick meshes
  2451. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  2452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2453. * @returns a PickingInfo
  2454. */
  2455. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2456. /**
  2457. * Launch a ray to try to pick a mesh in the scene
  2458. * @param x X position on screen
  2459. * @param y Y position on screen
  2460. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2461. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2462. * @returns an array of PickingInfo
  2463. */
  2464. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2465. /**
  2466. * Launch a ray to try to pick a mesh in the scene
  2467. * @param ray Ray to use
  2468. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2469. * @returns an array of PickingInfo
  2470. */
  2471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2472. /**
  2473. * Force the value of meshUnderPointer
  2474. * @param mesh defines the mesh to use
  2475. */
  2476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2477. /**
  2478. * Gets the mesh under the pointer
  2479. * @returns a Mesh or null if no mesh is under the pointer
  2480. */
  2481. getPointerOverMesh(): Nullable<AbstractMesh>;
  2482. /**
  2483. * Force the sprite under the pointer
  2484. * @param sprite defines the sprite to use
  2485. */
  2486. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2487. /**
  2488. * Gets the sprite under the pointer
  2489. * @returns a Sprite or null if no sprite is under the pointer
  2490. */
  2491. getPointerOverSprite(): Nullable<Sprite>;
  2492. /**
  2493. * Gets the current physics engine
  2494. * @returns a PhysicsEngine or null if none attached
  2495. */
  2496. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2497. /**
  2498. * Enables physics to the current scene
  2499. * @param gravity defines the scene's gravity for the physics engine
  2500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2501. * @return a boolean indicating if the physics engine was initialized
  2502. */
  2503. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2504. /**
  2505. * Disables and disposes the physics engine associated with the scene
  2506. */
  2507. disablePhysicsEngine(): void;
  2508. /**
  2509. * Gets a boolean indicating if there is an active physics engine
  2510. * @returns a boolean indicating if there is an active physics engine
  2511. */
  2512. isPhysicsEnabled(): boolean;
  2513. /**
  2514. * Deletes a physics compound impostor
  2515. * @param compound defines the compound to delete
  2516. */
  2517. deleteCompoundImpostor(compound: any): void;
  2518. /** @hidden */
  2519. _rebuildGeometries(): void;
  2520. /** @hidden */
  2521. _rebuildTextures(): void;
  2522. /**
  2523. * Creates a default light for the scene.
  2524. * @param replace Whether to replace the existing lights in the scene.
  2525. */
  2526. createDefaultLight(replace?: boolean): void;
  2527. /**
  2528. * Creates a default camera for the scene.
  2529. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2530. * @param replace Whether to replace the existing active camera in the scene.
  2531. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2532. */
  2533. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2534. /**
  2535. * Creates a default camera and a default light
  2536. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2537. * @param replace defines if the camera and/or light will replace the existing ones
  2538. * @param attachCameraControls defines if attachControl will be called on the new camera
  2539. */
  2540. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2541. /**
  2542. * Creates a new sky box
  2543. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2544. * @param environmentTexture defines the texture to use as environment texture
  2545. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2546. * @param scale defines the overall scale of the skybox
  2547. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2548. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2549. * @returns a new mesh holding the sky box
  2550. */
  2551. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2552. /**
  2553. * Creates a new environment
  2554. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2555. * @param options defines the options you can use to configure the environment
  2556. * @returns the new EnvironmentHelper
  2557. */
  2558. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2559. /**
  2560. * Creates a new VREXperienceHelper
  2561. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2562. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2563. * @returns a new VREXperienceHelper
  2564. */
  2565. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2566. private _getByTags(list, tagsQuery, forEach?);
  2567. /**
  2568. * Get a list of meshes by tags
  2569. * @param tagsQuery defines the tags query to use
  2570. * @param forEach defines a predicate used to filter results
  2571. * @returns an array of Mesh
  2572. */
  2573. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2574. /**
  2575. * Get a list of cameras by tags
  2576. * @param tagsQuery defines the tags query to use
  2577. * @param forEach defines a predicate used to filter results
  2578. * @returns an array of Camera
  2579. */
  2580. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2581. /**
  2582. * Get a list of lights by tags
  2583. * @param tagsQuery defines the tags query to use
  2584. * @param forEach defines a predicate used to filter results
  2585. * @returns an array of Light
  2586. */
  2587. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2588. /**
  2589. * Get a list of materials by tags
  2590. * @param tagsQuery defines the tags query to use
  2591. * @param forEach defines a predicate used to filter results
  2592. * @returns an array of Material
  2593. */
  2594. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2595. /**
  2596. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2597. * This allowed control for front to back rendering or reversly depending of the special needs.
  2598. *
  2599. * @param renderingGroupId The rendering group id corresponding to its index
  2600. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2601. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2602. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2603. */
  2604. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2605. /**
  2606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2607. *
  2608. * @param renderingGroupId The rendering group id corresponding to its index
  2609. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2610. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2611. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2612. */
  2613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2614. /**
  2615. * Will flag all materials as dirty to trigger new shader compilation
  2616. * @param flag defines the flag used to specify which material part must be marked as dirty
  2617. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2618. */
  2619. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2620. /** @hidden */
  2621. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2622. /** @hidden */
  2623. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2624. }
  2625. }
  2626. declare module BABYLON {
  2627. type Nullable<T> = T | null;
  2628. type float = number;
  2629. type double = number;
  2630. type int = number;
  2631. type FloatArray = number[] | Float32Array;
  2632. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2633. /**
  2634. * Alias for types that can be used by a Buffer or VertexBuffer.
  2635. */
  2636. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2637. }
  2638. declare module BABYLON {
  2639. /**
  2640. * The action to be carried out following a trigger
  2641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2642. */
  2643. class Action {
  2644. /** the trigger, with or without parameters, for the action */
  2645. triggerOptions: any;
  2646. /**
  2647. * Trigger for the action
  2648. */
  2649. trigger: number;
  2650. /**
  2651. * Internal only - manager for action
  2652. * @hidden
  2653. */
  2654. _actionManager: ActionManager;
  2655. private _nextActiveAction;
  2656. private _child;
  2657. private _condition?;
  2658. private _triggerParameter;
  2659. /**
  2660. * An event triggered prior to action being executed.
  2661. */
  2662. onBeforeExecuteObservable: Observable<Action>;
  2663. /**
  2664. * Creates a new Action
  2665. * @param triggerOptions the trigger, with or without parameters, for the action
  2666. * @param condition an optional determinant of action
  2667. */
  2668. constructor(
  2669. /** the trigger, with or without parameters, for the action */
  2670. triggerOptions: any, condition?: Condition);
  2671. /**
  2672. * Internal only
  2673. * @hidden
  2674. */
  2675. _prepare(): void;
  2676. /**
  2677. * Gets the trigger parameters
  2678. * @returns the trigger parameters
  2679. */
  2680. getTriggerParameter(): any;
  2681. /**
  2682. * Internal only - executes current action event
  2683. * @hidden
  2684. */
  2685. _executeCurrent(evt?: ActionEvent): void;
  2686. /**
  2687. * Execute placeholder for child classes
  2688. * @param evt optional action event
  2689. */
  2690. execute(evt?: ActionEvent): void;
  2691. /**
  2692. * Skips to next active action
  2693. */
  2694. skipToNextActiveAction(): void;
  2695. /**
  2696. * Adds action to chain of actions, may be a DoNothingAction
  2697. * @param action defines the next action to execute
  2698. * @returns The action passed in
  2699. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2700. */
  2701. then(action: Action): Action;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getProperty(propertyPath: string): string;
  2707. /**
  2708. * Internal only
  2709. * @hidden
  2710. */
  2711. _getEffectiveTarget(target: any, propertyPath: string): any;
  2712. /**
  2713. * Serialize placeholder for child classes
  2714. * @param parent of child
  2715. * @returns the serialized object
  2716. */
  2717. serialize(parent: any): any;
  2718. /**
  2719. * Internal only called by serialize
  2720. * @hidden
  2721. */
  2722. protected _serialize(serializedAction: any, parent?: any): any;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _SerializeValueAsString: (value: any) => string;
  2728. /**
  2729. * Internal only
  2730. * @hidden
  2731. */
  2732. static _GetTargetProperty: (target: Scene | Node) => {
  2733. name: string;
  2734. targetType: string;
  2735. value: string;
  2736. };
  2737. }
  2738. }
  2739. declare module BABYLON {
  2740. /**
  2741. * ActionEvent is the event being sent when an action is triggered.
  2742. */
  2743. class ActionEvent {
  2744. /** The mesh or sprite that triggered the action */
  2745. source: any;
  2746. /** The X mouse cursor position at the time of the event */
  2747. pointerX: number;
  2748. /** The Y mouse cursor position at the time of the event */
  2749. pointerY: number;
  2750. /** The mesh that is currently pointed at (can be null) */
  2751. meshUnderPointer: Nullable<AbstractMesh>;
  2752. /** the original (browser) event that triggered the ActionEvent */
  2753. sourceEvent: any;
  2754. /** additional data for the event */
  2755. additionalData: any;
  2756. /**
  2757. * Creates a new ActionEvent
  2758. * @param source The mesh or sprite that triggered the action
  2759. * @param pointerX The X mouse cursor position at the time of the event
  2760. * @param pointerY The Y mouse cursor position at the time of the event
  2761. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2762. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2763. * @param additionalData additional data for the event
  2764. */
  2765. constructor(
  2766. /** The mesh or sprite that triggered the action */
  2767. source: any,
  2768. /** The X mouse cursor position at the time of the event */
  2769. pointerX: number,
  2770. /** The Y mouse cursor position at the time of the event */
  2771. pointerY: number,
  2772. /** The mesh that is currently pointed at (can be null) */
  2773. meshUnderPointer: Nullable<AbstractMesh>,
  2774. /** the original (browser) event that triggered the ActionEvent */
  2775. sourceEvent?: any,
  2776. /** additional data for the event */
  2777. additionalData?: any);
  2778. /**
  2779. * Helper function to auto-create an ActionEvent from a source mesh.
  2780. * @param source The source mesh that triggered the event
  2781. * @param evt The original (browser) event
  2782. * @param additionalData additional data for the event
  2783. * @returns the new ActionEvent
  2784. */
  2785. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2786. /**
  2787. * Helper function to auto-create an ActionEvent from a source sprite
  2788. * @param source The source sprite that triggered the event
  2789. * @param scene Scene associated with the sprite
  2790. * @param evt The original (browser) event
  2791. * @param additionalData additional data for the event
  2792. * @returns the new ActionEvent
  2793. */
  2794. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2795. /**
  2796. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2797. * @param scene the scene where the event occurred
  2798. * @param evt The original (browser) event
  2799. * @returns the new ActionEvent
  2800. */
  2801. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2802. /**
  2803. * Helper function to auto-create an ActionEvent from a primitive
  2804. * @param prim defines the target primitive
  2805. * @param pointerPos defines the pointer position
  2806. * @param evt The original (browser) event
  2807. * @param additionalData additional data for the event
  2808. * @returns the new ActionEvent
  2809. */
  2810. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2811. }
  2812. /**
  2813. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2814. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2816. */
  2817. class ActionManager {
  2818. private static _NothingTrigger;
  2819. private static _OnPickTrigger;
  2820. private static _OnLeftPickTrigger;
  2821. private static _OnRightPickTrigger;
  2822. private static _OnCenterPickTrigger;
  2823. private static _OnPickDownTrigger;
  2824. private static _OnDoublePickTrigger;
  2825. private static _OnPickUpTrigger;
  2826. private static _OnLongPressTrigger;
  2827. private static _OnPointerOverTrigger;
  2828. private static _OnPointerOutTrigger;
  2829. private static _OnEveryFrameTrigger;
  2830. private static _OnIntersectionEnterTrigger;
  2831. private static _OnIntersectionExitTrigger;
  2832. private static _OnKeyDownTrigger;
  2833. private static _OnKeyUpTrigger;
  2834. private static _OnPickOutTrigger;
  2835. /**
  2836. * Nothing
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly NothingTrigger: number;
  2840. /**
  2841. * On pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnPickTrigger: number;
  2845. /**
  2846. * On left pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnLeftPickTrigger: number;
  2850. /**
  2851. * On right pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnRightPickTrigger: number;
  2855. /**
  2856. * On center pick
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnCenterPickTrigger: number;
  2860. /**
  2861. * On pick down
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnPickDownTrigger: number;
  2865. /**
  2866. * On double pick
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnDoublePickTrigger: number;
  2870. /**
  2871. * On pick up
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickUpTrigger: number;
  2875. /**
  2876. * On pick out.
  2877. * This trigger will only be raised if you also declared a OnPickDown
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnPickOutTrigger: number;
  2881. /**
  2882. * On long press
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnLongPressTrigger: number;
  2886. /**
  2887. * On pointer over
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOverTrigger: number;
  2891. /**
  2892. * On pointer out
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnPointerOutTrigger: number;
  2896. /**
  2897. * On every frame
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnEveryFrameTrigger: number;
  2901. /**
  2902. * On intersection enter
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionEnterTrigger: number;
  2906. /**
  2907. * On intersection exit
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnIntersectionExitTrigger: number;
  2911. /**
  2912. * On key down
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyDownTrigger: number;
  2916. /**
  2917. * On key up
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnKeyUpTrigger: number;
  2921. /** Gets the list of active triggers */
  2922. static Triggers: {
  2923. [key: string]: number;
  2924. };
  2925. /** Gets the list of actions */
  2926. actions: Action[];
  2927. /** Gets the cursor to use when hovering items */
  2928. hoverCursor: string;
  2929. private _scene;
  2930. /**
  2931. * Creates a new action manager
  2932. * @param scene defines the hosting scene
  2933. */
  2934. constructor(scene: Scene);
  2935. /**
  2936. * Releases all associated resources
  2937. */
  2938. dispose(): void;
  2939. /**
  2940. * Gets hosting scene
  2941. * @returns the hosting scene
  2942. */
  2943. getScene(): Scene;
  2944. /**
  2945. * Does this action manager handles actions of any of the given triggers
  2946. * @param triggers defines the triggers to be tested
  2947. * @return a boolean indicating whether one (or more) of the triggers is handled
  2948. */
  2949. hasSpecificTriggers(triggers: number[]): boolean;
  2950. /**
  2951. * Does this action manager handles actions of a given trigger
  2952. * @param trigger defines the trigger to be tested
  2953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2954. * @return whether the trigger is handled
  2955. */
  2956. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2957. /**
  2958. * Does this action manager has pointer triggers
  2959. */
  2960. readonly hasPointerTriggers: boolean;
  2961. /**
  2962. * Does this action manager has pick triggers
  2963. */
  2964. readonly hasPickTriggers: boolean;
  2965. /**
  2966. * Does exist one action manager with at least one trigger
  2967. **/
  2968. static readonly HasTriggers: boolean;
  2969. /**
  2970. * Does exist one action manager with at least one pick trigger
  2971. **/
  2972. static readonly HasPickTriggers: boolean;
  2973. /**
  2974. * Does exist one action manager that handles actions of a given trigger
  2975. * @param trigger defines the trigger to be tested
  2976. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2977. **/
  2978. static HasSpecificTrigger(trigger: number): boolean;
  2979. /**
  2980. * Registers an action to this action manager
  2981. * @param action defines the action to be registered
  2982. * @return the action amended (prepared) after registration
  2983. */
  2984. registerAction(action: Action): Nullable<Action>;
  2985. /**
  2986. * Unregisters an action to this action manager
  2987. * @param action defines the action to be unregistered
  2988. * @return a boolean indicating whether the action has been unregistered
  2989. */
  2990. unregisterAction(action: Action): Boolean;
  2991. /**
  2992. * Process a specific trigger
  2993. * @param trigger defines the trigger to process
  2994. * @param evt defines the event details to be processed
  2995. */
  2996. processTrigger(trigger: number, evt?: ActionEvent): void;
  2997. /** @hidden */
  2998. _getEffectiveTarget(target: any, propertyPath: string): any;
  2999. /** @hidden */
  3000. _getProperty(propertyPath: string): string;
  3001. /**
  3002. * Serialize this manager to a JSON object
  3003. * @param name defines the property name to store this manager
  3004. * @returns a JSON representation of this manager
  3005. */
  3006. serialize(name: string): any;
  3007. /**
  3008. * Creates a new ActionManager from a JSON data
  3009. * @param parsedActions defines the JSON data to read from
  3010. * @param object defines the hosting mesh
  3011. * @param scene defines the hosting scene
  3012. */
  3013. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3014. /**
  3015. * Get a trigger name by index
  3016. * @param trigger defines the trigger index
  3017. * @returns a trigger name
  3018. */
  3019. static GetTriggerName(trigger: number): string;
  3020. }
  3021. }
  3022. declare module BABYLON {
  3023. /**
  3024. * A Condition applied to an Action
  3025. */
  3026. class Condition {
  3027. /**
  3028. * Internal only - manager for action
  3029. * @hidden
  3030. */
  3031. _actionManager: ActionManager;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _evaluationId: number;
  3037. /**
  3038. * Internal only
  3039. * @hidden
  3040. */
  3041. _currentResult: boolean;
  3042. /**
  3043. * Creates a new Condition
  3044. * @param actionManager the manager of the action the condition is applied to
  3045. */
  3046. constructor(actionManager: ActionManager);
  3047. /**
  3048. * Check if the current condition is valid
  3049. * @returns a boolean
  3050. */
  3051. isValid(): boolean;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getProperty(propertyPath: string): string;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. _getEffectiveTarget(target: any, propertyPath: string): any;
  3062. /**
  3063. * Serialize placeholder for child classes
  3064. * @returns the serialized object
  3065. */
  3066. serialize(): any;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. protected _serialize(serializedCondition: any): any;
  3072. }
  3073. /**
  3074. * Defines specific conditional operators as extensions of Condition
  3075. */
  3076. class ValueCondition extends Condition {
  3077. /** path to specify the property of the target the conditional operator uses */
  3078. propertyPath: string;
  3079. /** the value compared by the conditional operator against the current value of the property */
  3080. value: any;
  3081. /** the conditional operator, default ValueCondition.IsEqual */
  3082. operator: number;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsEqual;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsDifferent;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsGreater;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsLesser;
  3103. /**
  3104. * returns the number for IsEqual
  3105. */
  3106. static readonly IsEqual: number;
  3107. /**
  3108. * Returns the number for IsDifferent
  3109. */
  3110. static readonly IsDifferent: number;
  3111. /**
  3112. * Returns the number for IsGreater
  3113. */
  3114. static readonly IsGreater: number;
  3115. /**
  3116. * Returns the number for IsLesser
  3117. */
  3118. static readonly IsLesser: number;
  3119. /**
  3120. * Internal only The action manager for the condition
  3121. * @hidden
  3122. */
  3123. _actionManager: ActionManager;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _target;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _effectiveTarget;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _property;
  3139. /**
  3140. * Creates a new ValueCondition
  3141. * @param actionManager manager for the action the condition applies to
  3142. * @param target for the action
  3143. * @param propertyPath path to specify the property of the target the conditional operator uses
  3144. * @param value the value compared by the conditional operator against the current value of the property
  3145. * @param operator the conditional operator, default ValueCondition.IsEqual
  3146. */
  3147. constructor(actionManager: ActionManager, target: any,
  3148. /** path to specify the property of the target the conditional operator uses */
  3149. propertyPath: string,
  3150. /** the value compared by the conditional operator against the current value of the property */
  3151. value: any,
  3152. /** the conditional operator, default ValueCondition.IsEqual */
  3153. operator?: number);
  3154. /**
  3155. * Compares the given value with the property value for the specified conditional operator
  3156. * @returns the result of the comparison
  3157. */
  3158. isValid(): boolean;
  3159. /**
  3160. * Serialize the ValueCondition into a JSON compatible object
  3161. * @returns serialization object
  3162. */
  3163. serialize(): any;
  3164. /**
  3165. * Gets the name of the conditional operator for the ValueCondition
  3166. * @param operator the conditional operator
  3167. * @returns the name
  3168. */
  3169. static GetOperatorName(operator: number): string;
  3170. }
  3171. /**
  3172. * Defines a predicate condition as an extension of Condition
  3173. */
  3174. class PredicateCondition extends Condition {
  3175. /** defines the predicate function used to validate the condition */
  3176. predicate: () => boolean;
  3177. /**
  3178. * Internal only - manager for action
  3179. * @hidden
  3180. */
  3181. _actionManager: ActionManager;
  3182. /**
  3183. * Creates a new PredicateCondition
  3184. * @param actionManager manager for the action the condition applies to
  3185. * @param predicate defines the predicate function used to validate the condition
  3186. */
  3187. constructor(actionManager: ActionManager,
  3188. /** defines the predicate function used to validate the condition */
  3189. predicate: () => boolean);
  3190. /**
  3191. * @returns the validity of the predicate condition
  3192. */
  3193. isValid(): boolean;
  3194. }
  3195. /**
  3196. * Defines a state condition as an extension of Condition
  3197. */
  3198. class StateCondition extends Condition {
  3199. value: string;
  3200. /**
  3201. * Internal only - manager for action
  3202. * @hidden
  3203. */
  3204. _actionManager: ActionManager;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _target;
  3210. /**
  3211. * Creates a new StateCondition
  3212. * @param actionManager manager for the action the condition applies to
  3213. * @param target of the condition
  3214. * @param value to compare with target state
  3215. */
  3216. constructor(actionManager: ActionManager, target: any, value: string);
  3217. /**
  3218. * @returns the validity of the state
  3219. */
  3220. isValid(): boolean;
  3221. /**
  3222. * Serialize the StateCondition into a JSON compatible object
  3223. * @returns serialization object
  3224. */
  3225. serialize(): any;
  3226. }
  3227. }
  3228. declare module BABYLON {
  3229. class SwitchBooleanAction extends Action {
  3230. propertyPath: string;
  3231. private _target;
  3232. private _effectiveTarget;
  3233. private _property;
  3234. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3235. _prepare(): void;
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class SetStateAction extends Action {
  3240. value: string;
  3241. private _target;
  3242. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3243. execute(): void;
  3244. serialize(parent: any): any;
  3245. }
  3246. class SetValueAction extends Action {
  3247. propertyPath: string;
  3248. value: any;
  3249. private _target;
  3250. private _effectiveTarget;
  3251. private _property;
  3252. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3253. _prepare(): void;
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class IncrementValueAction extends Action {
  3258. propertyPath: string;
  3259. value: any;
  3260. private _target;
  3261. private _effectiveTarget;
  3262. private _property;
  3263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3264. _prepare(): void;
  3265. execute(): void;
  3266. serialize(parent: any): any;
  3267. }
  3268. class PlayAnimationAction extends Action {
  3269. from: number;
  3270. to: number;
  3271. loop: boolean | undefined;
  3272. private _target;
  3273. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class StopAnimationAction extends Action {
  3279. private _target;
  3280. constructor(triggerOptions: any, target: any, condition?: Condition);
  3281. _prepare(): void;
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class DoNothingAction extends Action {
  3286. constructor(triggerOptions?: any, condition?: Condition);
  3287. execute(): void;
  3288. serialize(parent: any): any;
  3289. }
  3290. class CombineAction extends Action {
  3291. children: Action[];
  3292. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3293. _prepare(): void;
  3294. execute(evt: ActionEvent): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class ExecuteCodeAction extends Action {
  3298. func: (evt: ActionEvent) => void;
  3299. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3300. execute(evt: ActionEvent): void;
  3301. }
  3302. class SetParentAction extends Action {
  3303. private _parent;
  3304. private _target;
  3305. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3306. _prepare(): void;
  3307. execute(): void;
  3308. serialize(parent: any): any;
  3309. }
  3310. class PlaySoundAction extends Action {
  3311. private _sound;
  3312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3313. _prepare(): void;
  3314. execute(): void;
  3315. serialize(parent: any): any;
  3316. }
  3317. class StopSoundAction extends Action {
  3318. private _sound;
  3319. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3320. _prepare(): void;
  3321. execute(): void;
  3322. serialize(parent: any): any;
  3323. }
  3324. }
  3325. declare module BABYLON {
  3326. class InterpolateValueAction extends Action {
  3327. propertyPath: string;
  3328. value: any;
  3329. duration: number;
  3330. stopOtherAnimations: boolean | undefined;
  3331. onInterpolationDone: (() => void) | undefined;
  3332. private _target;
  3333. private _effectiveTarget;
  3334. private _property;
  3335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3337. _prepare(): void;
  3338. execute(): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. }
  3342. declare module BABYLON {
  3343. /**
  3344. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3346. */
  3347. class Analyser {
  3348. /**
  3349. * Gets or sets the smoothing
  3350. * @ignorenaming
  3351. */
  3352. SMOOTHING: number;
  3353. /**
  3354. * Gets or sets the FFT table size
  3355. * @ignorenaming
  3356. */
  3357. FFT_SIZE: number;
  3358. /**
  3359. * Gets or sets the bar graph amplitude
  3360. * @ignorenaming
  3361. */
  3362. BARGRAPHAMPLITUDE: number;
  3363. /**
  3364. * Gets or sets the position of the debug canvas
  3365. * @ignorenaming
  3366. */
  3367. DEBUGCANVASPOS: {
  3368. x: number;
  3369. y: number;
  3370. };
  3371. /**
  3372. * Gets or sets the debug canvas size
  3373. * @ignorenaming
  3374. */
  3375. DEBUGCANVASSIZE: {
  3376. width: number;
  3377. height: number;
  3378. };
  3379. private _byteFreqs;
  3380. private _byteTime;
  3381. private _floatFreqs;
  3382. private _webAudioAnalyser;
  3383. private _debugCanvas;
  3384. private _debugCanvasContext;
  3385. private _scene;
  3386. private _registerFunc;
  3387. private _audioEngine;
  3388. /**
  3389. * Creates a new analyser
  3390. * @param scene defines hosting scene
  3391. */
  3392. constructor(scene: Scene);
  3393. /**
  3394. * Get the number of data values you will have to play with for the visualization
  3395. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3396. * @returns a number
  3397. */
  3398. getFrequencyBinCount(): number;
  3399. /**
  3400. * Gets the current frequency data as a byte array
  3401. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3402. * @returns a Uint8Array
  3403. */
  3404. getByteFrequencyData(): Uint8Array;
  3405. /**
  3406. * Gets the current waveform as a byte array
  3407. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3408. * @returns a Uint8Array
  3409. */
  3410. getByteTimeDomainData(): Uint8Array;
  3411. /**
  3412. * Gets the current frequency data as a float array
  3413. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3414. * @returns a Float32Array
  3415. */
  3416. getFloatFrequencyData(): Float32Array;
  3417. /**
  3418. * Renders the debug canvas
  3419. */
  3420. drawDebugCanvas(): void;
  3421. /**
  3422. * Stops rendering the debug canvas and removes it
  3423. */
  3424. stopDebugCanvas(): void;
  3425. /**
  3426. * Connects two audio nodes
  3427. * @param inputAudioNode defines first node to connect
  3428. * @param outputAudioNode defines second node to connect
  3429. */
  3430. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3431. /**
  3432. * Releases all associated resources
  3433. */
  3434. dispose(): void;
  3435. }
  3436. }
  3437. declare module BABYLON {
  3438. class AudioEngine {
  3439. private _audioContext;
  3440. private _audioContextInitialized;
  3441. canUseWebAudio: boolean;
  3442. masterGain: GainNode;
  3443. private _connectedAnalyser;
  3444. WarnedWebAudioUnsupported: boolean;
  3445. unlocked: boolean;
  3446. onAudioUnlocked: () => any;
  3447. isMP3supported: boolean;
  3448. isOGGsupported: boolean;
  3449. readonly audioContext: Nullable<AudioContext>;
  3450. constructor();
  3451. private _unlockiOSaudio();
  3452. private _initializeAudioContext();
  3453. dispose(): void;
  3454. getGlobalVolume(): number;
  3455. setGlobalVolume(newVolume: number): void;
  3456. connectToAnalyser(analyser: Analyser): void;
  3457. }
  3458. }
  3459. declare module BABYLON {
  3460. class Sound {
  3461. name: string;
  3462. autoplay: boolean;
  3463. loop: boolean;
  3464. useCustomAttenuation: boolean;
  3465. soundTrackId: number;
  3466. spatialSound: boolean;
  3467. refDistance: number;
  3468. rolloffFactor: number;
  3469. maxDistance: number;
  3470. distanceModel: string;
  3471. private _panningModel;
  3472. onended: () => any;
  3473. private _playbackRate;
  3474. private _streaming;
  3475. private _startTime;
  3476. private _startOffset;
  3477. private _position;
  3478. private _localDirection;
  3479. private _volume;
  3480. private _isReadyToPlay;
  3481. isPlaying: boolean;
  3482. isPaused: boolean;
  3483. private _isDirectional;
  3484. private _readyToPlayCallback;
  3485. private _audioBuffer;
  3486. private _soundSource;
  3487. private _streamingSource;
  3488. private _soundPanner;
  3489. private _soundGain;
  3490. private _inputAudioNode;
  3491. private _ouputAudioNode;
  3492. private _coneInnerAngle;
  3493. private _coneOuterAngle;
  3494. private _coneOuterGain;
  3495. private _scene;
  3496. private _connectedMesh;
  3497. private _customAttenuationFunction;
  3498. private _registerFunc;
  3499. private _isOutputConnected;
  3500. private _htmlAudioElement;
  3501. private _urlType;
  3502. /**
  3503. * Create a sound and attach it to a scene
  3504. * @param name Name of your sound
  3505. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  3506. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3507. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3508. */
  3509. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3510. dispose(): void;
  3511. isReady(): boolean;
  3512. private _soundLoaded(audioData);
  3513. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3514. updateOptions(options: any): void;
  3515. private _createSpatialParameters();
  3516. private _updateSpatialParameters();
  3517. switchPanningModelToHRTF(): void;
  3518. switchPanningModelToEqualPower(): void;
  3519. private _switchPanningModel();
  3520. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3521. /**
  3522. * Transform this sound into a directional source
  3523. * @param coneInnerAngle Size of the inner cone in degree
  3524. * @param coneOuterAngle Size of the outer cone in degree
  3525. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3526. */
  3527. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3528. setPosition(newPosition: Vector3): void;
  3529. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3530. private _updateDirection();
  3531. updateDistanceFromListener(): void;
  3532. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3533. /**
  3534. * Play the sound
  3535. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3536. * @param offset (optional) Start the sound setting it at a specific time
  3537. */
  3538. play(time?: number, offset?: number): void;
  3539. private _onended();
  3540. /**
  3541. * Stop the sound
  3542. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3543. */
  3544. stop(time?: number): void;
  3545. pause(): void;
  3546. setVolume(newVolume: number, time?: number): void;
  3547. setPlaybackRate(newPlaybackRate: number): void;
  3548. getVolume(): number;
  3549. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3550. detachFromMesh(): void;
  3551. private _onRegisterAfterWorldMatrixUpdate(node);
  3552. clone(): Nullable<Sound>;
  3553. getAudioBuffer(): AudioBuffer | null;
  3554. serialize(): any;
  3555. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3556. }
  3557. }
  3558. declare module BABYLON {
  3559. class SoundTrack {
  3560. private _outputAudioNode;
  3561. private _scene;
  3562. id: number;
  3563. soundCollection: Array<Sound>;
  3564. private _isMainTrack;
  3565. private _connectedAnalyser;
  3566. private _options;
  3567. private _isInitialized;
  3568. constructor(scene: Scene, options?: any);
  3569. private _initializeSoundTrackAudioGraph();
  3570. dispose(): void;
  3571. AddSound(sound: Sound): void;
  3572. RemoveSound(sound: Sound): void;
  3573. setVolume(newVolume: number): void;
  3574. switchPanningModelToHRTF(): void;
  3575. switchPanningModelToEqualPower(): void;
  3576. connectToAnalyser(analyser: Analyser): void;
  3577. }
  3578. }
  3579. declare module BABYLON {
  3580. class Animatable {
  3581. target: any;
  3582. fromFrame: number;
  3583. toFrame: number;
  3584. loopAnimation: boolean;
  3585. onAnimationEnd: (() => void) | null | undefined;
  3586. private _localDelayOffset;
  3587. private _pausedDelay;
  3588. private _runtimeAnimations;
  3589. private _paused;
  3590. private _scene;
  3591. private _speedRatio;
  3592. private _weight;
  3593. private _syncRoot;
  3594. animationStarted: boolean;
  3595. /**
  3596. * Observer raised when the animation ends
  3597. */
  3598. onAnimationEndObservable: Observable<Animatable>;
  3599. /**
  3600. * Gets the root Animatable used to synchronize and normalize animations
  3601. */
  3602. readonly syncRoot: Animatable;
  3603. /**
  3604. * Gets the current frame of the first RuntimeAnimation
  3605. * Used to synchronize Animatables
  3606. */
  3607. readonly masterFrame: number;
  3608. /**
  3609. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3610. */
  3611. weight: number;
  3612. /**
  3613. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3614. */
  3615. speedRatio: number;
  3616. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3617. /**
  3618. * Synchronize and normalize current Animatable with a source Animatable
  3619. * This is useful when using animation weights and when animations are not of the same length
  3620. * @param root defines the root Animatable to synchronize with
  3621. * @returns the current Animatable
  3622. */
  3623. syncWith(root: Animatable): Animatable;
  3624. getAnimations(): RuntimeAnimation[];
  3625. appendAnimations(target: any, animations: Animation[]): void;
  3626. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3627. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3628. reset(): void;
  3629. enableBlending(blendingSpeed: number): void;
  3630. disableBlending(): void;
  3631. goToFrame(frame: number): void;
  3632. pause(): void;
  3633. restart(): void;
  3634. private _raiseOnAnimationEnd();
  3635. stop(animationName?: string): void;
  3636. /**
  3637. * Wait asynchronously for the animation to end
  3638. * @returns a promise which will be fullfilled when the animation ends
  3639. */
  3640. waitAsync(): Promise<Animatable>;
  3641. /** @hidden */
  3642. _animate(delay: number): boolean;
  3643. }
  3644. }
  3645. declare module BABYLON {
  3646. /**
  3647. * Represents the range of an animation
  3648. */
  3649. class AnimationRange {
  3650. /**The name of the animation range**/
  3651. name: string;
  3652. /**The starting frame of the animation */
  3653. from: number;
  3654. /**The ending frame of the animation*/
  3655. to: number;
  3656. /**
  3657. * Initializes the range of an animation
  3658. * @param name The name of the animation range
  3659. * @param from The starting frame of the animation
  3660. * @param to The ending frame of the animation
  3661. */
  3662. constructor(
  3663. /**The name of the animation range**/
  3664. name: string,
  3665. /**The starting frame of the animation */
  3666. from: number,
  3667. /**The ending frame of the animation*/
  3668. to: number);
  3669. /**
  3670. * Makes a copy of the animation range
  3671. * @returns A copy of the animation range
  3672. */
  3673. clone(): AnimationRange;
  3674. }
  3675. /**
  3676. * Composed of a frame, and an action function
  3677. */
  3678. class AnimationEvent {
  3679. /** The frame for which the event is triggered **/
  3680. frame: number;
  3681. /** The event to perform when triggered **/
  3682. action: () => void;
  3683. /** Specifies if the event should be triggered only once**/
  3684. onlyOnce: boolean | undefined;
  3685. /**
  3686. * Specifies if the animation event is done
  3687. */
  3688. isDone: boolean;
  3689. /**
  3690. * Initializes the animation event
  3691. * @param frame The frame for which the event is triggered
  3692. * @param action The event to perform when triggered
  3693. * @param onlyOnce Specifies if the event should be triggered only once
  3694. */
  3695. constructor(
  3696. /** The frame for which the event is triggered **/
  3697. frame: number,
  3698. /** The event to perform when triggered **/
  3699. action: () => void,
  3700. /** Specifies if the event should be triggered only once**/
  3701. onlyOnce?: boolean | undefined);
  3702. /** @hidden */
  3703. _clone(): AnimationEvent;
  3704. }
  3705. /**
  3706. * A cursor which tracks a point on a path
  3707. */
  3708. class PathCursor {
  3709. private path;
  3710. /**
  3711. * Stores path cursor callbacks for when an onchange event is triggered
  3712. */
  3713. private _onchange;
  3714. /**
  3715. * The value of the path cursor
  3716. */
  3717. value: number;
  3718. /**
  3719. * The animation array of the path cursor
  3720. */
  3721. animations: Animation[];
  3722. /**
  3723. * Initializes the path cursor
  3724. * @param path The path to track
  3725. */
  3726. constructor(path: Path2);
  3727. /**
  3728. * Gets the cursor point on the path
  3729. * @returns A point on the path cursor at the cursor location
  3730. */
  3731. getPoint(): Vector3;
  3732. /**
  3733. * Moves the cursor ahead by the step amount
  3734. * @param step The amount to move the cursor forward
  3735. * @returns This path cursor
  3736. */
  3737. moveAhead(step?: number): PathCursor;
  3738. /**
  3739. * Moves the cursor behind by the step amount
  3740. * @param step The amount to move the cursor back
  3741. * @returns This path cursor
  3742. */
  3743. moveBack(step?: number): PathCursor;
  3744. /**
  3745. * Moves the cursor by the step amount
  3746. * If the step amount is greater than one, an exception is thrown
  3747. * @param step The amount to move the cursor
  3748. * @returns This path cursor
  3749. */
  3750. move(step: number): PathCursor;
  3751. /**
  3752. * Ensures that the value is limited between zero and one
  3753. * @returns This path cursor
  3754. */
  3755. private ensureLimits();
  3756. /**
  3757. * Runs onchange callbacks on change (used by the animation engine)
  3758. * @returns This path cursor
  3759. */
  3760. private raiseOnChange();
  3761. /**
  3762. * Executes a function on change
  3763. * @param f A path cursor onchange callback
  3764. * @returns This path cursor
  3765. */
  3766. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3767. }
  3768. /**
  3769. * Defines an interface which represents an animation key frame
  3770. */
  3771. interface IAnimationKey {
  3772. /**
  3773. * Frame of the key frame
  3774. */
  3775. frame: number;
  3776. /**
  3777. * Value at the specifies key frame
  3778. */
  3779. value: any;
  3780. /**
  3781. * The input tangent for the cubic hermite spline
  3782. */
  3783. inTangent?: any;
  3784. /**
  3785. * The output tangent for the cubic hermite spline
  3786. */
  3787. outTangent?: any;
  3788. /**
  3789. * The animation interpolation type
  3790. */
  3791. interpolation?: AnimationKeyInterpolation;
  3792. }
  3793. /**
  3794. * Enum for the animation key frame interpolation type
  3795. */
  3796. enum AnimationKeyInterpolation {
  3797. /**
  3798. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3799. */
  3800. STEP = 1,
  3801. }
  3802. /**
  3803. * Class used to store any kind of animation
  3804. */
  3805. class Animation {
  3806. /**Name of the animation */
  3807. name: string;
  3808. /**Property to animate */
  3809. targetProperty: string;
  3810. /**The frames per second of the animation */
  3811. framePerSecond: number;
  3812. /**The data type of the animation */
  3813. dataType: number;
  3814. /**The loop mode of the animation */
  3815. loopMode: number | undefined;
  3816. /**Specifies if blending should be enabled */
  3817. enableBlending: boolean | undefined;
  3818. /**
  3819. * Use matrix interpolation instead of using direct key value when animating matrices
  3820. */
  3821. static AllowMatricesInterpolation: boolean;
  3822. /**
  3823. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3824. */
  3825. static AllowMatrixDecomposeForInterpolation: boolean;
  3826. /**
  3827. * Stores the key frames of the animation
  3828. */
  3829. private _keys;
  3830. /**
  3831. * Stores the easing function of the animation
  3832. */
  3833. private _easingFunction;
  3834. /**
  3835. * @hidden Internal use only
  3836. */
  3837. _runtimeAnimations: RuntimeAnimation[];
  3838. /**
  3839. * The set of event that will be linked to this animation
  3840. */
  3841. private _events;
  3842. /**
  3843. * Stores an array of target property paths
  3844. */
  3845. targetPropertyPath: string[];
  3846. /**
  3847. * Stores the blending speed of the animation
  3848. */
  3849. blendingSpeed: number;
  3850. /**
  3851. * Stores the animation ranges for the animation
  3852. */
  3853. private _ranges;
  3854. /**
  3855. * @hidden Internal use
  3856. */
  3857. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3858. /**
  3859. * Sets up an animation
  3860. * @param property The property to animate
  3861. * @param animationType The animation type to apply
  3862. * @param framePerSecond The frames per second of the animation
  3863. * @param easingFunction The easing function used in the animation
  3864. * @returns The created animation
  3865. */
  3866. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3867. /**
  3868. * Create and start an animation on a node
  3869. * @param name defines the name of the global animation that will be run on all nodes
  3870. * @param node defines the root node where the animation will take place
  3871. * @param targetProperty defines property to animate
  3872. * @param framePerSecond defines the number of frame per second yo use
  3873. * @param totalFrame defines the number of frames in total
  3874. * @param from defines the initial value
  3875. * @param to defines the final value
  3876. * @param loopMode defines which loop mode you want to use (off by default)
  3877. * @param easingFunction defines the easing function to use (linear by default)
  3878. * @param onAnimationEnd defines the callback to call when animation end
  3879. * @returns the animatable created for this animation
  3880. */
  3881. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3882. /**
  3883. * Create and start an animation on a node and its descendants
  3884. * @param name defines the name of the global animation that will be run on all nodes
  3885. * @param node defines the root node where the animation will take place
  3886. * @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
  3887. * @param targetProperty defines property to animate
  3888. * @param framePerSecond defines the number of frame per second to use
  3889. * @param totalFrame defines the number of frames in total
  3890. * @param from defines the initial value
  3891. * @param to defines the final value
  3892. * @param loopMode defines which loop mode you want to use (off by default)
  3893. * @param easingFunction defines the easing function to use (linear by default)
  3894. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3895. * @returns the list of animatables created for all nodes
  3896. * @example https://www.babylonjs-playground.com/#MH0VLI
  3897. */
  3898. 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[]>;
  3899. /**
  3900. * Creates a new animation, merges it with the existing animations and starts it
  3901. * @param name Name of the animation
  3902. * @param node Node which contains the scene that begins the animations
  3903. * @param targetProperty Specifies which property to animate
  3904. * @param framePerSecond The frames per second of the animation
  3905. * @param totalFrame The total number of frames
  3906. * @param from The frame at the beginning of the animation
  3907. * @param to The frame at the end of the animation
  3908. * @param loopMode Specifies the loop mode of the animation
  3909. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3910. * @param onAnimationEnd Callback to run once the animation is complete
  3911. * @returns Nullable animation
  3912. */
  3913. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3914. /**
  3915. * Transition property of an host to the target Value
  3916. * @param property The property to transition
  3917. * @param targetValue The target Value of the property
  3918. * @param host The object where the property to animate belongs
  3919. * @param scene Scene used to run the animation
  3920. * @param frameRate Framerate (in frame/s) to use
  3921. * @param transition The transition type we want to use
  3922. * @param duration The duration of the animation, in milliseconds
  3923. * @param onAnimationEnd Callback trigger at the end of the animation
  3924. * @returns Nullable animation
  3925. */
  3926. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3927. /**
  3928. * Return the array of runtime animations currently using this animation
  3929. */
  3930. readonly runtimeAnimations: RuntimeAnimation[];
  3931. /**
  3932. * Specifies if any of the runtime animations are currently running
  3933. */
  3934. readonly hasRunningRuntimeAnimations: boolean;
  3935. /**
  3936. * Initializes the animation
  3937. * @param name Name of the animation
  3938. * @param targetProperty Property to animate
  3939. * @param framePerSecond The frames per second of the animation
  3940. * @param dataType The data type of the animation
  3941. * @param loopMode The loop mode of the animation
  3942. * @param enableBlendings Specifies if blending should be enabled
  3943. */
  3944. constructor(
  3945. /**Name of the animation */
  3946. name: string,
  3947. /**Property to animate */
  3948. targetProperty: string,
  3949. /**The frames per second of the animation */
  3950. framePerSecond: number,
  3951. /**The data type of the animation */
  3952. dataType: number,
  3953. /**The loop mode of the animation */
  3954. loopMode?: number | undefined,
  3955. /**Specifies if blending should be enabled */
  3956. enableBlending?: boolean | undefined);
  3957. /**
  3958. * Converts the animation to a string
  3959. * @param fullDetails support for multiple levels of logging within scene loading
  3960. * @returns String form of the animation
  3961. */
  3962. toString(fullDetails?: boolean): string;
  3963. /**
  3964. * Add an event to this animation
  3965. * @param event Event to add
  3966. */
  3967. addEvent(event: AnimationEvent): void;
  3968. /**
  3969. * Remove all events found at the given frame
  3970. * @param frame The frame to remove events from
  3971. */
  3972. removeEvents(frame: number): void;
  3973. /**
  3974. * Retrieves all the events from the animation
  3975. * @returns Events from the animation
  3976. */
  3977. getEvents(): AnimationEvent[];
  3978. /**
  3979. * Creates an animation range
  3980. * @param name Name of the animation range
  3981. * @param from Starting frame of the animation range
  3982. * @param to Ending frame of the animation
  3983. */
  3984. createRange(name: string, from: number, to: number): void;
  3985. /**
  3986. * Deletes an animation range by name
  3987. * @param name Name of the animation range to delete
  3988. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3989. */
  3990. deleteRange(name: string, deleteFrames?: boolean): void;
  3991. /**
  3992. * Gets the animation range by name, or null if not defined
  3993. * @param name Name of the animation range
  3994. * @returns Nullable animation range
  3995. */
  3996. getRange(name: string): Nullable<AnimationRange>;
  3997. /**
  3998. * Gets the key frames from the animation
  3999. * @returns The key frames of the animation
  4000. */
  4001. getKeys(): Array<IAnimationKey>;
  4002. /**
  4003. * Gets the highest frame rate of the animation
  4004. * @returns Highest frame rate of the animation
  4005. */
  4006. getHighestFrame(): number;
  4007. /**
  4008. * Gets the easing function of the animation
  4009. * @returns Easing function of the animation
  4010. */
  4011. getEasingFunction(): IEasingFunction;
  4012. /**
  4013. * Sets the easing function of the animation
  4014. * @param easingFunction A custom mathematical formula for animation
  4015. */
  4016. setEasingFunction(easingFunction: EasingFunction): void;
  4017. /**
  4018. * Interpolates a scalar 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 scalar value
  4023. */
  4024. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4025. /**
  4026. * Interpolates a scalar cubically
  4027. * @param startValue Start value of the animation curve
  4028. * @param outTangent End tangent of the animation
  4029. * @param endValue End value of the animation curve
  4030. * @param inTangent Start tangent of the animation curve
  4031. * @param gradient Scalar amount to interpolate
  4032. * @returns Interpolated scalar value
  4033. */
  4034. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4035. /**
  4036. * Interpolates a quaternion using a spherical linear interpolation
  4037. * @param startValue Start value of the animation curve
  4038. * @param endValue End value of the animation curve
  4039. * @param gradient Scalar amount to interpolate
  4040. * @returns Interpolated quaternion value
  4041. */
  4042. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4043. /**
  4044. * Interpolates a quaternion cubically
  4045. * @param startValue Start value of the animation curve
  4046. * @param outTangent End tangent of the animation curve
  4047. * @param endValue End value of the animation curve
  4048. * @param inTangent Start tangent of the animation curve
  4049. * @param gradient Scalar amount to interpolate
  4050. * @returns Interpolated quaternion value
  4051. */
  4052. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4053. /**
  4054. * Interpolates a Vector3 linearl
  4055. * @param startValue Start value of the animation curve
  4056. * @param endValue End value of the animation curve
  4057. * @param gradient Scalar amount to interpolate
  4058. * @returns Interpolated scalar value
  4059. */
  4060. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4061. /**
  4062. * Interpolates a Vector3 cubically
  4063. * @param startValue Start value of the animation curve
  4064. * @param outTangent End tangent of the animation
  4065. * @param endValue End value of the animation curve
  4066. * @param inTangent Start tangent of the animation curve
  4067. * @param gradient Scalar amount to interpolate
  4068. * @returns InterpolatedVector3 value
  4069. */
  4070. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4071. /**
  4072. * Interpolates a Vector2 linearly
  4073. * @param startValue Start value of the animation curve
  4074. * @param endValue End value of the animation curve
  4075. * @param gradient Scalar amount to interpolate
  4076. * @returns Interpolated Vector2 value
  4077. */
  4078. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4079. /**
  4080. * Interpolates a Vector2 cubically
  4081. * @param startValue Start value of the animation curve
  4082. * @param outTangent End tangent of the animation
  4083. * @param endValue End value of the animation curve
  4084. * @param inTangent Start tangent of the animation curve
  4085. * @param gradient Scalar amount to interpolate
  4086. * @returns Interpolated Vector2 value
  4087. */
  4088. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4089. /**
  4090. * Interpolates a size linearly
  4091. * @param startValue Start value of the animation curve
  4092. * @param endValue End value of the animation curve
  4093. * @param gradient Scalar amount to interpolate
  4094. * @returns Interpolated Size value
  4095. */
  4096. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4097. /**
  4098. * Interpolates a Color3 linearly
  4099. * @param startValue Start value of the animation curve
  4100. * @param endValue End value of the animation curve
  4101. * @param gradient Scalar amount to interpolate
  4102. * @returns Interpolated Color3 value
  4103. */
  4104. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4105. /**
  4106. * @hidden Internal use only
  4107. */
  4108. _getKeyValue(value: any): any;
  4109. /**
  4110. * @hidden Internal use only
  4111. */
  4112. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4113. /**
  4114. * Defines the function to use to interpolate matrices
  4115. * @param startValue defines the start matrix
  4116. * @param endValue defines the end matrix
  4117. * @param gradient defines the gradient between both matrices
  4118. * @param result defines an optional target matrix where to store the interpolation
  4119. * @returns the interpolated matrix
  4120. */
  4121. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4122. /**
  4123. * Makes a copy of the animation
  4124. * @returns Cloned animation
  4125. */
  4126. clone(): Animation;
  4127. /**
  4128. * Sets the key frames of the animation
  4129. * @param values The animation key frames to set
  4130. */
  4131. setKeys(values: Array<IAnimationKey>): void;
  4132. /**
  4133. * Serializes the animation to an object
  4134. * @returns Serialized object
  4135. */
  4136. serialize(): any;
  4137. /**
  4138. * Float animation type
  4139. */
  4140. private static _ANIMATIONTYPE_FLOAT;
  4141. /**
  4142. * Vector3 animation type
  4143. */
  4144. private static _ANIMATIONTYPE_VECTOR3;
  4145. /**
  4146. * Quaternion animation type
  4147. */
  4148. private static _ANIMATIONTYPE_QUATERNION;
  4149. /**
  4150. * Matrix animation type
  4151. */
  4152. private static _ANIMATIONTYPE_MATRIX;
  4153. /**
  4154. * Color3 animation type
  4155. */
  4156. private static _ANIMATIONTYPE_COLOR3;
  4157. /**
  4158. * Vector2 animation type
  4159. */
  4160. private static _ANIMATIONTYPE_VECTOR2;
  4161. /**
  4162. * Size animation type
  4163. */
  4164. private static _ANIMATIONTYPE_SIZE;
  4165. /**
  4166. * Relative Loop Mode
  4167. */
  4168. private static _ANIMATIONLOOPMODE_RELATIVE;
  4169. /**
  4170. * Cycle Loop Mode
  4171. */
  4172. private static _ANIMATIONLOOPMODE_CYCLE;
  4173. /**
  4174. * Constant Loop Mode
  4175. */
  4176. private static _ANIMATIONLOOPMODE_CONSTANT;
  4177. /**
  4178. * Get the float animation type
  4179. */
  4180. static readonly ANIMATIONTYPE_FLOAT: number;
  4181. /**
  4182. * Get the Vector3 animation type
  4183. */
  4184. static readonly ANIMATIONTYPE_VECTOR3: number;
  4185. /**
  4186. * Get the Vectpr2 animation type
  4187. */
  4188. static readonly ANIMATIONTYPE_VECTOR2: number;
  4189. /**
  4190. * Get the Size animation type
  4191. */
  4192. static readonly ANIMATIONTYPE_SIZE: number;
  4193. /**
  4194. * Get the Quaternion animation type
  4195. */
  4196. static readonly ANIMATIONTYPE_QUATERNION: number;
  4197. /**
  4198. * Get the Matrix animation type
  4199. */
  4200. static readonly ANIMATIONTYPE_MATRIX: number;
  4201. /**
  4202. * Get the Color3 animation type
  4203. */
  4204. static readonly ANIMATIONTYPE_COLOR3: number;
  4205. /**
  4206. * Get the Relative Loop Mode
  4207. */
  4208. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4209. /**
  4210. * Get the Cycle Loop Mode
  4211. */
  4212. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4213. /**
  4214. * Get the Constant Loop Mode
  4215. */
  4216. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4217. /** @hidden */
  4218. static _UniversalLerp(left: any, right: any, amount: number): any;
  4219. /**
  4220. * Parses an animation object and creates an animation
  4221. * @param parsedAnimation Parsed animation object
  4222. * @returns Animation object
  4223. */
  4224. static Parse(parsedAnimation: any): Animation;
  4225. /**
  4226. * Appends the serialized animations from the source animations
  4227. * @param source Source containing the animations
  4228. * @param destination Target to store the animations
  4229. */
  4230. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4231. }
  4232. }
  4233. declare module BABYLON {
  4234. /**
  4235. * This class defines the direct association between an animation and a target
  4236. */
  4237. class TargetedAnimation {
  4238. animation: Animation;
  4239. target: any;
  4240. }
  4241. /**
  4242. * Use this class to create coordinated animations on multiple targets
  4243. */
  4244. class AnimationGroup implements IDisposable {
  4245. name: string;
  4246. private _scene;
  4247. private _targetedAnimations;
  4248. private _animatables;
  4249. private _from;
  4250. private _to;
  4251. private _isStarted;
  4252. private _speedRatio;
  4253. onAnimationEndObservable: Observable<TargetedAnimation>;
  4254. /**
  4255. * This observable will notify when all animations have ended.
  4256. */
  4257. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4258. /**
  4259. * Gets the first frame
  4260. */
  4261. readonly from: number;
  4262. /**
  4263. * Gets the last frame
  4264. */
  4265. readonly to: number;
  4266. /**
  4267. * Define if the animations are started
  4268. */
  4269. readonly isStarted: boolean;
  4270. /**
  4271. * Gets or sets the speed ratio to use for all animations
  4272. */
  4273. /**
  4274. * Gets or sets the speed ratio to use for all animations
  4275. */
  4276. speedRatio: number;
  4277. /**
  4278. * Gets the targeted animations for this animation group
  4279. */
  4280. readonly targetedAnimations: Array<TargetedAnimation>;
  4281. /**
  4282. * returning the list of animatables controlled by this animation group.
  4283. */
  4284. readonly animatables: Array<Animatable>;
  4285. constructor(name: string, scene?: Nullable<Scene>);
  4286. /**
  4287. * Add an animation (with its target) in the group
  4288. * @param animation defines the animation we want to add
  4289. * @param target defines the target of the animation
  4290. * @returns the {BABYLON.TargetedAnimation} object
  4291. */
  4292. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4293. /**
  4294. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4295. * It can add constant keys at begin or end
  4296. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4297. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4298. */
  4299. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4300. /**
  4301. * Start all animations on given targets
  4302. * @param loop defines if animations must loop
  4303. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4304. * @param from defines the from key (optional)
  4305. * @param to defines the to key (optional)
  4306. * @returns the current animation group
  4307. */
  4308. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4309. /**
  4310. * Pause all animations
  4311. */
  4312. pause(): AnimationGroup;
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. */
  4318. play(loop?: boolean): AnimationGroup;
  4319. /**
  4320. * Reset all animations to initial state
  4321. */
  4322. reset(): AnimationGroup;
  4323. /**
  4324. * Restart animations from key 0
  4325. */
  4326. restart(): AnimationGroup;
  4327. /**
  4328. * Stop all animations
  4329. */
  4330. stop(): AnimationGroup;
  4331. /**
  4332. * Set animation weight for all animatables
  4333. * @param weight defines the weight to use
  4334. * @return the animationGroup
  4335. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4336. */
  4337. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4338. /**
  4339. * Synchronize and normalize all animatables with a source animatable
  4340. * @param root defines the root animatable to synchronize with
  4341. * @return the animationGroup
  4342. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4343. */
  4344. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4345. /**
  4346. * Goes to a specific frame in this animation group
  4347. * @param frame the frame number to go to
  4348. * @return the animationGroup
  4349. */
  4350. goToFrame(frame: number): AnimationGroup;
  4351. /**
  4352. * Dispose all associated resources
  4353. */
  4354. dispose(): void;
  4355. private _checkAnimationGroupEnded(animatable);
  4356. }
  4357. }
  4358. declare module BABYLON {
  4359. /**
  4360. * Class used to override all child animations of a given target
  4361. */
  4362. class AnimationPropertiesOverride {
  4363. /**
  4364. * Gets or sets a value indicating if animation blending must be used
  4365. */
  4366. enableBlending: boolean;
  4367. /**
  4368. * Gets or sets the blending speed to use when enableBlending is true
  4369. */
  4370. blendingSpeed: number;
  4371. /**
  4372. * Gets or sets the default loop mode to use
  4373. */
  4374. loopMode: number;
  4375. }
  4376. }
  4377. declare module BABYLON {
  4378. interface IEasingFunction {
  4379. ease(gradient: number): number;
  4380. }
  4381. class EasingFunction implements IEasingFunction {
  4382. private static _EASINGMODE_EASEIN;
  4383. private static _EASINGMODE_EASEOUT;
  4384. private static _EASINGMODE_EASEINOUT;
  4385. static readonly EASINGMODE_EASEIN: number;
  4386. static readonly EASINGMODE_EASEOUT: number;
  4387. static readonly EASINGMODE_EASEINOUT: number;
  4388. private _easingMode;
  4389. setEasingMode(easingMode: number): void;
  4390. getEasingMode(): number;
  4391. easeInCore(gradient: number): number;
  4392. ease(gradient: number): number;
  4393. }
  4394. class CircleEase extends EasingFunction implements IEasingFunction {
  4395. easeInCore(gradient: number): number;
  4396. }
  4397. class BackEase extends EasingFunction implements IEasingFunction {
  4398. amplitude: number;
  4399. constructor(amplitude?: number);
  4400. easeInCore(gradient: number): number;
  4401. }
  4402. class BounceEase extends EasingFunction implements IEasingFunction {
  4403. bounces: number;
  4404. bounciness: number;
  4405. constructor(bounces?: number, bounciness?: number);
  4406. easeInCore(gradient: number): number;
  4407. }
  4408. class CubicEase extends EasingFunction implements IEasingFunction {
  4409. easeInCore(gradient: number): number;
  4410. }
  4411. class ElasticEase extends EasingFunction implements IEasingFunction {
  4412. oscillations: number;
  4413. springiness: number;
  4414. constructor(oscillations?: number, springiness?: number);
  4415. easeInCore(gradient: number): number;
  4416. }
  4417. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4418. exponent: number;
  4419. constructor(exponent?: number);
  4420. easeInCore(gradient: number): number;
  4421. }
  4422. class PowerEase extends EasingFunction implements IEasingFunction {
  4423. power: number;
  4424. constructor(power?: number);
  4425. easeInCore(gradient: number): number;
  4426. }
  4427. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4428. easeInCore(gradient: number): number;
  4429. }
  4430. class QuarticEase extends EasingFunction implements IEasingFunction {
  4431. easeInCore(gradient: number): number;
  4432. }
  4433. class QuinticEase extends EasingFunction implements IEasingFunction {
  4434. easeInCore(gradient: number): number;
  4435. }
  4436. class SineEase extends EasingFunction implements IEasingFunction {
  4437. easeInCore(gradient: number): number;
  4438. }
  4439. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4440. x1: number;
  4441. y1: number;
  4442. x2: number;
  4443. y2: number;
  4444. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4445. easeInCore(gradient: number): number;
  4446. }
  4447. }
  4448. declare module BABYLON {
  4449. /**
  4450. * Defines a runtime animation
  4451. */
  4452. class RuntimeAnimation {
  4453. private _events;
  4454. /**
  4455. * The current frame of the runtime animation
  4456. */
  4457. private _currentFrame;
  4458. /**
  4459. * The animation used by the runtime animation
  4460. */
  4461. private _animation;
  4462. /**
  4463. * The target of the runtime animation
  4464. */
  4465. private _target;
  4466. /**
  4467. * The initiating animatable
  4468. */
  4469. private _host;
  4470. /**
  4471. * The original value of the runtime animation
  4472. */
  4473. private _originalValue;
  4474. /**
  4475. * The original blend value of the runtime animation
  4476. */
  4477. private _originalBlendValue;
  4478. /**
  4479. * The offsets cache of the runtime animation
  4480. */
  4481. private _offsetsCache;
  4482. /**
  4483. * The high limits cache of the runtime animation
  4484. */
  4485. private _highLimitsCache;
  4486. /**
  4487. * Specifies if the runtime animation has been stopped
  4488. */
  4489. private _stopped;
  4490. /**
  4491. * The blending factor of the runtime animation
  4492. */
  4493. private _blendingFactor;
  4494. /**
  4495. * The BabylonJS scene
  4496. */
  4497. private _scene;
  4498. /**
  4499. * The current value of the runtime animation
  4500. */
  4501. private _currentValue;
  4502. /** @hidden */
  4503. _workValue: any;
  4504. /**
  4505. * The active target of the runtime animation
  4506. */
  4507. private _activeTarget;
  4508. /**
  4509. * The target path of the runtime animation
  4510. */
  4511. private _targetPath;
  4512. /**
  4513. * The weight of the runtime animation
  4514. */
  4515. private _weight;
  4516. /**
  4517. * The ratio offset of the runtime animation
  4518. */
  4519. private _ratioOffset;
  4520. /**
  4521. * The previous delay of the runtime animation
  4522. */
  4523. private _previousDelay;
  4524. /**
  4525. * The previous ratio of the runtime animation
  4526. */
  4527. private _previousRatio;
  4528. /**
  4529. * Gets the current frame of the runtime animation
  4530. */
  4531. readonly currentFrame: number;
  4532. /**
  4533. * Gets the weight of the runtime animation
  4534. */
  4535. readonly weight: number;
  4536. /**
  4537. * Gets the current value of the runtime animation
  4538. */
  4539. readonly currentValue: any;
  4540. /**
  4541. * Gets the target path of the runtime animation
  4542. */
  4543. readonly targetPath: string;
  4544. /**
  4545. * Gets the actual target of the runtime animation
  4546. */
  4547. readonly target: any;
  4548. /**
  4549. * Create a new RuntimeAnimation object
  4550. * @param target defines the target of the animation
  4551. * @param animation defines the source animation object
  4552. * @param scene defines the hosting scene
  4553. * @param host defines the initiating Animatable
  4554. */
  4555. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4556. /**
  4557. * Gets the animation from the runtime animation
  4558. */
  4559. readonly animation: Animation;
  4560. /**
  4561. * Resets the runtime animation to the beginning
  4562. * @param restoreOriginal defines whether to restore the target property to the original value
  4563. */
  4564. reset(restoreOriginal?: boolean): void;
  4565. /**
  4566. * Specifies if the runtime animation is stopped
  4567. * @returns Boolean specifying if the runtime animation is stopped
  4568. */
  4569. isStopped(): boolean;
  4570. /**
  4571. * Disposes of the runtime animation
  4572. */
  4573. dispose(): void;
  4574. /**
  4575. * Interpolates the animation from the current frame
  4576. * @param currentFrame The frame to interpolate the animation to
  4577. * @param repeatCount The number of times that the animation should loop
  4578. * @param loopMode The type of looping mode to use
  4579. * @param offsetValue Animation offset value
  4580. * @param highLimitValue The high limit value
  4581. * @returns The interpolated value
  4582. */
  4583. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4584. /**
  4585. * Apply the interpolated value to the target
  4586. * @param currentValue defines the value computed by the animation
  4587. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4588. */
  4589. setValue(currentValue: any, weight?: number): void;
  4590. private _setValue(target, currentValue, weight, targetIndex?);
  4591. /**
  4592. * Gets the loop pmode of the runtime animation
  4593. * @returns Loop Mode
  4594. */
  4595. private _getCorrectLoopMode();
  4596. /**
  4597. * Move the current animation to a given frame
  4598. * @param frame defines the frame to move to
  4599. */
  4600. goToFrame(frame: number): void;
  4601. /**
  4602. * @hidden Internal use only
  4603. */
  4604. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4605. /**
  4606. * Execute the current animation
  4607. * @param delay defines the delay to add to the current frame
  4608. * @param from defines the lower bound of the animation range
  4609. * @param to defines the upper bound of the animation range
  4610. * @param loop defines if the current animation must loop
  4611. * @param speedRatio defines the current speed ratio
  4612. * @param weight defines the weight of the animation (default is -1 so no weight)
  4613. * @returns a boolean indicating if the animation has ended
  4614. */
  4615. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * Interface used to define a behavior
  4621. */
  4622. interface Behavior<T> {
  4623. /** gets or sets behavior's name */
  4624. name: string;
  4625. /**
  4626. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4627. */
  4628. init(): void;
  4629. /**
  4630. * Called when the behavior is attached to a target
  4631. * @param target defines the target where the behavior is attached to
  4632. */
  4633. attach(target: T): void;
  4634. /**
  4635. * Called when the behavior is detached from its target
  4636. */
  4637. detach(): void;
  4638. }
  4639. /**
  4640. * Interface implemented by classes supporting behaviors
  4641. */
  4642. interface IBehaviorAware<T> {
  4643. /**
  4644. * Attach a behavior
  4645. * @param behavior defines the behavior to attach
  4646. * @returns the current host
  4647. */
  4648. addBehavior(behavior: Behavior<T>): T;
  4649. /**
  4650. * Remove a behavior from the current object
  4651. * @param behavior defines the behavior to detach
  4652. * @returns the current host
  4653. */
  4654. removeBehavior(behavior: Behavior<T>): T;
  4655. /**
  4656. * Gets a behavior using its name to search
  4657. * @param name defines the name to search
  4658. * @returns the behavior or null if not found
  4659. */
  4660. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4661. }
  4662. }
  4663. declare module BABYLON {
  4664. /**
  4665. * Class used to store bone information
  4666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4667. */
  4668. class Bone extends Node {
  4669. /**
  4670. * defines the bone name
  4671. */
  4672. name: string;
  4673. private static _tmpVecs;
  4674. private static _tmpQuat;
  4675. private static _tmpMats;
  4676. /**
  4677. * Gets the list of child bones
  4678. */
  4679. children: Bone[];
  4680. /** Gets the animations associated with this bone */
  4681. animations: Animation[];
  4682. /**
  4683. * Gets or sets bone length
  4684. */
  4685. length: number;
  4686. /**
  4687. * @hidden Internal only
  4688. * Set this value to map this bone to a different index in the transform matrices
  4689. * Set this value to -1 to exclude the bone from the transform matrices
  4690. */
  4691. _index: Nullable<number>;
  4692. private _skeleton;
  4693. private _localMatrix;
  4694. private _restPose;
  4695. private _baseMatrix;
  4696. private _absoluteTransform;
  4697. private _invertedAbsoluteTransform;
  4698. private _parent;
  4699. private _scalingDeterminant;
  4700. private _worldTransform;
  4701. private _localScaling;
  4702. private _localRotation;
  4703. private _localPosition;
  4704. private _needToDecompose;
  4705. private _needToCompose;
  4706. /** @hidden */
  4707. /** @hidden */
  4708. _matrix: Matrix;
  4709. /**
  4710. * Create a new bone
  4711. * @param name defines the bone name
  4712. * @param skeleton defines the parent skeleton
  4713. * @param parentBone defines the parent (can be null if the bone is the root)
  4714. * @param localMatrix defines the local matrix
  4715. * @param restPose defines the rest pose matrix
  4716. * @param baseMatrix defines the base matrix
  4717. * @param index defines index of the bone in the hiearchy
  4718. */
  4719. constructor(
  4720. /**
  4721. * defines the bone name
  4722. */
  4723. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4724. /**
  4725. * Gets the parent skeleton
  4726. * @returns a skeleton
  4727. */
  4728. getSkeleton(): Skeleton;
  4729. /**
  4730. * Gets parent bone
  4731. * @returns a bone or null if the bone is the root of the bone hierarchy
  4732. */
  4733. getParent(): Nullable<Bone>;
  4734. /**
  4735. * Sets the parent bone
  4736. * @param parent defines the parent (can be null if the bone is the root)
  4737. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4738. */
  4739. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4740. /**
  4741. * Gets the local matrix
  4742. * @returns a matrix
  4743. */
  4744. getLocalMatrix(): Matrix;
  4745. /**
  4746. * Gets the base matrix (initial matrix which remains unchanged)
  4747. * @returns a matrix
  4748. */
  4749. getBaseMatrix(): Matrix;
  4750. /**
  4751. * Gets the rest pose matrix
  4752. * @returns a matrix
  4753. */
  4754. getRestPose(): Matrix;
  4755. /**
  4756. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4757. */
  4758. getWorldMatrix(): Matrix;
  4759. /**
  4760. * Sets the local matrix to rest pose matrix
  4761. */
  4762. returnToRest(): void;
  4763. /**
  4764. * Gets the inverse of the absolute transform matrix.
  4765. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4766. * @returns a matrix
  4767. */
  4768. getInvertedAbsoluteTransform(): Matrix;
  4769. /**
  4770. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4771. * @returns a matrix
  4772. */
  4773. getAbsoluteTransform(): Matrix;
  4774. /** Gets or sets current position (in local space) */
  4775. position: Vector3;
  4776. /** Gets or sets current rotation (in local space) */
  4777. rotation: Vector3;
  4778. /** Gets or sets current rotation quaternion (in local space) */
  4779. rotationQuaternion: Quaternion;
  4780. /** Gets or sets current scaling (in local space) */
  4781. scaling: Vector3;
  4782. /**
  4783. * Gets the animation properties override
  4784. */
  4785. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4786. private _decompose();
  4787. private _compose();
  4788. /**
  4789. * Update the base and local matrices
  4790. * @param matrix defines the new base or local matrix
  4791. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4792. * @param updateLocalMatrix defines if the local matrix should be updated
  4793. */
  4794. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4795. /** @hidden */
  4796. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4797. /**
  4798. * Flag the bone as dirty (Forcing it to update everything)
  4799. */
  4800. markAsDirty(): void;
  4801. private _markAsDirtyAndCompose();
  4802. private _markAsDirtyAndDecompose();
  4803. /**
  4804. * Copy an animation range from another bone
  4805. * @param source defines the source bone
  4806. * @param rangeName defines the range name to copy
  4807. * @param frameOffset defines the frame offset
  4808. * @param rescaleAsRequired defines if rescaling must be applied if required
  4809. * @param skelDimensionsRatio defines the scaling ratio
  4810. * @returns true if operation was successful
  4811. */
  4812. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4813. /**
  4814. * Translate the bone in local or world space
  4815. * @param vec The amount to translate the bone
  4816. * @param space The space that the translation is in
  4817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4818. */
  4819. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4820. /**
  4821. * Set the postion of the bone in local or world space
  4822. * @param position The position to set the bone
  4823. * @param space The space that the position is in
  4824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4825. */
  4826. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4827. /**
  4828. * Set the absolute position of the bone (world space)
  4829. * @param position The position to set the bone
  4830. * @param mesh The mesh that this bone is attached to
  4831. */
  4832. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4833. /**
  4834. * Scale the bone on the x, y and z axes (in local space)
  4835. * @param x The amount to scale the bone on the x axis
  4836. * @param y The amount to scale the bone on the y axis
  4837. * @param z The amount to scale the bone on the z axis
  4838. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4839. */
  4840. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4841. /**
  4842. * Set the bone scaling in local space
  4843. * @param scale defines the scaling vector
  4844. */
  4845. setScale(scale: Vector3): void;
  4846. /**
  4847. * Gets the current scaling in local space
  4848. * @returns the current scaling vector
  4849. */
  4850. getScale(): Vector3;
  4851. /**
  4852. * Gets the current scaling in local space and stores it in a target vector
  4853. * @param result defines the target vector
  4854. */
  4855. getScaleToRef(result: Vector3): void;
  4856. /**
  4857. * Set the yaw, pitch, and roll of the bone in local or world space
  4858. * @param yaw The rotation of the bone on the y axis
  4859. * @param pitch The rotation of the bone on the x axis
  4860. * @param roll The rotation of the bone on the z axis
  4861. * @param space The space that the axes of rotation are in
  4862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4863. */
  4864. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4865. /**
  4866. * Add a rotation to the bone on an axis in local or world space
  4867. * @param axis The axis to rotate the bone on
  4868. * @param amount The amount to rotate the bone
  4869. * @param space The space that the axis is in
  4870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4871. */
  4872. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4873. /**
  4874. * Set the rotation of the bone to a particular axis angle in local or world space
  4875. * @param axis The axis to rotate the bone on
  4876. * @param angle The angle that the bone should be rotated to
  4877. * @param space The space that the axis is in
  4878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4879. */
  4880. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4881. /**
  4882. * Set the euler rotation of the bone in local of world space
  4883. * @param rotation The euler rotation that the bone should be set to
  4884. * @param space The space that the rotation is in
  4885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4886. */
  4887. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4888. /**
  4889. * Set the quaternion rotation of the bone in local of world space
  4890. * @param quat The quaternion rotation that the bone should be set to
  4891. * @param space The space that the rotation is in
  4892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4893. */
  4894. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4895. /**
  4896. * Set the rotation matrix of the bone in local of world space
  4897. * @param rotMat The rotation matrix that the bone should be set to
  4898. * @param space The space that the rotation is in
  4899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4900. */
  4901. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4902. private _rotateWithMatrix(rmat, space?, mesh?);
  4903. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4904. /**
  4905. * Get the position of the bone in local or world space
  4906. * @param space The space that the returned position is in
  4907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4908. * @returns The position of the bone
  4909. */
  4910. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4911. /**
  4912. * Copy the position of the bone to a vector3 in local or world space
  4913. * @param space The space that the returned position is in
  4914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4915. * @param result The vector3 to copy the position to
  4916. */
  4917. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4918. /**
  4919. * Get the absolute position of the bone (world space)
  4920. * @param mesh The mesh that this bone is attached to
  4921. * @returns The absolute position of the bone
  4922. */
  4923. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4924. /**
  4925. * Copy the absolute position of the bone (world space) to the result param
  4926. * @param mesh The mesh that this bone is attached to
  4927. * @param result The vector3 to copy the absolute position to
  4928. */
  4929. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4930. /**
  4931. * Compute the absolute transforms of this bone and its children
  4932. */
  4933. computeAbsoluteTransforms(): void;
  4934. /**
  4935. * Get the world direction from an axis that is in the local space of the bone
  4936. * @param localAxis The local direction that is used to compute the world direction
  4937. * @param mesh The mesh that this bone is attached to
  4938. * @returns The world direction
  4939. */
  4940. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4941. /**
  4942. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4943. * @param localAxis The local direction that is used to compute the world direction
  4944. * @param mesh The mesh that this bone is attached to
  4945. * @param result The vector3 that the world direction will be copied to
  4946. */
  4947. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4948. /**
  4949. * Get the euler rotation of the bone in local or world space
  4950. * @param space The space that the rotation should be in
  4951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4952. * @returns The euler rotation
  4953. */
  4954. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4955. /**
  4956. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4957. * @param space The space that the rotation should be in
  4958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4959. * @param result The vector3 that the rotation should be copied to
  4960. */
  4961. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4962. /**
  4963. * Get the quaternion rotation of the bone in either local or world space
  4964. * @param space The space that the rotation should be in
  4965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4966. * @returns The quaternion rotation
  4967. */
  4968. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4969. /**
  4970. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4971. * @param space The space that the rotation should be in
  4972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4973. * @param result The quaternion that the rotation should be copied to
  4974. */
  4975. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4976. /**
  4977. * Get the rotation matrix of the bone in local or world space
  4978. * @param space The space that the rotation should be in
  4979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4980. * @returns The rotation matrix
  4981. */
  4982. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4983. /**
  4984. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4985. * @param space The space that the rotation should be in
  4986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4987. * @param result The quaternion that the rotation should be copied to
  4988. */
  4989. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4990. /**
  4991. * Get the world position of a point that is in the local space of the bone
  4992. * @param position The local position
  4993. * @param mesh The mesh that this bone is attached to
  4994. * @returns The world position
  4995. */
  4996. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4997. /**
  4998. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4999. * @param position The local position
  5000. * @param mesh The mesh that this bone is attached to
  5001. * @param result The vector3 that the world position should be copied to
  5002. */
  5003. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5004. /**
  5005. * Get the local position of a point that is in world space
  5006. * @param position The world position
  5007. * @param mesh The mesh that this bone is attached to
  5008. * @returns The local position
  5009. */
  5010. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5011. /**
  5012. * Get the local position of a point that is in world space and copy it to the result param
  5013. * @param position The world position
  5014. * @param mesh The mesh that this bone is attached to
  5015. * @param result The vector3 that the local position should be copied to
  5016. */
  5017. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5018. }
  5019. }
  5020. declare module BABYLON {
  5021. /**
  5022. * Class used to apply inverse kinematics to bones
  5023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5024. */
  5025. class BoneIKController {
  5026. private static _tmpVecs;
  5027. private static _tmpQuat;
  5028. private static _tmpMats;
  5029. /**
  5030. * Gets or sets the target mesh
  5031. */
  5032. targetMesh: AbstractMesh;
  5033. /** Gets or sets the mesh used as pole */
  5034. poleTargetMesh: AbstractMesh;
  5035. /**
  5036. * Gets or sets the bone used as pole
  5037. */
  5038. poleTargetBone: Nullable<Bone>;
  5039. /**
  5040. * Gets or sets the target position
  5041. */
  5042. targetPosition: Vector3;
  5043. /**
  5044. * Gets or sets the pole target position
  5045. */
  5046. poleTargetPosition: Vector3;
  5047. /**
  5048. * Gets or sets the pole target local offset
  5049. */
  5050. poleTargetLocalOffset: Vector3;
  5051. /**
  5052. * Gets or sets the pole angle
  5053. */
  5054. poleAngle: number;
  5055. /**
  5056. * Gets or sets the mesh associated with the controller
  5057. */
  5058. mesh: AbstractMesh;
  5059. /**
  5060. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  5061. */
  5062. slerpAmount: number;
  5063. private _bone1Quat;
  5064. private _bone1Mat;
  5065. private _bone2Ang;
  5066. private _bone1;
  5067. private _bone2;
  5068. private _bone1Length;
  5069. private _bone2Length;
  5070. private _maxAngle;
  5071. private _maxReach;
  5072. private _rightHandedSystem;
  5073. private _bendAxis;
  5074. private _slerping;
  5075. private _adjustRoll;
  5076. /**
  5077. * Gets or sets maximum allowed angle
  5078. */
  5079. maxAngle: number;
  5080. /**
  5081. * Creates a new BoneIKController
  5082. * @param mesh defines the mesh to control
  5083. * @param bone defines the bone to control
  5084. * @param options defines options to set up the controller
  5085. */
  5086. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5087. targetMesh?: AbstractMesh;
  5088. poleTargetMesh?: AbstractMesh;
  5089. poleTargetBone?: Bone;
  5090. poleTargetLocalOffset?: Vector3;
  5091. poleAngle?: number;
  5092. bendAxis?: Vector3;
  5093. maxAngle?: number;
  5094. slerpAmount?: number;
  5095. });
  5096. private _setMaxAngle(ang);
  5097. /**
  5098. * Force the controller to update the bones
  5099. */
  5100. update(): void;
  5101. }
  5102. }
  5103. declare module BABYLON {
  5104. /**
  5105. * Class used to make a bone look toward a point in space
  5106. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5107. */
  5108. class BoneLookController {
  5109. private static _tmpVecs;
  5110. private static _tmpQuat;
  5111. private static _tmpMats;
  5112. /**
  5113. * The target Vector3 that the bone will look at
  5114. */
  5115. target: Vector3;
  5116. /**
  5117. * The mesh that the bone is attached to
  5118. */
  5119. mesh: AbstractMesh;
  5120. /**
  5121. * The bone that will be looking to the target
  5122. */
  5123. bone: Bone;
  5124. /**
  5125. * The up axis of the coordinate system that is used when the bone is rotated
  5126. */
  5127. upAxis: Vector3;
  5128. /**
  5129. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5130. */
  5131. upAxisSpace: Space;
  5132. /**
  5133. * Used to make an adjustment to the yaw of the bone
  5134. */
  5135. adjustYaw: number;
  5136. /**
  5137. * Used to make an adjustment to the pitch of the bone
  5138. */
  5139. adjustPitch: number;
  5140. /**
  5141. * Used to make an adjustment to the roll of the bone
  5142. */
  5143. adjustRoll: number;
  5144. /**
  5145. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  5146. */
  5147. slerpAmount: number;
  5148. private _minYaw;
  5149. private _maxYaw;
  5150. private _minPitch;
  5151. private _maxPitch;
  5152. private _minYawSin;
  5153. private _minYawCos;
  5154. private _maxYawSin;
  5155. private _maxYawCos;
  5156. private _midYawConstraint;
  5157. private _minPitchTan;
  5158. private _maxPitchTan;
  5159. private _boneQuat;
  5160. private _slerping;
  5161. private _transformYawPitch;
  5162. private _transformYawPitchInv;
  5163. private _firstFrameSkipped;
  5164. private _yawRange;
  5165. private _fowardAxis;
  5166. /**
  5167. * Gets or sets the minimum yaw angle that the bone can look to
  5168. */
  5169. minYaw: number;
  5170. /**
  5171. * Gets or sets the maximum yaw angle that the bone can look to
  5172. */
  5173. maxYaw: number;
  5174. /**
  5175. * Gets or sets the minimum pitch angle that the bone can look to
  5176. */
  5177. minPitch: number;
  5178. /**
  5179. * Gets or sets the maximum pitch angle that the bone can look to
  5180. */
  5181. maxPitch: number;
  5182. /**
  5183. * Create a BoneLookController
  5184. * @param mesh the mesh that the bone belongs to
  5185. * @param bone the bone that will be looking to the target
  5186. * @param target the target Vector3 to look at
  5187. * @param settings optional settings:
  5188. * * maxYaw: the maximum angle the bone will yaw to
  5189. * * minYaw: the minimum angle the bone will yaw to
  5190. * * maxPitch: the maximum angle the bone will pitch to
  5191. * * minPitch: the minimum angle the bone will yaw to
  5192. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5193. * * upAxis: the up axis of the coordinate system
  5194. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5195. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5196. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5197. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5198. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5199. * * adjustRoll: used to make an adjustment to the roll of the bone
  5200. **/
  5201. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5202. maxYaw?: number;
  5203. minYaw?: number;
  5204. maxPitch?: number;
  5205. minPitch?: number;
  5206. slerpAmount?: number;
  5207. upAxis?: Vector3;
  5208. upAxisSpace?: Space;
  5209. yawAxis?: Vector3;
  5210. pitchAxis?: Vector3;
  5211. adjustYaw?: number;
  5212. adjustPitch?: number;
  5213. adjustRoll?: number;
  5214. });
  5215. /**
  5216. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5217. */
  5218. update(): void;
  5219. private _getAngleDiff(ang1, ang2);
  5220. private _getAngleBetween(ang1, ang2);
  5221. private _isAngleBetween(ang, ang1, ang2);
  5222. }
  5223. }
  5224. declare module BABYLON {
  5225. /**
  5226. * Class used to handle skinning animations
  5227. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5228. */
  5229. class Skeleton implements IAnimatable {
  5230. /** defines the skeleton name */
  5231. name: string;
  5232. /** defines the skeleton Id */
  5233. id: string;
  5234. /**
  5235. * Gets the list of child bones
  5236. */
  5237. bones: Bone[];
  5238. /**
  5239. * Gets an estimate of the dimension of the skeleton at rest
  5240. */
  5241. dimensionsAtRest: Vector3;
  5242. /**
  5243. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5244. */
  5245. needInitialSkinMatrix: boolean;
  5246. /**
  5247. * Gets the list of animations attached to this skeleton
  5248. */
  5249. animations: Array<Animation>;
  5250. private _scene;
  5251. private _isDirty;
  5252. private _transformMatrices;
  5253. private _meshesWithPoseMatrix;
  5254. private _animatables;
  5255. private _identity;
  5256. private _synchronizedWithMesh;
  5257. private _ranges;
  5258. private _lastAbsoluteTransformsUpdateId;
  5259. /**
  5260. * Specifies if the skeleton should be serialized
  5261. */
  5262. doNotSerialize: boolean;
  5263. private _animationPropertiesOverride;
  5264. /**
  5265. * Gets or sets the animation properties override
  5266. */
  5267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5268. /**
  5269. * An observable triggered before computing the skeleton's matrices
  5270. */
  5271. onBeforeComputeObservable: Observable<Skeleton>;
  5272. /**
  5273. * Creates a new skeleton
  5274. * @param name defines the skeleton name
  5275. * @param id defines the skeleton Id
  5276. * @param scene defines the hosting scene
  5277. */
  5278. constructor(
  5279. /** defines the skeleton name */
  5280. name: string,
  5281. /** defines the skeleton Id */
  5282. id: string, scene: Scene);
  5283. /**
  5284. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5285. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5286. * @returns a Float32Array containing matrices data
  5287. */
  5288. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5289. /**
  5290. * Gets the current hosting scene
  5291. * @returns a scene object
  5292. */
  5293. getScene(): Scene;
  5294. /**
  5295. * Gets a string representing the current skeleton data
  5296. * @param fullDetails defines a boolean indicating if we want a verbose version
  5297. * @returns a string representing the current skeleton data
  5298. */
  5299. toString(fullDetails?: boolean): string;
  5300. /**
  5301. * Get bone's index searching by name
  5302. * @param name defines bone's name to search for
  5303. * @return the indice of the bone. Returns -1 if not found
  5304. */
  5305. getBoneIndexByName(name: string): number;
  5306. /**
  5307. * Creater a new animation range
  5308. * @param name defines the name of the range
  5309. * @param from defines the start key
  5310. * @param to defines the end key
  5311. */
  5312. createAnimationRange(name: string, from: number, to: number): void;
  5313. /**
  5314. * Delete a specific animation range
  5315. * @param name defines the name of the range
  5316. * @param deleteFrames defines if frames must be removed as well
  5317. */
  5318. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5319. /**
  5320. * Gets a specific animation range
  5321. * @param name defines the name of the range to look for
  5322. * @returns the requested animation range or null if not found
  5323. */
  5324. getAnimationRange(name: string): Nullable<AnimationRange>;
  5325. /**
  5326. * Gets the list of all animation ranges defined on this skeleton
  5327. * @returns an array
  5328. */
  5329. getAnimationRanges(): Nullable<AnimationRange>[];
  5330. /**
  5331. * Copy animation range from a source skeleton.
  5332. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5333. * @param source defines the source skeleton
  5334. * @param name defines the name of the range to copy
  5335. * @param rescaleAsRequired defines if rescaling must be applied if required
  5336. * @returns true if operation was successful
  5337. */
  5338. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5339. /**
  5340. * Forces the skeleton to go to rest pose
  5341. */
  5342. returnToRest(): void;
  5343. private _getHighestAnimationFrame();
  5344. /**
  5345. * Begin a specific animation range
  5346. * @param name defines the name of the range to start
  5347. * @param loop defines if looping must be turned on (false by default)
  5348. * @param speedRatio defines the speed ratio to apply (1 by default)
  5349. * @param onAnimationEnd defines a callback which will be called when animation will end
  5350. * @returns a new animatable
  5351. */
  5352. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5353. /** @hidden */
  5354. _markAsDirty(): void;
  5355. /** @hidden */
  5356. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5357. /** @hidden */
  5358. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5359. /** @hidden */
  5360. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5361. /**
  5362. * Build all resources required to render a skeleton
  5363. */
  5364. prepare(): void;
  5365. /**
  5366. * Gets the list of animatables currently running for this skeleton
  5367. * @returns an array of animatables
  5368. */
  5369. getAnimatables(): IAnimatable[];
  5370. /**
  5371. * Clone the current skeleton
  5372. * @param name defines the name of the new skeleton
  5373. * @param id defines the id of the enw skeleton
  5374. * @returns the new skeleton
  5375. */
  5376. clone(name: string, id: string): Skeleton;
  5377. /**
  5378. * Enable animation blending for this skeleton
  5379. * @param blendingSpeed defines the blending speed to apply
  5380. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5381. */
  5382. enableBlending(blendingSpeed?: number): void;
  5383. /**
  5384. * Releases all resources associated with the current skeleton
  5385. */
  5386. dispose(): void;
  5387. /**
  5388. * Serialize the skeleton in a JSON object
  5389. * @returns a JSON object
  5390. */
  5391. serialize(): any;
  5392. /**
  5393. * Creates a new skeleton from serialized data
  5394. * @param parsedSkeleton defines the serialized data
  5395. * @param scene defines the hosting scene
  5396. * @returns a new skeleton
  5397. */
  5398. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5399. /**
  5400. * Compute all node absolute transforms
  5401. * @param forceUpdate defines if computation must be done even if cache is up to date
  5402. */
  5403. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5404. /**
  5405. * Gets the root pose matrix
  5406. * @returns a matrix
  5407. */
  5408. getPoseMatrix(): Nullable<Matrix>;
  5409. /**
  5410. * Sorts bones per internal index
  5411. */
  5412. sortBones(): void;
  5413. private _sortBones(index, bones, visited);
  5414. }
  5415. }
  5416. declare module BABYLON {
  5417. class ArcRotateCamera extends TargetCamera {
  5418. alpha: number;
  5419. beta: number;
  5420. radius: number;
  5421. protected _target: Vector3;
  5422. protected _targetHost: Nullable<AbstractMesh>;
  5423. target: Vector3;
  5424. inertialAlphaOffset: number;
  5425. inertialBetaOffset: number;
  5426. inertialRadiusOffset: number;
  5427. lowerAlphaLimit: Nullable<number>;
  5428. upperAlphaLimit: Nullable<number>;
  5429. lowerBetaLimit: number;
  5430. upperBetaLimit: number;
  5431. lowerRadiusLimit: Nullable<number>;
  5432. upperRadiusLimit: Nullable<number>;
  5433. inertialPanningX: number;
  5434. inertialPanningY: number;
  5435. pinchToPanMaxDistance: number;
  5436. panningDistanceLimit: Nullable<number>;
  5437. panningOriginTarget: Vector3;
  5438. panningInertia: number;
  5439. angularSensibilityX: number;
  5440. angularSensibilityY: number;
  5441. pinchPrecision: number;
  5442. pinchDeltaPercentage: number;
  5443. panningSensibility: number;
  5444. keysUp: number[];
  5445. keysDown: number[];
  5446. keysLeft: number[];
  5447. keysRight: number[];
  5448. wheelPrecision: number;
  5449. wheelDeltaPercentage: number;
  5450. zoomOnFactor: number;
  5451. targetScreenOffset: Vector2;
  5452. allowUpsideDown: boolean;
  5453. _viewMatrix: Matrix;
  5454. _useCtrlForPanning: boolean;
  5455. _panningMouseButton: number;
  5456. inputs: ArcRotateCameraInputsManager;
  5457. _reset: () => void;
  5458. panningAxis: Vector3;
  5459. protected _localDirection: Vector3;
  5460. protected _transformedDirection: Vector3;
  5461. private _bouncingBehavior;
  5462. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5463. useBouncingBehavior: boolean;
  5464. private _framingBehavior;
  5465. readonly framingBehavior: Nullable<FramingBehavior>;
  5466. useFramingBehavior: boolean;
  5467. private _autoRotationBehavior;
  5468. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5469. useAutoRotationBehavior: boolean;
  5470. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5471. onCollide: (collidedMesh: AbstractMesh) => void;
  5472. checkCollisions: boolean;
  5473. collisionRadius: Vector3;
  5474. protected _collider: Collider;
  5475. protected _previousPosition: Vector3;
  5476. protected _collisionVelocity: Vector3;
  5477. protected _newPosition: Vector3;
  5478. protected _previousAlpha: number;
  5479. protected _previousBeta: number;
  5480. protected _previousRadius: number;
  5481. protected _collisionTriggered: boolean;
  5482. protected _targetBoundingCenter: Nullable<Vector3>;
  5483. private _computationVector;
  5484. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5485. _initCache(): void;
  5486. _updateCache(ignoreParentClass?: boolean): void;
  5487. protected _getTargetPosition(): Vector3;
  5488. /**
  5489. * Store current camera state (fov, position, etc..)
  5490. */
  5491. private _storedAlpha;
  5492. private _storedBeta;
  5493. private _storedRadius;
  5494. private _storedTarget;
  5495. storeState(): Camera;
  5496. /**
  5497. * Restored camera state. You must call storeState() first
  5498. */
  5499. _restoreStateValues(): boolean;
  5500. _isSynchronizedViewMatrix(): boolean;
  5501. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5502. detachControl(element: HTMLElement): void;
  5503. _checkInputs(): void;
  5504. protected _checkLimits(): void;
  5505. rebuildAnglesAndRadius(): void;
  5506. setPosition(position: Vector3): void;
  5507. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5508. _getViewMatrix(): Matrix;
  5509. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5510. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5511. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5512. min: Vector3;
  5513. max: Vector3;
  5514. distance: number;
  5515. }, doNotUpdateMaxZ?: boolean): void;
  5516. /**
  5517. * @override
  5518. * Override Camera.createRigCamera
  5519. */
  5520. createRigCamera(name: string, cameraIndex: number): Camera;
  5521. /**
  5522. * @override
  5523. * Override Camera._updateRigCameras
  5524. */
  5525. _updateRigCameras(): void;
  5526. dispose(): void;
  5527. getClassName(): string;
  5528. }
  5529. }
  5530. declare module BABYLON {
  5531. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5532. constructor(camera: ArcRotateCamera);
  5533. addMouseWheel(): ArcRotateCameraInputsManager;
  5534. addPointers(): ArcRotateCameraInputsManager;
  5535. addKeyboard(): ArcRotateCameraInputsManager;
  5536. addGamepad(): ArcRotateCameraInputsManager;
  5537. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5538. }
  5539. }
  5540. declare module BABYLON {
  5541. class Camera extends Node {
  5542. inputs: CameraInputsManager<Camera>;
  5543. private static _PERSPECTIVE_CAMERA;
  5544. private static _ORTHOGRAPHIC_CAMERA;
  5545. private static _FOVMODE_VERTICAL_FIXED;
  5546. private static _FOVMODE_HORIZONTAL_FIXED;
  5547. private static _RIG_MODE_NONE;
  5548. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5549. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5550. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5551. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5552. private static _RIG_MODE_VR;
  5553. private static _RIG_MODE_WEBVR;
  5554. static readonly PERSPECTIVE_CAMERA: number;
  5555. static readonly ORTHOGRAPHIC_CAMERA: number;
  5556. /**
  5557. * This is the default FOV mode for perspective cameras.
  5558. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5559. *
  5560. */
  5561. static readonly FOVMODE_VERTICAL_FIXED: number;
  5562. /**
  5563. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5564. *
  5565. */
  5566. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5567. static readonly RIG_MODE_NONE: number;
  5568. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5569. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5570. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5571. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5572. static readonly RIG_MODE_VR: number;
  5573. static readonly RIG_MODE_WEBVR: number;
  5574. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5575. static UseAlternateWebVRRendering: boolean;
  5576. position: Vector3;
  5577. /**
  5578. * The vector the camera should consider as up.
  5579. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5580. */
  5581. upVector: Vector3;
  5582. orthoLeft: Nullable<number>;
  5583. orthoRight: Nullable<number>;
  5584. orthoBottom: Nullable<number>;
  5585. orthoTop: Nullable<number>;
  5586. /**
  5587. * FOV is set in Radians. (default is 0.8)
  5588. */
  5589. fov: number;
  5590. minZ: number;
  5591. maxZ: number;
  5592. inertia: number;
  5593. mode: number;
  5594. isIntermediate: boolean;
  5595. viewport: Viewport;
  5596. /**
  5597. * Restricts the camera to viewing objects with the same layerMask.
  5598. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5599. */
  5600. layerMask: number;
  5601. /**
  5602. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5603. */
  5604. fovMode: number;
  5605. cameraRigMode: number;
  5606. interaxialDistance: number;
  5607. isStereoscopicSideBySide: boolean;
  5608. _cameraRigParams: any;
  5609. _rigCameras: Camera[];
  5610. _rigPostProcess: Nullable<PostProcess>;
  5611. protected _webvrViewMatrix: Matrix;
  5612. _skipRendering: boolean;
  5613. _alternateCamera: Camera;
  5614. customRenderTargets: RenderTargetTexture[];
  5615. onViewMatrixChangedObservable: Observable<Camera>;
  5616. onProjectionMatrixChangedObservable: Observable<Camera>;
  5617. onAfterCheckInputsObservable: Observable<Camera>;
  5618. onRestoreStateObservable: Observable<Camera>;
  5619. private _computedViewMatrix;
  5620. _projectionMatrix: Matrix;
  5621. private _doNotComputeProjectionMatrix;
  5622. private _worldMatrix;
  5623. _postProcesses: Nullable<PostProcess>[];
  5624. private _transformMatrix;
  5625. _activeMeshes: SmartArray<AbstractMesh>;
  5626. protected _globalPosition: Vector3;
  5627. private _frustumPlanes;
  5628. private _refreshFrustumPlanes;
  5629. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5630. private _storedFov;
  5631. private _stateStored;
  5632. /**
  5633. * Store current camera state (fov, position, etc..)
  5634. */
  5635. storeState(): Camera;
  5636. /**
  5637. * Restores the camera state values if it has been stored. You must call storeState() first
  5638. */
  5639. protected _restoreStateValues(): boolean;
  5640. /**
  5641. * Restored camera state. You must call storeState() first
  5642. */
  5643. restoreState(): boolean;
  5644. getClassName(): string;
  5645. /**
  5646. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5647. */
  5648. toString(fullDetails?: boolean): string;
  5649. readonly globalPosition: Vector3;
  5650. getActiveMeshes(): SmartArray<AbstractMesh>;
  5651. isActiveMesh(mesh: Mesh): boolean;
  5652. /**
  5653. * Is this camera ready to be used/rendered
  5654. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5655. * @return true if the camera is ready
  5656. */
  5657. isReady(completeCheck?: boolean): boolean;
  5658. _initCache(): void;
  5659. _updateCache(ignoreParentClass?: boolean): void;
  5660. _isSynchronized(): boolean;
  5661. _isSynchronizedViewMatrix(): boolean;
  5662. _isSynchronizedProjectionMatrix(): boolean;
  5663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5664. detachControl(element: HTMLElement): void;
  5665. update(): void;
  5666. _checkInputs(): void;
  5667. readonly rigCameras: Camera[];
  5668. readonly rigPostProcess: Nullable<PostProcess>;
  5669. /**
  5670. * Internal, gets the first post proces.
  5671. * @returns the first post process to be run on this camera.
  5672. */
  5673. _getFirstPostProcess(): Nullable<PostProcess>;
  5674. private _cascadePostProcessesToRigCams();
  5675. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5676. detachPostProcess(postProcess: PostProcess): void;
  5677. getWorldMatrix(): Matrix;
  5678. _getViewMatrix(): Matrix;
  5679. getViewMatrix(force?: boolean): Matrix;
  5680. freezeProjectionMatrix(projection?: Matrix): void;
  5681. unfreezeProjectionMatrix(): void;
  5682. getProjectionMatrix(force?: boolean): Matrix;
  5683. getTranformationMatrix(): Matrix;
  5684. private updateFrustumPlanes();
  5685. isInFrustum(target: ICullable): boolean;
  5686. isCompletelyInFrustum(target: ICullable): boolean;
  5687. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5688. /**
  5689. * Releases resources associated with this node.
  5690. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5691. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5692. */
  5693. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5694. readonly leftCamera: Nullable<FreeCamera>;
  5695. readonly rightCamera: Nullable<FreeCamera>;
  5696. getLeftTarget(): Nullable<Vector3>;
  5697. getRightTarget(): Nullable<Vector3>;
  5698. setCameraRigMode(mode: number, rigParams: any): void;
  5699. private _getVRProjectionMatrix();
  5700. protected _updateCameraRotationMatrix(): void;
  5701. protected _updateWebVRCameraRotationMatrix(): void;
  5702. /**
  5703. * This function MUST be overwritten by the different WebVR cameras available.
  5704. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5705. */
  5706. protected _getWebVRProjectionMatrix(): Matrix;
  5707. /**
  5708. * This function MUST be overwritten by the different WebVR cameras available.
  5709. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5710. */
  5711. protected _getWebVRViewMatrix(): Matrix;
  5712. setCameraRigParameter(name: string, value: any): void;
  5713. /**
  5714. * needs to be overridden by children so sub has required properties to be copied
  5715. */
  5716. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5717. /**
  5718. * May need to be overridden by children
  5719. */
  5720. _updateRigCameras(): void;
  5721. _setupInputs(): void;
  5722. serialize(): any;
  5723. clone(name: string): Camera;
  5724. getDirection(localAxis: Vector3): Vector3;
  5725. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5726. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5727. computeWorldMatrix(): Matrix;
  5728. static Parse(parsedCamera: any, scene: Scene): Camera;
  5729. }
  5730. }
  5731. declare module BABYLON {
  5732. var CameraInputTypes: {};
  5733. interface ICameraInput<TCamera extends Camera> {
  5734. camera: Nullable<TCamera>;
  5735. getClassName(): string;
  5736. getSimpleName(): string;
  5737. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5738. detachControl: (element: Nullable<HTMLElement>) => void;
  5739. checkInputs?: () => void;
  5740. }
  5741. interface CameraInputsMap<TCamera extends Camera> {
  5742. [name: string]: ICameraInput<TCamera>;
  5743. [idx: number]: ICameraInput<TCamera>;
  5744. }
  5745. class CameraInputsManager<TCamera extends Camera> {
  5746. attached: CameraInputsMap<TCamera>;
  5747. attachedElement: Nullable<HTMLElement>;
  5748. noPreventDefault: boolean;
  5749. camera: TCamera;
  5750. checkInputs: () => void;
  5751. constructor(camera: TCamera);
  5752. /**
  5753. * Add an input method to a camera.
  5754. * builtin inputs example: camera.inputs.addGamepad();
  5755. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5756. * @param input camera input method
  5757. */
  5758. add(input: ICameraInput<TCamera>): void;
  5759. /**
  5760. * Remove a specific input method from a camera
  5761. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5762. * @param inputToRemove camera input method
  5763. */
  5764. remove(inputToRemove: ICameraInput<TCamera>): void;
  5765. removeByType(inputType: string): void;
  5766. private _addCheckInputs(fn);
  5767. attachInput(input: ICameraInput<TCamera>): void;
  5768. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5769. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5770. rebuildInputCheck(): void;
  5771. /**
  5772. * Remove all attached input methods from a camera
  5773. */
  5774. clear(): void;
  5775. serialize(serializedCamera: any): void;
  5776. parse(parsedCamera: any): void;
  5777. }
  5778. }
  5779. declare module BABYLON {
  5780. /**
  5781. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5782. * being tilted forward or back and left or right.
  5783. */
  5784. class DeviceOrientationCamera extends FreeCamera {
  5785. private _initialQuaternion;
  5786. private _quaternionCache;
  5787. /**
  5788. * Creates a new device orientation camera
  5789. * @param name The name of the camera
  5790. * @param position The start position camera
  5791. * @param scene The scene the camera belongs to
  5792. */
  5793. constructor(name: string, position: Vector3, scene: Scene);
  5794. /**
  5795. * Gets the current instance class name ("DeviceOrientationCamera").
  5796. * This helps avoiding instanceof at run time.
  5797. * @returns the class name
  5798. */
  5799. getClassName(): string;
  5800. /**
  5801. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5802. */
  5803. _checkInputs(): void;
  5804. /**
  5805. * Reset the camera to its default orientation on the specified axis only.
  5806. * @param axis The axis to reset
  5807. */
  5808. resetToCurrentRotation(axis?: Axis): void;
  5809. }
  5810. }
  5811. declare module BABYLON {
  5812. class FollowCamera extends TargetCamera {
  5813. radius: number;
  5814. rotationOffset: number;
  5815. heightOffset: number;
  5816. cameraAcceleration: number;
  5817. maxCameraSpeed: number;
  5818. lockedTarget: Nullable<AbstractMesh>;
  5819. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5820. private getRadians(degrees);
  5821. private follow(cameraTarget);
  5822. _checkInputs(): void;
  5823. getClassName(): string;
  5824. }
  5825. class ArcFollowCamera extends TargetCamera {
  5826. alpha: number;
  5827. beta: number;
  5828. radius: number;
  5829. target: Nullable<AbstractMesh>;
  5830. private _cartesianCoordinates;
  5831. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5832. private follow();
  5833. _checkInputs(): void;
  5834. getClassName(): string;
  5835. }
  5836. }
  5837. declare module BABYLON {
  5838. class FreeCamera extends TargetCamera {
  5839. ellipsoid: Vector3;
  5840. ellipsoidOffset: Vector3;
  5841. checkCollisions: boolean;
  5842. applyGravity: boolean;
  5843. inputs: FreeCameraInputsManager;
  5844. /**
  5845. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5846. * Higher values reduce sensitivity.
  5847. */
  5848. /**
  5849. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5850. * Higher values reduce sensitivity.
  5851. */
  5852. angularSensibility: number;
  5853. keysUp: number[];
  5854. keysDown: number[];
  5855. keysLeft: number[];
  5856. keysRight: number[];
  5857. onCollide: (collidedMesh: AbstractMesh) => void;
  5858. private _collider;
  5859. private _needMoveForGravity;
  5860. private _oldPosition;
  5861. private _diffPosition;
  5862. private _newPosition;
  5863. _localDirection: Vector3;
  5864. _transformedDirection: Vector3;
  5865. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5867. detachControl(element: HTMLElement): void;
  5868. private _collisionMask;
  5869. collisionMask: number;
  5870. _collideWithWorld(displacement: Vector3): void;
  5871. private _onCollisionPositionChange;
  5872. _checkInputs(): void;
  5873. _decideIfNeedsToMove(): boolean;
  5874. _updatePosition(): void;
  5875. dispose(): void;
  5876. getClassName(): string;
  5877. }
  5878. }
  5879. declare module BABYLON {
  5880. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5881. constructor(camera: FreeCamera);
  5882. addKeyboard(): FreeCameraInputsManager;
  5883. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5884. addGamepad(): FreeCameraInputsManager;
  5885. addDeviceOrientation(): FreeCameraInputsManager;
  5886. addTouch(): FreeCameraInputsManager;
  5887. addVirtualJoystick(): FreeCameraInputsManager;
  5888. }
  5889. }
  5890. declare module BABYLON {
  5891. class GamepadCamera extends UniversalCamera {
  5892. gamepadAngularSensibility: number;
  5893. gamepadMoveSensibility: number;
  5894. constructor(name: string, position: Vector3, scene: Scene);
  5895. getClassName(): string;
  5896. }
  5897. }
  5898. declare module BABYLON {
  5899. /**
  5900. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  5901. */
  5902. class AnaglyphFreeCamera extends FreeCamera {
  5903. /**
  5904. * Creates a new AnaglyphFreeCamera
  5905. * @param name defines camera name
  5906. * @param position defines initial position
  5907. * @param interaxialDistance defines distance between each color axis
  5908. * @param scene defines the hosting scene
  5909. */
  5910. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5911. /**
  5912. * Gets camera class name
  5913. * @returns AnaglyphFreeCamera
  5914. */
  5915. getClassName(): string;
  5916. }
  5917. /**
  5918. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  5919. */
  5920. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  5921. /**
  5922. * Creates a new AnaglyphArcRotateCamera
  5923. * @param name defines camera name
  5924. * @param alpha defines alpha angle (in radians)
  5925. * @param beta defines beta angle (in radians)
  5926. * @param radius defines radius
  5927. * @param target defines camera target
  5928. * @param interaxialDistance defines distance between each color axis
  5929. * @param scene defines the hosting scene
  5930. */
  5931. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  5932. /**
  5933. * Gets camera class name
  5934. * @returns AnaglyphArcRotateCamera
  5935. */
  5936. getClassName(): string;
  5937. }
  5938. /**
  5939. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  5940. */
  5941. class AnaglyphGamepadCamera extends GamepadCamera {
  5942. /**
  5943. * Creates a new AnaglyphGamepadCamera
  5944. * @param name defines camera name
  5945. * @param position defines initial position
  5946. * @param interaxialDistance defines distance between each color axis
  5947. * @param scene defines the hosting scene
  5948. */
  5949. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5950. /**
  5951. * Gets camera class name
  5952. * @returns AnaglyphGamepadCamera
  5953. */
  5954. getClassName(): string;
  5955. }
  5956. /**
  5957. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  5958. */
  5959. class AnaglyphUniversalCamera extends UniversalCamera {
  5960. /**
  5961. * Creates a new AnaglyphUniversalCamera
  5962. * @param name defines camera name
  5963. * @param position defines initial position
  5964. * @param interaxialDistance defines distance between each color axis
  5965. * @param scene defines the hosting scene
  5966. */
  5967. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5968. /**
  5969. * Gets camera class name
  5970. * @returns AnaglyphUniversalCamera
  5971. */
  5972. getClassName(): string;
  5973. }
  5974. /**
  5975. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  5976. */
  5977. class StereoscopicFreeCamera extends FreeCamera {
  5978. /**
  5979. * Creates a new StereoscopicFreeCamera
  5980. * @param name defines camera name
  5981. * @param position defines initial position
  5982. * @param interaxialDistance defines distance between each color axis
  5983. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  5984. * @param scene defines the hosting scene
  5985. */
  5986. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5987. /**
  5988. * Gets camera class name
  5989. * @returns StereoscopicFreeCamera
  5990. */
  5991. getClassName(): string;
  5992. }
  5993. /**
  5994. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  5995. */
  5996. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  5997. /**
  5998. * Creates a new StereoscopicArcRotateCamera
  5999. * @param name defines camera name
  6000. * @param alpha defines alpha angle (in radians)
  6001. * @param beta defines beta angle (in radians)
  6002. * @param radius defines radius
  6003. * @param target defines camera target
  6004. * @param interaxialDistance defines distance between each color axis
  6005. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6006. * @param scene defines the hosting scene
  6007. */
  6008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6009. /**
  6010. * Gets camera class name
  6011. * @returns StereoscopicArcRotateCamera
  6012. */
  6013. getClassName(): string;
  6014. }
  6015. /**
  6016. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6017. */
  6018. class StereoscopicGamepadCamera extends GamepadCamera {
  6019. /**
  6020. * Creates a new StereoscopicGamepadCamera
  6021. * @param name defines camera name
  6022. * @param position defines initial position
  6023. * @param interaxialDistance defines distance between each color axis
  6024. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6025. * @param scene defines the hosting scene
  6026. */
  6027. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6028. /**
  6029. * Gets camera class name
  6030. * @returns StereoscopicGamepadCamera
  6031. */
  6032. getClassName(): string;
  6033. }
  6034. /**
  6035. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6036. */
  6037. class StereoscopicUniversalCamera extends UniversalCamera {
  6038. /**
  6039. * Creates a new StereoscopicUniversalCamera
  6040. * @param name defines camera name
  6041. * @param position defines initial position
  6042. * @param interaxialDistance defines distance between each color axis
  6043. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6044. * @param scene defines the hosting scene
  6045. */
  6046. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6047. /**
  6048. * Gets camera class name
  6049. * @returns StereoscopicUniversalCamera
  6050. */
  6051. getClassName(): string;
  6052. }
  6053. }
  6054. declare module BABYLON {
  6055. class TargetCamera extends Camera {
  6056. cameraDirection: Vector3;
  6057. cameraRotation: Vector2;
  6058. rotation: Vector3;
  6059. rotationQuaternion: Quaternion;
  6060. speed: number;
  6061. noRotationConstraint: boolean;
  6062. lockedTarget: any;
  6063. _currentTarget: Vector3;
  6064. _viewMatrix: Matrix;
  6065. _camMatrix: Matrix;
  6066. _cameraTransformMatrix: Matrix;
  6067. _cameraRotationMatrix: Matrix;
  6068. private _rigCamTransformMatrix;
  6069. _referencePoint: Vector3;
  6070. private _currentUpVector;
  6071. _transformedReferencePoint: Vector3;
  6072. protected _globalCurrentTarget: Vector3;
  6073. protected _globalCurrentUpVector: Vector3;
  6074. _reset: () => void;
  6075. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6076. getFrontPosition(distance: number): Vector3;
  6077. _getLockedTargetPosition(): Nullable<Vector3>;
  6078. /**
  6079. * Store current camera state (fov, position, etc..)
  6080. */
  6081. private _storedPosition;
  6082. private _storedRotation;
  6083. private _storedRotationQuaternion;
  6084. storeState(): Camera;
  6085. /**
  6086. * Restored camera state. You must call storeState() first
  6087. */
  6088. _restoreStateValues(): boolean;
  6089. _initCache(): void;
  6090. _updateCache(ignoreParentClass?: boolean): void;
  6091. _isSynchronizedViewMatrix(): boolean;
  6092. _computeLocalCameraSpeed(): number;
  6093. setTarget(target: Vector3): void;
  6094. /**
  6095. * Return the current target position of the camera. This value is expressed in local space.
  6096. */
  6097. getTarget(): Vector3;
  6098. _decideIfNeedsToMove(): boolean;
  6099. _updatePosition(): void;
  6100. _checkInputs(): void;
  6101. protected _updateCameraRotationMatrix(): void;
  6102. _getViewMatrix(): Matrix;
  6103. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6104. /**
  6105. * @override
  6106. * Override Camera.createRigCamera
  6107. */
  6108. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6109. /**
  6110. * @override
  6111. * Override Camera._updateRigCameras
  6112. */
  6113. _updateRigCameras(): void;
  6114. private _getRigCamPosition(halfSpace, result);
  6115. getClassName(): string;
  6116. }
  6117. }
  6118. declare module BABYLON {
  6119. class TouchCamera extends FreeCamera {
  6120. touchAngularSensibility: number;
  6121. touchMoveSensibility: number;
  6122. constructor(name: string, position: Vector3, scene: Scene);
  6123. getClassName(): string;
  6124. _setupInputs(): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. class UniversalCamera extends TouchCamera {
  6129. gamepadAngularSensibility: number;
  6130. gamepadMoveSensibility: number;
  6131. constructor(name: string, position: Vector3, scene: Scene);
  6132. getClassName(): string;
  6133. }
  6134. }
  6135. declare module BABYLON {
  6136. class VirtualJoysticksCamera extends FreeCamera {
  6137. constructor(name: string, position: Vector3, scene: Scene);
  6138. getClassName(): string;
  6139. }
  6140. }
  6141. interface VRDisplay extends EventTarget {
  6142. /**
  6143. * Dictionary of capabilities describing the VRDisplay.
  6144. */
  6145. readonly capabilities: VRDisplayCapabilities;
  6146. /**
  6147. * z-depth defining the far plane of the eye view frustum
  6148. * enables mapping of values in the render target depth
  6149. * attachment to scene coordinates. Initially set to 10000.0.
  6150. */
  6151. depthFar: number;
  6152. /**
  6153. * z-depth defining the near plane of the eye view frustum
  6154. * enables mapping of values in the render target depth
  6155. * attachment to scene coordinates. Initially set to 0.01.
  6156. */
  6157. depthNear: number;
  6158. /**
  6159. * An identifier for this distinct VRDisplay. Used as an
  6160. * association point in the Gamepad API.
  6161. */
  6162. readonly displayId: number;
  6163. /**
  6164. * A display name, a user-readable name identifying it.
  6165. */
  6166. readonly displayName: string;
  6167. readonly isConnected: boolean;
  6168. readonly isPresenting: boolean;
  6169. /**
  6170. * If this VRDisplay supports room-scale experiences, the optional
  6171. * stage attribute contains details on the room-scale parameters.
  6172. */
  6173. readonly stageParameters: VRStageParameters | null;
  6174. /**
  6175. * Passing the value returned by `requestAnimationFrame` to
  6176. * `cancelAnimationFrame` will unregister the callback.
  6177. */
  6178. cancelAnimationFrame(handle: number): void;
  6179. /**
  6180. * Stops presenting to the VRDisplay.
  6181. */
  6182. exitPresent(): Promise<void>;
  6183. getEyeParameters(whichEye: string): VREyeParameters;
  6184. /**
  6185. * Populates the passed VRFrameData with the information required to render
  6186. * the current frame.
  6187. */
  6188. getFrameData(frameData: VRFrameData): boolean;
  6189. /**
  6190. * Get the layers currently being presented.
  6191. */
  6192. getLayers(): VRLayer[];
  6193. /**
  6194. * Return a VRPose containing the future predicted pose of the VRDisplay
  6195. * when the current frame will be presented. The value returned will not
  6196. * change until JavaScript has returned control to the browser.
  6197. *
  6198. * The VRPose will contain the position, orientation, velocity,
  6199. * and acceleration of each of these properties.
  6200. */
  6201. getPose(): VRPose;
  6202. /**
  6203. * Return the current instantaneous pose of the VRDisplay, with no
  6204. * prediction applied.
  6205. */
  6206. getImmediatePose(): VRPose;
  6207. /**
  6208. * The callback passed to `requestAnimationFrame` will be called
  6209. * any time a new frame should be rendered. When the VRDisplay is
  6210. * presenting the callback will be called at the native refresh
  6211. * rate of the HMD. When not presenting this function acts
  6212. * identically to how window.requestAnimationFrame acts. Content should
  6213. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6214. * asynchronously from other displays and at differing refresh rates.
  6215. */
  6216. requestAnimationFrame(callback: FrameRequestCallback): number;
  6217. /**
  6218. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6219. * Repeat calls while already presenting will update the VRLayers being displayed.
  6220. */
  6221. requestPresent(layers: VRLayer[]): Promise<void>;
  6222. /**
  6223. * Reset the pose for this display, treating its current position and
  6224. * orientation as the "origin/zero" values. VRPose.position,
  6225. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6226. * updated when calling resetPose(). This should be called in only
  6227. * sitting-space experiences.
  6228. */
  6229. resetPose(): void;
  6230. /**
  6231. * The VRLayer provided to the VRDisplay will be captured and presented
  6232. * in the HMD. Calling this function has the same effect on the source
  6233. * canvas as any other operation that uses its source image, and canvases
  6234. * created without preserveDrawingBuffer set to true will be cleared.
  6235. */
  6236. submitFrame(pose?: VRPose): void;
  6237. }
  6238. declare var VRDisplay: {
  6239. prototype: VRDisplay;
  6240. new (): VRDisplay;
  6241. };
  6242. interface VRLayer {
  6243. leftBounds?: number[] | null;
  6244. rightBounds?: number[] | null;
  6245. source?: HTMLCanvasElement | null;
  6246. }
  6247. interface VRDisplayCapabilities {
  6248. readonly canPresent: boolean;
  6249. readonly hasExternalDisplay: boolean;
  6250. readonly hasOrientation: boolean;
  6251. readonly hasPosition: boolean;
  6252. readonly maxLayers: number;
  6253. }
  6254. interface VREyeParameters {
  6255. /** @deprecated */
  6256. readonly fieldOfView: VRFieldOfView;
  6257. readonly offset: Float32Array;
  6258. readonly renderHeight: number;
  6259. readonly renderWidth: number;
  6260. }
  6261. interface VRFieldOfView {
  6262. readonly downDegrees: number;
  6263. readonly leftDegrees: number;
  6264. readonly rightDegrees: number;
  6265. readonly upDegrees: number;
  6266. }
  6267. interface VRFrameData {
  6268. readonly leftProjectionMatrix: Float32Array;
  6269. readonly leftViewMatrix: Float32Array;
  6270. readonly pose: VRPose;
  6271. readonly rightProjectionMatrix: Float32Array;
  6272. readonly rightViewMatrix: Float32Array;
  6273. readonly timestamp: number;
  6274. }
  6275. interface VRPose {
  6276. readonly angularAcceleration: Float32Array | null;
  6277. readonly angularVelocity: Float32Array | null;
  6278. readonly linearAcceleration: Float32Array | null;
  6279. readonly linearVelocity: Float32Array | null;
  6280. readonly orientation: Float32Array | null;
  6281. readonly position: Float32Array | null;
  6282. readonly timestamp: number;
  6283. }
  6284. interface VRStageParameters {
  6285. sittingToStandingTransform?: Float32Array;
  6286. sizeX?: number;
  6287. sizeY?: number;
  6288. }
  6289. interface Navigator {
  6290. getVRDisplays(): Promise<VRDisplay[]>;
  6291. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6292. }
  6293. interface Window {
  6294. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6295. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6296. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6297. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6298. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6299. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6300. }
  6301. interface Gamepad {
  6302. readonly displayId: number;
  6303. }
  6304. declare module BABYLON {
  6305. class Collider {
  6306. /** Define if a collision was found */
  6307. collisionFound: boolean;
  6308. /**
  6309. * Define last intersection point in local space
  6310. */
  6311. intersectionPoint: Vector3;
  6312. /**
  6313. * Define last collided mesh
  6314. */
  6315. collidedMesh: Nullable<AbstractMesh>;
  6316. private _collisionPoint;
  6317. private _planeIntersectionPoint;
  6318. private _tempVector;
  6319. private _tempVector2;
  6320. private _tempVector3;
  6321. private _tempVector4;
  6322. private _edge;
  6323. private _baseToVertex;
  6324. private _destinationPoint;
  6325. private _slidePlaneNormal;
  6326. private _displacementVector;
  6327. _radius: Vector3;
  6328. _retry: number;
  6329. private _velocity;
  6330. private _basePoint;
  6331. private _epsilon;
  6332. _velocityWorldLength: number;
  6333. _basePointWorld: Vector3;
  6334. private _velocityWorld;
  6335. private _normalizedVelocity;
  6336. _initialVelocity: Vector3;
  6337. _initialPosition: Vector3;
  6338. private _nearestDistance;
  6339. private _collisionMask;
  6340. collisionMask: number;
  6341. /**
  6342. * Gets the plane normal used to compute the sliding response (in local space)
  6343. */
  6344. readonly slidePlaneNormal: Vector3;
  6345. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6346. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6347. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6348. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6349. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6350. _getResponse(pos: Vector3, vel: Vector3): void;
  6351. }
  6352. }
  6353. declare module BABYLON {
  6354. var CollisionWorker: string;
  6355. interface ICollisionCoordinator {
  6356. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6357. init(scene: Scene): void;
  6358. destroy(): void;
  6359. onMeshAdded(mesh: AbstractMesh): void;
  6360. onMeshUpdated(mesh: AbstractMesh): void;
  6361. onMeshRemoved(mesh: AbstractMesh): void;
  6362. onGeometryAdded(geometry: Geometry): void;
  6363. onGeometryUpdated(geometry: Geometry): void;
  6364. onGeometryDeleted(geometry: Geometry): void;
  6365. }
  6366. interface SerializedMesh {
  6367. id: string;
  6368. name: string;
  6369. uniqueId: number;
  6370. geometryId: Nullable<string>;
  6371. sphereCenter: Array<number>;
  6372. sphereRadius: number;
  6373. boxMinimum: Array<number>;
  6374. boxMaximum: Array<number>;
  6375. worldMatrixFromCache: any;
  6376. subMeshes: Array<SerializedSubMesh>;
  6377. checkCollisions: boolean;
  6378. }
  6379. interface SerializedSubMesh {
  6380. position: number;
  6381. verticesStart: number;
  6382. verticesCount: number;
  6383. indexStart: number;
  6384. indexCount: number;
  6385. hasMaterial: boolean;
  6386. sphereCenter: Array<number>;
  6387. sphereRadius: number;
  6388. boxMinimum: Array<number>;
  6389. boxMaximum: Array<number>;
  6390. }
  6391. /**
  6392. * Interface describing the value associated with a geometry
  6393. */
  6394. interface SerializedGeometry {
  6395. /**
  6396. * Defines the unique ID of the geometry
  6397. */
  6398. id: string;
  6399. /**
  6400. * Defines the array containing the positions
  6401. */
  6402. positions: Float32Array;
  6403. /**
  6404. * Defines the array containing the indices
  6405. */
  6406. indices: Uint32Array;
  6407. /**
  6408. * Defines the array containing the normals
  6409. */
  6410. normals: Float32Array;
  6411. }
  6412. interface BabylonMessage {
  6413. taskType: WorkerTaskType;
  6414. payload: InitPayload | CollidePayload | UpdatePayload;
  6415. }
  6416. interface SerializedColliderToWorker {
  6417. position: Array<number>;
  6418. velocity: Array<number>;
  6419. radius: Array<number>;
  6420. }
  6421. /** Defines supported task for worker process */
  6422. enum WorkerTaskType {
  6423. /** Initialization */
  6424. INIT = 0,
  6425. /** Update of geometry */
  6426. UPDATE = 1,
  6427. /** Evaluate collision */
  6428. COLLIDE = 2,
  6429. }
  6430. interface WorkerReply {
  6431. error: WorkerReplyType;
  6432. taskType: WorkerTaskType;
  6433. payload?: any;
  6434. }
  6435. interface CollisionReplyPayload {
  6436. newPosition: Array<number>;
  6437. collisionId: number;
  6438. collidedMeshUniqueId: number;
  6439. }
  6440. interface InitPayload {
  6441. }
  6442. interface CollidePayload {
  6443. collisionId: number;
  6444. collider: SerializedColliderToWorker;
  6445. maximumRetry: number;
  6446. excludedMeshUniqueId: Nullable<number>;
  6447. }
  6448. interface UpdatePayload {
  6449. updatedMeshes: {
  6450. [n: number]: SerializedMesh;
  6451. };
  6452. updatedGeometries: {
  6453. [s: string]: SerializedGeometry;
  6454. };
  6455. removedMeshes: Array<number>;
  6456. removedGeometries: Array<string>;
  6457. }
  6458. /** Defines kind of replies returned by worker */
  6459. enum WorkerReplyType {
  6460. /** Success */
  6461. SUCCESS = 0,
  6462. /** Unkown error */
  6463. UNKNOWN_ERROR = 1,
  6464. }
  6465. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6466. private _scene;
  6467. private _scaledPosition;
  6468. private _scaledVelocity;
  6469. private _collisionsCallbackArray;
  6470. private _init;
  6471. private _runningUpdated;
  6472. private _worker;
  6473. private _addUpdateMeshesList;
  6474. private _addUpdateGeometriesList;
  6475. private _toRemoveMeshesArray;
  6476. private _toRemoveGeometryArray;
  6477. constructor();
  6478. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6479. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6480. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6481. init(scene: Scene): void;
  6482. destroy(): void;
  6483. onMeshAdded(mesh: AbstractMesh): void;
  6484. onMeshUpdated: (transformNode: TransformNode) => void;
  6485. onMeshRemoved(mesh: AbstractMesh): void;
  6486. onGeometryAdded(geometry: Geometry): void;
  6487. onGeometryUpdated: (geometry: Geometry) => void;
  6488. onGeometryDeleted(geometry: Geometry): void;
  6489. private _afterRender;
  6490. private _onMessageFromWorker;
  6491. }
  6492. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6493. private _scene;
  6494. private _scaledPosition;
  6495. private _scaledVelocity;
  6496. private _finalPosition;
  6497. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6498. init(scene: Scene): void;
  6499. destroy(): void;
  6500. onMeshAdded(mesh: AbstractMesh): void;
  6501. onMeshUpdated(mesh: AbstractMesh): void;
  6502. onMeshRemoved(mesh: AbstractMesh): void;
  6503. onGeometryAdded(geometry: Geometry): void;
  6504. onGeometryUpdated(geometry: Geometry): void;
  6505. onGeometryDeleted(geometry: Geometry): void;
  6506. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  6507. }
  6508. }
  6509. declare function importScripts(...urls: string[]): void;
  6510. declare const safePostMessage: any;
  6511. declare module BABYLON {
  6512. var WorkerIncluded: boolean;
  6513. class CollisionCache {
  6514. private _meshes;
  6515. private _geometries;
  6516. getMeshes(): {
  6517. [n: number]: SerializedMesh;
  6518. };
  6519. getGeometries(): {
  6520. [s: number]: SerializedGeometry;
  6521. };
  6522. getMesh(id: any): SerializedMesh;
  6523. addMesh(mesh: SerializedMesh): void;
  6524. removeMesh(uniqueId: number): void;
  6525. getGeometry(id: string): SerializedGeometry;
  6526. addGeometry(geometry: SerializedGeometry): void;
  6527. removeGeometry(id: string): void;
  6528. }
  6529. class CollideWorker {
  6530. collider: Collider;
  6531. private _collisionCache;
  6532. private finalPosition;
  6533. private collisionsScalingMatrix;
  6534. private collisionTranformationMatrix;
  6535. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6536. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6537. private checkCollision(mesh);
  6538. private processCollisionsForSubMeshes(transformMatrix, mesh);
  6539. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  6540. private checkSubmeshCollision(subMesh);
  6541. }
  6542. interface ICollisionDetector {
  6543. onInit(payload: InitPayload): void;
  6544. onUpdate(payload: UpdatePayload): void;
  6545. onCollision(payload: CollidePayload): void;
  6546. }
  6547. class CollisionDetectorTransferable implements ICollisionDetector {
  6548. private _collisionCache;
  6549. onInit(payload: InitPayload): void;
  6550. onUpdate(payload: UpdatePayload): void;
  6551. onCollision(payload: CollidePayload): void;
  6552. }
  6553. }
  6554. declare module BABYLON {
  6555. class IntersectionInfo {
  6556. bu: Nullable<number>;
  6557. bv: Nullable<number>;
  6558. distance: number;
  6559. faceId: number;
  6560. subMeshId: number;
  6561. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6562. }
  6563. /**
  6564. * Information about the result of picking within a scene
  6565. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6566. */
  6567. class PickingInfo {
  6568. /**
  6569. * If the pick collided with an object
  6570. */
  6571. hit: boolean;
  6572. /**
  6573. * Distance away where the pick collided
  6574. */
  6575. distance: number;
  6576. /**
  6577. * The location of pick collision
  6578. */
  6579. pickedPoint: Nullable<Vector3>;
  6580. /**
  6581. * The mesh corrisponding the the pick collision
  6582. */
  6583. pickedMesh: Nullable<AbstractMesh>;
  6584. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6585. bu: number;
  6586. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6587. bv: number;
  6588. /** The id of the face on the mesh that was picked */
  6589. faceId: number;
  6590. /** Id of the the submesh that was picked */
  6591. subMeshId: number;
  6592. /** If a sprite was picked, this will be the sprite the pick collided with */
  6593. pickedSprite: Nullable<Sprite>;
  6594. /**
  6595. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6596. */
  6597. originMesh: Nullable<AbstractMesh>;
  6598. /**
  6599. * The ray that was used to perform the picking.
  6600. */
  6601. ray: Nullable<Ray>;
  6602. /**
  6603. * Gets the normal corrispodning to the face the pick collided with
  6604. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6605. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6606. * @returns The normal corrispodning to the face the pick collided with
  6607. */
  6608. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6609. /**
  6610. * Gets the texture coordinates of where the pick occured
  6611. * @returns the vector containing the coordnates of the texture
  6612. */
  6613. getTextureCoordinates(): Nullable<Vector2>;
  6614. }
  6615. }
  6616. declare module BABYLON {
  6617. class BoundingBox implements ICullable {
  6618. vectors: Vector3[];
  6619. center: Vector3;
  6620. centerWorld: Vector3;
  6621. extendSize: Vector3;
  6622. extendSizeWorld: Vector3;
  6623. directions: Vector3[];
  6624. vectorsWorld: Vector3[];
  6625. minimumWorld: Vector3;
  6626. maximumWorld: Vector3;
  6627. minimum: Vector3;
  6628. maximum: Vector3;
  6629. private _worldMatrix;
  6630. /**
  6631. * Creates a new bounding box
  6632. * @param min defines the minimum vector (in local space)
  6633. * @param max defines the maximum vector (in local space)
  6634. */
  6635. constructor(min: Vector3, max: Vector3);
  6636. /**
  6637. * Recreates the entire bounding box from scratch
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. */
  6641. reConstruct(min: Vector3, max: Vector3): void;
  6642. getWorldMatrix(): Matrix;
  6643. setWorldMatrix(matrix: Matrix): BoundingBox;
  6644. _update(world: Matrix): void;
  6645. isInFrustum(frustumPlanes: Plane[]): boolean;
  6646. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6647. intersectsPoint(point: Vector3): boolean;
  6648. intersectsSphere(sphere: BoundingSphere): boolean;
  6649. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6650. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6651. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6652. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6653. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6654. }
  6655. }
  6656. declare module BABYLON {
  6657. interface ICullable {
  6658. isInFrustum(frustumPlanes: Plane[]): boolean;
  6659. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6660. }
  6661. class BoundingInfo implements ICullable {
  6662. minimum: Vector3;
  6663. maximum: Vector3;
  6664. boundingBox: BoundingBox;
  6665. boundingSphere: BoundingSphere;
  6666. private _isLocked;
  6667. constructor(minimum: Vector3, maximum: Vector3);
  6668. isLocked: boolean;
  6669. update(world: Matrix): void;
  6670. /**
  6671. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6672. * @param center New center of the bounding info
  6673. * @param extend New extend of the bounding info
  6674. */
  6675. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6676. isInFrustum(frustumPlanes: Plane[]): boolean;
  6677. /**
  6678. * Gets the world distance between the min and max points of the bounding box
  6679. */
  6680. readonly diagonalLength: number;
  6681. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6682. _checkCollision(collider: Collider): boolean;
  6683. intersectsPoint(point: Vector3): boolean;
  6684. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6685. }
  6686. }
  6687. declare module BABYLON {
  6688. class BoundingSphere {
  6689. center: Vector3;
  6690. radius: number;
  6691. centerWorld: Vector3;
  6692. radiusWorld: number;
  6693. minimum: Vector3;
  6694. maximum: Vector3;
  6695. private _tempRadiusVector;
  6696. /**
  6697. * Creates a new bounding sphere
  6698. * @param min defines the minimum vector (in local space)
  6699. * @param max defines the maximum vector (in local space)
  6700. */
  6701. constructor(min: Vector3, max: Vector3);
  6702. /**
  6703. * Recreates the entire bounding sphere from scratch
  6704. * @param min defines the new minimum vector (in local space)
  6705. * @param max defines the new maximum vector (in local space)
  6706. */
  6707. reConstruct(min: Vector3, max: Vector3): void;
  6708. _update(world: Matrix): void;
  6709. isInFrustum(frustumPlanes: Plane[]): boolean;
  6710. intersectsPoint(point: Vector3): boolean;
  6711. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. class Ray {
  6716. origin: Vector3;
  6717. direction: Vector3;
  6718. length: number;
  6719. private _edge1;
  6720. private _edge2;
  6721. private _pvec;
  6722. private _tvec;
  6723. private _qvec;
  6724. private _tmpRay;
  6725. constructor(origin: Vector3, direction: Vector3, length?: number);
  6726. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6727. intersectsBox(box: BoundingBox): boolean;
  6728. intersectsSphere(sphere: BoundingSphere): boolean;
  6729. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6730. intersectsPlane(plane: Plane): Nullable<number>;
  6731. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6732. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6733. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  6734. private static smallnum;
  6735. private static rayl;
  6736. /**
  6737. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6738. * @param sega the first point of the segment to test the intersection against
  6739. * @param segb the second point of the segment to test the intersection against
  6740. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6741. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6742. */
  6743. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6744. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6745. static Zero(): Ray;
  6746. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6747. /**
  6748. * 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
  6749. * transformed to the given world matrix.
  6750. * @param origin The origin point
  6751. * @param end The end point
  6752. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6753. */
  6754. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6755. static Transform(ray: Ray, matrix: Matrix): Ray;
  6756. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6757. }
  6758. }
  6759. /**
  6760. * Module Debug contains the (visual) components to debug a scene correctly
  6761. */
  6762. declare module BABYLON.Debug {
  6763. /**
  6764. * The Axes viewer will show 3 axes in a specific point in space
  6765. */
  6766. class AxesViewer {
  6767. private _xline;
  6768. private _yline;
  6769. private _zline;
  6770. private _xmesh;
  6771. private _ymesh;
  6772. private _zmesh;
  6773. /**
  6774. * Gets the hosting scene
  6775. */
  6776. scene: Nullable<Scene>;
  6777. /**
  6778. * Gets or sets a number used to scale line length
  6779. */
  6780. scaleLines: number;
  6781. /**
  6782. * Creates a new AxesViewer
  6783. * @param scene defines the hosting scene
  6784. * @param scaleLines defines a number used to scale line length (1 by default)
  6785. */
  6786. constructor(scene: Scene, scaleLines?: number);
  6787. /**
  6788. * Force the viewer to update
  6789. * @param position defines the position of the viewer
  6790. * @param xaxis defines the x axis of the viewer
  6791. * @param yaxis defines the y axis of the viewer
  6792. * @param zaxis defines the z axis of the viewer
  6793. */
  6794. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6795. /** Releases resources */
  6796. dispose(): void;
  6797. }
  6798. }
  6799. declare module BABYLON.Debug {
  6800. /**
  6801. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6802. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6803. */
  6804. class BoneAxesViewer extends AxesViewer {
  6805. /**
  6806. * Gets or sets the target mesh where to display the axes viewer
  6807. */
  6808. mesh: Nullable<Mesh>;
  6809. /**
  6810. * Gets or sets the target bone where to display the axes viewer
  6811. */
  6812. bone: Nullable<Bone>;
  6813. /** Gets current position */
  6814. pos: Vector3;
  6815. /** Gets direction of X axis */
  6816. xaxis: Vector3;
  6817. /** Gets direction of Y axis */
  6818. yaxis: Vector3;
  6819. /** Gets direction of Z axis */
  6820. zaxis: Vector3;
  6821. /**
  6822. * Creates a new BoneAxesViewer
  6823. * @param scene defines the hosting scene
  6824. * @param bone defines the target bone
  6825. * @param mesh defines the target mesh
  6826. * @param scaleLines defines a scaling factor for line length (1 by default)
  6827. */
  6828. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6829. /**
  6830. * Force the viewer to update
  6831. */
  6832. update(): void;
  6833. /** Releases resources */
  6834. dispose(): void;
  6835. }
  6836. }
  6837. declare module BABYLON {
  6838. class DebugLayer {
  6839. private _scene;
  6840. static InspectorURL: string;
  6841. private _inspector;
  6842. private BJSINSPECTOR;
  6843. onPropertyChangedObservable: BABYLON.Observable<{
  6844. object: any;
  6845. property: string;
  6846. value: any;
  6847. initialValue: any;
  6848. }>;
  6849. constructor(scene: Scene);
  6850. /** Creates the inspector window. */
  6851. private _createInspector(config?);
  6852. isVisible(): boolean;
  6853. hide(): void;
  6854. /**
  6855. *
  6856. * Launch the debugLayer.
  6857. *
  6858. * initialTab:
  6859. * | Value | Tab Name |
  6860. * | --- | --- |
  6861. * | 0 | Scene |
  6862. * | 1 | Console |
  6863. * | 2 | Stats |
  6864. * | 3 | Textures |
  6865. * | 4 | Mesh |
  6866. * | 5 | Light |
  6867. * | 6 | Material |
  6868. * | 7 | GLTF |
  6869. * | 8 | GUI |
  6870. * | 9 | Physics |
  6871. * | 10 | Camera |
  6872. * | 11 | Audio |
  6873. *
  6874. */
  6875. show(config?: {
  6876. popup?: boolean;
  6877. initialTab?: number;
  6878. parentElement?: HTMLElement;
  6879. newColors?: {
  6880. backgroundColor?: string;
  6881. backgroundColorLighter?: string;
  6882. backgroundColorLighter2?: string;
  6883. backgroundColorLighter3?: string;
  6884. color?: string;
  6885. colorTop?: string;
  6886. colorBot?: string;
  6887. };
  6888. }): void;
  6889. /**
  6890. * Gets the active tab
  6891. * @return the index of the active tab or -1 if the inspector is hidden
  6892. */
  6893. getActiveTab(): number;
  6894. }
  6895. }
  6896. declare module BABYLON.Debug {
  6897. /**
  6898. * Used to show the physics impostor around the specific mesh
  6899. */
  6900. class PhysicsViewer {
  6901. /** @hidden */
  6902. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6903. /** @hidden */
  6904. protected _meshes: Array<Nullable<AbstractMesh>>;
  6905. /** @hidden */
  6906. protected _scene: Nullable<Scene>;
  6907. /** @hidden */
  6908. protected _numMeshes: number;
  6909. /** @hidden */
  6910. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6911. private _renderFunction;
  6912. private _debugBoxMesh;
  6913. private _debugSphereMesh;
  6914. private _debugMaterial;
  6915. /**
  6916. * Creates a new PhysicsViewer
  6917. * @param scene defines the hosting scene
  6918. */
  6919. constructor(scene: Scene);
  6920. /** @hidden */
  6921. protected _updateDebugMeshes(): void;
  6922. /**
  6923. * Renders a specified physic impostor
  6924. * @param impostor defines the impostor to render
  6925. */
  6926. showImpostor(impostor: PhysicsImpostor): void;
  6927. /**
  6928. * Hides a specified physic impostor
  6929. * @param impostor defines the impostor to hide
  6930. */
  6931. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6932. private _getDebugMaterial(scene);
  6933. private _getDebugBoxMesh(scene);
  6934. private _getDebugSphereMesh(scene);
  6935. private _getDebugMesh(impostor, scene);
  6936. /** Releases all resources */
  6937. dispose(): void;
  6938. }
  6939. }
  6940. declare module BABYLON {
  6941. class RayHelper {
  6942. ray: Nullable<Ray>;
  6943. private _renderPoints;
  6944. private _renderLine;
  6945. private _renderFunction;
  6946. private _scene;
  6947. private _updateToMeshFunction;
  6948. private _attachedToMesh;
  6949. private _meshSpaceDirection;
  6950. private _meshSpaceOrigin;
  6951. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6952. constructor(ray: Ray);
  6953. show(scene: Scene, color?: Color3): void;
  6954. hide(): void;
  6955. private _render();
  6956. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6957. detachFromMesh(): void;
  6958. private _updateToMesh();
  6959. dispose(): void;
  6960. }
  6961. }
  6962. declare module BABYLON.Debug {
  6963. /**
  6964. * Class used to render a debug view of a given skeleton
  6965. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6966. */
  6967. class SkeletonViewer {
  6968. /** defines the skeleton to render */
  6969. skeleton: Skeleton;
  6970. /** defines the mesh attached to the skeleton */
  6971. mesh: AbstractMesh;
  6972. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6973. autoUpdateBonesMatrices: boolean;
  6974. /** defines the rendering group id to use with the viewer */
  6975. renderingGroupId: number;
  6976. /** Gets or sets the color used to render the skeleton */
  6977. color: Color3;
  6978. private _scene;
  6979. private _debugLines;
  6980. private _debugMesh;
  6981. private _isEnabled;
  6982. private _renderFunction;
  6983. /**
  6984. * Creates a new SkeletonViewer
  6985. * @param skeleton defines the skeleton to render
  6986. * @param mesh defines the mesh attached to the skeleton
  6987. * @param scene defines the hosting scene
  6988. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6989. * @param renderingGroupId defines the rendering group id to use with the viewer
  6990. */
  6991. constructor(
  6992. /** defines the skeleton to render */
  6993. skeleton: Skeleton,
  6994. /** defines the mesh attached to the skeleton */
  6995. mesh: AbstractMesh, scene: Scene,
  6996. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6997. autoUpdateBonesMatrices?: boolean,
  6998. /** defines the rendering group id to use with the viewer */
  6999. renderingGroupId?: number);
  7000. /** Gets or sets a boolean indicating if the viewer is enabled */
  7001. isEnabled: boolean;
  7002. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  7003. private _getLinesForBonesWithLength(bones, meshMat);
  7004. private _getLinesForBonesNoLength(bones, meshMat);
  7005. /** Update the viewer to sync with current skeleton state */
  7006. update(): void;
  7007. /** Release associated resources */
  7008. dispose(): void;
  7009. }
  7010. }
  7011. declare module BABYLON {
  7012. class KeyboardEventTypes {
  7013. static _KEYDOWN: number;
  7014. static _KEYUP: number;
  7015. static readonly KEYDOWN: number;
  7016. static readonly KEYUP: number;
  7017. }
  7018. class KeyboardInfo {
  7019. type: number;
  7020. event: KeyboardEvent;
  7021. constructor(type: number, event: KeyboardEvent);
  7022. }
  7023. /**
  7024. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  7025. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  7026. */
  7027. class KeyboardInfoPre extends KeyboardInfo {
  7028. constructor(type: number, event: KeyboardEvent);
  7029. skipOnPointerObservable: boolean;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. class PointerEventTypes {
  7034. static _POINTERDOWN: number;
  7035. static _POINTERUP: number;
  7036. static _POINTERMOVE: number;
  7037. static _POINTERWHEEL: number;
  7038. static _POINTERPICK: number;
  7039. static _POINTERTAP: number;
  7040. static _POINTERDOUBLETAP: number;
  7041. static readonly POINTERDOWN: number;
  7042. static readonly POINTERUP: number;
  7043. static readonly POINTERMOVE: number;
  7044. static readonly POINTERWHEEL: number;
  7045. static readonly POINTERPICK: number;
  7046. static readonly POINTERTAP: number;
  7047. static readonly POINTERDOUBLETAP: number;
  7048. }
  7049. class PointerInfoBase {
  7050. type: number;
  7051. event: PointerEvent | MouseWheelEvent;
  7052. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  7053. }
  7054. /**
  7055. * This class is used to store pointer related info for the onPrePointerObservable event.
  7056. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  7057. */
  7058. class PointerInfoPre extends PointerInfoBase {
  7059. /**
  7060. * Ray from a pointer if availible (eg. 6dof controller)
  7061. */
  7062. ray: Nullable<Ray>;
  7063. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  7064. localPosition: Vector2;
  7065. skipOnPointerObservable: boolean;
  7066. }
  7067. /**
  7068. * This type contains all the data related to a pointer event in Babylon.js.
  7069. * 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.
  7070. */
  7071. class PointerInfo extends PointerInfoBase {
  7072. pickInfo: Nullable<PickingInfo>;
  7073. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  7074. }
  7075. }
  7076. declare module BABYLON {
  7077. /**
  7078. * Interface for attribute information associated with buffer instanciation
  7079. */
  7080. class InstancingAttributeInfo {
  7081. /**
  7082. * Index/offset of the attribute in the vertex shader
  7083. */
  7084. index: number;
  7085. /**
  7086. * size of the attribute, 1, 2, 3 or 4
  7087. */
  7088. attributeSize: number;
  7089. /**
  7090. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7091. * default is FLOAT
  7092. */
  7093. attribyteType: number;
  7094. /**
  7095. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7096. */
  7097. normalized: boolean;
  7098. /**
  7099. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7100. */
  7101. offset: number;
  7102. /**
  7103. * Name of the GLSL attribute, for debugging purpose only
  7104. */
  7105. attributeName: string;
  7106. }
  7107. /**
  7108. * Define options used to create a render target texture
  7109. */
  7110. class RenderTargetCreationOptions {
  7111. /**
  7112. * Specifies is mipmaps must be generated
  7113. */
  7114. generateMipMaps?: boolean;
  7115. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7116. generateDepthBuffer?: boolean;
  7117. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7118. generateStencilBuffer?: boolean;
  7119. /** Defines texture type (int by default) */
  7120. type?: number;
  7121. /** Defines sampling mode (trilinear by default) */
  7122. samplingMode?: number;
  7123. /** Defines format (RGBA by default) */
  7124. format?: number;
  7125. }
  7126. /**
  7127. * Define options used to create a depth texture
  7128. */
  7129. class DepthTextureCreationOptions {
  7130. /** Specifies whether or not a stencil should be allocated in the texture */
  7131. generateStencil?: boolean;
  7132. /** Specifies whether or not bilinear filtering is enable on the texture */
  7133. bilinearFiltering?: boolean;
  7134. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7135. comparisonFunction?: number;
  7136. /** Specifies if the created texture is a cube texture */
  7137. isCube?: boolean;
  7138. }
  7139. /**
  7140. * Class used to describe the capabilities of the engine relatively to the current browser
  7141. */
  7142. class EngineCapabilities {
  7143. /** Maximum textures units per fragment shader */
  7144. maxTexturesImageUnits: number;
  7145. /** Maximum texture units per vertex shader */
  7146. maxVertexTextureImageUnits: number;
  7147. /** Maximum textures units in the entire pipeline */
  7148. maxCombinedTexturesImageUnits: number;
  7149. /** Maximum texture size */
  7150. maxTextureSize: number;
  7151. /** Maximum cube texture size */
  7152. maxCubemapTextureSize: number;
  7153. /** Maximum render texture size */
  7154. maxRenderTextureSize: number;
  7155. /** Maximum number of vertex attributes */
  7156. maxVertexAttribs: number;
  7157. /** Maximum number of varyings */
  7158. maxVaryingVectors: number;
  7159. /** Maximum number of uniforms per vertex shader */
  7160. maxVertexUniformVectors: number;
  7161. /** Maximum number of uniforms per fragment shader */
  7162. maxFragmentUniformVectors: number;
  7163. /** Defines if standard derivates (dx/dy) are supported */
  7164. standardDerivatives: boolean;
  7165. /** Defines if s3tc texture compression is supported */
  7166. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7167. /** Defines if pvrtc texture compression is supported */
  7168. pvrtc: any;
  7169. /** Defines if etc1 texture compression is supported */
  7170. etc1: any;
  7171. /** Defines if etc2 texture compression is supported */
  7172. etc2: any;
  7173. /** Defines if astc texture compression is supported */
  7174. astc: any;
  7175. /** Defines if float textures are supported */
  7176. textureFloat: boolean;
  7177. /** Defines if vertex array objects are supported */
  7178. vertexArrayObject: boolean;
  7179. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7180. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7181. /** Gets the maximum level of anisotropy supported */
  7182. maxAnisotropy: number;
  7183. /** Defines if instancing is supported */
  7184. instancedArrays: boolean;
  7185. /** Defines if 32 bits indices are supported */
  7186. uintIndices: boolean;
  7187. /** Defines if high precision shaders are supported */
  7188. highPrecisionShaderSupported: boolean;
  7189. /** Defines if depth reading in the fragment shader is supported */
  7190. fragmentDepthSupported: boolean;
  7191. /** Defines if float texture linear filtering is supported*/
  7192. textureFloatLinearFiltering: boolean;
  7193. /** Defines if rendering to float textures is supported */
  7194. textureFloatRender: boolean;
  7195. /** Defines if half float textures are supported*/
  7196. textureHalfFloat: boolean;
  7197. /** Defines if half float texture linear filtering is supported*/
  7198. textureHalfFloatLinearFiltering: boolean;
  7199. /** Defines if rendering to half float textures is supported */
  7200. textureHalfFloatRender: boolean;
  7201. /** Defines if textureLOD shader command is supported */
  7202. textureLOD: boolean;
  7203. /** Defines if draw buffers extension is supported */
  7204. drawBuffersExtension: boolean;
  7205. /** Defines if depth textures are supported */
  7206. depthTextureExtension: boolean;
  7207. /** Defines if float color buffer are supported */
  7208. colorBufferFloat: boolean;
  7209. /** Gets disjoint timer query extension (null if not supported) */
  7210. timerQuery: EXT_disjoint_timer_query;
  7211. /** Defines if timestamp can be used with timer query */
  7212. canUseTimestampForTimerQuery: boolean;
  7213. }
  7214. /** Interface defining initialization parameters for Engine class */
  7215. interface EngineOptions extends WebGLContextAttributes {
  7216. /**
  7217. * Defines if the engine should no exceed a specified device ratio
  7218. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7219. */
  7220. limitDeviceRatio?: number;
  7221. /**
  7222. * Defines if webvr should be enabled automatically
  7223. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7224. */
  7225. autoEnableWebVR?: boolean;
  7226. /**
  7227. * Defines if webgl2 should be turned off even if supported
  7228. * @see http://doc.babylonjs.com/features/webgl2
  7229. */
  7230. disableWebGL2Support?: boolean;
  7231. /**
  7232. * Defines if webaudio should be initialized as well
  7233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7234. */
  7235. audioEngine?: boolean;
  7236. /**
  7237. * Defines if animations should run using a deterministic lock step
  7238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7239. */
  7240. deterministicLockstep?: boolean;
  7241. /** Defines the maximum steps to use with deterministic lock step mode */
  7242. lockstepMaxSteps?: number;
  7243. /**
  7244. * Defines that engine should ignore context lost events
  7245. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7246. */
  7247. doNotHandleContextLost?: boolean;
  7248. }
  7249. /**
  7250. * Defines the interface used by display changed events
  7251. */
  7252. interface IDisplayChangedEventArgs {
  7253. /** Gets the vrDisplay object (if any) */
  7254. vrDisplay: Nullable<any>;
  7255. /** Gets a boolean indicating if webVR is supported */
  7256. vrSupported: boolean;
  7257. }
  7258. /**
  7259. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7260. */
  7261. class Engine {
  7262. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7263. static ExceptionList: ({
  7264. key: string;
  7265. capture: string;
  7266. captureConstraint: number;
  7267. targets: string[];
  7268. } | {
  7269. key: string;
  7270. capture: null;
  7271. captureConstraint: null;
  7272. targets: string[];
  7273. })[];
  7274. /** Gets the list of created engines */
  7275. static Instances: Engine[];
  7276. /**
  7277. * Gets the latest created engine
  7278. */
  7279. static readonly LastCreatedEngine: Nullable<Engine>;
  7280. /**
  7281. * Gets the latest created scene
  7282. */
  7283. static readonly LastCreatedScene: Nullable<Scene>;
  7284. /**
  7285. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7286. * @param flag defines which part of the materials must be marked as dirty
  7287. * @param predicate defines a predicate used to filter which materials should be affected
  7288. */
  7289. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7290. private static _ALPHA_DISABLE;
  7291. private static _ALPHA_ADD;
  7292. private static _ALPHA_COMBINE;
  7293. private static _ALPHA_SUBTRACT;
  7294. private static _ALPHA_MULTIPLY;
  7295. private static _ALPHA_MAXIMIZED;
  7296. private static _ALPHA_ONEONE;
  7297. private static _ALPHA_PREMULTIPLIED;
  7298. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  7299. private static _ALPHA_INTERPOLATE;
  7300. private static _ALPHA_SCREENMODE;
  7301. private static _DELAYLOADSTATE_NONE;
  7302. private static _DELAYLOADSTATE_LOADED;
  7303. private static _DELAYLOADSTATE_LOADING;
  7304. private static _DELAYLOADSTATE_NOTLOADED;
  7305. private static _TEXTUREFORMAT_ALPHA;
  7306. private static _TEXTUREFORMAT_LUMINANCE;
  7307. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7308. private static _TEXTUREFORMAT_RGB;
  7309. private static _TEXTUREFORMAT_RGBA;
  7310. private static _TEXTUREFORMAT_R;
  7311. private static _TEXTUREFORMAT_RG;
  7312. private static _TEXTURETYPE_UNSIGNED_INT;
  7313. private static _TEXTURETYPE_FLOAT;
  7314. private static _TEXTURETYPE_HALF_FLOAT;
  7315. private static _NEVER;
  7316. private static _ALWAYS;
  7317. private static _LESS;
  7318. private static _EQUAL;
  7319. private static _LEQUAL;
  7320. private static _GREATER;
  7321. private static _GEQUAL;
  7322. private static _NOTEQUAL;
  7323. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7324. static readonly NEVER: number;
  7325. /** 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 */
  7326. static readonly ALWAYS: number;
  7327. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7328. static readonly LESS: number;
  7329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7330. static readonly EQUAL: number;
  7331. /** 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 */
  7332. static readonly LEQUAL: number;
  7333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7334. static readonly GREATER: number;
  7335. /** 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 */
  7336. static readonly GEQUAL: number;
  7337. /** 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 */
  7338. static readonly NOTEQUAL: number;
  7339. private static _KEEP;
  7340. private static _REPLACE;
  7341. private static _INCR;
  7342. private static _DECR;
  7343. private static _INVERT;
  7344. private static _INCR_WRAP;
  7345. private static _DECR_WRAP;
  7346. /** Passed to stencilOperation to specify that stencil value must be kept */
  7347. static readonly KEEP: number;
  7348. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7349. static readonly REPLACE: number;
  7350. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7351. static readonly INCR: number;
  7352. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7353. static readonly DECR: number;
  7354. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7355. static readonly INVERT: number;
  7356. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7357. static readonly INCR_WRAP: number;
  7358. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7359. static readonly DECR_WRAP: number;
  7360. /** Defines that alpha blending is disabled */
  7361. static readonly ALPHA_DISABLE: number;
  7362. /** Defines that alpha blending to SRC + DEST */
  7363. static readonly ALPHA_ONEONE: number;
  7364. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7365. static readonly ALPHA_ADD: number;
  7366. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7367. static readonly ALPHA_COMBINE: number;
  7368. /** Defines that alpha blending to DEST - SRC * DEST */
  7369. static readonly ALPHA_SUBTRACT: number;
  7370. /** Defines that alpha blending to SRC * DEST */
  7371. static readonly ALPHA_MULTIPLY: number;
  7372. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7373. static readonly ALPHA_MAXIMIZED: number;
  7374. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7375. static readonly ALPHA_PREMULTIPLIED: number;
  7376. /**
  7377. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7378. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7379. */
  7380. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7381. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7382. static readonly ALPHA_INTERPOLATE: number;
  7383. /**
  7384. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7385. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7386. */
  7387. static readonly ALPHA_SCREENMODE: number;
  7388. /** Defines that the ressource is not delayed*/
  7389. static readonly DELAYLOADSTATE_NONE: number;
  7390. /** Defines that the ressource was successfully delay loaded */
  7391. static readonly DELAYLOADSTATE_LOADED: number;
  7392. /** Defines that the ressource is currently delay loading */
  7393. static readonly DELAYLOADSTATE_LOADING: number;
  7394. /** Defines that the ressource is delayed and has not started loading */
  7395. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7396. /** ALPHA */
  7397. static readonly TEXTUREFORMAT_ALPHA: number;
  7398. /** LUMINANCE */
  7399. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7400. /**
  7401. * R
  7402. */
  7403. static readonly TEXTUREFORMAT_R: number;
  7404. /**
  7405. * RG
  7406. */
  7407. static readonly TEXTUREFORMAT_RG: number;
  7408. /** LUMINANCE_ALPHA */
  7409. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7410. /** RGB */
  7411. static readonly TEXTUREFORMAT_RGB: number;
  7412. /** RGBA */
  7413. static readonly TEXTUREFORMAT_RGBA: number;
  7414. /** UNSIGNED_INT */
  7415. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7416. /** FLOAT */
  7417. static readonly TEXTURETYPE_FLOAT: number;
  7418. /** HALF_FLOAT */
  7419. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7420. private static _SCALEMODE_FLOOR;
  7421. private static _SCALEMODE_NEAREST;
  7422. private static _SCALEMODE_CEILING;
  7423. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7424. static readonly SCALEMODE_FLOOR: number;
  7425. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7426. static readonly SCALEMODE_NEAREST: number;
  7427. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7428. static readonly SCALEMODE_CEILING: number;
  7429. /**
  7430. * Returns the current version of the framework
  7431. */
  7432. static readonly Version: string;
  7433. /**
  7434. * Gets or sets the epsilon value used by collision engine
  7435. */
  7436. static CollisionsEpsilon: number;
  7437. /**
  7438. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7439. */
  7440. static CodeRepository: string;
  7441. /**
  7442. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7443. */
  7444. static ShadersRepository: string;
  7445. /**
  7446. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7447. */
  7448. forcePOTTextures: boolean;
  7449. /**
  7450. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7451. */
  7452. isFullscreen: boolean;
  7453. /**
  7454. * Gets a boolean indicating if the pointer is currently locked
  7455. */
  7456. isPointerLock: boolean;
  7457. /**
  7458. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7459. */
  7460. cullBackFaces: boolean;
  7461. /**
  7462. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7463. */
  7464. renderEvenInBackground: boolean;
  7465. /**
  7466. * Gets or sets a boolean indicating that cache can be kept between frames
  7467. */
  7468. preventCacheWipeBetweenFrames: boolean;
  7469. /**
  7470. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7471. **/
  7472. enableOfflineSupport: boolean;
  7473. /**
  7474. * 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)
  7475. **/
  7476. disableManifestCheck: boolean;
  7477. /**
  7478. * Gets the list of created scenes
  7479. */
  7480. scenes: Scene[];
  7481. /**
  7482. * Gets the list of created postprocesses
  7483. */
  7484. postProcesses: PostProcess[];
  7485. /**
  7486. * Observable event triggered each time the rendering canvas is resized
  7487. */
  7488. onResizeObservable: Observable<Engine>;
  7489. /**
  7490. * Observable event triggered each time the canvas loses focus
  7491. */
  7492. onCanvasBlurObservable: Observable<Engine>;
  7493. /**
  7494. * Observable event triggered each time the canvas gains focus
  7495. */
  7496. onCanvasFocusObservable: Observable<Engine>;
  7497. /**
  7498. * Observable event triggered each time the canvas receives pointerout event
  7499. */
  7500. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7501. /**
  7502. * Observable event triggered before each texture is initialized
  7503. */
  7504. onBeforeTextureInitObservable: Observable<Texture>;
  7505. private _vrDisplay;
  7506. private _vrSupported;
  7507. private _oldSize;
  7508. private _oldHardwareScaleFactor;
  7509. private _vrExclusivePointerMode;
  7510. private _webVRInitPromise;
  7511. /**
  7512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7514. */
  7515. readonly isInVRExclusivePointerMode: boolean;
  7516. /**
  7517. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7518. */
  7519. disableUniformBuffers: boolean;
  7520. /** @hidden */
  7521. _uniformBuffers: UniformBuffer[];
  7522. /**
  7523. * Gets a boolean indicating that the engine supports uniform buffers
  7524. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7525. */
  7526. readonly supportsUniformBuffers: boolean;
  7527. /**
  7528. * Observable raised when the engine begins a new frame
  7529. */
  7530. onBeginFrameObservable: Observable<Engine>;
  7531. /**
  7532. * Observable raised when the engine ends the current frame
  7533. */
  7534. onEndFrameObservable: Observable<Engine>;
  7535. /**
  7536. * Observable raised when the engine is about to compile a shader
  7537. */
  7538. onBeforeShaderCompilationObservable: Observable<Engine>;
  7539. /**
  7540. * Observable raised when the engine has jsut compiled a shader
  7541. */
  7542. onAfterShaderCompilationObservable: Observable<Engine>;
  7543. private _gl;
  7544. private _renderingCanvas;
  7545. private _windowIsBackground;
  7546. private _webGLVersion;
  7547. /**
  7548. * Gets a boolean indicating that only power of 2 textures are supported
  7549. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7550. */
  7551. readonly needPOTTextures: boolean;
  7552. /** @hidden */
  7553. _badOS: boolean;
  7554. /** @hidden */
  7555. _badDesktopOS: boolean;
  7556. /**
  7557. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7558. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7559. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7560. */
  7561. disableTextureBindingOptimization: boolean;
  7562. /**
  7563. * Gets the audio engine
  7564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7565. * @ignorenaming
  7566. */
  7567. static audioEngine: AudioEngine;
  7568. private _onFocus;
  7569. private _onBlur;
  7570. private _onCanvasPointerOut;
  7571. private _onCanvasBlur;
  7572. private _onCanvasFocus;
  7573. private _onFullscreenChange;
  7574. private _onPointerLockChange;
  7575. private _onVRDisplayPointerRestricted;
  7576. private _onVRDisplayPointerUnrestricted;
  7577. private _onVrDisplayConnect;
  7578. private _onVrDisplayDisconnect;
  7579. private _onVrDisplayPresentChange;
  7580. /**
  7581. * Observable signaled when VR display mode changes
  7582. */
  7583. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7584. /**
  7585. * Observable signaled when VR request present is complete
  7586. */
  7587. onVRRequestPresentComplete: Observable<boolean>;
  7588. /**
  7589. * Observable signaled when VR request present starts
  7590. */
  7591. onVRRequestPresentStart: Observable<Engine>;
  7592. private _hardwareScalingLevel;
  7593. /** @hidden */
  7594. protected _caps: EngineCapabilities;
  7595. private _pointerLockRequested;
  7596. private _isStencilEnable;
  7597. private _colorWrite;
  7598. private _loadingScreen;
  7599. /** @hidden */
  7600. _drawCalls: PerfCounter;
  7601. /** @hidden */
  7602. _textureCollisions: PerfCounter;
  7603. private _glVersion;
  7604. private _glRenderer;
  7605. private _glVendor;
  7606. private _videoTextureSupported;
  7607. private _renderingQueueLaunched;
  7608. private _activeRenderLoops;
  7609. private _deterministicLockstep;
  7610. private _lockstepMaxSteps;
  7611. /**
  7612. * Observable signaled when a context lost event is raised
  7613. */
  7614. onContextLostObservable: Observable<Engine>;
  7615. /**
  7616. * Observable signaled when a context restored event is raised
  7617. */
  7618. onContextRestoredObservable: Observable<Engine>;
  7619. private _onContextLost;
  7620. private _onContextRestored;
  7621. private _contextWasLost;
  7622. private _doNotHandleContextLost;
  7623. /**
  7624. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7626. */
  7627. doNotHandleContextLost: boolean;
  7628. private _performanceMonitor;
  7629. private _fps;
  7630. private _deltaTime;
  7631. /**
  7632. * Turn this value on if you want to pause FPS computation when in background
  7633. */
  7634. disablePerformanceMonitorInBackground: boolean;
  7635. /**
  7636. * Gets the performance monitor attached to this engine
  7637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7638. */
  7639. readonly performanceMonitor: PerformanceMonitor;
  7640. /** @hidden */
  7641. protected _depthCullingState: _DepthCullingState;
  7642. /** @hidden */
  7643. protected _stencilState: _StencilState;
  7644. /** @hidden */
  7645. protected _alphaState: _AlphaState;
  7646. /** @hidden */
  7647. protected _alphaMode: number;
  7648. protected _internalTexturesCache: InternalTexture[];
  7649. /** @hidden */
  7650. protected _activeChannel: number;
  7651. private _currentTextureChannel;
  7652. /** @hidden */
  7653. protected _boundTexturesCache: {
  7654. [key: string]: Nullable<InternalTexture>;
  7655. };
  7656. /** @hidden */
  7657. protected _currentEffect: Nullable<Effect>;
  7658. /** @hidden */
  7659. protected _currentProgram: Nullable<WebGLProgram>;
  7660. private _compiledEffects;
  7661. private _vertexAttribArraysEnabled;
  7662. /** @hidden */
  7663. protected _cachedViewport: Nullable<Viewport>;
  7664. private _cachedVertexArrayObject;
  7665. /** @hidden */
  7666. protected _cachedVertexBuffers: any;
  7667. /** @hidden */
  7668. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7669. /** @hidden */
  7670. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7671. /** @hidden */
  7672. protected _currentRenderTarget: Nullable<InternalTexture>;
  7673. private _uintIndicesCurrentlySet;
  7674. private _currentBoundBuffer;
  7675. /** @hidden */
  7676. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7677. private _currentBufferPointers;
  7678. private _currentInstanceLocations;
  7679. private _currentInstanceBuffers;
  7680. private _textureUnits;
  7681. private _firstBoundInternalTextureTracker;
  7682. private _lastBoundInternalTextureTracker;
  7683. private _workingCanvas;
  7684. private _workingContext;
  7685. private _rescalePostProcess;
  7686. private _dummyFramebuffer;
  7687. private _externalData;
  7688. private _bindedRenderFunction;
  7689. private _vaoRecordInProgress;
  7690. private _mustWipeVertexAttributes;
  7691. private _emptyTexture;
  7692. private _emptyCubeTexture;
  7693. private _emptyTexture3D;
  7694. private _frameHandler;
  7695. private _nextFreeTextureSlots;
  7696. private _maxSimultaneousTextures;
  7697. private _activeRequests;
  7698. private _texturesSupported;
  7699. private _textureFormatInUse;
  7700. /**
  7701. * Gets the list of texture formats supported
  7702. */
  7703. readonly texturesSupported: Array<string>;
  7704. /**
  7705. * Gets the list of texture formats in use
  7706. */
  7707. readonly textureFormatInUse: Nullable<string>;
  7708. /**
  7709. * Gets the current viewport
  7710. */
  7711. readonly currentViewport: Nullable<Viewport>;
  7712. /**
  7713. * Gets the default empty texture
  7714. */
  7715. readonly emptyTexture: InternalTexture;
  7716. /**
  7717. * Gets the default empty 3D texture
  7718. */
  7719. readonly emptyTexture3D: InternalTexture;
  7720. /**
  7721. * Gets the default empty cube texture
  7722. */
  7723. readonly emptyCubeTexture: InternalTexture;
  7724. /**
  7725. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7726. */
  7727. readonly premultipliedAlpha: boolean;
  7728. /**
  7729. * Creates a new engine
  7730. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7731. * @param antialias defines enable antialiasing (default: false)
  7732. * @param options defines further options to be sent to the getContext() function
  7733. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7734. */
  7735. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7736. private _rebuildInternalTextures();
  7737. private _rebuildEffects();
  7738. private _rebuildBuffers();
  7739. private _initGLContext();
  7740. /**
  7741. * Gets version of the current webGL context
  7742. */
  7743. readonly webGLVersion: number;
  7744. /**
  7745. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7746. */
  7747. readonly isStencilEnable: boolean;
  7748. private _prepareWorkingCanvas();
  7749. /**
  7750. * Reset the texture cache to empty state
  7751. */
  7752. resetTextureCache(): void;
  7753. /**
  7754. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7756. * @returns true if engine is in deterministic lock step mode
  7757. */
  7758. isDeterministicLockStep(): boolean;
  7759. /**
  7760. * Gets the max steps when engine is running in deterministic lock step
  7761. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7762. * @returns the max steps
  7763. */
  7764. getLockstepMaxSteps(): number;
  7765. /**
  7766. * Gets an object containing information about the current webGL context
  7767. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7768. */
  7769. getGlInfo(): {
  7770. vendor: string;
  7771. renderer: string;
  7772. version: string;
  7773. };
  7774. /**
  7775. * Gets current aspect ratio
  7776. * @param camera defines the camera to use to get the aspect ratio
  7777. * @param useScreen defines if screen size must be used (or the current render target if any)
  7778. * @returns a number defining the aspect ratio
  7779. */
  7780. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7781. /**
  7782. * Gets current screen aspect ratio
  7783. * @returns a number defining the aspect ratio
  7784. */
  7785. getScreenAspectRatio(): number;
  7786. /**
  7787. * Gets the current render width
  7788. * @param useScreen defines if screen size must be used (or the current render target if any)
  7789. * @returns a number defining the current render width
  7790. */
  7791. getRenderWidth(useScreen?: boolean): number;
  7792. /**
  7793. * Gets the current render height
  7794. * @param useScreen defines if screen size must be used (or the current render target if any)
  7795. * @returns a number defining the current render height
  7796. */
  7797. getRenderHeight(useScreen?: boolean): number;
  7798. /**
  7799. * Gets the HTML canvas attached with the current webGL context
  7800. * @returns a HTML canvas
  7801. */
  7802. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7803. /**
  7804. * Gets the client rect of the HTML canvas attached with the current webGL context
  7805. * @returns a client rectanglee
  7806. */
  7807. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7808. /**
  7809. * Defines the hardware scaling level.
  7810. * By default the hardware scaling level is computed from the window device ratio.
  7811. * 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.
  7812. * @param level defines the level to use
  7813. */
  7814. setHardwareScalingLevel(level: number): void;
  7815. /**
  7816. * Gets the current hardware scaling level.
  7817. * By default the hardware scaling level is computed from the window device ratio.
  7818. * 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.
  7819. * @returns a number indicating the current hardware scaling level
  7820. */
  7821. getHardwareScalingLevel(): number;
  7822. /**
  7823. * Gets the list of loaded textures
  7824. * @returns an array containing all loaded textures
  7825. */
  7826. getLoadedTexturesCache(): InternalTexture[];
  7827. /**
  7828. * Gets the object containing all engine capabilities
  7829. * @returns the EngineCapabilities object
  7830. */
  7831. getCaps(): EngineCapabilities;
  7832. /** @hidden */
  7833. readonly drawCalls: number;
  7834. /** @hidden */
  7835. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7836. /**
  7837. * Gets the current depth function
  7838. * @returns a number defining the depth function
  7839. */
  7840. getDepthFunction(): Nullable<number>;
  7841. /**
  7842. * Sets the current depth function
  7843. * @param depthFunc defines the function to use
  7844. */
  7845. setDepthFunction(depthFunc: number): void;
  7846. /**
  7847. * Sets the current depth function to GREATER
  7848. */
  7849. setDepthFunctionToGreater(): void;
  7850. /**
  7851. * Sets the current depth function to GEQUAL
  7852. */
  7853. setDepthFunctionToGreaterOrEqual(): void;
  7854. /**
  7855. * Sets the current depth function to LESS
  7856. */
  7857. setDepthFunctionToLess(): void;
  7858. /**
  7859. * Sets the current depth function to LEQUAL
  7860. */
  7861. setDepthFunctionToLessOrEqual(): void;
  7862. /**
  7863. * Gets a boolean indicating if stencil buffer is enabled
  7864. * @returns the current stencil buffer state
  7865. */
  7866. getStencilBuffer(): boolean;
  7867. /**
  7868. * Enable or disable the stencil buffer
  7869. * @param enable defines if the stencil buffer must be enabled or disabled
  7870. */
  7871. setStencilBuffer(enable: boolean): void;
  7872. /**
  7873. * Gets the current stencil mask
  7874. * @returns a number defining the new stencil mask to use
  7875. */
  7876. getStencilMask(): number;
  7877. /**
  7878. * Sets the current stencil mask
  7879. * @param mask defines the new stencil mask to use
  7880. */
  7881. setStencilMask(mask: number): void;
  7882. /**
  7883. * Gets the current stencil function
  7884. * @returns a number defining the stencil function to use
  7885. */
  7886. getStencilFunction(): number;
  7887. /**
  7888. * Gets the current stencil reference value
  7889. * @returns a number defining the stencil reference value to use
  7890. */
  7891. getStencilFunctionReference(): number;
  7892. /**
  7893. * Gets the current stencil mask
  7894. * @returns a number defining the stencil mask to use
  7895. */
  7896. getStencilFunctionMask(): number;
  7897. /**
  7898. * Sets the current stencil function
  7899. * @param stencilFunc defines the new stencil function to use
  7900. */
  7901. setStencilFunction(stencilFunc: number): void;
  7902. /**
  7903. * Sets the current stencil reference
  7904. * @param reference defines the new stencil reference to use
  7905. */
  7906. setStencilFunctionReference(reference: number): void;
  7907. /**
  7908. * Sets the current stencil mask
  7909. * @param mask defines the new stencil mask to use
  7910. */
  7911. setStencilFunctionMask(mask: number): void;
  7912. /**
  7913. * Gets the current stencil operation when stencil fails
  7914. * @returns a number defining stencil operation to use when stencil fails
  7915. */
  7916. getStencilOperationFail(): number;
  7917. /**
  7918. * Gets the current stencil operation when depth fails
  7919. * @returns a number defining stencil operation to use when depth fails
  7920. */
  7921. getStencilOperationDepthFail(): number;
  7922. /**
  7923. * Gets the current stencil operation when stencil passes
  7924. * @returns a number defining stencil operation to use when stencil passes
  7925. */
  7926. getStencilOperationPass(): number;
  7927. /**
  7928. * Sets the stencil operation to use when stencil fails
  7929. * @param operation defines the stencil operation to use when stencil fails
  7930. */
  7931. setStencilOperationFail(operation: number): void;
  7932. /**
  7933. * Sets the stencil operation to use when depth fails
  7934. * @param operation defines the stencil operation to use when depth fails
  7935. */
  7936. setStencilOperationDepthFail(operation: number): void;
  7937. /**
  7938. * Sets the stencil operation to use when stencil passes
  7939. * @param operation defines the stencil operation to use when stencil passes
  7940. */
  7941. setStencilOperationPass(operation: number): void;
  7942. /**
  7943. * Sets a boolean indicating if the dithering state is enabled or disabled
  7944. * @param value defines the dithering state
  7945. */
  7946. setDitheringState(value: boolean): void;
  7947. /**
  7948. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7949. * @param value defines the rasterizer state
  7950. */
  7951. setRasterizerState(value: boolean): void;
  7952. /**
  7953. * stop executing a render loop function and remove it from the execution array
  7954. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7955. */
  7956. stopRenderLoop(renderFunction?: () => void): void;
  7957. /** @hidden */
  7958. _renderLoop(): void;
  7959. /**
  7960. * Register and execute a render loop. The engine can have more than one render function
  7961. * @param renderFunction defines the function to continuously execute
  7962. */
  7963. runRenderLoop(renderFunction: () => void): void;
  7964. /**
  7965. * Toggle full screen mode
  7966. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7967. * @param options defines an option object to be sent to the requestFullscreen function
  7968. */
  7969. switchFullscreen(requestPointerLock: boolean): void;
  7970. /**
  7971. * Clear the current render buffer or the current render target (if any is set up)
  7972. * @param color defines the color to use
  7973. * @param backBuffer defines if the back buffer must be cleared
  7974. * @param depth defines if the depth buffer must be cleared
  7975. * @param stencil defines if the stencil buffer must be cleared
  7976. */
  7977. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7978. /**
  7979. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7980. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7981. * @param y defines the y-coordinate of the corner of the clear rectangle
  7982. * @param width defines the width of the clear rectangle
  7983. * @param height defines the height of the clear rectangle
  7984. * @param clearColor defines the clear color
  7985. */
  7986. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7987. private _viewportCached;
  7988. /** @hidden */
  7989. _viewport(x: number, y: number, width: number, height: number): void;
  7990. /**
  7991. * Set the WebGL's viewport
  7992. * @param viewport defines the viewport element to be used
  7993. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7994. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7995. */
  7996. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7997. /**
  7998. * Directly set the WebGL Viewport
  7999. * @param x defines the x coordinate of the viewport (in screen space)
  8000. * @param y defines the y coordinate of the viewport (in screen space)
  8001. * @param width defines the width of the viewport (in screen space)
  8002. * @param height defines the height of the viewport (in screen space)
  8003. * @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
  8004. */
  8005. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8006. /**
  8007. * Begin a new frame
  8008. */
  8009. beginFrame(): void;
  8010. /**
  8011. * Enf the current frame
  8012. */
  8013. endFrame(): void;
  8014. /**
  8015. * Resize the view according to the canvas' size
  8016. */
  8017. resize(): void;
  8018. /**
  8019. * Force a specific size of the canvas
  8020. * @param width defines the new canvas' width
  8021. * @param height defines the new canvas' height
  8022. */
  8023. setSize(width: number, height: number): void;
  8024. /**
  8025. * Gets a boolean indicating if a webVR device was detected
  8026. * @returns true if a webVR device was detected
  8027. */
  8028. isVRDevicePresent(): boolean;
  8029. /**
  8030. * Gets the current webVR device
  8031. * @returns the current webVR device (or null)
  8032. */
  8033. getVRDevice(): any;
  8034. /**
  8035. * Initializes a webVR display and starts listening to display change events
  8036. * The onVRDisplayChangedObservable will be notified upon these changes
  8037. * @returns The onVRDisplayChangedObservable
  8038. */
  8039. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8040. /**
  8041. * Initializes a webVR display and starts listening to display change events
  8042. * The onVRDisplayChangedObservable will be notified upon these changes
  8043. * @returns A promise containing a VRDisplay and if vr is supported
  8044. */
  8045. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8046. /**
  8047. * Call this function to switch to webVR mode
  8048. * Will do nothing if webVR is not supported or if there is no webVR device
  8049. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8050. */
  8051. enableVR(): void;
  8052. /**
  8053. * Call this function to leave webVR mode
  8054. * Will do nothing if webVR is not supported or if there is no webVR device
  8055. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8056. */
  8057. disableVR(): void;
  8058. private _onVRFullScreenTriggered;
  8059. private _getVRDisplaysAsync();
  8060. /**
  8061. * Binds the frame buffer to the specified texture.
  8062. * @param texture The texture to render to or null for the default canvas
  8063. * @param faceIndex The face of the texture to render to in case of cube texture
  8064. * @param requiredWidth The width of the target to render to
  8065. * @param requiredHeight The height of the target to render to
  8066. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8067. * @param depthStencilTexture The depth stencil texture to use to render
  8068. * @param lodLevel defines le lod level to bind to the frame buffer
  8069. */
  8070. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8071. private bindUnboundFramebuffer(framebuffer);
  8072. /**
  8073. * Unbind the current render target texture from the webGL context
  8074. * @param texture defines the render target texture to unbind
  8075. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8076. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8077. */
  8078. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8079. /**
  8080. * Unbind a list of render target textures from the webGL context
  8081. * This is used only when drawBuffer extension or webGL2 are active
  8082. * @param textures defines the render target textures to unbind
  8083. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8084. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8085. */
  8086. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8087. /**
  8088. * Force the mipmap generation for the given render target texture
  8089. * @param texture defines the render target texture to use
  8090. */
  8091. generateMipMapsForCubemap(texture: InternalTexture): void;
  8092. /**
  8093. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8094. */
  8095. flushFramebuffer(): void;
  8096. /**
  8097. * Unbind the current render target and bind the default framebuffer
  8098. */
  8099. restoreDefaultFramebuffer(): void;
  8100. /**
  8101. * Create an uniform buffer
  8102. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8103. * @param elements defines the content of the uniform buffer
  8104. * @returns the webGL uniform buffer
  8105. */
  8106. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8107. /**
  8108. * Create a dynamic uniform buffer
  8109. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8110. * @param elements defines the content of the uniform buffer
  8111. * @returns the webGL uniform buffer
  8112. */
  8113. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8114. /**
  8115. * Update an existing uniform buffer
  8116. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8117. * @param uniformBuffer defines the target uniform buffer
  8118. * @param elements defines the content to update
  8119. * @param offset defines the offset in the uniform buffer where update should start
  8120. * @param count defines the size of the data to update
  8121. */
  8122. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8123. private _resetVertexBufferBinding();
  8124. /**
  8125. * Creates a vertex buffer
  8126. * @param data the data for the vertex buffer
  8127. * @returns the new WebGL static buffer
  8128. */
  8129. createVertexBuffer(data: DataArray): WebGLBuffer;
  8130. /**
  8131. * Creates a dynamic vertex buffer
  8132. * @param data the data for the dynamic vertex buffer
  8133. * @returns the new WebGL dynamic buffer
  8134. */
  8135. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8136. /**
  8137. * Update a dynamic index buffer
  8138. * @param indexBuffer defines the target index buffer
  8139. * @param indices defines the data to update
  8140. * @param offset defines the offset in the target index buffer where update should start
  8141. */
  8142. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8143. /**
  8144. * Updates a dynamic vertex buffer.
  8145. * @param vertexBuffer the vertex buffer to update
  8146. * @param data the data used to update the vertex buffer
  8147. * @param byteOffset the byte offset of the data
  8148. * @param byteLength the byte length of the data
  8149. */
  8150. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8151. private _resetIndexBufferBinding();
  8152. /**
  8153. * Creates a new index buffer
  8154. * @param indices defines the content of the index buffer
  8155. * @param updatable defines if the index buffer must be updatable
  8156. * @returns a new webGL buffer
  8157. */
  8158. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8159. /**
  8160. * Bind a webGL buffer to the webGL context
  8161. * @param buffer defines the buffer to bind
  8162. */
  8163. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8164. /**
  8165. * Bind an uniform buffer to the current webGL context
  8166. * @param buffer defines the buffer to bind
  8167. */
  8168. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8169. /**
  8170. * Bind a buffer to the current webGL context at a given location
  8171. * @param buffer defines the buffer to bind
  8172. * @param location defines the index where to bind the buffer
  8173. */
  8174. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8175. /**
  8176. * Bind a specific block at a given index in a specific shader program
  8177. * @param shaderProgram defines the shader program
  8178. * @param blockName defines the block name
  8179. * @param index defines the index where to bind the block
  8180. */
  8181. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8182. private bindIndexBuffer(buffer);
  8183. private bindBuffer(buffer, target);
  8184. /**
  8185. * update the bound buffer with the given data
  8186. * @param data defines the data to update
  8187. */
  8188. updateArrayBuffer(data: Float32Array): void;
  8189. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  8190. private _bindIndexBufferWithCache(indexBuffer);
  8191. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  8192. /**
  8193. * Records a vertex array object
  8194. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8195. * @param vertexBuffers defines the list of vertex buffers to store
  8196. * @param indexBuffer defines the index buffer to store
  8197. * @param effect defines the effect to store
  8198. * @returns the new vertex array object
  8199. */
  8200. recordVertexArrayObject(vertexBuffers: {
  8201. [key: string]: VertexBuffer;
  8202. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8203. /**
  8204. * Bind a specific vertex array object
  8205. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8206. * @param vertexArrayObject defines the vertex array object to bind
  8207. * @param indexBuffer defines the index buffer to bind
  8208. */
  8209. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8210. /**
  8211. * Bind webGl buffers directly to the webGL context
  8212. * @param vertexBuffer defines the vertex buffer to bind
  8213. * @param indexBuffer defines the index buffer to bind
  8214. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8215. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8216. * @param effect defines the effect associated with the vertex buffer
  8217. */
  8218. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8219. private _unbindVertexArrayObject();
  8220. /**
  8221. * Bind a list of vertex buffers to the webGL context
  8222. * @param vertexBuffers defines the list of vertex buffers to bind
  8223. * @param indexBuffer defines the index buffer to bind
  8224. * @param effect defines the effect associated with the vertex buffers
  8225. */
  8226. bindBuffers(vertexBuffers: {
  8227. [key: string]: Nullable<VertexBuffer>;
  8228. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8229. /**
  8230. * Unbind all instance attributes
  8231. */
  8232. unbindInstanceAttributes(): void;
  8233. /**
  8234. * Release and free the memory of a vertex array object
  8235. * @param vao defines the vertex array object to delete
  8236. */
  8237. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8238. /** @hidden */
  8239. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8240. /**
  8241. * Creates a webGL buffer to use with instanciation
  8242. * @param capacity defines the size of the buffer
  8243. * @returns the webGL buffer
  8244. */
  8245. createInstancesBuffer(capacity: number): WebGLBuffer;
  8246. /**
  8247. * Delete a webGL buffer used with instanciation
  8248. * @param buffer defines the webGL buffer to delete
  8249. */
  8250. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8251. /**
  8252. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8253. * @param instancesBuffer defines the webGL buffer to update and bind
  8254. * @param data defines the data to store in the buffer
  8255. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8256. */
  8257. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8258. /**
  8259. * Apply all cached states (depth, culling, stencil and alpha)
  8260. */
  8261. applyStates(): void;
  8262. /**
  8263. * Send a draw order
  8264. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8265. * @param indexStart defines the starting index
  8266. * @param indexCount defines the number of index to draw
  8267. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8268. */
  8269. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8270. /**
  8271. * Draw a list of points
  8272. * @param verticesStart defines the index of first vertex to draw
  8273. * @param verticesCount defines the count of vertices to draw
  8274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8275. */
  8276. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8277. /**
  8278. * Draw a list of unindexed primitives
  8279. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8280. * @param verticesStart defines the index of first vertex to draw
  8281. * @param verticesCount defines the count of vertices to draw
  8282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8283. */
  8284. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8285. /**
  8286. * Draw a list of indexed primitives
  8287. * @param fillMode defines the primitive to use
  8288. * @param indexStart defines the starting index
  8289. * @param indexCount defines the number of index to draw
  8290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8291. */
  8292. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8293. /**
  8294. * Draw a list of unindexed primitives
  8295. * @param fillMode defines the primitive to use
  8296. * @param verticesStart defines the index of first vertex to draw
  8297. * @param verticesCount defines the count of vertices to draw
  8298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8299. */
  8300. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8301. private _drawMode(fillMode);
  8302. /** @hidden */
  8303. _releaseEffect(effect: Effect): void;
  8304. /** @hidden */
  8305. _deleteProgram(program: WebGLProgram): void;
  8306. /**
  8307. * Create a new effect (used to store vertex/fragment shaders)
  8308. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8309. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8310. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8311. * @param samplers defines an array of string used to represent textures
  8312. * @param defines defines the string containing the defines to use to compile the shaders
  8313. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8314. * @param onCompiled defines a function to call when the effect creation is successful
  8315. * @param onError defines a function to call when the effect creation has failed
  8316. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8317. * @returns the new Effect
  8318. */
  8319. 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;
  8320. /**
  8321. * Create an effect to use with particle systems
  8322. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8323. * @param uniformsNames defines a list of attribute names
  8324. * @param samplers defines an array of string used to represent textures
  8325. * @param defines defines the string containing the defines to use to compile the shaders
  8326. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8327. * @param onCompiled defines a function to call when the effect creation is successful
  8328. * @param onError defines a function to call when the effect creation has failed
  8329. * @returns the new Effect
  8330. */
  8331. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8332. /**
  8333. * Directly creates a webGL program
  8334. * @param vertexCode defines the vertex shader code to use
  8335. * @param fragmentCode defines the fragment shader code to use
  8336. * @param context defines the webGL context to use (if not set, the current one will be used)
  8337. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8338. * @returns the new webGL program
  8339. */
  8340. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8341. /**
  8342. * Creates a webGL program
  8343. * @param vertexCode defines the vertex shader code to use
  8344. * @param fragmentCode defines the fragment shader code to use
  8345. * @param defines defines the string containing the defines to use to compile the shaders
  8346. * @param context defines the webGL context to use (if not set, the current one will be used)
  8347. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8348. * @returns the new webGL program
  8349. */
  8350. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8351. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8352. /**
  8353. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8354. * @param shaderProgram defines the webGL program to use
  8355. * @param uniformsNames defines the list of uniform names
  8356. * @returns an array of webGL uniform locations
  8357. */
  8358. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8359. /**
  8360. * Gets the lsit of active attributes for a given webGL program
  8361. * @param shaderProgram defines the webGL program to use
  8362. * @param attributesNames defines the list of attribute names to get
  8363. * @returns an array of indices indicating the offset of each attribute
  8364. */
  8365. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8366. /**
  8367. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8368. * @param effect defines the effect to activate
  8369. */
  8370. enableEffect(effect: Nullable<Effect>): void;
  8371. /**
  8372. * Set the value of an uniform to an array of int32
  8373. * @param uniform defines the webGL uniform location where to store the value
  8374. * @param array defines the array of int32 to store
  8375. */
  8376. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8377. /**
  8378. * Set the value of an uniform to an array of int32 (stored as vec2)
  8379. * @param uniform defines the webGL uniform location where to store the value
  8380. * @param array defines the array of int32 to store
  8381. */
  8382. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8383. /**
  8384. * Set the value of an uniform to an array of int32 (stored as vec3)
  8385. * @param uniform defines the webGL uniform location where to store the value
  8386. * @param array defines the array of int32 to store
  8387. */
  8388. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8389. /**
  8390. * Set the value of an uniform to an array of int32 (stored as vec4)
  8391. * @param uniform defines the webGL uniform location where to store the value
  8392. * @param array defines the array of int32 to store
  8393. */
  8394. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8395. /**
  8396. * Set the value of an uniform to an array of float32
  8397. * @param uniform defines the webGL uniform location where to store the value
  8398. * @param array defines the array of float32 to store
  8399. */
  8400. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8401. /**
  8402. * Set the value of an uniform to an array of float32 (stored as vec2)
  8403. * @param uniform defines the webGL uniform location where to store the value
  8404. * @param array defines the array of float32 to store
  8405. */
  8406. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8407. /**
  8408. * Set the value of an uniform to an array of float32 (stored as vec3)
  8409. * @param uniform defines the webGL uniform location where to store the value
  8410. * @param array defines the array of float32 to store
  8411. */
  8412. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8413. /**
  8414. * Set the value of an uniform to an array of float32 (stored as vec4)
  8415. * @param uniform defines the webGL uniform location where to store the value
  8416. * @param array defines the array of float32 to store
  8417. */
  8418. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8419. /**
  8420. * Set the value of an uniform to an array of number
  8421. * @param uniform defines the webGL uniform location where to store the value
  8422. * @param array defines the array of number to store
  8423. */
  8424. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8425. /**
  8426. * Set the value of an uniform to an array of number (stored as vec2)
  8427. * @param uniform defines the webGL uniform location where to store the value
  8428. * @param array defines the array of number to store
  8429. */
  8430. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8431. /**
  8432. * Set the value of an uniform to an array of number (stored as vec3)
  8433. * @param uniform defines the webGL uniform location where to store the value
  8434. * @param array defines the array of number to store
  8435. */
  8436. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8437. /**
  8438. * Set the value of an uniform to an array of number (stored as vec4)
  8439. * @param uniform defines the webGL uniform location where to store the value
  8440. * @param array defines the array of number to store
  8441. */
  8442. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8443. /**
  8444. * Set the value of an uniform to an array of float32 (stored as matrices)
  8445. * @param uniform defines the webGL uniform location where to store the value
  8446. * @param matrices defines the array of float32 to store
  8447. */
  8448. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8449. /**
  8450. * Set the value of an uniform to a matrix
  8451. * @param uniform defines the webGL uniform location where to store the value
  8452. * @param matrix defines the matrix to store
  8453. */
  8454. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8455. /**
  8456. * Set the value of an uniform to a matrix (3x3)
  8457. * @param uniform defines the webGL uniform location where to store the value
  8458. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8459. */
  8460. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8461. /**
  8462. * Set the value of an uniform to a matrix (2x2)
  8463. * @param uniform defines the webGL uniform location where to store the value
  8464. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8465. */
  8466. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8467. /**
  8468. * Set the value of an uniform to a number (int)
  8469. * @param uniform defines the webGL uniform location where to store the value
  8470. * @param value defines the int number to store
  8471. */
  8472. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8473. /**
  8474. * Set the value of an uniform to a number (float)
  8475. * @param uniform defines the webGL uniform location where to store the value
  8476. * @param value defines the float number to store
  8477. */
  8478. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8479. /**
  8480. * Set the value of an uniform to a vec2
  8481. * @param uniform defines the webGL uniform location where to store the value
  8482. * @param x defines the 1st component of the value
  8483. * @param y defines the 2nd component of the value
  8484. */
  8485. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8486. /**
  8487. * Set the value of an uniform to a vec3
  8488. * @param uniform defines the webGL uniform location where to store the value
  8489. * @param x defines the 1st component of the value
  8490. * @param y defines the 2nd component of the value
  8491. * @param z defines the 3rd component of the value
  8492. */
  8493. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8494. /**
  8495. * Set the value of an uniform to a boolean
  8496. * @param uniform defines the webGL uniform location where to store the value
  8497. * @param bool defines the boolean to store
  8498. */
  8499. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8500. /**
  8501. * Set the value of an uniform to a vec4
  8502. * @param uniform defines the webGL uniform location where to store the value
  8503. * @param x defines the 1st component of the value
  8504. * @param y defines the 2nd component of the value
  8505. * @param z defines the 3rd component of the value
  8506. * @param w defines the 4th component of the value
  8507. */
  8508. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8509. /**
  8510. * Set the value of an uniform to a Color3
  8511. * @param uniform defines the webGL uniform location where to store the value
  8512. * @param color3 defines the color to store
  8513. */
  8514. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8515. /**
  8516. * Set the value of an uniform to a Color3 and an alpha value
  8517. * @param uniform defines the webGL uniform location where to store the value
  8518. * @param color3 defines the color to store
  8519. * @param alpha defines the alpha component to store
  8520. */
  8521. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8522. /**
  8523. * Sets a Color4 on a uniform variable
  8524. * @param uniform defines the uniform location
  8525. * @param color4 defines the value to be set
  8526. */
  8527. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8528. /**
  8529. * Set various states to the webGL context
  8530. * @param culling defines backface culling state
  8531. * @param zOffset defines the value to apply to zOffset (0 by default)
  8532. * @param force defines if states must be applied even if cache is up to date
  8533. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8534. */
  8535. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8536. /**
  8537. * Set the z offset to apply to current rendering
  8538. * @param value defines the offset to apply
  8539. */
  8540. setZOffset(value: number): void;
  8541. /**
  8542. * Gets the current value of the zOffset
  8543. * @returns the current zOffset state
  8544. */
  8545. getZOffset(): number;
  8546. /**
  8547. * Enable or disable depth buffering
  8548. * @param enable defines the state to set
  8549. */
  8550. setDepthBuffer(enable: boolean): void;
  8551. /**
  8552. * Gets a boolean indicating if depth writing is enabled
  8553. * @returns the current depth writing state
  8554. */
  8555. getDepthWrite(): boolean;
  8556. /**
  8557. * Enable or disable depth writing
  8558. * @param enable defines the state to set
  8559. */
  8560. setDepthWrite(enable: boolean): void;
  8561. /**
  8562. * Enable or disable color writing
  8563. * @param enable defines the state to set
  8564. */
  8565. setColorWrite(enable: boolean): void;
  8566. /**
  8567. * Gets a boolean indicating if color writing is enabled
  8568. * @returns the current color writing state
  8569. */
  8570. getColorWrite(): boolean;
  8571. /**
  8572. * Sets alpha constants used by some alpha blending modes
  8573. * @param r defines the red component
  8574. * @param g defines the green component
  8575. * @param b defines the blue component
  8576. * @param a defines the alpha component
  8577. */
  8578. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8579. /**
  8580. * Sets the current alpha mode
  8581. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8582. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8583. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8584. */
  8585. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8586. /**
  8587. * Gets the current alpha mode
  8588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8589. * @returns the current alpha mode
  8590. */
  8591. getAlphaMode(): number;
  8592. /**
  8593. * Clears the list of texture accessible through engine.
  8594. * This can help preventing texture load conflict due to name collision.
  8595. */
  8596. clearInternalTexturesCache(): void;
  8597. /**
  8598. * Force the entire cache to be cleared
  8599. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8600. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8601. */
  8602. wipeCaches(bruteForce?: boolean): void;
  8603. /**
  8604. * Set the compressed texture format to use, based on the formats you have, and the formats
  8605. * supported by the hardware / browser.
  8606. *
  8607. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8608. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8609. * to API arguments needed to compressed textures. This puts the burden on the container
  8610. * generator to house the arcane code for determining these for current & future formats.
  8611. *
  8612. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8613. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8614. *
  8615. * Note: The result of this call is not taken into account when a texture is base64.
  8616. *
  8617. * @param formatsAvailable defines the list of those format families you have created
  8618. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8619. *
  8620. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8621. * @returns The extension selected.
  8622. */
  8623. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8624. /** @hidden */
  8625. _createTexture(): WebGLTexture;
  8626. /**
  8627. * Usually called from BABYLON.Texture.ts.
  8628. * Passed information to create a WebGLTexture
  8629. * @param urlArg defines a value which contains one of the following:
  8630. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8631. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8632. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8634. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8635. * @param scene needed for loading to the correct scene
  8636. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8637. * @param onLoad optional callback to be called upon successful completion
  8638. * @param onError optional callback to be called upon failure
  8639. * @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
  8640. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8641. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8642. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8643. */
  8644. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8645. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8646. /**
  8647. * Update a raw texture
  8648. * @param texture defines the texture to update
  8649. * @param data defines the data to store in the texture
  8650. * @param format defines the format of the data
  8651. * @param invertY defines if data must be stored with Y axis inverted
  8652. * @param compression defines the compression used (null by default)
  8653. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8654. */
  8655. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8656. /**
  8657. * Creates a raw texture
  8658. * @param data defines the data to store in the texture
  8659. * @param width defines the width of the texture
  8660. * @param height defines the height of the texture
  8661. * @param format defines the format of the data
  8662. * @param generateMipMaps defines if the engine should generate the mip levels
  8663. * @param invertY defines if data must be stored with Y axis inverted
  8664. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8665. * @param compression defines the compression used (null by default)
  8666. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8667. * @returns the raw texture inside an InternalTexture
  8668. */
  8669. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8670. private _unpackFlipYCached;
  8671. /** @hidden */
  8672. _unpackFlipY(value: boolean): void;
  8673. /**
  8674. * Creates a dynamic texture
  8675. * @param width defines the width of the texture
  8676. * @param height defines the height of the texture
  8677. * @param generateMipMaps defines if the engine should generate the mip levels
  8678. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8679. * @returns the dynamic texture inside an InternalTexture
  8680. */
  8681. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8682. /**
  8683. * Update the sampling mode of a given texture
  8684. * @param samplingMode defines the required sampling mode
  8685. * @param texture defines the texture to update
  8686. */
  8687. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8688. /**
  8689. * Update the content of a dynamic texture
  8690. * @param texture defines the texture to update
  8691. * @param canvas defines the canvas containing the source
  8692. * @param invertY defines if data must be stored with Y axis inverted
  8693. * @param premulAlpha defines if alpha is stored as premultiplied
  8694. * @param format defines the format of the data
  8695. */
  8696. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8697. /**
  8698. * Update a video texture
  8699. * @param texture defines the texture to update
  8700. * @param video defines the video element to use
  8701. * @param invertY defines if data must be stored with Y axis inverted
  8702. */
  8703. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8704. /**
  8705. * Updates a depth texture Comparison Mode and Function.
  8706. * If the comparison Function is equal to 0, the mode will be set to none.
  8707. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8708. * @param texture The texture to set the comparison function for
  8709. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8710. */
  8711. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8712. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8713. /**
  8714. * Creates a depth stencil texture.
  8715. * This is only available in WebGL 2 or with the depth texture extension available.
  8716. * @param size The size of face edge in the texture.
  8717. * @param options The options defining the texture.
  8718. * @returns The texture
  8719. */
  8720. createDepthStencilTexture(size: number | {
  8721. width: number;
  8722. height: number;
  8723. }, options: DepthTextureCreationOptions): InternalTexture;
  8724. /**
  8725. * Creates a depth stencil texture.
  8726. * This is only available in WebGL 2 or with the depth texture extension available.
  8727. * @param size The size of face edge in the texture.
  8728. * @param options The options defining the texture.
  8729. * @returns The texture
  8730. */
  8731. private _createDepthStencilTexture(size, options);
  8732. /**
  8733. * Creates a depth stencil cube texture.
  8734. * This is only available in WebGL 2.
  8735. * @param size The size of face edge in the cube texture.
  8736. * @param options The options defining the cube texture.
  8737. * @returns The cube texture
  8738. */
  8739. private _createDepthStencilCubeTexture(size, options);
  8740. /**
  8741. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8742. * @param renderTarget The render target to set the frame buffer for
  8743. */
  8744. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8745. /**
  8746. * Creates a new render target texture
  8747. * @param size defines the size of the texture
  8748. * @param options defines the options used to create the texture
  8749. * @returns a new render target texture stored in an InternalTexture
  8750. */
  8751. createRenderTargetTexture(size: number | {
  8752. width: number;
  8753. height: number;
  8754. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8755. /**
  8756. * Create a multi render target texture
  8757. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8758. * @param size defines the size of the texture
  8759. * @param options defines the creation options
  8760. * @returns the cube texture as an InternalTexture
  8761. */
  8762. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8763. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8764. /**
  8765. * Updates the sample count of a render target texture
  8766. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8767. * @param texture defines the texture to update
  8768. * @param samples defines the sample count to set
  8769. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8770. */
  8771. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8772. /**
  8773. * Update the sample count for a given multiple render target texture
  8774. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8775. * @param textures defines the textures to update
  8776. * @param samples defines the sample count to set
  8777. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8778. */
  8779. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8780. /** @hidden */
  8781. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8782. /** @hidden */
  8783. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8784. /** @hidden */
  8785. _uploadImageToTexture(texture: InternalTexture, faceIndex: number, lod: number, image: HTMLImageElement): void;
  8786. /**
  8787. * Creates a new render target cube texture
  8788. * @param size defines the size of the texture
  8789. * @param options defines the options used to create the texture
  8790. * @returns a new render target cube texture stored in an InternalTexture
  8791. */
  8792. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8793. /**
  8794. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8795. * @param rootUrl defines the url where the file to load is located
  8796. * @param scene defines the current scene
  8797. * @param lodScale defines scale to apply to the mip map selection
  8798. * @param lodOffset defines offset to apply to the mip map selection
  8799. * @param onLoad defines an optional callback raised when the texture is loaded
  8800. * @param onError defines an optional callback raised if there is an issue to load the texture
  8801. * @param format defines the format of the data
  8802. * @param forcedExtension defines the extension to use to pick the right loader
  8803. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8804. * @returns the cube texture as an InternalTexture
  8805. */
  8806. 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;
  8807. /**
  8808. * Creates a cube texture
  8809. * @param rootUrl defines the url where the files to load is located
  8810. * @param scene defines the current scene
  8811. * @param files defines the list of files to load (1 per face)
  8812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8813. * @param onLoad defines an optional callback raised when the texture is loaded
  8814. * @param onError defines an optional callback raised if there is an issue to load the texture
  8815. * @param format defines the format of the data
  8816. * @param forcedExtension defines the extension to use to pick the right loader
  8817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8820. * @returns the cube texture as an InternalTexture
  8821. */
  8822. 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): InternalTexture;
  8823. private setCubeMapTextureParams(gl, loadMipmap);
  8824. /**
  8825. * Update a raw cube texture
  8826. * @param texture defines the texture to udpdate
  8827. * @param data defines the data to store
  8828. * @param format defines the data format
  8829. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8830. * @param invertY defines if data must be stored with Y axis inverted
  8831. * @param compression defines the compression used (null by default)
  8832. * @param level defines which level of the texture to update
  8833. */
  8834. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8835. /**
  8836. * Creates a new raw cube texture
  8837. * @param data defines the array of data to use to create each face
  8838. * @param size defines the size of the textures
  8839. * @param format defines the format of the data
  8840. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8841. * @param generateMipMaps defines if the engine should generate the mip levels
  8842. * @param invertY defines if data must be stored with Y axis inverted
  8843. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8844. * @param compression defines the compression used (null by default)
  8845. * @returns the cube texture as an InternalTexture
  8846. */
  8847. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8848. /**
  8849. * Creates a new raw cube texture from a specified url
  8850. * @param url defines the url where the data is located
  8851. * @param scene defines the current scene
  8852. * @param size defines the size of the textures
  8853. * @param format defines the format of the data
  8854. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8855. * @param noMipmap defines if the engine should avoid generating the mip levels
  8856. * @param callback defines a callback used to extract texture data from loaded data
  8857. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8858. * @param onLoad defines a callback called when texture is loaded
  8859. * @param onError defines a callback called if there is an error
  8860. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8861. * @param invertY defines if data must be stored with Y axis inverted
  8862. * @returns the cube texture as an InternalTexture
  8863. */
  8864. 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;
  8865. /**
  8866. * Update a raw 3D texture
  8867. * @param texture defines the texture to update
  8868. * @param data defines the data to store
  8869. * @param format defines the data format
  8870. * @param invertY defines if data must be stored with Y axis inverted
  8871. * @param compression defines the used compression (can be null)
  8872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8873. */
  8874. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8875. /**
  8876. * Creates a new raw 3D texture
  8877. * @param data defines the data used to create the texture
  8878. * @param width defines the width of the texture
  8879. * @param height defines the height of the texture
  8880. * @param depth defines the depth of the texture
  8881. * @param format defines the format of the texture
  8882. * @param generateMipMaps defines if the engine must generate mip levels
  8883. * @param invertY defines if data must be stored with Y axis inverted
  8884. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8885. * @param compression defines the compressed used (can be null)
  8886. * @param textureType defines the compressed used (can be null)
  8887. * @returns a new raw 3D texture (stored in an InternalTexture)
  8888. */
  8889. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8890. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8891. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8892. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8893. /** @hidden */
  8894. _releaseFramebufferObjects(texture: InternalTexture): void;
  8895. /** @hidden */
  8896. _releaseTexture(texture: InternalTexture): void;
  8897. private setProgram(program);
  8898. private _boundUniforms;
  8899. /**
  8900. * Binds an effect to the webGL context
  8901. * @param effect defines the effect to bind
  8902. */
  8903. bindSamplers(effect: Effect): void;
  8904. private _moveBoundTextureOnTop(internalTexture);
  8905. private _getCorrectTextureChannel(channel, internalTexture);
  8906. private _linkTrackers(previous, next);
  8907. private _removeDesignatedSlot(internalTexture);
  8908. private _activateCurrentTexture();
  8909. /** @hidden */
  8910. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8911. /** @hidden */
  8912. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8913. /**
  8914. * Sets a texture to the webGL context from a postprocess
  8915. * @param channel defines the channel to use
  8916. * @param postProcess defines the source postprocess
  8917. */
  8918. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8919. /**
  8920. * Binds the output of the passed in post process to the texture channel specified
  8921. * @param channel The channel the texture should be bound to
  8922. * @param postProcess The post process which's output should be bound
  8923. */
  8924. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8925. /**
  8926. * Unbind all textures from the webGL context
  8927. */
  8928. unbindAllTextures(): void;
  8929. /**
  8930. * Sets a texture to the according uniform.
  8931. * @param channel The texture channel
  8932. * @param uniform The uniform to set
  8933. * @param texture The texture to apply
  8934. */
  8935. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8936. /**
  8937. * Sets a depth stencil texture from a render target to the according uniform.
  8938. * @param channel The texture channel
  8939. * @param uniform The uniform to set
  8940. * @param texture The render target texture containing the depth stencil texture to apply
  8941. */
  8942. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8943. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8944. private _getTextureWrapMode(mode);
  8945. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8946. /**
  8947. * Sets an array of texture to the webGL context
  8948. * @param channel defines the channel where the texture array must be set
  8949. * @param uniform defines the associated uniform location
  8950. * @param textures defines the array of textures to bind
  8951. */
  8952. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8953. /** @hidden */
  8954. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8955. private _setTextureParameterFloat(target, parameter, value, texture);
  8956. private _setTextureParameterInteger(target, parameter, value, texture?);
  8957. /**
  8958. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8959. * @param x defines the x coordinate of the rectangle where pixels must be read
  8960. * @param y defines the y coordinate of the rectangle where pixels must be read
  8961. * @param width defines the width of the rectangle where pixels must be read
  8962. * @param height defines the height of the rectangle where pixels must be read
  8963. * @returns a Uint8Array containing RGBA colors
  8964. */
  8965. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8966. /**
  8967. * Add an externaly attached data from its key.
  8968. * This method call will fail and return false, if such key already exists.
  8969. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8970. * @param key the unique key that identifies the data
  8971. * @param data the data object to associate to the key for this Engine instance
  8972. * @return true if no such key were already present and the data was added successfully, false otherwise
  8973. */
  8974. addExternalData<T>(key: string, data: T): boolean;
  8975. /**
  8976. * Get an externaly attached data from its key
  8977. * @param key the unique key that identifies the data
  8978. * @return the associated data, if present (can be null), or undefined if not present
  8979. */
  8980. getExternalData<T>(key: string): T;
  8981. /**
  8982. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8983. * @param key the unique key that identifies the data
  8984. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8985. * @return the associated data, can be null if the factory returned null.
  8986. */
  8987. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8988. /**
  8989. * Remove an externaly attached data from the Engine instance
  8990. * @param key the unique key that identifies the data
  8991. * @return true if the data was successfully removed, false if it doesn't exist
  8992. */
  8993. removeExternalData(key: string): boolean;
  8994. /**
  8995. * Unbind all vertex attributes from the webGL context
  8996. */
  8997. unbindAllAttributes(): void;
  8998. /**
  8999. * 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
  9000. */
  9001. releaseEffects(): void;
  9002. /**
  9003. * Dispose and release all associated resources
  9004. */
  9005. dispose(): void;
  9006. /**
  9007. * Display the loading screen
  9008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9009. */
  9010. displayLoadingUI(): void;
  9011. /**
  9012. * Hide the loading screen
  9013. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9014. */
  9015. hideLoadingUI(): void;
  9016. /**
  9017. * Gets the current loading screen object
  9018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9019. */
  9020. /**
  9021. * Sets the current loading screen object
  9022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9023. */
  9024. loadingScreen: ILoadingScreen;
  9025. /**
  9026. * Sets the current loading screen text
  9027. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9028. */
  9029. loadingUIText: string;
  9030. /**
  9031. * Sets the current loading screen background color
  9032. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9033. */
  9034. loadingUIBackgroundColor: string;
  9035. /**
  9036. * Attach a new callback raised when context lost event is fired
  9037. * @param callback defines the callback to call
  9038. */
  9039. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9040. /**
  9041. * Attach a new callback raised when context restored event is fired
  9042. * @param callback defines the callback to call
  9043. */
  9044. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9045. /**
  9046. * Gets the source code of the vertex shader associated with a specific webGL program
  9047. * @param program defines the program to use
  9048. * @returns a string containing the source code of the vertex shader associated with the program
  9049. */
  9050. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9051. /**
  9052. * Gets the source code of the fragment shader associated with a specific webGL program
  9053. * @param program defines the program to use
  9054. * @returns a string containing the source code of the fragment shader associated with the program
  9055. */
  9056. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9057. /**
  9058. * Get the current error code of the webGL context
  9059. * @returns the error code
  9060. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9061. */
  9062. getError(): number;
  9063. /**
  9064. * Gets the current framerate
  9065. * @returns a number representing the framerate
  9066. */
  9067. getFps(): number;
  9068. /**
  9069. * Gets the time spent between current and previous frame
  9070. * @returns a number representing the delta time in ms
  9071. */
  9072. getDeltaTime(): number;
  9073. private _measureFps();
  9074. /** @hidden */
  9075. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9076. private _canRenderToFloatFramebuffer();
  9077. private _canRenderToHalfFloatFramebuffer();
  9078. private _canRenderToFramebuffer(type);
  9079. /** @hidden */
  9080. _getWebGLTextureType(type: number): number;
  9081. private _getInternalFormat(format);
  9082. /** @hidden */
  9083. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9084. /** @hidden */
  9085. _getRGBAMultiSampleBufferFormat(type: number): number;
  9086. /**
  9087. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  9088. * @return the new query
  9089. */
  9090. createQuery(): WebGLQuery;
  9091. /**
  9092. * Delete and release a webGL query
  9093. * @param query defines the query to delete
  9094. * @return the current engine
  9095. */
  9096. deleteQuery(query: WebGLQuery): Engine;
  9097. /**
  9098. * Check if a given query has resolved and got its value
  9099. * @param query defines the query to check
  9100. * @returns true if the query got its value
  9101. */
  9102. isQueryResultAvailable(query: WebGLQuery): boolean;
  9103. /**
  9104. * Gets the value of a given query
  9105. * @param query defines the query to check
  9106. * @returns the value of the query
  9107. */
  9108. getQueryResult(query: WebGLQuery): number;
  9109. /**
  9110. * Initiates an occlusion query
  9111. * @param algorithmType defines the algorithm to use
  9112. * @param query defines the query to use
  9113. * @returns the current engine
  9114. * @see http://doc.babylonjs.com/features/occlusionquery
  9115. */
  9116. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  9117. /**
  9118. * Ends an occlusion query
  9119. * @see http://doc.babylonjs.com/features/occlusionquery
  9120. * @param algorithmType defines the algorithm to use
  9121. * @returns the current engine
  9122. */
  9123. endOcclusionQuery(algorithmType: number): Engine;
  9124. private _createTimeQuery();
  9125. private _deleteTimeQuery(query);
  9126. private _getTimeQueryResult(query);
  9127. private _getTimeQueryAvailability(query);
  9128. private _currentNonTimestampToken;
  9129. /**
  9130. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  9131. * Please note that only one query can be issued at a time
  9132. * @returns a time token used to track the time span
  9133. */
  9134. startTimeQuery(): Nullable<_TimeToken>;
  9135. /**
  9136. * Ends a time query
  9137. * @param token defines the token used to measure the time span
  9138. * @returns the time spent (in ns)
  9139. */
  9140. endTimeQuery(token: _TimeToken): int;
  9141. private getGlAlgorithmType(algorithmType);
  9142. /**
  9143. * Creates a webGL transform feedback object
  9144. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  9145. * @returns the webGL transform feedback object
  9146. */
  9147. createTransformFeedback(): WebGLTransformFeedback;
  9148. /**
  9149. * Delete a webGL transform feedback object
  9150. * @param value defines the webGL transform feedback object to delete
  9151. */
  9152. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  9153. /**
  9154. * Bind a webGL transform feedback object to the webgl context
  9155. * @param value defines the webGL transform feedback object to bind
  9156. */
  9157. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  9158. /**
  9159. * Begins a transform feedback operation
  9160. * @param usePoints defines if points or triangles must be used
  9161. */
  9162. beginTransformFeedback(usePoints?: boolean): void;
  9163. /**
  9164. * Ends a transform feedback operation
  9165. */
  9166. endTransformFeedback(): void;
  9167. /**
  9168. * Specify the varyings to use with transform feedback
  9169. * @param program defines the associated webGL program
  9170. * @param value defines the list of strings representing the varying names
  9171. */
  9172. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  9173. /**
  9174. * Bind a webGL buffer for a transform feedback operation
  9175. * @param value defines the webGL buffer to bind
  9176. */
  9177. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  9178. /** @hidden */
  9179. _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;
  9180. /** @hidden */
  9181. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9182. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  9183. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  9184. /**
  9185. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9186. * @returns true if the engine can be created
  9187. * @ignorenaming
  9188. */
  9189. static isSupported(): boolean;
  9190. }
  9191. }
  9192. declare module BABYLON {
  9193. class NullEngineOptions {
  9194. renderWidth: number;
  9195. renderHeight: number;
  9196. textureSize: number;
  9197. deterministicLockstep: boolean;
  9198. lockstepMaxSteps: number;
  9199. }
  9200. /**
  9201. * The null engine class provides support for headless version of babylon.js.
  9202. * This can be used in server side scenario or for testing purposes
  9203. */
  9204. class NullEngine extends Engine {
  9205. private _options;
  9206. isDeterministicLockStep(): boolean;
  9207. getLockstepMaxSteps(): number;
  9208. getHardwareScalingLevel(): number;
  9209. constructor(options?: NullEngineOptions);
  9210. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9211. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9212. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9213. getRenderWidth(useScreen?: boolean): number;
  9214. getRenderHeight(useScreen?: boolean): number;
  9215. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9216. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9217. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9218. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9219. bindSamplers(effect: Effect): void;
  9220. enableEffect(effect: Effect): void;
  9221. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9222. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9223. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9224. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9225. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9226. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9227. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9228. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9229. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9230. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9231. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9232. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9233. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9234. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9235. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9236. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9237. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9238. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9239. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9240. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9241. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9242. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9243. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9244. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9245. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9246. bindBuffers(vertexBuffers: {
  9247. [key: string]: VertexBuffer;
  9248. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9249. wipeCaches(bruteForce?: boolean): void;
  9250. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9251. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9252. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9253. _createTexture(): WebGLTexture;
  9254. _releaseTexture(texture: InternalTexture): void;
  9255. 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;
  9256. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9257. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9259. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9260. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9261. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9262. /**
  9263. * Updates a dynamic vertex buffer.
  9264. * @param vertexBuffer the vertex buffer to update
  9265. * @param data the data used to update the vertex buffer
  9266. * @param byteOffset the byte offset of the data (optional)
  9267. * @param byteLength the byte length of the data (optional)
  9268. */
  9269. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9270. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9271. _bindTexture(channel: number, texture: InternalTexture): void;
  9272. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9273. releaseEffects(): void;
  9274. }
  9275. }
  9276. interface WebGLRenderingContext {
  9277. readonly RASTERIZER_DISCARD: number;
  9278. readonly DEPTH_COMPONENT24: number;
  9279. readonly TEXTURE_3D: number;
  9280. readonly TEXTURE_2D_ARRAY: number;
  9281. readonly TEXTURE_COMPARE_FUNC: number;
  9282. readonly TEXTURE_COMPARE_MODE: number;
  9283. readonly COMPARE_REF_TO_TEXTURE: number;
  9284. readonly TEXTURE_WRAP_R: number;
  9285. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9286. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9287. 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;
  9288. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9289. readonly TRANSFORM_FEEDBACK: number;
  9290. readonly INTERLEAVED_ATTRIBS: number;
  9291. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9292. createTransformFeedback(): WebGLTransformFeedback;
  9293. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9294. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9295. beginTransformFeedback(primitiveMode: number): void;
  9296. endTransformFeedback(): void;
  9297. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9298. }
  9299. interface ImageBitmap {
  9300. readonly width: number;
  9301. readonly height: number;
  9302. close(): void;
  9303. }
  9304. interface WebGLQuery extends WebGLObject {
  9305. }
  9306. declare var WebGLQuery: {
  9307. prototype: WebGLQuery;
  9308. new (): WebGLQuery;
  9309. };
  9310. interface WebGLSampler extends WebGLObject {
  9311. }
  9312. declare var WebGLSampler: {
  9313. prototype: WebGLSampler;
  9314. new (): WebGLSampler;
  9315. };
  9316. interface WebGLSync extends WebGLObject {
  9317. }
  9318. declare var WebGLSync: {
  9319. prototype: WebGLSync;
  9320. new (): WebGLSync;
  9321. };
  9322. interface WebGLTransformFeedback extends WebGLObject {
  9323. }
  9324. declare var WebGLTransformFeedback: {
  9325. prototype: WebGLTransformFeedback;
  9326. new (): WebGLTransformFeedback;
  9327. };
  9328. interface WebGLVertexArrayObject extends WebGLObject {
  9329. }
  9330. declare var WebGLVertexArrayObject: {
  9331. prototype: WebGLVertexArrayObject;
  9332. new (): WebGLVertexArrayObject;
  9333. };
  9334. declare module BABYLON {
  9335. /**
  9336. * Single axis drag gizmo
  9337. */
  9338. class AxisDragGizmo extends Gizmo {
  9339. private _dragBehavior;
  9340. /**
  9341. * Creates an AxisDragGizmo
  9342. * @param gizmoLayer The utility layer the gizmo will be added to
  9343. * @param dragAxis The axis which the gizmo will be able to drag on
  9344. * @param color The color of the gizmo
  9345. */
  9346. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9347. protected _onInteractionsEnabledChanged(value: boolean): void;
  9348. /**
  9349. * Disposes of the gizmo
  9350. */
  9351. dispose(): void;
  9352. }
  9353. }
  9354. declare module BABYLON {
  9355. /**
  9356. * Single axis scale gizmo
  9357. */
  9358. class AxisScaleGizmo extends Gizmo {
  9359. private _dragBehavior;
  9360. /**
  9361. * Creates an AxisScaleGizmo
  9362. * @param gizmoLayer The utility layer the gizmo will be added to
  9363. * @param dragAxis The axis which the gizmo will be able to scale on
  9364. * @param color The color of the gizmo
  9365. */
  9366. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9367. protected _onInteractionsEnabledChanged(value: boolean): void;
  9368. /**
  9369. * Disposes of the gizmo
  9370. */
  9371. dispose(): void;
  9372. }
  9373. }
  9374. declare module BABYLON {
  9375. /**
  9376. * Bounding box gizmo
  9377. */
  9378. class BoundingBoxGizmo extends Gizmo {
  9379. private _lineBoundingBox;
  9380. private _rotateSpheresParent;
  9381. private _scaleBoxesParent;
  9382. private _boundingDimensions;
  9383. private _renderObserver;
  9384. private _pointerObserver;
  9385. private _scaleDragSpeed;
  9386. /**
  9387. * Creates an BoundingBoxGizmo
  9388. * @param gizmoLayer The utility layer the gizmo will be added to
  9389. * @param color The color of the gizmo
  9390. */
  9391. constructor(gizmoLayer: UtilityLayerRenderer, color: Color3);
  9392. private _selectNode(selectedMesh);
  9393. private _updateBoundingBox();
  9394. /**
  9395. * Disposes of the gizmo
  9396. */
  9397. dispose(): void;
  9398. }
  9399. }
  9400. declare module BABYLON {
  9401. /**
  9402. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9403. */
  9404. class Gizmo implements IDisposable {
  9405. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9406. /**
  9407. * The root mesh of the gizmo
  9408. */
  9409. protected _rootMesh: Mesh;
  9410. /**
  9411. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9412. */
  9413. attachedMesh: Nullable<AbstractMesh>;
  9414. /**
  9415. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9416. */
  9417. updateGizmoRotationToMatchAttachedMesh: boolean;
  9418. /**
  9419. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9420. */
  9421. updateGizmoPositionToMatchAttachedMesh: boolean;
  9422. /**
  9423. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9424. */
  9425. protected _updateScale: boolean;
  9426. protected _interactionsEnabled: boolean;
  9427. protected _onInteractionsEnabledChanged(value: boolean): void;
  9428. /**
  9429. * If interactions are enabled with this gizmo. (eg. dragging/rotation)
  9430. */
  9431. interactionsEnabled: boolean;
  9432. private _beforeRenderObserver;
  9433. /**
  9434. * Creates a gizmo
  9435. * @param gizmoLayer The utility layer the gizmo will be added to
  9436. */
  9437. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9438. /**
  9439. * Disposes of the gizmo
  9440. */
  9441. dispose(): void;
  9442. }
  9443. }
  9444. declare module BABYLON {
  9445. /**
  9446. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9447. */
  9448. class GizmoManager implements IDisposable {
  9449. private scene;
  9450. private _gizmoLayer;
  9451. private _gizmoSet;
  9452. private _pointerObserver;
  9453. /**
  9454. * Instatiates a gizmo manager
  9455. * @param scene the scene to overlay the gizmos on top of
  9456. * @param options If only a single gizmo should exist at one time
  9457. */
  9458. constructor(scene: Scene, options?: {
  9459. singleGizmo?: boolean;
  9460. });
  9461. /**
  9462. * Disposes of the gizmo manager
  9463. */
  9464. dispose(): void;
  9465. private _clearGizmos();
  9466. }
  9467. }
  9468. declare module BABYLON {
  9469. /**
  9470. * Single plane rotation gizmo
  9471. */
  9472. class PlaneRotationGizmo extends Gizmo {
  9473. private _dragBehavior;
  9474. /**
  9475. * Creates a PlaneRotationGizmo
  9476. * @param gizmoLayer The utility layer the gizmo will be added to
  9477. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9478. * @param color The color of the gizmo
  9479. */
  9480. constructor(gizmoLayer: UtilityLayerRenderer, planeNormal: Vector3, color: Color3);
  9481. protected _onInteractionsEnabledChanged(value: boolean): void;
  9482. /**
  9483. * Disposes of the gizmo
  9484. */
  9485. dispose(): void;
  9486. }
  9487. }
  9488. declare module BABYLON {
  9489. /**
  9490. * Gizmo that enables dragging a mesh along 3 axis
  9491. */
  9492. class PositionGizmo extends Gizmo {
  9493. private _xDrag;
  9494. private _yDrag;
  9495. private _zDrag;
  9496. attachedMesh: Nullable<AbstractMesh>;
  9497. /**
  9498. * Creates a PositionGizmo
  9499. * @param gizmoLayer The utility layer the gizmo will be added to
  9500. */
  9501. constructor(gizmoLayer: UtilityLayerRenderer);
  9502. protected _onInteractionsEnabledChanged(value: boolean): void;
  9503. /**
  9504. * Disposes of the gizmo
  9505. */
  9506. dispose(): void;
  9507. }
  9508. }
  9509. declare module BABYLON {
  9510. /**
  9511. * Gizmo that enables rotating a mesh along 3 axis
  9512. */
  9513. class RotationGizmo extends Gizmo {
  9514. private _xDrag;
  9515. private _yDrag;
  9516. private _zDrag;
  9517. attachedMesh: Nullable<AbstractMesh>;
  9518. /**
  9519. * Creates a RotationGizmo
  9520. * @param gizmoLayer The utility layer the gizmo will be added to
  9521. */
  9522. constructor(gizmoLayer: UtilityLayerRenderer);
  9523. protected _onInteractionsEnabledChanged(value: boolean): void;
  9524. /**
  9525. * Disposes of the gizmo
  9526. */
  9527. dispose(): void;
  9528. }
  9529. }
  9530. declare module BABYLON {
  9531. /**
  9532. * Gizmo that enables scaling a mesh along 3 axis
  9533. */
  9534. class ScaleGizmo extends Gizmo {
  9535. private _xDrag;
  9536. private _yDrag;
  9537. private _zDrag;
  9538. attachedMesh: Nullable<AbstractMesh>;
  9539. /**
  9540. * Creates a ScaleGizmo
  9541. * @param gizmoLayer The utility layer the gizmo will be added to
  9542. */
  9543. constructor(gizmoLayer: UtilityLayerRenderer);
  9544. protected _onInteractionsEnabledChanged(value: boolean): void;
  9545. /**
  9546. * Disposes of the gizmo
  9547. */
  9548. dispose(): void;
  9549. }
  9550. }
  9551. declare module BABYLON {
  9552. class StickValues {
  9553. x: number;
  9554. y: number;
  9555. constructor(x: number, y: number);
  9556. }
  9557. interface GamepadButtonChanges {
  9558. changed: boolean;
  9559. pressChanged: boolean;
  9560. touchChanged: boolean;
  9561. valueChanged: boolean;
  9562. }
  9563. class Gamepad {
  9564. id: string;
  9565. index: number;
  9566. browserGamepad: any;
  9567. type: number;
  9568. private _leftStick;
  9569. private _rightStick;
  9570. _isConnected: boolean;
  9571. private _leftStickAxisX;
  9572. private _leftStickAxisY;
  9573. private _rightStickAxisX;
  9574. private _rightStickAxisY;
  9575. private _onleftstickchanged;
  9576. private _onrightstickchanged;
  9577. static GAMEPAD: number;
  9578. static GENERIC: number;
  9579. static XBOX: number;
  9580. static POSE_ENABLED: number;
  9581. protected _invertLeftStickY: boolean;
  9582. readonly isConnected: boolean;
  9583. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9584. onleftstickchanged(callback: (values: StickValues) => void): void;
  9585. onrightstickchanged(callback: (values: StickValues) => void): void;
  9586. leftStick: StickValues;
  9587. rightStick: StickValues;
  9588. update(): void;
  9589. dispose(): void;
  9590. }
  9591. class GenericPad extends Gamepad {
  9592. private _buttons;
  9593. private _onbuttondown;
  9594. private _onbuttonup;
  9595. onButtonDownObservable: Observable<number>;
  9596. onButtonUpObservable: Observable<number>;
  9597. onbuttondown(callback: (buttonPressed: number) => void): void;
  9598. onbuttonup(callback: (buttonReleased: number) => void): void;
  9599. constructor(id: string, index: number, browserGamepad: any);
  9600. private _setButtonValue(newValue, currentValue, buttonIndex);
  9601. update(): void;
  9602. dispose(): void;
  9603. }
  9604. }
  9605. declare module BABYLON {
  9606. class GamepadManager {
  9607. private _scene;
  9608. private _babylonGamepads;
  9609. private _oneGamepadConnected;
  9610. _isMonitoring: boolean;
  9611. private _gamepadEventSupported;
  9612. private _gamepadSupport;
  9613. onGamepadConnectedObservable: Observable<Gamepad>;
  9614. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9615. private _onGamepadConnectedEvent;
  9616. private _onGamepadDisconnectedEvent;
  9617. constructor(_scene?: Scene | undefined);
  9618. readonly gamepads: Gamepad[];
  9619. getGamepadByType(type?: number): Nullable<Gamepad>;
  9620. dispose(): void;
  9621. private _addNewGamepad(gamepad);
  9622. private _startMonitoringGamepads();
  9623. private _stopMonitoringGamepads();
  9624. _checkGamepadsStatus(): void;
  9625. private _updateGamepadObjects();
  9626. }
  9627. }
  9628. declare module BABYLON {
  9629. /**
  9630. * Defines supported buttons for XBox360 compatible gamepads
  9631. */
  9632. enum Xbox360Button {
  9633. /** A */
  9634. A = 0,
  9635. /** B */
  9636. B = 1,
  9637. /** X */
  9638. X = 2,
  9639. /** Y */
  9640. Y = 3,
  9641. /** Start */
  9642. Start = 4,
  9643. /** Back */
  9644. Back = 5,
  9645. /** Left button */
  9646. LB = 6,
  9647. /** Right button */
  9648. RB = 7,
  9649. /** Left stick */
  9650. LeftStick = 8,
  9651. /** Right stick */
  9652. RightStick = 9,
  9653. }
  9654. /** Defines values for XBox360 DPad */
  9655. enum Xbox360Dpad {
  9656. /** Up */
  9657. Up = 0,
  9658. /** Down */
  9659. Down = 1,
  9660. /** Left */
  9661. Left = 2,
  9662. /** Right */
  9663. Right = 3,
  9664. }
  9665. /**
  9666. * Defines a XBox360 gamepad
  9667. */
  9668. class Xbox360Pad extends Gamepad {
  9669. private _leftTrigger;
  9670. private _rightTrigger;
  9671. private _onlefttriggerchanged;
  9672. private _onrighttriggerchanged;
  9673. private _onbuttondown;
  9674. private _onbuttonup;
  9675. private _ondpaddown;
  9676. private _ondpadup;
  9677. /** Observable raised when a button is pressed */
  9678. onButtonDownObservable: Observable<Xbox360Button>;
  9679. /** Observable raised when a button is released */
  9680. onButtonUpObservable: Observable<Xbox360Button>;
  9681. /** Observable raised when a pad is pressed */
  9682. onPadDownObservable: Observable<Xbox360Dpad>;
  9683. /** Observable raised when a pad is released */
  9684. onPadUpObservable: Observable<Xbox360Dpad>;
  9685. private _buttonA;
  9686. private _buttonB;
  9687. private _buttonX;
  9688. private _buttonY;
  9689. private _buttonBack;
  9690. private _buttonStart;
  9691. private _buttonLB;
  9692. private _buttonRB;
  9693. private _buttonLeftStick;
  9694. private _buttonRightStick;
  9695. private _dPadUp;
  9696. private _dPadDown;
  9697. private _dPadLeft;
  9698. private _dPadRight;
  9699. private _isXboxOnePad;
  9700. /**
  9701. * Creates a new XBox360 gamepad object
  9702. * @param id defines the id of this gamepad
  9703. * @param index defines its index
  9704. * @param gamepad defines the internal HTML gamepad object
  9705. * @param xboxOne defines if it is a XBox One gamepad
  9706. */
  9707. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9708. /**
  9709. * Defines the callback to call when left trigger is pressed
  9710. * @param callback defines the callback to use
  9711. */
  9712. onlefttriggerchanged(callback: (value: number) => void): void;
  9713. /**
  9714. * Defines the callback to call when right trigger is pressed
  9715. * @param callback defines the callback to use
  9716. */
  9717. onrighttriggerchanged(callback: (value: number) => void): void;
  9718. /**
  9719. * Gets or sets left trigger value
  9720. */
  9721. leftTrigger: number;
  9722. /**
  9723. * Gets or sets right trigger value
  9724. */
  9725. rightTrigger: number;
  9726. /**
  9727. * Defines the callback to call when a button is pressed
  9728. * @param callback defines the callback to use
  9729. */
  9730. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9731. /**
  9732. * Defines the callback to call when a button is released
  9733. * @param callback defines the callback to use
  9734. */
  9735. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9736. /**
  9737. * Defines the callback to call when a pad is pressed
  9738. * @param callback defines the callback to use
  9739. */
  9740. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9741. /**
  9742. * Defines the callback to call when a pad is released
  9743. * @param callback defines the callback to use
  9744. */
  9745. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9746. private _setButtonValue(newValue, currentValue, buttonType);
  9747. private _setDPadValue(newValue, currentValue, buttonType);
  9748. /** Gets or sets value of A button */
  9749. buttonA: number;
  9750. /** Gets or sets value of B button */
  9751. buttonB: number;
  9752. /** Gets or sets value of X button */
  9753. buttonX: number;
  9754. /** Gets or sets value of Y button */
  9755. buttonY: number;
  9756. /** Gets or sets value of Start button */
  9757. buttonStart: number;
  9758. /** Gets or sets value of Back button */
  9759. buttonBack: number;
  9760. /** Gets or sets value of Left button */
  9761. buttonLB: number;
  9762. /** Gets or sets value of Right button */
  9763. buttonRB: number;
  9764. /** Gets or sets value of left stick */
  9765. buttonLeftStick: number;
  9766. /** Gets or sets value of right stick */
  9767. buttonRightStick: number;
  9768. /** Gets or sets value of DPad up */
  9769. dPadUp: number;
  9770. /** Gets or sets value of DPad down */
  9771. dPadDown: number;
  9772. /** Gets or sets value of DPad left */
  9773. dPadLeft: number;
  9774. /** Gets or sets value of DPad right */
  9775. dPadRight: number;
  9776. /**
  9777. * Force the gamepad to synchronize with device values
  9778. */
  9779. update(): void;
  9780. dispose(): void;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. /**
  9785. * Represents the different options available during the creation of
  9786. * a Environment helper.
  9787. *
  9788. * This can control the default ground, skybox and image processing setup of your scene.
  9789. */
  9790. interface IEnvironmentHelperOptions {
  9791. /**
  9792. * Specifies wether or not to create a ground.
  9793. * True by default.
  9794. */
  9795. createGround: boolean;
  9796. /**
  9797. * Specifies the ground size.
  9798. * 15 by default.
  9799. */
  9800. groundSize: number;
  9801. /**
  9802. * The texture used on the ground for the main color.
  9803. * Comes from the BabylonJS CDN by default.
  9804. *
  9805. * Remarks: Can be either a texture or a url.
  9806. */
  9807. groundTexture: string | BaseTexture;
  9808. /**
  9809. * The color mixed in the ground texture by default.
  9810. * BabylonJS clearColor by default.
  9811. */
  9812. groundColor: Color3;
  9813. /**
  9814. * Specifies the ground opacity.
  9815. * 1 by default.
  9816. */
  9817. groundOpacity: number;
  9818. /**
  9819. * Enables the ground to receive shadows.
  9820. * True by default.
  9821. */
  9822. enableGroundShadow: boolean;
  9823. /**
  9824. * Helps preventing the shadow to be fully black on the ground.
  9825. * 0.5 by default.
  9826. */
  9827. groundShadowLevel: number;
  9828. /**
  9829. * Creates a mirror texture attach to the ground.
  9830. * false by default.
  9831. */
  9832. enableGroundMirror: boolean;
  9833. /**
  9834. * Specifies the ground mirror size ratio.
  9835. * 0.3 by default as the default kernel is 64.
  9836. */
  9837. groundMirrorSizeRatio: number;
  9838. /**
  9839. * Specifies the ground mirror blur kernel size.
  9840. * 64 by default.
  9841. */
  9842. groundMirrorBlurKernel: number;
  9843. /**
  9844. * Specifies the ground mirror visibility amount.
  9845. * 1 by default
  9846. */
  9847. groundMirrorAmount: number;
  9848. /**
  9849. * Specifies the ground mirror reflectance weight.
  9850. * This uses the standard weight of the background material to setup the fresnel effect
  9851. * of the mirror.
  9852. * 1 by default.
  9853. */
  9854. groundMirrorFresnelWeight: number;
  9855. /**
  9856. * Specifies the ground mirror Falloff distance.
  9857. * This can helps reducing the size of the reflection.
  9858. * 0 by Default.
  9859. */
  9860. groundMirrorFallOffDistance: number;
  9861. /**
  9862. * Specifies the ground mirror texture type.
  9863. * Unsigned Int by Default.
  9864. */
  9865. groundMirrorTextureType: number;
  9866. /**
  9867. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9868. * the shown objects.
  9869. */
  9870. groundYBias: number;
  9871. /**
  9872. * Specifies wether or not to create a skybox.
  9873. * True by default.
  9874. */
  9875. createSkybox: boolean;
  9876. /**
  9877. * Specifies the skybox size.
  9878. * 20 by default.
  9879. */
  9880. skyboxSize: number;
  9881. /**
  9882. * The texture used on the skybox for the main color.
  9883. * Comes from the BabylonJS CDN by default.
  9884. *
  9885. * Remarks: Can be either a texture or a url.
  9886. */
  9887. skyboxTexture: string | BaseTexture;
  9888. /**
  9889. * The color mixed in the skybox texture by default.
  9890. * BabylonJS clearColor by default.
  9891. */
  9892. skyboxColor: Color3;
  9893. /**
  9894. * The background rotation around the Y axis of the scene.
  9895. * This helps aligning the key lights of your scene with the background.
  9896. * 0 by default.
  9897. */
  9898. backgroundYRotation: number;
  9899. /**
  9900. * Compute automatically the size of the elements to best fit with the scene.
  9901. */
  9902. sizeAuto: boolean;
  9903. /**
  9904. * Default position of the rootMesh if autoSize is not true.
  9905. */
  9906. rootPosition: Vector3;
  9907. /**
  9908. * Sets up the image processing in the scene.
  9909. * true by default.
  9910. */
  9911. setupImageProcessing: boolean;
  9912. /**
  9913. * The texture used as your environment texture in the scene.
  9914. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9915. *
  9916. * Remarks: Can be either a texture or a url.
  9917. */
  9918. environmentTexture: string | BaseTexture;
  9919. /**
  9920. * The value of the exposure to apply to the scene.
  9921. * 0.6 by default if setupImageProcessing is true.
  9922. */
  9923. cameraExposure: number;
  9924. /**
  9925. * The value of the contrast to apply to the scene.
  9926. * 1.6 by default if setupImageProcessing is true.
  9927. */
  9928. cameraContrast: number;
  9929. /**
  9930. * Specifies wether or not tonemapping should be enabled in the scene.
  9931. * true by default if setupImageProcessing is true.
  9932. */
  9933. toneMappingEnabled: boolean;
  9934. }
  9935. /**
  9936. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9937. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9938. * It also helps with the default setup of your imageProcessing configuration.
  9939. */
  9940. class EnvironmentHelper {
  9941. /**
  9942. * Default ground texture URL.
  9943. */
  9944. private static _groundTextureCDNUrl;
  9945. /**
  9946. * Default skybox texture URL.
  9947. */
  9948. private static _skyboxTextureCDNUrl;
  9949. /**
  9950. * Default environment texture URL.
  9951. */
  9952. private static _environmentTextureCDNUrl;
  9953. /**
  9954. * Creates the default options for the helper.
  9955. */
  9956. private static _getDefaultOptions();
  9957. private _rootMesh;
  9958. /**
  9959. * Gets the root mesh created by the helper.
  9960. */
  9961. readonly rootMesh: Mesh;
  9962. private _skybox;
  9963. /**
  9964. * Gets the skybox created by the helper.
  9965. */
  9966. readonly skybox: Nullable<Mesh>;
  9967. private _skyboxTexture;
  9968. /**
  9969. * Gets the skybox texture created by the helper.
  9970. */
  9971. readonly skyboxTexture: Nullable<BaseTexture>;
  9972. private _skyboxMaterial;
  9973. /**
  9974. * Gets the skybox material created by the helper.
  9975. */
  9976. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9977. private _ground;
  9978. /**
  9979. * Gets the ground mesh created by the helper.
  9980. */
  9981. readonly ground: Nullable<Mesh>;
  9982. private _groundTexture;
  9983. /**
  9984. * Gets the ground texture created by the helper.
  9985. */
  9986. readonly groundTexture: Nullable<BaseTexture>;
  9987. private _groundMirror;
  9988. /**
  9989. * Gets the ground mirror created by the helper.
  9990. */
  9991. readonly groundMirror: Nullable<MirrorTexture>;
  9992. /**
  9993. * Gets the ground mirror render list to helps pushing the meshes
  9994. * you wish in the ground reflection.
  9995. */
  9996. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9997. private _groundMaterial;
  9998. /**
  9999. * Gets the ground material created by the helper.
  10000. */
  10001. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10002. /**
  10003. * Stores the creation options.
  10004. */
  10005. private readonly _scene;
  10006. private _options;
  10007. /**
  10008. * This observable will be notified with any error during the creation of the environment,
  10009. * mainly texture creation errors.
  10010. */
  10011. onErrorObservable: Observable<{
  10012. message?: string;
  10013. exception?: any;
  10014. }>;
  10015. /**
  10016. * constructor
  10017. * @param options
  10018. * @param scene The scene to add the material to
  10019. */
  10020. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10021. /**
  10022. * Updates the background according to the new options
  10023. * @param options
  10024. */
  10025. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10026. /**
  10027. * Sets the primary color of all the available elements.
  10028. * @param color the main color to affect to the ground and the background
  10029. */
  10030. setMainColor(color: Color3): void;
  10031. /**
  10032. * Setup the image processing according to the specified options.
  10033. */
  10034. private _setupImageProcessing();
  10035. /**
  10036. * Setup the environment texture according to the specified options.
  10037. */
  10038. private _setupEnvironmentTexture();
  10039. /**
  10040. * Setup the background according to the specified options.
  10041. */
  10042. private _setupBackground();
  10043. /**
  10044. * Get the scene sizes according to the setup.
  10045. */
  10046. private _getSceneSize();
  10047. /**
  10048. * Setup the ground according to the specified options.
  10049. */
  10050. private _setupGround(sceneSize);
  10051. /**
  10052. * Setup the ground material according to the specified options.
  10053. */
  10054. private _setupGroundMaterial();
  10055. /**
  10056. * Setup the ground diffuse texture according to the specified options.
  10057. */
  10058. private _setupGroundDiffuseTexture();
  10059. /**
  10060. * Setup the ground mirror texture according to the specified options.
  10061. */
  10062. private _setupGroundMirrorTexture(sceneSize);
  10063. /**
  10064. * Setup the ground to receive the mirror texture.
  10065. */
  10066. private _setupMirrorInGroundMaterial();
  10067. /**
  10068. * Setup the skybox according to the specified options.
  10069. */
  10070. private _setupSkybox(sceneSize);
  10071. /**
  10072. * Setup the skybox material according to the specified options.
  10073. */
  10074. private _setupSkyboxMaterial();
  10075. /**
  10076. * Setup the skybox reflection texture according to the specified options.
  10077. */
  10078. private _setupSkyboxReflectionTexture();
  10079. private _errorHandler;
  10080. /**
  10081. * Dispose all the elements created by the Helper.
  10082. */
  10083. dispose(): void;
  10084. }
  10085. }
  10086. declare module BABYLON {
  10087. /**
  10088. * Represents all the data needed to create a ParticleSystem.
  10089. */
  10090. interface IParticleSystemData {
  10091. /**
  10092. * ParticleSystem type
  10093. */
  10094. type: string;
  10095. /**
  10096. * Shape of the emitter
  10097. */
  10098. emitterType: string;
  10099. /**
  10100. * Maximum number of particles in the system
  10101. */
  10102. capacity: number;
  10103. /**
  10104. * Link for the texture file
  10105. */
  10106. textureFile: string;
  10107. /**
  10108. * minEmitBox Vector3
  10109. */
  10110. minEmitBox?: {
  10111. x: number;
  10112. y: number;
  10113. z: number;
  10114. };
  10115. /**
  10116. * maxEmitBox Vector3
  10117. */
  10118. maxEmitBox?: {
  10119. x: number;
  10120. y: number;
  10121. z: number;
  10122. };
  10123. /**
  10124. * color1 Color4
  10125. */
  10126. color1: {
  10127. r: number;
  10128. g: number;
  10129. b: number;
  10130. a: number;
  10131. };
  10132. /**
  10133. * color2 Color4
  10134. */
  10135. color2: {
  10136. r: number;
  10137. g: number;
  10138. b: number;
  10139. a: number;
  10140. };
  10141. /**
  10142. * colorDead Color4
  10143. */
  10144. colorDead: {
  10145. r: number;
  10146. g: number;
  10147. b: number;
  10148. a: number;
  10149. };
  10150. /**
  10151. * Minimum size of each particle
  10152. */
  10153. minSize: number;
  10154. /**
  10155. * Maximum size of each particle
  10156. */
  10157. maxSize: number;
  10158. /**
  10159. * Minimum scale of each particle on X axis
  10160. */
  10161. minScaleX: number;
  10162. /**
  10163. * Maximum scale of each particle on X axis
  10164. */
  10165. maxScaleX: number;
  10166. /**
  10167. * Minimum scale of each particle on Y axis
  10168. */
  10169. minScaleY: number;
  10170. /**
  10171. * Maximum scale of each particle on Y axis
  10172. */
  10173. maxScaleY: number;
  10174. /**
  10175. * Minimum lifetime for each particle
  10176. */
  10177. minLifeTime: number;
  10178. /**
  10179. * Maximum lifetime for each particle
  10180. */
  10181. maxLifeTime: number;
  10182. /**
  10183. * Emit rate
  10184. */
  10185. emitRate: number;
  10186. /**
  10187. * Blend Mode
  10188. */
  10189. blendMode: number;
  10190. /**
  10191. * gravity Vector3
  10192. */
  10193. gravity: {
  10194. x: number;
  10195. y: number;
  10196. z: number;
  10197. };
  10198. /**
  10199. * direction1 Vector3
  10200. */
  10201. direction1?: {
  10202. x: number;
  10203. y: number;
  10204. z: number;
  10205. };
  10206. /**
  10207. * direction2 Vector3
  10208. */
  10209. direction2?: {
  10210. x: number;
  10211. y: number;
  10212. z: number;
  10213. };
  10214. /**
  10215. * Minimum Angular Speed
  10216. */
  10217. minAngularSpeed: number;
  10218. /**
  10219. * Maximum Angular Speed
  10220. */
  10221. maxAngularSpeed: number;
  10222. /**
  10223. * Minimum Emit Power
  10224. */
  10225. minEmitPower: number;
  10226. /**
  10227. * Maximum Emit Power
  10228. */
  10229. maxEmitPower: number;
  10230. /**
  10231. * Update Speed
  10232. */
  10233. updateSpeed: number;
  10234. /**
  10235. * Radius
  10236. */
  10237. radius?: number;
  10238. /**
  10239. * Angle
  10240. */
  10241. angle?: number;
  10242. }
  10243. /**
  10244. * This class is made for on one-liner static method to help creating particle systems.
  10245. */
  10246. class ParticleHelper {
  10247. /**
  10248. * Base Assets URL.
  10249. */
  10250. private static _baseAssetsUrl;
  10251. /**
  10252. * This is the main static method (one-liner) of this helper to create different particle systems.
  10253. * @param type This string represents the type to the particle system to create
  10254. * @param emitter The object where the particle system will start to emit from.
  10255. * @param scene The scene where the particle system should live.
  10256. * @param gpu If the system will use gpu.
  10257. * @returns the ParticleSystem created.
  10258. */
  10259. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  10260. /**
  10261. * Static function used to create a new particle system from a IParticleSystemData
  10262. * @param data defines the source data
  10263. * @param scene defines the hosting scene
  10264. * @param emitter defines the particle emitter
  10265. * @returns a new ParticleSystem based on referenced data
  10266. */
  10267. static CreateSystem(data: IParticleSystemData, scene: Scene, emitter: AbstractMesh): ParticleSystem;
  10268. /**
  10269. * Static function used to update a particle system from a IParticleSystemData
  10270. * @param system defines the particle system to update
  10271. * @param data defines the source data
  10272. * @param scene defines the hosting scene
  10273. */
  10274. static UpdateSystem(system: ParticleSystem, data: IParticleSystemData, scene: Scene): void;
  10275. /**
  10276. * Static function used to export a particle system to a IParticleSystemData variable.
  10277. * Please note that texture file name is not exported and must be added manually
  10278. * @param system defines the particle system to export
  10279. */
  10280. static ExportSystem(system: ParticleSystem): IParticleSystemData;
  10281. }
  10282. }
  10283. declare module BABYLON {
  10284. /**
  10285. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10286. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10287. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10288. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10289. */
  10290. class PhotoDome extends Node {
  10291. /**
  10292. * The texture being displayed on the sphere
  10293. */
  10294. protected _photoTexture: Texture;
  10295. /**
  10296. * Gets the texture being displayed on the sphere
  10297. */
  10298. readonly photoTexture: Texture;
  10299. /**
  10300. * The skybox material
  10301. */
  10302. protected _material: BackgroundMaterial;
  10303. /**
  10304. * The surface used for the skybox
  10305. */
  10306. protected _mesh: Mesh;
  10307. /**
  10308. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10309. * Also see the options.resolution property.
  10310. */
  10311. fovMultiplier: number;
  10312. /**
  10313. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10314. * @param name Element's name, child elements will append suffixes for their own names.
  10315. * @param urlsOfPhoto define the url of the photo to display
  10316. * @param options An object containing optional or exposed sub element properties
  10317. */
  10318. constructor(name: string, urlOfPhoto: string, options: {
  10319. resolution?: number;
  10320. size?: number;
  10321. }, scene: Scene);
  10322. /**
  10323. * Releases resources associated with this node.
  10324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10326. */
  10327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10328. }
  10329. }
  10330. declare module BABYLON {
  10331. /**
  10332. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10333. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10334. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10335. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10336. */
  10337. class VideoDome extends Node {
  10338. /**
  10339. * The video texture being displayed on the sphere
  10340. */
  10341. protected _videoTexture: VideoTexture;
  10342. /**
  10343. * Gets the video texture being displayed on the sphere
  10344. */
  10345. readonly videoTexture: VideoTexture;
  10346. /**
  10347. * The skybox material
  10348. */
  10349. protected _material: BackgroundMaterial;
  10350. /**
  10351. * The surface used for the skybox
  10352. */
  10353. protected _mesh: Mesh;
  10354. /**
  10355. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10356. * Also see the options.resolution property.
  10357. */
  10358. fovMultiplier: number;
  10359. /**
  10360. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10361. * @param name Element's name, child elements will append suffixes for their own names.
  10362. * @param urlsOrVideo defines the url(s) or the video element to use
  10363. * @param options An object containing optional or exposed sub element properties
  10364. */
  10365. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10366. resolution?: number;
  10367. clickToPlay?: boolean;
  10368. autoPlay?: boolean;
  10369. loop?: boolean;
  10370. size?: number;
  10371. poster?: string;
  10372. }, scene: Scene);
  10373. /**
  10374. * Releases resources associated with this node.
  10375. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10376. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10377. */
  10378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10379. }
  10380. }
  10381. declare module BABYLON {
  10382. /**
  10383. * This class can be used to get instrumentation data from a Babylon engine
  10384. */
  10385. class EngineInstrumentation implements IDisposable {
  10386. engine: Engine;
  10387. private _captureGPUFrameTime;
  10388. private _gpuFrameTimeToken;
  10389. private _gpuFrameTime;
  10390. private _captureShaderCompilationTime;
  10391. private _shaderCompilationTime;
  10392. private _onBeginFrameObserver;
  10393. private _onEndFrameObserver;
  10394. private _onBeforeShaderCompilationObserver;
  10395. private _onAfterShaderCompilationObserver;
  10396. /**
  10397. * Gets the perf counter used for GPU frame time
  10398. */
  10399. readonly gpuFrameTimeCounter: PerfCounter;
  10400. /**
  10401. * Gets the GPU frame time capture status
  10402. */
  10403. /**
  10404. * Enable or disable the GPU frame time capture
  10405. */
  10406. captureGPUFrameTime: boolean;
  10407. /**
  10408. * Gets the perf counter used for shader compilation time
  10409. */
  10410. readonly shaderCompilationTimeCounter: PerfCounter;
  10411. /**
  10412. * Gets the shader compilation time capture status
  10413. */
  10414. /**
  10415. * Enable or disable the shader compilation time capture
  10416. */
  10417. captureShaderCompilationTime: boolean;
  10418. constructor(engine: Engine);
  10419. dispose(): void;
  10420. }
  10421. }
  10422. declare module BABYLON {
  10423. /**
  10424. * This class can be used to get instrumentation data from a Babylon engine
  10425. */
  10426. class SceneInstrumentation implements IDisposable {
  10427. scene: Scene;
  10428. private _captureActiveMeshesEvaluationTime;
  10429. private _activeMeshesEvaluationTime;
  10430. private _captureRenderTargetsRenderTime;
  10431. private _renderTargetsRenderTime;
  10432. private _captureFrameTime;
  10433. private _frameTime;
  10434. private _captureRenderTime;
  10435. private _renderTime;
  10436. private _captureInterFrameTime;
  10437. private _interFrameTime;
  10438. private _captureParticlesRenderTime;
  10439. private _particlesRenderTime;
  10440. private _captureSpritesRenderTime;
  10441. private _spritesRenderTime;
  10442. private _capturePhysicsTime;
  10443. private _physicsTime;
  10444. private _captureAnimationsTime;
  10445. private _animationsTime;
  10446. private _captureCameraRenderTime;
  10447. private _cameraRenderTime;
  10448. private _onBeforeActiveMeshesEvaluationObserver;
  10449. private _onAfterActiveMeshesEvaluationObserver;
  10450. private _onBeforeRenderTargetsRenderObserver;
  10451. private _onAfterRenderTargetsRenderObserver;
  10452. private _onAfterRenderObserver;
  10453. private _onBeforeDrawPhaseObserver;
  10454. private _onAfterDrawPhaseObserver;
  10455. private _onBeforeAnimationsObserver;
  10456. private _onBeforeParticlesRenderingObserver;
  10457. private _onAfterParticlesRenderingObserver;
  10458. private _onBeforeSpritesRenderingObserver;
  10459. private _onAfterSpritesRenderingObserver;
  10460. private _onBeforePhysicsObserver;
  10461. private _onAfterPhysicsObserver;
  10462. private _onAfterAnimationsObserver;
  10463. private _onBeforeCameraRenderObserver;
  10464. private _onAfterCameraRenderObserver;
  10465. /**
  10466. * Gets the perf counter used for active meshes evaluation time
  10467. */
  10468. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10469. /**
  10470. * Gets the active meshes evaluation time capture status
  10471. */
  10472. /**
  10473. * Enable or disable the active meshes evaluation time capture
  10474. */
  10475. captureActiveMeshesEvaluationTime: boolean;
  10476. /**
  10477. * Gets the perf counter used for render targets render time
  10478. */
  10479. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10480. /**
  10481. * Gets the render targets render time capture status
  10482. */
  10483. /**
  10484. * Enable or disable the render targets render time capture
  10485. */
  10486. captureRenderTargetsRenderTime: boolean;
  10487. /**
  10488. * Gets the perf counter used for particles render time
  10489. */
  10490. readonly particlesRenderTimeCounter: PerfCounter;
  10491. /**
  10492. * Gets the particles render time capture status
  10493. */
  10494. /**
  10495. * Enable or disable the particles render time capture
  10496. */
  10497. captureParticlesRenderTime: boolean;
  10498. /**
  10499. * Gets the perf counter used for sprites render time
  10500. */
  10501. readonly spritesRenderTimeCounter: PerfCounter;
  10502. /**
  10503. * Gets the sprites render time capture status
  10504. */
  10505. /**
  10506. * Enable or disable the sprites render time capture
  10507. */
  10508. captureSpritesRenderTime: boolean;
  10509. /**
  10510. * Gets the perf counter used for physics time
  10511. */
  10512. readonly physicsTimeCounter: PerfCounter;
  10513. /**
  10514. * Gets the physics time capture status
  10515. */
  10516. /**
  10517. * Enable or disable the physics time capture
  10518. */
  10519. capturePhysicsTime: boolean;
  10520. /**
  10521. * Gets the perf counter used for animations time
  10522. */
  10523. readonly animationsTimeCounter: PerfCounter;
  10524. /**
  10525. * Gets the animations time capture status
  10526. */
  10527. /**
  10528. * Enable or disable the animations time capture
  10529. */
  10530. captureAnimationsTime: boolean;
  10531. /**
  10532. * Gets the perf counter used for frame time capture
  10533. */
  10534. readonly frameTimeCounter: PerfCounter;
  10535. /**
  10536. * Gets the frame time capture status
  10537. */
  10538. /**
  10539. * Enable or disable the frame time capture
  10540. */
  10541. captureFrameTime: boolean;
  10542. /**
  10543. * Gets the perf counter used for inter-frames time capture
  10544. */
  10545. readonly interFrameTimeCounter: PerfCounter;
  10546. /**
  10547. * Gets the inter-frames time capture status
  10548. */
  10549. /**
  10550. * Enable or disable the inter-frames time capture
  10551. */
  10552. captureInterFrameTime: boolean;
  10553. /**
  10554. * Gets the perf counter used for render time capture
  10555. */
  10556. readonly renderTimeCounter: PerfCounter;
  10557. /**
  10558. * Gets the render time capture status
  10559. */
  10560. /**
  10561. * Enable or disable the render time capture
  10562. */
  10563. captureRenderTime: boolean;
  10564. /**
  10565. * Gets the perf counter used for camera render time capture
  10566. */
  10567. readonly cameraRenderTimeCounter: PerfCounter;
  10568. /**
  10569. * Gets the camera render time capture status
  10570. */
  10571. /**
  10572. * Enable or disable the camera render time capture
  10573. */
  10574. captureCameraRenderTime: boolean;
  10575. /**
  10576. * Gets the perf counter used for draw calls
  10577. */
  10578. readonly drawCallsCounter: PerfCounter;
  10579. /**
  10580. * Gets the perf counter used for texture collisions
  10581. */
  10582. readonly textureCollisionsCounter: PerfCounter;
  10583. constructor(scene: Scene);
  10584. dispose(): void;
  10585. }
  10586. }
  10587. declare module BABYLON {
  10588. /**
  10589. * @hidden
  10590. **/
  10591. class _TimeToken {
  10592. _startTimeQuery: Nullable<WebGLQuery>;
  10593. _endTimeQuery: Nullable<WebGLQuery>;
  10594. _timeElapsedQuery: Nullable<WebGLQuery>;
  10595. _timeElapsedQueryEnded: boolean;
  10596. }
  10597. }
  10598. declare module BABYLON {
  10599. /**
  10600. * Effect layer options. This helps customizing the behaviour
  10601. * of the effect layer.
  10602. */
  10603. interface IEffectLayerOptions {
  10604. /**
  10605. * Multiplication factor apply to the canvas size to compute the render target size
  10606. * used to generated the objects (the smaller the faster).
  10607. */
  10608. mainTextureRatio: number;
  10609. /**
  10610. * Enforces a fixed size texture to ensure effect stability across devices.
  10611. */
  10612. mainTextureFixedSize?: number;
  10613. /**
  10614. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10615. */
  10616. alphaBlendingMode: number;
  10617. /**
  10618. * The camera attached to the layer.
  10619. */
  10620. camera: Nullable<Camera>;
  10621. }
  10622. /**
  10623. * The effect layer Helps adding post process effect blended with the main pass.
  10624. *
  10625. * This can be for instance use to generate glow or higlight effects on the scene.
  10626. *
  10627. * The effect layer class can not be used directly and is intented to inherited from to be
  10628. * customized per effects.
  10629. */
  10630. abstract class EffectLayer {
  10631. private _vertexBuffers;
  10632. private _indexBuffer;
  10633. private _cachedDefines;
  10634. private _effectLayerMapGenerationEffect;
  10635. private _effectLayerOptions;
  10636. private _mergeEffect;
  10637. protected _scene: Scene;
  10638. protected _engine: Engine;
  10639. protected _maxSize: number;
  10640. protected _mainTextureDesiredSize: ISize;
  10641. protected _mainTexture: RenderTargetTexture;
  10642. protected _shouldRender: boolean;
  10643. protected _postProcesses: PostProcess[];
  10644. protected _textures: BaseTexture[];
  10645. protected _emissiveTextureAndColor: {
  10646. texture: Nullable<BaseTexture>;
  10647. color: Color4;
  10648. };
  10649. /**
  10650. * The name of the layer
  10651. */
  10652. name: string;
  10653. /**
  10654. * The clear color of the texture used to generate the glow map.
  10655. */
  10656. neutralColor: Color4;
  10657. /**
  10658. * Specifies wether the highlight layer is enabled or not.
  10659. */
  10660. isEnabled: boolean;
  10661. /**
  10662. * Gets the camera attached to the layer.
  10663. */
  10664. readonly camera: Nullable<Camera>;
  10665. /**
  10666. * An event triggered when the effect layer has been disposed.
  10667. */
  10668. onDisposeObservable: Observable<EffectLayer>;
  10669. /**
  10670. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10671. */
  10672. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10673. /**
  10674. * An event triggered when the generated texture is being merged in the scene.
  10675. */
  10676. onBeforeComposeObservable: Observable<EffectLayer>;
  10677. /**
  10678. * An event triggered when the generated texture has been merged in the scene.
  10679. */
  10680. onAfterComposeObservable: Observable<EffectLayer>;
  10681. /**
  10682. * An event triggered when the efffect layer changes its size.
  10683. */
  10684. onSizeChangedObservable: Observable<EffectLayer>;
  10685. /**
  10686. * Instantiates a new effect Layer and references it in the scene.
  10687. * @param name The name of the layer
  10688. * @param scene The scene to use the layer in
  10689. */
  10690. constructor(
  10691. /** The Friendly of the effect in the scene */
  10692. name: string, scene: Scene);
  10693. /**
  10694. * Get the effect name of the layer.
  10695. * @return The effect name
  10696. */
  10697. abstract getEffectName(): string;
  10698. /**
  10699. * Checks for the readiness of the element composing the layer.
  10700. * @param subMesh the mesh to check for
  10701. * @param useInstances specify wether or not to use instances to render the mesh
  10702. * @return true if ready otherwise, false
  10703. */
  10704. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10705. /**
  10706. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10707. * @returns true if the effect requires stencil during the main canvas render pass.
  10708. */
  10709. abstract needStencil(): boolean;
  10710. /**
  10711. * Create the merge effect. This is the shader use to blit the information back
  10712. * to the main canvas at the end of the scene rendering.
  10713. * @returns The effect containing the shader used to merge the effect on the main canvas
  10714. */
  10715. protected abstract _createMergeEffect(): Effect;
  10716. /**
  10717. * Creates the render target textures and post processes used in the effect layer.
  10718. */
  10719. protected abstract _createTextureAndPostProcesses(): void;
  10720. /**
  10721. * Implementation specific of rendering the generating effect on the main canvas.
  10722. * @param effect The effect used to render through
  10723. */
  10724. protected abstract _internalRender(effect: Effect): void;
  10725. /**
  10726. * Sets the required values for both the emissive texture and and the main color.
  10727. */
  10728. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10729. /**
  10730. * Free any resources and references associated to a mesh.
  10731. * Internal use
  10732. * @param mesh The mesh to free.
  10733. */
  10734. abstract _disposeMesh(mesh: Mesh): void;
  10735. /**
  10736. * Serializes this layer (Glow or Highlight for example)
  10737. * @returns a serialized layer object
  10738. */
  10739. abstract serialize?(): any;
  10740. /**
  10741. * Initializes the effect layer with the required options.
  10742. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10743. */
  10744. protected _init(options: Partial<IEffectLayerOptions>): void;
  10745. /**
  10746. * Generates the index buffer of the full screen quad blending to the main canvas.
  10747. */
  10748. private _generateIndexBuffer();
  10749. /**
  10750. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10751. */
  10752. private _genrateVertexBuffer();
  10753. /**
  10754. * Sets the main texture desired size which is the closest power of two
  10755. * of the engine canvas size.
  10756. */
  10757. private _setMainTextureSize();
  10758. /**
  10759. * Creates the main texture for the effect layer.
  10760. */
  10761. protected _createMainTexture(): void;
  10762. /**
  10763. * Checks for the readiness of the element composing the layer.
  10764. * @param subMesh the mesh to check for
  10765. * @param useInstances specify wether or not to use instances to render the mesh
  10766. * @param emissiveTexture the associated emissive texture used to generate the glow
  10767. * @return true if ready otherwise, false
  10768. */
  10769. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10770. /**
  10771. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10772. */
  10773. render(): void;
  10774. /**
  10775. * Determine if a given mesh will be used in the current effect.
  10776. * @param mesh mesh to test
  10777. * @returns true if the mesh will be used
  10778. */
  10779. hasMesh(mesh: AbstractMesh): boolean;
  10780. /**
  10781. * Returns true if the layer contains information to display, otherwise false.
  10782. * @returns true if the glow layer should be rendered
  10783. */
  10784. shouldRender(): boolean;
  10785. /**
  10786. * Returns true if the mesh should render, otherwise false.
  10787. * @param mesh The mesh to render
  10788. * @returns true if it should render otherwise false
  10789. */
  10790. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10791. /**
  10792. * Returns true if the mesh should render, otherwise false.
  10793. * @param mesh The mesh to render
  10794. * @returns true if it should render otherwise false
  10795. */
  10796. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10797. /**
  10798. * Renders the submesh passed in parameter to the generation map.
  10799. */
  10800. protected _renderSubMesh(subMesh: SubMesh): void;
  10801. /**
  10802. * Rebuild the required buffers.
  10803. * @hidden Internal use only.
  10804. */
  10805. _rebuild(): void;
  10806. /**
  10807. * Dispose only the render target textures and post process.
  10808. */
  10809. private _disposeTextureAndPostProcesses();
  10810. /**
  10811. * Dispose the highlight layer and free resources.
  10812. */
  10813. dispose(): void;
  10814. /**
  10815. * Gets the class name of the effect layer
  10816. * @returns the string with the class name of the effect layer
  10817. */
  10818. getClassName(): string;
  10819. /**
  10820. * Creates an effect layer from parsed effect layer data
  10821. * @param parsedEffectLayer defines effect layer data
  10822. * @param scene defines the current scene
  10823. * @param rootUrl defines the root URL containing the effect layer information
  10824. * @returns a parsed effect Layer
  10825. */
  10826. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10827. }
  10828. }
  10829. declare module BABYLON {
  10830. /**
  10831. * Glow layer options. This helps customizing the behaviour
  10832. * of the glow layer.
  10833. */
  10834. interface IGlowLayerOptions {
  10835. /**
  10836. * Multiplication factor apply to the canvas size to compute the render target size
  10837. * used to generated the glowing objects (the smaller the faster).
  10838. */
  10839. mainTextureRatio: number;
  10840. /**
  10841. * Enforces a fixed size texture to ensure resize independant blur.
  10842. */
  10843. mainTextureFixedSize?: number;
  10844. /**
  10845. * How big is the kernel of the blur texture.
  10846. */
  10847. blurKernelSize: number;
  10848. /**
  10849. * The camera attached to the layer.
  10850. */
  10851. camera: Nullable<Camera>;
  10852. /**
  10853. * Enable MSAA by chosing the number of samples.
  10854. */
  10855. mainTextureSamples?: number;
  10856. }
  10857. /**
  10858. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10859. *
  10860. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10861. * glowy meshes to your scene.
  10862. *
  10863. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10864. */
  10865. class GlowLayer extends EffectLayer {
  10866. /**
  10867. * Effect Name of the layer.
  10868. */
  10869. static readonly EffectName: string;
  10870. /**
  10871. * The default blur kernel size used for the glow.
  10872. */
  10873. static DefaultBlurKernelSize: number;
  10874. /**
  10875. * The default texture size ratio used for the glow.
  10876. */
  10877. static DefaultTextureRatio: number;
  10878. /**
  10879. * Gets the kernel size of the blur.
  10880. */
  10881. /**
  10882. * Sets the kernel size of the blur.
  10883. */
  10884. blurKernelSize: number;
  10885. /**
  10886. * Gets the glow intensity.
  10887. */
  10888. /**
  10889. * Sets the glow intensity.
  10890. */
  10891. intensity: number;
  10892. private _options;
  10893. private _intensity;
  10894. private _horizontalBlurPostprocess1;
  10895. private _verticalBlurPostprocess1;
  10896. private _horizontalBlurPostprocess2;
  10897. private _verticalBlurPostprocess2;
  10898. private _blurTexture1;
  10899. private _blurTexture2;
  10900. private _postProcesses1;
  10901. private _postProcesses2;
  10902. private _includedOnlyMeshes;
  10903. private _excludedMeshes;
  10904. /**
  10905. * Callback used to let the user override the color selection on a per mesh basis
  10906. */
  10907. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10908. /**
  10909. * Callback used to let the user override the texture selection on a per mesh basis
  10910. */
  10911. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10912. /**
  10913. * Instantiates a new glow Layer and references it to the scene.
  10914. * @param name The name of the layer
  10915. * @param scene The scene to use the layer in
  10916. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10917. */
  10918. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10919. /**
  10920. * Get the effect name of the layer.
  10921. * @return The effect name
  10922. */
  10923. getEffectName(): string;
  10924. /**
  10925. * Create the merge effect. This is the shader use to blit the information back
  10926. * to the main canvas at the end of the scene rendering.
  10927. */
  10928. protected _createMergeEffect(): Effect;
  10929. /**
  10930. * Creates the render target textures and post processes used in the glow layer.
  10931. */
  10932. protected _createTextureAndPostProcesses(): void;
  10933. /**
  10934. * Checks for the readiness of the element composing the layer.
  10935. * @param subMesh the mesh to check for
  10936. * @param useInstances specify wether or not to use instances to render the mesh
  10937. * @param emissiveTexture the associated emissive texture used to generate the glow
  10938. * @return true if ready otherwise, false
  10939. */
  10940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10941. /**
  10942. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10943. */
  10944. needStencil(): boolean;
  10945. /**
  10946. * Implementation specific of rendering the generating effect on the main canvas.
  10947. * @param effect The effect used to render through
  10948. */
  10949. protected _internalRender(effect: Effect): void;
  10950. /**
  10951. * Sets the required values for both the emissive texture and and the main color.
  10952. */
  10953. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10954. /**
  10955. * Returns true if the mesh should render, otherwise false.
  10956. * @param mesh The mesh to render
  10957. * @returns true if it should render otherwise false
  10958. */
  10959. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10960. /**
  10961. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10962. * @param mesh The mesh to exclude from the glow layer
  10963. */
  10964. addExcludedMesh(mesh: Mesh): void;
  10965. /**
  10966. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10967. * @param mesh The mesh to remove
  10968. */
  10969. removeExcludedMesh(mesh: Mesh): void;
  10970. /**
  10971. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10972. * @param mesh The mesh to include in the glow layer
  10973. */
  10974. addIncludedOnlyMesh(mesh: Mesh): void;
  10975. /**
  10976. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10977. * @param mesh The mesh to remove
  10978. */
  10979. removeIncludedOnlyMesh(mesh: Mesh): void;
  10980. /**
  10981. * Determine if a given mesh will be used in the glow layer
  10982. * @param mesh The mesh to test
  10983. * @returns true if the mesh will be highlighted by the current glow layer
  10984. */
  10985. hasMesh(mesh: AbstractMesh): boolean;
  10986. /**
  10987. * Free any resources and references associated to a mesh.
  10988. * Internal use
  10989. * @param mesh The mesh to free.
  10990. */
  10991. _disposeMesh(mesh: Mesh): void;
  10992. /**
  10993. * Gets the class name of the effect layer
  10994. * @returns the string with the class name of the effect layer
  10995. */
  10996. getClassName(): string;
  10997. /**
  10998. * Serializes this glow layer
  10999. * @returns a serialized glow layer object
  11000. */
  11001. serialize(): any;
  11002. /**
  11003. * Creates a Glow Layer from parsed glow layer data
  11004. * @param parsedGlowLayer defines glow layer data
  11005. * @param scene defines the current scene
  11006. * @param rootUrl defines the root URL containing the glow layer information
  11007. * @returns a parsed Glow Layer
  11008. */
  11009. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11010. }
  11011. }
  11012. declare module BABYLON {
  11013. /**
  11014. * Highlight layer options. This helps customizing the behaviour
  11015. * of the highlight layer.
  11016. */
  11017. interface IHighlightLayerOptions {
  11018. /**
  11019. * Multiplication factor apply to the canvas size to compute the render target size
  11020. * used to generated the glowing objects (the smaller the faster).
  11021. */
  11022. mainTextureRatio: number;
  11023. /**
  11024. * Enforces a fixed size texture to ensure resize independant blur.
  11025. */
  11026. mainTextureFixedSize?: number;
  11027. /**
  11028. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11029. * of the picture to blur (the smaller the faster).
  11030. */
  11031. blurTextureSizeRatio: number;
  11032. /**
  11033. * How big in texel of the blur texture is the vertical blur.
  11034. */
  11035. blurVerticalSize: number;
  11036. /**
  11037. * How big in texel of the blur texture is the horizontal blur.
  11038. */
  11039. blurHorizontalSize: number;
  11040. /**
  11041. * Alpha blending mode used to apply the blur. Default is combine.
  11042. */
  11043. alphaBlendingMode: number;
  11044. /**
  11045. * The camera attached to the layer.
  11046. */
  11047. camera: Nullable<Camera>;
  11048. /**
  11049. * Should we display highlight as a solid stroke?
  11050. */
  11051. isStroke?: boolean;
  11052. }
  11053. /**
  11054. * The highlight layer Helps adding a glow effect around a mesh.
  11055. *
  11056. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11057. * glowy meshes to your scene.
  11058. *
  11059. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11060. */
  11061. class HighlightLayer extends EffectLayer {
  11062. name: string;
  11063. /**
  11064. * Effect Name of the highlight layer.
  11065. */
  11066. static readonly EffectName: string;
  11067. /**
  11068. * The neutral color used during the preparation of the glow effect.
  11069. * This is black by default as the blend operation is a blend operation.
  11070. */
  11071. static NeutralColor: Color4;
  11072. /**
  11073. * Stencil value used for glowing meshes.
  11074. */
  11075. static GlowingMeshStencilReference: number;
  11076. /**
  11077. * Stencil value used for the other meshes in the scene.
  11078. */
  11079. static NormalMeshStencilReference: number;
  11080. /**
  11081. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11082. */
  11083. innerGlow: boolean;
  11084. /**
  11085. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11086. */
  11087. outerGlow: boolean;
  11088. /**
  11089. * Gets the horizontal size of the blur.
  11090. */
  11091. /**
  11092. * Specifies the horizontal size of the blur.
  11093. */
  11094. blurHorizontalSize: number;
  11095. /**
  11096. * Gets the vertical size of the blur.
  11097. */
  11098. /**
  11099. * Specifies the vertical size of the blur.
  11100. */
  11101. blurVerticalSize: number;
  11102. /**
  11103. * An event triggered when the highlight layer is being blurred.
  11104. */
  11105. onBeforeBlurObservable: Observable<HighlightLayer>;
  11106. /**
  11107. * An event triggered when the highlight layer has been blurred.
  11108. */
  11109. onAfterBlurObservable: Observable<HighlightLayer>;
  11110. private _instanceGlowingMeshStencilReference;
  11111. private _options;
  11112. private _downSamplePostprocess;
  11113. private _horizontalBlurPostprocess;
  11114. private _verticalBlurPostprocess;
  11115. private _blurTexture;
  11116. private _meshes;
  11117. private _excludedMeshes;
  11118. /**
  11119. * Instantiates a new highlight Layer and references it to the scene..
  11120. * @param name The name of the layer
  11121. * @param scene The scene to use the layer in
  11122. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11123. */
  11124. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11125. /**
  11126. * Get the effect name of the layer.
  11127. * @return The effect name
  11128. */
  11129. getEffectName(): string;
  11130. /**
  11131. * Create the merge effect. This is the shader use to blit the information back
  11132. * to the main canvas at the end of the scene rendering.
  11133. */
  11134. protected _createMergeEffect(): Effect;
  11135. /**
  11136. * Creates the render target textures and post processes used in the highlight layer.
  11137. */
  11138. protected _createTextureAndPostProcesses(): void;
  11139. /**
  11140. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11141. */
  11142. needStencil(): boolean;
  11143. /**
  11144. * Checks for the readiness of the element composing the layer.
  11145. * @param subMesh the mesh to check for
  11146. * @param useInstances specify wether or not to use instances to render the mesh
  11147. * @param emissiveTexture the associated emissive texture used to generate the glow
  11148. * @return true if ready otherwise, false
  11149. */
  11150. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11151. /**
  11152. * Implementation specific of rendering the generating effect on the main canvas.
  11153. * @param effect The effect used to render through
  11154. */
  11155. protected _internalRender(effect: Effect): void;
  11156. /**
  11157. * Returns true if the layer contains information to display, otherwise false.
  11158. */
  11159. shouldRender(): boolean;
  11160. /**
  11161. * Returns true if the mesh should render, otherwise false.
  11162. * @param mesh The mesh to render
  11163. * @returns true if it should render otherwise false
  11164. */
  11165. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11166. /**
  11167. * Sets the required values for both the emissive texture and and the main color.
  11168. */
  11169. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11170. /**
  11171. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11172. * @param mesh The mesh to exclude from the highlight layer
  11173. */
  11174. addExcludedMesh(mesh: Mesh): void;
  11175. /**
  11176. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11177. * @param mesh The mesh to highlight
  11178. */
  11179. removeExcludedMesh(mesh: Mesh): void;
  11180. /**
  11181. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11182. * @param mesh mesh to test
  11183. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11184. */
  11185. hasMesh(mesh: AbstractMesh): boolean;
  11186. /**
  11187. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11188. * @param mesh The mesh to highlight
  11189. * @param color The color of the highlight
  11190. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11191. */
  11192. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11193. /**
  11194. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11195. * @param mesh The mesh to highlight
  11196. */
  11197. removeMesh(mesh: Mesh): void;
  11198. /**
  11199. * Force the stencil to the normal expected value for none glowing parts
  11200. */
  11201. private _defaultStencilReference(mesh);
  11202. /**
  11203. * Free any resources and references associated to a mesh.
  11204. * Internal use
  11205. * @param mesh The mesh to free.
  11206. */
  11207. _disposeMesh(mesh: Mesh): void;
  11208. /**
  11209. * Dispose the highlight layer and free resources.
  11210. */
  11211. dispose(): void;
  11212. /**
  11213. * Gets the class name of the effect layer
  11214. * @returns the string with the class name of the effect layer
  11215. */
  11216. getClassName(): string;
  11217. /**
  11218. * Serializes this Highlight layer
  11219. * @returns a serialized Highlight layer object
  11220. */
  11221. serialize(): any;
  11222. /**
  11223. * Creates a Highlight layer from parsed Highlight layer data
  11224. * @param parsedHightlightLayer defines the Highlight layer data
  11225. * @param scene defines the current scene
  11226. * @param rootUrl defines the root URL containing the Highlight layer information
  11227. * @returns a parsed Highlight layer
  11228. */
  11229. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11230. }
  11231. }
  11232. declare module BABYLON {
  11233. class Layer {
  11234. name: string;
  11235. texture: Nullable<Texture>;
  11236. isBackground: boolean;
  11237. color: Color4;
  11238. scale: Vector2;
  11239. offset: Vector2;
  11240. alphaBlendingMode: number;
  11241. alphaTest: boolean;
  11242. layerMask: number;
  11243. private _scene;
  11244. private _vertexBuffers;
  11245. private _indexBuffer;
  11246. private _effect;
  11247. private _alphaTestEffect;
  11248. /**
  11249. * An event triggered when the layer is disposed.
  11250. */
  11251. onDisposeObservable: Observable<Layer>;
  11252. private _onDisposeObserver;
  11253. onDispose: () => void;
  11254. /**
  11255. * An event triggered before rendering the scene
  11256. */
  11257. onBeforeRenderObservable: Observable<Layer>;
  11258. private _onBeforeRenderObserver;
  11259. onBeforeRender: () => void;
  11260. /**
  11261. * An event triggered after rendering the scene
  11262. */
  11263. onAfterRenderObservable: Observable<Layer>;
  11264. private _onAfterRenderObserver;
  11265. onAfterRender: () => void;
  11266. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11267. private _createIndexBuffer();
  11268. _rebuild(): void;
  11269. render(): void;
  11270. dispose(): void;
  11271. }
  11272. }
  11273. declare module BABYLON {
  11274. class LensFlare {
  11275. size: number;
  11276. position: number;
  11277. color: Color3;
  11278. texture: Nullable<Texture>;
  11279. alphaMode: number;
  11280. private _system;
  11281. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11282. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11283. dispose(): void;
  11284. }
  11285. }
  11286. declare module BABYLON {
  11287. class LensFlareSystem {
  11288. name: string;
  11289. lensFlares: LensFlare[];
  11290. borderLimit: number;
  11291. viewportBorder: number;
  11292. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11293. layerMask: number;
  11294. id: string;
  11295. private _scene;
  11296. private _emitter;
  11297. private _vertexBuffers;
  11298. private _indexBuffer;
  11299. private _effect;
  11300. private _positionX;
  11301. private _positionY;
  11302. private _isEnabled;
  11303. constructor(name: string, emitter: any, scene: Scene);
  11304. isEnabled: boolean;
  11305. getScene(): Scene;
  11306. getEmitter(): any;
  11307. setEmitter(newEmitter: any): void;
  11308. getEmitterPosition(): Vector3;
  11309. computeEffectivePosition(globalViewport: Viewport): boolean;
  11310. _isVisible(): boolean;
  11311. render(): boolean;
  11312. dispose(): void;
  11313. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11314. serialize(): any;
  11315. }
  11316. }
  11317. declare module BABYLON {
  11318. /**
  11319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11321. * 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;
  11322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11323. */
  11324. class ColorCurves {
  11325. private _dirty;
  11326. private _tempColor;
  11327. private _globalCurve;
  11328. private _highlightsCurve;
  11329. private _midtonesCurve;
  11330. private _shadowsCurve;
  11331. private _positiveCurve;
  11332. private _negativeCurve;
  11333. private _globalHue;
  11334. private _globalDensity;
  11335. private _globalSaturation;
  11336. private _globalExposure;
  11337. /**
  11338. * Gets the global Hue value.
  11339. * 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).
  11340. */
  11341. /**
  11342. * Sets the global Hue value.
  11343. * 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).
  11344. */
  11345. globalHue: number;
  11346. /**
  11347. * Gets the global Density value.
  11348. * 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.
  11349. * Values less than zero provide a filter of opposite hue.
  11350. */
  11351. /**
  11352. * Sets the global Density value.
  11353. * 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.
  11354. * Values less than zero provide a filter of opposite hue.
  11355. */
  11356. globalDensity: number;
  11357. /**
  11358. * Gets the global Saturation value.
  11359. * 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.
  11360. */
  11361. /**
  11362. * Sets the global Saturation value.
  11363. * 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.
  11364. */
  11365. globalSaturation: number;
  11366. /**
  11367. * Gets the global Exposure value.
  11368. * 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.
  11369. */
  11370. /**
  11371. * Sets the global Exposure value.
  11372. * 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.
  11373. */
  11374. globalExposure: number;
  11375. private _highlightsHue;
  11376. private _highlightsDensity;
  11377. private _highlightsSaturation;
  11378. private _highlightsExposure;
  11379. /**
  11380. * Gets the highlights Hue value.
  11381. * 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).
  11382. */
  11383. /**
  11384. * Sets the highlights Hue value.
  11385. * 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).
  11386. */
  11387. highlightsHue: number;
  11388. /**
  11389. * Gets the highlights Density value.
  11390. * 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.
  11391. * Values less than zero provide a filter of opposite hue.
  11392. */
  11393. /**
  11394. * Sets the highlights Density value.
  11395. * 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.
  11396. * Values less than zero provide a filter of opposite hue.
  11397. */
  11398. highlightsDensity: number;
  11399. /**
  11400. * Gets the highlights Saturation value.
  11401. * 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.
  11402. */
  11403. /**
  11404. * Sets the highlights Saturation value.
  11405. * 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.
  11406. */
  11407. highlightsSaturation: number;
  11408. /**
  11409. * Gets the highlights Exposure value.
  11410. * 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.
  11411. */
  11412. /**
  11413. * Sets the highlights Exposure value.
  11414. * 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.
  11415. */
  11416. highlightsExposure: number;
  11417. private _midtonesHue;
  11418. private _midtonesDensity;
  11419. private _midtonesSaturation;
  11420. private _midtonesExposure;
  11421. /**
  11422. * Gets the midtones Hue value.
  11423. * 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).
  11424. */
  11425. /**
  11426. * Sets the midtones Hue value.
  11427. * 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).
  11428. */
  11429. midtonesHue: number;
  11430. /**
  11431. * Gets the midtones Density value.
  11432. * 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.
  11433. * Values less than zero provide a filter of opposite hue.
  11434. */
  11435. /**
  11436. * Sets the midtones Density value.
  11437. * 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.
  11438. * Values less than zero provide a filter of opposite hue.
  11439. */
  11440. midtonesDensity: number;
  11441. /**
  11442. * Gets the midtones Saturation value.
  11443. * 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.
  11444. */
  11445. /**
  11446. * Sets the midtones Saturation value.
  11447. * 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.
  11448. */
  11449. midtonesSaturation: number;
  11450. /**
  11451. * Gets the midtones Exposure value.
  11452. * 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.
  11453. */
  11454. /**
  11455. * Sets the midtones Exposure value.
  11456. * 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.
  11457. */
  11458. midtonesExposure: number;
  11459. private _shadowsHue;
  11460. private _shadowsDensity;
  11461. private _shadowsSaturation;
  11462. private _shadowsExposure;
  11463. /**
  11464. * Gets the shadows Hue value.
  11465. * 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).
  11466. */
  11467. /**
  11468. * Sets the shadows Hue value.
  11469. * 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).
  11470. */
  11471. shadowsHue: number;
  11472. /**
  11473. * Gets the shadows Density value.
  11474. * 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.
  11475. * Values less than zero provide a filter of opposite hue.
  11476. */
  11477. /**
  11478. * Sets the shadows Density value.
  11479. * 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.
  11480. * Values less than zero provide a filter of opposite hue.
  11481. */
  11482. shadowsDensity: number;
  11483. /**
  11484. * Gets the shadows Saturation value.
  11485. * 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.
  11486. */
  11487. /**
  11488. * Sets the shadows Saturation value.
  11489. * 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.
  11490. */
  11491. shadowsSaturation: number;
  11492. /**
  11493. * Gets the shadows Exposure value.
  11494. * 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.
  11495. */
  11496. /**
  11497. * Sets the shadows Exposure value.
  11498. * 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.
  11499. */
  11500. shadowsExposure: number;
  11501. getClassName(): string;
  11502. /**
  11503. * Binds the color curves to the shader.
  11504. * @param colorCurves The color curve to bind
  11505. * @param effect The effect to bind to
  11506. */
  11507. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11508. /**
  11509. * Prepare the list of uniforms associated with the ColorCurves effects.
  11510. * @param uniformsList The list of uniforms used in the effect
  11511. */
  11512. static PrepareUniforms(uniformsList: string[]): void;
  11513. /**
  11514. * Returns color grading data based on a hue, density, saturation and exposure value.
  11515. * @param filterHue The hue of the color filter.
  11516. * @param filterDensity The density of the color filter.
  11517. * @param saturation The saturation.
  11518. * @param exposure The exposure.
  11519. * @param result The result data container.
  11520. */
  11521. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11522. /**
  11523. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11524. * @param value The input slider value in range [-100,100].
  11525. * @returns Adjusted value.
  11526. */
  11527. private static applyColorGradingSliderNonlinear(value);
  11528. /**
  11529. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11530. * @param hue The hue (H) input.
  11531. * @param saturation The saturation (S) input.
  11532. * @param brightness The brightness (B) input.
  11533. * @result An RGBA color represented as Vector4.
  11534. */
  11535. private static fromHSBToRef(hue, saturation, brightness, result);
  11536. /**
  11537. * Returns a value clamped between min and max
  11538. * @param value The value to clamp
  11539. * @param min The minimum of value
  11540. * @param max The maximum of value
  11541. * @returns The clamped value.
  11542. */
  11543. private static clamp(value, min, max);
  11544. /**
  11545. * Clones the current color curve instance.
  11546. * @return The cloned curves
  11547. */
  11548. clone(): ColorCurves;
  11549. /**
  11550. * Serializes the current color curve instance to a json representation.
  11551. * @return a JSON representation
  11552. */
  11553. serialize(): any;
  11554. /**
  11555. * Parses the color curve from a json representation.
  11556. * @param source the JSON source to parse
  11557. * @return The parsed curves
  11558. */
  11559. static Parse(source: any): ColorCurves;
  11560. }
  11561. }
  11562. declare module BABYLON {
  11563. /**
  11564. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  11565. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  11566. */
  11567. class EffectFallbacks {
  11568. private _defines;
  11569. private _currentRank;
  11570. private _maxRank;
  11571. private _mesh;
  11572. /**
  11573. * Removes the fallback from the bound mesh.
  11574. */
  11575. unBindMesh(): void;
  11576. /**
  11577. * Adds a fallback on the specified property.
  11578. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11579. * @param define The name of the define in the shader
  11580. */
  11581. addFallback(rank: number, define: string): void;
  11582. /**
  11583. * Sets the mesh to use CPU skinning when needing to fallback.
  11584. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11585. * @param mesh The mesh to use the fallbacks.
  11586. */
  11587. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  11588. /**
  11589. * Checks to see if more fallbacks are still availible.
  11590. */
  11591. readonly isMoreFallbacks: boolean;
  11592. /**
  11593. * Removes the defines that shoould be removed when falling back.
  11594. * @param currentDefines defines the current define statements for the shader.
  11595. * @param effect defines the current effect we try to compile
  11596. * @returns The resulting defines with defines of the current rank removed.
  11597. */
  11598. reduce(currentDefines: string, effect: Effect): string;
  11599. }
  11600. /**
  11601. * Options to be used when creating an effect.
  11602. */
  11603. class EffectCreationOptions {
  11604. /**
  11605. * Atrributes that will be used in the shader.
  11606. */
  11607. attributes: string[];
  11608. /**
  11609. * Uniform varible names that will be set in the shader.
  11610. */
  11611. uniformsNames: string[];
  11612. /**
  11613. * Uniform buffer varible names that will be set in the shader.
  11614. */
  11615. uniformBuffersNames: string[];
  11616. /**
  11617. * Sampler texture variable names that will be set in the shader.
  11618. */
  11619. samplers: string[];
  11620. /**
  11621. * Define statements that will be set in the shader.
  11622. */
  11623. defines: any;
  11624. /**
  11625. * Possible fallbacks for this effect to improve performance when needed.
  11626. */
  11627. fallbacks: Nullable<EffectFallbacks>;
  11628. /**
  11629. * Callback that will be called when the shader is compiled.
  11630. */
  11631. onCompiled: Nullable<(effect: Effect) => void>;
  11632. /**
  11633. * Callback that will be called if an error occurs during shader compilation.
  11634. */
  11635. onError: Nullable<(effect: Effect, errors: string) => void>;
  11636. /**
  11637. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11638. */
  11639. indexParameters: any;
  11640. /**
  11641. * Max number of lights that can be used in the shader.
  11642. */
  11643. maxSimultaneousLights: number;
  11644. /**
  11645. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  11646. */
  11647. transformFeedbackVaryings: Nullable<string[]>;
  11648. }
  11649. /**
  11650. * Effect containing vertex and fragment shader that can be executed on an object.
  11651. */
  11652. class Effect {
  11653. /**
  11654. * Name of the effect.
  11655. */
  11656. name: any;
  11657. /**
  11658. * String container all the define statements that should be set on the shader.
  11659. */
  11660. defines: string;
  11661. /**
  11662. * Callback that will be called when the shader is compiled.
  11663. */
  11664. onCompiled: Nullable<(effect: Effect) => void>;
  11665. /**
  11666. * Callback that will be called if an error occurs during shader compilation.
  11667. */
  11668. onError: Nullable<(effect: Effect, errors: string) => void>;
  11669. /**
  11670. * Callback that will be called when effect is bound.
  11671. */
  11672. onBind: Nullable<(effect: Effect) => void>;
  11673. /**
  11674. * Unique ID of the effect.
  11675. */
  11676. uniqueId: number;
  11677. /**
  11678. * Observable that will be called when the shader is compiled.
  11679. */
  11680. onCompileObservable: Observable<Effect>;
  11681. /**
  11682. * Observable that will be called if an error occurs during shader compilation.
  11683. */
  11684. onErrorObservable: Observable<Effect>;
  11685. /**
  11686. * Observable that will be called when effect is bound.
  11687. */
  11688. onBindObservable: Observable<Effect>;
  11689. /** @hidden */
  11690. _bonesComputationForcedToCPU: boolean;
  11691. private static _uniqueIdSeed;
  11692. private _engine;
  11693. private _uniformBuffersNames;
  11694. private _uniformsNames;
  11695. private _samplers;
  11696. private _isReady;
  11697. private _compilationError;
  11698. private _attributesNames;
  11699. private _attributes;
  11700. private _uniforms;
  11701. /**
  11702. * Key for the effect.
  11703. */
  11704. _key: string;
  11705. private _indexParameters;
  11706. private _fallbacks;
  11707. private _vertexSourceCode;
  11708. private _fragmentSourceCode;
  11709. private _vertexSourceCodeOverride;
  11710. private _fragmentSourceCodeOverride;
  11711. private _transformFeedbackVaryings;
  11712. /**
  11713. * Compiled shader to webGL program.
  11714. */
  11715. _program: WebGLProgram;
  11716. private _valueCache;
  11717. private static _baseCache;
  11718. /**
  11719. * Instantiates an effect.
  11720. * An effect can be used to create/manage/execute vertex and fragment shaders.
  11721. * @param baseName Name of the effect.
  11722. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  11723. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  11724. * @param samplers List of sampler variables that will be passed to the shader.
  11725. * @param engine Engine to be used to render the effect
  11726. * @param defines Define statements to be added to the shader.
  11727. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  11728. * @param onCompiled Callback that will be called when the shader is compiled.
  11729. * @param onError Callback that will be called if an error occurs during shader compilation.
  11730. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11731. */
  11732. 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);
  11733. /**
  11734. * Unique key for this effect
  11735. */
  11736. readonly key: string;
  11737. /**
  11738. * If the effect has been compiled and prepared.
  11739. * @returns if the effect is compiled and prepared.
  11740. */
  11741. isReady(): boolean;
  11742. /**
  11743. * The engine the effect was initialized with.
  11744. * @returns the engine.
  11745. */
  11746. getEngine(): Engine;
  11747. /**
  11748. * The compiled webGL program for the effect
  11749. * @returns the webGL program.
  11750. */
  11751. getProgram(): WebGLProgram;
  11752. /**
  11753. * The set of names of attribute variables for the shader.
  11754. * @returns An array of attribute names.
  11755. */
  11756. getAttributesNames(): string[];
  11757. /**
  11758. * Returns the attribute at the given index.
  11759. * @param index The index of the attribute.
  11760. * @returns The location of the attribute.
  11761. */
  11762. getAttributeLocation(index: number): number;
  11763. /**
  11764. * Returns the attribute based on the name of the variable.
  11765. * @param name of the attribute to look up.
  11766. * @returns the attribute location.
  11767. */
  11768. getAttributeLocationByName(name: string): number;
  11769. /**
  11770. * The number of attributes.
  11771. * @returns the numnber of attributes.
  11772. */
  11773. getAttributesCount(): number;
  11774. /**
  11775. * Gets the index of a uniform variable.
  11776. * @param uniformName of the uniform to look up.
  11777. * @returns the index.
  11778. */
  11779. getUniformIndex(uniformName: string): number;
  11780. /**
  11781. * Returns the attribute based on the name of the variable.
  11782. * @param uniformName of the uniform to look up.
  11783. * @returns the location of the uniform.
  11784. */
  11785. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  11786. /**
  11787. * Returns an array of sampler variable names
  11788. * @returns The array of sampler variable neames.
  11789. */
  11790. getSamplers(): string[];
  11791. /**
  11792. * The error from the last compilation.
  11793. * @returns the error string.
  11794. */
  11795. getCompilationError(): string;
  11796. /**
  11797. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  11798. * @param func The callback to be used.
  11799. */
  11800. executeWhenCompiled(func: (effect: Effect) => void): void;
  11801. /** @hidden */
  11802. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  11803. /** @hidden */
  11804. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  11805. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  11806. private _processShaderConversion(sourceCode, isFragment, callback);
  11807. private _processIncludes(sourceCode, callback);
  11808. private _processPrecision(source);
  11809. /**
  11810. * Recompiles the webGL program
  11811. * @param vertexSourceCode The source code for the vertex shader.
  11812. * @param fragmentSourceCode The source code for the fragment shader.
  11813. * @param onCompiled Callback called when completed.
  11814. * @param onError Callback called on error.
  11815. */
  11816. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  11817. /**
  11818. * Gets the uniform locations of the the specified variable names
  11819. * @param names THe names of the variables to lookup.
  11820. * @returns Array of locations in the same order as variable names.
  11821. */
  11822. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  11823. /**
  11824. * Prepares the effect
  11825. */
  11826. _prepareEffect(): void;
  11827. /**
  11828. * Checks if the effect is supported. (Must be called after compilation)
  11829. */
  11830. readonly isSupported: boolean;
  11831. /**
  11832. * Binds a texture to the engine to be used as output of the shader.
  11833. * @param channel Name of the output variable.
  11834. * @param texture Texture to bind.
  11835. */
  11836. _bindTexture(channel: string, texture: InternalTexture): void;
  11837. /**
  11838. * Sets a texture on the engine to be used in the shader.
  11839. * @param channel Name of the sampler variable.
  11840. * @param texture Texture to set.
  11841. */
  11842. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  11843. /**
  11844. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  11845. * @param channel Name of the sampler variable.
  11846. * @param texture Texture to set.
  11847. */
  11848. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  11849. /**
  11850. * Sets an array of textures on the engine to be used in the shader.
  11851. * @param channel Name of the variable.
  11852. * @param textures Textures to set.
  11853. */
  11854. setTextureArray(channel: string, textures: BaseTexture[]): void;
  11855. /**
  11856. * 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)
  11857. * @param channel Name of the sampler variable.
  11858. * @param postProcess Post process to get the input texture from.
  11859. */
  11860. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  11861. /**
  11862. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  11863. * 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)
  11864. * @param channel Name of the sampler variable.
  11865. * @param postProcess Post process to get the output texture from.
  11866. */
  11867. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  11868. /** @hidden */
  11869. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  11870. /** @hidden */
  11871. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  11872. /** @hidden */
  11873. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  11874. /** @hidden */
  11875. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  11876. /**
  11877. * Binds a buffer to a uniform.
  11878. * @param buffer Buffer to bind.
  11879. * @param name Name of the uniform variable to bind to.
  11880. */
  11881. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  11882. /**
  11883. * Binds block to a uniform.
  11884. * @param blockName Name of the block to bind.
  11885. * @param index Index to bind.
  11886. */
  11887. bindUniformBlock(blockName: string, index: number): void;
  11888. /**
  11889. * Sets an interger value on a uniform variable.
  11890. * @param uniformName Name of the variable.
  11891. * @param value Value to be set.
  11892. * @returns this effect.
  11893. */
  11894. setInt(uniformName: string, value: number): Effect;
  11895. /**
  11896. * Sets an int array on a uniform variable.
  11897. * @param uniformName Name of the variable.
  11898. * @param array array to be set.
  11899. * @returns this effect.
  11900. */
  11901. setIntArray(uniformName: string, array: Int32Array): Effect;
  11902. /**
  11903. * 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)
  11904. * @param uniformName Name of the variable.
  11905. * @param array array to be set.
  11906. * @returns this effect.
  11907. */
  11908. setIntArray2(uniformName: string, array: Int32Array): Effect;
  11909. /**
  11910. * 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)
  11911. * @param uniformName Name of the variable.
  11912. * @param array array to be set.
  11913. * @returns this effect.
  11914. */
  11915. setIntArray3(uniformName: string, array: Int32Array): Effect;
  11916. /**
  11917. * 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)
  11918. * @param uniformName Name of the variable.
  11919. * @param array array to be set.
  11920. * @returns this effect.
  11921. */
  11922. setIntArray4(uniformName: string, array: Int32Array): Effect;
  11923. /**
  11924. * Sets an float array on a uniform variable.
  11925. * @param uniformName Name of the variable.
  11926. * @param array array to be set.
  11927. * @returns this effect.
  11928. */
  11929. setFloatArray(uniformName: string, array: Float32Array): Effect;
  11930. /**
  11931. * 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)
  11932. * @param uniformName Name of the variable.
  11933. * @param array array to be set.
  11934. * @returns this effect.
  11935. */
  11936. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  11937. /**
  11938. * 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)
  11939. * @param uniformName Name of the variable.
  11940. * @param array array to be set.
  11941. * @returns this effect.
  11942. */
  11943. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  11944. /**
  11945. * 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)
  11946. * @param uniformName Name of the variable.
  11947. * @param array array to be set.
  11948. * @returns this effect.
  11949. */
  11950. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  11951. /**
  11952. * Sets an array on a uniform variable.
  11953. * @param uniformName Name of the variable.
  11954. * @param array array to be set.
  11955. * @returns this effect.
  11956. */
  11957. setArray(uniformName: string, array: number[]): Effect;
  11958. /**
  11959. * 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)
  11960. * @param uniformName Name of the variable.
  11961. * @param array array to be set.
  11962. * @returns this effect.
  11963. */
  11964. setArray2(uniformName: string, array: number[]): Effect;
  11965. /**
  11966. * 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)
  11967. * @param uniformName Name of the variable.
  11968. * @param array array to be set.
  11969. * @returns this effect.
  11970. */
  11971. setArray3(uniformName: string, array: number[]): Effect;
  11972. /**
  11973. * 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)
  11974. * @param uniformName Name of the variable.
  11975. * @param array array to be set.
  11976. * @returns this effect.
  11977. */
  11978. setArray4(uniformName: string, array: number[]): Effect;
  11979. /**
  11980. * Sets matrices on a uniform variable.
  11981. * @param uniformName Name of the variable.
  11982. * @param matrices matrices to be set.
  11983. * @returns this effect.
  11984. */
  11985. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  11986. /**
  11987. * Sets matrix on a uniform variable.
  11988. * @param uniformName Name of the variable.
  11989. * @param matrix matrix to be set.
  11990. * @returns this effect.
  11991. */
  11992. setMatrix(uniformName: string, matrix: Matrix): Effect;
  11993. /**
  11994. * 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)
  11995. * @param uniformName Name of the variable.
  11996. * @param matrix matrix to be set.
  11997. * @returns this effect.
  11998. */
  11999. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12000. /**
  12001. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12002. * @param uniformName Name of the variable.
  12003. * @param matrix matrix to be set.
  12004. * @returns this effect.
  12005. */
  12006. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12007. /**
  12008. * Sets a float on a uniform variable.
  12009. * @param uniformName Name of the variable.
  12010. * @param value value to be set.
  12011. * @returns this effect.
  12012. */
  12013. setFloat(uniformName: string, value: number): Effect;
  12014. /**
  12015. * Sets a boolean on a uniform variable.
  12016. * @param uniformName Name of the variable.
  12017. * @param bool value to be set.
  12018. * @returns this effect.
  12019. */
  12020. setBool(uniformName: string, bool: boolean): Effect;
  12021. /**
  12022. * Sets a Vector2 on a uniform variable.
  12023. * @param uniformName Name of the variable.
  12024. * @param vector2 vector2 to be set.
  12025. * @returns this effect.
  12026. */
  12027. setVector2(uniformName: string, vector2: Vector2): Effect;
  12028. /**
  12029. * Sets a float2 on a uniform variable.
  12030. * @param uniformName Name of the variable.
  12031. * @param x First float in float2.
  12032. * @param y Second float in float2.
  12033. * @returns this effect.
  12034. */
  12035. setFloat2(uniformName: string, x: number, y: number): Effect;
  12036. /**
  12037. * Sets a Vector3 on a uniform variable.
  12038. * @param uniformName Name of the variable.
  12039. * @param vector3 Value to be set.
  12040. * @returns this effect.
  12041. */
  12042. setVector3(uniformName: string, vector3: Vector3): Effect;
  12043. /**
  12044. * Sets a float3 on a uniform variable.
  12045. * @param uniformName Name of the variable.
  12046. * @param x First float in float3.
  12047. * @param y Second float in float3.
  12048. * @param z Third float in float3.
  12049. * @returns this effect.
  12050. */
  12051. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12052. /**
  12053. * Sets a Vector4 on a uniform variable.
  12054. * @param uniformName Name of the variable.
  12055. * @param vector4 Value to be set.
  12056. * @returns this effect.
  12057. */
  12058. setVector4(uniformName: string, vector4: Vector4): Effect;
  12059. /**
  12060. * Sets a float4 on a uniform variable.
  12061. * @param uniformName Name of the variable.
  12062. * @param x First float in float4.
  12063. * @param y Second float in float4.
  12064. * @param z Third float in float4.
  12065. * @param w Fourth float in float4.
  12066. * @returns this effect.
  12067. */
  12068. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12069. /**
  12070. * Sets a Color3 on a uniform variable.
  12071. * @param uniformName Name of the variable.
  12072. * @param color3 Value to be set.
  12073. * @returns this effect.
  12074. */
  12075. setColor3(uniformName: string, color3: Color3): Effect;
  12076. /**
  12077. * Sets a Color4 on a uniform variable.
  12078. * @param uniformName Name of the variable.
  12079. * @param color3 Value to be set.
  12080. * @param alpha Alpha value to be set.
  12081. * @returns this effect.
  12082. */
  12083. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12084. /**
  12085. * Sets a Color4 on a uniform variable
  12086. * @param uniformName defines the name of the variable
  12087. * @param color4 defines the value to be set
  12088. * @returns this effect.
  12089. */
  12090. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12091. /**
  12092. * Store of each shader (The can be looked up using effect.key)
  12093. */
  12094. static ShadersStore: {
  12095. [key: string]: string;
  12096. };
  12097. /**
  12098. * Store of each included file for a shader (The can be looked up using effect.key)
  12099. */
  12100. static IncludesShadersStore: {
  12101. [key: string]: string;
  12102. };
  12103. /**
  12104. * Resets the cache of effects.
  12105. */
  12106. static ResetCache(): void;
  12107. }
  12108. }
  12109. declare module BABYLON {
  12110. class FresnelParameters {
  12111. private _isEnabled;
  12112. isEnabled: boolean;
  12113. leftColor: Color3;
  12114. rightColor: Color3;
  12115. bias: number;
  12116. power: number;
  12117. clone(): FresnelParameters;
  12118. serialize(): any;
  12119. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12120. }
  12121. }
  12122. declare module BABYLON {
  12123. /**
  12124. * Interface to follow in your material defines to integrate easily the
  12125. * Image proccessing functions.
  12126. * @hidden
  12127. */
  12128. interface IImageProcessingConfigurationDefines {
  12129. IMAGEPROCESSING: boolean;
  12130. VIGNETTE: boolean;
  12131. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12132. VIGNETTEBLENDMODEOPAQUE: boolean;
  12133. TONEMAPPING: boolean;
  12134. CONTRAST: boolean;
  12135. EXPOSURE: boolean;
  12136. COLORCURVES: boolean;
  12137. COLORGRADING: boolean;
  12138. COLORGRADING3D: boolean;
  12139. SAMPLER3DGREENDEPTH: boolean;
  12140. SAMPLER3DBGRMAP: boolean;
  12141. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12142. }
  12143. /**
  12144. * This groups together the common properties used for image processing either in direct forward pass
  12145. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12146. * or not.
  12147. */
  12148. class ImageProcessingConfiguration {
  12149. /**
  12150. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12151. */
  12152. colorCurves: Nullable<ColorCurves>;
  12153. private _colorCurvesEnabled;
  12154. /**
  12155. * Gets wether the color curves effect is enabled.
  12156. */
  12157. /**
  12158. * Sets wether the color curves effect is enabled.
  12159. */
  12160. colorCurvesEnabled: boolean;
  12161. /**
  12162. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12163. */
  12164. colorGradingTexture: Nullable<BaseTexture>;
  12165. private _colorGradingEnabled;
  12166. /**
  12167. * Gets wether the color grading effect is enabled.
  12168. */
  12169. /**
  12170. * Sets wether the color grading effect is enabled.
  12171. */
  12172. colorGradingEnabled: boolean;
  12173. private _colorGradingWithGreenDepth;
  12174. /**
  12175. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12176. */
  12177. /**
  12178. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12179. */
  12180. colorGradingWithGreenDepth: boolean;
  12181. private _colorGradingBGR;
  12182. /**
  12183. * Gets wether the color grading texture contains BGR values.
  12184. */
  12185. /**
  12186. * Sets wether the color grading texture contains BGR values.
  12187. */
  12188. colorGradingBGR: boolean;
  12189. _exposure: number;
  12190. /**
  12191. * Gets the Exposure used in the effect.
  12192. */
  12193. /**
  12194. * Sets the Exposure used in the effect.
  12195. */
  12196. exposure: number;
  12197. private _toneMappingEnabled;
  12198. /**
  12199. * Gets wether the tone mapping effect is enabled.
  12200. */
  12201. /**
  12202. * Sets wether the tone mapping effect is enabled.
  12203. */
  12204. toneMappingEnabled: boolean;
  12205. protected _contrast: number;
  12206. /**
  12207. * Gets the contrast used in the effect.
  12208. */
  12209. /**
  12210. * Sets the contrast used in the effect.
  12211. */
  12212. contrast: number;
  12213. /**
  12214. * Vignette stretch size.
  12215. */
  12216. vignetteStretch: number;
  12217. /**
  12218. * Vignette centre X Offset.
  12219. */
  12220. vignetteCentreX: number;
  12221. /**
  12222. * Vignette centre Y Offset.
  12223. */
  12224. vignetteCentreY: number;
  12225. /**
  12226. * Vignette weight or intensity of the vignette effect.
  12227. */
  12228. vignetteWeight: number;
  12229. /**
  12230. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12231. * if vignetteEnabled is set to true.
  12232. */
  12233. vignetteColor: Color4;
  12234. /**
  12235. * Camera field of view used by the Vignette effect.
  12236. */
  12237. vignetteCameraFov: number;
  12238. private _vignetteBlendMode;
  12239. /**
  12240. * Gets the vignette blend mode allowing different kind of effect.
  12241. */
  12242. /**
  12243. * Sets the vignette blend mode allowing different kind of effect.
  12244. */
  12245. vignetteBlendMode: number;
  12246. private _vignetteEnabled;
  12247. /**
  12248. * Gets wether the vignette effect is enabled.
  12249. */
  12250. /**
  12251. * Sets wether the vignette effect is enabled.
  12252. */
  12253. vignetteEnabled: boolean;
  12254. private _applyByPostProcess;
  12255. /**
  12256. * Gets wether the image processing is applied through a post process or not.
  12257. */
  12258. /**
  12259. * Sets wether the image processing is applied through a post process or not.
  12260. */
  12261. applyByPostProcess: boolean;
  12262. private _isEnabled;
  12263. /**
  12264. * Gets wether the image processing is enabled or not.
  12265. */
  12266. /**
  12267. * Sets wether the image processing is enabled or not.
  12268. */
  12269. isEnabled: boolean;
  12270. /**
  12271. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12272. */
  12273. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12274. /**
  12275. * Method called each time the image processing information changes requires to recompile the effect.
  12276. */
  12277. protected _updateParameters(): void;
  12278. getClassName(): string;
  12279. /**
  12280. * Prepare the list of uniforms associated with the Image Processing effects.
  12281. * @param uniformsList The list of uniforms used in the effect
  12282. * @param defines the list of defines currently in use
  12283. */
  12284. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12285. /**
  12286. * Prepare the list of samplers associated with the Image Processing effects.
  12287. * @param uniformsList The list of uniforms used in the effect
  12288. * @param defines the list of defines currently in use
  12289. */
  12290. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12291. /**
  12292. * Prepare the list of defines associated to the shader.
  12293. * @param defines the list of defines to complete
  12294. */
  12295. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12296. /**
  12297. * Returns true if all the image processing information are ready.
  12298. */
  12299. isReady(): boolean;
  12300. /**
  12301. * Binds the image processing to the shader.
  12302. * @param effect The effect to bind to
  12303. */
  12304. bind(effect: Effect, aspectRatio?: number): void;
  12305. /**
  12306. * Clones the current image processing instance.
  12307. * @return The cloned image processing
  12308. */
  12309. clone(): ImageProcessingConfiguration;
  12310. /**
  12311. * Serializes the current image processing instance to a json representation.
  12312. * @return a JSON representation
  12313. */
  12314. serialize(): any;
  12315. /**
  12316. * Parses the image processing from a json representation.
  12317. * @param source the JSON source to parse
  12318. * @return The parsed image processing
  12319. */
  12320. static Parse(source: any): ImageProcessingConfiguration;
  12321. private static _VIGNETTEMODE_MULTIPLY;
  12322. private static _VIGNETTEMODE_OPAQUE;
  12323. /**
  12324. * Used to apply the vignette as a mix with the pixel color.
  12325. */
  12326. static readonly VIGNETTEMODE_MULTIPLY: number;
  12327. /**
  12328. * Used to apply the vignette as a replacement of the pixel color.
  12329. */
  12330. static readonly VIGNETTEMODE_OPAQUE: number;
  12331. }
  12332. }
  12333. declare module BABYLON {
  12334. /**
  12335. * Manages the defines for the Material
  12336. */
  12337. class MaterialDefines {
  12338. private _keys;
  12339. private _isDirty;
  12340. /** @hidden */
  12341. _renderId: number;
  12342. /** @hidden */
  12343. _areLightsDirty: boolean;
  12344. /** @hidden */
  12345. _areAttributesDirty: boolean;
  12346. /** @hidden */
  12347. _areTexturesDirty: boolean;
  12348. /** @hidden */
  12349. _areFresnelDirty: boolean;
  12350. /** @hidden */
  12351. _areMiscDirty: boolean;
  12352. /** @hidden */
  12353. _areImageProcessingDirty: boolean;
  12354. /** @hidden */
  12355. _normals: boolean;
  12356. /** @hidden */
  12357. _uvs: boolean;
  12358. /** @hidden */
  12359. _needNormals: boolean;
  12360. /** @hidden */
  12361. _needUVs: boolean;
  12362. /**
  12363. * Specifies if the material needs to be re-calculated
  12364. */
  12365. readonly isDirty: boolean;
  12366. /**
  12367. * Marks the material to indicate that it has been re-calculated
  12368. */
  12369. markAsProcessed(): void;
  12370. /**
  12371. * Marks the material to indicate that it needs to be re-calculated
  12372. */
  12373. markAsUnprocessed(): void;
  12374. /**
  12375. * Marks the material to indicate all of its defines need to be re-calculated
  12376. */
  12377. markAllAsDirty(): void;
  12378. /**
  12379. * Marks the material to indicate that image processing needs to be re-calculated
  12380. */
  12381. markAsImageProcessingDirty(): void;
  12382. /**
  12383. * Marks the material to indicate the lights need to be re-calculated
  12384. */
  12385. markAsLightDirty(): void;
  12386. /**
  12387. * Marks the attribute state as changed
  12388. */
  12389. markAsAttributesDirty(): void;
  12390. /**
  12391. * Marks the texture state as changed
  12392. */
  12393. markAsTexturesDirty(): void;
  12394. /**
  12395. * Marks the fresnel state as changed
  12396. */
  12397. markAsFresnelDirty(): void;
  12398. /**
  12399. * Marks the misc state as changed
  12400. */
  12401. markAsMiscDirty(): void;
  12402. /**
  12403. * Rebuilds the material defines
  12404. */
  12405. rebuild(): void;
  12406. /**
  12407. * Specifies if two material defines are equal
  12408. * @param other - A material define instance to compare to
  12409. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  12410. */
  12411. isEqual(other: MaterialDefines): boolean;
  12412. /**
  12413. * Clones this instance's defines to another instance
  12414. * @param other - material defines to clone values to
  12415. */
  12416. cloneTo(other: MaterialDefines): void;
  12417. /**
  12418. * Resets the material define values
  12419. */
  12420. reset(): void;
  12421. /**
  12422. * Converts the material define values to a string
  12423. * @returns - String of material define information
  12424. */
  12425. toString(): string;
  12426. }
  12427. /**
  12428. * Base class for the main features of a material in Babylon.js
  12429. */
  12430. class Material implements IAnimatable {
  12431. private static _TriangleFillMode;
  12432. private static _WireFrameFillMode;
  12433. private static _PointFillMode;
  12434. private static _PointListDrawMode;
  12435. private static _LineListDrawMode;
  12436. private static _LineLoopDrawMode;
  12437. private static _LineStripDrawMode;
  12438. private static _TriangleStripDrawMode;
  12439. private static _TriangleFanDrawMode;
  12440. /**
  12441. * Returns the triangle fill mode
  12442. */
  12443. static readonly TriangleFillMode: number;
  12444. /**
  12445. * Returns the wireframe mode
  12446. */
  12447. static readonly WireFrameFillMode: number;
  12448. /**
  12449. * Returns the point fill mode
  12450. */
  12451. static readonly PointFillMode: number;
  12452. /**
  12453. * Returns the point list draw mode
  12454. */
  12455. static readonly PointListDrawMode: number;
  12456. /**
  12457. * Returns the line list draw mode
  12458. */
  12459. static readonly LineListDrawMode: number;
  12460. /**
  12461. * Returns the line loop draw mode
  12462. */
  12463. static readonly LineLoopDrawMode: number;
  12464. /**
  12465. * Returns the line strip draw mode
  12466. */
  12467. static readonly LineStripDrawMode: number;
  12468. /**
  12469. * Returns the triangle strip draw mode
  12470. */
  12471. static readonly TriangleStripDrawMode: number;
  12472. /**
  12473. * Returns the triangle fan draw mode
  12474. */
  12475. static readonly TriangleFanDrawMode: number;
  12476. /**
  12477. * Stores the clock-wise side orientation
  12478. */
  12479. private static _ClockWiseSideOrientation;
  12480. /**
  12481. * Stores the counter clock-wise side orientation
  12482. */
  12483. private static _CounterClockWiseSideOrientation;
  12484. /**
  12485. * Returns the clock-wise side orientation
  12486. */
  12487. static readonly ClockWiseSideOrientation: number;
  12488. /**
  12489. * Returns the counter clock-wise side orientation
  12490. */
  12491. static readonly CounterClockWiseSideOrientation: number;
  12492. /**
  12493. * The dirty texture flag value
  12494. */
  12495. private static _TextureDirtyFlag;
  12496. /**
  12497. * The dirty light flag value
  12498. */
  12499. private static _LightDirtyFlag;
  12500. /**
  12501. * The dirty fresnel flag value
  12502. */
  12503. private static _FresnelDirtyFlag;
  12504. /**
  12505. * The dirty attribute flag value
  12506. */
  12507. private static _AttributesDirtyFlag;
  12508. /**
  12509. * The dirty misc flag value
  12510. */
  12511. private static _MiscDirtyFlag;
  12512. /**
  12513. * Returns the dirty texture flag value
  12514. */
  12515. static readonly TextureDirtyFlag: number;
  12516. /**
  12517. * Returns the dirty light flag value
  12518. */
  12519. static readonly LightDirtyFlag: number;
  12520. /**
  12521. * Returns the dirty fresnel flag value
  12522. */
  12523. static readonly FresnelDirtyFlag: number;
  12524. /**
  12525. * Returns the dirty attributes flag value
  12526. */
  12527. static readonly AttributesDirtyFlag: number;
  12528. /**
  12529. * Returns the dirty misc flag value
  12530. */
  12531. static readonly MiscDirtyFlag: number;
  12532. /**
  12533. * The ID of the material
  12534. */
  12535. id: string;
  12536. /**
  12537. * Gets or sets the unique id of the material
  12538. */
  12539. uniqueId: number;
  12540. /**
  12541. * The name of the material
  12542. */
  12543. name: string;
  12544. /**
  12545. * Specifies if the ready state should be checked on each call
  12546. */
  12547. checkReadyOnEveryCall: boolean;
  12548. /**
  12549. * Specifies if the ready state should be checked once
  12550. */
  12551. checkReadyOnlyOnce: boolean;
  12552. /**
  12553. * The state of the material
  12554. */
  12555. state: string;
  12556. /**
  12557. * The alpha value of the material
  12558. */
  12559. protected _alpha: number;
  12560. /**
  12561. * Gets the alpha value of the material
  12562. */
  12563. /**
  12564. * Sets the alpha value of the material
  12565. */
  12566. alpha: number;
  12567. /**
  12568. * Specifies if back face culling is enabled
  12569. */
  12570. protected _backFaceCulling: boolean;
  12571. /**
  12572. * Gets the back-face culling state
  12573. */
  12574. /**
  12575. * Sets the back-face culling state
  12576. */
  12577. backFaceCulling: boolean;
  12578. /**
  12579. * Stores the value for side orientation
  12580. */
  12581. sideOrientation: number;
  12582. /**
  12583. * Callback triggered when the material is compiled
  12584. */
  12585. onCompiled: (effect: Effect) => void;
  12586. /**
  12587. * Callback triggered when an error occurs
  12588. */
  12589. onError: (effect: Effect, errors: string) => void;
  12590. /**
  12591. * Callback triggered to get the render target textures
  12592. */
  12593. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  12594. /**
  12595. * Specifies if the material should be serialized
  12596. */
  12597. doNotSerialize: boolean;
  12598. /**
  12599. * Specifies if the effect should be stored on sub meshes
  12600. */
  12601. storeEffectOnSubMeshes: boolean;
  12602. /**
  12603. * Stores the animations for the material
  12604. */
  12605. animations: Array<Animation>;
  12606. /**
  12607. * An event triggered when the material is disposed
  12608. */
  12609. onDisposeObservable: Observable<Material>;
  12610. /**
  12611. * An observer which watches for dispose events
  12612. */
  12613. private _onDisposeObserver;
  12614. /**
  12615. * Called during a dispose event
  12616. */
  12617. onDispose: () => void;
  12618. /**
  12619. * An event triggered when the material is bound
  12620. */
  12621. onBindObservable: Observable<AbstractMesh>;
  12622. /**
  12623. * An observer which watches for bind events
  12624. */
  12625. private _onBindObserver;
  12626. /**
  12627. * Called during a bind event
  12628. */
  12629. onBind: (Mesh: AbstractMesh) => void;
  12630. /**
  12631. * An event triggered when the material is unbound
  12632. */
  12633. onUnBindObservable: Observable<Material>;
  12634. /**
  12635. * Stores the value of the alpha mode
  12636. */
  12637. private _alphaMode;
  12638. /**
  12639. * Gets the value of the alpha mode
  12640. */
  12641. /**
  12642. * Sets the value of the alpha mode.
  12643. *
  12644. * | Value | Type | Description |
  12645. * | --- | --- | --- |
  12646. * | 0 | ALPHA_DISABLE | |
  12647. * | 1 | ALPHA_ADD | |
  12648. * | 2 | ALPHA_COMBINE | |
  12649. * | 3 | ALPHA_SUBTRACT | |
  12650. * | 4 | ALPHA_MULTIPLY | |
  12651. * | 5 | ALPHA_MAXIMIZED | |
  12652. * | 6 | ALPHA_ONEONE | |
  12653. * | 7 | ALPHA_PREMULTIPLIED | |
  12654. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  12655. * | 9 | ALPHA_INTERPOLATE | |
  12656. * | 10 | ALPHA_SCREENMODE | |
  12657. *
  12658. */
  12659. alphaMode: number;
  12660. /**
  12661. * Stores the state of the need depth pre-pass value
  12662. */
  12663. private _needDepthPrePass;
  12664. /**
  12665. * Gets the depth pre-pass value
  12666. */
  12667. /**
  12668. * Sets the need depth pre-pass value
  12669. */
  12670. needDepthPrePass: boolean;
  12671. /**
  12672. * Specifies if depth writing should be disabled
  12673. */
  12674. disableDepthWrite: boolean;
  12675. /**
  12676. * Specifies if depth writing should be forced
  12677. */
  12678. forceDepthWrite: boolean;
  12679. /**
  12680. * Specifies if there should be a separate pass for culling
  12681. */
  12682. separateCullingPass: boolean;
  12683. /**
  12684. * Stores the state specifing if fog should be enabled
  12685. */
  12686. private _fogEnabled;
  12687. /**
  12688. * Gets the value of the fog enabled state
  12689. */
  12690. /**
  12691. * Sets the state for enabling fog
  12692. */
  12693. fogEnabled: boolean;
  12694. /**
  12695. * Stores the size of points
  12696. */
  12697. pointSize: number;
  12698. /**
  12699. * Stores the z offset value
  12700. */
  12701. zOffset: number;
  12702. /**
  12703. * Gets a value specifying if wireframe mode is enabled
  12704. */
  12705. /**
  12706. * Sets the state of wireframe mode
  12707. */
  12708. wireframe: boolean;
  12709. /**
  12710. * Gets the value specifying if point clouds are enabled
  12711. */
  12712. /**
  12713. * Sets the state of point cloud mode
  12714. */
  12715. pointsCloud: boolean;
  12716. /**
  12717. * Gets the material fill mode
  12718. */
  12719. /**
  12720. * Sets the material fill mode
  12721. */
  12722. fillMode: number;
  12723. /**
  12724. * Stores the effects for the material
  12725. */
  12726. _effect: Nullable<Effect>;
  12727. /**
  12728. * Specifies if the material was previously ready
  12729. */
  12730. _wasPreviouslyReady: boolean;
  12731. /**
  12732. * Specifies if uniform buffers should be used
  12733. */
  12734. private _useUBO;
  12735. /**
  12736. * Stores a reference to the scene
  12737. */
  12738. private _scene;
  12739. /**
  12740. * Stores the fill mode state
  12741. */
  12742. private _fillMode;
  12743. /**
  12744. * Specifies if the depth write state should be cached
  12745. */
  12746. private _cachedDepthWriteState;
  12747. /**
  12748. * Stores the uniform buffer
  12749. */
  12750. protected _uniformBuffer: UniformBuffer;
  12751. /**
  12752. * Creates a material instance
  12753. * @param name defines the name of the material
  12754. * @param scene defines the scene to reference
  12755. * @param doNotAdd specifies if the material should be added to the scene
  12756. */
  12757. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  12758. /**
  12759. * Returns a string representation of the current material
  12760. * @param fullDetails defines a boolean indicating which levels of logging is desired
  12761. * @returns a string with material information
  12762. */
  12763. toString(fullDetails?: boolean): string;
  12764. /**
  12765. * Gets the class name of the material
  12766. * @returns a string with the class name of the material
  12767. */
  12768. getClassName(): string;
  12769. /**
  12770. * Specifies if updates for the material been locked
  12771. */
  12772. readonly isFrozen: boolean;
  12773. /**
  12774. * Locks updates for the material
  12775. */
  12776. freeze(): void;
  12777. /**
  12778. * Unlocks updates for the material
  12779. */
  12780. unfreeze(): void;
  12781. /**
  12782. * Specifies if the material is ready to be used
  12783. * @param mesh defines the mesh to check
  12784. * @param useInstances specifies if instances should be used
  12785. * @returns a boolean indicating if the material is ready to be used
  12786. */
  12787. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12788. /**
  12789. * Specifies that the submesh is ready to be used
  12790. * @param mesh defines the mesh to check
  12791. * @param subMesh defines which submesh to check
  12792. * @param useInstances specifies that instances should be used
  12793. * @returns a boolean indicating that the submesh is ready or not
  12794. */
  12795. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12796. /**
  12797. * Returns the material effect
  12798. * @returns the effect associated with the material
  12799. */
  12800. getEffect(): Nullable<Effect>;
  12801. /**
  12802. * Returns the current scene
  12803. * @returns a Scene
  12804. */
  12805. getScene(): Scene;
  12806. /**
  12807. * Specifies if the material will require alpha blending
  12808. * @returns a boolean specifying if alpha blending is needed
  12809. */
  12810. needAlphaBlending(): boolean;
  12811. /**
  12812. * Specifies if the mesh will require alpha blending
  12813. * @param mesh defines the mesh to check
  12814. * @returns a boolean specifying if alpha blending is needed for the mesh
  12815. */
  12816. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  12817. /**
  12818. * Specifies if this material should be rendered in alpha test mode
  12819. * @returns a boolean specifying if an alpha test is needed.
  12820. */
  12821. needAlphaTesting(): boolean;
  12822. /**
  12823. * Gets the texture used for the alpha test
  12824. * @returns the texture to use for alpha testing
  12825. */
  12826. getAlphaTestTexture(): Nullable<BaseTexture>;
  12827. /**
  12828. * Marks the material to indicate that it needs to be re-calculated
  12829. */
  12830. markDirty(): void;
  12831. /** @hidden */
  12832. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  12833. /**
  12834. * Binds the material to the mesh
  12835. * @param world defines the world transformation matrix
  12836. * @param mesh defines the mesh to bind the material to
  12837. */
  12838. bind(world: Matrix, mesh?: Mesh): void;
  12839. /**
  12840. * Binds the submesh to the material
  12841. * @param world defines the world transformation matrix
  12842. * @param mesh defines the mesh containing the submesh
  12843. * @param subMesh defines the submesh to bind the material to
  12844. */
  12845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12846. /**
  12847. * Binds the world matrix to the material
  12848. * @param world defines the world transformation matrix
  12849. */
  12850. bindOnlyWorldMatrix(world: Matrix): void;
  12851. /**
  12852. * Binds the scene's uniform buffer to the effect.
  12853. * @param effect defines the effect to bind to the scene uniform buffer
  12854. * @param sceneUbo defines the uniform buffer storing scene data
  12855. */
  12856. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  12857. /**
  12858. * Binds the view matrix to the effect
  12859. * @param effect defines the effect to bind the view matrix to
  12860. */
  12861. bindView(effect: Effect): void;
  12862. /**
  12863. * Binds the view projection matrix to the effect
  12864. * @param effect defines the effect to bind the view projection matrix to
  12865. */
  12866. bindViewProjection(effect: Effect): void;
  12867. /**
  12868. * Specifies if material alpha testing should be turned on for the mesh
  12869. * @param mesh defines the mesh to check
  12870. */
  12871. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  12872. /**
  12873. * Processes to execute after binding the material to a mesh
  12874. * @param mesh defines the rendered mesh
  12875. */
  12876. protected _afterBind(mesh?: Mesh): void;
  12877. /**
  12878. * Unbinds the material from the mesh
  12879. */
  12880. unbind(): void;
  12881. /**
  12882. * Gets the active textures from the material
  12883. * @returns an array of textures
  12884. */
  12885. getActiveTextures(): BaseTexture[];
  12886. /**
  12887. * Specifies if the material uses a texture
  12888. * @param texture defines the texture to check against the material
  12889. * @returns a boolean specifying if the material uses the texture
  12890. */
  12891. hasTexture(texture: BaseTexture): boolean;
  12892. /**
  12893. * Makes a duplicate of the material, and gives it a new name
  12894. * @param name defines the new name for the duplicated material
  12895. * @returns the cloned material
  12896. */
  12897. clone(name: string): Nullable<Material>;
  12898. /**
  12899. * Gets the meshes bound to the material
  12900. * @returns an array of meshes bound to the material
  12901. */
  12902. getBindedMeshes(): AbstractMesh[];
  12903. /**
  12904. * Force shader compilation
  12905. * @param mesh defines the mesh associated with this material
  12906. * @param onCompiled defines a function to execute once the material is compiled
  12907. * @param options defines the options to configure the compilation
  12908. */
  12909. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  12910. clipPlane: boolean;
  12911. }>): void;
  12912. /**
  12913. * Force shader compilation
  12914. * @param mesh defines the mesh that will use this material
  12915. * @param options defines additional options for compiling the shaders
  12916. * @returns a promise that resolves when the compilation completes
  12917. */
  12918. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  12919. clipPlane: boolean;
  12920. }>): Promise<void>;
  12921. /**
  12922. * Marks a define in the material to indicate that it needs to be re-computed
  12923. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  12924. */
  12925. markAsDirty(flag: number): void;
  12926. /**
  12927. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  12928. * @param func defines a function which checks material defines against the submeshes
  12929. */
  12930. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  12931. /**
  12932. * Indicates that image processing needs to be re-calculated for all submeshes
  12933. */
  12934. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  12935. /**
  12936. * Indicates that textures need to be re-calculated for all submeshes
  12937. */
  12938. protected _markAllSubMeshesAsTexturesDirty(): void;
  12939. /**
  12940. * Indicates that fresnel needs to be re-calculated for all submeshes
  12941. */
  12942. protected _markAllSubMeshesAsFresnelDirty(): void;
  12943. /**
  12944. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  12945. */
  12946. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  12947. /**
  12948. * Indicates that lights need to be re-calculated for all submeshes
  12949. */
  12950. protected _markAllSubMeshesAsLightsDirty(): void;
  12951. /**
  12952. * Indicates that attributes need to be re-calculated for all submeshes
  12953. */
  12954. protected _markAllSubMeshesAsAttributesDirty(): void;
  12955. /**
  12956. * Indicates that misc needs to be re-calculated for all submeshes
  12957. */
  12958. protected _markAllSubMeshesAsMiscDirty(): void;
  12959. /**
  12960. * Indicates that textures and misc need to be re-calculated for all submeshes
  12961. */
  12962. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  12963. /**
  12964. * Disposes the material
  12965. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12966. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12967. */
  12968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12969. /**
  12970. * Serializes this material
  12971. * @returns the serialized material object
  12972. */
  12973. serialize(): any;
  12974. /**
  12975. * Creates a MultiMaterial from parsed MultiMaterial data.
  12976. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  12977. * @param scene defines the hosting scene
  12978. * @returns a new MultiMaterial
  12979. */
  12980. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  12981. /**
  12982. * Creates a material from parsed material data
  12983. * @param parsedMaterial defines parsed material data
  12984. * @param scene defines the hosting scene
  12985. * @param rootUrl defines the root URL to use to load textures
  12986. * @returns a new material
  12987. */
  12988. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  12989. }
  12990. }
  12991. declare module BABYLON {
  12992. /**
  12993. * "Static Class" containing the most commonly used helper while dealing with material for
  12994. * rendering purpose.
  12995. *
  12996. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  12997. *
  12998. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12999. */
  13000. class MaterialHelper {
  13001. /**
  13002. * Bind the current view position to an effect.
  13003. * @param effect The effect to be bound
  13004. * @param scene The scene the eyes position is used from
  13005. */
  13006. static BindEyePosition(effect: Effect, scene: Scene): void;
  13007. /**
  13008. * Helps preparing the defines values about the UVs in used in the effect.
  13009. * UVs are shared as much as we can accross chanels in the shaders.
  13010. * @param texture The texture we are preparing the UVs for
  13011. * @param defines The defines to update
  13012. * @param key The chanel key "diffuse", "specular"... used in the shader
  13013. */
  13014. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13015. /**
  13016. * Binds a texture matrix value to its corrsponding uniform
  13017. * @param texture The texture to bind the matrix for
  13018. * @param uniformBuffer The uniform buffer receivin the data
  13019. * @param key The chanel key "diffuse", "specular"... used in the shader
  13020. */
  13021. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13022. /**
  13023. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13024. * @param mesh defines the current mesh
  13025. * @param scene defines the current scene
  13026. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13027. * @param pointsCloud defines if point cloud rendering has to be turned on
  13028. * @param fogEnabled defines if fog has to be turned on
  13029. * @param alphaTest defines if alpha testing has to be turned on
  13030. * @param defines defines the current list of defines
  13031. */
  13032. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13033. /**
  13034. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13035. * @param scene defines the current scene
  13036. * @param engine defines the current engine
  13037. * @param defines specifies the list of active defines
  13038. * @param useInstances defines if instances have to be turned on
  13039. * @param useClipPlane defines if clip plane have to be turned on
  13040. */
  13041. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13042. /**
  13043. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13044. * @param mesh The mesh containing the geometry data we will draw
  13045. * @param defines The defines to update
  13046. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13047. * @param useBones Precise whether bones should be used or not (override mesh info)
  13048. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13049. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13050. * @returns false if defines are considered not dirty and have not been checked
  13051. */
  13052. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13053. /**
  13054. * Prepares the defines related to the light information passed in parameter
  13055. * @param scene The scene we are intending to draw
  13056. * @param mesh The mesh the effect is compiling for
  13057. * @param defines The defines to update
  13058. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13059. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13060. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13061. * @returns true if normals will be required for the rest of the effect
  13062. */
  13063. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13064. /**
  13065. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13066. * that won t be acctive due to defines being turned off.
  13067. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13068. * @param samplersList The samplers list
  13069. * @param defines The defines helping in the list generation
  13070. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13071. */
  13072. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13073. /**
  13074. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13075. * @param defines The defines to update while falling back
  13076. * @param fallbacks The authorized effect fallbacks
  13077. * @param maxSimultaneousLights The maximum number of lights allowed
  13078. * @param rank the current rank of the Effect
  13079. * @returns The newly affected rank
  13080. */
  13081. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13082. /**
  13083. * Prepares the list of attributes required for morph targets according to the effect defines.
  13084. * @param attribs The current list of supported attribs
  13085. * @param mesh The mesh to prepare the morph targets attributes for
  13086. * @param defines The current Defines of the effect
  13087. */
  13088. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13089. /**
  13090. * Prepares the list of attributes required for bones according to the effect defines.
  13091. * @param attribs The current list of supported attribs
  13092. * @param mesh The mesh to prepare the bones attributes for
  13093. * @param defines The current Defines of the effect
  13094. * @param fallbacks The current efffect fallback strategy
  13095. */
  13096. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13097. /**
  13098. * Prepares the list of attributes required for instances according to the effect defines.
  13099. * @param attribs The current list of supported attribs
  13100. * @param defines The current Defines of the effect
  13101. */
  13102. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13103. /**
  13104. * Binds the light shadow information to the effect for the given mesh.
  13105. * @param light The light containing the generator
  13106. * @param scene The scene the lights belongs to
  13107. * @param mesh The mesh we are binding the information to render
  13108. * @param lightIndex The light index in the effect used to render the mesh
  13109. * @param effect The effect we are binding the data to
  13110. */
  13111. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13112. /**
  13113. * Binds the light information to the effect.
  13114. * @param light The light containing the generator
  13115. * @param effect The effect we are binding the data to
  13116. * @param lightIndex The light index in the effect used to render
  13117. */
  13118. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13119. /**
  13120. * Binds the lights information from the scene to the effect for the given mesh.
  13121. * @param scene The scene the lights belongs to
  13122. * @param mesh The mesh we are binding the information to render
  13123. * @param effect The effect we are binding the data to
  13124. * @param defines The generated defines for the effect
  13125. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13126. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13127. */
  13128. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13129. /**
  13130. * Binds the fog information from the scene to the effect for the given mesh.
  13131. * @param scene The scene the lights belongs to
  13132. * @param mesh The mesh we are binding the information to render
  13133. * @param effect The effect we are binding the data to
  13134. */
  13135. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13136. /**
  13137. * Binds the bones information from the mesh to the effect.
  13138. * @param mesh The mesh we are binding the information to render
  13139. * @param effect The effect we are binding the data to
  13140. */
  13141. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13142. /**
  13143. * Binds the morph targets information from the mesh to the effect.
  13144. * @param abstractMesh The mesh we are binding the information to render
  13145. * @param effect The effect we are binding the data to
  13146. */
  13147. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13148. /**
  13149. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13150. * @param defines The generated defines used in the effect
  13151. * @param effect The effect we are binding the data to
  13152. * @param scene The scene we are willing to render with logarithmic scale for
  13153. */
  13154. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13155. /**
  13156. * Binds the clip plane information from the scene to the effect.
  13157. * @param scene The scene the clip plane information are extracted from
  13158. * @param effect The effect we are binding the data to
  13159. */
  13160. static BindClipPlane(effect: Effect, scene: Scene): void;
  13161. }
  13162. }
  13163. declare module BABYLON {
  13164. class MultiMaterial extends Material {
  13165. private _subMaterials;
  13166. subMaterials: Nullable<Material>[];
  13167. constructor(name: string, scene: Scene);
  13168. private _hookArray(array);
  13169. getSubMaterial(index: number): Nullable<Material>;
  13170. getActiveTextures(): BaseTexture[];
  13171. getClassName(): string;
  13172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13173. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13174. serialize(): any;
  13175. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13176. }
  13177. }
  13178. declare module BABYLON {
  13179. class PushMaterial extends Material {
  13180. protected _activeEffect: Effect;
  13181. protected _normalMatrix: Matrix;
  13182. constructor(name: string, scene: Scene);
  13183. getEffect(): Effect;
  13184. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13185. /**
  13186. * Binds the given world matrix to the active effect
  13187. *
  13188. * @param world the matrix to bind
  13189. */
  13190. bindOnlyWorldMatrix(world: Matrix): void;
  13191. /**
  13192. * Binds the given normal matrix to the active effect
  13193. *
  13194. * @param normalMatrix the matrix to bind
  13195. */
  13196. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13197. bind(world: Matrix, mesh?: Mesh): void;
  13198. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13199. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13200. }
  13201. }
  13202. declare module BABYLON {
  13203. class ShaderMaterial extends Material {
  13204. private _shaderPath;
  13205. private _options;
  13206. private _textures;
  13207. private _textureArrays;
  13208. private _floats;
  13209. private _ints;
  13210. private _floatsArrays;
  13211. private _colors3;
  13212. private _colors3Arrays;
  13213. private _colors4;
  13214. private _vectors2;
  13215. private _vectors3;
  13216. private _vectors4;
  13217. private _matrices;
  13218. private _matrices3x3;
  13219. private _matrices2x2;
  13220. private _vectors2Arrays;
  13221. private _vectors3Arrays;
  13222. private _cachedWorldViewMatrix;
  13223. private _renderId;
  13224. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13225. getClassName(): string;
  13226. needAlphaBlending(): boolean;
  13227. needAlphaTesting(): boolean;
  13228. private _checkUniform(uniformName);
  13229. setTexture(name: string, texture: Texture): ShaderMaterial;
  13230. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13231. setFloat(name: string, value: number): ShaderMaterial;
  13232. setInt(name: string, value: number): ShaderMaterial;
  13233. setFloats(name: string, value: number[]): ShaderMaterial;
  13234. setColor3(name: string, value: Color3): ShaderMaterial;
  13235. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13236. setColor4(name: string, value: Color4): ShaderMaterial;
  13237. setVector2(name: string, value: Vector2): ShaderMaterial;
  13238. setVector3(name: string, value: Vector3): ShaderMaterial;
  13239. setVector4(name: string, value: Vector4): ShaderMaterial;
  13240. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13241. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13242. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13243. setArray2(name: string, value: number[]): ShaderMaterial;
  13244. setArray3(name: string, value: number[]): ShaderMaterial;
  13245. private _checkCache(scene, mesh?, useInstances?);
  13246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13247. bindOnlyWorldMatrix(world: Matrix): void;
  13248. bind(world: Matrix, mesh?: Mesh): void;
  13249. getActiveTextures(): BaseTexture[];
  13250. hasTexture(texture: BaseTexture): boolean;
  13251. clone(name: string): ShaderMaterial;
  13252. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13253. serialize(): any;
  13254. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13255. }
  13256. }
  13257. declare module BABYLON {
  13258. /** @hidden */
  13259. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13260. MAINUV1: boolean;
  13261. MAINUV2: boolean;
  13262. DIFFUSE: boolean;
  13263. DIFFUSEDIRECTUV: number;
  13264. AMBIENT: boolean;
  13265. AMBIENTDIRECTUV: number;
  13266. OPACITY: boolean;
  13267. OPACITYDIRECTUV: number;
  13268. OPACITYRGB: boolean;
  13269. REFLECTION: boolean;
  13270. EMISSIVE: boolean;
  13271. EMISSIVEDIRECTUV: number;
  13272. SPECULAR: boolean;
  13273. SPECULARDIRECTUV: number;
  13274. BUMP: boolean;
  13275. BUMPDIRECTUV: number;
  13276. PARALLAX: boolean;
  13277. PARALLAXOCCLUSION: boolean;
  13278. SPECULAROVERALPHA: boolean;
  13279. CLIPPLANE: boolean;
  13280. ALPHATEST: boolean;
  13281. DEPTHPREPASS: boolean;
  13282. ALPHAFROMDIFFUSE: boolean;
  13283. POINTSIZE: boolean;
  13284. FOG: boolean;
  13285. SPECULARTERM: boolean;
  13286. DIFFUSEFRESNEL: boolean;
  13287. OPACITYFRESNEL: boolean;
  13288. REFLECTIONFRESNEL: boolean;
  13289. REFRACTIONFRESNEL: boolean;
  13290. EMISSIVEFRESNEL: boolean;
  13291. FRESNEL: boolean;
  13292. NORMAL: boolean;
  13293. UV1: boolean;
  13294. UV2: boolean;
  13295. VERTEXCOLOR: boolean;
  13296. VERTEXALPHA: boolean;
  13297. NUM_BONE_INFLUENCERS: number;
  13298. BonesPerMesh: number;
  13299. INSTANCES: boolean;
  13300. GLOSSINESS: boolean;
  13301. ROUGHNESS: boolean;
  13302. EMISSIVEASILLUMINATION: boolean;
  13303. LINKEMISSIVEWITHDIFFUSE: boolean;
  13304. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13305. LIGHTMAP: boolean;
  13306. LIGHTMAPDIRECTUV: number;
  13307. OBJECTSPACE_NORMALMAP: boolean;
  13308. USELIGHTMAPASSHADOWMAP: boolean;
  13309. REFLECTIONMAP_3D: boolean;
  13310. REFLECTIONMAP_SPHERICAL: boolean;
  13311. REFLECTIONMAP_PLANAR: boolean;
  13312. REFLECTIONMAP_CUBIC: boolean;
  13313. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13314. REFLECTIONMAP_PROJECTION: boolean;
  13315. REFLECTIONMAP_SKYBOX: boolean;
  13316. REFLECTIONMAP_EXPLICIT: boolean;
  13317. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13318. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13319. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13320. INVERTCUBICMAP: boolean;
  13321. LOGARITHMICDEPTH: boolean;
  13322. REFRACTION: boolean;
  13323. REFRACTIONMAP_3D: boolean;
  13324. REFLECTIONOVERALPHA: boolean;
  13325. TWOSIDEDLIGHTING: boolean;
  13326. SHADOWFLOAT: boolean;
  13327. MORPHTARGETS: boolean;
  13328. MORPHTARGETS_NORMAL: boolean;
  13329. MORPHTARGETS_TANGENT: boolean;
  13330. NUM_MORPH_INFLUENCERS: number;
  13331. NONUNIFORMSCALING: boolean;
  13332. PREMULTIPLYALPHA: boolean;
  13333. IMAGEPROCESSING: boolean;
  13334. VIGNETTE: boolean;
  13335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13336. VIGNETTEBLENDMODEOPAQUE: boolean;
  13337. TONEMAPPING: boolean;
  13338. CONTRAST: boolean;
  13339. COLORCURVES: boolean;
  13340. COLORGRADING: boolean;
  13341. COLORGRADING3D: boolean;
  13342. SAMPLER3DGREENDEPTH: boolean;
  13343. SAMPLER3DBGRMAP: boolean;
  13344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13345. /**
  13346. * If the reflection texture on this material is in linear color space
  13347. * @hidden
  13348. */
  13349. IS_REFLECTION_LINEAR: boolean;
  13350. /**
  13351. * If the refraction texture on this material is in linear color space
  13352. * @hidden
  13353. */
  13354. IS_REFRACTION_LINEAR: boolean;
  13355. EXPOSURE: boolean;
  13356. constructor();
  13357. setReflectionMode(modeToEnable: string): void;
  13358. }
  13359. class StandardMaterial extends PushMaterial {
  13360. private _diffuseTexture;
  13361. diffuseTexture: Nullable<BaseTexture>;
  13362. private _ambientTexture;
  13363. ambientTexture: Nullable<BaseTexture>;
  13364. private _opacityTexture;
  13365. opacityTexture: Nullable<BaseTexture>;
  13366. private _reflectionTexture;
  13367. reflectionTexture: Nullable<BaseTexture>;
  13368. private _emissiveTexture;
  13369. emissiveTexture: Nullable<BaseTexture>;
  13370. private _specularTexture;
  13371. specularTexture: Nullable<BaseTexture>;
  13372. private _bumpTexture;
  13373. bumpTexture: Nullable<BaseTexture>;
  13374. private _lightmapTexture;
  13375. lightmapTexture: Nullable<BaseTexture>;
  13376. private _refractionTexture;
  13377. refractionTexture: Nullable<BaseTexture>;
  13378. ambientColor: Color3;
  13379. diffuseColor: Color3;
  13380. specularColor: Color3;
  13381. emissiveColor: Color3;
  13382. specularPower: number;
  13383. private _useAlphaFromDiffuseTexture;
  13384. useAlphaFromDiffuseTexture: boolean;
  13385. private _useEmissiveAsIllumination;
  13386. useEmissiveAsIllumination: boolean;
  13387. private _linkEmissiveWithDiffuse;
  13388. linkEmissiveWithDiffuse: boolean;
  13389. private _useSpecularOverAlpha;
  13390. useSpecularOverAlpha: boolean;
  13391. private _useReflectionOverAlpha;
  13392. useReflectionOverAlpha: boolean;
  13393. private _disableLighting;
  13394. disableLighting: boolean;
  13395. private _useObjectSpaceNormalMap;
  13396. /**
  13397. * Allows using an object space normal map (instead of tangent space).
  13398. */
  13399. useObjectSpaceNormalMap: boolean;
  13400. private _useParallax;
  13401. useParallax: boolean;
  13402. private _useParallaxOcclusion;
  13403. useParallaxOcclusion: boolean;
  13404. parallaxScaleBias: number;
  13405. private _roughness;
  13406. roughness: number;
  13407. indexOfRefraction: number;
  13408. invertRefractionY: boolean;
  13409. /**
  13410. * Defines the alpha limits in alpha test mode
  13411. */
  13412. alphaCutOff: number;
  13413. private _useLightmapAsShadowmap;
  13414. useLightmapAsShadowmap: boolean;
  13415. private _diffuseFresnelParameters;
  13416. diffuseFresnelParameters: FresnelParameters;
  13417. private _opacityFresnelParameters;
  13418. opacityFresnelParameters: FresnelParameters;
  13419. private _reflectionFresnelParameters;
  13420. reflectionFresnelParameters: FresnelParameters;
  13421. private _refractionFresnelParameters;
  13422. refractionFresnelParameters: FresnelParameters;
  13423. private _emissiveFresnelParameters;
  13424. emissiveFresnelParameters: FresnelParameters;
  13425. private _useReflectionFresnelFromSpecular;
  13426. useReflectionFresnelFromSpecular: boolean;
  13427. private _useGlossinessFromSpecularMapAlpha;
  13428. useGlossinessFromSpecularMapAlpha: boolean;
  13429. private _maxSimultaneousLights;
  13430. maxSimultaneousLights: number;
  13431. /**
  13432. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  13433. */
  13434. private _invertNormalMapX;
  13435. invertNormalMapX: boolean;
  13436. /**
  13437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  13438. */
  13439. private _invertNormalMapY;
  13440. invertNormalMapY: boolean;
  13441. /**
  13442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  13443. */
  13444. private _twoSidedLighting;
  13445. twoSidedLighting: boolean;
  13446. /**
  13447. * Default configuration related to image processing available in the standard Material.
  13448. */
  13449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13450. /**
  13451. * Gets the image processing configuration used either in this material.
  13452. */
  13453. /**
  13454. * Sets the Default image processing configuration used either in the this material.
  13455. *
  13456. * If sets to null, the scene one is in use.
  13457. */
  13458. imageProcessingConfiguration: ImageProcessingConfiguration;
  13459. /**
  13460. * Keep track of the image processing observer to allow dispose and replace.
  13461. */
  13462. private _imageProcessingObserver;
  13463. /**
  13464. * Attaches a new image processing configuration to the Standard Material.
  13465. * @param configuration
  13466. */
  13467. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13468. /**
  13469. * Gets wether the color curves effect is enabled.
  13470. */
  13471. /**
  13472. * Sets wether the color curves effect is enabled.
  13473. */
  13474. cameraColorCurvesEnabled: boolean;
  13475. /**
  13476. * Gets wether the color grading effect is enabled.
  13477. */
  13478. /**
  13479. * Gets wether the color grading effect is enabled.
  13480. */
  13481. cameraColorGradingEnabled: boolean;
  13482. /**
  13483. * Gets wether tonemapping is enabled or not.
  13484. */
  13485. /**
  13486. * Sets wether tonemapping is enabled or not
  13487. */
  13488. cameraToneMappingEnabled: boolean;
  13489. /**
  13490. * The camera exposure used on this material.
  13491. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13492. * This corresponds to a photographic exposure.
  13493. */
  13494. /**
  13495. * The camera exposure used on this material.
  13496. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13497. * This corresponds to a photographic exposure.
  13498. */
  13499. cameraExposure: number;
  13500. /**
  13501. * Gets The camera contrast used on this material.
  13502. */
  13503. /**
  13504. * Sets The camera contrast used on this material.
  13505. */
  13506. cameraContrast: number;
  13507. /**
  13508. * Gets the Color Grading 2D Lookup Texture.
  13509. */
  13510. /**
  13511. * Sets the Color Grading 2D Lookup Texture.
  13512. */
  13513. cameraColorGradingTexture: Nullable<BaseTexture>;
  13514. /**
  13515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13517. * 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;
  13518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13519. */
  13520. /**
  13521. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13522. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13523. * 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;
  13524. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13525. */
  13526. cameraColorCurves: Nullable<ColorCurves>;
  13527. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13528. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13529. protected _worldViewProjectionMatrix: Matrix;
  13530. protected _globalAmbientColor: Color3;
  13531. protected _useLogarithmicDepth: boolean;
  13532. constructor(name: string, scene: Scene);
  13533. getClassName(): string;
  13534. useLogarithmicDepth: boolean;
  13535. needAlphaBlending(): boolean;
  13536. needAlphaTesting(): boolean;
  13537. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  13538. getAlphaTestTexture(): Nullable<BaseTexture>;
  13539. /**
  13540. * Child classes can use it to update shaders
  13541. */
  13542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  13543. buildUniformLayout(): void;
  13544. unbind(): void;
  13545. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13546. getAnimatables(): IAnimatable[];
  13547. getActiveTextures(): BaseTexture[];
  13548. hasTexture(texture: BaseTexture): boolean;
  13549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13550. clone(name: string): StandardMaterial;
  13551. serialize(): any;
  13552. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  13553. static _DiffuseTextureEnabled: boolean;
  13554. static DiffuseTextureEnabled: boolean;
  13555. static _AmbientTextureEnabled: boolean;
  13556. static AmbientTextureEnabled: boolean;
  13557. static _OpacityTextureEnabled: boolean;
  13558. static OpacityTextureEnabled: boolean;
  13559. static _ReflectionTextureEnabled: boolean;
  13560. static ReflectionTextureEnabled: boolean;
  13561. static _EmissiveTextureEnabled: boolean;
  13562. static EmissiveTextureEnabled: boolean;
  13563. static _SpecularTextureEnabled: boolean;
  13564. static SpecularTextureEnabled: boolean;
  13565. static _BumpTextureEnabled: boolean;
  13566. static BumpTextureEnabled: boolean;
  13567. static _LightmapTextureEnabled: boolean;
  13568. static LightmapTextureEnabled: boolean;
  13569. static _RefractionTextureEnabled: boolean;
  13570. static RefractionTextureEnabled: boolean;
  13571. static _ColorGradingTextureEnabled: boolean;
  13572. static ColorGradingTextureEnabled: boolean;
  13573. static _FresnelEnabled: boolean;
  13574. static FresnelEnabled: boolean;
  13575. }
  13576. }
  13577. declare module BABYLON {
  13578. class UniformBuffer {
  13579. private _engine;
  13580. private _buffer;
  13581. private _data;
  13582. private _bufferData;
  13583. private _dynamic?;
  13584. private _uniformLocations;
  13585. private _uniformSizes;
  13586. private _uniformLocationPointer;
  13587. private _needSync;
  13588. private _noUBO;
  13589. private _currentEffect;
  13590. private static _MAX_UNIFORM_SIZE;
  13591. private static _tempBuffer;
  13592. /**
  13593. * Wrapper for updateUniform.
  13594. * @method updateMatrix3x3
  13595. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13596. * @param {Float32Array} matrix
  13597. */
  13598. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  13599. /**
  13600. * Wrapper for updateUniform.
  13601. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13602. * @param {Float32Array} matrix
  13603. */
  13604. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  13605. /**
  13606. * Wrapper for updateUniform.
  13607. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13608. * @param {number} x
  13609. */
  13610. updateFloat: (name: string, x: number) => void;
  13611. /**
  13612. * Wrapper for updateUniform.
  13613. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13614. * @param {number} x
  13615. * @param {number} y
  13616. * @param {string} [suffix] Suffix to add to the uniform name.
  13617. */
  13618. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  13619. /**
  13620. * Wrapper for updateUniform.
  13621. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13622. * @param {number} x
  13623. * @param {number} y
  13624. * @param {number} z
  13625. * @param {string} [suffix] Suffix to add to the uniform name.
  13626. */
  13627. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  13628. /**
  13629. * Wrapper for updateUniform.
  13630. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13631. * @param {number} x
  13632. * @param {number} y
  13633. * @param {number} z
  13634. * @param {number} w
  13635. * @param {string} [suffix] Suffix to add to the uniform name.
  13636. */
  13637. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  13638. /**
  13639. * Wrapper for updateUniform.
  13640. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13641. * @param {Matrix} A 4x4 matrix.
  13642. */
  13643. updateMatrix: (name: string, mat: Matrix) => void;
  13644. /**
  13645. * Wrapper for updateUniform.
  13646. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13647. * @param {Vector3} vector
  13648. */
  13649. updateVector3: (name: string, vector: Vector3) => void;
  13650. /**
  13651. * Wrapper for updateUniform.
  13652. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13653. * @param {Vector4} vector
  13654. */
  13655. updateVector4: (name: string, vector: Vector4) => void;
  13656. /**
  13657. * Wrapper for updateUniform.
  13658. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13659. * @param {Color3} color
  13660. * @param {string} [suffix] Suffix to add to the uniform name.
  13661. */
  13662. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  13663. /**
  13664. * Wrapper for updateUniform.
  13665. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13666. * @param {Color3} color
  13667. * @param {number} alpha
  13668. * @param {string} [suffix] Suffix to add to the uniform name.
  13669. */
  13670. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  13671. /**
  13672. * Uniform buffer objects.
  13673. *
  13674. * Handles blocks of uniform on the GPU.
  13675. *
  13676. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  13677. *
  13678. * For more information, please refer to :
  13679. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  13680. */
  13681. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  13682. /**
  13683. * Indicates if the buffer is using the WebGL2 UBO implementation,
  13684. * or just falling back on setUniformXXX calls.
  13685. */
  13686. readonly useUbo: boolean;
  13687. /**
  13688. * Indicates if the WebGL underlying uniform buffer is in sync
  13689. * with the javascript cache data.
  13690. */
  13691. readonly isSync: boolean;
  13692. /**
  13693. * Indicates if the WebGL underlying uniform buffer is dynamic.
  13694. * Also, a dynamic UniformBuffer will disable cache verification and always
  13695. * update the underlying WebGL uniform buffer to the GPU.
  13696. */
  13697. isDynamic(): boolean;
  13698. /**
  13699. * The data cache on JS side.
  13700. */
  13701. getData(): Float32Array;
  13702. /**
  13703. * The underlying WebGL Uniform buffer.
  13704. */
  13705. getBuffer(): Nullable<WebGLBuffer>;
  13706. /**
  13707. * std140 layout specifies how to align data within an UBO structure.
  13708. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  13709. * for specs.
  13710. */
  13711. private _fillAlignment(size);
  13712. /**
  13713. * Adds an uniform in the buffer.
  13714. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  13715. * for the layout to be correct !
  13716. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13717. * @param {number|number[]} size Data size, or data directly.
  13718. */
  13719. addUniform(name: string, size: number | number[]): void;
  13720. /**
  13721. * Wrapper for addUniform.
  13722. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13723. * @param {Matrix} mat A 4x4 matrix.
  13724. */
  13725. addMatrix(name: string, mat: Matrix): void;
  13726. /**
  13727. * Wrapper for addUniform.
  13728. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13729. * @param {number} x
  13730. * @param {number} y
  13731. */
  13732. addFloat2(name: string, x: number, y: number): void;
  13733. /**
  13734. * Wrapper for addUniform.
  13735. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13736. * @param {number} x
  13737. * @param {number} y
  13738. * @param {number} z
  13739. */
  13740. addFloat3(name: string, x: number, y: number, z: number): void;
  13741. /**
  13742. * Wrapper for addUniform.
  13743. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13744. * @param {Color3} color
  13745. */
  13746. addColor3(name: string, color: Color3): void;
  13747. /**
  13748. * Wrapper for addUniform.
  13749. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13750. * @param {Color3} color
  13751. * @param {number} alpha
  13752. */
  13753. addColor4(name: string, color: Color3, alpha: number): void;
  13754. /**
  13755. * Wrapper for addUniform.
  13756. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13757. * @param {Vector3} vector
  13758. */
  13759. addVector3(name: string, vector: Vector3): void;
  13760. /**
  13761. * Wrapper for addUniform.
  13762. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13763. */
  13764. addMatrix3x3(name: string): void;
  13765. /**
  13766. * Wrapper for addUniform.
  13767. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13768. */
  13769. addMatrix2x2(name: string): void;
  13770. /**
  13771. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  13772. */
  13773. create(): void;
  13774. _rebuild(): void;
  13775. /**
  13776. * Updates the WebGL Uniform Buffer on the GPU.
  13777. * If the `dynamic` flag is set to true, no cache comparison is done.
  13778. * Otherwise, the buffer will be updated only if the cache differs.
  13779. */
  13780. update(): void;
  13781. /**
  13782. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  13783. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13784. * @param {number[]|Float32Array} data Flattened data
  13785. * @param {number} size Size of the data.
  13786. */
  13787. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  13788. private _updateMatrix3x3ForUniform(name, matrix);
  13789. private _updateMatrix3x3ForEffect(name, matrix);
  13790. private _updateMatrix2x2ForEffect(name, matrix);
  13791. private _updateMatrix2x2ForUniform(name, matrix);
  13792. private _updateFloatForEffect(name, x);
  13793. private _updateFloatForUniform(name, x);
  13794. private _updateFloat2ForEffect(name, x, y, suffix?);
  13795. private _updateFloat2ForUniform(name, x, y, suffix?);
  13796. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  13797. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  13798. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  13799. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  13800. private _updateMatrixForEffect(name, mat);
  13801. private _updateMatrixForUniform(name, mat);
  13802. private _updateVector3ForEffect(name, vector);
  13803. private _updateVector3ForUniform(name, vector);
  13804. private _updateVector4ForEffect(name, vector);
  13805. private _updateVector4ForUniform(name, vector);
  13806. private _updateColor3ForEffect(name, color, suffix?);
  13807. private _updateColor3ForUniform(name, color, suffix?);
  13808. private _updateColor4ForEffect(name, color, alpha, suffix?);
  13809. private _updateColor4ForUniform(name, color, alpha, suffix?);
  13810. /**
  13811. * Sets a sampler uniform on the effect.
  13812. * @param {string} name Name of the sampler.
  13813. * @param {Texture} texture
  13814. */
  13815. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  13816. /**
  13817. * Directly updates the value of the uniform in the cache AND on the GPU.
  13818. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13819. * @param {number[]|Float32Array} data Flattened data
  13820. */
  13821. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  13822. /**
  13823. * Binds this uniform buffer to an effect.
  13824. * @param {Effect} effect
  13825. * @param {string} name Name of the uniform block in the shader.
  13826. */
  13827. bindToEffect(effect: Effect, name: string): void;
  13828. /**
  13829. * Disposes the uniform buffer.
  13830. */
  13831. dispose(): void;
  13832. }
  13833. }
  13834. declare module BABYLON {
  13835. /**
  13836. * A directional light is defined by a direction (what a surprise!).
  13837. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  13838. * 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.
  13839. * Documentation: https://doc.babylonjs.com/babylon101/lights
  13840. */
  13841. class DirectionalLight extends ShadowLight {
  13842. private _shadowFrustumSize;
  13843. /**
  13844. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  13845. */
  13846. /**
  13847. * Specifies a fix frustum size for the shadow generation.
  13848. */
  13849. shadowFrustumSize: number;
  13850. private _shadowOrthoScale;
  13851. /**
  13852. * Gets the shadow projection scale against the optimal computed one.
  13853. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  13854. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  13855. */
  13856. /**
  13857. * Sets the shadow projection scale against the optimal computed one.
  13858. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  13859. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  13860. */
  13861. shadowOrthoScale: number;
  13862. /**
  13863. * Automatically compute the projection matrix to best fit (including all the casters)
  13864. * on each frame.
  13865. */
  13866. autoUpdateExtends: boolean;
  13867. private _orthoLeft;
  13868. private _orthoRight;
  13869. private _orthoTop;
  13870. private _orthoBottom;
  13871. /**
  13872. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  13873. * The directional light is emitted from everywhere in the given direction.
  13874. * It can cast shawdows.
  13875. * Documentation : http://doc.babylonjs.com/tutorials/lights
  13876. * @param name The friendly name of the light
  13877. * @param direction The direction of the light
  13878. * @param scene The scene the light belongs to
  13879. */
  13880. constructor(name: string, direction: Vector3, scene: Scene);
  13881. /**
  13882. * Returns the string "DirectionalLight".
  13883. * @return The class name
  13884. */
  13885. getClassName(): string;
  13886. /**
  13887. * Returns the integer 1.
  13888. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13889. */
  13890. getTypeID(): number;
  13891. /**
  13892. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  13893. * Returns the DirectionalLight Shadow projection matrix.
  13894. */
  13895. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  13896. /**
  13897. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  13898. * Returns the DirectionalLight Shadow projection matrix.
  13899. */
  13900. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  13901. /**
  13902. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  13903. * Returns the DirectionalLight Shadow projection matrix.
  13904. */
  13905. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  13906. protected _buildUniformLayout(): void;
  13907. /**
  13908. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  13909. * @param effect The effect to update
  13910. * @param lightIndex The index of the light in the effect to update
  13911. * @returns The directional light
  13912. */
  13913. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  13914. /**
  13915. * Gets the minZ used for shadow according to both the scene and the light.
  13916. *
  13917. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  13918. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  13919. * @param activeCamera The camera we are returning the min for
  13920. * @returns the depth min z
  13921. */
  13922. getDepthMinZ(activeCamera: Camera): number;
  13923. /**
  13924. * Gets the maxZ used for shadow according to both the scene and the light.
  13925. *
  13926. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  13927. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  13928. * @param activeCamera The camera we are returning the max for
  13929. * @returns the depth max z
  13930. */
  13931. getDepthMaxZ(activeCamera: Camera): number;
  13932. }
  13933. }
  13934. declare module BABYLON {
  13935. /**
  13936. * The HemisphericLight simulates the ambient environment light,
  13937. * so the passed direction is the light reflection direction, not the incoming direction.
  13938. */
  13939. class HemisphericLight extends Light {
  13940. /**
  13941. * The groundColor is the light in the opposite direction to the one specified during creation.
  13942. * 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.
  13943. */
  13944. groundColor: Color3;
  13945. /**
  13946. * The light reflection direction, not the incoming direction.
  13947. */
  13948. direction: Vector3;
  13949. private _worldMatrix;
  13950. /**
  13951. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13952. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13953. * The HemisphericLight can't cast shadows.
  13954. * Documentation : http://doc.babylonjs.com/tutorials/lights
  13955. * @param name The friendly name of the light
  13956. * @param direction The direction of the light reflection
  13957. * @param scene The scene the light belongs to
  13958. */
  13959. constructor(name: string, direction: Vector3, scene: Scene);
  13960. protected _buildUniformLayout(): void;
  13961. /**
  13962. * Returns the string "HemisphericLight".
  13963. * @return The class name
  13964. */
  13965. getClassName(): string;
  13966. /**
  13967. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13968. * Returns the updated direction.
  13969. * @param target The target the direction should point to
  13970. * @return The computed direction
  13971. */
  13972. setDirectionToTarget(target: Vector3): Vector3;
  13973. /**
  13974. * Returns the shadow generator associated to the light.
  13975. * @returns Always null for hemispheric lights because it does not support shadows.
  13976. */
  13977. getShadowGenerator(): Nullable<ShadowGenerator>;
  13978. /**
  13979. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13980. * @param effect The effect to update
  13981. * @param lightIndex The index of the light in the effect to update
  13982. * @returns The hemispheric light
  13983. */
  13984. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13985. /**
  13986. * @hidden internal use only.
  13987. */
  13988. _getWorldMatrix(): Matrix;
  13989. /**
  13990. * Returns the integer 3.
  13991. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13992. */
  13993. getTypeID(): number;
  13994. }
  13995. }
  13996. declare module BABYLON {
  13997. /**
  13998. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  13999. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  14000. * 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.
  14001. */
  14002. abstract class Light extends Node {
  14003. private static _LIGHTMAP_DEFAULT;
  14004. private static _LIGHTMAP_SPECULAR;
  14005. private static _LIGHTMAP_SHADOWSONLY;
  14006. /**
  14007. * If every light affecting the material is in this lightmapMode,
  14008. * material.lightmapTexture adds or multiplies
  14009. * (depends on material.useLightmapAsShadowmap)
  14010. * after every other light calculations.
  14011. */
  14012. static readonly LIGHTMAP_DEFAULT: number;
  14013. /**
  14014. * material.lightmapTexture as only diffuse lighting from this light
  14015. * adds only specular lighting from this light
  14016. * adds dynamic shadows
  14017. */
  14018. static readonly LIGHTMAP_SPECULAR: number;
  14019. /**
  14020. * material.lightmapTexture as only lighting
  14021. * no light calculation from this light
  14022. * only adds dynamic shadows from this light
  14023. */
  14024. static readonly LIGHTMAP_SHADOWSONLY: number;
  14025. private static _INTENSITYMODE_AUTOMATIC;
  14026. private static _INTENSITYMODE_LUMINOUSPOWER;
  14027. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  14028. private static _INTENSITYMODE_ILLUMINANCE;
  14029. private static _INTENSITYMODE_LUMINANCE;
  14030. /**
  14031. * Each light type uses the default quantity according to its type:
  14032. * point/spot lights use luminous intensity
  14033. * directional lights use illuminance
  14034. */
  14035. static readonly INTENSITYMODE_AUTOMATIC: number;
  14036. /**
  14037. * lumen (lm)
  14038. */
  14039. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  14040. /**
  14041. * candela (lm/sr)
  14042. */
  14043. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  14044. /**
  14045. * lux (lm/m^2)
  14046. */
  14047. static readonly INTENSITYMODE_ILLUMINANCE: number;
  14048. /**
  14049. * nit (cd/m^2)
  14050. */
  14051. static readonly INTENSITYMODE_LUMINANCE: number;
  14052. private static _LIGHTTYPEID_POINTLIGHT;
  14053. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  14054. private static _LIGHTTYPEID_SPOTLIGHT;
  14055. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  14056. /**
  14057. * Light type const id of the point light.
  14058. */
  14059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  14060. /**
  14061. * Light type const id of the directional light.
  14062. */
  14063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  14064. /**
  14065. * Light type const id of the spot light.
  14066. */
  14067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  14068. /**
  14069. * Light type const id of the hemispheric light.
  14070. */
  14071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  14072. /**
  14073. * Diffuse gives the basic color to an object.
  14074. */
  14075. diffuse: Color3;
  14076. /**
  14077. * Specular produces a highlight color on an object.
  14078. * Note: This is note affecting PBR materials.
  14079. */
  14080. specular: Color3;
  14081. /**
  14082. * Strength of the light.
  14083. * Note: By default it is define in the framework own unit.
  14084. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  14085. */
  14086. intensity: number;
  14087. /**
  14088. * Defines how far from the source the light is impacting in scene units.
  14089. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14090. */
  14091. range: number;
  14092. /**
  14093. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  14094. * of light.
  14095. */
  14096. private _photometricScale;
  14097. private _intensityMode;
  14098. /**
  14099. * Gets the photometric scale used to interpret the intensity.
  14100. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14101. */
  14102. /**
  14103. * Sets the photometric scale used to interpret the intensity.
  14104. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14105. */
  14106. intensityMode: number;
  14107. private _radius;
  14108. /**
  14109. * Gets the light radius used by PBR Materials to simulate soft area lights.
  14110. */
  14111. /**
  14112. * sets the light radius used by PBR Materials to simulate soft area lights.
  14113. */
  14114. radius: number;
  14115. private _renderPriority;
  14116. /**
  14117. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  14118. * exceeding the number allowed of the materials.
  14119. */
  14120. renderPriority: number;
  14121. private _shadowEnabled;
  14122. /**
  14123. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14124. * the current shadow generator.
  14125. */
  14126. /**
  14127. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14128. * the current shadow generator.
  14129. */
  14130. shadowEnabled: boolean;
  14131. private _includedOnlyMeshes;
  14132. /**
  14133. * Gets the only meshes impacted by this light.
  14134. */
  14135. /**
  14136. * Sets the only meshes impacted by this light.
  14137. */
  14138. includedOnlyMeshes: AbstractMesh[];
  14139. private _excludedMeshes;
  14140. /**
  14141. * Gets the meshes not impacted by this light.
  14142. */
  14143. /**
  14144. * Sets the meshes not impacted by this light.
  14145. */
  14146. excludedMeshes: AbstractMesh[];
  14147. private _excludeWithLayerMask;
  14148. /**
  14149. * Gets the layer id use to find what meshes are not impacted by the light.
  14150. * Inactive if 0
  14151. */
  14152. /**
  14153. * Sets the layer id use to find what meshes are not impacted by the light.
  14154. * Inactive if 0
  14155. */
  14156. excludeWithLayerMask: number;
  14157. private _includeOnlyWithLayerMask;
  14158. /**
  14159. * Gets the layer id use to find what meshes are impacted by the light.
  14160. * Inactive if 0
  14161. */
  14162. /**
  14163. * Sets the layer id use to find what meshes are impacted by the light.
  14164. * Inactive if 0
  14165. */
  14166. includeOnlyWithLayerMask: number;
  14167. private _lightmapMode;
  14168. /**
  14169. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  14170. */
  14171. /**
  14172. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  14173. */
  14174. lightmapMode: number;
  14175. private _parentedWorldMatrix;
  14176. /**
  14177. * Shadow generator associted to the light.
  14178. * Internal use only.
  14179. */
  14180. _shadowGenerator: Nullable<IShadowGenerator>;
  14181. /**
  14182. * @hidden Internal use only.
  14183. */
  14184. _excludedMeshesIds: string[];
  14185. /**
  14186. * @hidden Internal use only.
  14187. */
  14188. _includedOnlyMeshesIds: string[];
  14189. /**
  14190. * The current light unifom buffer.
  14191. * @hidden Internal use only.
  14192. */
  14193. _uniformBuffer: UniformBuffer;
  14194. /**
  14195. * Creates a Light object in the scene.
  14196. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14197. * @param name The firendly name of the light
  14198. * @param scene The scene the light belongs too
  14199. */
  14200. constructor(name: string, scene: Scene);
  14201. protected abstract _buildUniformLayout(): void;
  14202. /**
  14203. * Sets the passed Effect "effect" with the Light information.
  14204. * @param effect The effect to update
  14205. * @param lightIndex The index of the light in the effect to update
  14206. * @returns The light
  14207. */
  14208. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  14209. /**
  14210. * @hidden internal use only.
  14211. */
  14212. abstract _getWorldMatrix(): Matrix;
  14213. /**
  14214. * Returns the string "Light".
  14215. * @returns the class name
  14216. */
  14217. getClassName(): string;
  14218. /**
  14219. * Converts the light information to a readable string for debug purpose.
  14220. * @param fullDetails Supports for multiple levels of logging within scene loading
  14221. * @returns the human readable light info
  14222. */
  14223. toString(fullDetails?: boolean): string;
  14224. /**
  14225. * Set the enabled state of this node.
  14226. * @param value - the new enabled state
  14227. */
  14228. setEnabled(value: boolean): void;
  14229. /**
  14230. * Returns the Light associated shadow generator if any.
  14231. * @return the associated shadow generator.
  14232. */
  14233. getShadowGenerator(): Nullable<IShadowGenerator>;
  14234. /**
  14235. * Returns a Vector3, the absolute light position in the World.
  14236. * @returns the world space position of the light
  14237. */
  14238. getAbsolutePosition(): Vector3;
  14239. /**
  14240. * Specifies if the light will affect the passed mesh.
  14241. * @param mesh The mesh to test against the light
  14242. * @return true the mesh is affected otherwise, false.
  14243. */
  14244. canAffectMesh(mesh: AbstractMesh): boolean;
  14245. /**
  14246. * Computes and Returns the light World matrix.
  14247. * @returns the world matrix
  14248. */
  14249. getWorldMatrix(): Matrix;
  14250. /**
  14251. * Sort function to order lights for rendering.
  14252. * @param a First Light object to compare to second.
  14253. * @param b Second Light object to compare first.
  14254. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  14255. */
  14256. static CompareLightsPriority(a: Light, b: Light): number;
  14257. /**
  14258. * Releases resources associated with this node.
  14259. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14260. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14261. */
  14262. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14263. /**
  14264. * Returns the light type ID (integer).
  14265. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14266. */
  14267. getTypeID(): number;
  14268. /**
  14269. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  14270. * @returns the scaled intensity in intensity mode unit
  14271. */
  14272. getScaledIntensity(): number;
  14273. /**
  14274. * Returns a new Light object, named "name", from the current one.
  14275. * @param name The name of the cloned light
  14276. * @returns the new created light
  14277. */
  14278. clone(name: string): Nullable<Light>;
  14279. /**
  14280. * Serializes the current light into a Serialization object.
  14281. * @returns the serialized object.
  14282. */
  14283. serialize(): any;
  14284. /**
  14285. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  14286. * This new light is named "name" and added to the passed scene.
  14287. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  14288. * @param name The friendly name of the light
  14289. * @param scene The scene the new light will belong to
  14290. * @returns the constructor function
  14291. */
  14292. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  14293. /**
  14294. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  14295. * @param parsedLight The JSON representation of the light
  14296. * @param scene The scene to create the parsed light in
  14297. * @returns the created light after parsing
  14298. */
  14299. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  14300. private _hookArrayForExcluded(array);
  14301. private _hookArrayForIncludedOnly(array);
  14302. private _resyncMeshes();
  14303. /**
  14304. * Forces the meshes to update their light related information in their rendering used effects
  14305. * @hidden Internal Use Only
  14306. */
  14307. _markMeshesAsLightDirty(): void;
  14308. /**
  14309. * Recomputes the cached photometric scale if needed.
  14310. */
  14311. private _computePhotometricScale();
  14312. /**
  14313. * Returns the Photometric Scale according to the light type and intensity mode.
  14314. */
  14315. private _getPhotometricScale();
  14316. /**
  14317. * Reorder the light in the scene according to their defined priority.
  14318. * @hidden Internal Use Only
  14319. */
  14320. _reorderLightsInScene(): void;
  14321. }
  14322. }
  14323. declare module BABYLON {
  14324. /**
  14325. * A point light is a light defined by an unique point in world space.
  14326. * The light is emitted in every direction from this point.
  14327. * A good example of a point light is a standard light bulb.
  14328. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14329. */
  14330. class PointLight extends ShadowLight {
  14331. private _shadowAngle;
  14332. /**
  14333. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14334. * This specifies what angle the shadow will use to be created.
  14335. *
  14336. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  14337. */
  14338. /**
  14339. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14340. * This specifies what angle the shadow will use to be created.
  14341. *
  14342. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  14343. */
  14344. shadowAngle: number;
  14345. /**
  14346. * Gets the direction if it has been set.
  14347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14348. */
  14349. /**
  14350. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14351. */
  14352. direction: Vector3;
  14353. /**
  14354. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  14355. * A PointLight emits the light in every direction.
  14356. * It can cast shadows.
  14357. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  14358. * ```javascript
  14359. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  14360. * ```
  14361. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14362. * @param name The light friendly name
  14363. * @param position The position of the point light in the scene
  14364. * @param scene The scene the lights belongs to
  14365. */
  14366. constructor(name: string, position: Vector3, scene: Scene);
  14367. /**
  14368. * Returns the string "PointLight"
  14369. * @returns the class name
  14370. */
  14371. getClassName(): string;
  14372. /**
  14373. * Returns the integer 0.
  14374. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14375. */
  14376. getTypeID(): number;
  14377. /**
  14378. * Specifies wether or not the shadowmap should be a cube texture.
  14379. * @returns true if the shadowmap needs to be a cube texture.
  14380. */
  14381. needCube(): boolean;
  14382. /**
  14383. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  14384. * @param faceIndex The index of the face we are computed the direction to generate shadow
  14385. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  14386. */
  14387. getShadowDirection(faceIndex?: number): Vector3;
  14388. /**
  14389. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  14390. * - fov = PI / 2
  14391. * - aspect ratio : 1.0
  14392. * - z-near and far equal to the active camera minZ and maxZ.
  14393. * Returns the PointLight.
  14394. */
  14395. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14396. protected _buildUniformLayout(): void;
  14397. /**
  14398. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  14399. * @param effect The effect to update
  14400. * @param lightIndex The index of the light in the effect to update
  14401. * @returns The point light
  14402. */
  14403. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  14404. }
  14405. }
  14406. declare module BABYLON {
  14407. /**
  14408. * Interface describing all the common properties and methods a shadow light needs to implement.
  14409. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  14410. * as well as binding the different shadow properties to the effects.
  14411. */
  14412. interface IShadowLight extends Light {
  14413. /**
  14414. * The light id in the scene (used in scene.findLighById for instance)
  14415. */
  14416. id: string;
  14417. /**
  14418. * The position the shdow will be casted from.
  14419. */
  14420. position: Vector3;
  14421. /**
  14422. * In 2d mode (needCube being false), the direction used to cast the shadow.
  14423. */
  14424. direction: Vector3;
  14425. /**
  14426. * The transformed position. Position of the light in world space taking parenting in account.
  14427. */
  14428. transformedPosition: Vector3;
  14429. /**
  14430. * The transformed direction. Direction of the light in world space taking parenting in account.
  14431. */
  14432. transformedDirection: Vector3;
  14433. /**
  14434. * The friendly name of the light in the scene.
  14435. */
  14436. name: string;
  14437. /**
  14438. * Defines the shadow projection clipping minimum z value.
  14439. */
  14440. shadowMinZ: number;
  14441. /**
  14442. * Defines the shadow projection clipping maximum z value.
  14443. */
  14444. shadowMaxZ: number;
  14445. /**
  14446. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  14447. * @returns true if the information has been computed, false if it does not need to (no parenting)
  14448. */
  14449. computeTransformedInformation(): boolean;
  14450. /**
  14451. * Gets the scene the light belongs to.
  14452. * @returns The scene
  14453. */
  14454. getScene(): Scene;
  14455. /**
  14456. * Callback defining a custom Projection Matrix Builder.
  14457. * This can be used to override the default projection matrix computation.
  14458. */
  14459. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  14460. /**
  14461. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  14462. * @param matrix The materix to updated with the projection information
  14463. * @param viewMatrix The transform matrix of the light
  14464. * @param renderList The list of mesh to render in the map
  14465. * @returns The current light
  14466. */
  14467. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  14468. /**
  14469. * Gets the current depth scale used in ESM.
  14470. * @returns The scale
  14471. */
  14472. getDepthScale(): number;
  14473. /**
  14474. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  14475. * @returns true if a cube texture needs to be use
  14476. */
  14477. needCube(): boolean;
  14478. /**
  14479. * Detects if the projection matrix requires to be recomputed this frame.
  14480. * @returns true if it requires to be recomputed otherwise, false.
  14481. */
  14482. needProjectionMatrixCompute(): boolean;
  14483. /**
  14484. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  14485. */
  14486. forceProjectionMatrixCompute(): void;
  14487. /**
  14488. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  14489. * @param faceIndex The index of the face we are computed the direction to generate shadow
  14490. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  14491. */
  14492. getShadowDirection(faceIndex?: number): Vector3;
  14493. /**
  14494. * Gets the minZ used for shadow according to both the scene and the light.
  14495. * @param activeCamera The camera we are returning the min for
  14496. * @returns the depth min z
  14497. */
  14498. getDepthMinZ(activeCamera: Camera): number;
  14499. /**
  14500. * Gets the maxZ used for shadow according to both the scene and the light.
  14501. * @param activeCamera The camera we are returning the max for
  14502. * @returns the depth max z
  14503. */
  14504. getDepthMaxZ(activeCamera: Camera): number;
  14505. }
  14506. /**
  14507. * Base implementation IShadowLight
  14508. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  14509. */
  14510. abstract class ShadowLight extends Light implements IShadowLight {
  14511. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14512. protected _position: Vector3;
  14513. protected _setPosition(value: Vector3): void;
  14514. /**
  14515. * Sets the position the shadow will be casted from. Also use as the light position for both
  14516. * point and spot lights.
  14517. */
  14518. /**
  14519. * Sets the position the shadow will be casted from. Also use as the light position for both
  14520. * point and spot lights.
  14521. */
  14522. position: Vector3;
  14523. protected _direction: Vector3;
  14524. protected _setDirection(value: Vector3): void;
  14525. /**
  14526. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  14527. * Also use as the light direction on spot and directional lights.
  14528. */
  14529. /**
  14530. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  14531. * Also use as the light direction on spot and directional lights.
  14532. */
  14533. direction: Vector3;
  14534. private _shadowMinZ;
  14535. /**
  14536. * Gets the shadow projection clipping minimum z value.
  14537. */
  14538. /**
  14539. * Sets the shadow projection clipping minimum z value.
  14540. */
  14541. shadowMinZ: number;
  14542. private _shadowMaxZ;
  14543. /**
  14544. * Sets the shadow projection clipping maximum z value.
  14545. */
  14546. /**
  14547. * Gets the shadow projection clipping maximum z value.
  14548. */
  14549. shadowMaxZ: number;
  14550. /**
  14551. * Callback defining a custom Projection Matrix Builder.
  14552. * This can be used to override the default projection matrix computation.
  14553. */
  14554. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  14555. /**
  14556. * The transformed position. Position of the light in world space taking parenting in account.
  14557. */
  14558. transformedPosition: Vector3;
  14559. /**
  14560. * The transformed direction. Direction of the light in world space taking parenting in account.
  14561. */
  14562. transformedDirection: Vector3;
  14563. private _worldMatrix;
  14564. private _needProjectionMatrixCompute;
  14565. /**
  14566. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  14567. * @returns true if the information has been computed, false if it does not need to (no parenting)
  14568. */
  14569. computeTransformedInformation(): boolean;
  14570. /**
  14571. * Return the depth scale used for the shadow map.
  14572. * @returns the depth scale.
  14573. */
  14574. getDepthScale(): number;
  14575. /**
  14576. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  14577. * @param faceIndex The index of the face we are computed the direction to generate shadow
  14578. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  14579. */
  14580. getShadowDirection(faceIndex?: number): Vector3;
  14581. /**
  14582. * Returns the ShadowLight absolute position in the World.
  14583. * @returns the position vector in world space
  14584. */
  14585. getAbsolutePosition(): Vector3;
  14586. /**
  14587. * Sets the ShadowLight direction toward the passed target.
  14588. * @param target The point tot target in local space
  14589. * @returns the updated ShadowLight direction
  14590. */
  14591. setDirectionToTarget(target: Vector3): Vector3;
  14592. /**
  14593. * Returns the light rotation in euler definition.
  14594. * @returns the x y z rotation in local space.
  14595. */
  14596. getRotation(): Vector3;
  14597. /**
  14598. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  14599. * @returns true if a cube texture needs to be use
  14600. */
  14601. needCube(): boolean;
  14602. /**
  14603. * Detects if the projection matrix requires to be recomputed this frame.
  14604. * @returns true if it requires to be recomputed otherwise, false.
  14605. */
  14606. needProjectionMatrixCompute(): boolean;
  14607. /**
  14608. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  14609. */
  14610. forceProjectionMatrixCompute(): void;
  14611. /**
  14612. * Get the world matrix of the sahdow lights.
  14613. * @hidden Internal Use Only
  14614. */
  14615. _getWorldMatrix(): Matrix;
  14616. /**
  14617. * Gets the minZ used for shadow according to both the scene and the light.
  14618. * @param activeCamera The camera we are returning the min for
  14619. * @returns the depth min z
  14620. */
  14621. getDepthMinZ(activeCamera: Camera): number;
  14622. /**
  14623. * Gets the maxZ used for shadow according to both the scene and the light.
  14624. * @param activeCamera The camera we are returning the max for
  14625. * @returns the depth max z
  14626. */
  14627. getDepthMaxZ(activeCamera: Camera): number;
  14628. /**
  14629. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  14630. * @param matrix The materix to updated with the projection information
  14631. * @param viewMatrix The transform matrix of the light
  14632. * @param renderList The list of mesh to render in the map
  14633. * @returns The current light
  14634. */
  14635. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  14636. }
  14637. }
  14638. declare module BABYLON {
  14639. /**
  14640. * A spot light is defined by a position, a direction, an angle, and an exponent.
  14641. * These values define a cone of light starting from the position, emitting toward the direction.
  14642. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  14643. * and the exponent defines the speed of the decay of the light with distance (reach).
  14644. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14645. */
  14646. class SpotLight extends ShadowLight {
  14647. private _angle;
  14648. /**
  14649. * Gets the cone angle of the spot light in Radians.
  14650. */
  14651. /**
  14652. * Sets the cone angle of the spot light in Radians.
  14653. */
  14654. angle: number;
  14655. private _shadowAngleScale;
  14656. /**
  14657. * Allows scaling the angle of the light for shadow generation only.
  14658. */
  14659. /**
  14660. * Allows scaling the angle of the light for shadow generation only.
  14661. */
  14662. shadowAngleScale: number;
  14663. /**
  14664. * The light decay speed with the distance from the emission spot.
  14665. */
  14666. exponent: number;
  14667. private _projectionTextureMatrix;
  14668. /**
  14669. * Allows reading the projecton texture
  14670. */
  14671. readonly projectionTextureMatrix: Matrix;
  14672. protected _projectionTextureLightNear: number;
  14673. /**
  14674. * Gets the near clip of the Spotlight for texture projection.
  14675. */
  14676. /**
  14677. * Sets the near clip of the Spotlight for texture projection.
  14678. */
  14679. projectionTextureLightNear: number;
  14680. protected _projectionTextureLightFar: number;
  14681. /**
  14682. * Gets the far clip of the Spotlight for texture projection.
  14683. */
  14684. /**
  14685. * Sets the far clip of the Spotlight for texture projection.
  14686. */
  14687. projectionTextureLightFar: number;
  14688. protected _projectionTextureUpDirection: Vector3;
  14689. /**
  14690. * Gets the Up vector of the Spotlight for texture projection.
  14691. */
  14692. /**
  14693. * Sets the Up vector of the Spotlight for texture projection.
  14694. */
  14695. projectionTextureUpDirection: Vector3;
  14696. private _projectionTexture;
  14697. /**
  14698. * Gets the projection texture of the light.
  14699. */
  14700. /**
  14701. * Sets the projection texture of the light.
  14702. */
  14703. projectionTexture: Nullable<BaseTexture>;
  14704. private _projectionTextureViewLightDirty;
  14705. private _projectionTextureProjectionLightDirty;
  14706. private _projectionTextureDirty;
  14707. private _projectionTextureViewTargetVector;
  14708. private _projectionTextureViewLightMatrix;
  14709. private _projectionTextureProjectionLightMatrix;
  14710. private _projectionTextureScalingMatrix;
  14711. /**
  14712. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  14713. * It can cast shadows.
  14714. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14715. * @param name The light friendly name
  14716. * @param position The position of the spot light in the scene
  14717. * @param direction The direction of the light in the scene
  14718. * @param angle The cone angle of the light in Radians
  14719. * @param exponent The light decay speed with the distance from the emission spot
  14720. * @param scene The scene the lights belongs to
  14721. */
  14722. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  14723. /**
  14724. * Returns the string "SpotLight".
  14725. * @returns the class name
  14726. */
  14727. getClassName(): string;
  14728. /**
  14729. * Returns the integer 2.
  14730. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14731. */
  14732. getTypeID(): number;
  14733. /**
  14734. * Overrides the direction setter to recompute the projection texture view light Matrix.
  14735. */
  14736. protected _setDirection(value: Vector3): void;
  14737. /**
  14738. * Overrides the position setter to recompute the projection texture view light Matrix.
  14739. */
  14740. protected _setPosition(value: Vector3): void;
  14741. /**
  14742. * 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.
  14743. * Returns the SpotLight.
  14744. */
  14745. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14746. protected _computeProjectionTextureViewLightMatrix(): void;
  14747. protected _computeProjectionTextureProjectionLightMatrix(): void;
  14748. /**
  14749. * Main function for light texture projection matrix computing.
  14750. */
  14751. protected _computeProjectionTextureMatrix(): void;
  14752. protected _buildUniformLayout(): void;
  14753. /**
  14754. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  14755. * @param effect The effect to update
  14756. * @param lightIndex The index of the light in the effect to update
  14757. * @returns The spot light
  14758. */
  14759. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  14760. /**
  14761. * Disposes the light and the associated resources.
  14762. */
  14763. dispose(): void;
  14764. }
  14765. }
  14766. declare module BABYLON {
  14767. class Scalar {
  14768. /**
  14769. * Two pi constants convenient for computation.
  14770. */
  14771. static TwoPi: number;
  14772. /**
  14773. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14774. */
  14775. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14776. /**
  14777. * Returns a string : the upper case translation of the number i to hexadecimal.
  14778. */
  14779. static ToHex(i: number): string;
  14780. /**
  14781. * Returns -1 if value is negative and +1 is value is positive.
  14782. * Returns the value itself if it's equal to zero.
  14783. */
  14784. static Sign(value: number): number;
  14785. /**
  14786. * Returns the value itself if it's between min and max.
  14787. * Returns min if the value is lower than min.
  14788. * Returns max if the value is greater than max.
  14789. */
  14790. static Clamp(value: number, min?: number, max?: number): number;
  14791. /**
  14792. * Returns the log2 of value.
  14793. */
  14794. static Log2(value: number): number;
  14795. /**
  14796. * Loops the value, so that it is never larger than length and never smaller than 0.
  14797. *
  14798. * This is similar to the modulo operator but it works with floating point numbers.
  14799. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14800. * With t = 5 and length = 2.5, the result would be 0.0.
  14801. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14802. */
  14803. static Repeat(value: number, length: number): number;
  14804. /**
  14805. * Normalize the value between 0.0 and 1.0 using min and max values
  14806. */
  14807. static Normalize(value: number, min: number, max: number): number;
  14808. /**
  14809. * Denormalize the value from 0.0 and 1.0 using min and max values
  14810. */
  14811. static Denormalize(normalized: number, min: number, max: number): number;
  14812. /**
  14813. * Calculates the shortest difference between two given angles given in degrees.
  14814. */
  14815. static DeltaAngle(current: number, target: number): number;
  14816. /**
  14817. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14818. *
  14819. * The returned value will move back and forth between 0 and length
  14820. */
  14821. static PingPong(tx: number, length: number): number;
  14822. /**
  14823. * Interpolates between min and max with smoothing at the limits.
  14824. *
  14825. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14826. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14827. */
  14828. static SmoothStep(from: number, to: number, tx: number): number;
  14829. /**
  14830. * Moves a value current towards target.
  14831. *
  14832. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14833. * Negative values of maxDelta pushes the value away from target.
  14834. */
  14835. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14836. /**
  14837. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14838. *
  14839. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14840. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14841. */
  14842. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14843. /**
  14844. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14845. */
  14846. static Lerp(start: number, end: number, amount: number): number;
  14847. /**
  14848. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14849. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14850. */
  14851. static LerpAngle(start: number, end: number, amount: number): number;
  14852. /**
  14853. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14854. */
  14855. static InverseLerp(a: number, b: number, value: number): number;
  14856. /**
  14857. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14858. */
  14859. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14860. /**
  14861. * Returns a random float number between and min and max values
  14862. */
  14863. static RandomRange(min: number, max: number): number;
  14864. /**
  14865. * This function returns percentage of a number in a given range.
  14866. *
  14867. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14868. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14869. */
  14870. static RangeToPercent(number: number, min: number, max: number): number;
  14871. /**
  14872. * This function returns number that corresponds to the percentage in a given range.
  14873. *
  14874. * PercentToRange(0.34,0,100) will return 34.
  14875. */
  14876. static PercentToRange(percent: number, min: number, max: number): number;
  14877. /**
  14878. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14879. * @param angle The angle to normalize in radian.
  14880. * @return The converted angle.
  14881. */
  14882. static NormalizeRadians(angle: number): number;
  14883. }
  14884. }
  14885. declare module BABYLON {
  14886. const ToGammaSpace: number;
  14887. const ToLinearSpace = 2.2;
  14888. const Epsilon = 0.001;
  14889. /**
  14890. * Class used to hold a RBG color
  14891. */
  14892. class Color3 {
  14893. /**
  14894. * Defines the red component (between 0 and 1, default is 0)
  14895. */
  14896. r: number;
  14897. /**
  14898. * Defines the green component (between 0 and 1, default is 0)
  14899. */
  14900. g: number;
  14901. /**
  14902. * Defines the blue component (between 0 and 1, default is 0)
  14903. */
  14904. b: number;
  14905. /**
  14906. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14907. * @param r defines the red component (between 0 and 1, default is 0)
  14908. * @param g defines the green component (between 0 and 1, default is 0)
  14909. * @param b defines the blue component (between 0 and 1, default is 0)
  14910. */
  14911. constructor(
  14912. /**
  14913. * Defines the red component (between 0 and 1, default is 0)
  14914. */
  14915. r?: number,
  14916. /**
  14917. * Defines the green component (between 0 and 1, default is 0)
  14918. */
  14919. g?: number,
  14920. /**
  14921. * Defines the blue component (between 0 and 1, default is 0)
  14922. */
  14923. b?: number);
  14924. /**
  14925. * Creates a string with the Color3 current values
  14926. * @returns the string representation of the Color3 object
  14927. */
  14928. toString(): string;
  14929. /**
  14930. * Returns the string "Color3"
  14931. * @returns "Color3"
  14932. */
  14933. getClassName(): string;
  14934. /**
  14935. * Compute the Color3 hash code
  14936. * @returns an unique number that can be used to hash Color3 objects
  14937. */
  14938. getHashCode(): number;
  14939. /**
  14940. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14941. * @param array defines the array where to store the r,g,b components
  14942. * @param index defines an optional index in the target array to define where to start storing values
  14943. * @returns the current Color3 object
  14944. */
  14945. toArray(array: FloatArray, index?: number): Color3;
  14946. /**
  14947. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14948. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14949. * @returns a new {BABYLON.Color4} object
  14950. */
  14951. toColor4(alpha?: number): Color4;
  14952. /**
  14953. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14954. * @returns the new array
  14955. */
  14956. asArray(): number[];
  14957. /**
  14958. * Returns the luminance value
  14959. * @returns a float value
  14960. */
  14961. toLuminance(): number;
  14962. /**
  14963. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14964. * @param otherColor defines the second operand
  14965. * @returns the new Color3 object
  14966. */
  14967. multiply(otherColor: Color3): Color3;
  14968. /**
  14969. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14970. * @param otherColor defines the second operand
  14971. * @param result defines the Color3 object where to store the result
  14972. * @returns the current Color3
  14973. */
  14974. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14975. /**
  14976. * Determines equality between Color3 objects
  14977. * @param otherColor defines the second operand
  14978. * @returns true if the rgb values are equal to the given ones
  14979. */
  14980. equals(otherColor: Color3): boolean;
  14981. /**
  14982. * Determines equality between the current Color3 object and a set of r,b,g values
  14983. * @param r defines the red component to check
  14984. * @param g defines the green component to check
  14985. * @param b defines the blue component to check
  14986. * @returns true if the rgb values are equal to the given ones
  14987. */
  14988. equalsFloats(r: number, g: number, b: number): boolean;
  14989. /**
  14990. * Multiplies in place each rgb value by scale
  14991. * @param scale defines the scaling factor
  14992. * @returns the updated Color3
  14993. */
  14994. scale(scale: number): Color3;
  14995. /**
  14996. * Multiplies the rgb values by scale and stores the result into "result"
  14997. * @param scale defines the scaling factor
  14998. * @param result defines the Color3 object where to store the result
  14999. * @returns the unmodified current Color3
  15000. */
  15001. scaleToRef(scale: number, result: Color3): Color3;
  15002. /**
  15003. * Scale the current Color3 values by a factor and add the result to a given Color3
  15004. * @param scale defines the scale factor
  15005. * @param result defines color to store the result into
  15006. * @returns the unmodified current Color3
  15007. */
  15008. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15009. /**
  15010. * Clamps the rgb values by the min and max values and stores the result into "result"
  15011. * @param min defines minimum clamping value (default is 0)
  15012. * @param max defines maximum clamping value (default is 1)
  15013. * @param result defines color to store the result into
  15014. * @returns the original Color3
  15015. */
  15016. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15017. /**
  15018. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15019. * @param otherColor defines the second operand
  15020. * @returns the new Color3
  15021. */
  15022. add(otherColor: Color3): Color3;
  15023. /**
  15024. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15025. * @param otherColor defines the second operand
  15026. * @param result defines Color3 object to store the result into
  15027. * @returns the unmodified current Color3
  15028. */
  15029. addToRef(otherColor: Color3, result: Color3): Color3;
  15030. /**
  15031. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15032. * @param otherColor defines the second operand
  15033. * @returns the new Color3
  15034. */
  15035. subtract(otherColor: Color3): Color3;
  15036. /**
  15037. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15038. * @param otherColor defines the second operand
  15039. * @param result defines Color3 object to store the result into
  15040. * @returns the unmodified current Color3
  15041. */
  15042. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15043. /**
  15044. * Copy the current object
  15045. * @returns a new Color3 copied the current one
  15046. */
  15047. clone(): Color3;
  15048. /**
  15049. * Copies the rgb values from the source in the current Color3
  15050. * @param source defines the source Color3 object
  15051. * @returns the updated Color3 object
  15052. */
  15053. copyFrom(source: Color3): Color3;
  15054. /**
  15055. * Updates the Color3 rgb values from the given floats
  15056. * @param r defines the red component to read from
  15057. * @param g defines the green component to read from
  15058. * @param b defines the blue component to read from
  15059. * @returns the current Color3 object
  15060. */
  15061. copyFromFloats(r: number, g: number, b: number): Color3;
  15062. /**
  15063. * Updates the Color3 rgb values from the given floats
  15064. * @param r defines the red component to read from
  15065. * @param g defines the green component to read from
  15066. * @param b defines the blue component to read from
  15067. * @returns the current Color3 object
  15068. */
  15069. set(r: number, g: number, b: number): Color3;
  15070. /**
  15071. * Compute the Color3 hexadecimal code as a string
  15072. * @returns a string containing the hexadecimal representation of the Color3 object
  15073. */
  15074. toHexString(): string;
  15075. /**
  15076. * Computes a new Color3 converted from the current one to linear space
  15077. * @returns a new Color3 object
  15078. */
  15079. toLinearSpace(): Color3;
  15080. /**
  15081. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15082. * @param convertedColor defines the Color3 object where to store the linear space version
  15083. * @returns the unmodified Color3
  15084. */
  15085. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15086. /**
  15087. * Computes a new Color3 converted from the current one to gamma space
  15088. * @returns a new Color3 object
  15089. */
  15090. toGammaSpace(): Color3;
  15091. /**
  15092. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15093. * @param convertedColor defines the Color3 object where to store the gamma space version
  15094. * @returns the unmodified Color3
  15095. */
  15096. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15097. /**
  15098. * Creates a new Color3 from the string containing valid hexadecimal values
  15099. * @param hex defines a string containing valid hexadecimal values
  15100. * @returns a new Color3 object
  15101. */
  15102. static FromHexString(hex: string): Color3;
  15103. /**
  15104. * Creates a new Vector3 from the starting index of the given array
  15105. * @param array defines the source array
  15106. * @param offset defines an offset in the source array
  15107. * @returns a new Color3 object
  15108. */
  15109. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15110. /**
  15111. * Creates a new Color3 from integer values (< 256)
  15112. * @param r defines the red component to read from (value between 0 and 255)
  15113. * @param g defines the green component to read from (value between 0 and 255)
  15114. * @param b defines the blue component to read from (value between 0 and 255)
  15115. * @returns a new Color3 object
  15116. */
  15117. static FromInts(r: number, g: number, b: number): Color3;
  15118. /**
  15119. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15120. * @param start defines the start Color3 value
  15121. * @param end defines the end Color3 value
  15122. * @param amount defines the gradient value between start and end
  15123. * @returns a new Color3 object
  15124. */
  15125. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15126. /**
  15127. * Returns a Color3 value containing a red color
  15128. * @returns a new Color3 object
  15129. */
  15130. static Red(): Color3;
  15131. /**
  15132. * Returns a Color3 value containing a green color
  15133. * @returns a new Color3 object
  15134. */
  15135. static Green(): Color3;
  15136. /**
  15137. * Returns a Color3 value containing a blue color
  15138. * @returns a new Color3 object
  15139. */
  15140. static Blue(): Color3;
  15141. /**
  15142. * Returns a Color3 value containing a black color
  15143. * @returns a new Color3 object
  15144. */
  15145. static Black(): Color3;
  15146. /**
  15147. * Returns a Color3 value containing a white color
  15148. * @returns a new Color3 object
  15149. */
  15150. static White(): Color3;
  15151. /**
  15152. * Returns a Color3 value containing a purple color
  15153. * @returns a new Color3 object
  15154. */
  15155. static Purple(): Color3;
  15156. /**
  15157. * Returns a Color3 value containing a magenta color
  15158. * @returns a new Color3 object
  15159. */
  15160. static Magenta(): Color3;
  15161. /**
  15162. * Returns a Color3 value containing a yellow color
  15163. * @returns a new Color3 object
  15164. */
  15165. static Yellow(): Color3;
  15166. /**
  15167. * Returns a Color3 value containing a gray color
  15168. * @returns a new Color3 object
  15169. */
  15170. static Gray(): Color3;
  15171. /**
  15172. * Returns a Color3 value containing a teal color
  15173. * @returns a new Color3 object
  15174. */
  15175. static Teal(): Color3;
  15176. /**
  15177. * Returns a Color3 value containing a random color
  15178. * @returns a new Color3 object
  15179. */
  15180. static Random(): Color3;
  15181. }
  15182. /**
  15183. * Class used to hold a RBGA color
  15184. */
  15185. class Color4 {
  15186. /**
  15187. * Defines the red component (between 0 and 1, default is 0)
  15188. */
  15189. r: number;
  15190. /**
  15191. * Defines the green component (between 0 and 1, default is 0)
  15192. */
  15193. g: number;
  15194. /**
  15195. * Defines the blue component (between 0 and 1, default is 0)
  15196. */
  15197. b: number;
  15198. /**
  15199. * Defines the alpha component (between 0 and 1, default is 1)
  15200. */
  15201. a: number;
  15202. /**
  15203. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15204. * @param r defines the red component (between 0 and 1, default is 0)
  15205. * @param g defines the green component (between 0 and 1, default is 0)
  15206. * @param b defines the blue component (between 0 and 1, default is 0)
  15207. * @param a defines the alpha component (between 0 and 1, default is 1)
  15208. */
  15209. constructor(
  15210. /**
  15211. * Defines the red component (between 0 and 1, default is 0)
  15212. */
  15213. r?: number,
  15214. /**
  15215. * Defines the green component (between 0 and 1, default is 0)
  15216. */
  15217. g?: number,
  15218. /**
  15219. * Defines the blue component (between 0 and 1, default is 0)
  15220. */
  15221. b?: number,
  15222. /**
  15223. * Defines the alpha component (between 0 and 1, default is 1)
  15224. */
  15225. a?: number);
  15226. /**
  15227. * Adds in place the given Color4 values to the current Color4 object
  15228. * @param right defines the second operand
  15229. * @returns the current updated Color4 object
  15230. */
  15231. addInPlace(right: Color4): Color4;
  15232. /**
  15233. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15234. * @returns the new array
  15235. */
  15236. asArray(): number[];
  15237. /**
  15238. * Stores from the starting index in the given array the Color4 successive values
  15239. * @param array defines the array where to store the r,g,b components
  15240. * @param index defines an optional index in the target array to define where to start storing values
  15241. * @returns the current Color4 object
  15242. */
  15243. toArray(array: number[], index?: number): Color4;
  15244. /**
  15245. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15246. * @param right defines the second operand
  15247. * @returns a new Color4 object
  15248. */
  15249. add(right: Color4): Color4;
  15250. /**
  15251. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15252. * @param right defines the second operand
  15253. * @returns a new Color4 object
  15254. */
  15255. subtract(right: Color4): Color4;
  15256. /**
  15257. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15258. * @param right defines the second operand
  15259. * @param result defines the Color4 object where to store the result
  15260. * @returns the current Color4 object
  15261. */
  15262. subtractToRef(right: Color4, result: Color4): Color4;
  15263. /**
  15264. * Creates a new Color4 with the current Color4 values multiplied by scale
  15265. * @param scale defines the scaling factor to apply
  15266. * @returns a new Color4 object
  15267. */
  15268. scale(scale: number): Color4;
  15269. /**
  15270. * Multiplies the current Color4 values by scale and stores the result in "result"
  15271. * @param scale defines the scaling factor to apply
  15272. * @param result defines the Color4 object where to store the result
  15273. * @returns the current unmodified Color4
  15274. */
  15275. scaleToRef(scale: number, result: Color4): Color4;
  15276. /**
  15277. * Scale the current Color4 values by a factor and add the result to a given Color4
  15278. * @param scale defines the scale factor
  15279. * @param result defines the Color4 object where to store the result
  15280. * @returns the unmodified current Color4
  15281. */
  15282. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15283. /**
  15284. * Clamps the rgb values by the min and max values and stores the result into "result"
  15285. * @param min defines minimum clamping value (default is 0)
  15286. * @param max defines maximum clamping value (default is 1)
  15287. * @param result defines color to store the result into.
  15288. * @returns the cuurent Color4
  15289. */
  15290. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15291. /**
  15292. * Multipy an Color4 value by another and return a new Color4 object
  15293. * @param color defines the Color4 value to multiply by
  15294. * @returns a new Color4 object
  15295. */
  15296. multiply(color: Color4): Color4;
  15297. /**
  15298. * Multipy a Color4 value by another and push the result in a reference value
  15299. * @param color defines the Color4 value to multiply by
  15300. * @param result defines the Color4 to fill the result in
  15301. * @returns the result Color4
  15302. */
  15303. multiplyToRef(color: Color4, result: Color4): Color4;
  15304. /**
  15305. * Creates a string with the Color4 current values
  15306. * @returns the string representation of the Color4 object
  15307. */
  15308. toString(): string;
  15309. /**
  15310. * Returns the string "Color4"
  15311. * @returns "Color4"
  15312. */
  15313. getClassName(): string;
  15314. /**
  15315. * Compute the Color4 hash code
  15316. * @returns an unique number that can be used to hash Color4 objects
  15317. */
  15318. getHashCode(): number;
  15319. /**
  15320. * Creates a new Color4 copied from the current one
  15321. * @returns a new Color4 object
  15322. */
  15323. clone(): Color4;
  15324. /**
  15325. * Copies the given Color4 values into the current one
  15326. * @param source defines the source Color4 object
  15327. * @returns the current updated Color4 object
  15328. */
  15329. copyFrom(source: Color4): Color4;
  15330. /**
  15331. * Copies the given float values into the current one
  15332. * @param r defines the red component to read from
  15333. * @param g defines the green component to read from
  15334. * @param b defines the blue component to read from
  15335. * @param a defines the alpha component to read from
  15336. * @returns the current updated Color4 object
  15337. */
  15338. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15339. /**
  15340. * Copies the given float values into the current one
  15341. * @param r defines the red component to read from
  15342. * @param g defines the green component to read from
  15343. * @param b defines the blue component to read from
  15344. * @param a defines the alpha component to read from
  15345. * @returns the current updated Color4 object
  15346. */
  15347. set(r: number, g: number, b: number, a: number): Color4;
  15348. /**
  15349. * Compute the Color4 hexadecimal code as a string
  15350. * @returns a string containing the hexadecimal representation of the Color4 object
  15351. */
  15352. toHexString(): string;
  15353. /**
  15354. * Computes a new Color4 converted from the current one to linear space
  15355. * @returns a new Color4 object
  15356. */
  15357. toLinearSpace(): Color4;
  15358. /**
  15359. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15360. * @param convertedColor defines the Color4 object where to store the linear space version
  15361. * @returns the unmodified Color4
  15362. */
  15363. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15364. /**
  15365. * Computes a new Color4 converted from the current one to gamma space
  15366. * @returns a new Color4 object
  15367. */
  15368. toGammaSpace(): Color4;
  15369. /**
  15370. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15371. * @param convertedColor defines the Color4 object where to store the gamma space version
  15372. * @returns the unmodified Color4
  15373. */
  15374. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15375. /**
  15376. * Creates a new Color4 from the string containing valid hexadecimal values
  15377. * @param hex defines a string containing valid hexadecimal values
  15378. * @returns a new Color4 object
  15379. */
  15380. static FromHexString(hex: string): Color4;
  15381. /**
  15382. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15383. * @param left defines the start value
  15384. * @param right defines the end value
  15385. * @param amount defines the gradient factor
  15386. * @returns a new Color4 object
  15387. */
  15388. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15389. /**
  15390. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15391. * @param left defines the start value
  15392. * @param right defines the end value
  15393. * @param amount defines the gradient factor
  15394. * @param result defines the Color4 object where to store data
  15395. */
  15396. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15397. /**
  15398. * Creates a new Color4 from the starting index element of the given array
  15399. * @param array defines the source array to read from
  15400. * @param offset defines the offset in the source array
  15401. * @returns a new Color4 object
  15402. */
  15403. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15404. /**
  15405. * Creates a new Color3 from integer values (< 256)
  15406. * @param r defines the red component to read from (value between 0 and 255)
  15407. * @param g defines the green component to read from (value between 0 and 255)
  15408. * @param b defines the blue component to read from (value between 0 and 255)
  15409. * @param a defines the alpha component to read from (value between 0 and 255)
  15410. * @returns a new Color3 object
  15411. */
  15412. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15413. /**
  15414. * Check the content of a given array and convert it to an array containing RGBA data
  15415. * If the original array was already containing count * 4 values then it is returned directly
  15416. * @param colors defines the array to check
  15417. * @param count defines the number of RGBA data to expect
  15418. * @returns an array containing count * 4 values (RGBA)
  15419. */
  15420. static CheckColors4(colors: number[], count: number): number[];
  15421. }
  15422. /**
  15423. * Class representing a vector containing 2 coordinates
  15424. */
  15425. class Vector2 {
  15426. /** defines the first coordinate */
  15427. x: number;
  15428. /** defines the second coordinate */
  15429. y: number;
  15430. /**
  15431. * Creates a new Vector2 from the given x and y coordinates
  15432. * @param x defines the first coordinate
  15433. * @param y defines the second coordinate
  15434. */
  15435. constructor(
  15436. /** defines the first coordinate */
  15437. x: number,
  15438. /** defines the second coordinate */
  15439. y: number);
  15440. /**
  15441. * Gets a string with the Vector2 coordinates
  15442. * @returns a string with the Vector2 coordinates
  15443. */
  15444. toString(): string;
  15445. /**
  15446. * Gets class name
  15447. * @returns the string "Vector2"
  15448. */
  15449. getClassName(): string;
  15450. /**
  15451. * Gets current vector hash code
  15452. * @returns the Vector2 hash code as a number
  15453. */
  15454. getHashCode(): number;
  15455. /**
  15456. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15457. * @param array defines the source array
  15458. * @param index defines the offset in source array
  15459. * @returns the current Vector2
  15460. */
  15461. toArray(array: FloatArray, index?: number): Vector2;
  15462. /**
  15463. * Copy the current vector to an array
  15464. * @returns a new array with 2 elements: the Vector2 coordinates.
  15465. */
  15466. asArray(): number[];
  15467. /**
  15468. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15469. * @param source defines the source Vector2
  15470. * @returns the current updated Vector2
  15471. */
  15472. copyFrom(source: Vector2): Vector2;
  15473. /**
  15474. * Sets the Vector2 coordinates with the given floats
  15475. * @param x defines the first coordinate
  15476. * @param y defines the second coordinate
  15477. * @returns the current updated Vector2
  15478. */
  15479. copyFromFloats(x: number, y: number): Vector2;
  15480. /**
  15481. * Sets the Vector2 coordinates with the given floats
  15482. * @param x defines the first coordinate
  15483. * @param y defines the second coordinate
  15484. * @returns the current updated Vector2
  15485. */
  15486. set(x: number, y: number): Vector2;
  15487. /**
  15488. * Add another vector with the current one
  15489. * @param otherVector defines the other vector
  15490. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15491. */
  15492. add(otherVector: Vector2): Vector2;
  15493. /**
  15494. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15495. * @param otherVector defines the other vector
  15496. * @param result defines the target vector
  15497. * @returns the unmodified current Vector2
  15498. */
  15499. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15500. /**
  15501. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15502. * @param otherVector defines the other vector
  15503. * @returns the current updated Vector2
  15504. */
  15505. addInPlace(otherVector: Vector2): Vector2;
  15506. /**
  15507. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15508. * @param otherVector defines the other vector
  15509. * @returns a new Vector2
  15510. */
  15511. addVector3(otherVector: Vector3): Vector2;
  15512. /**
  15513. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15514. * @param otherVector defines the other vector
  15515. * @returns a new Vector2
  15516. */
  15517. subtract(otherVector: Vector2): Vector2;
  15518. /**
  15519. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15520. * @param otherVector defines the other vector
  15521. * @param result defines the target vector
  15522. * @returns the unmodified current Vector2
  15523. */
  15524. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15525. /**
  15526. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15527. * @param otherVector defines the other vector
  15528. * @returns the current updated Vector2
  15529. */
  15530. subtractInPlace(otherVector: Vector2): Vector2;
  15531. /**
  15532. * Multiplies in place the current Vector2 coordinates by the given ones
  15533. * @param otherVector defines the other vector
  15534. * @returns the current updated Vector2
  15535. */
  15536. multiplyInPlace(otherVector: Vector2): Vector2;
  15537. /**
  15538. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15539. * @param otherVector defines the other vector
  15540. * @returns a new Vector2
  15541. */
  15542. multiply(otherVector: Vector2): Vector2;
  15543. /**
  15544. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15545. * @param otherVector defines the other vector
  15546. * @param result defines the target vector
  15547. * @returns the unmodified current Vector2
  15548. */
  15549. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15550. /**
  15551. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15552. * @param x defines the first coordinate
  15553. * @param y defines the second coordinate
  15554. * @returns a new Vector2
  15555. */
  15556. multiplyByFloats(x: number, y: number): Vector2;
  15557. /**
  15558. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15559. * @param otherVector defines the other vector
  15560. * @returns a new Vector2
  15561. */
  15562. divide(otherVector: Vector2): Vector2;
  15563. /**
  15564. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15565. * @param otherVector defines the other vector
  15566. * @param result defines the target vector
  15567. * @returns the unmodified current Vector2
  15568. */
  15569. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15570. /**
  15571. * Divides the current Vector3 coordinates by the given ones
  15572. * @param otherVector defines the other vector
  15573. * @returns the current updated Vector2
  15574. */
  15575. divideInPlace(otherVector: Vector2): Vector2;
  15576. /**
  15577. * Gets a new Vector2 with current Vector2 negated coordinates
  15578. * @returns a new Vector2
  15579. */
  15580. negate(): Vector2;
  15581. /**
  15582. * Multiply the Vector2 coordinates by scale
  15583. * @param scale defines the scaling factor
  15584. * @returns the current updated Vector2
  15585. */
  15586. scaleInPlace(scale: number): Vector2;
  15587. /**
  15588. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15589. * @param scale defines the scaling factor
  15590. * @returns a new Vector2
  15591. */
  15592. scale(scale: number): Vector2;
  15593. /**
  15594. * Scale the current Vector2 values by a factor to a given Vector2
  15595. * @param scale defines the scale factor
  15596. * @param result defines the Vector2 object where to store the result
  15597. * @returns the unmodified current Vector2
  15598. */
  15599. scaleToRef(scale: number, result: Vector2): Vector2;
  15600. /**
  15601. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15602. * @param scale defines the scale factor
  15603. * @param result defines the Vector2 object where to store the result
  15604. * @returns the unmodified current Vector2
  15605. */
  15606. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15607. /**
  15608. * Gets a boolean if two vectors are equals
  15609. * @param otherVector defines the other vector
  15610. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15611. */
  15612. equals(otherVector: Vector2): boolean;
  15613. /**
  15614. * Gets a boolean if two vectors are equals (using an epsilon value)
  15615. * @param otherVector defines the other vector
  15616. * @param epsilon defines the minimal distance to consider equality
  15617. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15618. */
  15619. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15620. /**
  15621. * Gets the length of the vector
  15622. * @returns the vector length (float)
  15623. */
  15624. length(): number;
  15625. /**
  15626. * Gets the vector squared length
  15627. * @returns the vector squared length (float)
  15628. */
  15629. lengthSquared(): number;
  15630. /**
  15631. * Normalize the vector
  15632. * @returns the current updated Vector2
  15633. */
  15634. normalize(): Vector2;
  15635. /**
  15636. * Gets a new Vector2 copied from the Vector2
  15637. * @returns a new Vector2
  15638. */
  15639. clone(): Vector2;
  15640. /**
  15641. * Gets a new Vector2(0, 0)
  15642. * @returns a new Vector2
  15643. */
  15644. static Zero(): Vector2;
  15645. /**
  15646. * Gets a new Vector2(1, 1)
  15647. * @returns a new Vector2
  15648. */
  15649. static One(): Vector2;
  15650. /**
  15651. * Gets a new Vector2 set from the given index element of the given array
  15652. * @param array defines the data source
  15653. * @param offset defines the offset in the data source
  15654. * @returns a new Vector2
  15655. */
  15656. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15657. /**
  15658. * Sets "result" from the given index element of the given array
  15659. * @param array defines the data source
  15660. * @param offset defines the offset in the data source
  15661. * @param result defines the target vector
  15662. */
  15663. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15664. /**
  15665. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15666. * @param value1 defines 1st point of control
  15667. * @param value2 defines 2nd point of control
  15668. * @param value3 defines 3rd point of control
  15669. * @param value4 defines 4th point of control
  15670. * @param amount defines the interpolation factor
  15671. * @returns a new Vector2
  15672. */
  15673. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15674. /**
  15675. * 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".
  15676. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15677. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15678. * @param value defines the value to clamp
  15679. * @param min defines the lower limit
  15680. * @param max defines the upper limit
  15681. * @returns a new Vector2
  15682. */
  15683. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15684. /**
  15685. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15686. * @param value1 defines the 1st control point
  15687. * @param tangent1 defines the outgoing tangent
  15688. * @param value2 defines the 2nd control point
  15689. * @param tangent2 defines the incoming tangent
  15690. * @param amount defines the interpolation factor
  15691. * @returns a new Vector2
  15692. */
  15693. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15694. /**
  15695. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15696. * @param start defines the start vector
  15697. * @param end defines the end vector
  15698. * @param amount defines the interpolation factor
  15699. * @returns a new Vector2
  15700. */
  15701. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15702. /**
  15703. * Gets the dot product of the vector "left" and the vector "right"
  15704. * @param left defines first vector
  15705. * @param right defines second vector
  15706. * @returns the dot product (float)
  15707. */
  15708. static Dot(left: Vector2, right: Vector2): number;
  15709. /**
  15710. * Returns a new Vector2 equal to the normalized given vector
  15711. * @param vector defines the vector to normalize
  15712. * @returns a new Vector2
  15713. */
  15714. static Normalize(vector: Vector2): Vector2;
  15715. /**
  15716. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15717. * @param left defines 1st vector
  15718. * @param right defines 2nd vector
  15719. * @returns a new Vector2
  15720. */
  15721. static Minimize(left: Vector2, right: Vector2): Vector2;
  15722. /**
  15723. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15724. * @param left defines 1st vector
  15725. * @param right defines 2nd vector
  15726. * @returns a new Vector2
  15727. */
  15728. static Maximize(left: Vector2, right: Vector2): Vector2;
  15729. /**
  15730. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15731. * @param vector defines the vector to transform
  15732. * @param transformation defines the matrix to apply
  15733. * @returns a new Vector2
  15734. */
  15735. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15736. /**
  15737. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15738. * @param vector defines the vector to transform
  15739. * @param transformation defines the matrix to apply
  15740. * @param result defines the target vector
  15741. */
  15742. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15743. /**
  15744. * Determines if a given vector is included in a triangle
  15745. * @param p defines the vector to test
  15746. * @param p0 defines 1st triangle point
  15747. * @param p1 defines 2nd triangle point
  15748. * @param p2 defines 3rd triangle point
  15749. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15750. */
  15751. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15752. /**
  15753. * Gets the distance between the vectors "value1" and "value2"
  15754. * @param value1 defines first vector
  15755. * @param value2 defines second vector
  15756. * @returns the distance between vectors
  15757. */
  15758. static Distance(value1: Vector2, value2: Vector2): number;
  15759. /**
  15760. * Returns the squared distance between the vectors "value1" and "value2"
  15761. * @param value1 defines first vector
  15762. * @param value2 defines second vector
  15763. * @returns the squared distance between vectors
  15764. */
  15765. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15766. /**
  15767. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15768. * @param value1 defines first vector
  15769. * @param value2 defines second vector
  15770. * @returns a new Vector2
  15771. */
  15772. static Center(value1: Vector2, value2: Vector2): Vector2;
  15773. /**
  15774. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15775. * @param p defines the middle point
  15776. * @param segA defines one point of the segment
  15777. * @param segB defines the other point of the segment
  15778. * @returns the shortest distance
  15779. */
  15780. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15781. }
  15782. /**
  15783. * Classed used to store (x,y,z) vector representation
  15784. * A Vector3 is the main object used in 3D geometry
  15785. * It can represent etiher the coordinates of a point the space, either a direction
  15786. * Reminder: Babylon.js uses a left handed forward facing system
  15787. */
  15788. class Vector3 {
  15789. /**
  15790. * Defines the first coordinates (on X axis)
  15791. */
  15792. x: number;
  15793. /**
  15794. * Defines the second coordinates (on Y axis)
  15795. */
  15796. y: number;
  15797. /**
  15798. * Defines the third coordinates (on Z axis)
  15799. */
  15800. z: number;
  15801. /**
  15802. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15803. * @param x defines the first coordinates (on X axis)
  15804. * @param y defines the second coordinates (on Y axis)
  15805. * @param z defines the third coordinates (on Z axis)
  15806. */
  15807. constructor(
  15808. /**
  15809. * Defines the first coordinates (on X axis)
  15810. */
  15811. x: number,
  15812. /**
  15813. * Defines the second coordinates (on Y axis)
  15814. */
  15815. y: number,
  15816. /**
  15817. * Defines the third coordinates (on Z axis)
  15818. */
  15819. z: number);
  15820. /**
  15821. * Creates a string representation of the Vector3
  15822. * @returns a string with the Vector3 coordinates.
  15823. */
  15824. toString(): string;
  15825. /**
  15826. * Gets the class name
  15827. * @returns the string "Vector3"
  15828. */
  15829. getClassName(): string;
  15830. /**
  15831. * Creates the Vector3 hash code
  15832. * @returns a number which tends to be unique between Vector3 instances
  15833. */
  15834. getHashCode(): number;
  15835. /**
  15836. * Creates an array containing three elements : the coordinates of the Vector3
  15837. * @returns a new array of numbers
  15838. */
  15839. asArray(): number[];
  15840. /**
  15841. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15842. * @param array defines the destination array
  15843. * @param index defines the offset in the destination array
  15844. * @returns the current Vector3
  15845. */
  15846. toArray(array: FloatArray, index?: number): Vector3;
  15847. /**
  15848. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15849. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15850. */
  15851. toQuaternion(): Quaternion;
  15852. /**
  15853. * Adds the given vector to the current Vector3
  15854. * @param otherVector defines the second operand
  15855. * @returns the current updated Vector3
  15856. */
  15857. addInPlace(otherVector: Vector3): Vector3;
  15858. /**
  15859. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15860. * @param otherVector defines the second operand
  15861. * @returns the resulting Vector3
  15862. */
  15863. add(otherVector: Vector3): Vector3;
  15864. /**
  15865. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15866. * @param otherVector defines the second operand
  15867. * @param result defines the Vector3 object where to store the result
  15868. * @returns the current Vector3
  15869. */
  15870. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15871. /**
  15872. * Subtract the given vector from the current Vector3
  15873. * @param otherVector defines the second operand
  15874. * @returns the current updated Vector3
  15875. */
  15876. subtractInPlace(otherVector: Vector3): Vector3;
  15877. /**
  15878. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15879. * @param otherVector defines the second operand
  15880. * @returns the resulting Vector3
  15881. */
  15882. subtract(otherVector: Vector3): Vector3;
  15883. /**
  15884. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15885. * @param otherVector defines the second operand
  15886. * @param result defines the Vector3 object where to store the result
  15887. * @returns the current Vector3
  15888. */
  15889. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15890. /**
  15891. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15892. * @param x defines the x coordinate of the operand
  15893. * @param y defines the y coordinate of the operand
  15894. * @param z defines the z coordinate of the operand
  15895. * @returns the resulting Vector3
  15896. */
  15897. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15898. /**
  15899. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15900. * @param x defines the x coordinate of the operand
  15901. * @param y defines the y coordinate of the operand
  15902. * @param z defines the z coordinate of the operand
  15903. * @param result defines the Vector3 object where to store the result
  15904. * @returns the current Vector3
  15905. */
  15906. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15907. /**
  15908. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15909. * @returns a new Vector3
  15910. */
  15911. negate(): Vector3;
  15912. /**
  15913. * Multiplies the Vector3 coordinates by the float "scale"
  15914. * @param scale defines the multiplier factor
  15915. * @returns the current updated Vector3
  15916. */
  15917. scaleInPlace(scale: number): Vector3;
  15918. /**
  15919. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15920. * @param scale defines the multiplier factor
  15921. * @returns a new Vector3
  15922. */
  15923. scale(scale: number): Vector3;
  15924. /**
  15925. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15926. * @param scale defines the multiplier factor
  15927. * @param result defines the Vector3 object where to store the result
  15928. * @returns the current Vector3
  15929. */
  15930. scaleToRef(scale: number, result: Vector3): Vector3;
  15931. /**
  15932. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15933. * @param scale defines the scale factor
  15934. * @param result defines the Vector3 object where to store the result
  15935. * @returns the unmodified current Vector3
  15936. */
  15937. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15938. /**
  15939. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15940. * @param otherVector defines the second operand
  15941. * @returns true if both vectors are equals
  15942. */
  15943. equals(otherVector: Vector3): boolean;
  15944. /**
  15945. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15946. * @param otherVector defines the second operand
  15947. * @param epsilon defines the minimal distance to define values as equals
  15948. * @returns true if both vectors are distant less than epsilon
  15949. */
  15950. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15951. /**
  15952. * Returns true if the current Vector3 coordinates equals the given floats
  15953. * @param x defines the x coordinate of the operand
  15954. * @param y defines the y coordinate of the operand
  15955. * @param z defines the z coordinate of the operand
  15956. * @returns true if both vectors are equals
  15957. */
  15958. equalsToFloats(x: number, y: number, z: number): boolean;
  15959. /**
  15960. * Multiplies the current Vector3 coordinates by the given ones
  15961. * @param otherVector defines the second operand
  15962. * @returns the current updated Vector3
  15963. */
  15964. multiplyInPlace(otherVector: Vector3): Vector3;
  15965. /**
  15966. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15967. * @param otherVector defines the second operand
  15968. * @returns the new Vector3
  15969. */
  15970. multiply(otherVector: Vector3): Vector3;
  15971. /**
  15972. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  15973. * @param otherVector defines the second operand
  15974. * @param result defines the Vector3 object where to store the result
  15975. * @returns the current Vector3
  15976. */
  15977. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15978. /**
  15979. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15980. * @param x defines the x coordinate of the operand
  15981. * @param y defines the y coordinate of the operand
  15982. * @param z defines the z coordinate of the operand
  15983. * @returns the new Vector3
  15984. */
  15985. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15986. /**
  15987. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15988. * @param otherVector defines the second operand
  15989. * @returns the new Vector3
  15990. */
  15991. divide(otherVector: Vector3): Vector3;
  15992. /**
  15993. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15994. * @param otherVector defines the second operand
  15995. * @param result defines the Vector3 object where to store the result
  15996. * @returns the current Vector3
  15997. */
  15998. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15999. /**
  16000. * Divides the current Vector3 coordinates by the given ones.
  16001. * @param otherVector defines the second operand
  16002. * @returns the current updated Vector3
  16003. */
  16004. divideInPlace(otherVector: Vector3): Vector3;
  16005. /**
  16006. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16007. * @param other defines the second operand
  16008. * @returns the current updated Vector3
  16009. */
  16010. minimizeInPlace(other: Vector3): Vector3;
  16011. /**
  16012. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16013. * @param other defines the second operand
  16014. * @returns the current updated Vector3
  16015. */
  16016. maximizeInPlace(other: Vector3): Vector3;
  16017. /**
  16018. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16019. */
  16020. readonly isNonUniform: boolean;
  16021. /**
  16022. * Gets the length of the Vector3
  16023. * @returns the length of the Vecto3
  16024. */
  16025. length(): number;
  16026. /**
  16027. * Gets the squared length of the Vector3
  16028. * @returns squared length of the Vector3
  16029. */
  16030. lengthSquared(): number;
  16031. /**
  16032. * Normalize the current Vector3.
  16033. * Please note that this is an in place operation.
  16034. * @returns the current updated Vector3
  16035. */
  16036. normalize(): Vector3;
  16037. /**
  16038. * Normalize the current Vector3 to a new vector
  16039. * @returns the new Vector3
  16040. */
  16041. normalizeToNew(): Vector3;
  16042. /**
  16043. * Normalize the current Vector3 to the reference
  16044. * @param reference define the Vector3 to update
  16045. * @returns the updated Vector3
  16046. */
  16047. normalizeToRef(reference: Vector3): Vector3;
  16048. /**
  16049. * Creates a new Vector3 copied from the current Vector3
  16050. * @returns the new Vector3
  16051. */
  16052. clone(): Vector3;
  16053. /**
  16054. * Copies the given vector coordinates to the current Vector3 ones
  16055. * @param source defines the source Vector3
  16056. * @returns the current updated Vector3
  16057. */
  16058. copyFrom(source: Vector3): Vector3;
  16059. /**
  16060. * Copies the given floats to the current Vector3 coordinates
  16061. * @param x defines the x coordinate of the operand
  16062. * @param y defines the y coordinate of the operand
  16063. * @param z defines the z coordinate of the operand
  16064. * @returns the current updated Vector3
  16065. */
  16066. copyFromFloats(x: number, y: number, z: number): Vector3;
  16067. /**
  16068. * Copies the given floats to the current Vector3 coordinates
  16069. * @param x defines the x coordinate of the operand
  16070. * @param y defines the y coordinate of the operand
  16071. * @param z defines the z coordinate of the operand
  16072. * @returns the current updated Vector3
  16073. */
  16074. set(x: number, y: number, z: number): Vector3;
  16075. /**
  16076. * Get the clip factor between two vectors
  16077. * @param vector0 defines the first operand
  16078. * @param vector1 defines the second operand
  16079. * @param axis defines the axis to use
  16080. * @param size defines the size along the axis
  16081. * @returns the clip factor
  16082. */
  16083. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16084. /**
  16085. * Get angle between two vectors
  16086. * @param vector0 angle between vector0 and vector1
  16087. * @param vector1 angle between vector0 and vector1
  16088. * @param normal direction of the normal
  16089. * @return the angle between vector0 and vector1
  16090. */
  16091. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16092. /**
  16093. * Returns a new Vector3 set from the index "offset" of the given array
  16094. * @param array defines the source array
  16095. * @param offset defines the offset in the source array
  16096. * @returns the new Vector3
  16097. */
  16098. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16099. /**
  16100. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16101. * This function is deprecated. Use FromArray instead
  16102. * @param array defines the source array
  16103. * @param offset defines the offset in the source array
  16104. * @returns the new Vector3
  16105. */
  16106. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16107. /**
  16108. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16109. * @param array defines the source array
  16110. * @param offset defines the offset in the source array
  16111. * @param result defines the Vector3 where to store the result
  16112. */
  16113. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16114. /**
  16115. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16116. * This function is deprecated. Use FromArrayToRef instead.
  16117. * @param array defines the source array
  16118. * @param offset defines the offset in the source array
  16119. * @param result defines the Vector3 where to store the result
  16120. */
  16121. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16122. /**
  16123. * Sets the given vector "result" with the given floats.
  16124. * @param x defines the x coordinate of the source
  16125. * @param y defines the y coordinate of the source
  16126. * @param z defines the z coordinate of the source
  16127. * @param result defines the Vector3 where to store the result
  16128. */
  16129. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16130. /**
  16131. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16132. * @returns a new empty Vector3
  16133. */
  16134. static Zero(): Vector3;
  16135. /**
  16136. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16137. * @returns a new unit Vector3
  16138. */
  16139. static One(): Vector3;
  16140. /**
  16141. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16142. * @returns a new up Vector3
  16143. */
  16144. static Up(): Vector3;
  16145. /**
  16146. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16147. * @returns a new down Vector3
  16148. */
  16149. static Down(): Vector3;
  16150. /**
  16151. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16152. * @returns a new forward Vector3
  16153. */
  16154. static Forward(): Vector3;
  16155. /**
  16156. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16157. * @returns a new right Vector3
  16158. */
  16159. static Right(): Vector3;
  16160. /**
  16161. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16162. * @returns a new left Vector3
  16163. */
  16164. static Left(): Vector3;
  16165. /**
  16166. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16167. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16168. * @param vector defines the Vector3 to transform
  16169. * @param transformation defines the transformation matrix
  16170. * @returns the transformed Vector3
  16171. */
  16172. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16173. /**
  16174. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16175. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16176. * @param vector defines the Vector3 to transform
  16177. * @param transformation defines the transformation matrix
  16178. * @param result defines the Vector3 where to store the result
  16179. */
  16180. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16181. /**
  16182. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16183. * This method computes tranformed coordinates only, not transformed direction vectors
  16184. * @param x define the x coordinate of the source vector
  16185. * @param y define the y coordinate of the source vector
  16186. * @param z define the z coordinate of the source vector
  16187. * @param transformation defines the transformation matrix
  16188. * @param result defines the Vector3 where to store the result
  16189. */
  16190. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16191. /**
  16192. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16193. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16194. * @param vector defines the Vector3 to transform
  16195. * @param transformation defines the transformation matrix
  16196. * @returns the new Vector3
  16197. */
  16198. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16199. /**
  16200. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16201. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16202. * @param vector defines the Vector3 to transform
  16203. * @param transformation defines the transformation matrix
  16204. * @param result defines the Vector3 where to store the result
  16205. */
  16206. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16207. /**
  16208. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16209. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16210. * @param x define the x coordinate of the source vector
  16211. * @param y define the y coordinate of the source vector
  16212. * @param z define the z coordinate of the source vector
  16213. * @param transformation defines the transformation matrix
  16214. * @param result defines the Vector3 where to store the result
  16215. */
  16216. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16217. /**
  16218. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16219. * @param value1 defines the first control point
  16220. * @param value2 defines the second control point
  16221. * @param value3 defines the third control point
  16222. * @param value4 defines the fourth control point
  16223. * @param amount defines the amount on the spline to use
  16224. * @returns the new Vector3
  16225. */
  16226. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16227. /**
  16228. * 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"
  16229. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16230. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16231. * @param value defines the current value
  16232. * @param min defines the lower range value
  16233. * @param max defines the upper range value
  16234. * @returns the new Vector3
  16235. */
  16236. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16237. /**
  16238. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16239. * @param value1 defines the first control point
  16240. * @param tangent1 defines the first tangent vector
  16241. * @param value2 defines the second control point
  16242. * @param tangent2 defines the second tangent vector
  16243. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16244. * @returns the new Vector3
  16245. */
  16246. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16247. /**
  16248. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16249. * @param start defines the start value
  16250. * @param end defines the end value
  16251. * @param amount max defines amount between both (between 0 and 1)
  16252. * @returns the new Vector3
  16253. */
  16254. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16255. /**
  16256. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16257. * @param start defines the start value
  16258. * @param end defines the end value
  16259. * @param amount max defines amount between both (between 0 and 1)
  16260. * @param result defines the Vector3 where to store the result
  16261. */
  16262. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16263. /**
  16264. * Returns the dot product (float) between the vectors "left" and "right"
  16265. * @param left defines the left operand
  16266. * @param right defines the right operand
  16267. * @returns the dot product
  16268. */
  16269. static Dot(left: Vector3, right: Vector3): number;
  16270. /**
  16271. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16272. * The cross product is then orthogonal to both "left" and "right"
  16273. * @param left defines the left operand
  16274. * @param right defines the right operand
  16275. * @returns the cross product
  16276. */
  16277. static Cross(left: Vector3, right: Vector3): Vector3;
  16278. /**
  16279. * Sets the given vector "result" with the cross product of "left" and "right"
  16280. * The cross product is then orthogonal to both "left" and "right"
  16281. * @param left defines the left operand
  16282. * @param right defines the right operand
  16283. * @param result defines the Vector3 where to store the result
  16284. */
  16285. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16286. /**
  16287. * Returns a new Vector3 as the normalization of the given vector
  16288. * @param vector defines the Vector3 to normalize
  16289. * @returns the new Vector3
  16290. */
  16291. static Normalize(vector: Vector3): Vector3;
  16292. /**
  16293. * Sets the given vector "result" with the normalization of the given first vector
  16294. * @param vector defines the Vector3 to normalize
  16295. * @param result defines the Vector3 where to store the result
  16296. */
  16297. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16298. private static _viewportMatrixCache;
  16299. /**
  16300. * Project a Vector3 onto screen space
  16301. * @param vector defines the Vector3 to project
  16302. * @param world defines the world matrix to use
  16303. * @param transform defines the transform (view x projection) matrix to use
  16304. * @param viewport defines the screen viewport to use
  16305. * @returns the new Vector3
  16306. */
  16307. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16308. /**
  16309. * Unproject from screen space to object space
  16310. * @param source defines the screen space Vector3 to use
  16311. * @param viewportWidth defines the current width of the viewport
  16312. * @param viewportHeight defines the current height of the viewport
  16313. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16314. * @param transform defines the transform (view x projection) matrix to use
  16315. * @returns the new Vector3
  16316. */
  16317. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16318. /**
  16319. * Unproject from screen space to object space
  16320. * @param source defines the screen space Vector3 to use
  16321. * @param viewportWidth defines the current width of the viewport
  16322. * @param viewportHeight defines the current height of the viewport
  16323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16324. * @param view defines the view matrix to use
  16325. * @param projection defines the projection matrix to use
  16326. * @returns the new Vector3
  16327. */
  16328. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16329. /**
  16330. * Unproject from screen space to object space
  16331. * @param source defines the screen space Vector3 to use
  16332. * @param viewportWidth defines the current width of the viewport
  16333. * @param viewportHeight defines the current height of the viewport
  16334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16335. * @param view defines the view matrix to use
  16336. * @param projection defines the projection matrix to use
  16337. * @param result defines the Vector3 where to store the result
  16338. */
  16339. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16340. /**
  16341. * Unproject from screen space to object space
  16342. * @param sourceX defines the screen space x coordinate to use
  16343. * @param sourceY defines the screen space y coordinate to use
  16344. * @param sourceZ defines the screen space z coordinate to use
  16345. * @param viewportWidth defines the current width of the viewport
  16346. * @param viewportHeight defines the current height of the viewport
  16347. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16348. * @param view defines the view matrix to use
  16349. * @param projection defines the projection matrix to use
  16350. * @param result defines the Vector3 where to store the result
  16351. */
  16352. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16353. /**
  16354. * Gets the minimal coordinate values between two Vector3
  16355. * @param left defines the first operand
  16356. * @param right defines the second operand
  16357. * @returns the new Vector3
  16358. */
  16359. static Minimize(left: Vector3, right: Vector3): Vector3;
  16360. /**
  16361. * Gets the maximal coordinate values between two Vector3
  16362. * @param left defines the first operand
  16363. * @param right defines the second operand
  16364. * @returns the new Vector3
  16365. */
  16366. static Maximize(left: Vector3, right: Vector3): Vector3;
  16367. /**
  16368. * Returns the distance between the vectors "value1" and "value2"
  16369. * @param value1 defines the first operand
  16370. * @param value2 defines the second operand
  16371. * @returns the distance
  16372. */
  16373. static Distance(value1: Vector3, value2: Vector3): number;
  16374. /**
  16375. * Returns the squared distance between the vectors "value1" and "value2"
  16376. * @param value1 defines the first operand
  16377. * @param value2 defines the second operand
  16378. * @returns the squared distance
  16379. */
  16380. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16381. /**
  16382. * Returns a new Vector3 located at the center between "value1" and "value2"
  16383. * @param value1 defines the first operand
  16384. * @param value2 defines the second operand
  16385. * @returns the new Vector3
  16386. */
  16387. static Center(value1: Vector3, value2: Vector3): Vector3;
  16388. /**
  16389. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16390. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16391. * to something in order to rotate it from its local system to the given target system
  16392. * Note: axis1, axis2 and axis3 are normalized during this operation
  16393. * @param axis1 defines the first axis
  16394. * @param axis2 defines the second axis
  16395. * @param axis3 defines the third axis
  16396. * @returns a new Vector3
  16397. */
  16398. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16399. /**
  16400. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16401. * @param axis1 defines the first axis
  16402. * @param axis2 defines the second axis
  16403. * @param axis3 defines the third axis
  16404. * @param ref defines the Vector3 where to store the result
  16405. */
  16406. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16407. }
  16408. class Vector4 {
  16409. x: number;
  16410. y: number;
  16411. z: number;
  16412. w: number;
  16413. /**
  16414. * Creates a Vector4 object from the given floats.
  16415. */
  16416. constructor(x: number, y: number, z: number, w: number);
  16417. /**
  16418. * Returns the string with the Vector4 coordinates.
  16419. */
  16420. toString(): string;
  16421. /**
  16422. * Returns the string "Vector4".
  16423. */
  16424. getClassName(): string;
  16425. /**
  16426. * Returns the Vector4 hash code.
  16427. */
  16428. getHashCode(): number;
  16429. /**
  16430. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16431. */
  16432. asArray(): number[];
  16433. /**
  16434. * Populates the given array from the given index with the Vector4 coordinates.
  16435. * Returns the Vector4.
  16436. */
  16437. toArray(array: FloatArray, index?: number): Vector4;
  16438. /**
  16439. * Adds the given vector to the current Vector4.
  16440. * Returns the updated Vector4.
  16441. */
  16442. addInPlace(otherVector: Vector4): Vector4;
  16443. /**
  16444. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16445. */
  16446. add(otherVector: Vector4): Vector4;
  16447. /**
  16448. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16449. * Returns the current Vector4.
  16450. */
  16451. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16452. /**
  16453. * Subtract in place the given vector from the current Vector4.
  16454. * Returns the updated Vector4.
  16455. */
  16456. subtractInPlace(otherVector: Vector4): Vector4;
  16457. /**
  16458. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16459. */
  16460. subtract(otherVector: Vector4): Vector4;
  16461. /**
  16462. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16463. * Returns the current Vector4.
  16464. */
  16465. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16466. /**
  16467. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16468. */
  16469. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16470. /**
  16471. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16472. * Returns the current Vector4.
  16473. */
  16474. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16475. /**
  16476. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16477. */
  16478. negate(): Vector4;
  16479. /**
  16480. * Multiplies the current Vector4 coordinates by scale (float).
  16481. * Returns the updated Vector4.
  16482. */
  16483. scaleInPlace(scale: number): Vector4;
  16484. /**
  16485. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16486. */
  16487. scale(scale: number): Vector4;
  16488. /**
  16489. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16490. * Returns the current Vector4.
  16491. */
  16492. scaleToRef(scale: number, result: Vector4): Vector4;
  16493. /**
  16494. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16495. * @param scale defines the scale factor
  16496. * @param result defines the Vector4 object where to store the result
  16497. * @returns the unmodified current Vector4
  16498. */
  16499. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16500. /**
  16501. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16502. */
  16503. equals(otherVector: Vector4): boolean;
  16504. /**
  16505. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16506. */
  16507. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16508. /**
  16509. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16510. */
  16511. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16512. /**
  16513. * Multiplies in place the current Vector4 by the given one.
  16514. * Returns the updated Vector4.
  16515. */
  16516. multiplyInPlace(otherVector: Vector4): Vector4;
  16517. /**
  16518. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16519. */
  16520. multiply(otherVector: Vector4): Vector4;
  16521. /**
  16522. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16523. * Returns the current Vector4.
  16524. */
  16525. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16526. /**
  16527. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16528. */
  16529. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16530. /**
  16531. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16532. */
  16533. divide(otherVector: Vector4): Vector4;
  16534. /**
  16535. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16536. * Returns the current Vector4.
  16537. */
  16538. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16539. /**
  16540. * Divides the current Vector3 coordinates by the given ones.
  16541. * @returns the updated Vector3.
  16542. */
  16543. divideInPlace(otherVector: Vector4): Vector4;
  16544. /**
  16545. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16546. * @param other defines the second operand
  16547. * @returns the current updated Vector4
  16548. */
  16549. minimizeInPlace(other: Vector4): Vector4;
  16550. /**
  16551. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16552. * @param other defines the second operand
  16553. * @returns the current updated Vector4
  16554. */
  16555. maximizeInPlace(other: Vector4): Vector4;
  16556. /**
  16557. * Returns the Vector4 length (float).
  16558. */
  16559. length(): number;
  16560. /**
  16561. * Returns the Vector4 squared length (float).
  16562. */
  16563. lengthSquared(): number;
  16564. /**
  16565. * Normalizes in place the Vector4.
  16566. * Returns the updated Vector4.
  16567. */
  16568. normalize(): Vector4;
  16569. /**
  16570. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16571. */
  16572. toVector3(): Vector3;
  16573. /**
  16574. * Returns a new Vector4 copied from the current one.
  16575. */
  16576. clone(): Vector4;
  16577. /**
  16578. * Updates the current Vector4 with the given one coordinates.
  16579. * Returns the updated Vector4.
  16580. */
  16581. copyFrom(source: Vector4): Vector4;
  16582. /**
  16583. * Updates the current Vector4 coordinates with the given floats.
  16584. * Returns the updated Vector4.
  16585. */
  16586. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16587. /**
  16588. * Updates the current Vector4 coordinates with the given floats.
  16589. * Returns the updated Vector4.
  16590. */
  16591. set(x: number, y: number, z: number, w: number): Vector4;
  16592. /**
  16593. * Returns a new Vector4 set from the starting index of the given array.
  16594. */
  16595. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16596. /**
  16597. * Updates the given vector "result" from the starting index of the given array.
  16598. */
  16599. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16600. /**
  16601. * Updates the given vector "result" from the starting index of the given Float32Array.
  16602. */
  16603. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16604. /**
  16605. * Updates the given vector "result" coordinates from the given floats.
  16606. */
  16607. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16608. /**
  16609. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16610. */
  16611. static Zero(): Vector4;
  16612. /**
  16613. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16614. */
  16615. static One(): Vector4;
  16616. /**
  16617. * Returns a new normalized Vector4 from the given one.
  16618. */
  16619. static Normalize(vector: Vector4): Vector4;
  16620. /**
  16621. * Updates the given vector "result" from the normalization of the given one.
  16622. */
  16623. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16624. static Minimize(left: Vector4, right: Vector4): Vector4;
  16625. static Maximize(left: Vector4, right: Vector4): Vector4;
  16626. /**
  16627. * Returns the distance (float) between the vectors "value1" and "value2".
  16628. */
  16629. static Distance(value1: Vector4, value2: Vector4): number;
  16630. /**
  16631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16632. */
  16633. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16634. /**
  16635. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16636. */
  16637. static Center(value1: Vector4, value2: Vector4): Vector4;
  16638. /**
  16639. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16640. * This methods computes transformed normalized direction vectors only.
  16641. */
  16642. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16643. /**
  16644. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16645. * This methods computes transformed normalized direction vectors only.
  16646. */
  16647. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16648. /**
  16649. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16650. * This methods computes transformed normalized direction vectors only.
  16651. */
  16652. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16653. }
  16654. interface ISize {
  16655. width: number;
  16656. height: number;
  16657. }
  16658. class Size implements ISize {
  16659. width: number;
  16660. height: number;
  16661. /**
  16662. * Creates a Size object from the given width and height (floats).
  16663. */
  16664. constructor(width: number, height: number);
  16665. toString(): string;
  16666. /**
  16667. * Returns the string "Size"
  16668. */
  16669. getClassName(): string;
  16670. /**
  16671. * Returns the Size hash code.
  16672. */
  16673. getHashCode(): number;
  16674. /**
  16675. * Updates the current size from the given one.
  16676. * Returns the updated Size.
  16677. */
  16678. copyFrom(src: Size): void;
  16679. /**
  16680. * Updates in place the current Size from the given floats.
  16681. * Returns the updated Size.
  16682. */
  16683. copyFromFloats(width: number, height: number): Size;
  16684. /**
  16685. * Updates in place the current Size from the given floats.
  16686. * Returns the updated Size.
  16687. */
  16688. set(width: number, height: number): Size;
  16689. /**
  16690. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16691. */
  16692. multiplyByFloats(w: number, h: number): Size;
  16693. /**
  16694. * Returns a new Size copied from the given one.
  16695. */
  16696. clone(): Size;
  16697. /**
  16698. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16699. */
  16700. equals(other: Size): boolean;
  16701. /**
  16702. * Returns the surface of the Size : width * height (float).
  16703. */
  16704. readonly surface: number;
  16705. /**
  16706. * Returns a new Size set to (0.0, 0.0)
  16707. */
  16708. static Zero(): Size;
  16709. /**
  16710. * Returns a new Size set as the addition result of the current Size and the given one.
  16711. */
  16712. add(otherSize: Size): Size;
  16713. /**
  16714. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16715. */
  16716. subtract(otherSize: Size): Size;
  16717. /**
  16718. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16719. */
  16720. static Lerp(start: Size, end: Size, amount: number): Size;
  16721. }
  16722. /**
  16723. * Class used to store quaternion data
  16724. * @see https://en.wikipedia.org/wiki/Quaternion
  16725. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16726. */
  16727. class Quaternion {
  16728. /** defines the first component (0 by default) */
  16729. x: number;
  16730. /** defines the second component (0 by default) */
  16731. y: number;
  16732. /** defines the third component (0 by default) */
  16733. z: number;
  16734. /** defines the fourth component (1.0 by default) */
  16735. w: number;
  16736. /**
  16737. * Creates a new Quaternion from the given floats
  16738. * @param x defines the first component (0 by default)
  16739. * @param y defines the second component (0 by default)
  16740. * @param z defines the third component (0 by default)
  16741. * @param w defines the fourth component (1.0 by default)
  16742. */
  16743. constructor(
  16744. /** defines the first component (0 by default) */
  16745. x?: number,
  16746. /** defines the second component (0 by default) */
  16747. y?: number,
  16748. /** defines the third component (0 by default) */
  16749. z?: number,
  16750. /** defines the fourth component (1.0 by default) */
  16751. w?: number);
  16752. /**
  16753. * Gets a string representation for the current quaternion
  16754. * @returns a string with the Quaternion coordinates
  16755. */
  16756. toString(): string;
  16757. /**
  16758. * Gets the class name of the quaternion
  16759. * @returns the string "Quaternion"
  16760. */
  16761. getClassName(): string;
  16762. /**
  16763. * Gets a hash code for this quaternion
  16764. * @returns the quaternion hash code
  16765. */
  16766. getHashCode(): number;
  16767. /**
  16768. * Copy the quaternion to an array
  16769. * @returns a new array populated with 4 elements from the quaternion coordinates
  16770. */
  16771. asArray(): number[];
  16772. /**
  16773. * Check if two quaternions are equals
  16774. * @param otherQuaternion defines the second operand
  16775. * @return true if the current quaternion and the given one coordinates are strictly equals
  16776. */
  16777. equals(otherQuaternion: Quaternion): boolean;
  16778. /**
  16779. * Clone the current quaternion
  16780. * @returns a new quaternion copied from the current one
  16781. */
  16782. clone(): Quaternion;
  16783. /**
  16784. * Copy a quaternion to the current one
  16785. * @param other defines the other quaternion
  16786. * @returns the updated current quaternion
  16787. */
  16788. copyFrom(other: Quaternion): Quaternion;
  16789. /**
  16790. * Updates the current quaternion with the given float coordinates
  16791. * @param x defines the x coordinate
  16792. * @param y defines the y coordinate
  16793. * @param z defines the z coordinate
  16794. * @param w defines the w coordinate
  16795. * @returns the updated current quaternion
  16796. */
  16797. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16798. /**
  16799. * Updates the current quaternion from the given float coordinates
  16800. * @param x defines the x coordinate
  16801. * @param y defines the y coordinate
  16802. * @param z defines the z coordinate
  16803. * @param w defines the w coordinate
  16804. * @returns the updated current quaternion
  16805. */
  16806. set(x: number, y: number, z: number, w: number): Quaternion;
  16807. /**
  16808. * Adds two quaternions
  16809. * @param other defines the second operand
  16810. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16811. */
  16812. add(other: Quaternion): Quaternion;
  16813. /**
  16814. * Add a quaternion to the current one
  16815. * @param other defines the quaternion to add
  16816. * @returns the current quaternion
  16817. */
  16818. addInPlace(other: Quaternion): Quaternion;
  16819. /**
  16820. * Subtract two quaternions
  16821. * @param other defines the second operand
  16822. * @returns a new quaternion as the subtraction result of the given one from the current one
  16823. */
  16824. subtract(other: Quaternion): Quaternion;
  16825. /**
  16826. * Multiplies the current quaternion by a scale factor
  16827. * @param value defines the scale factor
  16828. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16829. */
  16830. scale(value: number): Quaternion;
  16831. /**
  16832. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16833. * @param scale defines the scale factor
  16834. * @param result defines the Quaternion object where to store the result
  16835. * @returns the unmodified current quaternion
  16836. */
  16837. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16838. /**
  16839. * Multiplies in place the current quaternion by a scale factor
  16840. * @param value defines the scale factor
  16841. * @returns the current modified quaternion
  16842. */
  16843. scaleInPlace(value: number): Quaternion;
  16844. /**
  16845. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16846. * @param scale defines the scale factor
  16847. * @param result defines the Quaternion object where to store the result
  16848. * @returns the unmodified current quaternion
  16849. */
  16850. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16851. /**
  16852. * Multiplies two quaternions
  16853. * @param q1 defines the second operand
  16854. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16855. */
  16856. multiply(q1: Quaternion): Quaternion;
  16857. /**
  16858. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16859. * @param q1 defines the second operand
  16860. * @param result defines the target quaternion
  16861. * @returns the current quaternion
  16862. */
  16863. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16864. /**
  16865. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16866. * @param q1 defines the second operand
  16867. * @returns the currentupdated quaternion
  16868. */
  16869. multiplyInPlace(q1: Quaternion): Quaternion;
  16870. /**
  16871. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16872. * @param ref defines the target quaternion
  16873. * @returns the current quaternion
  16874. */
  16875. conjugateToRef(ref: Quaternion): Quaternion;
  16876. /**
  16877. * Conjugates in place (1-q) the current quaternion
  16878. * @returns the current updated quaternion
  16879. */
  16880. conjugateInPlace(): Quaternion;
  16881. /**
  16882. * Conjugates in place (1-q) the current quaternion
  16883. * @returns a new quaternion
  16884. */
  16885. conjugate(): Quaternion;
  16886. /**
  16887. * Gets length of current quaternion
  16888. * @returns the quaternion length (float)
  16889. */
  16890. length(): number;
  16891. /**
  16892. * Normalize in place the current quaternion
  16893. * @returns the current updated quaternion
  16894. */
  16895. normalize(): Quaternion;
  16896. /**
  16897. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16898. * @param order is a reserved parameter and is ignore for now
  16899. * @returns a new Vector3 containing the Euler angles
  16900. */
  16901. toEulerAngles(order?: string): Vector3;
  16902. /**
  16903. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16904. * @param result defines the vector which will be filled with the Euler angles
  16905. * @param order is a reserved parameter and is ignore for now
  16906. * @returns the current unchanged quaternion
  16907. */
  16908. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16909. /**
  16910. * Updates the given rotation matrix with the current quaternion values
  16911. * @param result defines the target matrix
  16912. * @returns the current unchanged quaternion
  16913. */
  16914. toRotationMatrix(result: Matrix): Quaternion;
  16915. /**
  16916. * Updates the current quaternion from the given rotation matrix values
  16917. * @param matrix defines the source matrix
  16918. * @returns the current updated quaternion
  16919. */
  16920. fromRotationMatrix(matrix: Matrix): Quaternion;
  16921. /**
  16922. * Creates a new quaternion from a rotation matrix
  16923. * @param matrix defines the source matrix
  16924. * @returns a new quaternion created from the given rotation matrix values
  16925. */
  16926. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16927. /**
  16928. * Updates the given quaternion with the given rotation matrix values
  16929. * @param matrix defines the source matrix
  16930. * @param result defines the target quaternion
  16931. */
  16932. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16933. /**
  16934. * Returns the dot product (float) between the quaternions "left" and "right"
  16935. * @param left defines the left operand
  16936. * @param right defines the right operand
  16937. * @returns the dot product
  16938. */
  16939. static Dot(left: Quaternion, right: Quaternion): number;
  16940. /**
  16941. * Checks if the two quaternions are close to each other
  16942. * @param quat0 defines the first quaternion to check
  16943. * @param quat1 defines the second quaternion to check
  16944. * @returns true if the two quaternions are close to each other
  16945. */
  16946. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16947. /**
  16948. * Creates an empty quaternion
  16949. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16950. */
  16951. static Zero(): Quaternion;
  16952. /**
  16953. * Inverse a given quaternion
  16954. * @param q defines the source quaternion
  16955. * @returns a new quaternion as the inverted current quaternion
  16956. */
  16957. static Inverse(q: Quaternion): Quaternion;
  16958. /**
  16959. * Creates an identity quaternion
  16960. * @returns the identity quaternion
  16961. */
  16962. static Identity(): Quaternion;
  16963. /**
  16964. * Gets a boolean indicating if the given quaternion is identity
  16965. * @param quaternion defines the quaternion to check
  16966. * @returns true if the quaternion is identity
  16967. */
  16968. static IsIdentity(quaternion: Quaternion): boolean;
  16969. /**
  16970. * Creates a quaternion from a rotation around an axis
  16971. * @param axis defines the axis to use
  16972. * @param angle defines the angle to use
  16973. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16974. */
  16975. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16976. /**
  16977. * Creates a rotation around an axis and stores it into the given quaternion
  16978. * @param axis defines the axis to use
  16979. * @param angle defines the angle to use
  16980. * @param result defines the target quaternion
  16981. * @returns the target quaternion
  16982. */
  16983. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16984. /**
  16985. * Creates a new quaternion from data stored into an array
  16986. * @param array defines the data source
  16987. * @param offset defines the offset in the source array where the data starts
  16988. * @returns a new quaternion
  16989. */
  16990. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16991. /**
  16992. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16993. * @param yaw defines the rotation around Y axis
  16994. * @param pitch defines the rotation around X axis
  16995. * @param roll defines the rotation around Z axis
  16996. * @returns the new quaternion
  16997. */
  16998. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16999. /**
  17000. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17001. * @param yaw defines the rotation around Y axis
  17002. * @param pitch defines the rotation around X axis
  17003. * @param roll defines the rotation around Z axis
  17004. * @param result defines the target quaternion
  17005. */
  17006. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17007. /**
  17008. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17009. * @param alpha defines the rotation around first axis
  17010. * @param beta defines the rotation around second axis
  17011. * @param gamma defines the rotation around third axis
  17012. * @returns the new quaternion
  17013. */
  17014. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17015. /**
  17016. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17017. * @param alpha defines the rotation around first axis
  17018. * @param beta defines the rotation around second axis
  17019. * @param gamma defines the rotation around third axis
  17020. * @param result defines the target quaternion
  17021. */
  17022. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17023. /**
  17024. * 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)
  17025. * @param axis1 defines the first axis
  17026. * @param axis2 defines the second axis
  17027. * @param axis3 defines the third axis
  17028. * @returns the new quaternion
  17029. */
  17030. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17031. /**
  17032. * 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
  17033. * @param axis1 defines the first axis
  17034. * @param axis2 defines the second axis
  17035. * @param axis3 defines the third axis
  17036. * @param ref defines the target quaternion
  17037. */
  17038. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17039. /**
  17040. * Interpolates between two quaternions
  17041. * @param left defines first quaternion
  17042. * @param right defines second quaternion
  17043. * @param amount defines the gradient to use
  17044. * @returns the new interpolated quaternion
  17045. */
  17046. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17047. /**
  17048. * Interpolates between two quaternions and stores it into a target quaternion
  17049. * @param left defines first quaternion
  17050. * @param right defines second quaternion
  17051. * @param amount defines the gradient to use
  17052. * @param result defines the target quaternion
  17053. */
  17054. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17055. /**
  17056. * Interpolate between two quaternions using Hermite interpolation
  17057. * @param value1 defines first quaternion
  17058. * @param tangent1 defines the incoming tangent
  17059. * @param value2 defines second quaternion
  17060. * @param tangent2 defines the outgoing tangent
  17061. * @param amount defines the target quaternion
  17062. * @returns the new interpolated quaternion
  17063. */
  17064. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17065. }
  17066. /**
  17067. * Class used to store matrix data (4x4)
  17068. */
  17069. class Matrix {
  17070. private static _tempQuaternion;
  17071. private static _xAxis;
  17072. private static _yAxis;
  17073. private static _zAxis;
  17074. private static _updateFlagSeed;
  17075. private static _identityReadOnly;
  17076. private _isIdentity;
  17077. private _isIdentityDirty;
  17078. /**
  17079. * Gets the update flag of the matrix which is an unique number for the matrix.
  17080. * It will be incremented every time the matrix data change.
  17081. * You can use it to speed the comparison between two versions of the same matrix.
  17082. */
  17083. updateFlag: number;
  17084. /**
  17085. * Gets or sets the internal data of the matrix
  17086. */
  17087. m: Float32Array;
  17088. /** @hidden */
  17089. _markAsUpdated(): void;
  17090. /**
  17091. * Creates an empty matrix (filled with zeros)
  17092. */
  17093. constructor();
  17094. /**
  17095. * Check if the current matrix is indentity
  17096. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17097. * @returns true is the matrix is the identity matrix
  17098. */
  17099. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17100. /**
  17101. * Gets the determinant of the matrix
  17102. * @returns the matrix determinant
  17103. */
  17104. determinant(): number;
  17105. /**
  17106. * Returns the matrix as a Float32Array
  17107. * @returns the matrix underlying array
  17108. */
  17109. toArray(): Float32Array;
  17110. /**
  17111. * Returns the matrix as a Float32Array
  17112. * @returns the matrix underlying array.
  17113. */
  17114. asArray(): Float32Array;
  17115. /**
  17116. * Inverts the current matrix in place
  17117. * @returns the current inverted matrix
  17118. */
  17119. invert(): Matrix;
  17120. /**
  17121. * Sets all the matrix elements to zero
  17122. * @returns the current matrix
  17123. */
  17124. reset(): Matrix;
  17125. /**
  17126. * Adds the current matrix with a second one
  17127. * @param other defines the matrix to add
  17128. * @returns a new matrix as the addition of the current matrix and the given one
  17129. */
  17130. add(other: Matrix): Matrix;
  17131. /**
  17132. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17133. * @param other defines the matrix to add
  17134. * @param result defines the target matrix
  17135. * @returns the current matrix
  17136. */
  17137. addToRef(other: Matrix, result: Matrix): Matrix;
  17138. /**
  17139. * Adds in place the given matrix to the current matrix
  17140. * @param other defines the second operand
  17141. * @returns the current updated matrix
  17142. */
  17143. addToSelf(other: Matrix): Matrix;
  17144. /**
  17145. * Sets the given matrix to the current inverted Matrix
  17146. * @param other defines the target matrix
  17147. * @returns the unmodified current matrix
  17148. */
  17149. invertToRef(other: Matrix): Matrix;
  17150. /**
  17151. * Inserts the translation vector (using 3 floats) in the current matrix
  17152. * @param x defines the 1st component of the translation
  17153. * @param y defines the 2nd component of the translation
  17154. * @param z defines the 3rd component of the translation
  17155. * @returns the current updated matrix
  17156. */
  17157. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17158. /**
  17159. * Inserts the translation vector in the current matrix
  17160. * @param vector3 defines the translation to insert
  17161. * @returns the current updated matrix
  17162. */
  17163. setTranslation(vector3: Vector3): Matrix;
  17164. /**
  17165. * Gets the translation value of the current matrix
  17166. * @returns a new Vector3 as the extracted translation from the matrix
  17167. */
  17168. getTranslation(): Vector3;
  17169. /**
  17170. * Fill a Vector3 with the extracted translation from the matrix
  17171. * @param result defines the Vector3 where to store the translation
  17172. * @returns the current matrix
  17173. */
  17174. getTranslationToRef(result: Vector3): Matrix;
  17175. /**
  17176. * Remove rotation and scaling part from the matrix
  17177. * @returns the updated matrix
  17178. */
  17179. removeRotationAndScaling(): Matrix;
  17180. /**
  17181. * Multiply two matrices
  17182. * @param other defines the second operand
  17183. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17184. */
  17185. multiply(other: Matrix): Matrix;
  17186. /**
  17187. * Copy the current matrix from the given one
  17188. * @param other defines the source matrix
  17189. * @returns the current updated matrix
  17190. */
  17191. copyFrom(other: Matrix): Matrix;
  17192. /**
  17193. * Populates the given array from the starting index with the current matrix values
  17194. * @param array defines the target array
  17195. * @param offset defines the offset in the target array where to start storing values
  17196. * @returns the current matrix
  17197. */
  17198. copyToArray(array: Float32Array, offset?: number): Matrix;
  17199. /**
  17200. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17201. * @param other defines the second operand
  17202. * @param result defines the matrix where to store the multiplication
  17203. * @returns the current matrix
  17204. */
  17205. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17206. /**
  17207. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17208. * @param other defines the second operand
  17209. * @param result defines the array where to store the multiplication
  17210. * @param offset defines the offset in the target array where to start storing values
  17211. * @returns the current matrix
  17212. */
  17213. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17214. /**
  17215. * Check equality between this matrix and a second one
  17216. * @param value defines the second matrix to compare
  17217. * @returns true is the current matrix and the given one values are strictly equal
  17218. */
  17219. equals(value: Matrix): boolean;
  17220. /**
  17221. * Clone the current matrix
  17222. * @returns a new matrix from the current matrix
  17223. */
  17224. clone(): Matrix;
  17225. /**
  17226. * Returns the name of the current matrix class
  17227. * @returns the string "Matrix"
  17228. */
  17229. getClassName(): string;
  17230. /**
  17231. * Gets the hash code of the current matrix
  17232. * @returns the hash code
  17233. */
  17234. getHashCode(): number;
  17235. /**
  17236. * Decomposes the current Matrix into a translation, rotation and scaling components
  17237. * @param scale defines the scale vector3 given as a reference to update
  17238. * @param rotation defines the rotation quaternion given as a reference to update
  17239. * @param translation defines the translation vector3 given as a reference to update
  17240. * @returns true if operation was successful
  17241. */
  17242. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17243. /**
  17244. * Gets specific row of the matrix
  17245. * @param index defines the number of the row to get
  17246. * @returns the index-th row of the current matrix as a new Vector4
  17247. */
  17248. getRow(index: number): Nullable<Vector4>;
  17249. /**
  17250. * Sets the index-th row of the current matrix to the vector4 values
  17251. * @param index defines the number of the row to set
  17252. * @param row defines the target vector4
  17253. * @returns the updated current matrix
  17254. */
  17255. setRow(index: number, row: Vector4): Matrix;
  17256. /**
  17257. * Compute the transpose of the matrix
  17258. * @returns the new transposed matrix
  17259. */
  17260. transpose(): Matrix;
  17261. /**
  17262. * Compute the transpose of the matrix and store it in a given matrix
  17263. * @param result defines the target matrix
  17264. * @returns the current matrix
  17265. */
  17266. transposeToRef(result: Matrix): Matrix;
  17267. /**
  17268. * Sets the index-th row of the current matrix with the given 4 x float values
  17269. * @param index defines the row index
  17270. * @param x defines the x component to set
  17271. * @param y defines the y component to set
  17272. * @param z defines the z component to set
  17273. * @param w defines the w component to set
  17274. * @returns the updated current matrix
  17275. */
  17276. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17277. /**
  17278. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17279. * @param scale defines the scale factor
  17280. * @returns a new matrix
  17281. */
  17282. scale(scale: number): Matrix;
  17283. /**
  17284. * Scale the current matrix values by a factor to a given result matrix
  17285. * @param scale defines the scale factor
  17286. * @param result defines the matrix to store the result
  17287. * @returns the current matrix
  17288. */
  17289. scaleToRef(scale: number, result: Matrix): Matrix;
  17290. /**
  17291. * Scale the current matrix values by a factor and add the result to a given matrix
  17292. * @param scale defines the scale factor
  17293. * @param result defines the Matrix to store the result
  17294. * @returns the current matrix
  17295. */
  17296. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17297. /**
  17298. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17299. * @param ref matrix to store the result
  17300. */
  17301. toNormalMatrix(ref: Matrix): void;
  17302. /**
  17303. * Gets only rotation part of the current matrix
  17304. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17305. */
  17306. getRotationMatrix(): Matrix;
  17307. /**
  17308. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17309. * @param result defines the target matrix to store data to
  17310. * @returns the current matrix
  17311. */
  17312. getRotationMatrixToRef(result: Matrix): Matrix;
  17313. /**
  17314. * Creates a matrix from an array
  17315. * @param array defines the source array
  17316. * @param offset defines an offset in the source array
  17317. * @returns a new Matrix set from the starting index of the given array
  17318. */
  17319. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17320. /**
  17321. * Copy the content of an array into a given matrix
  17322. * @param array defines the source array
  17323. * @param offset defines an offset in the source array
  17324. * @param result defines the target matrix
  17325. */
  17326. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17327. /**
  17328. * Stores an array into a matrix after having multiplied each component by a given factor
  17329. * @param array defines the source array
  17330. * @param offset defines the offset in the source array
  17331. * @param scale defines the scaling factor
  17332. * @param result defines the target matrix
  17333. */
  17334. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17335. /**
  17336. * Stores a list of values (16) inside a given matrix
  17337. * @param initialM11 defines 1st value of 1st row
  17338. * @param initialM12 defines 2nd value of 1st row
  17339. * @param initialM13 defines 3rd value of 1st row
  17340. * @param initialM14 defines 4th value of 1st row
  17341. * @param initialM21 defines 1st value of 2nd row
  17342. * @param initialM22 defines 2nd value of 2nd row
  17343. * @param initialM23 defines 3rd value of 2nd row
  17344. * @param initialM24 defines 4th value of 2nd row
  17345. * @param initialM31 defines 1st value of 3rd row
  17346. * @param initialM32 defines 2nd value of 3rd row
  17347. * @param initialM33 defines 3rd value of 3rd row
  17348. * @param initialM34 defines 4th value of 3rd row
  17349. * @param initialM41 defines 1st value of 4th row
  17350. * @param initialM42 defines 2nd value of 4th row
  17351. * @param initialM43 defines 3rd value of 4th row
  17352. * @param initialM44 defines 4th value of 4th row
  17353. * @param result defines the target matrix
  17354. */
  17355. 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;
  17356. /**
  17357. * Gets an identity matrix that must not be updated
  17358. */
  17359. static readonly IdentityReadOnly: Matrix;
  17360. /**
  17361. * Creates new matrix from a list of values (16)
  17362. * @param initialM11 defines 1st value of 1st row
  17363. * @param initialM12 defines 2nd value of 1st row
  17364. * @param initialM13 defines 3rd value of 1st row
  17365. * @param initialM14 defines 4th value of 1st row
  17366. * @param initialM21 defines 1st value of 2nd row
  17367. * @param initialM22 defines 2nd value of 2nd row
  17368. * @param initialM23 defines 3rd value of 2nd row
  17369. * @param initialM24 defines 4th value of 2nd row
  17370. * @param initialM31 defines 1st value of 3rd row
  17371. * @param initialM32 defines 2nd value of 3rd row
  17372. * @param initialM33 defines 3rd value of 3rd row
  17373. * @param initialM34 defines 4th value of 3rd row
  17374. * @param initialM41 defines 1st value of 4th row
  17375. * @param initialM42 defines 2nd value of 4th row
  17376. * @param initialM43 defines 3rd value of 4th row
  17377. * @param initialM44 defines 4th value of 4th row
  17378. * @returns the new matrix
  17379. */
  17380. 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;
  17381. /**
  17382. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17383. * @param scale defines the scale vector3
  17384. * @param rotation defines the rotation quaternion
  17385. * @param translation defines the translation vector3
  17386. * @returns a new matrix
  17387. */
  17388. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17389. /**
  17390. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17391. * @param scale defines the scale vector3
  17392. * @param rotation defines the rotation quaternion
  17393. * @param translation defines the translation vector3
  17394. * @param result defines the target matrix
  17395. */
  17396. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17397. /**
  17398. * Creates a new identity matrix
  17399. * @returns a new identity matrix
  17400. */
  17401. static Identity(): Matrix;
  17402. /**
  17403. * Creates a new identity matrix and stores the result in a given matrix
  17404. * @param result defines the target matrix
  17405. */
  17406. static IdentityToRef(result: Matrix): void;
  17407. /**
  17408. * Creates a new zero matrix
  17409. * @returns a new zero matrix
  17410. */
  17411. static Zero(): Matrix;
  17412. /**
  17413. * Creates a new rotation matrix for "angle" radians around the X axis
  17414. * @param angle defines the angle (in radians) to use
  17415. * @return the new matrix
  17416. */
  17417. static RotationX(angle: number): Matrix;
  17418. /**
  17419. * Creates a new matrix as the invert of a given matrix
  17420. * @param source defines the source matrix
  17421. * @returns the new matrix
  17422. */
  17423. static Invert(source: Matrix): Matrix;
  17424. /**
  17425. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17426. * @param angle defines the angle (in radians) to use
  17427. * @param result defines the target matrix
  17428. */
  17429. static RotationXToRef(angle: number, result: Matrix): void;
  17430. /**
  17431. * Creates a new rotation matrix for "angle" radians around the Y axis
  17432. * @param angle defines the angle (in radians) to use
  17433. * @return the new matrix
  17434. */
  17435. static RotationY(angle: number): Matrix;
  17436. /**
  17437. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17438. * @param angle defines the angle (in radians) to use
  17439. * @param result defines the target matrix
  17440. */
  17441. static RotationYToRef(angle: number, result: Matrix): void;
  17442. /**
  17443. * Creates a new rotation matrix for "angle" radians around the Z axis
  17444. * @param angle defines the angle (in radians) to use
  17445. * @return the new matrix
  17446. */
  17447. static RotationZ(angle: number): Matrix;
  17448. /**
  17449. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17450. * @param angle defines the angle (in radians) to use
  17451. * @param result defines the target matrix
  17452. */
  17453. static RotationZToRef(angle: number, result: Matrix): void;
  17454. /**
  17455. * Creates a new rotation matrix for "angle" radians around the given axis
  17456. * @param axis defines the axis to use
  17457. * @param angle defines the angle (in radians) to use
  17458. * @return the new matrix
  17459. */
  17460. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17461. /**
  17462. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17463. * @param axis defines the axis to use
  17464. * @param angle defines the angle (in radians) to use
  17465. * @param result defines the target matrix
  17466. */
  17467. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17468. /**
  17469. * Creates a rotation matrix
  17470. * @param yaw defines the yaw angle in radians (Y axis)
  17471. * @param pitch defines the pitch angle in radians (X axis)
  17472. * @param roll defines the roll angle in radians (X axis)
  17473. * @returns the new rotation matrix
  17474. */
  17475. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17476. /**
  17477. * Creates a rotation matrix and stores it in a given matrix
  17478. * @param yaw defines the yaw angle in radians (Y axis)
  17479. * @param pitch defines the pitch angle in radians (X axis)
  17480. * @param roll defines the roll angle in radians (X axis)
  17481. * @param result defines the target matrix
  17482. */
  17483. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17484. /**
  17485. * Creates a scaling matrix
  17486. * @param x defines the scale factor on X axis
  17487. * @param y defines the scale factor on Y axis
  17488. * @param z defines the scale factor on Z axis
  17489. * @returns the new matrix
  17490. */
  17491. static Scaling(x: number, y: number, z: number): Matrix;
  17492. /**
  17493. * Creates a scaling matrix and stores it in a given matrix
  17494. * @param x defines the scale factor on X axis
  17495. * @param y defines the scale factor on Y axis
  17496. * @param z defines the scale factor on Z axis
  17497. * @param result defines the target matrix
  17498. */
  17499. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17500. /**
  17501. * Creates a translation matrix
  17502. * @param x defines the translation on X axis
  17503. * @param y defines the translation on Y axis
  17504. * @param z defines the translationon Z axis
  17505. * @returns the new matrix
  17506. */
  17507. static Translation(x: number, y: number, z: number): Matrix;
  17508. /**
  17509. * Creates a translation matrix and stores it in a given matrix
  17510. * @param x defines the translation on X axis
  17511. * @param y defines the translation on Y axis
  17512. * @param z defines the translationon Z axis
  17513. * @param result defines the target matrix
  17514. */
  17515. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17516. /**
  17517. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17518. * @param startValue defines the start value
  17519. * @param endValue defines the end value
  17520. * @param gradient defines the gradient factor
  17521. * @returns the new matrix
  17522. */
  17523. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17524. /**
  17525. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17526. * @param startValue defines the start value
  17527. * @param endValue defines the end value
  17528. * @param gradient defines the gradient factor
  17529. * @param result defines the Matrix object where to store data
  17530. */
  17531. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17532. /**
  17533. * Builds a new matrix whose values are computed by:
  17534. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17535. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17536. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17537. * @param startValue defines the first matrix
  17538. * @param endValue defines the second matrix
  17539. * @param gradient defines the gradient between the two matrices
  17540. * @returns the new matrix
  17541. */
  17542. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17543. /**
  17544. * Update a matrix to values which are computed by:
  17545. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17546. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17547. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17548. * @param startValue defines the first matrix
  17549. * @param endValue defines the second matrix
  17550. * @param gradient defines the gradient between the two matrices
  17551. * @param result defines the target matrix
  17552. */
  17553. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17554. /**
  17555. * 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"
  17556. * This function works in left handed mode
  17557. * @param eye defines the final position of the entity
  17558. * @param target defines where the entity should look at
  17559. * @param up defines the up vector for the entity
  17560. * @returns the new matrix
  17561. */
  17562. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17563. /**
  17564. * 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".
  17565. * This function works in left handed mode
  17566. * @param eye defines the final position of the entity
  17567. * @param target defines where the entity should look at
  17568. * @param up defines the up vector for the entity
  17569. * @param result defines the target matrix
  17570. */
  17571. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17572. /**
  17573. * 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"
  17574. * This function works in right handed mode
  17575. * @param eye defines the final position of the entity
  17576. * @param target defines where the entity should look at
  17577. * @param up defines the up vector for the entity
  17578. * @returns the new matrix
  17579. */
  17580. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17581. /**
  17582. * 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".
  17583. * This function works in right handed mode
  17584. * @param eye defines the final position of the entity
  17585. * @param target defines where the entity should look at
  17586. * @param up defines the up vector for the entity
  17587. * @param result defines the target matrix
  17588. */
  17589. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17590. /**
  17591. * Create a left-handed orthographic projection matrix
  17592. * @param width defines the viewport width
  17593. * @param height defines the viewport height
  17594. * @param znear defines the near clip plane
  17595. * @param zfar defines the far clip plane
  17596. * @returns a new matrix as a left-handed orthographic projection matrix
  17597. */
  17598. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17599. /**
  17600. * Store a left-handed orthographic projection to a given matrix
  17601. * @param width defines the viewport width
  17602. * @param height defines the viewport height
  17603. * @param znear defines the near clip plane
  17604. * @param zfar defines the far clip plane
  17605. * @param result defines the target matrix
  17606. */
  17607. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17608. /**
  17609. * Create a left-handed orthographic projection matrix
  17610. * @param left defines the viewport left coordinate
  17611. * @param right defines the viewport right coordinate
  17612. * @param bottom defines the viewport bottom coordinate
  17613. * @param top defines the viewport top coordinate
  17614. * @param znear defines the near clip plane
  17615. * @param zfar defines the far clip plane
  17616. * @returns a new matrix as a left-handed orthographic projection matrix
  17617. */
  17618. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17619. /**
  17620. * Stores a left-handed orthographic projection into a given matrix
  17621. * @param left defines the viewport left coordinate
  17622. * @param right defines the viewport right coordinate
  17623. * @param bottom defines the viewport bottom coordinate
  17624. * @param top defines the viewport top coordinate
  17625. * @param znear defines the near clip plane
  17626. * @param zfar defines the far clip plane
  17627. * @param result defines the target matrix
  17628. */
  17629. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17630. /**
  17631. * Creates a right-handed orthographic projection matrix
  17632. * @param left defines the viewport left coordinate
  17633. * @param right defines the viewport right coordinate
  17634. * @param bottom defines the viewport bottom coordinate
  17635. * @param top defines the viewport top coordinate
  17636. * @param znear defines the near clip plane
  17637. * @param zfar defines the far clip plane
  17638. * @returns a new matrix as a right-handed orthographic projection matrix
  17639. */
  17640. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17641. /**
  17642. * Stores a right-handed orthographic projection into a given matrix
  17643. * @param left defines the viewport left coordinate
  17644. * @param right defines the viewport right coordinate
  17645. * @param bottom defines the viewport bottom coordinate
  17646. * @param top defines the viewport top coordinate
  17647. * @param znear defines the near clip plane
  17648. * @param zfar defines the far clip plane
  17649. * @param result defines the target matrix
  17650. */
  17651. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17652. /**
  17653. * Creates a left-handed perspective projection matrix
  17654. * @param width defines the viewport width
  17655. * @param height defines the viewport height
  17656. * @param znear defines the near clip plane
  17657. * @param zfar defines the far clip plane
  17658. * @returns a new matrix as a left-handed perspective projection matrix
  17659. */
  17660. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17661. /**
  17662. * Creates a left-handed perspective projection matrix
  17663. * @param fov defines the horizontal field of view
  17664. * @param aspect defines the aspect ratio
  17665. * @param znear defines the near clip plane
  17666. * @param zfar defines the far clip plane
  17667. * @returns a new matrix as a left-handed perspective projection matrix
  17668. */
  17669. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17670. /**
  17671. * Stores a left-handed perspective projection into a given matrix
  17672. * @param fov defines the horizontal field of view
  17673. * @param aspect defines the aspect ratio
  17674. * @param znear defines the near clip plane
  17675. * @param zfar defines the far clip plane
  17676. * @param result defines the target matrix
  17677. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17678. */
  17679. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17680. /**
  17681. * Creates a right-handed perspective projection matrix
  17682. * @param fov defines the horizontal field of view
  17683. * @param aspect defines the aspect ratio
  17684. * @param znear defines the near clip plane
  17685. * @param zfar defines the far clip plane
  17686. * @returns a new matrix as a right-handed perspective projection matrix
  17687. */
  17688. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17689. /**
  17690. * Stores a right-handed perspective projection into a given matrix
  17691. * @param fov defines the horizontal field of view
  17692. * @param aspect defines the aspect ratio
  17693. * @param znear defines the near clip plane
  17694. * @param zfar defines the far clip plane
  17695. * @param result defines the target matrix
  17696. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17697. */
  17698. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17699. /**
  17700. * Stores a perspective projection for WebVR info a given matrix
  17701. * @param fov defines the field of view
  17702. * @param znear defines the near clip plane
  17703. * @param zfar defines the far clip plane
  17704. * @param result defines the target matrix
  17705. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17706. */
  17707. static PerspectiveFovWebVRToRef(fov: {
  17708. upDegrees: number;
  17709. downDegrees: number;
  17710. leftDegrees: number;
  17711. rightDegrees: number;
  17712. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17713. /**
  17714. * Computes a complete transformation matrix
  17715. * @param viewport defines the viewport to use
  17716. * @param world defines the world matrix
  17717. * @param view defines the view matrix
  17718. * @param projection defines the projection matrix
  17719. * @param zmin defines the near clip plane
  17720. * @param zmax defines the far clip plane
  17721. * @returns the transformation matrix
  17722. */
  17723. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17724. /**
  17725. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17726. * @param matrix defines the matrix to use
  17727. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17728. */
  17729. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17730. /**
  17731. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17732. * @param matrix defines the matrix to use
  17733. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17734. */
  17735. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17736. /**
  17737. * Compute the transpose of a given matrix
  17738. * @param matrix defines the matrix to transpose
  17739. * @returns the new matrix
  17740. */
  17741. static Transpose(matrix: Matrix): Matrix;
  17742. /**
  17743. * Compute the transpose of a matrix and store it in a target matrix
  17744. * @param matrix defines the matrix to transpose
  17745. * @param result defines the target matrix
  17746. */
  17747. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17748. /**
  17749. * Computes a reflection matrix from a plane
  17750. * @param plane defines the reflection plane
  17751. * @returns a new matrix
  17752. */
  17753. static Reflection(plane: Plane): Matrix;
  17754. /**
  17755. * Computes a reflection matrix from a plane
  17756. * @param plane defines the reflection plane
  17757. * @param result defines the target matrix
  17758. */
  17759. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17760. /**
  17761. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17762. * @param xaxis defines the value of the 1st axis
  17763. * @param yaxis defines the value of the 2nd axis
  17764. * @param zaxis defines the value of the 3rd axis
  17765. * @param result defines the target matrix
  17766. */
  17767. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17768. /**
  17769. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17770. * @param quat defines the quaternion to use
  17771. * @param result defines the target matrix
  17772. */
  17773. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17774. }
  17775. class Plane {
  17776. normal: Vector3;
  17777. d: number;
  17778. /**
  17779. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17780. */
  17781. constructor(a: number, b: number, c: number, d: number);
  17782. /**
  17783. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17784. */
  17785. asArray(): number[];
  17786. /**
  17787. * Returns a new plane copied from the current Plane.
  17788. */
  17789. clone(): Plane;
  17790. /**
  17791. * Returns the string "Plane".
  17792. */
  17793. getClassName(): string;
  17794. /**
  17795. * Returns the Plane hash code.
  17796. */
  17797. getHashCode(): number;
  17798. /**
  17799. * Normalize the current Plane in place.
  17800. * Returns the updated Plane.
  17801. */
  17802. normalize(): Plane;
  17803. /**
  17804. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17805. */
  17806. transform(transformation: Matrix): Plane;
  17807. /**
  17808. * Returns the dot product (float) of the point coordinates and the plane normal.
  17809. */
  17810. dotCoordinate(point: Vector3): number;
  17811. /**
  17812. * Updates the current Plane from the plane defined by the three given points.
  17813. * Returns the updated Plane.
  17814. */
  17815. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17816. /**
  17817. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17818. */
  17819. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17820. /**
  17821. * Returns the signed distance (float) from the given point to the Plane.
  17822. */
  17823. signedDistanceTo(point: Vector3): number;
  17824. /**
  17825. * Returns a new Plane from the given array.
  17826. */
  17827. static FromArray(array: ArrayLike<number>): Plane;
  17828. /**
  17829. * Returns a new Plane defined by the three given points.
  17830. */
  17831. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17832. /**
  17833. * Returns a new Plane the normal vector to this plane at the given origin point.
  17834. * Note : the vector "normal" is updated because normalized.
  17835. */
  17836. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17837. /**
  17838. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17839. */
  17840. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17841. }
  17842. class Viewport {
  17843. x: number;
  17844. y: number;
  17845. width: number;
  17846. height: number;
  17847. /**
  17848. * Creates a Viewport object located at (x, y) and sized (width, height).
  17849. */
  17850. constructor(x: number, y: number, width: number, height: number);
  17851. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17852. /**
  17853. * Returns a new Viewport copied from the current one.
  17854. */
  17855. clone(): Viewport;
  17856. }
  17857. class Frustum {
  17858. /**
  17859. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17860. */
  17861. static GetPlanes(transform: Matrix): Plane[];
  17862. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17863. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17864. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17865. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17866. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17867. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17868. /**
  17869. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17870. */
  17871. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17872. }
  17873. /** Defines supported spaces */
  17874. enum Space {
  17875. /** Local (object) space */
  17876. LOCAL = 0,
  17877. /** World space */
  17878. WORLD = 1,
  17879. /** Bone space */
  17880. BONE = 2,
  17881. }
  17882. /** Defines the 3 main axes */
  17883. class Axis {
  17884. /** X axis */
  17885. static X: Vector3;
  17886. /** Y axis */
  17887. static Y: Vector3;
  17888. /** Z axis */
  17889. static Z: Vector3;
  17890. }
  17891. class BezierCurve {
  17892. /**
  17893. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17894. */
  17895. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17896. }
  17897. /**
  17898. * Defines potential orientation for back face culling
  17899. */
  17900. enum Orientation {
  17901. /**
  17902. * Clockwise
  17903. */
  17904. CW = 0,
  17905. /** Counter clockwise */
  17906. CCW = 1,
  17907. }
  17908. /**
  17909. * Defines angle representation
  17910. */
  17911. class Angle {
  17912. private _radians;
  17913. /**
  17914. * Creates an Angle object of "radians" radians (float).
  17915. */
  17916. constructor(radians: number);
  17917. /**
  17918. * Get value in degrees
  17919. * @returns the Angle value in degrees (float)
  17920. */
  17921. degrees(): number;
  17922. /**
  17923. * Get value in radians
  17924. * @returns the Angle value in radians (float)
  17925. */
  17926. radians(): number;
  17927. /**
  17928. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17929. * @param a defines first vector
  17930. * @param b defines second vector
  17931. * @returns a new Angle
  17932. */
  17933. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17934. /**
  17935. * Gets a new Angle object from the given float in radians
  17936. * @param radians defines the angle value in radians
  17937. * @returns a new Angle
  17938. */
  17939. static FromRadians(radians: number): Angle;
  17940. /**
  17941. * Gets a new Angle object from the given float in degrees
  17942. * @param degrees defines the angle value in degrees
  17943. * @returns a new Angle
  17944. */
  17945. static FromDegrees(degrees: number): Angle;
  17946. }
  17947. class Arc2 {
  17948. startPoint: Vector2;
  17949. midPoint: Vector2;
  17950. endPoint: Vector2;
  17951. centerPoint: Vector2;
  17952. radius: number;
  17953. angle: Angle;
  17954. startAngle: Angle;
  17955. orientation: Orientation;
  17956. /**
  17957. * Creates an Arc object from the three given points : start, middle and end.
  17958. */
  17959. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17960. }
  17961. class Path2 {
  17962. private _points;
  17963. private _length;
  17964. closed: boolean;
  17965. /**
  17966. * Creates a Path2 object from the starting 2D coordinates x and y.
  17967. */
  17968. constructor(x: number, y: number);
  17969. /**
  17970. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17971. * Returns the updated Path2.
  17972. */
  17973. addLineTo(x: number, y: number): Path2;
  17974. /**
  17975. * 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.
  17976. * Returns the updated Path2.
  17977. */
  17978. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17979. /**
  17980. * Closes the Path2.
  17981. * Returns the Path2.
  17982. */
  17983. close(): Path2;
  17984. /**
  17985. * Returns the Path2 total length (float).
  17986. */
  17987. length(): number;
  17988. /**
  17989. * Returns the Path2 internal array of points.
  17990. */
  17991. getPoints(): Vector2[];
  17992. /**
  17993. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17994. */
  17995. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17996. /**
  17997. * Returns a new Path2 starting at the coordinates (x, y).
  17998. */
  17999. static StartingAt(x: number, y: number): Path2;
  18000. }
  18001. class Path3D {
  18002. path: Vector3[];
  18003. private _curve;
  18004. private _distances;
  18005. private _tangents;
  18006. private _normals;
  18007. private _binormals;
  18008. private _raw;
  18009. /**
  18010. * new Path3D(path, normal, raw)
  18011. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18012. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18013. * path : an array of Vector3, the curve axis of the Path3D
  18014. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18015. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18016. */
  18017. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18018. /**
  18019. * Returns the Path3D array of successive Vector3 designing its curve.
  18020. */
  18021. getCurve(): Vector3[];
  18022. /**
  18023. * Returns an array populated with tangent vectors on each Path3D curve point.
  18024. */
  18025. getTangents(): Vector3[];
  18026. /**
  18027. * Returns an array populated with normal vectors on each Path3D curve point.
  18028. */
  18029. getNormals(): Vector3[];
  18030. /**
  18031. * Returns an array populated with binormal vectors on each Path3D curve point.
  18032. */
  18033. getBinormals(): Vector3[];
  18034. /**
  18035. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18036. */
  18037. getDistances(): number[];
  18038. /**
  18039. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18040. * Returns the same object updated.
  18041. */
  18042. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18043. private _compute(firstNormal);
  18044. private _getFirstNonNullVector(index);
  18045. private _getLastNonNullVector(index);
  18046. private _normalVector(v0, vt, va);
  18047. }
  18048. class Curve3 {
  18049. private _points;
  18050. private _length;
  18051. /**
  18052. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18054. * @param v1 (Vector3) the control point
  18055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18056. * @param nbPoints (integer) the wanted number of points in the curve
  18057. */
  18058. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18059. /**
  18060. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18061. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18062. * @param v1 (Vector3) the first control point
  18063. * @param v2 (Vector3) the second control point
  18064. * @param v3 (Vector3) the end point of the Cubic Bezier
  18065. * @param nbPoints (integer) the wanted number of points in the curve
  18066. */
  18067. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18068. /**
  18069. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18070. * @param p1 (Vector3) the origin point of the Hermite Spline
  18071. * @param t1 (Vector3) the tangent vector at the origin point
  18072. * @param p2 (Vector3) the end point of the Hermite Spline
  18073. * @param t2 (Vector3) the tangent vector at the end point
  18074. * @param nbPoints (integer) the wanted number of points in the curve
  18075. */
  18076. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18077. /**
  18078. * Returns a Curve3 object along a CatmullRom Spline curve :
  18079. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18080. * @param nbPoints (integer) the wanted number of points between each curve control points
  18081. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18082. */
  18083. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18084. /**
  18085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18086. * A Curve3 is designed from a series of successive Vector3.
  18087. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18088. */
  18089. constructor(points: Vector3[]);
  18090. /**
  18091. * Returns the Curve3 stored array of successive Vector3
  18092. */
  18093. getPoints(): Vector3[];
  18094. /**
  18095. * Returns the computed length (float) of the curve.
  18096. */
  18097. length(): number;
  18098. /**
  18099. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18100. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18101. * curveA and curveB keep unchanged.
  18102. */
  18103. continue(curve: Curve3): Curve3;
  18104. private _computeLength(path);
  18105. }
  18106. class PositionNormalVertex {
  18107. position: Vector3;
  18108. normal: Vector3;
  18109. constructor(position?: Vector3, normal?: Vector3);
  18110. clone(): PositionNormalVertex;
  18111. }
  18112. class PositionNormalTextureVertex {
  18113. position: Vector3;
  18114. normal: Vector3;
  18115. uv: Vector2;
  18116. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18117. clone(): PositionNormalTextureVertex;
  18118. }
  18119. class Tmp {
  18120. static Color3: Color3[];
  18121. static Vector2: Vector2[];
  18122. static Vector3: Vector3[];
  18123. static Vector4: Vector4[];
  18124. static Quaternion: Quaternion[];
  18125. static Matrix: Matrix[];
  18126. }
  18127. }
  18128. declare module BABYLON {
  18129. class SphericalPolynomial {
  18130. x: Vector3;
  18131. y: Vector3;
  18132. z: Vector3;
  18133. xx: Vector3;
  18134. yy: Vector3;
  18135. zz: Vector3;
  18136. xy: Vector3;
  18137. yz: Vector3;
  18138. zx: Vector3;
  18139. addAmbient(color: Color3): void;
  18140. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18141. scale(scale: number): void;
  18142. }
  18143. class SphericalHarmonics {
  18144. L00: Vector3;
  18145. L1_1: Vector3;
  18146. L10: Vector3;
  18147. L11: Vector3;
  18148. L2_2: Vector3;
  18149. L2_1: Vector3;
  18150. L20: Vector3;
  18151. L21: Vector3;
  18152. L22: Vector3;
  18153. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18154. scale(scale: number): void;
  18155. convertIncidentRadianceToIrradiance(): void;
  18156. convertIrradianceToLambertianRadiance(): void;
  18157. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18158. }
  18159. }
  18160. declare module BABYLON {
  18161. interface ILoadingScreen {
  18162. displayLoadingUI: () => void;
  18163. hideLoadingUI: () => void;
  18164. loadingUIBackgroundColor: string;
  18165. loadingUIText: string;
  18166. }
  18167. class DefaultLoadingScreen implements ILoadingScreen {
  18168. private _renderingCanvas;
  18169. private _loadingText;
  18170. private _loadingDivBackgroundColor;
  18171. private _loadingDiv;
  18172. private _loadingTextDiv;
  18173. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  18174. displayLoadingUI(): void;
  18175. hideLoadingUI(): void;
  18176. loadingUIText: string;
  18177. loadingUIBackgroundColor: string;
  18178. private _resizeLoadingUI;
  18179. }
  18180. }
  18181. declare module BABYLON {
  18182. class SceneLoaderProgressEvent {
  18183. readonly lengthComputable: boolean;
  18184. readonly loaded: number;
  18185. readonly total: number;
  18186. constructor(lengthComputable: boolean, loaded: number, total: number);
  18187. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  18188. }
  18189. interface ISceneLoaderPluginExtensions {
  18190. [extension: string]: {
  18191. isBinary: boolean;
  18192. };
  18193. }
  18194. interface ISceneLoaderPluginFactory {
  18195. name: string;
  18196. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  18197. canDirectLoad?: (data: string) => boolean;
  18198. }
  18199. interface ISceneLoaderPlugin {
  18200. /**
  18201. * The friendly name of this plugin.
  18202. */
  18203. name: string;
  18204. /**
  18205. * The file extensions supported by this plugin.
  18206. */
  18207. extensions: string | ISceneLoaderPluginExtensions;
  18208. /**
  18209. * Import meshes into a scene.
  18210. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  18211. * @param scene The scene to import into
  18212. * @param data The data to import
  18213. * @param rootUrl The root url for scene and resources
  18214. * @param meshes The meshes array to import into
  18215. * @param particleSystems The particle systems array to import into
  18216. * @param skeletons The skeletons array to import into
  18217. * @param onError The callback when import fails
  18218. * @returns True if successful or false otherwise
  18219. */
  18220. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  18221. /**
  18222. * Load into a scene.
  18223. * @param scene The scene to load into
  18224. * @param data The data to import
  18225. * @param rootUrl The root url for scene and resources
  18226. * @param onError The callback when import fails
  18227. * @returns true if successful or false otherwise
  18228. */
  18229. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  18230. /**
  18231. * The callback that returns true if the data can be directly loaded.
  18232. */
  18233. canDirectLoad?: (data: string) => boolean;
  18234. /**
  18235. * The callback that allows custom handling of the root url based on the response url.
  18236. */
  18237. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  18238. /**
  18239. * Load into an asset container.
  18240. * @param scene The scene to load into
  18241. * @param data The data to import
  18242. * @param rootUrl The root url for scene and resources
  18243. * @param onError The callback when import fails
  18244. * @returns The loaded asset container
  18245. */
  18246. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  18247. }
  18248. interface ISceneLoaderPluginAsync {
  18249. /**
  18250. * The friendly name of this plugin.
  18251. */
  18252. name: string;
  18253. /**
  18254. * The file extensions supported by this plugin.
  18255. */
  18256. extensions: string | ISceneLoaderPluginExtensions;
  18257. /**
  18258. * Import meshes into a scene.
  18259. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  18260. * @param scene The scene to import into
  18261. * @param data The data to import
  18262. * @param rootUrl The root url for scene and resources
  18263. * @param onProgress The callback when the load progresses
  18264. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  18265. */
  18266. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  18267. meshes: AbstractMesh[];
  18268. particleSystems: ParticleSystem[];
  18269. skeletons: Skeleton[];
  18270. animationGroups: AnimationGroup[];
  18271. }>;
  18272. /**
  18273. * Load into a scene.
  18274. * @param scene The scene to load into
  18275. * @param data The data to import
  18276. * @param rootUrl The root url for scene and resources
  18277. * @param onProgress The callback when the load progresses
  18278. * @returns Nothing
  18279. */
  18280. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  18281. /**
  18282. * The callback that returns true if the data can be directly loaded.
  18283. */
  18284. canDirectLoad?: (data: string) => boolean;
  18285. /**
  18286. * The callback that allows custom handling of the root url based on the response url.
  18287. */
  18288. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  18289. /**
  18290. * Load into an asset container.
  18291. * @param scene The scene to load into
  18292. * @param data The data to import
  18293. * @param rootUrl The root url for scene and resources
  18294. * @param onProgress The callback when the load progresses
  18295. * @returns The loaded asset container
  18296. */
  18297. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  18298. }
  18299. class SceneLoader {
  18300. private static _ForceFullSceneLoadingForIncremental;
  18301. private static _ShowLoadingScreen;
  18302. private static _CleanBoneMatrixWeights;
  18303. static readonly NO_LOGGING: number;
  18304. static readonly MINIMAL_LOGGING: number;
  18305. static readonly SUMMARY_LOGGING: number;
  18306. static readonly DETAILED_LOGGING: number;
  18307. private static _loggingLevel;
  18308. static ForceFullSceneLoadingForIncremental: boolean;
  18309. static ShowLoadingScreen: boolean;
  18310. static loggingLevel: number;
  18311. static CleanBoneMatrixWeights: boolean;
  18312. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  18313. private static _registeredPlugins;
  18314. private static _getDefaultPlugin();
  18315. private static _getPluginForExtension(extension);
  18316. private static _getPluginForDirectLoad(data);
  18317. private static _getPluginForFilename(sceneFilename);
  18318. private static _getDirectLoad(sceneFilename);
  18319. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  18320. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  18321. static IsPluginForExtensionAvailable(extension: string): boolean;
  18322. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  18323. /**
  18324. * Import meshes into a scene
  18325. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  18326. * @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)
  18327. * @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)
  18328. * @param scene the instance of BABYLON.Scene to append to
  18329. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  18330. * @param onProgress a callback with a progress event for each file being loaded
  18331. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  18332. * @param pluginExtension the extension used to determine the plugin
  18333. * @returns The loaded plugin
  18334. */
  18335. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  18336. /**
  18337. * Import meshes into a scene
  18338. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  18339. * @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)
  18340. * @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)
  18341. * @param scene the instance of BABYLON.Scene to append to
  18342. * @param onProgress a callback with a progress event for each file being loaded
  18343. * @param pluginExtension the extension used to determine the plugin
  18344. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  18345. */
  18346. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  18347. meshes: AbstractMesh[];
  18348. particleSystems: ParticleSystem[];
  18349. skeletons: Skeleton[];
  18350. animationGroups: AnimationGroup[];
  18351. }>;
  18352. /**
  18353. * Load a scene
  18354. * @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)
  18355. * @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)
  18356. * @param engine is the instance of BABYLON.Engine to use to create the scene
  18357. * @param onSuccess a callback with the scene when import succeeds
  18358. * @param onProgress a callback with a progress event for each file being loaded
  18359. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  18360. * @param pluginExtension the extension used to determine the plugin
  18361. * @returns The loaded plugin
  18362. */
  18363. 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>;
  18364. /**
  18365. * Load a scene
  18366. * @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)
  18367. * @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)
  18368. * @param engine is the instance of BABYLON.Engine to use to create the scene
  18369. * @param onProgress a callback with a progress event for each file being loaded
  18370. * @param pluginExtension the extension used to determine the plugin
  18371. * @returns The loaded scene
  18372. */
  18373. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  18374. /**
  18375. * Append a scene
  18376. * @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)
  18377. * @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)
  18378. * @param scene is the instance of BABYLON.Scene to append to
  18379. * @param onSuccess a callback with the scene when import succeeds
  18380. * @param onProgress a callback with a progress event for each file being loaded
  18381. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  18382. * @param pluginExtension the extension used to determine the plugin
  18383. * @returns The loaded plugin
  18384. */
  18385. 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>;
  18386. /**
  18387. * Append a scene
  18388. * @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)
  18389. * @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)
  18390. * @param scene is the instance of BABYLON.Scene to append to
  18391. * @param onProgress a callback with a progress event for each file being loaded
  18392. * @param pluginExtension the extension used to determine the plugin
  18393. * @returns The given scene
  18394. */
  18395. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  18396. /**
  18397. * Load a scene into an asset container
  18398. * @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)
  18399. * @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)
  18400. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  18401. * @param onSuccess a callback with the scene when import succeeds
  18402. * @param onProgress a callback with a progress event for each file being loaded
  18403. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  18404. * @param pluginExtension the extension used to determine the plugin
  18405. * @returns The loaded plugin
  18406. */
  18407. 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>;
  18408. /**
  18409. * Load a scene into an asset container
  18410. * @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)
  18411. * @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)
  18412. * @param scene is the instance of BABYLON.Scene to append to
  18413. * @param onProgress a callback with a progress event for each file being loaded
  18414. * @param pluginExtension the extension used to determine the plugin
  18415. * @returns The loaded asset container
  18416. */
  18417. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  18418. }
  18419. }
  18420. declare module BABYLON {
  18421. /**
  18422. * Defines a target to use with MorphTargetManager
  18423. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18424. */
  18425. class MorphTarget implements IAnimatable {
  18426. /** defines the name of the target */
  18427. name: string;
  18428. /**
  18429. * Gets or sets the list of animations
  18430. */
  18431. animations: Animation[];
  18432. private _scene;
  18433. private _positions;
  18434. private _normals;
  18435. private _tangents;
  18436. private _influence;
  18437. /**
  18438. * Observable raised when the influence changes
  18439. */
  18440. onInfluenceChanged: Observable<boolean>;
  18441. /**
  18442. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18443. */
  18444. influence: number;
  18445. private _animationPropertiesOverride;
  18446. /**
  18447. * Gets or sets the animation properties override
  18448. */
  18449. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18450. /**
  18451. * Creates a new MorphTarget
  18452. * @param name defines the name of the target
  18453. * @param influence defines the influence to use
  18454. */
  18455. constructor(
  18456. /** defines the name of the target */
  18457. name: string, influence?: number, scene?: Nullable<Scene>);
  18458. /**
  18459. * Gets a boolean defining if the target contains position data
  18460. */
  18461. readonly hasPositions: boolean;
  18462. /**
  18463. * Gets a boolean defining if the target contains normal data
  18464. */
  18465. readonly hasNormals: boolean;
  18466. /**
  18467. * Gets a boolean defining if the target contains tangent data
  18468. */
  18469. readonly hasTangents: boolean;
  18470. /**
  18471. * Affects position data to this target
  18472. * @param data defines the position data to use
  18473. */
  18474. setPositions(data: Nullable<FloatArray>): void;
  18475. /**
  18476. * Gets the position data stored in this target
  18477. * @returns a FloatArray containing the position data (or null if not present)
  18478. */
  18479. getPositions(): Nullable<FloatArray>;
  18480. /**
  18481. * Affects normal data to this target
  18482. * @param data defines the normal data to use
  18483. */
  18484. setNormals(data: Nullable<FloatArray>): void;
  18485. /**
  18486. * Gets the normal data stored in this target
  18487. * @returns a FloatArray containing the normal data (or null if not present)
  18488. */
  18489. getNormals(): Nullable<FloatArray>;
  18490. /**
  18491. * Affects tangent data to this target
  18492. * @param data defines the tangent data to use
  18493. */
  18494. setTangents(data: Nullable<FloatArray>): void;
  18495. /**
  18496. * Gets the tangent data stored in this target
  18497. * @returns a FloatArray containing the tangent data (or null if not present)
  18498. */
  18499. getTangents(): Nullable<FloatArray>;
  18500. /**
  18501. * Serializes the current target into a Serialization object
  18502. * @returns the serialized object
  18503. */
  18504. serialize(): any;
  18505. /**
  18506. * Creates a new target from serialized data
  18507. * @param serializationObject defines the serialized data to use
  18508. * @returns a new MorphTarget
  18509. */
  18510. static Parse(serializationObject: any): MorphTarget;
  18511. /**
  18512. * Creates a MorphTarget from mesh data
  18513. * @param mesh defines the source mesh
  18514. * @param name defines the name to use for the new target
  18515. * @param influence defines the influence to attach to the target
  18516. * @returns a new MorphTarget
  18517. */
  18518. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18519. }
  18520. }
  18521. declare module BABYLON {
  18522. /**
  18523. * This class is used to deform meshes using morphing between different targets
  18524. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18525. */
  18526. class MorphTargetManager {
  18527. private _targets;
  18528. private _targetObservable;
  18529. private _activeTargets;
  18530. private _scene;
  18531. private _influences;
  18532. private _supportsNormals;
  18533. private _supportsTangents;
  18534. private _vertexCount;
  18535. private _uniqueId;
  18536. private _tempInfluences;
  18537. /**
  18538. * Creates a new MorphTargetManager
  18539. * @param scene defines the current scene
  18540. */
  18541. constructor(scene?: Nullable<Scene>);
  18542. /**
  18543. * Gets the unique ID of this manager
  18544. */
  18545. readonly uniqueId: number;
  18546. /**
  18547. * Gets the number of vertices handled by this manager
  18548. */
  18549. readonly vertexCount: number;
  18550. /**
  18551. * Gets a boolean indicating if this manager supports morphing of normals
  18552. */
  18553. readonly supportsNormals: boolean;
  18554. /**
  18555. * Gets a boolean indicating if this manager supports morphing of tangents
  18556. */
  18557. readonly supportsTangents: boolean;
  18558. /**
  18559. * Gets the number of targets stored in this manager
  18560. */
  18561. readonly numTargets: number;
  18562. /**
  18563. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18564. */
  18565. readonly numInfluencers: number;
  18566. /**
  18567. * Gets the list of influences (one per target)
  18568. */
  18569. readonly influences: Float32Array;
  18570. /**
  18571. * Gets the active target at specified index. An active target is a target with an influence > 0
  18572. * @param index defines the index to check
  18573. * @returns the requested target
  18574. */
  18575. getActiveTarget(index: number): MorphTarget;
  18576. /**
  18577. * Gets the target at specified index
  18578. * @param index defines the index to check
  18579. * @returns the requested target
  18580. */
  18581. getTarget(index: number): MorphTarget;
  18582. /**
  18583. * Add a new target to this manager
  18584. * @param target defines the target to add
  18585. */
  18586. addTarget(target: MorphTarget): void;
  18587. /**
  18588. * Removes a target from the manager
  18589. * @param target defines the target to remove
  18590. */
  18591. removeTarget(target: MorphTarget): void;
  18592. /**
  18593. * Serializes the current manager into a Serialization object
  18594. * @returns the serialized object
  18595. */
  18596. serialize(): any;
  18597. private _syncActiveTargets(needUpdate);
  18598. /**
  18599. * Syncrhonize the targets with all the meshes using this morph target manager
  18600. */
  18601. synchronize(): void;
  18602. /**
  18603. * Creates a new MorphTargetManager from serialized data
  18604. * @param serializationObject defines the serialized data
  18605. * @param scene defines the hosting scene
  18606. * @returns the new MorphTargetManager
  18607. */
  18608. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18609. }
  18610. }
  18611. declare module BABYLON {
  18612. /**
  18613. * Class used to store all common mesh properties
  18614. */
  18615. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18616. /** No occlusion */
  18617. static OCCLUSION_TYPE_NONE: number;
  18618. /** Occlusion set to optimisitic */
  18619. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18620. /** Occlusion set to strict */
  18621. static OCCLUSION_TYPE_STRICT: number;
  18622. /** Use an accurante occlusion algorithm */
  18623. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18624. /** Use a conservative occlusion algorithm */
  18625. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18626. /**
  18627. * No billboard
  18628. */
  18629. static readonly BILLBOARDMODE_NONE: number;
  18630. /** Billboard on X axis */
  18631. static readonly BILLBOARDMODE_X: number;
  18632. /** Billboard on Y axis */
  18633. static readonly BILLBOARDMODE_Y: number;
  18634. /** Billboard on Z axis */
  18635. static readonly BILLBOARDMODE_Z: number;
  18636. /** Billboard on all axes */
  18637. static readonly BILLBOARDMODE_ALL: number;
  18638. private _facetPositions;
  18639. private _facetNormals;
  18640. private _facetPartitioning;
  18641. private _facetNb;
  18642. private _partitioningSubdivisions;
  18643. private _partitioningBBoxRatio;
  18644. private _facetDataEnabled;
  18645. private _facetParameters;
  18646. private _bbSize;
  18647. private _subDiv;
  18648. private _facetDepthSort;
  18649. private _facetDepthSortEnabled;
  18650. private _depthSortedIndices;
  18651. private _depthSortedFacets;
  18652. private _facetDepthSortFunction;
  18653. private _facetDepthSortFrom;
  18654. private _facetDepthSortOrigin;
  18655. private _invertedMatrix;
  18656. /**
  18657. * Gets the number of facets in the mesh
  18658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18659. */
  18660. readonly facetNb: number;
  18661. /**
  18662. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18664. */
  18665. partitioningSubdivisions: number;
  18666. /**
  18667. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18668. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18670. */
  18671. partitioningBBoxRatio: number;
  18672. /**
  18673. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18674. * Works only for updatable meshes.
  18675. * Doesn't work with multi-materials
  18676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18677. */
  18678. mustDepthSortFacets: boolean;
  18679. /**
  18680. * The location (Vector3) where the facet depth sort must be computed from.
  18681. * By default, the active camera position.
  18682. * Used only when facet depth sort is enabled
  18683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18684. */
  18685. facetDepthSortFrom: Vector3;
  18686. /**
  18687. * gets a boolean indicating if facetData is enabled
  18688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18689. */
  18690. readonly isFacetDataEnabled: boolean;
  18691. /** @hidden */
  18692. _updateNonUniformScalingState(value: boolean): boolean;
  18693. /**
  18694. * An event triggered when this mesh collides with another one
  18695. */
  18696. onCollideObservable: Observable<AbstractMesh>;
  18697. private _onCollideObserver;
  18698. /** Set a function to call when this mesh collides with another one */
  18699. onCollide: () => void;
  18700. /**
  18701. * An event triggered when the collision's position changes
  18702. */
  18703. onCollisionPositionChangeObservable: Observable<Vector3>;
  18704. private _onCollisionPositionChangeObserver;
  18705. /** Set a function to call when the collision's position changes */
  18706. onCollisionPositionChange: () => void;
  18707. /**
  18708. * An event triggered when material is changed
  18709. */
  18710. onMaterialChangedObservable: Observable<AbstractMesh>;
  18711. /**
  18712. * Gets or sets the orientation for POV movement & rotation
  18713. */
  18714. definedFacingForward: boolean;
  18715. /**
  18716. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18717. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18718. * * 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.
  18719. * @see http://doc.babylonjs.com/features/occlusionquery
  18720. */
  18721. occlusionQueryAlgorithmType: number;
  18722. /**
  18723. * 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:
  18724. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18725. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18726. * * 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.
  18727. * @see http://doc.babylonjs.com/features/occlusionquery
  18728. */
  18729. occlusionType: number;
  18730. /**
  18731. * 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.
  18732. * The default value is -1 which means don't break the query and wait till the result
  18733. * @see http://doc.babylonjs.com/features/occlusionquery
  18734. */
  18735. occlusionRetryCount: number;
  18736. private _occlusionInternalRetryCounter;
  18737. protected _isOccluded: boolean;
  18738. /**
  18739. * 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
  18740. * @see http://doc.babylonjs.com/features/occlusionquery
  18741. */
  18742. isOccluded: boolean;
  18743. private _isOcclusionQueryInProgress;
  18744. /**
  18745. * Flag to check the progress status of the query
  18746. * @see http://doc.babylonjs.com/features/occlusionquery
  18747. */
  18748. readonly isOcclusionQueryInProgress: boolean;
  18749. private _occlusionQuery;
  18750. private _visibility;
  18751. /**
  18752. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18753. */
  18754. /**
  18755. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18756. */
  18757. visibility: number;
  18758. /** Gets or sets the alpha index used to sort transparent meshes
  18759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18760. */
  18761. alphaIndex: number;
  18762. /**
  18763. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18764. */
  18765. isVisible: boolean;
  18766. /**
  18767. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18768. */
  18769. isPickable: boolean;
  18770. /**
  18771. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18772. */
  18773. showBoundingBox: boolean;
  18774. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18775. showSubMeshesBoundingBox: boolean;
  18776. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18777. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18778. */
  18779. isBlocker: boolean;
  18780. /**
  18781. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18782. */
  18783. enablePointerMoveEvents: boolean;
  18784. /**
  18785. * Specifies the rendering group id for this mesh (0 by default)
  18786. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18787. */
  18788. renderingGroupId: number;
  18789. private _material;
  18790. /** Gets or sets current material */
  18791. material: Nullable<Material>;
  18792. private _receiveShadows;
  18793. /**
  18794. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18795. * @see http://doc.babylonjs.com/babylon101/shadows
  18796. */
  18797. receiveShadows: boolean;
  18798. /**
  18799. * Gets or sets a boolean indicating if the outline must be rendered as well
  18800. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18801. */
  18802. renderOutline: boolean;
  18803. /** Defines color to use when rendering outline */
  18804. outlineColor: Color3;
  18805. /** Define width to use when rendering outline */
  18806. outlineWidth: number;
  18807. /**
  18808. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18809. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18810. */
  18811. renderOverlay: boolean;
  18812. /** Defines color to use when rendering overlay */
  18813. overlayColor: Color3;
  18814. /** Defines alpha to use when rendering overlay */
  18815. overlayAlpha: number;
  18816. private _hasVertexAlpha;
  18817. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18818. hasVertexAlpha: boolean;
  18819. private _useVertexColors;
  18820. /** 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) */
  18821. useVertexColors: boolean;
  18822. private _computeBonesUsingShaders;
  18823. /**
  18824. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18825. */
  18826. computeBonesUsingShaders: boolean;
  18827. private _numBoneInfluencers;
  18828. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18829. numBoneInfluencers: number;
  18830. private _applyFog;
  18831. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18832. applyFog: boolean;
  18833. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18834. useOctreeForRenderingSelection: boolean;
  18835. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18836. useOctreeForPicking: boolean;
  18837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18838. useOctreeForCollisions: boolean;
  18839. private _layerMask;
  18840. /**
  18841. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18842. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18843. */
  18844. layerMask: number;
  18845. /**
  18846. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18847. */
  18848. alwaysSelectAsActiveMesh: boolean;
  18849. /**
  18850. * Gets or sets the current action manager
  18851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18852. */
  18853. actionManager: Nullable<ActionManager>;
  18854. /**
  18855. * Gets or sets impostor used for physic simulation
  18856. * @see http://doc.babylonjs.com/features/physics_engine
  18857. */
  18858. physicsImpostor: Nullable<PhysicsImpostor>;
  18859. private _checkCollisions;
  18860. private _collisionMask;
  18861. private _collisionGroup;
  18862. /**
  18863. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18864. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18865. */
  18866. ellipsoid: Vector3;
  18867. /**
  18868. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18869. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18870. */
  18871. ellipsoidOffset: Vector3;
  18872. private _collider;
  18873. private _oldPositionForCollisions;
  18874. private _diffPositionForCollisions;
  18875. /**
  18876. * Gets or sets a collision mask used to mask collisions (default is -1).
  18877. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18878. */
  18879. collisionMask: number;
  18880. /**
  18881. * Gets or sets the current collision group mask (-1 by default).
  18882. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18883. */
  18884. collisionGroup: number;
  18885. /**
  18886. * Defines edge width used when edgesRenderer is enabled
  18887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18888. */
  18889. edgesWidth: number;
  18890. /**
  18891. * Defines edge color used when edgesRenderer is enabled
  18892. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18893. */
  18894. edgesColor: Color4;
  18895. /** @hidden */
  18896. _edgesRenderer: Nullable<EdgesRenderer>;
  18897. private _collisionsTransformMatrix;
  18898. private _collisionsScalingMatrix;
  18899. /** @hidden */
  18900. _masterMesh: Nullable<AbstractMesh>;
  18901. /** @hidden */
  18902. _boundingInfo: Nullable<BoundingInfo>;
  18903. /** @hidden */
  18904. _renderId: number;
  18905. /**
  18906. * Gets or sets the list of subMeshes
  18907. * @see http://doc.babylonjs.com/how_to/multi_materials
  18908. */
  18909. subMeshes: SubMesh[];
  18910. /** @hidden */
  18911. _submeshesOctree: Octree<SubMesh>;
  18912. /** @hidden */
  18913. _intersectionsInProgress: AbstractMesh[];
  18914. /** @hidden */
  18915. _unIndexed: boolean;
  18916. /** @hidden */
  18917. _lightSources: Light[];
  18918. /** @hidden */
  18919. readonly _positions: Nullable<Vector3[]>;
  18920. /** @hidden */
  18921. _waitingActions: any;
  18922. /** @hidden */
  18923. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18924. private _skeleton;
  18925. /** @hidden */
  18926. _bonesTransformMatrices: Nullable<Float32Array>;
  18927. /**
  18928. * Gets or sets a skeleton to apply skining transformations
  18929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18930. */
  18931. skeleton: Nullable<Skeleton>;
  18932. /**
  18933. * Creates a new AbstractMesh
  18934. * @param name defines the name of the mesh
  18935. * @param scene defines the hosting scene
  18936. */
  18937. constructor(name: string, scene?: Nullable<Scene>);
  18938. /**
  18939. * Returns the string "AbstractMesh"
  18940. * @returns "AbstractMesh"
  18941. */
  18942. getClassName(): string;
  18943. /**
  18944. * Gets a string representation of the current mesh
  18945. * @param fullDetails defines a boolean indicating if full details must be included
  18946. * @returns a string representation of the current mesh
  18947. */
  18948. toString(fullDetails?: boolean): string;
  18949. /** @hidden */
  18950. _rebuild(): void;
  18951. /** @hidden */
  18952. _resyncLightSources(): void;
  18953. /** @hidden */
  18954. _resyncLighSource(light: Light): void;
  18955. /** @hidden */
  18956. _unBindEffect(): void;
  18957. /** @hidden */
  18958. _removeLightSource(light: Light): void;
  18959. private _markSubMeshesAsDirty(func);
  18960. /** @hidden */
  18961. _markSubMeshesAsLightDirty(): void;
  18962. /** @hidden */
  18963. _markSubMeshesAsAttributesDirty(): void;
  18964. /** @hidden */
  18965. _markSubMeshesAsMiscDirty(): void;
  18966. /**
  18967. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18968. */
  18969. scaling: Vector3;
  18970. /**
  18971. * Disables the mesh edge rendering mode
  18972. * @returns the currentAbstractMesh
  18973. */
  18974. disableEdgesRendering(): AbstractMesh;
  18975. /**
  18976. * Enables the edge rendering mode on the mesh.
  18977. * This mode makes the mesh edges visible
  18978. * @param epsilon defines the maximal distance between two angles to detect a face
  18979. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18980. * @returns the currentAbstractMesh
  18981. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18982. */
  18983. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18984. /**
  18985. * Gets the edgesRenderer associated with the mesh
  18986. */
  18987. readonly edgesRenderer: Nullable<EdgesRenderer>;
  18988. /**
  18989. * Returns true if the mesh is blocked. Implemented by child classes
  18990. */
  18991. readonly isBlocked: boolean;
  18992. /**
  18993. * Returns the mesh itself by default. Implemented by child classes
  18994. * @param camera defines the camera to use to pick the right LOD level
  18995. * @returns the currentAbstractMesh
  18996. */
  18997. getLOD(camera: Camera): Nullable<AbstractMesh>;
  18998. /**
  18999. * Returns 0 by default. Implemented by child classes
  19000. * @returns an integer
  19001. */
  19002. getTotalVertices(): number;
  19003. /**
  19004. * Returns null by default. Implemented by child classes
  19005. * @returns null
  19006. */
  19007. getIndices(): Nullable<IndicesArray>;
  19008. /**
  19009. * Returns the array of the requested vertex data kind. Implemented by child classes
  19010. * @param kind defines the vertex data kind to use
  19011. * @returns null
  19012. */
  19013. getVerticesData(kind: string): Nullable<FloatArray>;
  19014. /**
  19015. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19016. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19017. * Note that a new underlying VertexBuffer object is created each call.
  19018. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19019. * @param kind defines vertex data kind:
  19020. * * BABYLON.VertexBuffer.PositionKind
  19021. * * BABYLON.VertexBuffer.UVKind
  19022. * * BABYLON.VertexBuffer.UV2Kind
  19023. * * BABYLON.VertexBuffer.UV3Kind
  19024. * * BABYLON.VertexBuffer.UV4Kind
  19025. * * BABYLON.VertexBuffer.UV5Kind
  19026. * * BABYLON.VertexBuffer.UV6Kind
  19027. * * BABYLON.VertexBuffer.ColorKind
  19028. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19029. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19030. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19031. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19032. * @param data defines the data source
  19033. * @param updatable defines if the data must be flagged as updatable (or static)
  19034. * @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
  19035. * @returns the current mesh
  19036. */
  19037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19038. /**
  19039. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19040. * If the mesh has no geometry, it is simply returned as it is.
  19041. * @param kind defines vertex data kind:
  19042. * * BABYLON.VertexBuffer.PositionKind
  19043. * * BABYLON.VertexBuffer.UVKind
  19044. * * BABYLON.VertexBuffer.UV2Kind
  19045. * * BABYLON.VertexBuffer.UV3Kind
  19046. * * BABYLON.VertexBuffer.UV4Kind
  19047. * * BABYLON.VertexBuffer.UV5Kind
  19048. * * BABYLON.VertexBuffer.UV6Kind
  19049. * * BABYLON.VertexBuffer.ColorKind
  19050. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19051. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19052. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19053. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19054. * @param data defines the data source
  19055. * @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
  19056. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19057. * @returns the current mesh
  19058. */
  19059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19060. /**
  19061. * Sets the mesh indices,
  19062. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19063. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19064. * @param totalVertices Defines the total number of vertices
  19065. * @returns the current mesh
  19066. */
  19067. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19068. /**
  19069. * Gets a boolean indicating if specific vertex data is present
  19070. * @param kind defines the vertex data kind to use
  19071. * @returns true is data kind is present
  19072. */
  19073. isVerticesDataPresent(kind: string): boolean;
  19074. /**
  19075. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19076. * @returns a BoundingInfo
  19077. */
  19078. getBoundingInfo(): BoundingInfo;
  19079. /**
  19080. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19081. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19082. * @returns the current mesh
  19083. */
  19084. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19085. /**
  19086. * Overwrite the current bounding info
  19087. * @param boundingInfo defines the new bounding info
  19088. * @returns the current mesh
  19089. */
  19090. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19091. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19092. readonly useBones: boolean;
  19093. /** @hidden */
  19094. _preActivate(): void;
  19095. /** @hidden */
  19096. _preActivateForIntermediateRendering(renderId: number): void;
  19097. /** @hidden */
  19098. _activate(renderId: number): void;
  19099. /**
  19100. * Gets the current world matrix
  19101. * @returns a Matrix
  19102. */
  19103. getWorldMatrix(): Matrix;
  19104. /** @hidden */
  19105. _getWorldMatrixDeterminant(): number;
  19106. /**
  19107. * Perform relative position change from the point of view of behind the front of the mesh.
  19108. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19109. * Supports definition of mesh facing forward or backward
  19110. * @param amountRight defines the distance on the right axis
  19111. * @param amountUp defines the distance on the up axis
  19112. * @param amountForward defines the distance on the forward axis
  19113. * @returns the current mesh
  19114. */
  19115. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19116. /**
  19117. * Calculate relative position change from the point of view of behind the front of the mesh.
  19118. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19119. * Supports definition of mesh facing forward or backward
  19120. * @param amountRight defines the distance on the right axis
  19121. * @param amountUp defines the distance on the up axis
  19122. * @param amountForward defines the distance on the forward axis
  19123. * @returns the new displacement vector
  19124. */
  19125. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19126. /**
  19127. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19128. * Supports definition of mesh facing forward or backward
  19129. * @param flipBack defines the flip
  19130. * @param twirlClockwise defines the twirl
  19131. * @param tiltRight defines the tilt
  19132. * @returns the current mesh
  19133. */
  19134. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19135. /**
  19136. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19137. * Supports definition of mesh facing forward or backward.
  19138. * @param flipBack defines the flip
  19139. * @param twirlClockwise defines the twirl
  19140. * @param tiltRight defines the tilt
  19141. * @returns the new rotation vector
  19142. */
  19143. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19144. /**
  19145. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19146. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19147. * @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
  19148. * @returns the new bounding vectors
  19149. */
  19150. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19151. min: Vector3;
  19152. max: Vector3;
  19153. };
  19154. /** @hidden */
  19155. _updateBoundingInfo(): AbstractMesh;
  19156. /** @hidden */
  19157. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19158. /** @hidden */
  19159. protected _afterComputeWorldMatrix(): void;
  19160. /**
  19161. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19162. * A mesh is in the frustum if its bounding box intersects the frustum
  19163. * @param frustumPlanes defines the frustum to test
  19164. * @returns true if the mesh is in the frustum planes
  19165. */
  19166. isInFrustum(frustumPlanes: Plane[]): boolean;
  19167. /**
  19168. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19169. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19170. * @param frustumPlanes defines the frustum to test
  19171. * @returns true if the mesh is completely in the frustum planes
  19172. */
  19173. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19174. /**
  19175. * True if the mesh intersects another mesh or a SolidParticle object
  19176. * @param mesh defines a target mesh or SolidParticle to test
  19177. * @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)
  19178. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19179. * @returns true if there is an intersection
  19180. */
  19181. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19182. /**
  19183. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19184. * @param point defines the point to test
  19185. * @returns true if there is an intersection
  19186. */
  19187. intersectsPoint(point: Vector3): boolean;
  19188. /**
  19189. * Gets the current physics impostor
  19190. * @see http://doc.babylonjs.com/features/physics_engine
  19191. * @returns a physics impostor or null
  19192. */
  19193. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19194. /**
  19195. * Gets the position of the current mesh in camera space
  19196. * @param camera defines the camera to use
  19197. * @returns a position
  19198. */
  19199. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19200. /**
  19201. * Returns the distance from the mesh to the active camera
  19202. * @param camera defines the camera to use
  19203. * @returns the distance
  19204. */
  19205. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19206. /**
  19207. * Apply a physic impulse to the mesh
  19208. * @param force defines the force to apply
  19209. * @param contactPoint defines where to apply the force
  19210. * @returns the current mesh
  19211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19212. */
  19213. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19214. /**
  19215. * Creates a physic joint between two meshes
  19216. * @param otherMesh defines the other mesh to use
  19217. * @param pivot1 defines the pivot to use on this mesh
  19218. * @param pivot2 defines the pivot to use on the other mesh
  19219. * @param options defines additional options (can be plugin dependent)
  19220. * @returns the current mesh
  19221. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19222. */
  19223. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19224. /**
  19225. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19226. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19227. */
  19228. checkCollisions: boolean;
  19229. /**
  19230. * Gets Collider object used to compute collisions (not physics)
  19231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19232. */
  19233. readonly collider: Collider;
  19234. /**
  19235. * Move the mesh using collision engine
  19236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19237. * @param displacement defines the requested displacement vector
  19238. * @returns the current mesh
  19239. */
  19240. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19241. private _onCollisionPositionChange;
  19242. /**
  19243. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19244. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19245. * @param maxCapacity defines the maximum size of each block (64 by default)
  19246. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19247. * @returns the new octree
  19248. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19250. */
  19251. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19252. /** @hidden */
  19253. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19254. /** @hidden */
  19255. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19256. /** @hidden */
  19257. _checkCollision(collider: Collider): AbstractMesh;
  19258. /** @hidden */
  19259. _generatePointsArray(): boolean;
  19260. /**
  19261. * Checks if the passed Ray intersects with the mesh
  19262. * @param ray defines the ray to use
  19263. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19264. * @returns the picking info
  19265. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19266. */
  19267. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19268. /**
  19269. * Clones the current mesh
  19270. * @param name defines the mesh name
  19271. * @param newParent defines the new mesh parent
  19272. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19273. * @returns the new mesh
  19274. */
  19275. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19276. /**
  19277. * Disposes all the submeshes of the current meshnp
  19278. * @returns the current mesh
  19279. */
  19280. releaseSubMeshes(): AbstractMesh;
  19281. /**
  19282. * Releases resources associated with this abstract mesh.
  19283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19285. */
  19286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19287. /**
  19288. * Adds the passed mesh as a child to the current mesh
  19289. * @param mesh defines the child mesh
  19290. * @returns the current mesh
  19291. */
  19292. addChild(mesh: AbstractMesh): AbstractMesh;
  19293. /**
  19294. * Removes the passed mesh from the current mesh children list
  19295. * @param mesh defines the child mesh
  19296. * @returns the current mesh
  19297. */
  19298. removeChild(mesh: AbstractMesh): AbstractMesh;
  19299. /** @hidden */
  19300. private _initFacetData();
  19301. /**
  19302. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19303. * This method can be called within the render loop.
  19304. * 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
  19305. * @returns the current mesh
  19306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19307. */
  19308. updateFacetData(): AbstractMesh;
  19309. /**
  19310. * Returns the facetLocalNormals array.
  19311. * The normals are expressed in the mesh local spac
  19312. * @returns an array of Vector3
  19313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19314. */
  19315. getFacetLocalNormals(): Vector3[];
  19316. /**
  19317. * Returns the facetLocalPositions array.
  19318. * The facet positions are expressed in the mesh local space
  19319. * @returns an array of Vector3
  19320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19321. */
  19322. getFacetLocalPositions(): Vector3[];
  19323. /**
  19324. * Returns the facetLocalPartioning array
  19325. * @returns an array of array of numbers
  19326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19327. */
  19328. getFacetLocalPartitioning(): number[][];
  19329. /**
  19330. * Returns the i-th facet position in the world system.
  19331. * This method allocates a new Vector3 per call
  19332. * @param i defines the facet index
  19333. * @returns a new Vector3
  19334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19335. */
  19336. getFacetPosition(i: number): Vector3;
  19337. /**
  19338. * Sets the reference Vector3 with the i-th facet position in the world system
  19339. * @param i defines the facet index
  19340. * @param ref defines the target vector
  19341. * @returns the current mesh
  19342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19343. */
  19344. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19345. /**
  19346. * Returns the i-th facet normal in the world system.
  19347. * This method allocates a new Vector3 per call
  19348. * @param i defines the facet index
  19349. * @returns a new Vector3
  19350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19351. */
  19352. getFacetNormal(i: number): Vector3;
  19353. /**
  19354. * Sets the reference Vector3 with the i-th facet normal in the world system
  19355. * @param i defines the facet index
  19356. * @param ref defines the target vector
  19357. * @returns the current mesh
  19358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19359. */
  19360. getFacetNormalToRef(i: number, ref: Vector3): this;
  19361. /**
  19362. * 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)
  19363. * @param x defines x coordinate
  19364. * @param y defines y coordinate
  19365. * @param z defines z coordinate
  19366. * @returns the array of facet indexes
  19367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19368. */
  19369. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19370. /**
  19371. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19372. * @param projected sets as the (x,y,z) world projection on the facet
  19373. * @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
  19374. * @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
  19375. * @param x defines x coordinate
  19376. * @param y defines y coordinate
  19377. * @param z defines z coordinate
  19378. * @returns the face index if found (or null instead)
  19379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19380. */
  19381. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19382. /**
  19383. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19384. * @param projected sets as the (x,y,z) local projection on the facet
  19385. * @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
  19386. * @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
  19387. * @param x defines x coordinate
  19388. * @param y defines y coordinate
  19389. * @param z defines z coordinate
  19390. * @returns the face index if found (or null instead)
  19391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19392. */
  19393. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19394. /**
  19395. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19396. * @returns the parameters
  19397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19398. */
  19399. getFacetDataParameters(): any;
  19400. /**
  19401. * Disables the feature FacetData and frees the related memory
  19402. * @returns the current mesh
  19403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19404. */
  19405. disableFacetData(): AbstractMesh;
  19406. /**
  19407. * Updates the AbstractMesh indices array
  19408. * @param indices defines the data source
  19409. * @returns the current mesh
  19410. */
  19411. updateIndices(indices: IndicesArray): AbstractMesh;
  19412. /**
  19413. * Creates new normals data for the mesh
  19414. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19415. * @returns the current mesh
  19416. */
  19417. createNormals(updatable: boolean): AbstractMesh;
  19418. /**
  19419. * Align the mesh with a normal
  19420. * @param normal defines the normal to use
  19421. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19422. * @returns the current mesh
  19423. */
  19424. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19425. /** @hidden */
  19426. protected _checkOcclusionQuery(): void;
  19427. }
  19428. }
  19429. declare module BABYLON {
  19430. class Buffer {
  19431. private _engine;
  19432. private _buffer;
  19433. /** @hidden */
  19434. _data: Nullable<DataArray>;
  19435. private _updatable;
  19436. private _instanced;
  19437. /**
  19438. * Gets the byte stride.
  19439. */
  19440. readonly byteStride: number;
  19441. /**
  19442. * Constructor
  19443. * @param engine the engine
  19444. * @param data the data to use for this buffer
  19445. * @param updatable whether the data is updatable
  19446. * @param stride the stride (optional)
  19447. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19448. * @param instanced whether the buffer is instanced (optional)
  19449. * @param useBytes set to true if the stride in in bytes (optional)
  19450. */
  19451. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19452. /**
  19453. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19454. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19455. * @param offset defines offset in the buffer (0 by default)
  19456. * @param size defines the size in floats of attributes (position is 3 for instance)
  19457. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19458. * @param instanced defines if the vertex buffer contains indexed data
  19459. * @param useBytes defines if the offset and stride are in bytes
  19460. * @returns the new vertex buffer
  19461. */
  19462. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19463. isUpdatable(): boolean;
  19464. getData(): Nullable<DataArray>;
  19465. getBuffer(): Nullable<WebGLBuffer>;
  19466. /**
  19467. * Gets the stride in float32 units (i.e. byte stride / 4).
  19468. * May not be an integer if the byte stride is not divisible by 4.
  19469. * DEPRECATED. Use byteStride instead.
  19470. * @returns the stride in float32 units
  19471. */
  19472. getStrideSize(): number;
  19473. create(data?: Nullable<DataArray>): void;
  19474. _rebuild(): void;
  19475. update(data: DataArray): void;
  19476. /**
  19477. * Updates the data directly.
  19478. * @param data the new data
  19479. * @param offset the new offset
  19480. * @param vertexCount the vertex count (optional)
  19481. * @param useBytes set to true if the offset is in bytes
  19482. */
  19483. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19484. dispose(): void;
  19485. }
  19486. }
  19487. declare module BABYLON {
  19488. class CSG {
  19489. private polygons;
  19490. matrix: Matrix;
  19491. position: Vector3;
  19492. rotation: Vector3;
  19493. rotationQuaternion: Nullable<Quaternion>;
  19494. scaling: Vector3;
  19495. static FromMesh(mesh: Mesh): CSG;
  19496. private static FromPolygons(polygons);
  19497. clone(): CSG;
  19498. union(csg: CSG): CSG;
  19499. unionInPlace(csg: CSG): void;
  19500. subtract(csg: CSG): CSG;
  19501. subtractInPlace(csg: CSG): void;
  19502. intersect(csg: CSG): CSG;
  19503. intersectInPlace(csg: CSG): void;
  19504. inverse(): CSG;
  19505. inverseInPlace(): void;
  19506. copyTransformAttributes(csg: CSG): CSG;
  19507. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19508. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19509. }
  19510. }
  19511. declare module BABYLON {
  19512. /**
  19513. * Class used to store geometry data (vertex buffers + index buffer)
  19514. */
  19515. class Geometry implements IGetSetVerticesData {
  19516. /**
  19517. * Gets or sets the unique ID of the geometry
  19518. */
  19519. id: string;
  19520. /**
  19521. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19522. */
  19523. delayLoadState: number;
  19524. /**
  19525. * Gets the file containing the data to load when running in delay load state
  19526. */
  19527. delayLoadingFile: Nullable<string>;
  19528. /**
  19529. * Callback called when the geometry is updated
  19530. */
  19531. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19532. private _scene;
  19533. private _engine;
  19534. private _meshes;
  19535. private _totalVertices;
  19536. /** @hidden */
  19537. _indices: IndicesArray;
  19538. /** @hidden */
  19539. _vertexBuffers: {
  19540. [key: string]: VertexBuffer;
  19541. };
  19542. private _isDisposed;
  19543. private _extend;
  19544. private _boundingBias;
  19545. /** @hidden */
  19546. _delayInfo: Array<string>;
  19547. private _indexBuffer;
  19548. private _indexBufferIsUpdatable;
  19549. /** @hidden */
  19550. _boundingInfo: Nullable<BoundingInfo>;
  19551. /** @hidden */
  19552. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19553. /** @hidden */
  19554. _softwareSkinningRenderId: number;
  19555. private _vertexArrayObjects;
  19556. private _updatable;
  19557. /** @hidden */
  19558. _positions: Nullable<Vector3[]>;
  19559. /**
  19560. * 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
  19561. */
  19562. /**
  19563. * 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
  19564. */
  19565. boundingBias: Vector2;
  19566. /**
  19567. * Static function used to attach a new empty geometry to a mesh
  19568. * @param mesh defines the mesh to attach the geometry to
  19569. * @returns the new {BABYLON.Geometry}
  19570. */
  19571. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19572. /**
  19573. * Creates a new geometry
  19574. * @param id defines the unique ID
  19575. * @param scene defines the hosting scene
  19576. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19577. * @param updatable defines if geometry must be updatable (false by default)
  19578. * @param mesh defines the mesh that will be associated with the geometry
  19579. */
  19580. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19581. /**
  19582. * Gets the current extend of the geometry
  19583. */
  19584. readonly extend: {
  19585. minimum: Vector3;
  19586. maximum: Vector3;
  19587. };
  19588. /**
  19589. * Gets the hosting scene
  19590. * @returns the hosting {BABYLON.Scene}
  19591. */
  19592. getScene(): Scene;
  19593. /**
  19594. * Gets the hosting engine
  19595. * @returns the hosting {BABYLON.Engine}
  19596. */
  19597. getEngine(): Engine;
  19598. /**
  19599. * Defines if the geometry is ready to use
  19600. * @returns true if the geometry is ready to be used
  19601. */
  19602. isReady(): boolean;
  19603. /**
  19604. * Gets a value indicating that the geometry should not be serialized
  19605. */
  19606. readonly doNotSerialize: boolean;
  19607. /** @hidden */
  19608. _rebuild(): void;
  19609. /**
  19610. * Affects all geometry data in one call
  19611. * @param vertexData defines the geometry data
  19612. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19613. */
  19614. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19615. /**
  19616. * Set specific vertex data
  19617. * @param kind defines the data kind (Position, normal, etc...)
  19618. * @param data defines the vertex data to use
  19619. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19620. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19621. */
  19622. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19623. /**
  19624. * Removes a specific vertex data
  19625. * @param kind defines the data kind (Position, normal, etc...)
  19626. */
  19627. removeVerticesData(kind: string): void;
  19628. /**
  19629. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19630. * @param buffer defines the vertex buffer to use
  19631. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19632. */
  19633. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19634. /**
  19635. * Update a specific vertex buffer
  19636. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19637. * It will do nothing if the buffer is not updatable
  19638. * @param kind defines the data kind (Position, normal, etc...)
  19639. * @param data defines the data to use
  19640. * @param offset defines the offset in the target buffer where to store the data
  19641. * @param useBytes set to true if the offset is in bytes
  19642. */
  19643. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19644. /**
  19645. * Update a specific vertex buffer
  19646. * This function will create a new buffer if the current one is not updatable
  19647. * @param kind defines the data kind (Position, normal, etc...)
  19648. * @param data defines the data to use
  19649. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19650. */
  19651. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19652. private _updateBoundingInfo(updateExtends, data);
  19653. /** @hidden */
  19654. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19655. /**
  19656. * Gets total number of vertices
  19657. * @returns the total number of vertices
  19658. */
  19659. getTotalVertices(): number;
  19660. /**
  19661. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19662. * @param kind defines the data kind (Position, normal, etc...)
  19663. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19665. * @returns a float array containing vertex data
  19666. */
  19667. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19668. /**
  19669. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19670. * @param kind defines the data kind (Position, normal, etc...)
  19671. * @returns true if the vertex buffer with the specified kind is updatable
  19672. */
  19673. isVertexBufferUpdatable(kind: string): boolean;
  19674. /**
  19675. * Gets a specific vertex buffer
  19676. * @param kind defines the data kind (Position, normal, etc...)
  19677. * @returns a {BABYLON.VertexBuffer}
  19678. */
  19679. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19680. /**
  19681. * Returns all vertex buffers
  19682. * @return an object holding all vertex buffers indexed by kind
  19683. */
  19684. getVertexBuffers(): Nullable<{
  19685. [key: string]: VertexBuffer;
  19686. }>;
  19687. /**
  19688. * Gets a boolean indicating if specific vertex buffer is present
  19689. * @param kind defines the data kind (Position, normal, etc...)
  19690. * @returns true if data is present
  19691. */
  19692. isVerticesDataPresent(kind: string): boolean;
  19693. /**
  19694. * Gets a list of all attached data kinds (Position, normal, etc...)
  19695. * @returns a list of string containing all kinds
  19696. */
  19697. getVerticesDataKinds(): string[];
  19698. /**
  19699. * Update index buffer
  19700. * @param indices defines the indices to store in the index buffer
  19701. * @param offset defines the offset in the target buffer where to store the data
  19702. */
  19703. updateIndices(indices: IndicesArray, offset?: number): void;
  19704. /**
  19705. * Creates a new index buffer
  19706. * @param indices defines the indices to store in the index buffer
  19707. * @param totalVertices defines the total number of vertices (could be null)
  19708. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19709. */
  19710. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19711. /**
  19712. * Return the total number of indices
  19713. * @returns the total number of indices
  19714. */
  19715. getTotalIndices(): number;
  19716. /**
  19717. * Gets the index buffer array
  19718. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19719. * @returns the index buffer array
  19720. */
  19721. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19722. /**
  19723. * Gets the index buffer
  19724. * @return the index buffer
  19725. */
  19726. getIndexBuffer(): Nullable<WebGLBuffer>;
  19727. /** @hidden */
  19728. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19729. /**
  19730. * Release the associated resources for a specific mesh
  19731. * @param mesh defines the source mesh
  19732. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19733. */
  19734. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19735. /**
  19736. * Apply current geometry to a given mesh
  19737. * @param mesh defines the mesh to apply geometry to
  19738. */
  19739. applyToMesh(mesh: Mesh): void;
  19740. private _updateExtend(data?);
  19741. private _applyToMesh(mesh);
  19742. private notifyUpdate(kind?);
  19743. /**
  19744. * Load the geometry if it was flagged as delay loaded
  19745. * @param scene defines the hosting scene
  19746. * @param onLoaded defines a callback called when the geometry is loaded
  19747. */
  19748. load(scene: Scene, onLoaded?: () => void): void;
  19749. private _queueLoad(scene, onLoaded?);
  19750. /**
  19751. * Invert the geometry to move from a right handed system to a left handed one.
  19752. */
  19753. toLeftHanded(): void;
  19754. /** @hidden */
  19755. _resetPointsArrayCache(): void;
  19756. /** @hidden */
  19757. _generatePointsArray(): boolean;
  19758. /**
  19759. * Gets a value indicating if the geometry is disposed
  19760. * @returns true if the geometry was disposed
  19761. */
  19762. isDisposed(): boolean;
  19763. private _disposeVertexArrayObjects();
  19764. /**
  19765. * Free all associated resources
  19766. */
  19767. dispose(): void;
  19768. /**
  19769. * Clone the current geometry into a new geometry
  19770. * @param id defines the unique ID of the new geometry
  19771. * @returns a new geometry object
  19772. */
  19773. copy(id: string): Geometry;
  19774. /**
  19775. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19776. * @return a JSON representation of the current geometry data (without the vertices data)
  19777. */
  19778. serialize(): any;
  19779. private toNumberArray(origin);
  19780. /**
  19781. * Serialize all vertices data into a JSON oject
  19782. * @returns a JSON representation of the current geometry data
  19783. */
  19784. serializeVerticeData(): any;
  19785. /**
  19786. * Extracts a clone of a mesh geometry
  19787. * @param mesh defines the source mesh
  19788. * @param id defines the unique ID of the new geometry object
  19789. * @returns the new geometry object
  19790. */
  19791. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19792. /**
  19793. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19794. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19795. * Be aware Math.random() could cause collisions, but:
  19796. * "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"
  19797. * @returns a string containing a new GUID
  19798. */
  19799. static RandomId(): string;
  19800. /** @hidden */
  19801. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19802. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19803. /**
  19804. * Create a new geometry from persisted data (Using .babylon file format)
  19805. * @param parsedVertexData defines the persisted data
  19806. * @param scene defines the hosting scene
  19807. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19808. * @returns the new geometry object
  19809. */
  19810. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19811. }
  19812. /**
  19813. * Abstract class used to provide common services for all typed geometries
  19814. * @hidden
  19815. */
  19816. class _PrimitiveGeometry extends Geometry {
  19817. private _canBeRegenerated;
  19818. private _beingRegenerated;
  19819. /**
  19820. * Creates a new typed geometry
  19821. * @param id defines the unique ID of the geometry
  19822. * @param scene defines the hosting scene
  19823. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19824. * @param mesh defines the hosting mesh (can be null)
  19825. */
  19826. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19827. /**
  19828. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19829. * @returns true if the geometry can be regenerated
  19830. */
  19831. canBeRegenerated(): boolean;
  19832. /**
  19833. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19834. */
  19835. regenerate(): void;
  19836. /**
  19837. * Clone the geometry
  19838. * @param id defines the unique ID of the new geometry
  19839. * @returns the new geometry
  19840. */
  19841. asNewGeometry(id: string): Geometry;
  19842. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19843. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19844. /** @hidden */
  19845. _regenerateVertexData(): VertexData;
  19846. copy(id: string): Geometry;
  19847. serialize(): any;
  19848. }
  19849. /**
  19850. * Creates a ribbon geometry
  19851. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19852. */
  19853. class RibbonGeometry extends _PrimitiveGeometry {
  19854. /**
  19855. * Defines the array of paths to use
  19856. */
  19857. pathArray: Vector3[][];
  19858. /**
  19859. * Defines if the last and first points of each path in your pathArray must be joined
  19860. */
  19861. closeArray: boolean;
  19862. /**
  19863. * Defines if the last and first points of each path in your pathArray must be joined
  19864. */
  19865. closePath: boolean;
  19866. /**
  19867. * Defines the offset between points
  19868. */
  19869. offset: number;
  19870. /**
  19871. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19872. */
  19873. side: number;
  19874. /**
  19875. * Creates a ribbon geometry
  19876. * @param id defines the unique ID of the geometry
  19877. * @param scene defines the hosting scene
  19878. * @param pathArray defines the array of paths to use
  19879. * @param closeArray defines if the last path and the first path must be joined
  19880. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19881. * @param offset defines the offset between points
  19882. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19883. * @param mesh defines the hosting mesh (can be null)
  19884. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19885. */
  19886. constructor(id: string, scene: Scene,
  19887. /**
  19888. * Defines the array of paths to use
  19889. */
  19890. pathArray: Vector3[][],
  19891. /**
  19892. * Defines if the last and first points of each path in your pathArray must be joined
  19893. */
  19894. closeArray: boolean,
  19895. /**
  19896. * Defines if the last and first points of each path in your pathArray must be joined
  19897. */
  19898. closePath: boolean,
  19899. /**
  19900. * Defines the offset between points
  19901. */
  19902. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19903. /**
  19904. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19905. */
  19906. side?: number);
  19907. /** @hidden */
  19908. _regenerateVertexData(): VertexData;
  19909. copy(id: string): Geometry;
  19910. }
  19911. /**
  19912. * Creates a box geometry
  19913. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19914. */
  19915. class BoxGeometry extends _PrimitiveGeometry {
  19916. /**
  19917. * Defines the zise of the box (width, height and depth are the same)
  19918. */
  19919. size: number;
  19920. /**
  19921. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19922. */
  19923. side: number;
  19924. /**
  19925. * Creates a box geometry
  19926. * @param id defines the unique ID of the geometry
  19927. * @param scene defines the hosting scene
  19928. * @param size defines the zise of the box (width, height and depth are the same)
  19929. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19930. * @param mesh defines the hosting mesh (can be null)
  19931. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19932. */
  19933. constructor(id: string, scene: Scene,
  19934. /**
  19935. * Defines the zise of the box (width, height and depth are the same)
  19936. */
  19937. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19938. /**
  19939. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19940. */
  19941. side?: number);
  19942. _regenerateVertexData(): VertexData;
  19943. copy(id: string): Geometry;
  19944. serialize(): any;
  19945. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19946. }
  19947. /**
  19948. * Creates a sphere geometry
  19949. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19950. */
  19951. class SphereGeometry extends _PrimitiveGeometry {
  19952. /**
  19953. * Defines the number of segments to use to create the sphere
  19954. */
  19955. segments: number;
  19956. /**
  19957. * Defines the diameter of the sphere
  19958. */
  19959. diameter: number;
  19960. /**
  19961. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19962. */
  19963. side: number;
  19964. /**
  19965. * Create a new sphere geometry
  19966. * @param id defines the unique ID of the geometry
  19967. * @param scene defines the hosting scene
  19968. * @param segments defines the number of segments to use to create the sphere
  19969. * @param diameter defines the diameter of the sphere
  19970. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19971. * @param mesh defines the hosting mesh (can be null)
  19972. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19973. */
  19974. constructor(id: string, scene: Scene,
  19975. /**
  19976. * Defines the number of segments to use to create the sphere
  19977. */
  19978. segments: number,
  19979. /**
  19980. * Defines the diameter of the sphere
  19981. */
  19982. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19983. /**
  19984. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19985. */
  19986. side?: number);
  19987. _regenerateVertexData(): VertexData;
  19988. copy(id: string): Geometry;
  19989. serialize(): any;
  19990. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19991. }
  19992. /**
  19993. * Creates a disc geometry
  19994. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19995. */
  19996. class DiscGeometry extends _PrimitiveGeometry {
  19997. /**
  19998. * Defines the radius of the disc
  19999. */
  20000. radius: number;
  20001. /**
  20002. * Defines the tesselation factor to apply to the disc
  20003. */
  20004. tessellation: number;
  20005. /**
  20006. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20007. */
  20008. side: number;
  20009. /**
  20010. * Creates a new disc geometry
  20011. * @param id defines the unique ID of the geometry
  20012. * @param scene defines the hosting scene
  20013. * @param radius defines the radius of the disc
  20014. * @param tessellation defines the tesselation factor to apply to the disc
  20015. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20016. * @param mesh defines the hosting mesh (can be null)
  20017. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20018. */
  20019. constructor(id: string, scene: Scene,
  20020. /**
  20021. * Defines the radius of the disc
  20022. */
  20023. radius: number,
  20024. /**
  20025. * Defines the tesselation factor to apply to the disc
  20026. */
  20027. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20028. /**
  20029. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20030. */
  20031. side?: number);
  20032. _regenerateVertexData(): VertexData;
  20033. copy(id: string): Geometry;
  20034. }
  20035. /**
  20036. * Creates a new cylinder geometry
  20037. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20038. */
  20039. class CylinderGeometry extends _PrimitiveGeometry {
  20040. /**
  20041. * Defines the height of the cylinder
  20042. */
  20043. height: number;
  20044. /**
  20045. * Defines the diameter of the cylinder's top cap
  20046. */
  20047. diameterTop: number;
  20048. /**
  20049. * Defines the diameter of the cylinder's bottom cap
  20050. */
  20051. diameterBottom: number;
  20052. /**
  20053. * Defines the tessellation factor to apply to the cylinder
  20054. */
  20055. tessellation: number;
  20056. /**
  20057. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20058. */
  20059. subdivisions: number;
  20060. /**
  20061. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20062. */
  20063. side: number;
  20064. /**
  20065. * Creates a new cylinder geometry
  20066. * @param id defines the unique ID of the geometry
  20067. * @param scene defines the hosting scene
  20068. * @param height defines the height of the cylinder
  20069. * @param diameterTop defines the diameter of the cylinder's top cap
  20070. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20071. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20072. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20073. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20074. * @param mesh defines the hosting mesh (can be null)
  20075. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20076. */
  20077. constructor(id: string, scene: Scene,
  20078. /**
  20079. * Defines the height of the cylinder
  20080. */
  20081. height: number,
  20082. /**
  20083. * Defines the diameter of the cylinder's top cap
  20084. */
  20085. diameterTop: number,
  20086. /**
  20087. * Defines the diameter of the cylinder's bottom cap
  20088. */
  20089. diameterBottom: number,
  20090. /**
  20091. * Defines the tessellation factor to apply to the cylinder
  20092. */
  20093. tessellation: number,
  20094. /**
  20095. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20096. */
  20097. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20098. /**
  20099. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20100. */
  20101. side?: number);
  20102. _regenerateVertexData(): VertexData;
  20103. copy(id: string): Geometry;
  20104. serialize(): any;
  20105. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20106. }
  20107. /**
  20108. * Creates a new torus geometry
  20109. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20110. */
  20111. class TorusGeometry extends _PrimitiveGeometry {
  20112. /**
  20113. * Defines the diameter of the torus
  20114. */
  20115. diameter: number;
  20116. /**
  20117. * Defines the thickness of the torus (ie. internal diameter)
  20118. */
  20119. thickness: number;
  20120. /**
  20121. * Defines the tesselation factor to apply to the torus
  20122. */
  20123. tessellation: number;
  20124. /**
  20125. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20126. */
  20127. side: number;
  20128. /**
  20129. * Creates a new torus geometry
  20130. * @param id defines the unique ID of the geometry
  20131. * @param scene defines the hosting scene
  20132. * @param diameter defines the diameter of the torus
  20133. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20134. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20135. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20136. * @param mesh defines the hosting mesh (can be null)
  20137. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20138. */
  20139. constructor(id: string, scene: Scene,
  20140. /**
  20141. * Defines the diameter of the torus
  20142. */
  20143. diameter: number,
  20144. /**
  20145. * Defines the thickness of the torus (ie. internal diameter)
  20146. */
  20147. thickness: number,
  20148. /**
  20149. * Defines the tesselation factor to apply to the torus
  20150. */
  20151. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20152. /**
  20153. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20154. */
  20155. side?: number);
  20156. _regenerateVertexData(): VertexData;
  20157. copy(id: string): Geometry;
  20158. serialize(): any;
  20159. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20160. }
  20161. /**
  20162. * Creates a new ground geometry
  20163. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20164. */
  20165. class GroundGeometry extends _PrimitiveGeometry {
  20166. /**
  20167. * Defines the width of the ground
  20168. */
  20169. width: number;
  20170. /**
  20171. * Defines the height of the ground
  20172. */
  20173. height: number;
  20174. /**
  20175. * Defines the subdivisions to apply to the ground
  20176. */
  20177. subdivisions: number;
  20178. /**
  20179. * Creates a new ground geometry
  20180. * @param id defines the unique ID of the geometry
  20181. * @param scene defines the hosting scene
  20182. * @param width defines the width of the ground
  20183. * @param height defines the height of the ground
  20184. * @param subdivisions defines the subdivisions to apply to the ground
  20185. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20186. * @param mesh defines the hosting mesh (can be null)
  20187. */
  20188. constructor(id: string, scene: Scene,
  20189. /**
  20190. * Defines the width of the ground
  20191. */
  20192. width: number,
  20193. /**
  20194. * Defines the height of the ground
  20195. */
  20196. height: number,
  20197. /**
  20198. * Defines the subdivisions to apply to the ground
  20199. */
  20200. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20201. _regenerateVertexData(): VertexData;
  20202. copy(id: string): Geometry;
  20203. serialize(): any;
  20204. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20205. }
  20206. /**
  20207. * Creates a tiled ground geometry
  20208. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20209. */
  20210. class TiledGroundGeometry extends _PrimitiveGeometry {
  20211. /**
  20212. * Defines the minimum value on X axis
  20213. */
  20214. xmin: number;
  20215. /**
  20216. * Defines the minimum value on Z axis
  20217. */
  20218. zmin: number;
  20219. /**
  20220. * Defines the maximum value on X axis
  20221. */
  20222. xmax: number;
  20223. /**
  20224. * Defines the maximum value on Z axis
  20225. */
  20226. zmax: number;
  20227. /**
  20228. * Defines the subdivisions to apply to the ground
  20229. */
  20230. subdivisions: {
  20231. w: number;
  20232. h: number;
  20233. };
  20234. /**
  20235. * Defines the precision to use when computing the tiles
  20236. */
  20237. precision: {
  20238. w: number;
  20239. h: number;
  20240. };
  20241. /**
  20242. * Creates a tiled ground geometry
  20243. * @param id defines the unique ID of the geometry
  20244. * @param scene defines the hosting scene
  20245. * @param xmin defines the minimum value on X axis
  20246. * @param zmin defines the minimum value on Z axis
  20247. * @param xmax defines the maximum value on X axis
  20248. * @param zmax defines the maximum value on Z axis
  20249. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20250. * @param precision defines the precision to use when computing the tiles
  20251. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20252. * @param mesh defines the hosting mesh (can be null)
  20253. */
  20254. constructor(id: string, scene: Scene,
  20255. /**
  20256. * Defines the minimum value on X axis
  20257. */
  20258. xmin: number,
  20259. /**
  20260. * Defines the minimum value on Z axis
  20261. */
  20262. zmin: number,
  20263. /**
  20264. * Defines the maximum value on X axis
  20265. */
  20266. xmax: number,
  20267. /**
  20268. * Defines the maximum value on Z axis
  20269. */
  20270. zmax: number,
  20271. /**
  20272. * Defines the subdivisions to apply to the ground
  20273. */
  20274. subdivisions: {
  20275. w: number;
  20276. h: number;
  20277. },
  20278. /**
  20279. * Defines the precision to use when computing the tiles
  20280. */
  20281. precision: {
  20282. w: number;
  20283. h: number;
  20284. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20285. _regenerateVertexData(): VertexData;
  20286. copy(id: string): Geometry;
  20287. }
  20288. /**
  20289. * Creates a plane geometry
  20290. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20291. */
  20292. class PlaneGeometry extends _PrimitiveGeometry {
  20293. /**
  20294. * Defines the size of the plane (width === height)
  20295. */
  20296. size: number;
  20297. /**
  20298. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20299. */
  20300. side: number;
  20301. /**
  20302. * Creates a plane geometry
  20303. * @param id defines the unique ID of the geometry
  20304. * @param scene defines the hosting scene
  20305. * @param size defines the size of the plane (width === height)
  20306. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20307. * @param mesh defines the hosting mesh (can be null)
  20308. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20309. */
  20310. constructor(id: string, scene: Scene,
  20311. /**
  20312. * Defines the size of the plane (width === height)
  20313. */
  20314. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20315. /**
  20316. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20317. */
  20318. side?: number);
  20319. _regenerateVertexData(): VertexData;
  20320. copy(id: string): Geometry;
  20321. serialize(): any;
  20322. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20323. }
  20324. /**
  20325. * Creates a torus knot geometry
  20326. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20327. */
  20328. class TorusKnotGeometry extends _PrimitiveGeometry {
  20329. /**
  20330. * Defines the radius of the torus knot
  20331. */
  20332. radius: number;
  20333. /**
  20334. * Defines the thickness of the torus knot tube
  20335. */
  20336. tube: number;
  20337. /**
  20338. * Defines the number of radial segments
  20339. */
  20340. radialSegments: number;
  20341. /**
  20342. * Defines the number of tubular segments
  20343. */
  20344. tubularSegments: number;
  20345. /**
  20346. * Defines the first number of windings
  20347. */
  20348. p: number;
  20349. /**
  20350. * Defines the second number of windings
  20351. */
  20352. q: number;
  20353. /**
  20354. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20355. */
  20356. side: number;
  20357. /**
  20358. * Creates a torus knot geometry
  20359. * @param id defines the unique ID of the geometry
  20360. * @param scene defines the hosting scene
  20361. * @param radius defines the radius of the torus knot
  20362. * @param tube defines the thickness of the torus knot tube
  20363. * @param radialSegments defines the number of radial segments
  20364. * @param tubularSegments defines the number of tubular segments
  20365. * @param p defines the first number of windings
  20366. * @param q defines the second number of windings
  20367. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20368. * @param mesh defines the hosting mesh (can be null)
  20369. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20370. */
  20371. constructor(id: string, scene: Scene,
  20372. /**
  20373. * Defines the radius of the torus knot
  20374. */
  20375. radius: number,
  20376. /**
  20377. * Defines the thickness of the torus knot tube
  20378. */
  20379. tube: number,
  20380. /**
  20381. * Defines the number of radial segments
  20382. */
  20383. radialSegments: number,
  20384. /**
  20385. * Defines the number of tubular segments
  20386. */
  20387. tubularSegments: number,
  20388. /**
  20389. * Defines the first number of windings
  20390. */
  20391. p: number,
  20392. /**
  20393. * Defines the second number of windings
  20394. */
  20395. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20396. /**
  20397. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20398. */
  20399. side?: number);
  20400. _regenerateVertexData(): VertexData;
  20401. copy(id: string): Geometry;
  20402. serialize(): any;
  20403. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20404. }
  20405. }
  20406. declare module BABYLON {
  20407. class GroundMesh extends Mesh {
  20408. generateOctree: boolean;
  20409. private _heightQuads;
  20410. _subdivisionsX: number;
  20411. _subdivisionsY: number;
  20412. _width: number;
  20413. _height: number;
  20414. _minX: number;
  20415. _maxX: number;
  20416. _minZ: number;
  20417. _maxZ: number;
  20418. constructor(name: string, scene: Scene);
  20419. getClassName(): string;
  20420. readonly subdivisions: number;
  20421. readonly subdivisionsX: number;
  20422. readonly subdivisionsY: number;
  20423. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20424. /**
  20425. * Returns a height (y) value in the Worl system :
  20426. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20427. * Returns the ground y position if (x, z) are outside the ground surface.
  20428. */
  20429. getHeightAtCoordinates(x: number, z: number): number;
  20430. /**
  20431. * Returns a normalized vector (Vector3) orthogonal to the ground
  20432. * at the ground coordinates (x, z) expressed in the World system.
  20433. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20434. */
  20435. getNormalAtCoordinates(x: number, z: number): Vector3;
  20436. /**
  20437. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20438. * at the ground coordinates (x, z) expressed in the World system.
  20439. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20440. * Returns the GroundMesh.
  20441. */
  20442. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20443. /**
  20444. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20445. * if the ground has been updated.
  20446. * This can be used in the render loop.
  20447. * Returns the GroundMesh.
  20448. */
  20449. updateCoordinateHeights(): GroundMesh;
  20450. private _getFacetAt(x, z);
  20451. private _initHeightQuads();
  20452. private _computeHeightQuads();
  20453. serialize(serializationObject: any): void;
  20454. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20455. }
  20456. }
  20457. declare module BABYLON {
  20458. /**
  20459. * Creates an instance based on a source mesh.
  20460. */
  20461. class InstancedMesh extends AbstractMesh {
  20462. private _sourceMesh;
  20463. private _currentLOD;
  20464. constructor(name: string, source: Mesh);
  20465. /**
  20466. * Returns the string "InstancedMesh".
  20467. */
  20468. getClassName(): string;
  20469. readonly receiveShadows: boolean;
  20470. readonly material: Nullable<Material>;
  20471. readonly visibility: number;
  20472. readonly skeleton: Nullable<Skeleton>;
  20473. renderingGroupId: number;
  20474. /**
  20475. * Returns the total number of vertices (integer).
  20476. */
  20477. getTotalVertices(): number;
  20478. readonly sourceMesh: Mesh;
  20479. /**
  20480. * Is this node ready to be used/rendered
  20481. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20482. * @return {boolean} is it ready
  20483. */
  20484. isReady(completeCheck?: boolean): boolean;
  20485. /**
  20486. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20487. */
  20488. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20489. /**
  20490. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20491. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20492. * The `data` are either a numeric array either a Float32Array.
  20493. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20494. * 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).
  20495. * Note that a new underlying VertexBuffer object is created each call.
  20496. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20497. *
  20498. * Possible `kind` values :
  20499. * - BABYLON.VertexBuffer.PositionKind
  20500. * - BABYLON.VertexBuffer.UVKind
  20501. * - BABYLON.VertexBuffer.UV2Kind
  20502. * - BABYLON.VertexBuffer.UV3Kind
  20503. * - BABYLON.VertexBuffer.UV4Kind
  20504. * - BABYLON.VertexBuffer.UV5Kind
  20505. * - BABYLON.VertexBuffer.UV6Kind
  20506. * - BABYLON.VertexBuffer.ColorKind
  20507. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20508. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20509. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20510. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20511. *
  20512. * Returns the Mesh.
  20513. */
  20514. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20515. /**
  20516. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20517. * If the mesh has no geometry, it is simply returned as it is.
  20518. * The `data` are either a numeric array either a Float32Array.
  20519. * No new underlying VertexBuffer object is created.
  20520. * 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.
  20521. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20522. *
  20523. * Possible `kind` values :
  20524. * - BABYLON.VertexBuffer.PositionKind
  20525. * - BABYLON.VertexBuffer.UVKind
  20526. * - BABYLON.VertexBuffer.UV2Kind
  20527. * - BABYLON.VertexBuffer.UV3Kind
  20528. * - BABYLON.VertexBuffer.UV4Kind
  20529. * - BABYLON.VertexBuffer.UV5Kind
  20530. * - BABYLON.VertexBuffer.UV6Kind
  20531. * - BABYLON.VertexBuffer.ColorKind
  20532. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20533. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20534. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20535. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20536. *
  20537. * Returns the Mesh.
  20538. */
  20539. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20540. /**
  20541. * Sets the mesh indices.
  20542. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20543. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20544. * This method creates a new index buffer each call.
  20545. * Returns the Mesh.
  20546. */
  20547. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20548. /**
  20549. * Boolean : True if the mesh owns the requested kind of data.
  20550. */
  20551. isVerticesDataPresent(kind: string): boolean;
  20552. /**
  20553. * Returns an array of indices (IndicesArray).
  20554. */
  20555. getIndices(): Nullable<IndicesArray>;
  20556. readonly _positions: Nullable<Vector3[]>;
  20557. /**
  20558. * Sets a new updated BoundingInfo to the mesh.
  20559. * Returns the mesh.
  20560. */
  20561. refreshBoundingInfo(): InstancedMesh;
  20562. _preActivate(): InstancedMesh;
  20563. _activate(renderId: number): InstancedMesh;
  20564. /**
  20565. * Returns the current associated LOD AbstractMesh.
  20566. */
  20567. getLOD(camera: Camera): AbstractMesh;
  20568. _syncSubMeshes(): InstancedMesh;
  20569. _generatePointsArray(): boolean;
  20570. /**
  20571. * Creates a new InstancedMesh from the current mesh.
  20572. * - name (string) : the cloned mesh name
  20573. * - newParent (optional Node) : the optional Node to parent the clone to.
  20574. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20575. *
  20576. * Returns the clone.
  20577. */
  20578. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20579. /**
  20580. * Disposes the InstancedMesh.
  20581. * Returns nothing.
  20582. */
  20583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20584. }
  20585. }
  20586. declare module BABYLON {
  20587. class LinesMesh extends Mesh {
  20588. useVertexColor: boolean | undefined;
  20589. useVertexAlpha: boolean | undefined;
  20590. color: Color3;
  20591. alpha: number;
  20592. /**
  20593. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20594. * This margin is expressed in world space coordinates, so its value may vary.
  20595. * Default value is 0.1
  20596. * @returns the intersection Threshold value.
  20597. */
  20598. /**
  20599. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20600. * This margin is expressed in world space coordinates, so its value may vary.
  20601. * @param value the new threshold to apply
  20602. */
  20603. intersectionThreshold: number;
  20604. private _intersectionThreshold;
  20605. private _colorShader;
  20606. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20607. /**
  20608. * Returns the string "LineMesh"
  20609. */
  20610. getClassName(): string;
  20611. material: Material;
  20612. readonly checkCollisions: boolean;
  20613. createInstance(name: string): InstancedMesh;
  20614. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20615. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20616. dispose(doNotRecurse?: boolean): void;
  20617. /**
  20618. * Returns a new LineMesh object cloned from the current one.
  20619. */
  20620. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20621. }
  20622. }
  20623. declare module BABYLON {
  20624. /**
  20625. * @hidden
  20626. **/
  20627. class _InstancesBatch {
  20628. mustReturn: boolean;
  20629. visibleInstances: Nullable<InstancedMesh[]>[];
  20630. renderSelf: boolean[];
  20631. }
  20632. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20633. static _FRONTSIDE: number;
  20634. static _BACKSIDE: number;
  20635. static _DOUBLESIDE: number;
  20636. static _DEFAULTSIDE: number;
  20637. static _NO_CAP: number;
  20638. static _CAP_START: number;
  20639. static _CAP_END: number;
  20640. static _CAP_ALL: number;
  20641. /**
  20642. * Mesh side orientation : usually the external or front surface
  20643. */
  20644. static readonly FRONTSIDE: number;
  20645. /**
  20646. * Mesh side orientation : usually the internal or back surface
  20647. */
  20648. static readonly BACKSIDE: number;
  20649. /**
  20650. * Mesh side orientation : both internal and external or front and back surfaces
  20651. */
  20652. static readonly DOUBLESIDE: number;
  20653. /**
  20654. * Mesh side orientation : by default, `FRONTSIDE`
  20655. */
  20656. static readonly DEFAULTSIDE: number;
  20657. /**
  20658. * Mesh cap setting : no cap
  20659. */
  20660. static readonly NO_CAP: number;
  20661. /**
  20662. * Mesh cap setting : one cap at the beginning of the mesh
  20663. */
  20664. static readonly CAP_START: number;
  20665. /**
  20666. * Mesh cap setting : one cap at the end of the mesh
  20667. */
  20668. static readonly CAP_END: number;
  20669. /**
  20670. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20671. */
  20672. static readonly CAP_ALL: number;
  20673. /**
  20674. * An event triggered before rendering the mesh
  20675. */
  20676. onBeforeRenderObservable: Observable<Mesh>;
  20677. /**
  20678. * An event triggered after rendering the mesh
  20679. */
  20680. onAfterRenderObservable: Observable<Mesh>;
  20681. /**
  20682. * An event triggered before drawing the mesh
  20683. */
  20684. onBeforeDrawObservable: Observable<Mesh>;
  20685. private _onBeforeDrawObserver;
  20686. onBeforeDraw: () => void;
  20687. delayLoadState: number;
  20688. instances: InstancedMesh[];
  20689. delayLoadingFile: string;
  20690. _binaryInfo: any;
  20691. private _LODLevels;
  20692. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20693. private _morphTargetManager;
  20694. morphTargetManager: Nullable<MorphTargetManager>;
  20695. _geometry: Nullable<Geometry>;
  20696. _delayInfo: Array<string>;
  20697. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20698. _visibleInstances: any;
  20699. private _renderIdForInstances;
  20700. private _batchCache;
  20701. private _instancesBufferSize;
  20702. private _instancesBuffer;
  20703. private _instancesData;
  20704. private _overridenInstanceCount;
  20705. private _effectiveMaterial;
  20706. _shouldGenerateFlatShading: boolean;
  20707. private _preActivateId;
  20708. _originalBuilderSideOrientation: number;
  20709. overrideMaterialSideOrientation: Nullable<number>;
  20710. private _areNormalsFrozen;
  20711. private _sourcePositions;
  20712. private _sourceNormals;
  20713. private _source;
  20714. readonly source: Nullable<Mesh>;
  20715. isUnIndexed: boolean;
  20716. /**
  20717. * @constructor
  20718. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20719. * @param {Scene} scene The scene to add this mesh to.
  20720. * @param {Node} parent The parent of this mesh, if it has one
  20721. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20722. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20723. * When false, achieved by calling a clone(), also passing False.
  20724. * This will make creation of children, recursive.
  20725. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20726. */
  20727. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20728. /**
  20729. * Returns the string "Mesh".
  20730. */
  20731. getClassName(): string;
  20732. /**
  20733. * Returns a string.
  20734. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20735. */
  20736. toString(fullDetails?: boolean): string;
  20737. _unBindEffect(): void;
  20738. /**
  20739. * True if the mesh has some Levels Of Details (LOD).
  20740. * Returns a boolean.
  20741. */
  20742. readonly hasLODLevels: boolean;
  20743. /**
  20744. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20745. * @returns an array of {BABYLON.MeshLODLevel}
  20746. */
  20747. getLODLevels(): MeshLODLevel[];
  20748. private _sortLODLevels();
  20749. /**
  20750. * Add a mesh as LOD level triggered at the given distance.
  20751. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20752. * @param distance The distance from the center of the object to show this level
  20753. * @param mesh The mesh to be added as LOD level (can be null)
  20754. * @return This mesh (for chaining)
  20755. */
  20756. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20757. /**
  20758. * Returns the LOD level mesh at the passed distance or null if not found.
  20759. * It is related to the method `addLODLevel(distance, mesh)`.
  20760. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20761. * Returns an object Mesh or `null`.
  20762. */
  20763. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20764. /**
  20765. * Remove a mesh from the LOD array
  20766. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20767. * @param {Mesh} mesh The mesh to be removed.
  20768. * @return {Mesh} This mesh (for chaining)
  20769. */
  20770. removeLODLevel(mesh: Mesh): Mesh;
  20771. /**
  20772. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20773. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  20774. */
  20775. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20776. /**
  20777. * Returns the mesh internal Geometry object.
  20778. */
  20779. readonly geometry: Nullable<Geometry>;
  20780. /**
  20781. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20782. */
  20783. getTotalVertices(): number;
  20784. /**
  20785. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20786. * 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.
  20787. * You can force the copy with forceCopy === true
  20788. * Returns null if the mesh has no geometry or no vertex buffer.
  20789. * Possible `kind` values :
  20790. * - BABYLON.VertexBuffer.PositionKind
  20791. * - BABYLON.VertexBuffer.UVKind
  20792. * - BABYLON.VertexBuffer.UV2Kind
  20793. * - BABYLON.VertexBuffer.UV3Kind
  20794. * - BABYLON.VertexBuffer.UV4Kind
  20795. * - BABYLON.VertexBuffer.UV5Kind
  20796. * - BABYLON.VertexBuffer.UV6Kind
  20797. * - BABYLON.VertexBuffer.ColorKind
  20798. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20799. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20800. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20801. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20802. */
  20803. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20804. /**
  20805. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20806. * Returns `null` if the mesh has no geometry.
  20807. * Possible `kind` values :
  20808. * - BABYLON.VertexBuffer.PositionKind
  20809. * - BABYLON.VertexBuffer.UVKind
  20810. * - BABYLON.VertexBuffer.UV2Kind
  20811. * - BABYLON.VertexBuffer.UV3Kind
  20812. * - BABYLON.VertexBuffer.UV4Kind
  20813. * - BABYLON.VertexBuffer.UV5Kind
  20814. * - BABYLON.VertexBuffer.UV6Kind
  20815. * - BABYLON.VertexBuffer.ColorKind
  20816. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20817. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20818. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20819. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20820. */
  20821. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20822. isVerticesDataPresent(kind: string): boolean;
  20823. /**
  20824. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20825. * Possible `kind` values :
  20826. * - BABYLON.VertexBuffer.PositionKind
  20827. * - BABYLON.VertexBuffer.UVKind
  20828. * - BABYLON.VertexBuffer.UV2Kind
  20829. * - BABYLON.VertexBuffer.UV3Kind
  20830. * - BABYLON.VertexBuffer.UV4Kind
  20831. * - BABYLON.VertexBuffer.UV5Kind
  20832. * - BABYLON.VertexBuffer.UV6Kind
  20833. * - BABYLON.VertexBuffer.ColorKind
  20834. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20835. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20836. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20837. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20838. */
  20839. isVertexBufferUpdatable(kind: string): boolean;
  20840. /**
  20841. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20842. * Possible `kind` values :
  20843. * - BABYLON.VertexBuffer.PositionKind
  20844. * - BABYLON.VertexBuffer.UVKind
  20845. * - BABYLON.VertexBuffer.UV2Kind
  20846. * - BABYLON.VertexBuffer.UV3Kind
  20847. * - BABYLON.VertexBuffer.UV4Kind
  20848. * - BABYLON.VertexBuffer.UV5Kind
  20849. * - BABYLON.VertexBuffer.UV6Kind
  20850. * - BABYLON.VertexBuffer.ColorKind
  20851. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20852. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20853. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20854. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20855. */
  20856. getVerticesDataKinds(): string[];
  20857. /**
  20858. * Returns a positive integer : the total number of indices in this mesh geometry.
  20859. * Returns zero if the mesh has no geometry.
  20860. */
  20861. getTotalIndices(): number;
  20862. /**
  20863. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20864. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  20865. * Returns an empty array if the mesh has no geometry.
  20866. */
  20867. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20868. readonly isBlocked: boolean;
  20869. /**
  20870. * Determine if the current mesh is ready to be rendered
  20871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20872. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20873. * @returns true if all associated assets are ready (material, textures, shaders)
  20874. */
  20875. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20876. /**
  20877. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20878. * This property is pertinent only for updatable parametric shapes.
  20879. */
  20880. readonly areNormalsFrozen: boolean;
  20881. /**
  20882. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20883. * It has no effect at all on other shapes.
  20884. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20885. * Returns the Mesh.
  20886. */
  20887. freezeNormals(): Mesh;
  20888. /**
  20889. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20890. * It has no effect at all on other shapes.
  20891. * It reactivates the mesh normals computation if it was previously frozen.
  20892. * Returns the Mesh.
  20893. */
  20894. unfreezeNormals(): Mesh;
  20895. /**
  20896. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20897. */
  20898. overridenInstanceCount: number;
  20899. _preActivate(): Mesh;
  20900. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20901. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20902. /**
  20903. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20904. * This means the mesh underlying bounding box and sphere are recomputed.
  20905. * Returns the Mesh.
  20906. */
  20907. refreshBoundingInfo(): Mesh;
  20908. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20909. private _getPositionData(applySkeleton);
  20910. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20911. subdivide(count: number): void;
  20912. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20913. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20914. /**
  20915. * Sets the mesh VertexBuffer.
  20916. * Returns the Mesh.
  20917. */
  20918. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20920. /**
  20921. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20922. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20923. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20924. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20925. * Returns the Mesh.
  20926. */
  20927. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20928. /**
  20929. * Creates a un-shared specific occurence of the geometry for the mesh.
  20930. * Returns the Mesh.
  20931. */
  20932. makeGeometryUnique(): Mesh;
  20933. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20934. /**
  20935. * Update the current index buffer
  20936. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20937. * Returns the Mesh.
  20938. */
  20939. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20940. /**
  20941. * Invert the geometry to move from a right handed system to a left handed one.
  20942. * Returns the Mesh.
  20943. */
  20944. toLeftHanded(): Mesh;
  20945. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20946. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20947. /**
  20948. * Registers for this mesh a javascript function called just before the rendering process.
  20949. * This function is passed the current mesh.
  20950. * Return the Mesh.
  20951. */
  20952. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20953. /**
  20954. * Disposes a previously registered javascript function called before the rendering.
  20955. * This function is passed the current mesh.
  20956. * Returns the Mesh.
  20957. */
  20958. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20959. /**
  20960. * Registers for this mesh a javascript function called just after the rendering is complete.
  20961. * This function is passed the current mesh.
  20962. * Returns the Mesh.
  20963. */
  20964. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20965. /**
  20966. * Disposes a previously registered javascript function called after the rendering.
  20967. * This function is passed the current mesh.
  20968. * Return the Mesh.
  20969. */
  20970. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20971. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20972. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20973. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20974. /**
  20975. * Triggers the draw call for the mesh.
  20976. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20977. * Returns the Mesh.
  20978. */
  20979. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20980. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20981. /**
  20982. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20983. */
  20984. getEmittedParticleSystems(): IParticleSystem[];
  20985. /**
  20986. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20987. */
  20988. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20989. /**
  20990. * Normalize matrix weights so that all vertices have a total weight set to 1
  20991. */
  20992. cleanMatrixWeights(): void;
  20993. _checkDelayState(): Mesh;
  20994. private _queueLoad(scene);
  20995. /**
  20996. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20997. */
  20998. isInFrustum(frustumPlanes: Plane[]): boolean;
  20999. /**
  21000. * Sets the mesh material by the material or multiMaterial `id` property.
  21001. * The material `id` is a string identifying the material or the multiMaterial.
  21002. * This method returns the Mesh.
  21003. */
  21004. setMaterialByID(id: string): Mesh;
  21005. /**
  21006. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21007. */
  21008. getAnimatables(): IAnimatable[];
  21009. /**
  21010. * Modifies the mesh geometry according to the passed transformation matrix.
  21011. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21012. * The mesh normals are modified accordingly the same transformation.
  21013. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21014. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21015. * Returns the Mesh.
  21016. */
  21017. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21018. /**
  21019. * Modifies the mesh geometry according to its own current World Matrix.
  21020. * The mesh World Matrix is then reset.
  21021. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21022. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21023. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21024. * Returns the Mesh.
  21025. */
  21026. bakeCurrentTransformIntoVertices(): Mesh;
  21027. readonly _positions: Nullable<Vector3[]>;
  21028. _resetPointsArrayCache(): Mesh;
  21029. _generatePointsArray(): boolean;
  21030. /**
  21031. * Returns a new Mesh object generated from the current mesh properties.
  21032. * This method must not get confused with createInstance().
  21033. * The parameter `name` is a string, the name given to the new mesh.
  21034. * The optional parameter `newParent` can be any Node object (default `null`).
  21035. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21036. * 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.
  21037. */
  21038. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21039. /**
  21040. * Releases resources associated with this mesh.
  21041. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21042. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21043. */
  21044. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21045. /**
  21046. * Modifies the mesh geometry according to a displacement map.
  21047. * 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.
  21048. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21049. * This method returns nothing.
  21050. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21051. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21052. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21053. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21054. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21055. *
  21056. * Returns the Mesh.
  21057. */
  21058. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21059. /**
  21060. * Modifies the mesh geometry according to a displacementMap buffer.
  21061. * 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.
  21062. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21063. * This method returns nothing.
  21064. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21065. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21066. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21067. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21068. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21069. *
  21070. * Returns the Mesh.
  21071. */
  21072. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21073. /**
  21074. * Modify the mesh to get a flat shading rendering.
  21075. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21076. * This method returns the Mesh.
  21077. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21078. */
  21079. convertToFlatShadedMesh(): Mesh;
  21080. /**
  21081. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21082. * In other words, more vertices, no more indices and a single bigger VBO.
  21083. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21084. * Returns the Mesh.
  21085. */
  21086. convertToUnIndexedMesh(): Mesh;
  21087. /**
  21088. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21089. * This method returns the Mesh.
  21090. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21091. */
  21092. flipFaces(flipNormals?: boolean): Mesh;
  21093. /**
  21094. * Creates a new InstancedMesh object from the mesh model.
  21095. * An instance shares the same properties and the same material than its model.
  21096. * Only these properties of each instance can then be set individually :
  21097. * - position
  21098. * - rotation
  21099. * - rotationQuaternion
  21100. * - setPivotMatrix
  21101. * - scaling
  21102. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21103. * Warning : this method is not supported for Line mesh and LineSystem
  21104. */
  21105. createInstance(name: string): InstancedMesh;
  21106. /**
  21107. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21108. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21109. * This method returns the Mesh.
  21110. */
  21111. synchronizeInstances(): Mesh;
  21112. /**
  21113. * Simplify the mesh according to the given array of settings.
  21114. * Function will return immediately and will simplify async. It returns the Mesh.
  21115. * @param settings a collection of simplification settings.
  21116. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21117. * @param type the type of simplification to run.
  21118. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21119. */
  21120. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21121. /**
  21122. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21123. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21124. * This should be used together with the simplification to avoid disappearing triangles.
  21125. * Returns the Mesh.
  21126. * @param successCallback an optional success callback to be called after the optimization finished.
  21127. */
  21128. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21129. serialize(serializationObject: any): void;
  21130. _syncGeometryWithMorphTargetManager(): void;
  21131. /**
  21132. * Returns a new Mesh object parsed from the source provided.
  21133. * The parameter `parsedMesh` is the source.
  21134. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21135. */
  21136. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21137. /**
  21138. * Creates a ribbon mesh.
  21139. * Please consider using the same method from the MeshBuilder class instead.
  21140. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21141. *
  21142. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21143. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21144. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21145. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21146. * 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.
  21147. * 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.
  21148. * 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
  21149. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21150. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21151. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21152. */
  21153. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21154. /**
  21155. * Creates a plane polygonal mesh. By default, this is a disc.
  21156. * Please consider using the same method from the MeshBuilder class instead.
  21157. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21158. * 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.
  21159. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21160. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21161. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21162. */
  21163. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21164. /**
  21165. * Creates a box mesh.
  21166. * Please consider using the same method from the MeshBuilder class instead.
  21167. * The parameter `size` sets the size (float) of each box side (default 1).
  21168. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21169. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21170. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21171. */
  21172. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21173. /**
  21174. * Creates a sphere mesh.
  21175. * Please consider using the same method from the MeshBuilder class instead.
  21176. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21177. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21178. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21179. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21180. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21181. */
  21182. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21183. /**
  21184. * Creates a cylinder or a cone mesh.
  21185. * Please consider using the same method from the MeshBuilder class instead.
  21186. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21187. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21188. * 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.
  21189. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21190. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21191. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21192. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21193. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21194. */
  21195. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21196. /**
  21197. * Creates a torus mesh.
  21198. * Please consider using the same method from the MeshBuilder class instead.
  21199. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21200. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21201. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21202. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21203. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21204. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21205. */
  21206. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21207. /**
  21208. * Creates a torus knot mesh.
  21209. * Please consider using the same method from the MeshBuilder class instead.
  21210. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21211. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21212. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21213. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21214. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21215. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21216. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21217. */
  21218. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21219. /**
  21220. * Creates a line mesh.
  21221. * Please consider using the same method from the MeshBuilder class instead.
  21222. * 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.
  21223. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21224. * The parameter `points` is an array successive Vector3.
  21225. * 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
  21226. * When updating an instance, remember that only point positions can change, not the number of points.
  21227. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21228. */
  21229. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21230. /**
  21231. * Creates a dashed line mesh.
  21232. * Please consider using the same method from the MeshBuilder class instead.
  21233. * 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.
  21234. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21235. * The parameter `points` is an array successive Vector3.
  21236. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21237. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21238. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21239. * 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
  21240. * When updating an instance, remember that only point positions can change, not the number of points.
  21241. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21242. */
  21243. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21244. /**
  21245. * Creates a polygon mesh.
  21246. * Please consider using the same method from the MeshBuilder class instead.
  21247. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21248. * 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.
  21249. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21250. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21251. * Remember you can only change the shape positions, not their number when updating a polygon.
  21252. */
  21253. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21254. /**
  21255. * Creates an extruded polygon mesh, with depth in the Y direction.
  21256. * Please consider using the same method from the MeshBuilder class instead.
  21257. */
  21258. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21259. /**
  21260. * Creates an extruded shape mesh.
  21261. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21262. * Please consider using the same method from the MeshBuilder class instead.
  21263. *
  21264. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21265. * 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
  21266. * extruded along the Z axis.
  21267. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21268. * 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.
  21269. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21270. * 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
  21271. * 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
  21272. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21273. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21274. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21275. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21276. */
  21277. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21278. /**
  21279. * Creates an custom extruded shape mesh.
  21280. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21281. * Please consider using the same method from the MeshBuilder class instead.
  21282. *
  21283. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21284. * 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
  21285. * extruded along the Z axis.
  21286. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21287. * 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
  21288. * and the distance of this point from the begining of the path :
  21289. * ```javascript
  21290. * var rotationFunction = function(i, distance) {
  21291. * // do things
  21292. * return rotationValue; }
  21293. * ```
  21294. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21295. * 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
  21296. * and the distance of this point from the begining of the path :
  21297. * ```javascript
  21298. * var scaleFunction = function(i, distance) {
  21299. * // do things
  21300. * return scaleValue;}
  21301. * ```
  21302. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21303. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21304. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21305. * 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
  21306. * 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
  21307. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21308. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21309. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21310. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21311. */
  21312. 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;
  21313. /**
  21314. * Creates lathe mesh.
  21315. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21316. * Please consider using the same method from the MeshBuilder class instead.
  21317. * 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
  21318. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21319. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21320. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21321. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21322. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21323. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21324. */
  21325. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21326. /**
  21327. * Creates a plane mesh.
  21328. * Please consider using the same method from the MeshBuilder class instead.
  21329. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21330. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21331. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21332. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21333. */
  21334. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21335. /**
  21336. * Creates a ground mesh.
  21337. * Please consider using the same method from the MeshBuilder class instead.
  21338. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21339. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21340. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21341. */
  21342. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21343. /**
  21344. * Creates a tiled ground mesh.
  21345. * Please consider using the same method from the MeshBuilder class instead.
  21346. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21347. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21348. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21349. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21350. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21351. * numbers of subdivisions on the ground width and height of each tile.
  21352. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21353. */
  21354. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21355. w: number;
  21356. h: number;
  21357. }, precision: {
  21358. w: number;
  21359. h: number;
  21360. }, scene: Scene, updatable?: boolean): Mesh;
  21361. /**
  21362. * Creates a ground mesh from a height map.
  21363. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21364. * Please consider using the same method from the MeshBuilder class instead.
  21365. * The parameter `url` sets the URL of the height map image resource.
  21366. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21367. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21368. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21369. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21370. * 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).
  21371. * This function is passed the newly built mesh :
  21372. * ```javascript
  21373. * function(mesh) { // do things
  21374. * return; }
  21375. * ```
  21376. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21377. */
  21378. 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;
  21379. /**
  21380. * Creates a tube mesh.
  21381. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21382. * Please consider using the same method from the MeshBuilder class instead.
  21383. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21384. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21385. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21386. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21387. * 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.
  21388. * It must return a radius value (positive float) :
  21389. * ```javascript
  21390. * var radiusFunction = function(i, distance) {
  21391. * // do things
  21392. * return radius; }
  21393. * ```
  21394. * 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
  21395. * 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
  21396. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21397. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21398. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21399. */
  21400. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21401. (i: number, distance: number): number;
  21402. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21403. /**
  21404. * Creates a polyhedron mesh.
  21405. * Please consider using the same method from the MeshBuilder class instead.
  21406. * 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
  21407. * to choose the wanted type.
  21408. * The parameter `size` (positive float, default 1) sets the polygon size.
  21409. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21410. * 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`.
  21411. * 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
  21412. * 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)`).
  21413. * 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
  21414. * 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.
  21415. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21416. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21417. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21418. */
  21419. static CreatePolyhedron(name: string, options: {
  21420. type?: number;
  21421. size?: number;
  21422. sizeX?: number;
  21423. sizeY?: number;
  21424. sizeZ?: number;
  21425. custom?: any;
  21426. faceUV?: Vector4[];
  21427. faceColors?: Color4[];
  21428. updatable?: boolean;
  21429. sideOrientation?: number;
  21430. }, scene: Scene): Mesh;
  21431. /**
  21432. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21433. * Please consider using the same method from the MeshBuilder class instead.
  21434. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21435. * 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`).
  21436. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21437. * 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.
  21438. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21439. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21440. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21441. */
  21442. static CreateIcoSphere(name: string, options: {
  21443. radius?: number;
  21444. flat?: boolean;
  21445. subdivisions?: number;
  21446. sideOrientation?: number;
  21447. updatable?: boolean;
  21448. }, scene: Scene): Mesh;
  21449. /**
  21450. * Creates a decal mesh.
  21451. * Please consider using the same method from the MeshBuilder class instead.
  21452. * 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.
  21453. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21454. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21455. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21456. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21457. */
  21458. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21459. /**
  21460. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21461. */
  21462. setPositionsForCPUSkinning(): Float32Array;
  21463. /**
  21464. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21465. */
  21466. setNormalsForCPUSkinning(): Float32Array;
  21467. /**
  21468. * Updates the vertex buffer by applying transformation from the bones.
  21469. * Returns the Mesh.
  21470. *
  21471. * @param {skeleton} skeleton to apply
  21472. */
  21473. applySkeleton(skeleton: Skeleton): Mesh;
  21474. /**
  21475. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21476. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21477. */
  21478. static MinMax(meshes: AbstractMesh[]): {
  21479. min: Vector3;
  21480. max: Vector3;
  21481. };
  21482. /**
  21483. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21484. */
  21485. static Center(meshesOrMinMaxVector: {
  21486. min: Vector3;
  21487. max: Vector3;
  21488. } | AbstractMesh[]): Vector3;
  21489. /**
  21490. * Merge the array of meshes into a single mesh for performance reasons.
  21491. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21492. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21493. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21494. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21495. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21496. */
  21497. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21498. }
  21499. }
  21500. declare module BABYLON {
  21501. /**
  21502. * Define an interface for all classes that will get and set the data on vertices
  21503. */
  21504. interface IGetSetVerticesData {
  21505. isVerticesDataPresent(kind: string): boolean;
  21506. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21507. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21508. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21510. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21511. }
  21512. /**
  21513. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21514. */
  21515. class VertexData {
  21516. /**
  21517. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21518. */
  21519. positions: Nullable<FloatArray>;
  21520. /**
  21521. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21522. */
  21523. normals: Nullable<FloatArray>;
  21524. /**
  21525. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21526. */
  21527. tangents: Nullable<FloatArray>;
  21528. /**
  21529. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21530. */
  21531. uvs: Nullable<FloatArray>;
  21532. /**
  21533. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21534. */
  21535. uvs2: Nullable<FloatArray>;
  21536. /**
  21537. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21538. */
  21539. uvs3: Nullable<FloatArray>;
  21540. /**
  21541. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21542. */
  21543. uvs4: Nullable<FloatArray>;
  21544. /**
  21545. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21546. */
  21547. uvs5: Nullable<FloatArray>;
  21548. /**
  21549. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21550. */
  21551. uvs6: Nullable<FloatArray>;
  21552. /**
  21553. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21554. */
  21555. colors: Nullable<FloatArray>;
  21556. /**
  21557. * 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).
  21558. */
  21559. matricesIndices: Nullable<FloatArray>;
  21560. /**
  21561. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21562. */
  21563. matricesWeights: Nullable<FloatArray>;
  21564. /**
  21565. * An array extending the number of possible indices
  21566. */
  21567. matricesIndicesExtra: Nullable<FloatArray>;
  21568. /**
  21569. * An array extending the number of possible weights when the number of indices is extended
  21570. */
  21571. matricesWeightsExtra: Nullable<FloatArray>;
  21572. /**
  21573. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21574. */
  21575. indices: Nullable<IndicesArray>;
  21576. /**
  21577. * Uses the passed data array to set the set the values for the specified kind of data
  21578. * @param data a linear array of floating numbers
  21579. * @param kind the type of data that is being set, eg positions, colors etc
  21580. */
  21581. set(data: FloatArray, kind: string): void;
  21582. /**
  21583. * Associates the vertexData to the passed Mesh.
  21584. * Sets it as updatable or not (default `false`)
  21585. * @param mesh the mesh the vertexData is applied to
  21586. * @param updatable when used and having the value true allows new data to update the vertexData
  21587. * @returns the VertexData
  21588. */
  21589. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21590. /**
  21591. * Associates the vertexData to the passed Geometry.
  21592. * Sets it as updatable or not (default `false`)
  21593. * @param geometry the geometry the vertexData is applied to
  21594. * @param updatable when used and having the value true allows new data to update the vertexData
  21595. * @returns VertexData
  21596. */
  21597. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21598. /**
  21599. * Updates the associated mesh
  21600. * @param mesh the mesh to be updated
  21601. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21602. * @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
  21603. * @returns VertexData
  21604. */
  21605. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21606. /**
  21607. * Updates the associated geometry
  21608. * @param geometry the geometry to be updated
  21609. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21610. * @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
  21611. * @returns VertexData.
  21612. */
  21613. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21614. private _applyTo(meshOrGeometry, updatable?);
  21615. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21616. /**
  21617. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21618. * @param matrix the transforming matrix
  21619. * @returns the VertexData
  21620. */
  21621. transform(matrix: Matrix): VertexData;
  21622. /**
  21623. * Merges the passed VertexData into the current one
  21624. * @param other the VertexData to be merged into the current one
  21625. * @returns the modified VertexData
  21626. */
  21627. merge(other: VertexData): VertexData;
  21628. private _mergeElement(source, other);
  21629. private _validate();
  21630. /**
  21631. * Serializes the VertexData
  21632. * @returns a serialized object
  21633. */
  21634. serialize(): any;
  21635. /**
  21636. * Extracts the vertexData from a mesh
  21637. * @param mesh the mesh from which to extract the VertexData
  21638. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21639. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21640. * @returns the object VertexData associated to the passed mesh
  21641. */
  21642. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21643. /**
  21644. * Extracts the vertexData from the geometry
  21645. * @param geometry the geometry from which to extract the VertexData
  21646. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21647. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21648. * @returns the object VertexData associated to the passed mesh
  21649. */
  21650. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21651. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21652. /**
  21653. * Creates the VertexData for a Ribbon
  21654. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21655. * * pathArray array of paths, each of which an array of successive Vector3
  21656. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21657. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21658. * * 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
  21659. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21660. * * 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)
  21661. * * 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)
  21662. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21663. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21664. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21665. * @returns the VertexData of the ribbon
  21666. */
  21667. static CreateRibbon(options: {
  21668. pathArray: Vector3[][];
  21669. closeArray?: boolean;
  21670. closePath?: boolean;
  21671. offset?: number;
  21672. sideOrientation?: number;
  21673. frontUVs?: Vector4;
  21674. backUVs?: Vector4;
  21675. invertUV?: boolean;
  21676. uvs?: Vector2[];
  21677. colors?: Color4[];
  21678. }): VertexData;
  21679. /**
  21680. * Creates the VertexData for a box
  21681. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21682. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21683. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21684. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21685. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21686. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21687. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21688. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21689. * * 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)
  21690. * * 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)
  21691. * @returns the VertexData of the box
  21692. */
  21693. static CreateBox(options: {
  21694. size?: number;
  21695. width?: number;
  21696. height?: number;
  21697. depth?: number;
  21698. faceUV?: Vector4[];
  21699. faceColors?: Color4[];
  21700. sideOrientation?: number;
  21701. frontUVs?: Vector4;
  21702. backUVs?: Vector4;
  21703. }): VertexData;
  21704. /**
  21705. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21706. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21707. * * segments sets the number of horizontal strips optional, default 32
  21708. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21709. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21710. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21711. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21712. * * 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
  21713. * * 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
  21714. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21715. * * 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)
  21716. * * 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)
  21717. * @returns the VertexData of the ellipsoid
  21718. */
  21719. static CreateSphere(options: {
  21720. segments?: number;
  21721. diameter?: number;
  21722. diameterX?: number;
  21723. diameterY?: number;
  21724. diameterZ?: number;
  21725. arc?: number;
  21726. slice?: number;
  21727. sideOrientation?: number;
  21728. frontUVs?: Vector4;
  21729. backUVs?: Vector4;
  21730. }): VertexData;
  21731. /**
  21732. * Creates the VertexData for a cylinder, cone or prism
  21733. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21734. * * height sets the height (y direction) of the cylinder, optional, default 2
  21735. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21736. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21737. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21738. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21739. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21740. * * 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
  21741. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21742. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21743. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21744. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21745. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21746. * * 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)
  21747. * * 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)
  21748. * @returns the VertexData of the cylinder, cone or prism
  21749. */
  21750. static CreateCylinder(options: {
  21751. height?: number;
  21752. diameterTop?: number;
  21753. diameterBottom?: number;
  21754. diameter?: number;
  21755. tessellation?: number;
  21756. subdivisions?: number;
  21757. arc?: number;
  21758. faceColors?: Color4[];
  21759. faceUV?: Vector4[];
  21760. hasRings?: boolean;
  21761. enclose?: boolean;
  21762. sideOrientation?: number;
  21763. frontUVs?: Vector4;
  21764. backUVs?: Vector4;
  21765. }): VertexData;
  21766. /**
  21767. * Creates the VertexData for a torus
  21768. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21769. * * diameter the diameter of the torus, optional default 1
  21770. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21771. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21772. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21773. * * 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)
  21774. * * 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)
  21775. * @returns the VertexData of the torus
  21776. */
  21777. static CreateTorus(options: {
  21778. diameter?: number;
  21779. thickness?: number;
  21780. tessellation?: number;
  21781. sideOrientation?: number;
  21782. frontUVs?: Vector4;
  21783. backUVs?: Vector4;
  21784. }): VertexData;
  21785. /**
  21786. * Creates the VertexData of the LineSystem
  21787. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21788. * - lines an array of lines, each line being an array of successive Vector3
  21789. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21790. * @returns the VertexData of the LineSystem
  21791. */
  21792. static CreateLineSystem(options: {
  21793. lines: Vector3[][];
  21794. colors?: Nullable<Color4[][]>;
  21795. }): VertexData;
  21796. /**
  21797. * Create the VertexData for a DashedLines
  21798. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21799. * - points an array successive Vector3
  21800. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21801. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21802. * - dashNb the intended total number of dashes, optional, default 200
  21803. * @returns the VertexData for the DashedLines
  21804. */
  21805. static CreateDashedLines(options: {
  21806. points: Vector3[];
  21807. dashSize?: number;
  21808. gapSize?: number;
  21809. dashNb?: number;
  21810. }): VertexData;
  21811. /**
  21812. * Creates the VertexData for a Ground
  21813. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21814. * - width the width (x direction) of the ground, optional, default 1
  21815. * - height the height (z direction) of the ground, optional, default 1
  21816. * - subdivisions the number of subdivisions per side, optional, default 1
  21817. * @returns the VertexData of the Ground
  21818. */
  21819. static CreateGround(options: {
  21820. width?: number;
  21821. height?: number;
  21822. subdivisions?: number;
  21823. subdivisionsX?: number;
  21824. subdivisionsY?: number;
  21825. }): VertexData;
  21826. /**
  21827. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21828. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21829. * * xmin the ground minimum X coordinate, optional, default -1
  21830. * * zmin the ground minimum Z coordinate, optional, default -1
  21831. * * xmax the ground maximum X coordinate, optional, default 1
  21832. * * zmax the ground maximum Z coordinate, optional, default 1
  21833. * * 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}
  21834. * * 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}
  21835. * @returns the VertexData of the TiledGround
  21836. */
  21837. static CreateTiledGround(options: {
  21838. xmin: number;
  21839. zmin: number;
  21840. xmax: number;
  21841. zmax: number;
  21842. subdivisions?: {
  21843. w: number;
  21844. h: number;
  21845. };
  21846. precision?: {
  21847. w: number;
  21848. h: number;
  21849. };
  21850. }): VertexData;
  21851. /**
  21852. * Creates the VertexData of the Ground designed from a heightmap
  21853. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21854. * * width the width (x direction) of the ground
  21855. * * height the height (z direction) of the ground
  21856. * * subdivisions the number of subdivisions per side
  21857. * * minHeight the minimum altitude on the ground, optional, default 0
  21858. * * maxHeight the maximum altitude on the ground, optional default 1
  21859. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21860. * * buffer the array holding the image color data
  21861. * * bufferWidth the width of image
  21862. * * bufferHeight the height of image
  21863. * @returns the VertexData of the Ground designed from a heightmap
  21864. */
  21865. static CreateGroundFromHeightMap(options: {
  21866. width: number;
  21867. height: number;
  21868. subdivisions: number;
  21869. minHeight: number;
  21870. maxHeight: number;
  21871. colorFilter: Color3;
  21872. buffer: Uint8Array;
  21873. bufferWidth: number;
  21874. bufferHeight: number;
  21875. }): VertexData;
  21876. /**
  21877. * Creates the VertexData for a Plane
  21878. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21879. * * size sets the width and height of the plane to the value of size, optional default 1
  21880. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21881. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21882. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21883. * * 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)
  21884. * * 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)
  21885. * @returns the VertexData of the box
  21886. */
  21887. static CreatePlane(options: {
  21888. size?: number;
  21889. width?: number;
  21890. height?: number;
  21891. sideOrientation?: number;
  21892. frontUVs?: Vector4;
  21893. backUVs?: Vector4;
  21894. }): VertexData;
  21895. /**
  21896. * Creates the VertexData of the Disc or regular Polygon
  21897. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21898. * * radius the radius of the disc, optional default 0.5
  21899. * * tessellation the number of polygon sides, optional, default 64
  21900. * * 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
  21901. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21902. * * 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)
  21903. * * 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)
  21904. * @returns the VertexData of the box
  21905. */
  21906. static CreateDisc(options: {
  21907. radius?: number;
  21908. tessellation?: number;
  21909. arc?: number;
  21910. sideOrientation?: number;
  21911. frontUVs?: Vector4;
  21912. backUVs?: Vector4;
  21913. }): VertexData;
  21914. /**
  21915. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21916. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21917. * @param polygon a mesh built from polygonTriangulation.build()
  21918. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21919. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21920. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21921. * @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)
  21922. * @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)
  21923. * @returns the VertexData of the Polygon
  21924. */
  21925. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21926. /**
  21927. * Creates the VertexData of the IcoSphere
  21928. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21929. * * radius the radius of the IcoSphere, optional default 1
  21930. * * radiusX allows stretching in the x direction, optional, default radius
  21931. * * radiusY allows stretching in the y direction, optional, default radius
  21932. * * radiusZ allows stretching in the z direction, optional, default radius
  21933. * * flat when true creates a flat shaded mesh, optional, default true
  21934. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21935. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21936. * * 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)
  21937. * * 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)
  21938. * @returns the VertexData of the IcoSphere
  21939. */
  21940. static CreateIcoSphere(options: {
  21941. radius?: number;
  21942. radiusX?: number;
  21943. radiusY?: number;
  21944. radiusZ?: number;
  21945. flat?: boolean;
  21946. subdivisions?: number;
  21947. sideOrientation?: number;
  21948. frontUVs?: Vector4;
  21949. backUVs?: Vector4;
  21950. }): VertexData;
  21951. /**
  21952. * Creates the VertexData for a Polyhedron
  21953. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21954. * * type provided types are:
  21955. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21956. * * 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)
  21957. * * size the size of the IcoSphere, optional default 1
  21958. * * sizeX allows stretching in the x direction, optional, default size
  21959. * * sizeY allows stretching in the y direction, optional, default size
  21960. * * sizeZ allows stretching in the z direction, optional, default size
  21961. * * 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
  21962. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21963. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21964. * * flat when true creates a flat shaded mesh, optional, default true
  21965. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21966. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21967. * * 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)
  21968. * * 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)
  21969. * @returns the VertexData of the Polyhedron
  21970. */
  21971. static CreatePolyhedron(options: {
  21972. type?: number;
  21973. size?: number;
  21974. sizeX?: number;
  21975. sizeY?: number;
  21976. sizeZ?: number;
  21977. custom?: any;
  21978. faceUV?: Vector4[];
  21979. faceColors?: Color4[];
  21980. flat?: boolean;
  21981. sideOrientation?: number;
  21982. frontUVs?: Vector4;
  21983. backUVs?: Vector4;
  21984. }): VertexData;
  21985. /**
  21986. * Creates the VertexData for a TorusKnot
  21987. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21988. * * radius the radius of the torus knot, optional, default 2
  21989. * * tube the thickness of the tube, optional, default 0.5
  21990. * * radialSegments the number of sides on each tube segments, optional, default 32
  21991. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21992. * * p the number of windings around the z axis, optional, default 2
  21993. * * q the number of windings around the x axis, optional, default 3
  21994. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21995. * * 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)
  21996. * * 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)
  21997. * @returns the VertexData of the Torus Knot
  21998. */
  21999. static CreateTorusKnot(options: {
  22000. radius?: number;
  22001. tube?: number;
  22002. radialSegments?: number;
  22003. tubularSegments?: number;
  22004. p?: number;
  22005. q?: number;
  22006. sideOrientation?: number;
  22007. frontUVs?: Vector4;
  22008. backUVs?: Vector4;
  22009. }): VertexData;
  22010. /**
  22011. * Compute normals for given positions and indices
  22012. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22013. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22014. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22015. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22016. * * facetNormals : optional array of facet normals (vector3)
  22017. * * facetPositions : optional array of facet positions (vector3)
  22018. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22019. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22020. * * bInfo : optional bounding info, required for facetPartitioning computation
  22021. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22022. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22023. * * useRightHandedSystem: optional boolean to for right handed system computation
  22024. * * depthSort : optional boolean to enable the facet depth sort computation
  22025. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22026. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22027. */
  22028. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22029. facetNormals?: any;
  22030. facetPositions?: any;
  22031. facetPartitioning?: any;
  22032. ratio?: number;
  22033. bInfo?: any;
  22034. bbSize?: Vector3;
  22035. subDiv?: any;
  22036. useRightHandedSystem?: boolean;
  22037. depthSort?: boolean;
  22038. distanceTo?: Vector3;
  22039. depthSortedFacets?: any;
  22040. }): void;
  22041. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22042. /**
  22043. * Applies VertexData created from the imported parameters to the geometry
  22044. * @param parsedVertexData the parsed data from an imported file
  22045. * @param geometry the geometry to apply the VertexData to
  22046. */
  22047. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22048. }
  22049. }
  22050. declare module BABYLON {
  22051. /**
  22052. * Class containing static functions to help procedurally build meshes
  22053. */
  22054. class MeshBuilder {
  22055. private static updateSideOrientation(orientation?);
  22056. /**
  22057. * Creates a box mesh
  22058. * * The parameter `size` sets the size (float) of each box side (default 1)
  22059. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22060. * * 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)
  22061. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22063. * * 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
  22064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22065. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22066. * @param name defines the name of the mesh
  22067. * @param options defines the options used to create the mesh
  22068. * @param scene defines the hosting scene
  22069. * @returns the box mesh
  22070. */
  22071. static CreateBox(name: string, options: {
  22072. size?: number;
  22073. width?: number;
  22074. height?: number;
  22075. depth?: number;
  22076. faceUV?: Vector4[];
  22077. faceColors?: Color4[];
  22078. sideOrientation?: number;
  22079. frontUVs?: Vector4;
  22080. backUVs?: Vector4;
  22081. updatable?: boolean;
  22082. }, scene?: Nullable<Scene>): Mesh;
  22083. /**
  22084. * Creates a sphere mesh
  22085. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22086. * * 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`)
  22087. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22088. * * 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
  22089. * * 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)
  22090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22091. * * 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
  22092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22093. * @param name defines the name of the mesh
  22094. * @param options defines the options used to create the mesh
  22095. * @param scene defines the hosting scene
  22096. * @returns the sphere mesh
  22097. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22098. */
  22099. static CreateSphere(name: string, options: {
  22100. segments?: number;
  22101. diameter?: number;
  22102. diameterX?: number;
  22103. diameterY?: number;
  22104. diameterZ?: number;
  22105. arc?: number;
  22106. slice?: number;
  22107. sideOrientation?: number;
  22108. frontUVs?: Vector4;
  22109. backUVs?: Vector4;
  22110. updatable?: boolean;
  22111. }, scene: any): Mesh;
  22112. /**
  22113. * Creates a plane polygonal mesh. By default, this is a disc
  22114. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22115. * * 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
  22116. * * 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
  22117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22118. * * 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
  22119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22120. * @param name defines the name of the mesh
  22121. * @param options defines the options used to create the mesh
  22122. * @param scene defines the hosting scene
  22123. * @returns the plane polygonal mesh
  22124. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22125. */
  22126. static CreateDisc(name: string, options: {
  22127. radius?: number;
  22128. tessellation?: number;
  22129. arc?: number;
  22130. updatable?: boolean;
  22131. sideOrientation?: number;
  22132. frontUVs?: Vector4;
  22133. backUVs?: Vector4;
  22134. }, scene?: Nullable<Scene>): Mesh;
  22135. /**
  22136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22138. * * 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`)
  22139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22140. * * 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
  22141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22142. * * 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
  22143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22144. * @param name defines the name of the mesh
  22145. * @param options defines the options used to create the mesh
  22146. * @param scene defines the hosting scene
  22147. * @returns the icosahedron mesh
  22148. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22149. */
  22150. static CreateIcoSphere(name: string, options: {
  22151. radius?: number;
  22152. radiusX?: number;
  22153. radiusY?: number;
  22154. radiusZ?: number;
  22155. flat?: boolean;
  22156. subdivisions?: number;
  22157. sideOrientation?: number;
  22158. frontUVs?: Vector4;
  22159. backUVs?: Vector4;
  22160. updatable?: boolean;
  22161. }, scene: Scene): Mesh;
  22162. /**
  22163. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22164. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22165. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22166. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22167. * * 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
  22168. * * 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
  22169. * * 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
  22170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22171. * * 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
  22172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22173. * * 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
  22174. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22175. * * 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
  22176. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22178. * @param name defines the name of the mesh
  22179. * @param options defines the options used to create the mesh
  22180. * @param scene defines the hosting scene
  22181. * @returns the ribbon mesh
  22182. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22183. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22184. */
  22185. static CreateRibbon(name: string, options: {
  22186. pathArray: Vector3[][];
  22187. closeArray?: boolean;
  22188. closePath?: boolean;
  22189. offset?: number;
  22190. updatable?: boolean;
  22191. sideOrientation?: number;
  22192. frontUVs?: Vector4;
  22193. backUVs?: Vector4;
  22194. instance?: Mesh;
  22195. invertUV?: boolean;
  22196. uvs?: Vector2[];
  22197. colors?: Color4[];
  22198. }, scene?: Nullable<Scene>): Mesh;
  22199. /**
  22200. * Creates a cylinder or a cone mesh
  22201. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22202. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22203. * * 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.
  22204. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22205. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22206. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22207. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22208. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22209. * * 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).
  22210. * * 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
  22211. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22212. * * 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
  22213. * * 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.
  22214. * * If `enclose` is false, a ring surface is one element.
  22215. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22216. * * 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
  22217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22218. * * 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
  22219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22220. * @param name defines the name of the mesh
  22221. * @param options defines the options used to create the mesh
  22222. * @param scene defines the hosting scene
  22223. * @returns the cylinder mesh
  22224. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22225. */
  22226. static CreateCylinder(name: string, options: {
  22227. height?: number;
  22228. diameterTop?: number;
  22229. diameterBottom?: number;
  22230. diameter?: number;
  22231. tessellation?: number;
  22232. subdivisions?: number;
  22233. arc?: number;
  22234. faceColors?: Color4[];
  22235. faceUV?: Vector4[];
  22236. updatable?: boolean;
  22237. hasRings?: boolean;
  22238. enclose?: boolean;
  22239. sideOrientation?: number;
  22240. frontUVs?: Vector4;
  22241. backUVs?: Vector4;
  22242. }, scene: any): Mesh;
  22243. /**
  22244. * Creates a torus mesh
  22245. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22246. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22247. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22249. * * 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
  22250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22251. * @param name defines the name of the mesh
  22252. * @param options defines the options used to create the mesh
  22253. * @param scene defines the hosting scene
  22254. * @returns the torus mesh
  22255. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22256. */
  22257. static CreateTorus(name: string, options: {
  22258. diameter?: number;
  22259. thickness?: number;
  22260. tessellation?: number;
  22261. updatable?: boolean;
  22262. sideOrientation?: number;
  22263. frontUVs?: Vector4;
  22264. backUVs?: Vector4;
  22265. }, scene: any): Mesh;
  22266. /**
  22267. * Creates a torus knot mesh
  22268. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22269. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22270. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22271. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22273. * * 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
  22274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22275. * @param name defines the name of the mesh
  22276. * @param options defines the options used to create the mesh
  22277. * @param scene defines the hosting scene
  22278. * @returns the torus knot mesh
  22279. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22280. */
  22281. static CreateTorusKnot(name: string, options: {
  22282. radius?: number;
  22283. tube?: number;
  22284. radialSegments?: number;
  22285. tubularSegments?: number;
  22286. p?: number;
  22287. q?: number;
  22288. updatable?: boolean;
  22289. sideOrientation?: number;
  22290. frontUVs?: Vector4;
  22291. backUVs?: Vector4;
  22292. }, scene: any): Mesh;
  22293. /**
  22294. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22295. * * 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
  22296. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22297. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22298. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22299. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22300. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22301. * * 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
  22302. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22305. * @param name defines the name of the new line system
  22306. * @param options defines the options used to create the line system
  22307. * @param scene defines the hosting scene
  22308. * @returns a new line system mesh
  22309. */
  22310. static CreateLineSystem(name: string, options: {
  22311. lines: Vector3[][];
  22312. updatable?: boolean;
  22313. instance?: Nullable<LinesMesh>;
  22314. colors?: Nullable<Color4[][]>;
  22315. useVertexAlpha?: boolean;
  22316. }, scene: Nullable<Scene>): LinesMesh;
  22317. /**
  22318. * Creates a line mesh
  22319. * 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
  22320. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22321. * * The parameter `points` is an array successive Vector3
  22322. * * 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
  22323. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22324. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22325. * * When updating an instance, remember that only point positions can change, not the number of points
  22326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22327. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22328. * @param name defines the name of the new line system
  22329. * @param options defines the options used to create the line system
  22330. * @param scene defines the hosting scene
  22331. * @returns a new line mesh
  22332. */
  22333. static CreateLines(name: string, options: {
  22334. points: Vector3[];
  22335. updatable?: boolean;
  22336. instance?: Nullable<LinesMesh>;
  22337. colors?: Color4[];
  22338. useVertexAlpha?: boolean;
  22339. }, scene?: Nullable<Scene>): LinesMesh;
  22340. /**
  22341. * Creates a dashed line mesh
  22342. * * 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
  22343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22344. * * The parameter `points` is an array successive Vector3
  22345. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22346. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22347. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22348. * * 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
  22349. * * When updating an instance, remember that only point positions can change, not the number of points
  22350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22351. * @param name defines the name of the mesh
  22352. * @param options defines the options used to create the mesh
  22353. * @param scene defines the hosting scene
  22354. * @returns the dashed line mesh
  22355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22356. */
  22357. static CreateDashedLines(name: string, options: {
  22358. points: Vector3[];
  22359. dashSize?: number;
  22360. gapSize?: number;
  22361. dashNb?: number;
  22362. updatable?: boolean;
  22363. instance?: LinesMesh;
  22364. }, scene?: Nullable<Scene>): LinesMesh;
  22365. /**
  22366. * 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.
  22367. * * 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.
  22368. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22369. * * 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.
  22370. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22371. * * 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
  22372. * * 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
  22373. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22375. * * 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
  22376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22378. * @param name defines the name of the mesh
  22379. * @param options defines the options used to create the mesh
  22380. * @param scene defines the hosting scene
  22381. * @returns the extruded shape mesh
  22382. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22383. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22384. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22385. */
  22386. static ExtrudeShape(name: string, options: {
  22387. shape: Vector3[];
  22388. path: Vector3[];
  22389. scale?: number;
  22390. rotation?: number;
  22391. cap?: number;
  22392. updatable?: boolean;
  22393. sideOrientation?: number;
  22394. frontUVs?: Vector4;
  22395. backUVs?: Vector4;
  22396. instance?: Mesh;
  22397. invertUV?: boolean;
  22398. }, scene?: Nullable<Scene>): Mesh;
  22399. /**
  22400. * Creates an custom extruded shape mesh.
  22401. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22402. * * 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.
  22403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22404. * * 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
  22405. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22406. * * 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
  22407. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22408. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22409. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22410. * * 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
  22411. * * 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
  22412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22414. * * 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
  22415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22417. * @param name defines the name of the mesh
  22418. * @param options defines the options used to create the mesh
  22419. * @param scene defines the hosting scene
  22420. * @returns the custom extruded shape mesh
  22421. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22422. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22423. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22424. */
  22425. static ExtrudeShapeCustom(name: string, options: {
  22426. shape: Vector3[];
  22427. path: Vector3[];
  22428. scaleFunction?: any;
  22429. rotationFunction?: any;
  22430. ribbonCloseArray?: boolean;
  22431. ribbonClosePath?: boolean;
  22432. cap?: number;
  22433. updatable?: boolean;
  22434. sideOrientation?: number;
  22435. frontUVs?: Vector4;
  22436. backUVs?: Vector4;
  22437. instance?: Mesh;
  22438. invertUV?: boolean;
  22439. }, scene: Scene): Mesh;
  22440. /**
  22441. * Creates lathe mesh.
  22442. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22443. * * 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
  22444. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22445. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22446. * * 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
  22447. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22448. * * 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
  22449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22450. * * 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
  22451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22453. * @param name defines the name of the mesh
  22454. * @param options defines the options used to create the mesh
  22455. * @param scene defines the hosting scene
  22456. * @returns the lathe mesh
  22457. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22458. */
  22459. static CreateLathe(name: string, options: {
  22460. shape: Vector3[];
  22461. radius?: number;
  22462. tessellation?: number;
  22463. arc?: number;
  22464. closed?: boolean;
  22465. updatable?: boolean;
  22466. sideOrientation?: number;
  22467. frontUVs?: Vector4;
  22468. backUVs?: Vector4;
  22469. cap?: number;
  22470. invertUV?: boolean;
  22471. }, scene: Scene): Mesh;
  22472. /**
  22473. * Creates a plane mesh
  22474. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22475. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22476. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22478. * * 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
  22479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22480. * @param name defines the name of the mesh
  22481. * @param options defines the options used to create the mesh
  22482. * @param scene defines the hosting scene
  22483. * @returns the plane mesh
  22484. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22485. */
  22486. static CreatePlane(name: string, options: {
  22487. size?: number;
  22488. width?: number;
  22489. height?: number;
  22490. sideOrientation?: number;
  22491. frontUVs?: Vector4;
  22492. backUVs?: Vector4;
  22493. updatable?: boolean;
  22494. sourcePlane?: Plane;
  22495. }, scene: Scene): Mesh;
  22496. /**
  22497. * Creates a ground mesh
  22498. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22499. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22501. * @param name defines the name of the mesh
  22502. * @param options defines the options used to create the mesh
  22503. * @param scene defines the hosting scene
  22504. * @returns the ground mesh
  22505. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22506. */
  22507. static CreateGround(name: string, options: {
  22508. width?: number;
  22509. height?: number;
  22510. subdivisions?: number;
  22511. subdivisionsX?: number;
  22512. subdivisionsY?: number;
  22513. updatable?: boolean;
  22514. }, scene: any): Mesh;
  22515. /**
  22516. * Creates a tiled ground mesh
  22517. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22518. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22519. * * 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
  22520. * * 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
  22521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22522. * @param name defines the name of the mesh
  22523. * @param options defines the options used to create the mesh
  22524. * @param scene defines the hosting scene
  22525. * @returns the tiled ground mesh
  22526. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22527. */
  22528. static CreateTiledGround(name: string, options: {
  22529. xmin: number;
  22530. zmin: number;
  22531. xmax: number;
  22532. zmax: number;
  22533. subdivisions?: {
  22534. w: number;
  22535. h: number;
  22536. };
  22537. precision?: {
  22538. w: number;
  22539. h: number;
  22540. };
  22541. updatable?: boolean;
  22542. }, scene: Scene): Mesh;
  22543. /**
  22544. * Creates a ground mesh from a height map
  22545. * * The parameter `url` sets the URL of the height map image resource.
  22546. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22547. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22548. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22549. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22550. * * 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.
  22551. * * 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).
  22552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22553. * @param name defines the name of the mesh
  22554. * @param url defines the url to the height map
  22555. * @param options defines the options used to create the mesh
  22556. * @param scene defines the hosting scene
  22557. * @returns the ground mesh
  22558. * @see http://doc.babylonjs.com/babylon101/height_map
  22559. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22560. */
  22561. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22562. width?: number;
  22563. height?: number;
  22564. subdivisions?: number;
  22565. minHeight?: number;
  22566. maxHeight?: number;
  22567. colorFilter?: Color3;
  22568. updatable?: boolean;
  22569. onReady?: (mesh: GroundMesh) => void;
  22570. }, scene: Scene): GroundMesh;
  22571. /**
  22572. * Creates a polygon mesh
  22573. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22574. * * 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
  22575. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22577. * * 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)
  22578. * * Remember you can only change the shape positions, not their number when updating a polygon
  22579. * @param name defines the name of the mesh
  22580. * @param options defines the options used to create the mesh
  22581. * @param scene defines the hosting scene
  22582. * @returns the polygon mesh
  22583. */
  22584. static CreatePolygon(name: string, options: {
  22585. shape: Vector3[];
  22586. holes?: Vector3[][];
  22587. depth?: number;
  22588. faceUV?: Vector4[];
  22589. faceColors?: Color4[];
  22590. updatable?: boolean;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }, scene: Scene): Mesh;
  22595. /**
  22596. * Creates an extruded polygon mesh, with depth in the Y direction.
  22597. * * 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)
  22598. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22599. * @param name defines the name of the mesh
  22600. * @param options defines the options used to create the mesh
  22601. * @param scene defines the hosting scene
  22602. * @returns the polygon mesh
  22603. */
  22604. static ExtrudePolygon(name: string, options: {
  22605. shape: Vector3[];
  22606. holes?: Vector3[][];
  22607. depth?: number;
  22608. faceUV?: Vector4[];
  22609. faceColors?: Color4[];
  22610. updatable?: boolean;
  22611. sideOrientation?: number;
  22612. frontUVs?: Vector4;
  22613. backUVs?: Vector4;
  22614. }, scene: Scene): Mesh;
  22615. /**
  22616. * Creates a tube mesh.
  22617. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22618. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22619. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22620. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22621. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22622. * * 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)
  22623. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22624. * * 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
  22625. * * 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
  22626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22627. * * 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
  22628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22630. * @param name defines the name of the mesh
  22631. * @param options defines the options used to create the mesh
  22632. * @param scene defines the hosting scene
  22633. * @returns the tube mesh
  22634. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22635. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22636. */
  22637. static CreateTube(name: string, options: {
  22638. path: Vector3[];
  22639. radius?: number;
  22640. tessellation?: number;
  22641. radiusFunction?: {
  22642. (i: number, distance: number): number;
  22643. };
  22644. cap?: number;
  22645. arc?: number;
  22646. updatable?: boolean;
  22647. sideOrientation?: number;
  22648. frontUVs?: Vector4;
  22649. backUVs?: Vector4;
  22650. instance?: Mesh;
  22651. invertUV?: boolean;
  22652. }, scene: Scene): Mesh;
  22653. /**
  22654. * Creates a polyhedron mesh
  22655. * * 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
  22656. * * The parameter `size` (positive float, default 1) sets the polygon size
  22657. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22658. * * 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`
  22659. * * 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
  22660. * * 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)`)
  22661. * * 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
  22662. * * 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
  22663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22664. * * 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
  22665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22666. * @param name defines the name of the mesh
  22667. * @param options defines the options used to create the mesh
  22668. * @param scene defines the hosting scene
  22669. * @returns the polyhedron mesh
  22670. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22671. */
  22672. static CreatePolyhedron(name: string, options: {
  22673. type?: number;
  22674. size?: number;
  22675. sizeX?: number;
  22676. sizeY?: number;
  22677. sizeZ?: number;
  22678. custom?: any;
  22679. faceUV?: Vector4[];
  22680. faceColors?: Color4[];
  22681. flat?: boolean;
  22682. updatable?: boolean;
  22683. sideOrientation?: number;
  22684. frontUVs?: Vector4;
  22685. backUVs?: Vector4;
  22686. }, scene: Scene): Mesh;
  22687. /**
  22688. * Creates a decal mesh.
  22689. * 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
  22690. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22691. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22692. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22693. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22694. * @param name defines the name of the mesh
  22695. * @param sourceMesh defines the mesh where the decal must be applied
  22696. * @param options defines the options used to create the mesh
  22697. * @param scene defines the hosting scene
  22698. * @returns the decal mesh
  22699. * @see http://doc.babylonjs.com/how_to/decals
  22700. */
  22701. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22702. position?: Vector3;
  22703. normal?: Vector3;
  22704. size?: Vector3;
  22705. angle?: number;
  22706. }): Mesh;
  22707. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22708. }
  22709. }
  22710. declare module BABYLON {
  22711. class MeshLODLevel {
  22712. distance: number;
  22713. mesh: Nullable<Mesh>;
  22714. constructor(distance: number, mesh: Nullable<Mesh>);
  22715. }
  22716. }
  22717. declare module BABYLON {
  22718. /**
  22719. * A simplifier interface for future simplification implementations.
  22720. */
  22721. interface ISimplifier {
  22722. /**
  22723. * Simplification of a given mesh according to the given settings.
  22724. * Since this requires computation, it is assumed that the function runs async.
  22725. * @param settings The settings of the simplification, including quality and distance
  22726. * @param successCallback A callback that will be called after the mesh was simplified.
  22727. * @param errorCallback in case of an error, this callback will be called. optional.
  22728. */
  22729. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22730. }
  22731. /**
  22732. * Expected simplification settings.
  22733. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22734. */
  22735. interface ISimplificationSettings {
  22736. quality: number;
  22737. distance: number;
  22738. optimizeMesh?: boolean;
  22739. }
  22740. class SimplificationSettings implements ISimplificationSettings {
  22741. quality: number;
  22742. distance: number;
  22743. optimizeMesh: boolean | undefined;
  22744. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22745. }
  22746. interface ISimplificationTask {
  22747. settings: Array<ISimplificationSettings>;
  22748. simplificationType: SimplificationType;
  22749. mesh: Mesh;
  22750. successCallback?: () => void;
  22751. parallelProcessing: boolean;
  22752. }
  22753. class SimplificationQueue {
  22754. private _simplificationArray;
  22755. running: boolean;
  22756. constructor();
  22757. addTask(task: ISimplificationTask): void;
  22758. executeNext(): void;
  22759. runSimplification(task: ISimplificationTask): void;
  22760. private getSimplifier(task);
  22761. }
  22762. /**
  22763. * The implemented types of simplification
  22764. * At the moment only Quadratic Error Decimation is implemented
  22765. */
  22766. enum SimplificationType {
  22767. /** Quadratic error decimation */
  22768. QUADRATIC = 0,
  22769. }
  22770. class DecimationTriangle {
  22771. vertices: Array<DecimationVertex>;
  22772. normal: Vector3;
  22773. error: Array<number>;
  22774. deleted: boolean;
  22775. isDirty: boolean;
  22776. borderFactor: number;
  22777. deletePending: boolean;
  22778. originalOffset: number;
  22779. constructor(vertices: Array<DecimationVertex>);
  22780. }
  22781. class DecimationVertex {
  22782. position: Vector3;
  22783. id: number;
  22784. q: QuadraticMatrix;
  22785. isBorder: boolean;
  22786. triangleStart: number;
  22787. triangleCount: number;
  22788. originalOffsets: Array<number>;
  22789. constructor(position: Vector3, id: number);
  22790. updatePosition(newPosition: Vector3): void;
  22791. }
  22792. class QuadraticMatrix {
  22793. data: Array<number>;
  22794. constructor(data?: Array<number>);
  22795. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22796. addInPlace(matrix: QuadraticMatrix): void;
  22797. addArrayInPlace(data: Array<number>): void;
  22798. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22799. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22800. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22801. }
  22802. class Reference {
  22803. vertexId: number;
  22804. triangleId: number;
  22805. constructor(vertexId: number, triangleId: number);
  22806. }
  22807. /**
  22808. * An implementation of the Quadratic Error simplification algorithm.
  22809. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22810. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22811. * @author RaananW
  22812. */
  22813. class QuadraticErrorSimplification implements ISimplifier {
  22814. private _mesh;
  22815. private triangles;
  22816. private vertices;
  22817. private references;
  22818. private _reconstructedMesh;
  22819. syncIterations: number;
  22820. aggressiveness: number;
  22821. decimationIterations: number;
  22822. boundingBoxEpsilon: number;
  22823. constructor(_mesh: Mesh);
  22824. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22825. private runDecimation(settings, submeshIndex, successCallback);
  22826. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22827. private init(callback);
  22828. private reconstructMesh(submeshIndex);
  22829. private initDecimatedMesh();
  22830. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22831. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22832. private identifyBorder();
  22833. private updateMesh(identifyBorders?);
  22834. private vertexError(q, point);
  22835. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22836. }
  22837. }
  22838. declare module BABYLON {
  22839. class Polygon {
  22840. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22841. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22842. static Parse(input: string): Vector2[];
  22843. static StartingAt(x: number, y: number): Path2;
  22844. }
  22845. class PolygonMeshBuilder {
  22846. private _points;
  22847. private _outlinepoints;
  22848. private _holes;
  22849. private _name;
  22850. private _scene;
  22851. private _epoints;
  22852. private _eholes;
  22853. private _addToepoint(points);
  22854. constructor(name: string, contours: Path2, scene: Scene);
  22855. constructor(name: string, contours: Vector2[], scene: Scene);
  22856. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22857. build(updatable?: boolean, depth?: number): Mesh;
  22858. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22859. }
  22860. }
  22861. declare module BABYLON {
  22862. class BaseSubMesh {
  22863. _materialDefines: Nullable<MaterialDefines>;
  22864. _materialEffect: Nullable<Effect>;
  22865. readonly effect: Nullable<Effect>;
  22866. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22867. }
  22868. class SubMesh extends BaseSubMesh implements ICullable {
  22869. materialIndex: number;
  22870. verticesStart: number;
  22871. verticesCount: number;
  22872. indexStart: number;
  22873. indexCount: number;
  22874. linesIndexCount: number;
  22875. private _mesh;
  22876. private _renderingMesh;
  22877. private _boundingInfo;
  22878. private _linesIndexBuffer;
  22879. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22880. _trianglePlanes: Plane[];
  22881. _lastColliderTransformMatrix: Matrix;
  22882. _renderId: number;
  22883. _alphaIndex: number;
  22884. _distanceToCamera: number;
  22885. _id: number;
  22886. private _currentMaterial;
  22887. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22888. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22889. readonly IsGlobal: boolean;
  22890. /**
  22891. * Returns the submesh BoudingInfo object.
  22892. */
  22893. getBoundingInfo(): BoundingInfo;
  22894. /**
  22895. * Sets the submesh BoundingInfo.
  22896. * Return the SubMesh.
  22897. */
  22898. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22899. /**
  22900. * Returns the mesh of the current submesh.
  22901. */
  22902. getMesh(): AbstractMesh;
  22903. /**
  22904. * Returns the rendering mesh of the submesh.
  22905. */
  22906. getRenderingMesh(): Mesh;
  22907. /**
  22908. * Returns the submesh material.
  22909. */
  22910. getMaterial(): Nullable<Material>;
  22911. /**
  22912. * Sets a new updated BoundingInfo object to the submesh.
  22913. * Returns the SubMesh.
  22914. */
  22915. refreshBoundingInfo(): SubMesh;
  22916. _checkCollision(collider: Collider): boolean;
  22917. /**
  22918. * Updates the submesh BoundingInfo.
  22919. * Returns the Submesh.
  22920. */
  22921. updateBoundingInfo(world: Matrix): SubMesh;
  22922. /**
  22923. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22924. * Boolean returned.
  22925. */
  22926. isInFrustum(frustumPlanes: Plane[]): boolean;
  22927. /**
  22928. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22929. * Boolean returned.
  22930. */
  22931. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22932. /**
  22933. * Renders the submesh.
  22934. * Returns it.
  22935. */
  22936. render(enableAlphaMode: boolean): SubMesh;
  22937. /**
  22938. * Returns a new Index Buffer.
  22939. * Type returned : WebGLBuffer.
  22940. */
  22941. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22942. /**
  22943. * True is the passed Ray intersects the submesh bounding box.
  22944. * Boolean returned.
  22945. */
  22946. canIntersects(ray: Ray): boolean;
  22947. /**
  22948. * Returns an object IntersectionInfo.
  22949. */
  22950. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22951. _rebuild(): void;
  22952. /**
  22953. * Creates a new Submesh from the passed Mesh.
  22954. */
  22955. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22956. /**
  22957. * Disposes the Submesh.
  22958. * Returns nothing.
  22959. */
  22960. dispose(): void;
  22961. /**
  22962. * Creates a new Submesh from the passed parameters :
  22963. * - materialIndex (integer) : the index of the main mesh material.
  22964. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22965. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22966. * - mesh (Mesh) : the main mesh to create the submesh from.
  22967. * - renderingMesh (optional Mesh) : rendering mesh.
  22968. */
  22969. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22970. }
  22971. }
  22972. declare module BABYLON {
  22973. class TransformNode extends Node {
  22974. static BILLBOARDMODE_NONE: number;
  22975. static BILLBOARDMODE_X: number;
  22976. static BILLBOARDMODE_Y: number;
  22977. static BILLBOARDMODE_Z: number;
  22978. static BILLBOARDMODE_ALL: number;
  22979. private _forward;
  22980. private _forwardInverted;
  22981. private _up;
  22982. private _right;
  22983. private _rightInverted;
  22984. private _rotation;
  22985. private _rotationQuaternion;
  22986. protected _scaling: Vector3;
  22987. protected _isDirty: boolean;
  22988. private _transformToBoneReferal;
  22989. /**
  22990. * Set the billboard mode. Default is 0.
  22991. *
  22992. * | Value | Type | Description |
  22993. * | --- | --- | --- |
  22994. * | 0 | BILLBOARDMODE_NONE | |
  22995. * | 1 | BILLBOARDMODE_X | |
  22996. * | 2 | BILLBOARDMODE_Y | |
  22997. * | 4 | BILLBOARDMODE_Z | |
  22998. * | 7 | BILLBOARDMODE_ALL | |
  22999. *
  23000. */
  23001. billboardMode: number;
  23002. scalingDeterminant: number;
  23003. infiniteDistance: boolean;
  23004. /**
  23005. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23006. * By default the system will update normals to compensate
  23007. */
  23008. ignoreNonUniformScaling: boolean;
  23009. position: Vector3;
  23010. _poseMatrix: Matrix;
  23011. private _localWorld;
  23012. _worldMatrix: Matrix;
  23013. _worldMatrixDeterminant: number;
  23014. private _absolutePosition;
  23015. private _pivotMatrix;
  23016. private _pivotMatrixInverse;
  23017. private _postMultiplyPivotMatrix;
  23018. protected _isWorldMatrixFrozen: boolean;
  23019. /**
  23020. * An event triggered after the world matrix is updated
  23021. */
  23022. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23023. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23024. /**
  23025. * Gets a string idenfifying the name of the class
  23026. * @returns "TransformNode" string
  23027. */
  23028. getClassName(): string;
  23029. /**
  23030. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23031. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23032. * Default : (0.0, 0.0, 0.0)
  23033. */
  23034. rotation: Vector3;
  23035. /**
  23036. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23037. * Default : (1.0, 1.0, 1.0)
  23038. */
  23039. /**
  23040. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23041. * Default : (1.0, 1.0, 1.0)
  23042. */
  23043. scaling: Vector3;
  23044. /**
  23045. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23046. * It's null by default.
  23047. * 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)
  23048. */
  23049. rotationQuaternion: Nullable<Quaternion>;
  23050. /**
  23051. * The forward direction of that transform in world space.
  23052. */
  23053. readonly forward: Vector3;
  23054. /**
  23055. * The up direction of that transform in world space.
  23056. */
  23057. readonly up: Vector3;
  23058. /**
  23059. * The right direction of that transform in world space.
  23060. */
  23061. readonly right: Vector3;
  23062. /**
  23063. * Returns the latest update of the World matrix
  23064. * Returns a Matrix.
  23065. */
  23066. getWorldMatrix(): Matrix;
  23067. /** @hidden */
  23068. _getWorldMatrixDeterminant(): number;
  23069. /**
  23070. * Returns directly the latest state of the mesh World matrix.
  23071. * A Matrix is returned.
  23072. */
  23073. readonly worldMatrixFromCache: Matrix;
  23074. /**
  23075. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23076. * Returns the TransformNode.
  23077. */
  23078. updatePoseMatrix(matrix: Matrix): TransformNode;
  23079. /**
  23080. * Returns the mesh Pose matrix.
  23081. * Returned object : Matrix
  23082. */
  23083. getPoseMatrix(): Matrix;
  23084. _isSynchronized(): boolean;
  23085. _initCache(): void;
  23086. markAsDirty(property: string): TransformNode;
  23087. /**
  23088. * Returns the current mesh absolute position.
  23089. * Retuns a Vector3.
  23090. */
  23091. readonly absolutePosition: Vector3;
  23092. /**
  23093. * Sets a new matrix to apply before all other transformation
  23094. * @param matrix defines the transform matrix
  23095. * @returns the current TransformNode
  23096. */
  23097. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23098. /**
  23099. * Sets a new pivot matrix to the current node
  23100. * @param matrix defines the new pivot matrix to use
  23101. * @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
  23102. * @returns the current TransformNode
  23103. */
  23104. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23105. /**
  23106. * Returns the mesh pivot matrix.
  23107. * Default : Identity.
  23108. * A Matrix is returned.
  23109. */
  23110. getPivotMatrix(): Matrix;
  23111. /**
  23112. * Prevents the World matrix to be computed any longer.
  23113. * Returns the TransformNode.
  23114. */
  23115. freezeWorldMatrix(): TransformNode;
  23116. /**
  23117. * Allows back the World matrix computation.
  23118. * Returns the TransformNode.
  23119. */
  23120. unfreezeWorldMatrix(): this;
  23121. /**
  23122. * True if the World matrix has been frozen.
  23123. * Returns a boolean.
  23124. */
  23125. readonly isWorldMatrixFrozen: boolean;
  23126. /**
  23127. * Retuns the mesh absolute position in the World.
  23128. * Returns a Vector3.
  23129. */
  23130. getAbsolutePosition(): Vector3;
  23131. /**
  23132. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23133. * Returns the TransformNode.
  23134. */
  23135. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23136. /**
  23137. * Sets the mesh position in its local space.
  23138. * Returns the TransformNode.
  23139. */
  23140. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23141. /**
  23142. * Returns the mesh position in the local space from the current World matrix values.
  23143. * Returns a new Vector3.
  23144. */
  23145. getPositionExpressedInLocalSpace(): Vector3;
  23146. /**
  23147. * Translates the mesh along the passed Vector3 in its local space.
  23148. * Returns the TransformNode.
  23149. */
  23150. locallyTranslate(vector3: Vector3): TransformNode;
  23151. private static _lookAtVectorCache;
  23152. /**
  23153. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23154. * @param targetPoint the position (must be in same space as current mesh) to look at
  23155. * @param yawCor optional yaw (y-axis) correction in radians
  23156. * @param pitchCor optional pitch (x-axis) correction in radians
  23157. * @param rollCor optional roll (z-axis) correction in radians
  23158. * @param space the choosen space of the target
  23159. * @returns the TransformNode.
  23160. */
  23161. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23162. /**
  23163. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23164. * This Vector3 is expressed in the World space.
  23165. */
  23166. getDirection(localAxis: Vector3): Vector3;
  23167. /**
  23168. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23169. * localAxis is expressed in the mesh local space.
  23170. * result is computed in the Wordl space from the mesh World matrix.
  23171. * Returns the TransformNode.
  23172. */
  23173. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23174. /**
  23175. * Sets a new pivot point to the current node
  23176. * @param point defines the new pivot point to use
  23177. * @param space defines if the point is in world or local space (local by default)
  23178. * @returns the current TransformNode
  23179. */
  23180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23181. /**
  23182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23183. */
  23184. getPivotPoint(): Vector3;
  23185. /**
  23186. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23187. * Returns the TransformNode.
  23188. */
  23189. getPivotPointToRef(result: Vector3): TransformNode;
  23190. /**
  23191. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23192. */
  23193. getAbsolutePivotPoint(): Vector3;
  23194. /**
  23195. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23196. * Returns the TransformNode.
  23197. */
  23198. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23199. /**
  23200. * Defines the passed node as the parent of the current node.
  23201. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23202. * Returns the TransformNode.
  23203. */
  23204. setParent(node: Nullable<Node>): TransformNode;
  23205. private _nonUniformScaling;
  23206. readonly nonUniformScaling: boolean;
  23207. _updateNonUniformScalingState(value: boolean): boolean;
  23208. /**
  23209. * Attach the current TransformNode to another TransformNode associated with a bone
  23210. * @param bone Bone affecting the TransformNode
  23211. * @param affectedTransformNode TransformNode associated with the bone
  23212. */
  23213. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23214. detachFromBone(): TransformNode;
  23215. private static _rotationAxisCache;
  23216. /**
  23217. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23218. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23219. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23220. * The passed axis is also normalized.
  23221. * Returns the TransformNode.
  23222. */
  23223. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23224. /**
  23225. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23226. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23227. * The passed axis is also normalized.
  23228. * Returns the TransformNode.
  23229. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23230. */
  23231. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23232. /**
  23233. * Translates the mesh along the axis vector for the passed distance in the given space.
  23234. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23235. * Returns the TransformNode.
  23236. */
  23237. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23238. /**
  23239. * Adds a rotation step to the mesh current rotation.
  23240. * x, y, z are Euler angles expressed in radians.
  23241. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23242. * This means this rotation is made in the mesh local space only.
  23243. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23244. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23245. * ```javascript
  23246. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23247. * ```
  23248. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23249. * 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.
  23250. * Returns the TransformNode.
  23251. */
  23252. addRotation(x: number, y: number, z: number): TransformNode;
  23253. /**
  23254. * Computes the mesh World matrix and returns it.
  23255. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23256. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23257. * If the parameter `force`is set to `true`, the actual computation is done.
  23258. * Returns the mesh World Matrix.
  23259. */
  23260. computeWorldMatrix(force?: boolean): Matrix;
  23261. protected _afterComputeWorldMatrix(): void;
  23262. /**
  23263. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23264. * @param func: callback function to add
  23265. *
  23266. * Returns the TransformNode.
  23267. */
  23268. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23269. /**
  23270. * Removes a registered callback function.
  23271. * Returns the TransformNode.
  23272. */
  23273. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23274. /**
  23275. * Clone the current transform node
  23276. * Returns the new transform node
  23277. * @param name Name of the new clone
  23278. * @param newParent New parent for the clone
  23279. * @param doNotCloneChildren Do not clone children hierarchy
  23280. */
  23281. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23282. serialize(currentSerializationObject?: any): any;
  23283. /**
  23284. * Returns a new TransformNode object parsed from the source provided.
  23285. * The parameter `parsedMesh` is the source.
  23286. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23287. */
  23288. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23289. /**
  23290. * Releases resources associated with this transform node.
  23291. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23292. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23293. */
  23294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23295. }
  23296. }
  23297. declare module BABYLON {
  23298. class VertexBuffer {
  23299. /** @hidden */
  23300. _buffer: Buffer;
  23301. private _kind;
  23302. private _size;
  23303. private _ownsBuffer;
  23304. private _instanced;
  23305. private _instanceDivisor;
  23306. /**
  23307. * The byte type.
  23308. */
  23309. static readonly BYTE: number;
  23310. /**
  23311. * The unsigned byte type.
  23312. */
  23313. static readonly UNSIGNED_BYTE: number;
  23314. /**
  23315. * The short type.
  23316. */
  23317. static readonly SHORT: number;
  23318. /**
  23319. * The unsigned short type.
  23320. */
  23321. static readonly UNSIGNED_SHORT: number;
  23322. /**
  23323. * The integer type.
  23324. */
  23325. static readonly INT: number;
  23326. /**
  23327. * The unsigned integer type.
  23328. */
  23329. static readonly UNSIGNED_INT: number;
  23330. /**
  23331. * The float type.
  23332. */
  23333. static readonly FLOAT: number;
  23334. /**
  23335. * Gets or sets the instance divisor when in instanced mode
  23336. */
  23337. instanceDivisor: number;
  23338. /**
  23339. * Gets the byte stride.
  23340. */
  23341. readonly byteStride: number;
  23342. /**
  23343. * Gets the byte offset.
  23344. */
  23345. readonly byteOffset: number;
  23346. /**
  23347. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23348. */
  23349. readonly normalized: boolean;
  23350. /**
  23351. * Gets the data type of each component in the array.
  23352. */
  23353. readonly type: number;
  23354. /**
  23355. * Constructor
  23356. * @param engine the engine
  23357. * @param data the data to use for this vertex buffer
  23358. * @param kind the vertex buffer kind
  23359. * @param updatable whether the data is updatable
  23360. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23361. * @param stride the stride (optional)
  23362. * @param instanced whether the buffer is instanced (optional)
  23363. * @param offset the offset of the data (optional)
  23364. * @param size the number of components (optional)
  23365. * @param type the type of the component (optional)
  23366. * @param normalized whether the data contains normalized data (optional)
  23367. * @param useBytes set to true if stride and offset are in bytes (optional)
  23368. */
  23369. 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);
  23370. _rebuild(): void;
  23371. /**
  23372. * Returns the kind of the VertexBuffer (string).
  23373. */
  23374. getKind(): string;
  23375. /**
  23376. * Boolean : is the VertexBuffer updatable ?
  23377. */
  23378. isUpdatable(): boolean;
  23379. /**
  23380. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23381. */
  23382. getData(): Nullable<DataArray>;
  23383. /**
  23384. * Returns the WebGLBuffer associated to the VertexBuffer.
  23385. */
  23386. getBuffer(): Nullable<WebGLBuffer>;
  23387. /**
  23388. * Returns the stride as a multiple of the type byte length.
  23389. * DEPRECATED. Use byteStride instead.
  23390. */
  23391. getStrideSize(): number;
  23392. /**
  23393. * Returns the offset as a multiple of the type byte length.
  23394. * DEPRECATED. Use byteOffset instead.
  23395. */
  23396. getOffset(): number;
  23397. /**
  23398. * Returns the number of components per vertex attribute (integer).
  23399. */
  23400. getSize(): number;
  23401. /**
  23402. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23403. */
  23404. getIsInstanced(): boolean;
  23405. /**
  23406. * Returns the instancing divisor, zero for non-instanced (integer).
  23407. */
  23408. getInstanceDivisor(): number;
  23409. /**
  23410. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23411. * Returns the created WebGLBuffer.
  23412. */
  23413. create(data?: DataArray): void;
  23414. /**
  23415. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23416. * This function will create a new buffer if the current one is not updatable
  23417. * Returns the updated WebGLBuffer.
  23418. */
  23419. update(data: DataArray): void;
  23420. /**
  23421. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23422. * Returns the directly updated WebGLBuffer.
  23423. * @param data the new data
  23424. * @param offset the new offset
  23425. * @param useBytes set to true if the offset is in bytes
  23426. */
  23427. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23428. /**
  23429. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23430. */
  23431. dispose(): void;
  23432. /**
  23433. * Enumerates each value of this vertex buffer as numbers.
  23434. * @param count the number of values to enumerate
  23435. * @param callback the callback function called for each value
  23436. */
  23437. forEach(count: number, callback: (value: number, index: number) => void): void;
  23438. private static _PositionKind;
  23439. private static _NormalKind;
  23440. private static _TangentKind;
  23441. private static _UVKind;
  23442. private static _UV2Kind;
  23443. private static _UV3Kind;
  23444. private static _UV4Kind;
  23445. private static _UV5Kind;
  23446. private static _UV6Kind;
  23447. private static _ColorKind;
  23448. private static _MatricesIndicesKind;
  23449. private static _MatricesWeightsKind;
  23450. private static _MatricesIndicesExtraKind;
  23451. private static _MatricesWeightsExtraKind;
  23452. static readonly PositionKind: string;
  23453. static readonly NormalKind: string;
  23454. static readonly TangentKind: string;
  23455. static readonly UVKind: string;
  23456. static readonly UV2Kind: string;
  23457. static readonly UV3Kind: string;
  23458. static readonly UV4Kind: string;
  23459. static readonly UV5Kind: string;
  23460. static readonly UV6Kind: string;
  23461. static readonly ColorKind: string;
  23462. static readonly MatricesIndicesKind: string;
  23463. static readonly MatricesWeightsKind: string;
  23464. static readonly MatricesIndicesExtraKind: string;
  23465. static readonly MatricesWeightsExtraKind: string;
  23466. /**
  23467. * Deduces the stride given a kind.
  23468. * @param kind The kind string to deduce
  23469. * @returns The deduced stride
  23470. */
  23471. static DeduceStride(kind: string): number;
  23472. /**
  23473. * Gets the byte length of the given type.
  23474. * @param type the type
  23475. * @returns the number of bytes
  23476. */
  23477. static GetTypeByteLength(type: number): number;
  23478. /**
  23479. * Enumerates each value of the given parameters as numbers.
  23480. * @param data the data to enumerate
  23481. * @param byteOffset the byte offset of the data
  23482. * @param byteStride the byte stride of the data
  23483. * @param componentCount the number of components per element
  23484. * @param componentType the type of the component
  23485. * @param count the total number of components
  23486. * @param normalized whether the data is normalized
  23487. * @param callback the callback function called for each value
  23488. */
  23489. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23490. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23491. }
  23492. }
  23493. declare module BABYLON {
  23494. /**
  23495. * This represents a GPU particle system in Babylon
  23496. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23497. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23498. */
  23499. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23500. /**
  23501. * The id of the Particle system.
  23502. */
  23503. id: string;
  23504. /**
  23505. * The friendly name of the Particle system.
  23506. */
  23507. name: string;
  23508. /**
  23509. * The emitter represents the Mesh or position we are attaching the particle system to.
  23510. */
  23511. emitter: Nullable<AbstractMesh | Vector3>;
  23512. /**
  23513. * The rendering group used by the Particle system to chose when to render.
  23514. */
  23515. renderingGroupId: number;
  23516. /**
  23517. * The layer mask we are rendering the particles through.
  23518. */
  23519. layerMask: number;
  23520. private _capacity;
  23521. private _activeCount;
  23522. private _currentActiveCount;
  23523. private _renderEffect;
  23524. private _updateEffect;
  23525. private _buffer0;
  23526. private _buffer1;
  23527. private _spriteBuffer;
  23528. private _updateVAO;
  23529. private _renderVAO;
  23530. private _targetIndex;
  23531. private _sourceBuffer;
  23532. private _targetBuffer;
  23533. private _scene;
  23534. private _engine;
  23535. private _currentRenderId;
  23536. private _started;
  23537. private _stopped;
  23538. private _timeDelta;
  23539. private _randomTexture;
  23540. private _attributesStrideSize;
  23541. private _updateEffectOptions;
  23542. private _randomTextureSize;
  23543. private _actualFrame;
  23544. /**
  23545. * List of animations used by the particle system.
  23546. */
  23547. animations: Animation[];
  23548. /**
  23549. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23550. */
  23551. static readonly IsSupported: boolean;
  23552. /**
  23553. * An event triggered when the system is disposed.
  23554. */
  23555. onDisposeObservable: Observable<GPUParticleSystem>;
  23556. /**
  23557. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23558. */
  23559. updateSpeed: number;
  23560. /**
  23561. * The amount of time the particle system is running (depends of the overall update speed).
  23562. */
  23563. targetStopDuration: number;
  23564. /**
  23565. * The texture used to render each particle. (this can be a spritesheet)
  23566. */
  23567. particleTexture: Nullable<Texture>;
  23568. /**
  23569. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23570. */
  23571. blendMode: number;
  23572. /**
  23573. * Minimum life time of emitting particles.
  23574. */
  23575. minLifeTime: number;
  23576. /**
  23577. * Maximum life time of emitting particles.
  23578. */
  23579. maxLifeTime: number;
  23580. /**
  23581. * Minimum Size of emitting particles.
  23582. */
  23583. minSize: number;
  23584. /**
  23585. * Maximum Size of emitting particles.
  23586. */
  23587. maxSize: number;
  23588. /**
  23589. * Minimum scale of emitting particles on X axis.
  23590. */
  23591. minScaleX: number;
  23592. /**
  23593. * Maximum scale of emitting particles on X axis.
  23594. */
  23595. maxScaleX: number;
  23596. /**
  23597. * Minimum scale of emitting particles on Y axis.
  23598. */
  23599. minScaleY: number;
  23600. /**
  23601. * Maximum scale of emitting particles on Y axis.
  23602. */
  23603. maxScaleY: number;
  23604. /**
  23605. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23606. */
  23607. color1: Color4;
  23608. /**
  23609. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23610. */
  23611. color2: Color4;
  23612. /**
  23613. * Color the particle will have at the end of its lifetime.
  23614. */
  23615. colorDead: Color4;
  23616. /**
  23617. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23618. */
  23619. emitRate: number;
  23620. /**
  23621. * You can use gravity if you want to give an orientation to your particles.
  23622. */
  23623. gravity: Vector3;
  23624. /**
  23625. * Minimum power of emitting particles.
  23626. */
  23627. minEmitPower: number;
  23628. /**
  23629. * Maximum power of emitting particles.
  23630. */
  23631. maxEmitPower: number;
  23632. /**
  23633. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23634. */
  23635. minAngularSpeed: number;
  23636. /**
  23637. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23638. */
  23639. maxAngularSpeed: number;
  23640. /**
  23641. * The particle emitter type defines the emitter used by the particle system.
  23642. * It can be for example box, sphere, or cone...
  23643. */
  23644. particleEmitterType: Nullable<IParticleEmitterType>;
  23645. /**
  23646. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23647. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23648. */
  23649. direction1: Vector3;
  23650. /**
  23651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23652. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23653. */
  23654. direction2: Vector3;
  23655. /**
  23656. * 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.
  23657. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23658. */
  23659. minEmitBox: Vector3;
  23660. /**
  23661. * 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.
  23662. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23663. */
  23664. maxEmitBox: Vector3;
  23665. /**
  23666. * Gets the maximum number of particles active at the same time.
  23667. * @returns The max number of active particles.
  23668. */
  23669. getCapacity(): number;
  23670. /**
  23671. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23672. * to override the particles.
  23673. */
  23674. forceDepthWrite: boolean;
  23675. /**
  23676. * Gets or set the number of active particles
  23677. */
  23678. activeParticleCount: number;
  23679. /**
  23680. * Is this system ready to be used/rendered
  23681. * @return true if the system is ready
  23682. */
  23683. isReady(): boolean;
  23684. /**
  23685. * Gets Wether the system has been started.
  23686. * @returns True if it has been started, otherwise false.
  23687. */
  23688. isStarted(): boolean;
  23689. /**
  23690. * Starts the particle system and begins to emit.
  23691. */
  23692. start(): void;
  23693. /**
  23694. * Stops the particle system.
  23695. */
  23696. stop(): void;
  23697. /**
  23698. * Remove all active particles
  23699. */
  23700. reset(): void;
  23701. /**
  23702. * Returns the string "GPUParticleSystem"
  23703. * @returns a string containing the class name
  23704. */
  23705. getClassName(): string;
  23706. private _isBillboardBased;
  23707. /**
  23708. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  23709. */
  23710. isBillboardBased: boolean;
  23711. /**
  23712. * Instantiates a GPU particle system.
  23713. * 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.
  23714. * @param name The name of the particle system
  23715. * @param capacity The max number of particles alive at the same time
  23716. * @param scene The scene the particle system belongs to
  23717. */
  23718. constructor(name: string, options: Partial<{
  23719. capacity: number;
  23720. randomTextureSize: number;
  23721. }>, scene: Scene);
  23722. private _createUpdateVAO(source);
  23723. private _createRenderVAO(source, spriteSource);
  23724. private _initialize(force?);
  23725. /** @hidden */
  23726. _recreateUpdateEffect(): void;
  23727. /** @hidden */
  23728. _recreateRenderEffect(): void;
  23729. /**
  23730. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23731. */
  23732. animate(): void;
  23733. /**
  23734. * Renders the particle system in its current state.
  23735. * @returns the current number of particles
  23736. */
  23737. render(): number;
  23738. /**
  23739. * Rebuilds the particle system
  23740. */
  23741. rebuild(): void;
  23742. private _releaseBuffers();
  23743. private _releaseVAOs();
  23744. /**
  23745. * Disposes the particle system and free the associated resources
  23746. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23747. */
  23748. dispose(disposeTexture?: boolean): void;
  23749. /**
  23750. * Clones the particle system.
  23751. * @param name The name of the cloned object
  23752. * @param newEmitter The new emitter to use
  23753. * @returns the cloned particle system
  23754. */
  23755. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  23756. /**
  23757. * Serializes the particle system to a JSON object.
  23758. * @returns the JSON object
  23759. */
  23760. serialize(): any;
  23761. /**
  23762. * Parses a JSON object to create a GPU particle system.
  23763. * @param parsedParticleSystem The JSON object to parse
  23764. * @param scene The scene to create the particle system in
  23765. * @param rootUrl The root url to use to load external dependencies like texture
  23766. * @returns the parsed GPU particle system
  23767. */
  23768. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  23769. }
  23770. }
  23771. declare module BABYLON {
  23772. /**
  23773. * Interface representing a particle system in Babylon.
  23774. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  23775. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  23776. */
  23777. interface IParticleSystem {
  23778. /**
  23779. * The id of the Particle system.
  23780. */
  23781. id: string;
  23782. /**
  23783. * The name of the Particle system.
  23784. */
  23785. name: string;
  23786. /**
  23787. * The emitter represents the Mesh or position we are attaching the particle system to.
  23788. */
  23789. emitter: Nullable<AbstractMesh | Vector3>;
  23790. /**
  23791. * The rendering group used by the Particle system to chose when to render.
  23792. */
  23793. renderingGroupId: number;
  23794. /**
  23795. * The layer mask we are rendering the particles through.
  23796. */
  23797. layerMask: number;
  23798. /**
  23799. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23800. */
  23801. updateSpeed: number;
  23802. /**
  23803. * The amount of time the particle system is running (depends of the overall update speed).
  23804. */
  23805. targetStopDuration: number;
  23806. /**
  23807. * The texture used to render each particle. (this can be a spritesheet)
  23808. */
  23809. particleTexture: Nullable<Texture>;
  23810. /**
  23811. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23812. */
  23813. blendMode: number;
  23814. /**
  23815. * Minimum life time of emitting particles.
  23816. */
  23817. minLifeTime: number;
  23818. /**
  23819. * Maximum life time of emitting particles.
  23820. */
  23821. maxLifeTime: number;
  23822. /**
  23823. * Minimum Size of emitting particles.
  23824. */
  23825. minSize: number;
  23826. /**
  23827. * Maximum Size of emitting particles.
  23828. */
  23829. maxSize: number;
  23830. /**
  23831. * Minimum scale of emitting particles on X axis.
  23832. */
  23833. minScaleX: number;
  23834. /**
  23835. * Maximum scale of emitting particles on X axis.
  23836. */
  23837. maxScaleX: number;
  23838. /**
  23839. * Minimum scale of emitting particles on Y axis.
  23840. */
  23841. minScaleY: number;
  23842. /**
  23843. * Maximum scale of emitting particles on Y axis.
  23844. */
  23845. maxScaleY: number;
  23846. /**
  23847. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23848. */
  23849. color1: Color4;
  23850. /**
  23851. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23852. */
  23853. color2: Color4;
  23854. /**
  23855. * Color the particle will have at the end of its lifetime.
  23856. */
  23857. colorDead: Color4;
  23858. /**
  23859. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23860. */
  23861. emitRate: number;
  23862. /**
  23863. * You can use gravity if you want to give an orientation to your particles.
  23864. */
  23865. gravity: Vector3;
  23866. /**
  23867. * Minimum power of emitting particles.
  23868. */
  23869. minEmitPower: number;
  23870. /**
  23871. * Maximum power of emitting particles.
  23872. */
  23873. maxEmitPower: number;
  23874. /**
  23875. * The particle emitter type defines the emitter used by the particle system.
  23876. * It can be for example box, sphere, or cone...
  23877. */
  23878. particleEmitterType: Nullable<IParticleEmitterType>;
  23879. /**
  23880. * Gets the maximum number of particles active at the same time.
  23881. * @returns The max number of active particles.
  23882. */
  23883. getCapacity(): number;
  23884. /**
  23885. * Gets Wether the system has been started.
  23886. * @returns True if it has been started, otherwise false.
  23887. */
  23888. isStarted(): boolean;
  23889. /**
  23890. * Gets if the particle system has been started.
  23891. * @return true if the system has been started, otherwise false.
  23892. */
  23893. isStarted(): boolean;
  23894. /**
  23895. * Animates the particle system for this frame.
  23896. */
  23897. animate(): void;
  23898. /**
  23899. * Renders the particle system in its current state.
  23900. * @returns the current number of particles
  23901. */
  23902. render(): number;
  23903. /**
  23904. * Dispose the particle system and frees its associated resources.
  23905. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23906. */
  23907. dispose(disposeTexture?: boolean): void;
  23908. /**
  23909. * Clones the particle system.
  23910. * @param name The name of the cloned object
  23911. * @param newEmitter The new emitter to use
  23912. * @returns the cloned particle system
  23913. */
  23914. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23915. /**
  23916. * Serializes the particle system to a JSON object.
  23917. * @returns the JSON object
  23918. */
  23919. serialize(): any;
  23920. /**
  23921. * Rebuild the particle system
  23922. */
  23923. rebuild(): void;
  23924. /**
  23925. * Starts the particle system and begins to emit.
  23926. */
  23927. start(): void;
  23928. /**
  23929. * Stops the particle system.
  23930. */
  23931. stop(): void;
  23932. /**
  23933. * Remove all active particles
  23934. */
  23935. reset(): void;
  23936. /**
  23937. * Is this system ready to be used/rendered
  23938. * @return true if the system is ready
  23939. */
  23940. isReady(): boolean;
  23941. }
  23942. }
  23943. declare module BABYLON {
  23944. /**
  23945. * A particle represents one of the element emitted by a particle system.
  23946. * This is mainly define by its coordinates, direction, velocity and age.
  23947. */
  23948. class Particle {
  23949. /**
  23950. * particleSystem the particle system the particle belongs to.
  23951. */
  23952. particleSystem: ParticleSystem;
  23953. /**
  23954. * The world position of the particle in the scene.
  23955. */
  23956. position: Vector3;
  23957. /**
  23958. * The world direction of the particle in the scene.
  23959. */
  23960. direction: Vector3;
  23961. /**
  23962. * The color of the particle.
  23963. */
  23964. color: Color4;
  23965. /**
  23966. * The color change of the particle per step.
  23967. */
  23968. colorStep: Color4;
  23969. /**
  23970. * Defines how long will the life of the particle be.
  23971. */
  23972. lifeTime: number;
  23973. /**
  23974. * The current age of the particle.
  23975. */
  23976. age: number;
  23977. /**
  23978. * The current size of the particle.
  23979. */
  23980. size: number;
  23981. /**
  23982. * The current scale of the particle.
  23983. */
  23984. scale: Vector2;
  23985. /**
  23986. * The current angle of the particle.
  23987. */
  23988. angle: number;
  23989. /**
  23990. * Defines how fast is the angle changing.
  23991. */
  23992. angularSpeed: number;
  23993. /**
  23994. * Defines the cell index used by the particle to be rendered from a sprite.
  23995. */
  23996. cellIndex: number;
  23997. private _currentFrameCounter;
  23998. /** @hidden */
  23999. _initialDirection: Nullable<Vector3>;
  24000. /**
  24001. * Creates a new instance Particle
  24002. * @param particleSystem the particle system the particle belongs to
  24003. */
  24004. constructor(
  24005. /**
  24006. * particleSystem the particle system the particle belongs to.
  24007. */
  24008. particleSystem: ParticleSystem);
  24009. private updateCellInfoFromSystem();
  24010. /**
  24011. * Defines how the sprite cell index is updated for the particle. This is
  24012. * defined as a callback.
  24013. */
  24014. updateCellIndex: (scaledUpdateSpeed: number) => void;
  24015. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  24016. private _updateCellIndexWithCustomSpeed();
  24017. /**
  24018. * Copy the properties of particle to another one.
  24019. * @param other the particle to copy the information to.
  24020. */
  24021. copyTo(other: Particle): void;
  24022. }
  24023. }
  24024. declare module BABYLON {
  24025. /**
  24026. * This represents a particle system in Babylon.
  24027. * 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.
  24028. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24029. * @example https://doc.babylonjs.com/babylon101/particles
  24030. */
  24031. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  24032. /**
  24033. * Source color is added to the destination color without alpha affecting the result.
  24034. */
  24035. static BLENDMODE_ONEONE: number;
  24036. /**
  24037. * Blend current color and particle color using particle’s alpha.
  24038. */
  24039. static BLENDMODE_STANDARD: number;
  24040. /**
  24041. * Add current color and particle color multiplied by particle’s alpha.
  24042. */
  24043. static BLENDMODE_ADD: number;
  24044. /**
  24045. * List of animations used by the particle system.
  24046. */
  24047. animations: Animation[];
  24048. /**
  24049. * The id of the Particle system.
  24050. */
  24051. id: string;
  24052. /**
  24053. * The friendly name of the Particle system.
  24054. */
  24055. name: string;
  24056. /**
  24057. * The rendering group used by the Particle system to chose when to render.
  24058. */
  24059. renderingGroupId: number;
  24060. /**
  24061. * The emitter represents the Mesh or position we are attaching the particle system to.
  24062. */
  24063. emitter: Nullable<AbstractMesh | Vector3>;
  24064. /**
  24065. * The maximum number of particles to emit per frame
  24066. */
  24067. emitRate: number;
  24068. /**
  24069. * If you want to launch only a few particles at once, that can be done, as well.
  24070. */
  24071. manualEmitCount: number;
  24072. /**
  24073. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24074. */
  24075. updateSpeed: number;
  24076. /**
  24077. * The amount of time the particle system is running (depends of the overall update speed).
  24078. */
  24079. targetStopDuration: number;
  24080. /**
  24081. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24082. */
  24083. disposeOnStop: boolean;
  24084. /**
  24085. * Minimum power of emitting particles.
  24086. */
  24087. minEmitPower: number;
  24088. /**
  24089. * Maximum power of emitting particles.
  24090. */
  24091. maxEmitPower: number;
  24092. /**
  24093. * Minimum life time of emitting particles.
  24094. */
  24095. minLifeTime: number;
  24096. /**
  24097. * Maximum life time of emitting particles.
  24098. */
  24099. maxLifeTime: number;
  24100. /**
  24101. * Minimum Size of emitting particles.
  24102. */
  24103. minSize: number;
  24104. /**
  24105. * Maximum Size of emitting particles.
  24106. */
  24107. maxSize: number;
  24108. /**
  24109. * Minimum scale of emitting particles on X axis.
  24110. */
  24111. minScaleX: number;
  24112. /**
  24113. * Maximum scale of emitting particles on X axis.
  24114. */
  24115. maxScaleX: number;
  24116. /**
  24117. * Minimum scale of emitting particles on Y axis.
  24118. */
  24119. minScaleY: number;
  24120. /**
  24121. * Maximum scale of emitting particles on Y axis.
  24122. */
  24123. maxScaleY: number;
  24124. /**
  24125. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24126. */
  24127. minAngularSpeed: number;
  24128. /**
  24129. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24130. */
  24131. maxAngularSpeed: number;
  24132. /**
  24133. * The texture used to render each particle. (this can be a spritesheet)
  24134. */
  24135. particleTexture: Nullable<Texture>;
  24136. /**
  24137. * The layer mask we are rendering the particles through.
  24138. */
  24139. layerMask: number;
  24140. /**
  24141. * This can help using your own shader to render the particle system.
  24142. * The according effect will be created
  24143. */
  24144. customShader: any;
  24145. /**
  24146. * By default particle system starts as soon as they are created. This prevents the
  24147. * automatic start to happen and let you decide when to start emitting particles.
  24148. */
  24149. preventAutoStart: boolean;
  24150. /**
  24151. * This function can be defined to provide custom update for active particles.
  24152. * This function will be called instead of regular update (age, position, color, etc.).
  24153. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  24154. */
  24155. updateFunction: (particles: Particle[]) => void;
  24156. /**
  24157. * Callback triggered when the particle animation is ending.
  24158. */
  24159. onAnimationEnd: Nullable<() => void>;
  24160. /**
  24161. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24162. */
  24163. blendMode: number;
  24164. /**
  24165. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24166. * to override the particles.
  24167. */
  24168. forceDepthWrite: boolean;
  24169. /**
  24170. * You can use gravity if you want to give an orientation to your particles.
  24171. */
  24172. gravity: Vector3;
  24173. private _colorGradients;
  24174. /**
  24175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24176. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24177. */
  24178. direction1: Vector3;
  24179. /**
  24180. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24181. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24182. */
  24183. direction2: Vector3;
  24184. /**
  24185. * 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.
  24186. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24187. */
  24188. minEmitBox: Vector3;
  24189. /**
  24190. * 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.
  24191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24192. */
  24193. maxEmitBox: Vector3;
  24194. /**
  24195. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24196. */
  24197. color1: Color4;
  24198. /**
  24199. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24200. */
  24201. color2: Color4;
  24202. /**
  24203. * Color the particle will have at the end of its lifetime
  24204. */
  24205. colorDead: Color4;
  24206. /**
  24207. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24208. */
  24209. textureMask: Color4;
  24210. /**
  24211. * The particle emitter type defines the emitter used by the particle system.
  24212. * It can be for example box, sphere, or cone...
  24213. */
  24214. particleEmitterType: IParticleEmitterType;
  24215. /**
  24216. * This function can be defined to specify initial direction for every new particle.
  24217. * It by default use the emitterType defined function
  24218. */
  24219. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  24220. /**
  24221. * This function can be defined to specify initial position for every new particle.
  24222. * It by default use the emitterType defined function
  24223. */
  24224. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  24225. /**
  24226. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not
  24227. */
  24228. spriteCellLoop: boolean;
  24229. /**
  24230. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop
  24231. */
  24232. spriteCellChangeSpeed: number;
  24233. /**
  24234. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display
  24235. */
  24236. startSpriteCellID: number;
  24237. /**
  24238. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display
  24239. */
  24240. endSpriteCellID: number;
  24241. /**
  24242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24243. */
  24244. spriteCellWidth: number;
  24245. /**
  24246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24247. */
  24248. spriteCellHeight: number;
  24249. /** 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 */
  24250. preWarmCycles: number;
  24251. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24252. preWarmStepOffset: number;
  24253. /**
  24254. * An event triggered when the system is disposed
  24255. */
  24256. onDisposeObservable: Observable<ParticleSystem>;
  24257. private _onDisposeObserver;
  24258. /**
  24259. * Sets a callback that will be triggered when the system is disposed
  24260. */
  24261. onDispose: () => void;
  24262. /**
  24263. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24264. */
  24265. readonly isAnimationSheetEnabled: boolean;
  24266. /**
  24267. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24268. */
  24269. isBillboardBased: boolean;
  24270. private _particles;
  24271. private _epsilon;
  24272. private _capacity;
  24273. private _scene;
  24274. private _stockParticles;
  24275. private _newPartsExcess;
  24276. private _vertexData;
  24277. private _vertexBuffer;
  24278. private _vertexBuffers;
  24279. private _spriteBuffer;
  24280. private _indexBuffer;
  24281. private _effect;
  24282. private _customEffect;
  24283. private _cachedDefines;
  24284. private _scaledColorStep;
  24285. private _colorDiff;
  24286. private _scaledDirection;
  24287. private _scaledGravity;
  24288. private _currentRenderId;
  24289. private _alive;
  24290. private _useInstancing;
  24291. private _started;
  24292. private _stopped;
  24293. private _actualFrame;
  24294. private _scaledUpdateSpeed;
  24295. private _vertexBufferSize;
  24296. private _isAnimationSheetEnabled;
  24297. private _isBillboardBased;
  24298. /**
  24299. * 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.
  24300. */
  24301. subEmitters: ParticleSystem[];
  24302. /**
  24303. * The current active Sub-systems, this property is used by the root particle system only.
  24304. */
  24305. activeSubSystems: Array<ParticleSystem>;
  24306. private _rootParticleSystem;
  24307. /**
  24308. * Gets the current list of active particles
  24309. */
  24310. readonly particles: Particle[];
  24311. /**
  24312. * Returns the string "ParticleSystem"
  24313. * @returns a string containing the class name
  24314. */
  24315. getClassName(): string;
  24316. /**
  24317. * Instantiates a particle system.
  24318. * 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.
  24319. * @param name The name of the particle system
  24320. * @param capacity The max number of particles alive at the same time
  24321. * @param scene The scene the particle system belongs to
  24322. * @param customEffect a custom effect used to change the way particles are rendered by default
  24323. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24324. * @param epsilon Offset used to render the particles
  24325. */
  24326. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  24327. /**
  24328. * Adds a new color gradient
  24329. * @param gradient defines the gradient to use (between 0 and 1)
  24330. * @param color defines the color to affect to the specified gradient
  24331. */
  24332. addColorGradient(gradient: number, color: Color4): ParticleSystem;
  24333. /**
  24334. * Remove a specific color gradient
  24335. * @param gradient defines the gradient to remove
  24336. */
  24337. removeColorGradient(gradient: number): ParticleSystem;
  24338. private _resetEffect();
  24339. private _createVertexBuffers();
  24340. private _createIndexBuffer();
  24341. /**
  24342. * Gets the maximum number of particles active at the same time.
  24343. * @returns The max number of active particles.
  24344. */
  24345. getCapacity(): number;
  24346. /**
  24347. * Gets Wether there are still active particles in the system.
  24348. * @returns True if it is alive, otherwise false.
  24349. */
  24350. isAlive(): boolean;
  24351. /**
  24352. * Gets Wether the system has been started.
  24353. * @returns True if it has been started, otherwise false.
  24354. */
  24355. isStarted(): boolean;
  24356. /**
  24357. * Starts the particle system and begins to emit.
  24358. */
  24359. start(): void;
  24360. /**
  24361. * Stops the particle system.
  24362. * @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.
  24363. */
  24364. stop(stopSubEmitters?: boolean): void;
  24365. /**
  24366. * Remove all active particles
  24367. */
  24368. reset(): void;
  24369. /**
  24370. * @hidden (for internal use only)
  24371. */
  24372. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  24373. /**
  24374. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  24375. * Its lifetime will start back at 0.
  24376. */
  24377. recycleParticle: (particle: Particle) => void;
  24378. private _stopSubEmitters();
  24379. private _createParticle;
  24380. private _removeFromRoot();
  24381. private _emitFromParticle;
  24382. private _update(newParticles);
  24383. private _getEffect();
  24384. /**
  24385. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24386. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  24387. */
  24388. animate(preWarmOnly?: boolean): void;
  24389. private _appendParticleVertices(offset, particle);
  24390. /**
  24391. * Rebuilds the particle system.
  24392. */
  24393. rebuild(): void;
  24394. /**
  24395. * Is this system ready to be used/rendered
  24396. * @return true if the system is ready
  24397. */
  24398. isReady(): boolean;
  24399. /**
  24400. * Renders the particle system in its current state.
  24401. * @returns the current number of particles
  24402. */
  24403. render(): number;
  24404. /**
  24405. * Disposes the particle system and free the associated resources
  24406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24407. */
  24408. dispose(disposeTexture?: boolean): void;
  24409. /**
  24410. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  24411. * @param radius The radius of the sphere to emit from
  24412. * @returns the emitter
  24413. */
  24414. createSphereEmitter(radius?: number): SphereParticleEmitter;
  24415. /**
  24416. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  24417. * @param radius The radius of the sphere to emit from
  24418. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24419. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24420. * @returns the emitter
  24421. */
  24422. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24423. /**
  24424. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  24425. * @param radius The radius of the cone to emit from
  24426. * @param angle The base angle of the cone
  24427. * @returns the emitter
  24428. */
  24429. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24430. /**
  24431. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24434. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24435. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24436. * @returns the emitter
  24437. */
  24438. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24439. /**
  24440. * Clones the particle system.
  24441. * @param name The name of the cloned object
  24442. * @param newEmitter The new emitter to use
  24443. * @returns the cloned particle system
  24444. */
  24445. clone(name: string, newEmitter: any): ParticleSystem;
  24446. /**
  24447. * Serializes the particle system to a JSON object.
  24448. * @returns the JSON object
  24449. */
  24450. serialize(): any;
  24451. /**
  24452. * Parses a JSON object to create a particle system.
  24453. * @param parsedParticleSystem The JSON object to parse
  24454. * @param scene The scene to create the particle system in
  24455. * @param rootUrl The root url to use to load external dependencies like texture
  24456. * @returns the Parsed particle system
  24457. */
  24458. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  24459. }
  24460. }
  24461. declare module BABYLON {
  24462. /**
  24463. * Represents one particle of a solid particle system.
  24464. */
  24465. class SolidParticle {
  24466. /**
  24467. * particle global index
  24468. */
  24469. idx: number;
  24470. /**
  24471. * The color of the particle
  24472. */
  24473. color: Nullable<Color4>;
  24474. /**
  24475. * The world space position of the particle.
  24476. */
  24477. position: Vector3;
  24478. /**
  24479. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24480. */
  24481. rotation: Vector3;
  24482. /**
  24483. * The world space rotation quaternion of the particle.
  24484. */
  24485. rotationQuaternion: Nullable<Quaternion>;
  24486. /**
  24487. * The scaling of the particle.
  24488. */
  24489. scaling: Vector3;
  24490. /**
  24491. * The uvs of the particle.
  24492. */
  24493. uvs: Vector4;
  24494. /**
  24495. * The current speed of the particle.
  24496. */
  24497. velocity: Vector3;
  24498. /**
  24499. * The pivot point in the particle local space.
  24500. */
  24501. pivot: Vector3;
  24502. /**
  24503. * Must the particle be translated from its pivot point in its local space ?
  24504. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24505. * Default : false
  24506. */
  24507. translateFromPivot: boolean;
  24508. /**
  24509. * Is the particle active or not ?
  24510. */
  24511. alive: boolean;
  24512. /**
  24513. * Is the particle visible or not ?
  24514. */
  24515. isVisible: boolean;
  24516. /**
  24517. * Index of this particle in the global "positions" array (Internal use)
  24518. */
  24519. _pos: number;
  24520. /**
  24521. * Index of this particle in the global "indices" array (Internal use)
  24522. */
  24523. _ind: number;
  24524. /**
  24525. * ModelShape of this particle (Internal use)
  24526. */
  24527. _model: ModelShape;
  24528. /**
  24529. * ModelShape id of this particle
  24530. */
  24531. shapeId: number;
  24532. /**
  24533. * Index of the particle in its shape id (Internal use)
  24534. */
  24535. idxInShape: number;
  24536. /**
  24537. * Reference to the shape model BoundingInfo object (Internal use)
  24538. */
  24539. _modelBoundingInfo: BoundingInfo;
  24540. /**
  24541. * Particle BoundingInfo object (Internal use)
  24542. */
  24543. _boundingInfo: BoundingInfo;
  24544. /**
  24545. * Reference to the SPS what the particle belongs to (Internal use)
  24546. */
  24547. _sps: SolidParticleSystem;
  24548. /**
  24549. * Still set as invisible in order to skip useless computations (Internal use)
  24550. */
  24551. _stillInvisible: boolean;
  24552. /**
  24553. * Last computed particle rotation matrix
  24554. */
  24555. _rotationMatrix: number[];
  24556. /**
  24557. * Parent particle Id, if any.
  24558. * Default null.
  24559. */
  24560. parentId: Nullable<number>;
  24561. /**
  24562. * Internal global position in the SPS.
  24563. */
  24564. _globalPosition: Vector3;
  24565. /**
  24566. * Creates a Solid Particle object.
  24567. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24568. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24569. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24570. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24571. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24572. * @param shapeId (integer) is the model shape identifier in the SPS.
  24573. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24574. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24575. */
  24576. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24577. /**
  24578. * Legacy support, changed scale to scaling
  24579. */
  24580. /**
  24581. * Legacy support, changed scale to scaling
  24582. */
  24583. scale: Vector3;
  24584. /**
  24585. * Legacy support, changed quaternion to rotationQuaternion
  24586. */
  24587. /**
  24588. * Legacy support, changed quaternion to rotationQuaternion
  24589. */
  24590. quaternion: Nullable<Quaternion>;
  24591. /**
  24592. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24593. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24594. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24595. * @returns true if it intersects
  24596. */
  24597. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24598. }
  24599. /**
  24600. * Represents the shape of the model used by one particle of a solid particle system.
  24601. * SPS internal tool, don't use it manually.
  24602. */
  24603. class ModelShape {
  24604. /**
  24605. * The shape id.
  24606. */
  24607. shapeID: number;
  24608. /**
  24609. * flat array of model positions (internal use)
  24610. */
  24611. _shape: Vector3[];
  24612. /**
  24613. * flat array of model UVs (internal use)
  24614. */
  24615. _shapeUV: number[];
  24616. /**
  24617. * length of the shape in the model indices array (internal use)
  24618. */
  24619. _indicesLength: number;
  24620. /**
  24621. * Custom position function (internal use)
  24622. */
  24623. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24624. /**
  24625. * Custom vertex function (internal use)
  24626. */
  24627. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24628. /**
  24629. * 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.
  24630. * SPS internal tool, don't use it manually.
  24631. * @hidden
  24632. */
  24633. 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>);
  24634. }
  24635. /**
  24636. * Represents a Depth Sorted Particle in the solid particle system.
  24637. */
  24638. class DepthSortedParticle {
  24639. /**
  24640. * Index of the particle in the "indices" array
  24641. */
  24642. ind: number;
  24643. /**
  24644. * Length of the particle shape in the "indices" array
  24645. */
  24646. indicesLength: number;
  24647. /**
  24648. * Squared distance from the particle to the camera
  24649. */
  24650. sqDistance: number;
  24651. }
  24652. }
  24653. declare module BABYLON {
  24654. /**
  24655. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24656. *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.
  24657. * The SPS is also a particle system. It provides some methods to manage the particles.
  24658. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24659. *
  24660. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24661. */
  24662. class SolidParticleSystem implements IDisposable {
  24663. /**
  24664. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24665. * Example : var p = SPS.particles[i];
  24666. */
  24667. particles: SolidParticle[];
  24668. /**
  24669. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24670. */
  24671. nbParticles: number;
  24672. /**
  24673. * If the particles must ever face the camera (default false). Useful for planar particles.
  24674. */
  24675. billboard: boolean;
  24676. /**
  24677. * Recompute normals when adding a shape
  24678. */
  24679. recomputeNormals: boolean;
  24680. /**
  24681. * This a counter ofr your own usage. It's not set by any SPS functions.
  24682. */
  24683. counter: number;
  24684. /**
  24685. * The SPS name. This name is also given to the underlying mesh.
  24686. */
  24687. name: string;
  24688. /**
  24689. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24690. */
  24691. mesh: Mesh;
  24692. /**
  24693. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24694. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24695. */
  24696. vars: any;
  24697. /**
  24698. * This array is populated when the SPS is set as 'pickable'.
  24699. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24700. * Each element of this array is an object `{idx: int, faceId: int}`.
  24701. * `idx` is the picked particle index in the `SPS.particles` array
  24702. * `faceId` is the picked face index counted within this particle.
  24703. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24704. */
  24705. pickedParticles: {
  24706. idx: number;
  24707. faceId: number;
  24708. }[];
  24709. /**
  24710. * This array is populated when `enableDepthSort` is set to true.
  24711. * Each element of this array is an instance of the class DepthSortedParticle.
  24712. */
  24713. depthSortedParticles: DepthSortedParticle[];
  24714. /**
  24715. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24716. */
  24717. _bSphereOnly: boolean;
  24718. /**
  24719. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24720. */
  24721. _bSphereRadiusFactor: number;
  24722. private _scene;
  24723. private _positions;
  24724. private _indices;
  24725. private _normals;
  24726. private _colors;
  24727. private _uvs;
  24728. private _indices32;
  24729. private _positions32;
  24730. private _normals32;
  24731. private _fixedNormal32;
  24732. private _colors32;
  24733. private _uvs32;
  24734. private _index;
  24735. private _updatable;
  24736. private _pickable;
  24737. private _isVisibilityBoxLocked;
  24738. private _alwaysVisible;
  24739. private _depthSort;
  24740. private _shapeCounter;
  24741. private _copy;
  24742. private _shape;
  24743. private _shapeUV;
  24744. private _color;
  24745. private _computeParticleColor;
  24746. private _computeParticleTexture;
  24747. private _computeParticleRotation;
  24748. private _computeParticleVertex;
  24749. private _computeBoundingBox;
  24750. private _depthSortParticles;
  24751. private _cam_axisZ;
  24752. private _cam_axisY;
  24753. private _cam_axisX;
  24754. private _axisZ;
  24755. private _camera;
  24756. private _particle;
  24757. private _camDir;
  24758. private _camInvertedPosition;
  24759. private _rotMatrix;
  24760. private _invertMatrix;
  24761. private _rotated;
  24762. private _quaternion;
  24763. private _vertex;
  24764. private _normal;
  24765. private _yaw;
  24766. private _pitch;
  24767. private _roll;
  24768. private _halfroll;
  24769. private _halfpitch;
  24770. private _halfyaw;
  24771. private _sinRoll;
  24772. private _cosRoll;
  24773. private _sinPitch;
  24774. private _cosPitch;
  24775. private _sinYaw;
  24776. private _cosYaw;
  24777. private _mustUnrotateFixedNormals;
  24778. private _minimum;
  24779. private _maximum;
  24780. private _minBbox;
  24781. private _maxBbox;
  24782. private _particlesIntersect;
  24783. private _depthSortFunction;
  24784. private _needs32Bits;
  24785. private _pivotBackTranslation;
  24786. private _scaledPivot;
  24787. private _particleHasParent;
  24788. private _parent;
  24789. /**
  24790. * Creates a SPS (Solid Particle System) object.
  24791. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24792. * @param scene (Scene) is the scene in which the SPS is added.
  24793. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24794. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24795. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24796. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24797. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24798. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24799. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24800. */
  24801. constructor(name: string, scene: Scene, options?: {
  24802. updatable?: boolean;
  24803. isPickable?: boolean;
  24804. enableDepthSort?: boolean;
  24805. particleIntersection?: boolean;
  24806. boundingSphereOnly?: boolean;
  24807. bSphereRadiusFactor?: number;
  24808. });
  24809. /**
  24810. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24811. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24812. * @returns the created mesh
  24813. */
  24814. buildMesh(): Mesh;
  24815. /**
  24816. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24817. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24818. * Thus the particles generated from `digest()` have their property `position` set yet.
  24819. * @param mesh ( Mesh ) is the mesh to be digested
  24820. * @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
  24821. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24822. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24823. * @returns the current SPS
  24824. */
  24825. digest(mesh: Mesh, options?: {
  24826. facetNb?: number;
  24827. number?: number;
  24828. delta?: number;
  24829. }): SolidParticleSystem;
  24830. private _unrotateFixedNormals();
  24831. private _resetCopy();
  24832. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  24833. private _posToShape(positions);
  24834. private _uvsToShapeUV(uvs);
  24835. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  24836. /**
  24837. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24838. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24839. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24840. * @param nb (positive integer) the number of particles to be created from this model
  24841. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24842. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24843. * @returns the number of shapes in the system
  24844. */
  24845. addShape(mesh: Mesh, nb: number, options?: {
  24846. positionFunction?: any;
  24847. vertexFunction?: any;
  24848. }): number;
  24849. private _rebuildParticle(particle);
  24850. /**
  24851. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24852. * @returns the SPS.
  24853. */
  24854. rebuildMesh(): SolidParticleSystem;
  24855. /**
  24856. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24857. * This method calls `updateParticle()` for each particle of the SPS.
  24858. * For an animated SPS, it is usually called within the render loop.
  24859. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24860. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24861. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24862. * @returns the SPS.
  24863. */
  24864. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24865. private _quaternionRotationYPR();
  24866. private _quaternionToRotationMatrix();
  24867. /**
  24868. * Disposes the SPS.
  24869. */
  24870. dispose(): void;
  24871. /**
  24872. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24873. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24874. * @returns the SPS.
  24875. */
  24876. refreshVisibleSize(): SolidParticleSystem;
  24877. /**
  24878. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24879. * @param size the size (float) of the visibility box
  24880. * note : this doesn't lock the SPS mesh bounding box.
  24881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24882. */
  24883. setVisibilityBox(size: number): void;
  24884. /**
  24885. * Gets whether the SPS as always visible or not
  24886. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24887. */
  24888. /**
  24889. * Sets the SPS as always visible or not
  24890. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24891. */
  24892. isAlwaysVisible: boolean;
  24893. /**
  24894. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24895. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24896. */
  24897. /**
  24898. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24899. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24900. */
  24901. isVisibilityBoxLocked: boolean;
  24902. /**
  24903. * Gets if `setParticles()` computes the particle rotations or not.
  24904. * Default value : true. The SPS is faster when it's set to false.
  24905. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24906. */
  24907. /**
  24908. * Tells to `setParticles()` to compute the particle rotations or not.
  24909. * Default value : true. The SPS is faster when it's set to false.
  24910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24911. */
  24912. computeParticleRotation: boolean;
  24913. /**
  24914. * Gets if `setParticles()` computes the particle colors or not.
  24915. * Default value : true. The SPS is faster when it's set to false.
  24916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24917. */
  24918. /**
  24919. * Tells to `setParticles()` to compute the particle colors or not.
  24920. * Default value : true. The SPS is faster when it's set to false.
  24921. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24922. */
  24923. computeParticleColor: boolean;
  24924. /**
  24925. * Gets if `setParticles()` computes the particle textures or not.
  24926. * Default value : true. The SPS is faster when it's set to false.
  24927. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24928. */
  24929. computeParticleTexture: boolean;
  24930. /**
  24931. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24932. * Default value : false. The SPS is faster when it's set to false.
  24933. * Note : the particle custom vertex positions aren't stored values.
  24934. */
  24935. /**
  24936. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24937. * Default value : false. The SPS is faster when it's set to false.
  24938. * Note : the particle custom vertex positions aren't stored values.
  24939. */
  24940. computeParticleVertex: boolean;
  24941. /**
  24942. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24943. */
  24944. /**
  24945. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24946. */
  24947. computeBoundingBox: boolean;
  24948. /**
  24949. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24950. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24951. * Default : `true`
  24952. */
  24953. /**
  24954. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24956. * Default : `true`
  24957. */
  24958. depthSortParticles: boolean;
  24959. /**
  24960. * This function does nothing. It may be overwritten to set all the particle first values.
  24961. * The SPS doesn't call this function, you may have to call it by your own.
  24962. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24963. */
  24964. initParticles(): void;
  24965. /**
  24966. * This function does nothing. It may be overwritten to recycle a particle.
  24967. * The SPS doesn't call this function, you may have to call it by your own.
  24968. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24969. * @param particle The particle to recycle
  24970. * @returns the recycled particle
  24971. */
  24972. recycleParticle(particle: SolidParticle): SolidParticle;
  24973. /**
  24974. * Updates a particle : this function should be overwritten by the user.
  24975. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24976. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24977. * @example : just set a particle position or velocity and recycle conditions
  24978. * @param particle The particle to update
  24979. * @returns the updated particle
  24980. */
  24981. updateParticle(particle: SolidParticle): SolidParticle;
  24982. /**
  24983. * Updates a vertex of a particle : it can be overwritten by the user.
  24984. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24985. * @param particle the current particle
  24986. * @param vertex the current index of the current particle
  24987. * @param pt the index of the current vertex in the particle shape
  24988. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24989. * @example : just set a vertex particle position
  24990. * @returns the updated vertex
  24991. */
  24992. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24993. /**
  24994. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24995. * This does nothing and may be overwritten by the user.
  24996. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24997. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24998. * @param update the boolean update value actually passed to setParticles()
  24999. */
  25000. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25001. /**
  25002. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25003. * This will be passed three parameters.
  25004. * This does nothing and may be overwritten by the user.
  25005. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25006. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25007. * @param update the boolean update value actually passed to setParticles()
  25008. */
  25009. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25010. }
  25011. }
  25012. declare module BABYLON {
  25013. interface PhysicsImpostorJoint {
  25014. mainImpostor: PhysicsImpostor;
  25015. connectedImpostor: PhysicsImpostor;
  25016. joint: PhysicsJoint;
  25017. }
  25018. class PhysicsEngine {
  25019. private _physicsPlugin;
  25020. gravity: Vector3;
  25021. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  25022. setGravity(gravity: Vector3): void;
  25023. /**
  25024. * Set the time step of the physics engine.
  25025. * default is 1/60.
  25026. * To slow it down, enter 1/600 for example.
  25027. * To speed it up, 1/30
  25028. * @param {number} newTimeStep the new timestep to apply to this world.
  25029. */
  25030. setTimeStep(newTimeStep?: number): void;
  25031. /**
  25032. * Get the time step of the physics engine.
  25033. */
  25034. getTimeStep(): number;
  25035. dispose(): void;
  25036. getPhysicsPluginName(): string;
  25037. static Epsilon: number;
  25038. private _impostors;
  25039. private _joints;
  25040. /**
  25041. * Adding a new impostor for the impostor tracking.
  25042. * This will be done by the impostor itself.
  25043. * @param {PhysicsImpostor} impostor the impostor to add
  25044. */
  25045. addImpostor(impostor: PhysicsImpostor): void;
  25046. /**
  25047. * Remove an impostor from the engine.
  25048. * This impostor and its mesh will not longer be updated by the physics engine.
  25049. * @param {PhysicsImpostor} impostor the impostor to remove
  25050. */
  25051. removeImpostor(impostor: PhysicsImpostor): void;
  25052. /**
  25053. * Add a joint to the physics engine
  25054. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  25055. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  25056. * @param {PhysicsJoint} the joint that will connect both impostors.
  25057. */
  25058. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25059. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25060. /**
  25061. * Called by the scene. no need to call it.
  25062. */
  25063. _step(delta: number): void;
  25064. getPhysicsPlugin(): IPhysicsEnginePlugin;
  25065. getImpostors(): Array<PhysicsImpostor>;
  25066. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25067. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  25068. }
  25069. interface IPhysicsEnginePlugin {
  25070. world: any;
  25071. name: string;
  25072. setGravity(gravity: Vector3): void;
  25073. setTimeStep(timeStep: number): void;
  25074. getTimeStep(): number;
  25075. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  25076. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25077. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25078. generatePhysicsBody(impostor: PhysicsImpostor): void;
  25079. removePhysicsBody(impostor: PhysicsImpostor): void;
  25080. generateJoint(joint: PhysicsImpostorJoint): void;
  25081. removeJoint(joint: PhysicsImpostorJoint): void;
  25082. isSupported(): boolean;
  25083. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  25084. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  25085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  25090. getBodyMass(impostor: PhysicsImpostor): number;
  25091. getBodyFriction(impostor: PhysicsImpostor): number;
  25092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  25093. getBodyRestitution(impostor: PhysicsImpostor): number;
  25094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  25095. sleepBody(impostor: PhysicsImpostor): void;
  25096. wakeUpBody(impostor: PhysicsImpostor): void;
  25097. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  25098. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  25099. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25100. getRadius(impostor: PhysicsImpostor): number;
  25101. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  25102. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  25103. dispose(): void;
  25104. }
  25105. }
  25106. declare module BABYLON {
  25107. class PhysicsHelper {
  25108. private _scene;
  25109. private _physicsEngine;
  25110. constructor(scene: Scene);
  25111. /**
  25112. * @param {Vector3} origin the origin of the explosion
  25113. * @param {number} radius the explosion radius
  25114. * @param {number} strength the explosion strength
  25115. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25116. */
  25117. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25118. /**
  25119. * @param {Vector3} origin the origin of the explosion
  25120. * @param {number} radius the explosion radius
  25121. * @param {number} strength the explosion strength
  25122. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25123. */
  25124. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25125. /**
  25126. * @param {Vector3} origin the origin of the explosion
  25127. * @param {number} radius the explosion radius
  25128. * @param {number} strength the explosion strength
  25129. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25130. */
  25131. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25132. /**
  25133. * @param {Vector3} origin the origin of the updraft
  25134. * @param {number} radius the radius of the updraft
  25135. * @param {number} strength the strength of the updraft
  25136. * @param {number} height the height of the updraft
  25137. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  25138. */
  25139. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  25140. /**
  25141. * @param {Vector3} origin the of the vortex
  25142. * @param {number} radius the radius of the vortex
  25143. * @param {number} strength the strength of the vortex
  25144. * @param {number} height the height of the vortex
  25145. */
  25146. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  25147. }
  25148. /***** Radial explosion *****/
  25149. class PhysicsRadialExplosionEvent {
  25150. private _scene;
  25151. private _sphere;
  25152. private _sphereOptions;
  25153. private _rays;
  25154. private _dataFetched;
  25155. constructor(scene: Scene);
  25156. /**
  25157. * Returns the data related to the radial explosion event (sphere & rays).
  25158. * @returns {PhysicsRadialExplosionEventData}
  25159. */
  25160. getData(): PhysicsRadialExplosionEventData;
  25161. /**
  25162. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  25163. * @param impostor
  25164. * @param {Vector3} origin the origin of the explosion
  25165. * @param {number} radius the explosion radius
  25166. * @param {number} strength the explosion strength
  25167. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  25168. * @returns {Nullable<PhysicsForceAndContactPoint>}
  25169. */
  25170. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  25171. /**
  25172. * Disposes the sphere.
  25173. * @param {bolean} force
  25174. */
  25175. dispose(force?: boolean): void;
  25176. /*** Helpers ***/
  25177. private _prepareSphere();
  25178. private _intersectsWithSphere(impostor, origin, radius);
  25179. }
  25180. /***** Gravitational Field *****/
  25181. class PhysicsGravitationalFieldEvent {
  25182. private _physicsHelper;
  25183. private _scene;
  25184. private _origin;
  25185. private _radius;
  25186. private _strength;
  25187. private _falloff;
  25188. private _tickCallback;
  25189. private _sphere;
  25190. private _dataFetched;
  25191. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  25192. /**
  25193. * Returns the data related to the gravitational field event (sphere).
  25194. * @returns {PhysicsGravitationalFieldEventData}
  25195. */
  25196. getData(): PhysicsGravitationalFieldEventData;
  25197. /**
  25198. * Enables the gravitational field.
  25199. */
  25200. enable(): void;
  25201. /**
  25202. * Disables the gravitational field.
  25203. */
  25204. disable(): void;
  25205. /**
  25206. * Disposes the sphere.
  25207. * @param {bolean} force
  25208. */
  25209. dispose(force?: boolean): void;
  25210. private _tick();
  25211. }
  25212. /***** Updraft *****/
  25213. class PhysicsUpdraftEvent {
  25214. private _scene;
  25215. private _origin;
  25216. private _radius;
  25217. private _strength;
  25218. private _height;
  25219. private _updraftMode;
  25220. private _physicsEngine;
  25221. private _originTop;
  25222. private _originDirection;
  25223. private _tickCallback;
  25224. private _cylinder;
  25225. private _cylinderPosition;
  25226. private _dataFetched;
  25227. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  25228. /**
  25229. * Returns the data related to the updraft event (cylinder).
  25230. * @returns {PhysicsUpdraftEventData}
  25231. */
  25232. getData(): PhysicsUpdraftEventData;
  25233. /**
  25234. * Enables the updraft.
  25235. */
  25236. enable(): void;
  25237. /**
  25238. * Disables the cortex.
  25239. */
  25240. disable(): void;
  25241. /**
  25242. * Disposes the sphere.
  25243. * @param {bolean} force
  25244. */
  25245. dispose(force?: boolean): void;
  25246. private getImpostorForceAndContactPoint(impostor);
  25247. private _tick();
  25248. /*** Helpers ***/
  25249. private _prepareCylinder();
  25250. private _intersectsWithCylinder(impostor);
  25251. }
  25252. /***** Vortex *****/
  25253. class PhysicsVortexEvent {
  25254. private _scene;
  25255. private _origin;
  25256. private _radius;
  25257. private _strength;
  25258. private _height;
  25259. private _physicsEngine;
  25260. private _originTop;
  25261. private _centripetalForceThreshold;
  25262. private _updraftMultiplier;
  25263. private _tickCallback;
  25264. private _cylinder;
  25265. private _cylinderPosition;
  25266. private _dataFetched;
  25267. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  25268. /**
  25269. * Returns the data related to the vortex event (cylinder).
  25270. * @returns {PhysicsVortexEventData}
  25271. */
  25272. getData(): PhysicsVortexEventData;
  25273. /**
  25274. * Enables the vortex.
  25275. */
  25276. enable(): void;
  25277. /**
  25278. * Disables the cortex.
  25279. */
  25280. disable(): void;
  25281. /**
  25282. * Disposes the sphere.
  25283. * @param {bolean} force
  25284. */
  25285. dispose(force?: boolean): void;
  25286. private getImpostorForceAndContactPoint(impostor);
  25287. private _tick();
  25288. /*** Helpers ***/
  25289. private _prepareCylinder();
  25290. private _intersectsWithCylinder(impostor);
  25291. }
  25292. /***** Enums *****/
  25293. /**
  25294. * The strenght of the force in correspondence to the distance of the affected object
  25295. */
  25296. enum PhysicsRadialImpulseFalloff {
  25297. /** Defines that impulse is constant in strength across it's whole radius */
  25298. Constant = 0,
  25299. /** DEfines that impulse gets weaker if it's further from the origin */
  25300. Linear = 1,
  25301. }
  25302. /**
  25303. * The strenght of the force in correspondence to the distance of the affected object
  25304. */
  25305. enum PhysicsUpdraftMode {
  25306. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  25307. Center = 0,
  25308. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  25309. Perpendicular = 1,
  25310. }
  25311. /***** Data interfaces *****/
  25312. interface PhysicsForceAndContactPoint {
  25313. force: Vector3;
  25314. contactPoint: Vector3;
  25315. }
  25316. interface PhysicsRadialExplosionEventData {
  25317. sphere: Mesh;
  25318. rays: Array<Ray>;
  25319. }
  25320. interface PhysicsGravitationalFieldEventData {
  25321. sphere: Mesh;
  25322. }
  25323. interface PhysicsUpdraftEventData {
  25324. cylinder: Mesh;
  25325. }
  25326. interface PhysicsVortexEventData {
  25327. cylinder: Mesh;
  25328. }
  25329. }
  25330. declare module BABYLON {
  25331. interface PhysicsImpostorParameters {
  25332. mass: number;
  25333. friction?: number;
  25334. restitution?: number;
  25335. nativeOptions?: any;
  25336. ignoreParent?: boolean;
  25337. disableBidirectionalTransformation?: boolean;
  25338. }
  25339. interface IPhysicsEnabledObject {
  25340. position: Vector3;
  25341. rotationQuaternion: Nullable<Quaternion>;
  25342. scaling: Vector3;
  25343. rotation?: Vector3;
  25344. parent?: any;
  25345. getBoundingInfo(): BoundingInfo;
  25346. computeWorldMatrix(force: boolean): Matrix;
  25347. getWorldMatrix?(): Matrix;
  25348. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  25349. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  25350. getIndices?(): Nullable<IndicesArray>;
  25351. getScene?(): Scene;
  25352. getAbsolutePosition(): Vector3;
  25353. getAbsolutePivotPoint(): Vector3;
  25354. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25355. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25356. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25357. getClassName(): string;
  25358. }
  25359. class PhysicsImpostor {
  25360. object: IPhysicsEnabledObject;
  25361. type: number;
  25362. private _options;
  25363. private _scene;
  25364. static DEFAULT_OBJECT_SIZE: Vector3;
  25365. static IDENTITY_QUATERNION: Quaternion;
  25366. private _physicsEngine;
  25367. private _physicsBody;
  25368. private _bodyUpdateRequired;
  25369. private _onBeforePhysicsStepCallbacks;
  25370. private _onAfterPhysicsStepCallbacks;
  25371. private _onPhysicsCollideCallbacks;
  25372. private _deltaPosition;
  25373. private _deltaRotation;
  25374. private _deltaRotationConjugated;
  25375. private _parent;
  25376. private _isDisposed;
  25377. private static _tmpVecs;
  25378. private static _tmpQuat;
  25379. readonly isDisposed: boolean;
  25380. mass: number;
  25381. friction: number;
  25382. restitution: number;
  25383. uniqueId: number;
  25384. private _joints;
  25385. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25386. /**
  25387. * This function will completly initialize this impostor.
  25388. * It will create a new body - but only if this mesh has no parent.
  25389. * If it has, this impostor will not be used other than to define the impostor
  25390. * of the child mesh.
  25391. */
  25392. _init(): void;
  25393. private _getPhysicsParent();
  25394. /**
  25395. * Should a new body be generated.
  25396. */
  25397. isBodyInitRequired(): boolean;
  25398. setScalingUpdated(updated: boolean): void;
  25399. /**
  25400. * Force a regeneration of this or the parent's impostor's body.
  25401. * Use under cautious - This will remove all joints already implemented.
  25402. */
  25403. forceUpdate(): void;
  25404. /**
  25405. * Gets the body that holds this impostor. Either its own, or its parent.
  25406. */
  25407. /**
  25408. * Set the physics body. Used mainly by the physics engine/plugin
  25409. */
  25410. physicsBody: any;
  25411. parent: Nullable<PhysicsImpostor>;
  25412. resetUpdateFlags(): void;
  25413. getObjectExtendSize(): Vector3;
  25414. getObjectCenter(): Vector3;
  25415. /**
  25416. * Get a specific parametes from the options parameter.
  25417. */
  25418. getParam(paramName: string): any;
  25419. /**
  25420. * Sets a specific parameter in the options given to the physics plugin
  25421. */
  25422. setParam(paramName: string, value: number): void;
  25423. /**
  25424. * Specifically change the body's mass option. Won't recreate the physics body object
  25425. */
  25426. setMass(mass: number): void;
  25427. getLinearVelocity(): Nullable<Vector3>;
  25428. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25429. getAngularVelocity(): Nullable<Vector3>;
  25430. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25431. /**
  25432. * Execute a function with the physics plugin native code.
  25433. * Provide a function the will have two variables - the world object and the physics body object.
  25434. */
  25435. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25436. /**
  25437. * Register a function that will be executed before the physics world is stepping forward.
  25438. */
  25439. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25440. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25441. /**
  25442. * Register a function that will be executed after the physics step
  25443. */
  25444. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25445. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25446. /**
  25447. * register a function that will be executed when this impostor collides against a different body.
  25448. */
  25449. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25450. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25451. private _tmpQuat;
  25452. private _tmpQuat2;
  25453. getParentsRotation(): Quaternion;
  25454. /**
  25455. * this function is executed by the physics engine.
  25456. */
  25457. beforeStep: () => void;
  25458. /**
  25459. * this function is executed by the physics engine.
  25460. */
  25461. afterStep: () => void;
  25462. /**
  25463. * Legacy collision detection event support
  25464. */
  25465. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25466. onCollide: (e: {
  25467. body: any;
  25468. }) => void;
  25469. /**
  25470. * Apply a force
  25471. */
  25472. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25473. /**
  25474. * Apply an impulse
  25475. */
  25476. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25477. /**
  25478. * A help function to create a joint.
  25479. */
  25480. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25481. /**
  25482. * Add a joint to this impostor with a different impostor.
  25483. */
  25484. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25485. /**
  25486. * Will keep this body still, in a sleep mode.
  25487. */
  25488. sleep(): PhysicsImpostor;
  25489. /**
  25490. * Wake the body up.
  25491. */
  25492. wakeUp(): PhysicsImpostor;
  25493. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25494. dispose(): void;
  25495. setDeltaPosition(position: Vector3): void;
  25496. setDeltaRotation(rotation: Quaternion): void;
  25497. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25498. getRadius(): number;
  25499. /**
  25500. * Sync a bone with this impostor
  25501. * @param bone The bone to sync to the impostor.
  25502. * @param boneMesh The mesh that the bone is influencing.
  25503. * @param jointPivot The pivot of the joint / bone in local space.
  25504. * @param distToJoint Optional distance from the impostor to the joint.
  25505. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25506. */
  25507. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25508. /**
  25509. * Sync impostor to a bone
  25510. * @param bone The bone that the impostor will be synced to.
  25511. * @param boneMesh The mesh that the bone is influencing.
  25512. * @param jointPivot The pivot of the joint / bone in local space.
  25513. * @param distToJoint Optional distance from the impostor to the joint.
  25514. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25515. * @param boneAxis Optional vector3 axis the bone is aligned with
  25516. */
  25517. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25518. static NoImpostor: number;
  25519. static SphereImpostor: number;
  25520. static BoxImpostor: number;
  25521. static PlaneImpostor: number;
  25522. static MeshImpostor: number;
  25523. static CylinderImpostor: number;
  25524. static ParticleImpostor: number;
  25525. static HeightmapImpostor: number;
  25526. }
  25527. }
  25528. declare module BABYLON {
  25529. interface PhysicsJointData {
  25530. mainPivot?: Vector3;
  25531. connectedPivot?: Vector3;
  25532. mainAxis?: Vector3;
  25533. connectedAxis?: Vector3;
  25534. collision?: boolean;
  25535. nativeParams?: any;
  25536. }
  25537. /**
  25538. * This is a holder class for the physics joint created by the physics plugin.
  25539. * It holds a set of functions to control the underlying joint.
  25540. */
  25541. class PhysicsJoint {
  25542. type: number;
  25543. jointData: PhysicsJointData;
  25544. private _physicsJoint;
  25545. protected _physicsPlugin: IPhysicsEnginePlugin;
  25546. constructor(type: number, jointData: PhysicsJointData);
  25547. physicsJoint: any;
  25548. physicsPlugin: IPhysicsEnginePlugin;
  25549. /**
  25550. * Execute a function that is physics-plugin specific.
  25551. * @param {Function} func the function that will be executed.
  25552. * It accepts two parameters: the physics world and the physics joint.
  25553. */
  25554. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25555. static DistanceJoint: number;
  25556. static HingeJoint: number;
  25557. static BallAndSocketJoint: number;
  25558. static WheelJoint: number;
  25559. static SliderJoint: number;
  25560. static PrismaticJoint: number;
  25561. static UniversalJoint: number;
  25562. static Hinge2Joint: number;
  25563. static PointToPointJoint: number;
  25564. static SpringJoint: number;
  25565. static LockJoint: number;
  25566. }
  25567. /**
  25568. * A class representing a physics distance joint.
  25569. */
  25570. class DistanceJoint extends PhysicsJoint {
  25571. constructor(jointData: DistanceJointData);
  25572. /**
  25573. * Update the predefined distance.
  25574. */
  25575. updateDistance(maxDistance: number, minDistance?: number): void;
  25576. }
  25577. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25578. constructor(type: number, jointData: PhysicsJointData);
  25579. /**
  25580. * Set the motor values.
  25581. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25582. * @param {number} force the force to apply
  25583. * @param {number} maxForce max force for this motor.
  25584. */
  25585. setMotor(force?: number, maxForce?: number): void;
  25586. /**
  25587. * Set the motor's limits.
  25588. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25589. */
  25590. setLimit(upperLimit: number, lowerLimit?: number): void;
  25591. }
  25592. /**
  25593. * This class represents a single hinge physics joint
  25594. */
  25595. class HingeJoint extends MotorEnabledJoint {
  25596. constructor(jointData: PhysicsJointData);
  25597. /**
  25598. * Set the motor values.
  25599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25600. * @param {number} force the force to apply
  25601. * @param {number} maxForce max force for this motor.
  25602. */
  25603. setMotor(force?: number, maxForce?: number): void;
  25604. /**
  25605. * Set the motor's limits.
  25606. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25607. */
  25608. setLimit(upperLimit: number, lowerLimit?: number): void;
  25609. }
  25610. /**
  25611. * This class represents a dual hinge physics joint (same as wheel joint)
  25612. */
  25613. class Hinge2Joint extends MotorEnabledJoint {
  25614. constructor(jointData: PhysicsJointData);
  25615. /**
  25616. * Set the motor values.
  25617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25618. * @param {number} force the force to apply
  25619. * @param {number} maxForce max force for this motor.
  25620. * @param {motorIndex} the motor's index, 0 or 1.
  25621. */
  25622. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25623. /**
  25624. * Set the motor limits.
  25625. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25626. * @param {number} upperLimit the upper limit
  25627. * @param {number} lowerLimit lower limit
  25628. * @param {motorIndex} the motor's index, 0 or 1.
  25629. */
  25630. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25631. }
  25632. interface IMotorEnabledJoint {
  25633. physicsJoint: any;
  25634. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25635. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25636. }
  25637. interface DistanceJointData extends PhysicsJointData {
  25638. maxDistance: number;
  25639. }
  25640. interface SpringJointData extends PhysicsJointData {
  25641. length: number;
  25642. stiffness: number;
  25643. damping: number;
  25644. }
  25645. }
  25646. declare module BABYLON {
  25647. class ReflectionProbe {
  25648. name: string;
  25649. private _scene;
  25650. private _renderTargetTexture;
  25651. private _projectionMatrix;
  25652. private _viewMatrix;
  25653. private _target;
  25654. private _add;
  25655. private _attachedMesh;
  25656. private _invertYAxis;
  25657. position: Vector3;
  25658. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25659. samples: number;
  25660. refreshRate: number;
  25661. getScene(): Scene;
  25662. readonly cubeTexture: RenderTargetTexture;
  25663. readonly renderList: Nullable<AbstractMesh[]>;
  25664. attachToMesh(mesh: AbstractMesh): void;
  25665. /**
  25666. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25667. *
  25668. * @param renderingGroupId The rendering group id corresponding to its index
  25669. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25670. */
  25671. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25672. dispose(): void;
  25673. }
  25674. }
  25675. declare module BABYLON {
  25676. class BoundingBoxRenderer {
  25677. frontColor: Color3;
  25678. backColor: Color3;
  25679. showBackLines: boolean;
  25680. renderList: SmartArray<BoundingBox>;
  25681. private _scene;
  25682. private _colorShader;
  25683. private _vertexBuffers;
  25684. private _indexBuffer;
  25685. constructor(scene: Scene);
  25686. private _prepareRessources();
  25687. private _createIndexBuffer();
  25688. _rebuild(): void;
  25689. reset(): void;
  25690. render(): void;
  25691. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  25692. dispose(): void;
  25693. }
  25694. }
  25695. declare module BABYLON {
  25696. /**
  25697. * This represents a depth renderer in Babylon.
  25698. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  25699. */
  25700. class DepthRenderer {
  25701. private _scene;
  25702. private _depthMap;
  25703. private _effect;
  25704. private _cachedDefines;
  25705. private _camera;
  25706. /**
  25707. * Instantiates a depth renderer
  25708. * @param scene The scene the renderer belongs to
  25709. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  25710. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  25711. */
  25712. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  25713. /**
  25714. * Creates the depth rendering effect and checks if the effect is ready.
  25715. * @param subMesh The submesh to be used to render the depth map of
  25716. * @param useInstances If multiple world instances should be used
  25717. * @returns if the depth renderer is ready to render the depth map
  25718. */
  25719. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25720. /**
  25721. * Gets the texture which the depth map will be written to.
  25722. * @returns The depth map texture
  25723. */
  25724. getDepthMap(): RenderTargetTexture;
  25725. /**
  25726. * Disposes of the depth renderer.
  25727. */
  25728. dispose(): void;
  25729. }
  25730. }
  25731. declare module BABYLON {
  25732. class EdgesRenderer {
  25733. edgesWidthScalerForOrthographic: number;
  25734. edgesWidthScalerForPerspective: number;
  25735. private _source;
  25736. private _linesPositions;
  25737. private _linesNormals;
  25738. private _linesIndices;
  25739. private _epsilon;
  25740. private _indicesCount;
  25741. private _lineShader;
  25742. private _ib;
  25743. private _buffers;
  25744. private _checkVerticesInsteadOfIndices;
  25745. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  25746. isEnabled: boolean;
  25747. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  25748. private _prepareRessources();
  25749. _rebuild(): void;
  25750. dispose(): void;
  25751. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  25752. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  25753. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  25754. _generateEdgesLines(): void;
  25755. render(): void;
  25756. }
  25757. }
  25758. declare module BABYLON {
  25759. /**
  25760. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  25761. */
  25762. class GeometryBufferRenderer {
  25763. private _scene;
  25764. private _multiRenderTarget;
  25765. private _ratio;
  25766. private _enablePosition;
  25767. protected _effect: Effect;
  25768. protected _cachedDefines: string;
  25769. /**
  25770. * Set the render list (meshes to be rendered) used in the G buffer.
  25771. */
  25772. renderList: Mesh[];
  25773. /**
  25774. * Gets wether or not G buffer are supported by the running hardware.
  25775. * This requires draw buffer supports
  25776. */
  25777. readonly isSupported: boolean;
  25778. /**
  25779. * Gets wether or not position are enabled for the G buffer.
  25780. */
  25781. /**
  25782. * Sets wether or not position are enabled for the G buffer.
  25783. */
  25784. enablePosition: boolean;
  25785. /**
  25786. * Gets the scene associated with the buffer.
  25787. */
  25788. readonly scene: Scene;
  25789. /**
  25790. * Gets the ratio used by the buffer during its creation.
  25791. * How big is the buffer related to the main canvas.
  25792. */
  25793. readonly ratio: number;
  25794. /**
  25795. * Creates a new G Buffer for the scene
  25796. * @param scene The scene the buffer belongs to
  25797. * @param ratio How big is the buffer related to the main canvas.
  25798. */
  25799. constructor(scene: Scene, ratio?: number);
  25800. /**
  25801. * Checks wether everything is ready to render a submesh to the G buffer.
  25802. * @param subMesh the submesh to check readiness for
  25803. * @param useInstances is the mesh drawn using instance or not
  25804. * @returns true if ready otherwise false
  25805. */
  25806. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25807. /**
  25808. * Gets the current underlying G Buffer.
  25809. * @returns the buffer
  25810. */
  25811. getGBuffer(): MultiRenderTarget;
  25812. /**
  25813. * Gets the number of samples used to render the buffer (anti aliasing).
  25814. */
  25815. /**
  25816. * Sets the number of samples used to render the buffer (anti aliasing).
  25817. */
  25818. samples: number;
  25819. /**
  25820. * Disposes the renderer and frees up associated resources.
  25821. */
  25822. dispose(): void;
  25823. protected _createRenderTargets(): void;
  25824. }
  25825. }
  25826. declare module BABYLON {
  25827. class OutlineRenderer {
  25828. private _scene;
  25829. private _effect;
  25830. private _cachedDefines;
  25831. zOffset: number;
  25832. constructor(scene: Scene);
  25833. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  25834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25835. }
  25836. }
  25837. declare module BABYLON {
  25838. class RenderingGroup {
  25839. index: number;
  25840. private _scene;
  25841. private _opaqueSubMeshes;
  25842. private _transparentSubMeshes;
  25843. private _alphaTestSubMeshes;
  25844. private _depthOnlySubMeshes;
  25845. private _particleSystems;
  25846. private _spriteManagers;
  25847. private _opaqueSortCompareFn;
  25848. private _alphaTestSortCompareFn;
  25849. private _transparentSortCompareFn;
  25850. private _renderOpaque;
  25851. private _renderAlphaTest;
  25852. private _renderTransparent;
  25853. private _edgesRenderers;
  25854. onBeforeTransparentRendering: () => void;
  25855. /**
  25856. * Set the opaque sort comparison function.
  25857. * If null the sub meshes will be render in the order they were created
  25858. */
  25859. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25860. /**
  25861. * Set the alpha test sort comparison function.
  25862. * If null the sub meshes will be render in the order they were created
  25863. */
  25864. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25865. /**
  25866. * Set the transparent sort comparison function.
  25867. * If null the sub meshes will be render in the order they were created
  25868. */
  25869. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25870. /**
  25871. * Creates a new rendering group.
  25872. * @param index The rendering group index
  25873. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25874. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25875. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25876. */
  25877. 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>);
  25878. /**
  25879. * Render all the sub meshes contained in the group.
  25880. * @param customRenderFunction Used to override the default render behaviour of the group.
  25881. * @returns true if rendered some submeshes.
  25882. */
  25883. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25884. /**
  25885. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25886. * @param subMeshes The submeshes to render
  25887. */
  25888. private renderOpaqueSorted(subMeshes);
  25889. /**
  25890. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25891. * @param subMeshes The submeshes to render
  25892. */
  25893. private renderAlphaTestSorted(subMeshes);
  25894. /**
  25895. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25896. * @param subMeshes The submeshes to render
  25897. */
  25898. private renderTransparentSorted(subMeshes);
  25899. /**
  25900. * Renders the submeshes in a specified order.
  25901. * @param subMeshes The submeshes to sort before render
  25902. * @param sortCompareFn The comparison function use to sort
  25903. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25904. * @param transparent Specifies to activate blending if true
  25905. */
  25906. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25907. /**
  25908. * Renders the submeshes in the order they were dispatched (no sort applied).
  25909. * @param subMeshes The submeshes to render
  25910. */
  25911. private static renderUnsorted(subMeshes);
  25912. /**
  25913. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25914. * are rendered back to front if in the same alpha index.
  25915. *
  25916. * @param a The first submesh
  25917. * @param b The second submesh
  25918. * @returns The result of the comparison
  25919. */
  25920. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25921. /**
  25922. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25923. * are rendered back to front.
  25924. *
  25925. * @param a The first submesh
  25926. * @param b The second submesh
  25927. * @returns The result of the comparison
  25928. */
  25929. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25930. /**
  25931. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25932. * are rendered front to back (prevent overdraw).
  25933. *
  25934. * @param a The first submesh
  25935. * @param b The second submesh
  25936. * @returns The result of the comparison
  25937. */
  25938. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25939. /**
  25940. * Resets the different lists of submeshes to prepare a new frame.
  25941. */
  25942. prepare(): void;
  25943. dispose(): void;
  25944. /**
  25945. * Inserts the submesh in its correct queue depending on its material.
  25946. * @param subMesh The submesh to dispatch
  25947. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25948. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25949. */
  25950. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25951. dispatchSprites(spriteManager: SpriteManager): void;
  25952. dispatchParticles(particleSystem: IParticleSystem): void;
  25953. private _renderParticles(activeMeshes);
  25954. private _renderSprites();
  25955. }
  25956. }
  25957. declare module BABYLON {
  25958. class RenderingManager {
  25959. /**
  25960. * The max id used for rendering groups (not included)
  25961. */
  25962. static MAX_RENDERINGGROUPS: number;
  25963. /**
  25964. * The min id used for rendering groups (included)
  25965. */
  25966. static MIN_RENDERINGGROUPS: number;
  25967. /**
  25968. * Used to globally prevent autoclearing scenes.
  25969. */
  25970. static AUTOCLEAR: boolean;
  25971. private _scene;
  25972. private _renderingGroups;
  25973. private _depthStencilBufferAlreadyCleaned;
  25974. private _autoClearDepthStencil;
  25975. private _customOpaqueSortCompareFn;
  25976. private _customAlphaTestSortCompareFn;
  25977. private _customTransparentSortCompareFn;
  25978. private _renderinGroupInfo;
  25979. constructor(scene: Scene);
  25980. private _clearDepthStencilBuffer(depth?, stencil?);
  25981. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25982. reset(): void;
  25983. dispose(): void;
  25984. /**
  25985. * Clear the info related to rendering groups preventing retention points during dispose.
  25986. */
  25987. freeRenderingGroups(): void;
  25988. private _prepareRenderingGroup(renderingGroupId);
  25989. dispatchSprites(spriteManager: SpriteManager): void;
  25990. dispatchParticles(particleSystem: IParticleSystem): void;
  25991. /**
  25992. * @param subMesh The submesh to dispatch
  25993. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25994. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25995. */
  25996. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25997. /**
  25998. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25999. * This allowed control for front to back rendering or reversly depending of the special needs.
  26000. *
  26001. * @param renderingGroupId The rendering group id corresponding to its index
  26002. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26003. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26004. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26005. */
  26006. 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;
  26007. /**
  26008. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26009. *
  26010. * @param renderingGroupId The rendering group id corresponding to its index
  26011. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26012. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26013. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26014. */
  26015. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26016. }
  26017. }
  26018. declare module BABYLON {
  26019. /**
  26020. * Renders a layer on top of an existing scene
  26021. */
  26022. class UtilityLayerRenderer implements IDisposable {
  26023. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26024. private _pointerCaptures;
  26025. private _lastPointerEvents;
  26026. /**
  26027. * The scene that is rendered on top of the original scene
  26028. */
  26029. utilityLayerScene: Scene;
  26030. /**
  26031. * If the utility layer should automatically be rendered on top of existing scene
  26032. */
  26033. shouldRender: boolean;
  26034. /**
  26035. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  26036. */
  26037. onlyCheckPointerDownEvents: boolean;
  26038. /**
  26039. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  26040. */
  26041. processAllEvents: boolean;
  26042. /**
  26043. * Observable raised when the pointer move from the utility layer scene to the main scene
  26044. */
  26045. onPointerOutObservable: Observable<number>;
  26046. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  26047. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  26048. private _afterRenderObserver;
  26049. private _sceneDisposeObserver;
  26050. private _originalPointerObserver;
  26051. /**
  26052. * Instantiates a UtilityLayerRenderer
  26053. * @param originalScene the original scene that will be rendered on top of
  26054. */
  26055. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26056. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  26057. /**
  26058. * Renders the utility layers scene on top of the original scene
  26059. */
  26060. render(): void;
  26061. /**
  26062. * Disposes of the renderer
  26063. */
  26064. dispose(): void;
  26065. private _updateCamera();
  26066. }
  26067. }
  26068. declare module BABYLON {
  26069. class Sprite {
  26070. name: string;
  26071. position: Vector3;
  26072. color: Color4;
  26073. width: number;
  26074. height: number;
  26075. angle: number;
  26076. cellIndex: number;
  26077. invertU: number;
  26078. invertV: number;
  26079. disposeWhenFinishedAnimating: boolean;
  26080. animations: Animation[];
  26081. isPickable: boolean;
  26082. actionManager: ActionManager;
  26083. private _animationStarted;
  26084. private _loopAnimation;
  26085. private _fromIndex;
  26086. private _toIndex;
  26087. private _delay;
  26088. private _direction;
  26089. private _manager;
  26090. private _time;
  26091. private _onAnimationEnd;
  26092. /**
  26093. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  26094. */
  26095. isVisible: boolean;
  26096. size: number;
  26097. constructor(name: string, manager: SpriteManager);
  26098. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26099. stopAnimation(): void;
  26100. _animate(deltaTime: number): void;
  26101. dispose(): void;
  26102. }
  26103. }
  26104. declare module BABYLON {
  26105. class SpriteManager {
  26106. name: string;
  26107. sprites: Sprite[];
  26108. renderingGroupId: number;
  26109. layerMask: number;
  26110. fogEnabled: boolean;
  26111. isPickable: boolean;
  26112. cellWidth: number;
  26113. cellHeight: number;
  26114. /**
  26115. * An event triggered when the manager is disposed.
  26116. */
  26117. onDisposeObservable: Observable<SpriteManager>;
  26118. private _onDisposeObserver;
  26119. onDispose: () => void;
  26120. private _capacity;
  26121. private _spriteTexture;
  26122. private _epsilon;
  26123. private _scene;
  26124. private _vertexData;
  26125. private _buffer;
  26126. private _vertexBuffers;
  26127. private _indexBuffer;
  26128. private _effectBase;
  26129. private _effectFog;
  26130. texture: Texture;
  26131. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26132. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26133. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26134. render(): void;
  26135. dispose(): void;
  26136. }
  26137. }
  26138. declare module BABYLON {
  26139. /**
  26140. * Postprocess used to generate anaglyphic rendering
  26141. */
  26142. class AnaglyphPostProcess extends PostProcess {
  26143. private _passedProcess;
  26144. /**
  26145. * Creates a new AnaglyphPostProcess
  26146. * @param name defines postprocess name
  26147. * @param options defines creation options or target ratio scale
  26148. * @param rigCameras defines cameras using this postprocess
  26149. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26150. * @param engine defines hosting engine
  26151. * @param reusable defines if the postprocess will be reused multiple times per frame
  26152. */
  26153. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26154. }
  26155. }
  26156. declare module BABYLON {
  26157. class BlackAndWhitePostProcess extends PostProcess {
  26158. degree: number;
  26159. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26160. }
  26161. }
  26162. declare module BABYLON {
  26163. /**
  26164. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26165. */
  26166. class BloomEffect extends PostProcessRenderEffect {
  26167. private bloomScale;
  26168. /**
  26169. * Internal
  26170. */
  26171. _effects: Array<PostProcess>;
  26172. /**
  26173. * Internal
  26174. */
  26175. _downscale: ExtractHighlightsPostProcess;
  26176. private _blurX;
  26177. private _blurY;
  26178. private _merge;
  26179. /**
  26180. * The luminance threshold to find bright areas of the image to bloom.
  26181. */
  26182. threshold: number;
  26183. /**
  26184. * The strength of the bloom.
  26185. */
  26186. weight: number;
  26187. /**
  26188. * Specifies the size of the bloom blur kernel, relative to the final output size
  26189. */
  26190. kernel: number;
  26191. /**
  26192. * Creates a new instance of @see BloomEffect
  26193. * @param scene The scene the effect belongs to.
  26194. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26195. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26196. * @param bloomWeight The the strength of bloom.
  26197. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26198. * @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)
  26199. */
  26200. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26201. /**
  26202. * Disposes each of the internal effects for a given camera.
  26203. * @param camera The camera to dispose the effect on.
  26204. */
  26205. disposeEffects(camera: Camera): void;
  26206. /**
  26207. * Internal
  26208. */
  26209. _updateEffects(): void;
  26210. /**
  26211. * Internal
  26212. * @returns if all the contained post processes are ready.
  26213. */
  26214. _isReady(): boolean;
  26215. }
  26216. }
  26217. declare module BABYLON {
  26218. /**
  26219. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26220. */
  26221. class BloomMergePostProcess extends PostProcess {
  26222. /** Weight of the bloom to be added to the original input. */ weight: number;
  26223. /**
  26224. * Creates a new instance of @see BloomMergePostProcess
  26225. * @param name The name of the effect.
  26226. * @param originalFromInput Post process which's input will be used for the merge.
  26227. * @param blurred Blurred highlights post process which's output will be used.
  26228. * @param weight Weight of the bloom to be added to the original input.
  26229. * @param options The required width/height ratio to downsize to before computing the render pass.
  26230. * @param camera The camera to apply the render pass to.
  26231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26232. * @param engine The engine which the post process will be applied. (default: current engine)
  26233. * @param reusable If the post process can be reused on the same frame. (default: false)
  26234. * @param textureType Type of textures used when performing the post process. (default: 0)
  26235. * @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)
  26236. */
  26237. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26238. }
  26239. }
  26240. declare module BABYLON {
  26241. /**
  26242. * The Blur Post Process which blurs an image based on a kernel and direction.
  26243. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26244. */
  26245. class BlurPostProcess extends PostProcess {
  26246. /** The direction in which to blur the image. */ direction: Vector2;
  26247. private blockCompilation;
  26248. protected _kernel: number;
  26249. protected _idealKernel: number;
  26250. protected _packedFloat: boolean;
  26251. private _staticDefines;
  26252. /**
  26253. * Gets the length in pixels of the blur sample region
  26254. */
  26255. /**
  26256. * Sets the length in pixels of the blur sample region
  26257. */
  26258. kernel: number;
  26259. /**
  26260. * Gets wether or not the blur is unpacking/repacking floats
  26261. */
  26262. /**
  26263. * Sets wether or not the blur needs to unpack/repack floats
  26264. */
  26265. packedFloat: boolean;
  26266. /**
  26267. * Creates a new instance BlurPostProcess
  26268. * @param name The name of the effect.
  26269. * @param direction The direction in which to blur the image.
  26270. * @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.
  26271. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26272. * @param camera The camera to apply the render pass to.
  26273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26274. * @param engine The engine which the post process will be applied. (default: current engine)
  26275. * @param reusable If the post process can be reused on the same frame. (default: false)
  26276. * @param textureType Type of textures used when performing the post process. (default: 0)
  26277. * @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)
  26278. */
  26279. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  26280. /**
  26281. * Updates the effect with the current post process compile time values and recompiles the shader.
  26282. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26283. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26284. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26285. * @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
  26286. * @param onCompiled Called when the shader has been compiled.
  26287. * @param onError Called if there is an error when compiling a shader.
  26288. */
  26289. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26290. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26291. /**
  26292. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  26293. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  26294. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  26295. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  26296. * The gaps between physical kernels are compensated for in the weighting of the samples
  26297. * @param idealKernel Ideal blur kernel.
  26298. * @return Nearest best kernel.
  26299. */
  26300. protected _nearestBestKernel(idealKernel: number): number;
  26301. /**
  26302. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  26303. * @param x The point on the Gaussian distribution to sample.
  26304. * @return the value of the Gaussian function at x.
  26305. */
  26306. protected _gaussianWeight(x: number): number;
  26307. /**
  26308. * Generates a string that can be used as a floating point number in GLSL.
  26309. * @param x Value to print.
  26310. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  26311. * @return GLSL float string.
  26312. */
  26313. protected _glslFloat(x: number, decimalFigures?: number): string;
  26314. }
  26315. }
  26316. declare module BABYLON {
  26317. /**
  26318. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  26319. */
  26320. class ChromaticAberrationPostProcess extends PostProcess {
  26321. /**
  26322. * The amount of seperation of rgb channels (default: 30)
  26323. */
  26324. aberrationAmount: number;
  26325. /**
  26326. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  26327. */
  26328. radialIntensity: number;
  26329. /**
  26330. * 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))
  26331. */
  26332. direction: Vector2;
  26333. /**
  26334. * 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))
  26335. */
  26336. centerPosition: Vector2;
  26337. /**
  26338. * Creates a new instance ChromaticAberrationPostProcess
  26339. * @param name The name of the effect.
  26340. * @param screenWidth The width of the screen to apply the effect on.
  26341. * @param screenHeight The height of the screen to apply the effect on.
  26342. * @param options The required width/height ratio to downsize to before computing the render pass.
  26343. * @param camera The camera to apply the render pass to.
  26344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26345. * @param engine The engine which the post process will be applied. (default: current engine)
  26346. * @param reusable If the post process can be reused on the same frame. (default: false)
  26347. * @param textureType Type of textures used when performing the post process. (default: 0)
  26348. * @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)
  26349. */
  26350. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26351. }
  26352. }
  26353. declare module BABYLON {
  26354. /**
  26355. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  26356. */
  26357. class CircleOfConfusionPostProcess extends PostProcess {
  26358. /**
  26359. * 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.
  26360. */
  26361. lensSize: number;
  26362. /**
  26363. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26364. */
  26365. fStop: number;
  26366. /**
  26367. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26368. */
  26369. focusDistance: number;
  26370. /**
  26371. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  26372. */
  26373. focalLength: number;
  26374. private _depthTexture;
  26375. /**
  26376. * Creates a new instance CircleOfConfusionPostProcess
  26377. * @param name The name of the effect.
  26378. * @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.
  26379. * @param options The required width/height ratio to downsize to before computing the render pass.
  26380. * @param camera The camera to apply the render pass to.
  26381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26382. * @param engine The engine which the post process will be applied. (default: current engine)
  26383. * @param reusable If the post process can be reused on the same frame. (default: false)
  26384. * @param textureType Type of textures used when performing the post process. (default: 0)
  26385. * @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)
  26386. */
  26387. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26388. /**
  26389. * 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.
  26390. */
  26391. depthTexture: RenderTargetTexture;
  26392. }
  26393. }
  26394. declare module BABYLON {
  26395. class ColorCorrectionPostProcess extends PostProcess {
  26396. private _colorTableTexture;
  26397. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26398. }
  26399. }
  26400. declare module BABYLON {
  26401. /**
  26402. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  26403. * input texture to perform effects such as edge detection or sharpening
  26404. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26405. */
  26406. class ConvolutionPostProcess extends PostProcess {
  26407. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  26408. /**
  26409. * Creates a new instance ConvolutionPostProcess
  26410. * @param name The name of the effect.
  26411. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  26412. * @param options The required width/height ratio to downsize to before computing the render pass.
  26413. * @param camera The camera to apply the render pass to.
  26414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26415. * @param engine The engine which the post process will be applied. (default: current engine)
  26416. * @param reusable If the post process can be reused on the same frame. (default: false)
  26417. * @param textureType Type of textures used when performing the post process. (default: 0)
  26418. */
  26419. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26420. /**
  26421. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26422. */
  26423. static EdgeDetect0Kernel: number[];
  26424. /**
  26425. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26426. */
  26427. static EdgeDetect1Kernel: number[];
  26428. /**
  26429. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26430. */
  26431. static EdgeDetect2Kernel: number[];
  26432. /**
  26433. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26434. */
  26435. static SharpenKernel: number[];
  26436. /**
  26437. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26438. */
  26439. static EmbossKernel: number[];
  26440. /**
  26441. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26442. */
  26443. static GaussianKernel: number[];
  26444. }
  26445. }
  26446. declare module BABYLON {
  26447. /**
  26448. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  26449. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  26450. * based on samples that have a large difference in distance than the center pixel.
  26451. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  26452. */
  26453. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  26454. direction: Vector2;
  26455. /**
  26456. * Creates a new instance CircleOfConfusionPostProcess
  26457. * @param name The name of the effect.
  26458. * @param scene The scene the effect belongs to.
  26459. * @param direction The direction the blur should be applied.
  26460. * @param kernel The size of the kernel used to blur.
  26461. * @param options The required width/height ratio to downsize to before computing the render pass.
  26462. * @param camera The camera to apply the render pass to.
  26463. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  26464. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  26465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26466. * @param engine The engine which the post process will be applied. (default: current engine)
  26467. * @param reusable If the post process can be reused on the same frame. (default: false)
  26468. * @param textureType Type of textures used when performing the post process. (default: 0)
  26469. * @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)
  26470. */
  26471. 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);
  26472. }
  26473. }
  26474. declare module BABYLON {
  26475. /**
  26476. * Specifies the level of max blur that should be applied when using the depth of field effect
  26477. */
  26478. enum DepthOfFieldEffectBlurLevel {
  26479. /**
  26480. * Subtle blur
  26481. */
  26482. Low = 0,
  26483. /**
  26484. * Medium blur
  26485. */
  26486. Medium = 1,
  26487. /**
  26488. * Large blur
  26489. */
  26490. High = 2,
  26491. }
  26492. /**
  26493. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  26494. */
  26495. class DepthOfFieldEffect extends PostProcessRenderEffect {
  26496. private _circleOfConfusion;
  26497. /**
  26498. * Internal, blurs from high to low
  26499. */
  26500. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  26501. private _depthOfFieldBlurY;
  26502. private _dofMerge;
  26503. /**
  26504. * Internal post processes in depth of field effect
  26505. */
  26506. _effects: Array<PostProcess>;
  26507. /**
  26508. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  26509. */
  26510. focalLength: number;
  26511. /**
  26512. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26513. */
  26514. fStop: number;
  26515. /**
  26516. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26517. */
  26518. focusDistance: number;
  26519. /**
  26520. * 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.
  26521. */
  26522. lensSize: number;
  26523. /**
  26524. * Creates a new instance DepthOfFieldEffect
  26525. * @param scene The scene the effect belongs to.
  26526. * @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.
  26527. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26528. * @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)
  26529. */
  26530. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  26531. /**
  26532. * 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.
  26533. */
  26534. depthTexture: RenderTargetTexture;
  26535. /**
  26536. * Disposes each of the internal effects for a given camera.
  26537. * @param camera The camera to dispose the effect on.
  26538. */
  26539. disposeEffects(camera: Camera): void;
  26540. /**
  26541. * Internal
  26542. */
  26543. _updateEffects(): void;
  26544. /**
  26545. * Internal
  26546. * @returns if all the contained post processes are ready.
  26547. */
  26548. _isReady(): boolean;
  26549. }
  26550. }
  26551. declare module BABYLON {
  26552. /**
  26553. * Options to be set when merging outputs from the default pipeline.
  26554. */
  26555. class DepthOfFieldMergePostProcessOptions {
  26556. /**
  26557. * The original image to merge on top of
  26558. */
  26559. originalFromInput: PostProcess;
  26560. /**
  26561. * Parameters to perform the merge of the depth of field effect
  26562. */
  26563. depthOfField?: {
  26564. circleOfConfusion: PostProcess;
  26565. blurSteps: Array<PostProcess>;
  26566. };
  26567. /**
  26568. * Parameters to perform the merge of bloom effect
  26569. */
  26570. bloom?: {
  26571. blurred: PostProcess;
  26572. weight: number;
  26573. };
  26574. }
  26575. /**
  26576. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26577. */
  26578. class DepthOfFieldMergePostProcess extends PostProcess {
  26579. private blurSteps;
  26580. /**
  26581. * Creates a new instance of DepthOfFieldMergePostProcess
  26582. * @param name The name of the effect.
  26583. * @param originalFromInput Post process which's input will be used for the merge.
  26584. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  26585. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  26586. * @param options The required width/height ratio to downsize to before computing the render pass.
  26587. * @param camera The camera to apply the render pass to.
  26588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26589. * @param engine The engine which the post process will be applied. (default: current engine)
  26590. * @param reusable If the post process can be reused on the same frame. (default: false)
  26591. * @param textureType Type of textures used when performing the post process. (default: 0)
  26592. * @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)
  26593. */
  26594. 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);
  26595. /**
  26596. * Updates the effect with the current post process compile time values and recompiles the shader.
  26597. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26598. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26599. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26600. * @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
  26601. * @param onCompiled Called when the shader has been compiled.
  26602. * @param onError Called if there is an error when compiling a shader.
  26603. */
  26604. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26605. }
  26606. }
  26607. declare module BABYLON {
  26608. class DisplayPassPostProcess extends PostProcess {
  26609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26610. }
  26611. }
  26612. declare module BABYLON {
  26613. /**
  26614. * 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.
  26615. */
  26616. class ExtractHighlightsPostProcess extends PostProcess {
  26617. /**
  26618. * The luminance threshold, pixels below this value will be set to black.
  26619. */
  26620. threshold: number;
  26621. /**
  26622. * Internal
  26623. */
  26624. _exposure: number;
  26625. /**
  26626. * Post process which has the input texture to be used when performing highlight extraction
  26627. */
  26628. _inputPostProcess: Nullable<PostProcess>;
  26629. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26630. }
  26631. }
  26632. declare module BABYLON {
  26633. class FilterPostProcess extends PostProcess {
  26634. kernelMatrix: Matrix;
  26635. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26636. }
  26637. }
  26638. declare module BABYLON {
  26639. class FxaaPostProcess extends PostProcess {
  26640. texelWidth: number;
  26641. texelHeight: number;
  26642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26643. private _getDefines();
  26644. }
  26645. }
  26646. declare module BABYLON {
  26647. /**
  26648. * The GrainPostProcess adds noise to the image at mid luminance levels
  26649. */
  26650. class GrainPostProcess extends PostProcess {
  26651. /**
  26652. * The intensity of the grain added (default: 30)
  26653. */
  26654. intensity: number;
  26655. /**
  26656. * If the grain should be randomized on every frame
  26657. */
  26658. animated: boolean;
  26659. /**
  26660. * Creates a new instance of @see GrainPostProcess
  26661. * @param name The name of the effect.
  26662. * @param options The required width/height ratio to downsize to before computing the render pass.
  26663. * @param camera The camera to apply the render pass to.
  26664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26665. * @param engine The engine which the post process will be applied. (default: current engine)
  26666. * @param reusable If the post process can be reused on the same frame. (default: false)
  26667. * @param textureType Type of textures used when performing the post process. (default: 0)
  26668. * @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)
  26669. */
  26670. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26671. }
  26672. }
  26673. declare module BABYLON {
  26674. class HighlightsPostProcess extends PostProcess {
  26675. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26676. }
  26677. }
  26678. declare module BABYLON {
  26679. class ImageProcessingPostProcess extends PostProcess {
  26680. /**
  26681. * Default configuration related to image processing available in the PBR Material.
  26682. */
  26683. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26684. /**
  26685. * Gets the image processing configuration used either in this material.
  26686. */
  26687. /**
  26688. * Sets the Default image processing configuration used either in the this material.
  26689. *
  26690. * If sets to null, the scene one is in use.
  26691. */
  26692. imageProcessingConfiguration: ImageProcessingConfiguration;
  26693. /**
  26694. * Keep track of the image processing observer to allow dispose and replace.
  26695. */
  26696. private _imageProcessingObserver;
  26697. /**
  26698. * Attaches a new image processing configuration to the PBR Material.
  26699. * @param configuration
  26700. */
  26701. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  26702. /**
  26703. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26704. */
  26705. /**
  26706. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26707. */
  26708. colorCurves: Nullable<ColorCurves>;
  26709. /**
  26710. * Gets wether the color curves effect is enabled.
  26711. */
  26712. /**
  26713. * Sets wether the color curves effect is enabled.
  26714. */
  26715. colorCurvesEnabled: boolean;
  26716. /**
  26717. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26718. */
  26719. /**
  26720. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26721. */
  26722. colorGradingTexture: Nullable<BaseTexture>;
  26723. /**
  26724. * Gets wether the color grading effect is enabled.
  26725. */
  26726. /**
  26727. * Gets wether the color grading effect is enabled.
  26728. */
  26729. colorGradingEnabled: boolean;
  26730. /**
  26731. * Gets exposure used in the effect.
  26732. */
  26733. /**
  26734. * Sets exposure used in the effect.
  26735. */
  26736. exposure: number;
  26737. /**
  26738. * Gets wether tonemapping is enabled or not.
  26739. */
  26740. /**
  26741. * Sets wether tonemapping is enabled or not
  26742. */
  26743. toneMappingEnabled: boolean;
  26744. /**
  26745. * Gets contrast used in the effect.
  26746. */
  26747. /**
  26748. * Sets contrast used in the effect.
  26749. */
  26750. contrast: number;
  26751. /**
  26752. * Gets Vignette stretch size.
  26753. */
  26754. /**
  26755. * Sets Vignette stretch size.
  26756. */
  26757. vignetteStretch: number;
  26758. /**
  26759. * Gets Vignette centre X Offset.
  26760. */
  26761. /**
  26762. * Sets Vignette centre X Offset.
  26763. */
  26764. vignetteCentreX: number;
  26765. /**
  26766. * Gets Vignette centre Y Offset.
  26767. */
  26768. /**
  26769. * Sets Vignette centre Y Offset.
  26770. */
  26771. vignetteCentreY: number;
  26772. /**
  26773. * Gets Vignette weight or intensity of the vignette effect.
  26774. */
  26775. /**
  26776. * Sets Vignette weight or intensity of the vignette effect.
  26777. */
  26778. vignetteWeight: number;
  26779. /**
  26780. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26781. * if vignetteEnabled is set to true.
  26782. */
  26783. /**
  26784. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26785. * if vignetteEnabled is set to true.
  26786. */
  26787. vignetteColor: Color4;
  26788. /**
  26789. * Gets Camera field of view used by the Vignette effect.
  26790. */
  26791. /**
  26792. * Sets Camera field of view used by the Vignette effect.
  26793. */
  26794. vignetteCameraFov: number;
  26795. /**
  26796. * Gets the vignette blend mode allowing different kind of effect.
  26797. */
  26798. /**
  26799. * Sets the vignette blend mode allowing different kind of effect.
  26800. */
  26801. vignetteBlendMode: number;
  26802. /**
  26803. * Gets wether the vignette effect is enabled.
  26804. */
  26805. /**
  26806. * Sets wether the vignette effect is enabled.
  26807. */
  26808. vignetteEnabled: boolean;
  26809. private _fromLinearSpace;
  26810. /**
  26811. * Gets wether the input of the processing is in Gamma or Linear Space.
  26812. */
  26813. /**
  26814. * Sets wether the input of the processing is in Gamma or Linear Space.
  26815. */
  26816. fromLinearSpace: boolean;
  26817. /**
  26818. * Defines cache preventing GC.
  26819. */
  26820. private _defines;
  26821. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26822. getClassName(): string;
  26823. protected _updateParameters(): void;
  26824. dispose(camera?: Camera): void;
  26825. }
  26826. }
  26827. declare module BABYLON {
  26828. class PassPostProcess extends PostProcess {
  26829. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26830. }
  26831. }
  26832. declare module BABYLON {
  26833. type PostProcessOptions = {
  26834. width: number;
  26835. height: number;
  26836. };
  26837. /**
  26838. * PostProcess can be used to apply a shader to a texture after it has been rendered
  26839. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26840. */
  26841. class PostProcess {
  26842. /** Name of the PostProcess. */ name: string;
  26843. /**
  26844. * Width of the texture to apply the post process on
  26845. */
  26846. width: number;
  26847. /**
  26848. * Height of the texture to apply the post process on
  26849. */
  26850. height: number;
  26851. /**
  26852. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  26853. */
  26854. _outputTexture: Nullable<InternalTexture>;
  26855. /**
  26856. * Sampling mode used by the shader
  26857. * See https://doc.babylonjs.com/classes/3.1/texture
  26858. */
  26859. renderTargetSamplingMode: number;
  26860. /**
  26861. * Clear color to use when screen clearing
  26862. */
  26863. clearColor: Color4;
  26864. /**
  26865. * If the buffer needs to be cleared before applying the post process. (default: true)
  26866. * Should be set to false if shader will overwrite all previous pixels.
  26867. */
  26868. autoClear: boolean;
  26869. /**
  26870. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26871. */
  26872. alphaMode: number;
  26873. /**
  26874. * Sets the setAlphaBlendConstants of the babylon engine
  26875. */
  26876. alphaConstants: Color4;
  26877. /**
  26878. * Animations to be used for the post processing
  26879. */
  26880. animations: Animation[];
  26881. /**
  26882. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26883. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26884. */
  26885. enablePixelPerfectMode: boolean;
  26886. /**
  26887. * Force the postprocess to be applied without taking in account viewport
  26888. */
  26889. forceFullscreenViewport: boolean;
  26890. /**
  26891. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26892. *
  26893. * | Value | Type | Description |
  26894. * | ----- | ----------------------------------- | ----------- |
  26895. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  26896. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  26897. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  26898. *
  26899. */
  26900. scaleMode: number;
  26901. /**
  26902. * Force textures to be a power of two (default: false)
  26903. */
  26904. alwaysForcePOT: boolean;
  26905. /**
  26906. * Number of sample textures (default: 1)
  26907. */
  26908. samples: number;
  26909. /**
  26910. * Modify the scale of the post process to be the same as the viewport (default: false)
  26911. */
  26912. adaptScaleToCurrentViewport: boolean;
  26913. private _camera;
  26914. private _scene;
  26915. private _engine;
  26916. private _options;
  26917. private _reusable;
  26918. private _textureType;
  26919. /**
  26920. * Smart array of input and output textures for the post process.
  26921. */
  26922. _textures: SmartArray<InternalTexture>;
  26923. /**
  26924. * The index in _textures that corresponds to the output texture.
  26925. */
  26926. _currentRenderTextureInd: number;
  26927. private _effect;
  26928. private _samplers;
  26929. private _fragmentUrl;
  26930. private _vertexUrl;
  26931. private _parameters;
  26932. private _scaleRatio;
  26933. protected _indexParameters: any;
  26934. private _shareOutputWithPostProcess;
  26935. private _texelSize;
  26936. private _forcedOutputTexture;
  26937. /**
  26938. * An event triggered when the postprocess is activated.
  26939. */
  26940. onActivateObservable: Observable<Camera>;
  26941. private _onActivateObserver;
  26942. /**
  26943. * A function that is added to the onActivateObservable
  26944. */
  26945. onActivate: Nullable<(camera: Camera) => void>;
  26946. /**
  26947. * An event triggered when the postprocess changes its size.
  26948. */
  26949. onSizeChangedObservable: Observable<PostProcess>;
  26950. private _onSizeChangedObserver;
  26951. /**
  26952. * A function that is added to the onSizeChangedObservable
  26953. */
  26954. onSizeChanged: (postProcess: PostProcess) => void;
  26955. /**
  26956. * An event triggered when the postprocess applies its effect.
  26957. */
  26958. onApplyObservable: Observable<Effect>;
  26959. private _onApplyObserver;
  26960. /**
  26961. * A function that is added to the onApplyObservable
  26962. */
  26963. onApply: (effect: Effect) => void;
  26964. /**
  26965. * An event triggered before rendering the postprocess
  26966. */
  26967. onBeforeRenderObservable: Observable<Effect>;
  26968. private _onBeforeRenderObserver;
  26969. /**
  26970. * A function that is added to the onBeforeRenderObservable
  26971. */
  26972. onBeforeRender: (effect: Effect) => void;
  26973. /**
  26974. * An event triggered after rendering the postprocess
  26975. */
  26976. onAfterRenderObservable: Observable<Effect>;
  26977. private _onAfterRenderObserver;
  26978. /**
  26979. * A function that is added to the onAfterRenderObservable
  26980. */
  26981. onAfterRender: (efect: Effect) => void;
  26982. /**
  26983. * 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
  26984. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26985. */
  26986. inputTexture: InternalTexture;
  26987. /**
  26988. * Gets the camera which post process is applied to.
  26989. * @returns The camera the post process is applied to.
  26990. */
  26991. getCamera(): Camera;
  26992. /**
  26993. * Gets the texel size of the postprocess.
  26994. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26995. */
  26996. readonly texelSize: Vector2;
  26997. /**
  26998. * Creates a new instance PostProcess
  26999. * @param name The name of the PostProcess.
  27000. * @param fragmentUrl The url of the fragment shader to be used.
  27001. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27002. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27003. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27004. * @param camera The camera to apply the render pass to.
  27005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27006. * @param engine The engine which the post process will be applied. (default: current engine)
  27007. * @param reusable If the post process can be reused on the same frame. (default: false)
  27008. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27009. * @param textureType Type of textures used when performing the post process. (default: 0)
  27010. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27011. * @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
  27012. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27013. */
  27014. constructor(/** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  27015. /**
  27016. * Gets the engine which this post process belongs to.
  27017. * @returns The engine the post process was enabled with.
  27018. */
  27019. getEngine(): Engine;
  27020. /**
  27021. * The effect that is created when initializing the post process.
  27022. * @returns The created effect corrisponding the the postprocess.
  27023. */
  27024. getEffect(): Effect;
  27025. /**
  27026. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27027. * @param postProcess The post process to share the output with.
  27028. * @returns This post process.
  27029. */
  27030. shareOutputWith(postProcess: PostProcess): PostProcess;
  27031. /**
  27032. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27033. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27034. */
  27035. useOwnOutput(): void;
  27036. /**
  27037. * Updates the effect with the current post process compile time values and recompiles the shader.
  27038. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27039. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27040. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27041. * @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
  27042. * @param onCompiled Called when the shader has been compiled.
  27043. * @param onError Called if there is an error when compiling a shader.
  27044. */
  27045. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27046. /**
  27047. * The post process is reusable if it can be used multiple times within one frame.
  27048. * @returns If the post process is reusable
  27049. */
  27050. isReusable(): boolean;
  27051. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27052. markTextureDirty(): void;
  27053. /**
  27054. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27055. * 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.
  27056. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27057. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27058. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27059. * @returns The target texture that was bound to be written to.
  27060. */
  27061. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27062. /**
  27063. * If the post process is supported.
  27064. */
  27065. readonly isSupported: boolean;
  27066. /**
  27067. * The aspect ratio of the output texture.
  27068. */
  27069. readonly aspectRatio: number;
  27070. /**
  27071. * Get a value indicating if the post-process is ready to be used
  27072. * @returns true if the post-process is ready (shader is compiled)
  27073. */
  27074. isReady(): boolean;
  27075. /**
  27076. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27077. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27078. */
  27079. apply(): Nullable<Effect>;
  27080. private _disposeTextures();
  27081. /**
  27082. * Disposes the post process.
  27083. * @param camera The camera to dispose the post process on.
  27084. */
  27085. dispose(camera?: Camera): void;
  27086. }
  27087. }
  27088. declare module BABYLON {
  27089. /**
  27090. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27091. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27092. */
  27093. class PostProcessManager {
  27094. private _scene;
  27095. private _indexBuffer;
  27096. private _vertexBuffers;
  27097. /**
  27098. * Creates a new instance PostProcess
  27099. * @param scene The scene that the post process is associated with.
  27100. */
  27101. constructor(scene: Scene);
  27102. private _prepareBuffers();
  27103. private _buildIndexBuffer();
  27104. /**
  27105. * Rebuilds the vertex buffers of the manager.
  27106. */
  27107. _rebuild(): void;
  27108. /**
  27109. * Prepares a frame to be run through a post process.
  27110. * @param sourceTexture The input texture to the post procesess. (default: null)
  27111. * @param postProcesses An array of post processes to be run. (default: null)
  27112. * @returns True if the post processes were able to be run.
  27113. */
  27114. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27115. /**
  27116. * Manually render a set of post processes to a texture.
  27117. * @param postProcesses An array of post processes to be run.
  27118. * @param targetTexture The target texture to render to.
  27119. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  27120. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  27121. * @param lodLevel defines which lod of the texture to render to
  27122. */
  27123. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  27124. /**
  27125. * Finalize the result of the output of the postprocesses.
  27126. * @param doNotPresent If true the result will not be displayed to the screen.
  27127. * @param targetTexture The target texture to render to.
  27128. * @param faceIndex The index of the face to bind the target texture to.
  27129. * @param postProcesses The array of post processes to render.
  27130. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27131. */
  27132. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  27133. /**
  27134. * Disposes of the post process manager.
  27135. */
  27136. dispose(): void;
  27137. }
  27138. }
  27139. declare module BABYLON {
  27140. class RefractionPostProcess extends PostProcess {
  27141. color: Color3;
  27142. depth: number;
  27143. colorLevel: number;
  27144. private _refTexture;
  27145. private _ownRefractionTexture;
  27146. /**
  27147. * Gets or sets the refraction texture
  27148. * Please note that you are responsible for disposing the texture if you set it manually
  27149. */
  27150. refractionTexture: Texture;
  27151. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27152. dispose(camera: Camera): void;
  27153. }
  27154. }
  27155. declare module BABYLON {
  27156. /**
  27157. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27158. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27159. */
  27160. class SharpenPostProcess extends PostProcess {
  27161. /**
  27162. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27163. */
  27164. colorAmount: number;
  27165. /**
  27166. * How much sharpness should be applied (default: 0.3)
  27167. */
  27168. edgeAmount: number;
  27169. /**
  27170. * Creates a new instance ConvolutionPostProcess
  27171. * @param name The name of the effect.
  27172. * @param options The required width/height ratio to downsize to before computing the render pass.
  27173. * @param camera The camera to apply the render pass to.
  27174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27175. * @param engine The engine which the post process will be applied. (default: current engine)
  27176. * @param reusable If the post process can be reused on the same frame. (default: false)
  27177. * @param textureType Type of textures used when performing the post process. (default: 0)
  27178. * @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)
  27179. */
  27180. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27181. }
  27182. }
  27183. declare module BABYLON {
  27184. class StereoscopicInterlacePostProcess extends PostProcess {
  27185. private _stepSize;
  27186. private _passedProcess;
  27187. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27188. }
  27189. }
  27190. declare module BABYLON {
  27191. /** Defines operator used for tonemapping */
  27192. enum TonemappingOperator {
  27193. /** Hable */
  27194. Hable = 0,
  27195. /** Reinhard */
  27196. Reinhard = 1,
  27197. /** HejiDawson */
  27198. HejiDawson = 2,
  27199. /** Photographic */
  27200. Photographic = 3,
  27201. }
  27202. /**
  27203. * Defines a post process to apply tone mapping
  27204. */
  27205. class TonemapPostProcess extends PostProcess {
  27206. private _operator;
  27207. /** Defines the required exposure adjustement */
  27208. exposureAdjustment: number;
  27209. /**
  27210. * Creates a new TonemapPostProcess
  27211. * @param name defines the name of the postprocess
  27212. * @param _operator defines the operator to use
  27213. * @param exposureAdjustment defines the required exposure adjustement
  27214. * @param camera defines the camera to use (can be null)
  27215. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  27216. * @param engine defines the hosting engine (can be ignore if camera is set)
  27217. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27218. */
  27219. constructor(name: string, _operator: TonemappingOperator,
  27220. /** Defines the required exposure adjustement */
  27221. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  27222. }
  27223. }
  27224. declare module BABYLON {
  27225. class VolumetricLightScatteringPostProcess extends PostProcess {
  27226. private _volumetricLightScatteringPass;
  27227. private _volumetricLightScatteringRTT;
  27228. private _viewPort;
  27229. private _screenCoordinates;
  27230. private _cachedDefines;
  27231. /**
  27232. * If not undefined, the mesh position is computed from the attached node position
  27233. */
  27234. attachedNode: {
  27235. position: Vector3;
  27236. };
  27237. /**
  27238. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  27239. */
  27240. customMeshPosition: Vector3;
  27241. /**
  27242. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  27243. */
  27244. useCustomMeshPosition: boolean;
  27245. /**
  27246. * If the post-process should inverse the light scattering direction
  27247. */
  27248. invert: boolean;
  27249. /**
  27250. * The internal mesh used by the post-process
  27251. */
  27252. mesh: Mesh;
  27253. useDiffuseColor: boolean;
  27254. /**
  27255. * Array containing the excluded meshes not rendered in the internal pass
  27256. */
  27257. excludedMeshes: AbstractMesh[];
  27258. /**
  27259. * Controls the overall intensity of the post-process
  27260. */
  27261. exposure: number;
  27262. /**
  27263. * Dissipates each sample's contribution in range [0, 1]
  27264. */
  27265. decay: number;
  27266. /**
  27267. * Controls the overall intensity of each sample
  27268. */
  27269. weight: number;
  27270. /**
  27271. * Controls the density of each sample
  27272. */
  27273. density: number;
  27274. /**
  27275. * @constructor
  27276. * @param {string} name - The post-process name
  27277. * @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)
  27278. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  27279. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  27280. * @param {number} samples - The post-process quality, default 100
  27281. * @param {number} samplingMode - The post-process filtering mode
  27282. * @param {BABYLON.Engine} engine - The babylon engine
  27283. * @param {boolean} reusable - If the post-process is reusable
  27284. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  27285. */
  27286. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  27287. getClassName(): string;
  27288. private _isReady(subMesh, useInstances);
  27289. /**
  27290. * Sets the new light position for light scattering effect
  27291. * @param {BABYLON.Vector3} The new custom light position
  27292. */
  27293. setCustomMeshPosition(position: Vector3): void;
  27294. /**
  27295. * Returns the light position for light scattering effect
  27296. * @return {BABYLON.Vector3} The custom light position
  27297. */
  27298. getCustomMeshPosition(): Vector3;
  27299. /**
  27300. * Disposes the internal assets and detaches the post-process from the camera
  27301. */
  27302. dispose(camera: Camera): void;
  27303. /**
  27304. * Returns the render target texture used by the post-process
  27305. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  27306. */
  27307. getPass(): RenderTargetTexture;
  27308. private _meshExcluded(mesh);
  27309. private _createPass(scene, ratio);
  27310. private _updateMeshScreenCoordinates(scene);
  27311. /**
  27312. * Creates a default mesh for the Volumeric Light Scattering post-process
  27313. * @param {string} The mesh name
  27314. * @param {BABYLON.Scene} The scene where to create the mesh
  27315. * @return {BABYLON.Mesh} the default mesh
  27316. */
  27317. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  27318. }
  27319. }
  27320. declare module BABYLON {
  27321. class VRDistortionCorrectionPostProcess extends PostProcess {
  27322. private _isRightEye;
  27323. private _distortionFactors;
  27324. private _postProcessScaleFactor;
  27325. private _lensCenterOffset;
  27326. private _scaleIn;
  27327. private _scaleFactor;
  27328. private _lensCenter;
  27329. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27330. }
  27331. }
  27332. declare module BABYLON {
  27333. /**
  27334. * @hidden
  27335. **/
  27336. class _AlphaState {
  27337. private _isAlphaBlendDirty;
  27338. private _isBlendFunctionParametersDirty;
  27339. private _isBlendEquationParametersDirty;
  27340. private _isBlendConstantsDirty;
  27341. private _alphaBlend;
  27342. private _blendFunctionParameters;
  27343. private _blendEquationParameters;
  27344. private _blendConstants;
  27345. /**
  27346. * Initializes the state.
  27347. */
  27348. constructor();
  27349. readonly isDirty: boolean;
  27350. alphaBlend: boolean;
  27351. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  27352. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  27353. setAlphaEquationParameters(rgb: number, alpha: number): void;
  27354. reset(): void;
  27355. apply(gl: WebGLRenderingContext): void;
  27356. }
  27357. }
  27358. declare module BABYLON {
  27359. /**
  27360. * @hidden
  27361. **/
  27362. class _DepthCullingState {
  27363. private _isDepthTestDirty;
  27364. private _isDepthMaskDirty;
  27365. private _isDepthFuncDirty;
  27366. private _isCullFaceDirty;
  27367. private _isCullDirty;
  27368. private _isZOffsetDirty;
  27369. private _isFrontFaceDirty;
  27370. private _depthTest;
  27371. private _depthMask;
  27372. private _depthFunc;
  27373. private _cull;
  27374. private _cullFace;
  27375. private _zOffset;
  27376. private _frontFace;
  27377. /**
  27378. * Initializes the state.
  27379. */
  27380. constructor();
  27381. readonly isDirty: boolean;
  27382. zOffset: number;
  27383. cullFace: Nullable<number>;
  27384. cull: Nullable<boolean>;
  27385. depthFunc: Nullable<number>;
  27386. depthMask: boolean;
  27387. depthTest: boolean;
  27388. frontFace: Nullable<number>;
  27389. reset(): void;
  27390. apply(gl: WebGLRenderingContext): void;
  27391. }
  27392. }
  27393. declare module BABYLON {
  27394. /**
  27395. * @hidden
  27396. **/
  27397. class _StencilState {
  27398. private _isStencilTestDirty;
  27399. private _isStencilMaskDirty;
  27400. private _isStencilFuncDirty;
  27401. private _isStencilOpDirty;
  27402. private _stencilTest;
  27403. private _stencilMask;
  27404. private _stencilFunc;
  27405. private _stencilFuncRef;
  27406. private _stencilFuncMask;
  27407. private _stencilOpStencilFail;
  27408. private _stencilOpDepthFail;
  27409. private _stencilOpStencilDepthPass;
  27410. readonly isDirty: boolean;
  27411. stencilFunc: number;
  27412. stencilFuncRef: number;
  27413. stencilFuncMask: number;
  27414. stencilOpStencilFail: number;
  27415. stencilOpDepthFail: number;
  27416. stencilOpStencilDepthPass: number;
  27417. stencilMask: number;
  27418. stencilTest: boolean;
  27419. constructor();
  27420. reset(): void;
  27421. apply(gl: WebGLRenderingContext): void;
  27422. }
  27423. }
  27424. declare module BABYLON {
  27425. /**
  27426. * Class used to evalaute queries containing `and` and `or` operators
  27427. */
  27428. class AndOrNotEvaluator {
  27429. /**
  27430. * Evaluate a query
  27431. * @param query defines the query to evaluate
  27432. * @param evaluateCallback defines the callback used to filter result
  27433. * @returns true if the query matches
  27434. */
  27435. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27436. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27437. private static _SimplifyNegation(booleanString);
  27438. }
  27439. }
  27440. declare module BABYLON {
  27441. /**
  27442. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27443. */
  27444. enum AssetTaskState {
  27445. /**
  27446. * Initialization
  27447. */
  27448. INIT = 0,
  27449. /**
  27450. * Running
  27451. */
  27452. RUNNING = 1,
  27453. /**
  27454. * Done
  27455. */
  27456. DONE = 2,
  27457. /**
  27458. * Error
  27459. */
  27460. ERROR = 3,
  27461. }
  27462. /**
  27463. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27464. */
  27465. abstract class AbstractAssetTask {
  27466. /**
  27467. * Task name
  27468. */ name: string;
  27469. /**
  27470. * Callback called when the task is successful
  27471. */
  27472. onSuccess: (task: any) => void;
  27473. /**
  27474. * Callback called when the task is not successful
  27475. */
  27476. onError: (task: any, message?: string, exception?: any) => void;
  27477. /**
  27478. * Creates a new {BABYLON.AssetsManager}
  27479. * @param name defines the name of the task
  27480. */
  27481. constructor(
  27482. /**
  27483. * Task name
  27484. */ name: string);
  27485. private _isCompleted;
  27486. private _taskState;
  27487. private _errorObject;
  27488. /**
  27489. * Get if the task is completed
  27490. */
  27491. readonly isCompleted: boolean;
  27492. /**
  27493. * Gets the current state of the task
  27494. */
  27495. readonly taskState: AssetTaskState;
  27496. /**
  27497. * Gets the current error object (if task is in error)
  27498. */
  27499. readonly errorObject: {
  27500. message?: string;
  27501. exception?: any;
  27502. };
  27503. /**
  27504. * Internal only
  27505. * @hidden
  27506. */
  27507. _setErrorObject(message?: string, exception?: any): void;
  27508. /**
  27509. * Execute the current task
  27510. * @param scene defines the scene where you want your assets to be loaded
  27511. * @param onSuccess is a callback called when the task is successfully executed
  27512. * @param onError is a callback called if an error occurs
  27513. */
  27514. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27515. /**
  27516. * Execute the current task
  27517. * @param scene defines the scene where you want your assets to be loaded
  27518. * @param onSuccess is a callback called when the task is successfully executed
  27519. * @param onError is a callback called if an error occurs
  27520. */
  27521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27522. /**
  27523. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  27524. * This can be used with failed tasks that have the reason for failure fixed.
  27525. */
  27526. reset(): void;
  27527. private onErrorCallback(onError, message?, exception?);
  27528. private onDoneCallback(onSuccess, onError);
  27529. }
  27530. /**
  27531. * Define the interface used by progress events raised during assets loading
  27532. */
  27533. interface IAssetsProgressEvent {
  27534. /**
  27535. * Defines the number of remaining tasks to process
  27536. */
  27537. remainingCount: number;
  27538. /**
  27539. * Defines the total number of tasks
  27540. */
  27541. totalCount: number;
  27542. /**
  27543. * Defines the task that was just processed
  27544. */
  27545. task: AbstractAssetTask;
  27546. }
  27547. /**
  27548. * Class used to share progress information about assets loading
  27549. */
  27550. class AssetsProgressEvent implements IAssetsProgressEvent {
  27551. /**
  27552. * Defines the number of remaining tasks to process
  27553. */
  27554. remainingCount: number;
  27555. /**
  27556. * Defines the total number of tasks
  27557. */
  27558. totalCount: number;
  27559. /**
  27560. * Defines the task that was just processed
  27561. */
  27562. task: AbstractAssetTask;
  27563. /**
  27564. * Creates a {BABYLON.AssetsProgressEvent}
  27565. * @param remainingCount defines the number of remaining tasks to process
  27566. * @param totalCount defines the total number of tasks
  27567. * @param task defines the task that was just processed
  27568. */
  27569. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27570. }
  27571. /**
  27572. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27573. */
  27574. class MeshAssetTask extends AbstractAssetTask {
  27575. /**
  27576. * Defines the name of the task
  27577. */
  27578. name: string;
  27579. /**
  27580. * Defines the list of mesh's names you want to load
  27581. */
  27582. meshesNames: any;
  27583. /**
  27584. * Defines the root url to use as a base to load your meshes and associated resources
  27585. */
  27586. rootUrl: string;
  27587. /**
  27588. * Defines the filename of the scene to load from
  27589. */
  27590. sceneFilename: string;
  27591. /**
  27592. * Gets the list of loaded meshes
  27593. */
  27594. loadedMeshes: Array<AbstractMesh>;
  27595. /**
  27596. * Gets the list of loaded particle systems
  27597. */
  27598. loadedParticleSystems: Array<ParticleSystem>;
  27599. /**
  27600. * Gets the list of loaded skeletons
  27601. */
  27602. loadedSkeletons: Array<Skeleton>;
  27603. /**
  27604. * Callback called when the task is successful
  27605. */
  27606. onSuccess: (task: MeshAssetTask) => void;
  27607. /**
  27608. * Callback called when the task is successful
  27609. */
  27610. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27611. /**
  27612. * Creates a new {BABYLON.MeshAssetTask}
  27613. * @param name defines the name of the task
  27614. * @param meshesNames defines the list of mesh's names you want to load
  27615. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27616. * @param sceneFilename defines the filename of the scene to load from
  27617. */
  27618. constructor(
  27619. /**
  27620. * Defines the name of the task
  27621. */
  27622. name: string,
  27623. /**
  27624. * Defines the list of mesh's names you want to load
  27625. */
  27626. meshesNames: any,
  27627. /**
  27628. * Defines the root url to use as a base to load your meshes and associated resources
  27629. */
  27630. rootUrl: string,
  27631. /**
  27632. * Defines the filename of the scene to load from
  27633. */
  27634. sceneFilename: string);
  27635. /**
  27636. * Execute the current task
  27637. * @param scene defines the scene where you want your assets to be loaded
  27638. * @param onSuccess is a callback called when the task is successfully executed
  27639. * @param onError is a callback called if an error occurs
  27640. */
  27641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27642. }
  27643. /**
  27644. * Define a task used by {BABYLON.AssetsManager} to load text content
  27645. */
  27646. class TextFileAssetTask extends AbstractAssetTask {
  27647. /**
  27648. * Defines the name of the task
  27649. */
  27650. name: string;
  27651. /**
  27652. * Defines the location of the file to load
  27653. */
  27654. url: string;
  27655. /**
  27656. * Gets the loaded text string
  27657. */
  27658. text: string;
  27659. /**
  27660. * Callback called when the task is successful
  27661. */
  27662. onSuccess: (task: TextFileAssetTask) => void;
  27663. /**
  27664. * Callback called when the task is successful
  27665. */
  27666. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27667. /**
  27668. * Creates a new TextFileAssetTask object
  27669. * @param name defines the name of the task
  27670. * @param url defines the location of the file to load
  27671. */
  27672. constructor(
  27673. /**
  27674. * Defines the name of the task
  27675. */
  27676. name: string,
  27677. /**
  27678. * Defines the location of the file to load
  27679. */
  27680. url: string);
  27681. /**
  27682. * Execute the current task
  27683. * @param scene defines the scene where you want your assets to be loaded
  27684. * @param onSuccess is a callback called when the task is successfully executed
  27685. * @param onError is a callback called if an error occurs
  27686. */
  27687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27688. }
  27689. /**
  27690. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27691. */
  27692. class BinaryFileAssetTask extends AbstractAssetTask {
  27693. /**
  27694. * Defines the name of the task
  27695. */
  27696. name: string;
  27697. /**
  27698. * Defines the location of the file to load
  27699. */
  27700. url: string;
  27701. /**
  27702. * Gets the lodaded data (as an array buffer)
  27703. */
  27704. data: ArrayBuffer;
  27705. /**
  27706. * Callback called when the task is successful
  27707. */
  27708. onSuccess: (task: BinaryFileAssetTask) => void;
  27709. /**
  27710. * Callback called when the task is successful
  27711. */
  27712. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27713. /**
  27714. * Creates a new BinaryFileAssetTask object
  27715. * @param name defines the name of the new task
  27716. * @param url defines the location of the file to load
  27717. */
  27718. constructor(
  27719. /**
  27720. * Defines the name of the task
  27721. */
  27722. name: string,
  27723. /**
  27724. * Defines the location of the file to load
  27725. */
  27726. url: string);
  27727. /**
  27728. * Execute the current task
  27729. * @param scene defines the scene where you want your assets to be loaded
  27730. * @param onSuccess is a callback called when the task is successfully executed
  27731. * @param onError is a callback called if an error occurs
  27732. */
  27733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27734. }
  27735. /**
  27736. * Define a task used by {BABYLON.AssetsManager} to load images
  27737. */
  27738. class ImageAssetTask extends AbstractAssetTask {
  27739. /**
  27740. * Defines the name of the task
  27741. */
  27742. name: string;
  27743. /**
  27744. * Defines the location of the image to load
  27745. */
  27746. url: string;
  27747. /**
  27748. * Gets the loaded images
  27749. */
  27750. image: HTMLImageElement;
  27751. /**
  27752. * Callback called when the task is successful
  27753. */
  27754. onSuccess: (task: ImageAssetTask) => void;
  27755. /**
  27756. * Callback called when the task is successful
  27757. */
  27758. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27759. /**
  27760. * Creates a new ImageAssetTask
  27761. * @param name defines the name of the task
  27762. * @param url defines the location of the image to load
  27763. */
  27764. constructor(
  27765. /**
  27766. * Defines the name of the task
  27767. */
  27768. name: string,
  27769. /**
  27770. * Defines the location of the image to load
  27771. */
  27772. url: string);
  27773. /**
  27774. * Execute the current task
  27775. * @param scene defines the scene where you want your assets to be loaded
  27776. * @param onSuccess is a callback called when the task is successfully executed
  27777. * @param onError is a callback called if an error occurs
  27778. */
  27779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27780. }
  27781. /**
  27782. * Defines the interface used by texture loading tasks
  27783. */
  27784. interface ITextureAssetTask<TEX extends BaseTexture> {
  27785. /**
  27786. * Gets the loaded texture
  27787. */
  27788. texture: TEX;
  27789. }
  27790. /**
  27791. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27792. */
  27793. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27794. /**
  27795. * Defines the name of the task
  27796. */
  27797. name: string;
  27798. /**
  27799. * Defines the location of the file to load
  27800. */
  27801. url: string;
  27802. /**
  27803. * Defines if mipmap should not be generated (default is false)
  27804. */
  27805. noMipmap: boolean | undefined;
  27806. /**
  27807. * Defines if texture must be inverted on Y axis (default is false)
  27808. */
  27809. invertY: boolean | undefined;
  27810. /**
  27811. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27812. */
  27813. samplingMode: number;
  27814. /**
  27815. * Gets the loaded texture
  27816. */
  27817. texture: Texture;
  27818. /**
  27819. * Callback called when the task is successful
  27820. */
  27821. onSuccess: (task: TextureAssetTask) => void;
  27822. /**
  27823. * Callback called when the task is successful
  27824. */
  27825. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27826. /**
  27827. * Creates a new TextureAssetTask object
  27828. * @param name defines the name of the task
  27829. * @param url defines the location of the file to load
  27830. * @param noMipmap defines if mipmap should not be generated (default is false)
  27831. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27832. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27833. */
  27834. constructor(
  27835. /**
  27836. * Defines the name of the task
  27837. */
  27838. name: string,
  27839. /**
  27840. * Defines the location of the file to load
  27841. */
  27842. url: string,
  27843. /**
  27844. * Defines if mipmap should not be generated (default is false)
  27845. */
  27846. noMipmap?: boolean | undefined,
  27847. /**
  27848. * Defines if texture must be inverted on Y axis (default is false)
  27849. */
  27850. invertY?: boolean | undefined,
  27851. /**
  27852. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27853. */
  27854. samplingMode?: number);
  27855. /**
  27856. * Execute the current task
  27857. * @param scene defines the scene where you want your assets to be loaded
  27858. * @param onSuccess is a callback called when the task is successfully executed
  27859. * @param onError is a callback called if an error occurs
  27860. */
  27861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27862. }
  27863. /**
  27864. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27865. */
  27866. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27867. /**
  27868. * Defines the name of the task
  27869. */
  27870. name: string;
  27871. /**
  27872. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27873. */
  27874. url: string;
  27875. /**
  27876. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27877. */
  27878. extensions: string[] | undefined;
  27879. /**
  27880. * Defines if mipmaps should not be generated (default is false)
  27881. */
  27882. noMipmap: boolean | undefined;
  27883. /**
  27884. * Defines the explicit list of files (undefined by default)
  27885. */
  27886. files: string[] | undefined;
  27887. /**
  27888. * Gets the loaded texture
  27889. */
  27890. texture: CubeTexture;
  27891. /**
  27892. * Callback called when the task is successful
  27893. */
  27894. onSuccess: (task: CubeTextureAssetTask) => void;
  27895. /**
  27896. * Callback called when the task is successful
  27897. */
  27898. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27899. /**
  27900. * Creates a new CubeTextureAssetTask
  27901. * @param name defines the name of the task
  27902. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27903. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27904. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27905. * @param files defines the explicit list of files (undefined by default)
  27906. */
  27907. constructor(
  27908. /**
  27909. * Defines the name of the task
  27910. */
  27911. name: string,
  27912. /**
  27913. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27914. */
  27915. url: string,
  27916. /**
  27917. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27918. */
  27919. extensions?: string[] | undefined,
  27920. /**
  27921. * Defines if mipmaps should not be generated (default is false)
  27922. */
  27923. noMipmap?: boolean | undefined,
  27924. /**
  27925. * Defines the explicit list of files (undefined by default)
  27926. */
  27927. files?: string[] | undefined);
  27928. /**
  27929. * Execute the current task
  27930. * @param scene defines the scene where you want your assets to be loaded
  27931. * @param onSuccess is a callback called when the task is successfully executed
  27932. * @param onError is a callback called if an error occurs
  27933. */
  27934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27935. }
  27936. /**
  27937. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27938. */
  27939. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27940. /**
  27941. * Defines the name of the task
  27942. */
  27943. name: string;
  27944. /**
  27945. * Defines the location of the file to load
  27946. */
  27947. url: string;
  27948. /**
  27949. * Defines the desired size (the more it increases the longer the generation will be)
  27950. */
  27951. size: number;
  27952. /**
  27953. * Defines if mipmaps should not be generated (default is false)
  27954. */
  27955. noMipmap: boolean;
  27956. /**
  27957. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27958. */
  27959. generateHarmonics: boolean;
  27960. /**
  27961. * 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)
  27962. */
  27963. gammaSpace: boolean;
  27964. /**
  27965. * Internal Use Only
  27966. */
  27967. reserved: boolean;
  27968. /**
  27969. * Gets the loaded texture
  27970. */
  27971. texture: HDRCubeTexture;
  27972. /**
  27973. * Callback called when the task is successful
  27974. */
  27975. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27976. /**
  27977. * Callback called when the task is successful
  27978. */
  27979. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27980. /**
  27981. * Creates a new HDRCubeTextureAssetTask object
  27982. * @param name defines the name of the task
  27983. * @param url defines the location of the file to load
  27984. * @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.
  27985. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27986. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27987. * @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)
  27988. * @param reserved Internal use only
  27989. */
  27990. constructor(
  27991. /**
  27992. * Defines the name of the task
  27993. */
  27994. name: string,
  27995. /**
  27996. * Defines the location of the file to load
  27997. */
  27998. url: string,
  27999. /**
  28000. * Defines the desired size (the more it increases the longer the generation will be)
  28001. */
  28002. size: number,
  28003. /**
  28004. * Defines if mipmaps should not be generated (default is false)
  28005. */
  28006. noMipmap?: boolean,
  28007. /**
  28008. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28009. */
  28010. generateHarmonics?: boolean,
  28011. /**
  28012. * 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)
  28013. */
  28014. gammaSpace?: boolean,
  28015. /**
  28016. * Internal Use Only
  28017. */
  28018. reserved?: boolean);
  28019. /**
  28020. * Execute the current task
  28021. * @param scene defines the scene where you want your assets to be loaded
  28022. * @param onSuccess is a callback called when the task is successfully executed
  28023. * @param onError is a callback called if an error occurs
  28024. */
  28025. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28026. }
  28027. /**
  28028. * This class can be used to easily import assets into a scene
  28029. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  28030. */
  28031. class AssetsManager {
  28032. private _scene;
  28033. private _isLoading;
  28034. protected _tasks: AbstractAssetTask[];
  28035. protected _waitingTasksCount: number;
  28036. protected _totalTasksCount: number;
  28037. /**
  28038. * Callback called when all tasks are processed
  28039. */
  28040. onFinish: (tasks: AbstractAssetTask[]) => void;
  28041. /**
  28042. * Callback called when a task is successful
  28043. */
  28044. onTaskSuccess: (task: AbstractAssetTask) => void;
  28045. /**
  28046. * Callback called when a task had an error
  28047. */
  28048. onTaskError: (task: AbstractAssetTask) => void;
  28049. /**
  28050. * Callback called when a task is done (whatever the result is)
  28051. */
  28052. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  28053. /**
  28054. * Observable called when all tasks are processed
  28055. */
  28056. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  28057. /**
  28058. * Observable called when a task had an error
  28059. */
  28060. onTaskErrorObservable: Observable<AbstractAssetTask>;
  28061. /**
  28062. * Observable called when a task is successful
  28063. */
  28064. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  28065. /**
  28066. * Observable called when a task is done (whatever the result is)
  28067. */
  28068. onProgressObservable: Observable<IAssetsProgressEvent>;
  28069. /**
  28070. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  28071. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28072. */
  28073. useDefaultLoadingScreen: boolean;
  28074. /**
  28075. * Creates a new AssetsManager
  28076. * @param scene defines the scene to work on
  28077. */
  28078. constructor(scene: Scene);
  28079. /**
  28080. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  28081. * @param taskName defines the name of the new task
  28082. * @param meshesNames defines the name of meshes to load
  28083. * @param rootUrl defines the root url to use to locate files
  28084. * @param sceneFilename defines the filename of the scene file
  28085. * @returns a new {BABYLON.MeshAssetTask} object
  28086. */
  28087. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  28088. /**
  28089. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  28090. * @param taskName defines the name of the new task
  28091. * @param url defines the url of the file to load
  28092. * @returns a new {BABYLON.TextFileAssetTask} object
  28093. */
  28094. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  28095. /**
  28096. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  28097. * @param taskName defines the name of the new task
  28098. * @param url defines the url of the file to load
  28099. * @returns a new {BABYLON.BinaryFileAssetTask} object
  28100. */
  28101. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  28102. /**
  28103. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  28104. * @param taskName defines the name of the new task
  28105. * @param url defines the url of the file to load
  28106. * @returns a new {BABYLON.ImageAssetTask} object
  28107. */
  28108. addImageTask(taskName: string, url: string): ImageAssetTask;
  28109. /**
  28110. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  28111. * @param taskName defines the name of the new task
  28112. * @param url defines the url of the file to load
  28113. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28114. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  28115. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  28116. * @returns a new {BABYLON.TextureAssetTask} object
  28117. */
  28118. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  28119. /**
  28120. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  28121. * @param taskName defines the name of the new task
  28122. * @param url defines the url of the file to load
  28123. * @param extensions defines the extension to use to load the cube map (can be null)
  28124. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28125. * @param files defines the list of files to load (can be null)
  28126. * @returns a new {BABYLON.CubeTextureAssetTask} object
  28127. */
  28128. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  28129. /**
  28130. *
  28131. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  28132. * @param taskName defines the name of the new task
  28133. * @param url defines the url of the file to load
  28134. * @param size defines the size you want for the cubemap (can be null)
  28135. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28136. * @param generateHarmonics defines if you want to automatically generate (true by default)
  28137. * @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)
  28138. * @param reserved Internal use only
  28139. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  28140. */
  28141. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  28142. /**
  28143. * Remove a task from the assets manager.
  28144. * @param task the task to remove
  28145. */
  28146. removeTask(task: AbstractAssetTask): void;
  28147. private _decreaseWaitingTasksCount(task);
  28148. private _runTask(task);
  28149. /**
  28150. * Reset the {BABYLON.AssetsManager} and remove all tasks
  28151. * @return the current instance of the {BABYLON.AssetsManager}
  28152. */
  28153. reset(): AssetsManager;
  28154. /**
  28155. * Start the loading process
  28156. * @return the current instance of the {BABYLON.AssetsManager}
  28157. */
  28158. load(): AssetsManager;
  28159. }
  28160. }
  28161. declare module BABYLON {
  28162. /**
  28163. * Class used to enable access to IndexedDB
  28164. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  28165. */
  28166. class Database {
  28167. private callbackManifestChecked;
  28168. private currentSceneUrl;
  28169. private db;
  28170. private _enableSceneOffline;
  28171. private _enableTexturesOffline;
  28172. private manifestVersionFound;
  28173. private mustUpdateRessources;
  28174. private hasReachedQuota;
  28175. private isSupported;
  28176. private idbFactory;
  28177. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  28178. static IsUASupportingBlobStorage: boolean;
  28179. /** Gets a boolean indicating if Database storate is enabled */
  28180. static IDBStorageEnabled: boolean;
  28181. /**
  28182. * Gets a boolean indicating if scene must be saved in the database
  28183. */
  28184. readonly enableSceneOffline: boolean;
  28185. /**
  28186. * Gets a boolean indicating if textures must be saved in the database
  28187. */
  28188. readonly enableTexturesOffline: boolean;
  28189. /**
  28190. * Creates a new Database
  28191. * @param urlToScene defines the url to load the scene
  28192. * @param callbackManifestChecked defines the callback to use when manifest is checked
  28193. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  28194. */
  28195. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  28196. private static _ParseURL;
  28197. private static _ReturnFullUrlLocation;
  28198. private _checkManifestFile();
  28199. /**
  28200. * Open the database and make it available
  28201. * @param successCallback defines the callback to call on success
  28202. * @param errorCallback defines the callback to call on error
  28203. */
  28204. openAsync(successCallback: () => void, errorCallback: () => void): void;
  28205. /**
  28206. * Loads an image from the database
  28207. * @param url defines the url to load from
  28208. * @param image defines the target DOM image
  28209. */
  28210. loadImageFromDB(url: string, image: HTMLImageElement): void;
  28211. private _loadImageFromDBAsync(url, image, notInDBCallback);
  28212. private _saveImageIntoDBAsync(url, image);
  28213. private _checkVersionFromDB(url, versionLoaded);
  28214. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  28215. private _saveVersionIntoDBAsync(url, callback);
  28216. /**
  28217. * Loads a file from database
  28218. * @param url defines the URL to load from
  28219. * @param sceneLoaded defines a callback to call on success
  28220. * @param progressCallBack defines a callback to call when progress changed
  28221. * @param errorCallback defines a callback to call on error
  28222. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  28223. */
  28224. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  28225. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  28226. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  28227. }
  28228. }
  28229. declare module BABYLON {
  28230. interface DDSInfo {
  28231. width: number;
  28232. height: number;
  28233. mipmapCount: number;
  28234. isFourCC: boolean;
  28235. isRGB: boolean;
  28236. isLuminance: boolean;
  28237. isCube: boolean;
  28238. isCompressed: boolean;
  28239. dxgiFormat: number;
  28240. textureType: number;
  28241. /** Sphericle polynomial created for the dds texture */
  28242. sphericalPolynomial?: SphericalPolynomial;
  28243. }
  28244. class DDSTools {
  28245. static StoreLODInAlphaChannel: boolean;
  28246. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  28247. private static _FloatView;
  28248. private static _Int32View;
  28249. private static _ToHalfFloat(value);
  28250. private static _FromHalfFloat(value);
  28251. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28252. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28253. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28254. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28255. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28256. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  28257. private static _ExtractLongWordOrder(value);
  28258. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  28259. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  28260. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  28261. }
  28262. }
  28263. declare module BABYLON {
  28264. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28265. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28266. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28267. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28268. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28269. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28270. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28271. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28272. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28273. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28274. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28275. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28276. /**
  28277. * Decorator used to define property that can be serialized as reference to a camera
  28278. * @param sourceName defines the name of the property to decorate
  28279. */
  28280. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28281. class SerializationHelper {
  28282. static Serialize<T>(entity: T, serializationObject?: any): any;
  28283. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28284. static Clone<T>(creationFunction: () => T, source: T): T;
  28285. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28286. }
  28287. }
  28288. declare module BABYLON {
  28289. /**
  28290. * Wrapper class for promise with external resolve and reject.
  28291. */
  28292. class Deferred<T> {
  28293. /**
  28294. * The promise associated with this deferred object.
  28295. */
  28296. readonly promise: Promise<T>;
  28297. private _resolve;
  28298. private _reject;
  28299. /**
  28300. * The resolve method of the promise associated with this deferred object.
  28301. */
  28302. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  28303. /**
  28304. * The reject method of the promise associated with this deferred object.
  28305. */
  28306. readonly reject: (reason?: any) => void;
  28307. /**
  28308. * Constructor for this deferred object.
  28309. */
  28310. constructor();
  28311. }
  28312. }
  28313. declare module BABYLON {
  28314. /**
  28315. * Raw texture data and descriptor sufficient for WebGL texture upload
  28316. */
  28317. interface EnvironmentTextureInfo {
  28318. /**
  28319. * Version of the environment map
  28320. */
  28321. version: number;
  28322. /**
  28323. * Width of image
  28324. */
  28325. width: number;
  28326. /**
  28327. * Irradiance information stored in the file.
  28328. */
  28329. irradiance: any;
  28330. /**
  28331. * Specular information stored in the file.
  28332. */
  28333. specular: any;
  28334. }
  28335. /**
  28336. * Sets of helpers addressing the serialization and deserialization of environment texture
  28337. * stored in a BabylonJS env file.
  28338. * Those files are usually stored as .env files.
  28339. */
  28340. class EnvironmentTextureTools {
  28341. /**
  28342. * Magic number identifying the env file.
  28343. */
  28344. private static _MagicBytes;
  28345. /**
  28346. * Gets the environment info from an env file.
  28347. * @param data The array buffer containing the .env bytes.
  28348. * @returns the environment file info (the json header) if successfully parsed.
  28349. */
  28350. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  28351. /**
  28352. * Creates an environment texture from a loaded cube texture.
  28353. * @param texture defines the cube texture to convert in env file
  28354. * @return a promise containing the environment data if succesfull.
  28355. */
  28356. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  28357. /**
  28358. * Creates a JSON representation of the spherical data.
  28359. * @param texture defines the texture containing the polynomials
  28360. * @return the JSON representation of the spherical info
  28361. */
  28362. private static _CreateEnvTextureIrradiance(texture);
  28363. /**
  28364. * Uploads the texture info contained in the env file to te GPU.
  28365. * @param texture defines the internal texture to upload to
  28366. * @param arrayBuffer defines the buffer cotaining the data to load
  28367. * @param info defines the texture info retrieved through the GetEnvInfo method
  28368. * @returns a promise
  28369. */
  28370. static UploadLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  28371. /**
  28372. * Uploads spherical polynomials information to the texture.
  28373. * @param texture defines the texture we are trying to upload the information to
  28374. * @param arrayBuffer defines the array buffer holding the data
  28375. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  28376. */
  28377. static UploadPolynomials(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): void;
  28378. /**
  28379. * Upload spherical polynomial coefficients to the texture
  28380. * @param polynmials Spherical polynmial coefficients (9)
  28381. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28382. */
  28383. private static _UploadSP(polynmials, outPolynomialCoefficents);
  28384. /**
  28385. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  28386. * L = (1/pi) * E * rho
  28387. *
  28388. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  28389. * @param harmonics Spherical harmonic coefficients (9)
  28390. */
  28391. private static _ConvertSHIrradianceToLambertianRadiance(harmonics);
  28392. /**
  28393. * Convert spherical harmonics to spherical polynomial coefficients
  28394. * @param harmonics Spherical harmonic coefficients (9)
  28395. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28396. */
  28397. private static _ConvertSHToSP(harmonics, outPolynomialCoefficents);
  28398. }
  28399. }
  28400. declare module BABYLON {
  28401. class FilesInput {
  28402. static FilesToLoad: {
  28403. [key: string]: File;
  28404. };
  28405. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  28406. private _engine;
  28407. private _currentScene;
  28408. private _sceneLoadedCallback;
  28409. private _progressCallback;
  28410. private _additionalRenderLoopLogicCallback;
  28411. private _textureLoadingCallback;
  28412. private _startingProcessingFilesCallback;
  28413. private _onReloadCallback;
  28414. private _errorCallback;
  28415. private _elementToMonitor;
  28416. private _sceneFileToLoad;
  28417. private _filesToLoad;
  28418. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  28419. private _dragEnterHandler;
  28420. private _dragOverHandler;
  28421. private _dropHandler;
  28422. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  28423. dispose(): void;
  28424. private renderFunction();
  28425. private drag(e);
  28426. private drop(eventDrop);
  28427. private _traverseFolder(folder, files, remaining, callback);
  28428. private _processFiles(files);
  28429. loadFiles(event: any): void;
  28430. private _processReload();
  28431. reload(): void;
  28432. }
  28433. }
  28434. declare module BABYLON {
  28435. /**
  28436. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28437. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28438. */
  28439. class KhronosTextureContainer {
  28440. arrayBuffer: any;
  28441. static HEADER_LEN: number;
  28442. static COMPRESSED_2D: number;
  28443. static COMPRESSED_3D: number;
  28444. static TEX_2D: number;
  28445. static TEX_3D: number;
  28446. glType: number;
  28447. glTypeSize: number;
  28448. glFormat: number;
  28449. glInternalFormat: number;
  28450. glBaseInternalFormat: number;
  28451. pixelWidth: number;
  28452. pixelHeight: number;
  28453. pixelDepth: number;
  28454. numberOfArrayElements: number;
  28455. numberOfFaces: number;
  28456. numberOfMipmapLevels: number;
  28457. bytesOfKeyValueData: number;
  28458. loadType: number;
  28459. /**
  28460. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  28461. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  28462. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  28463. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  28464. */
  28465. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  28466. switchEndainness(val: number): number;
  28467. /**
  28468. * It is assumed that the texture has already been created & is currently bound
  28469. */
  28470. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  28471. private _upload2DCompressedLevels(gl, loadMipmaps);
  28472. }
  28473. }
  28474. declare module BABYLON {
  28475. /**
  28476. * A class serves as a medium between the observable and its observers
  28477. */
  28478. class EventState {
  28479. /**
  28480. * Create a new EventState
  28481. * @param mask defines the mask associated with this state
  28482. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28483. * @param target defines the original target of the state
  28484. * @param currentTarget defines the current target of the state
  28485. */
  28486. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  28487. /**
  28488. * Initialize the current event state
  28489. * @param mask defines the mask associated with this state
  28490. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28491. * @param target defines the original target of the state
  28492. * @param currentTarget defines the current target of the state
  28493. * @returns the current event state
  28494. */
  28495. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  28496. /**
  28497. * An Observer can set this property to true to prevent subsequent observers of being notified
  28498. */
  28499. skipNextObservers: boolean;
  28500. /**
  28501. * Get the mask value that were used to trigger the event corresponding to this EventState object
  28502. */
  28503. mask: number;
  28504. /**
  28505. * The object that originally notified the event
  28506. */
  28507. target?: any;
  28508. /**
  28509. * The current object in the bubbling phase
  28510. */
  28511. currentTarget?: any;
  28512. /**
  28513. * This will be populated with the return value of the last function that was executed.
  28514. * If it is the first function in the callback chain it will be the event data.
  28515. */
  28516. lastReturnValue?: any;
  28517. }
  28518. /**
  28519. * Represent an Observer registered to a given Observable object.
  28520. */
  28521. class Observer<T> {
  28522. /**
  28523. * Defines the callback to call when the observer is notified
  28524. */
  28525. callback: (eventData: T, eventState: EventState) => void;
  28526. /**
  28527. * Defines the mask of the observer (used to filter notifications)
  28528. */
  28529. mask: number;
  28530. /**
  28531. * Defines the current scope used to restore the JS context
  28532. */
  28533. scope: any;
  28534. /** @hidden */
  28535. _willBeUnregistered: boolean;
  28536. /**
  28537. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28538. */
  28539. unregisterOnNextCall: boolean;
  28540. /**
  28541. * Creates a new observer
  28542. * @param callback defines the callback to call when the observer is notified
  28543. * @param mask defines the mask of the observer (used to filter notifications)
  28544. * @param scope defines the current scope used to restore the JS context
  28545. */
  28546. constructor(
  28547. /**
  28548. * Defines the callback to call when the observer is notified
  28549. */
  28550. callback: (eventData: T, eventState: EventState) => void,
  28551. /**
  28552. * Defines the mask of the observer (used to filter notifications)
  28553. */
  28554. mask: number,
  28555. /**
  28556. * Defines the current scope used to restore the JS context
  28557. */
  28558. scope?: any);
  28559. }
  28560. /**
  28561. * Represent a list of observers registered to multiple Observables object.
  28562. */
  28563. class MultiObserver<T> {
  28564. private _observers;
  28565. private _observables;
  28566. /**
  28567. * Release associated resources
  28568. */
  28569. dispose(): void;
  28570. /**
  28571. * Raise a callback when one of the observable will notify
  28572. * @param observables defines a list of observables to watch
  28573. * @param callback defines the callback to call on notification
  28574. * @param mask defines the mask used to filter notifications
  28575. * @param scope defines the current scope used to restore the JS context
  28576. * @returns the new MultiObserver
  28577. */
  28578. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  28579. }
  28580. /**
  28581. * The Observable class is a simple implementation of the Observable pattern.
  28582. *
  28583. * 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.
  28584. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  28585. * 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).
  28586. * 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.
  28587. */
  28588. class Observable<T> {
  28589. private _observers;
  28590. private _eventState;
  28591. private _onObserverAdded;
  28592. /**
  28593. * Creates a new observable
  28594. * @param onObserverAdded defines a callback to call when a new observer is added
  28595. */
  28596. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  28597. /**
  28598. * Create a new Observer with the specified callback
  28599. * @param callback the callback that will be executed for that Observer
  28600. * @param mask the mask used to filter observers
  28601. * @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.
  28602. * @param scope optional scope for the callback to be called from
  28603. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  28604. * @returns the new observer created for the callback
  28605. */
  28606. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  28607. /**
  28608. * Create a new Observer with the specified callback and unregisters after the next notification
  28609. * @param callback the callback that will be executed for that Observer
  28610. * @returns the new observer created for the callback
  28611. */
  28612. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28613. /**
  28614. * Remove an Observer from the Observable object
  28615. * @param observer the instance of the Observer to remove
  28616. * @returns false if it doesn't belong to this Observable
  28617. */
  28618. remove(observer: Nullable<Observer<T>>): boolean;
  28619. /**
  28620. * Remove a callback from the Observable object
  28621. * @param callback the callback to remove
  28622. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28623. * @returns false if it doesn't belong to this Observable
  28624. */
  28625. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28626. private _deferUnregister(observer);
  28627. /**
  28628. * Notify all Observers by calling their respective callback with the given data
  28629. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28630. * @param eventData defines the data to send to all observers
  28631. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28632. * @param target defines the original target of the state
  28633. * @param currentTarget defines the current target of the state
  28634. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28635. */
  28636. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28637. /**
  28638. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28639. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28640. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28641. * and it is crucial that all callbacks will be executed.
  28642. * The order of the callbacks is kept, callbacks are not executed parallel.
  28643. *
  28644. * @param eventData The data to be sent to each callback
  28645. * @param mask is used to filter observers defaults to -1
  28646. * @param target defines the callback target (see EventState)
  28647. * @param currentTarget defines he current object in the bubbling phase
  28648. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28649. */
  28650. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28651. /**
  28652. * Notify a specific observer
  28653. * @param observer defines the observer to notify
  28654. * @param eventData defines the data to be sent to each callback
  28655. * @param mask is used to filter observers defaults to -1
  28656. */
  28657. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28658. /**
  28659. * Gets a boolean indicating if the observable has at least one observer
  28660. * @returns true is the Observable has at least one Observer registered
  28661. */
  28662. hasObservers(): boolean;
  28663. /**
  28664. * Clear the list of observers
  28665. */
  28666. clear(): void;
  28667. /**
  28668. * Clone the current observable
  28669. * @returns a new observable
  28670. */
  28671. clone(): Observable<T>;
  28672. /**
  28673. * Does this observable handles observer registered with a given mask
  28674. * @param mask defines the mask to be tested
  28675. * @return whether or not one observer registered with the given mask is handeled
  28676. **/
  28677. hasSpecificMask(mask?: number): boolean;
  28678. }
  28679. }
  28680. declare module BABYLON {
  28681. /**
  28682. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28683. */
  28684. class PerformanceMonitor {
  28685. private _enabled;
  28686. private _rollingFrameTime;
  28687. private _lastFrameTimeMs;
  28688. /**
  28689. * constructor
  28690. * @param frameSampleSize The number of samples required to saturate the sliding window
  28691. */
  28692. constructor(frameSampleSize?: number);
  28693. /**
  28694. * Samples current frame
  28695. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28696. */
  28697. sampleFrame(timeMs?: number): void;
  28698. /**
  28699. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28700. * @return Average frame time in milliseconds
  28701. */
  28702. readonly averageFrameTime: number;
  28703. /**
  28704. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28705. * @return Frame time variance in milliseconds squared
  28706. */
  28707. readonly averageFrameTimeVariance: number;
  28708. /**
  28709. * Returns the frame time of the most recent frame
  28710. * @return Frame time in milliseconds
  28711. */
  28712. readonly instantaneousFrameTime: number;
  28713. /**
  28714. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28715. * @return Framerate in frames per second
  28716. */
  28717. readonly averageFPS: number;
  28718. /**
  28719. * Returns the average framerate in frames per second using the most recent frame time
  28720. * @return Framerate in frames per second
  28721. */
  28722. readonly instantaneousFPS: number;
  28723. /**
  28724. * Returns true if enough samples have been taken to completely fill the sliding window
  28725. * @return true if saturated
  28726. */
  28727. readonly isSaturated: boolean;
  28728. /**
  28729. * Enables contributions to the sliding window sample set
  28730. */
  28731. enable(): void;
  28732. /**
  28733. * Disables contributions to the sliding window sample set
  28734. * Samples will not be interpolated over the disabled period
  28735. */
  28736. disable(): void;
  28737. /**
  28738. * Returns true if sampling is enabled
  28739. * @return true if enabled
  28740. */
  28741. readonly isEnabled: boolean;
  28742. /**
  28743. * Resets performance monitor
  28744. */
  28745. reset(): void;
  28746. }
  28747. /**
  28748. * RollingAverage
  28749. *
  28750. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28751. */
  28752. class RollingAverage {
  28753. /**
  28754. * Current average
  28755. */
  28756. average: number;
  28757. /**
  28758. * Current variance
  28759. */
  28760. variance: number;
  28761. protected _samples: Array<number>;
  28762. protected _sampleCount: number;
  28763. protected _pos: number;
  28764. protected _m2: number;
  28765. /**
  28766. * constructor
  28767. * @param length The number of samples required to saturate the sliding window
  28768. */
  28769. constructor(length: number);
  28770. /**
  28771. * Adds a sample to the sample set
  28772. * @param v The sample value
  28773. */
  28774. add(v: number): void;
  28775. /**
  28776. * Returns previously added values or null if outside of history or outside the sliding window domain
  28777. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28778. * @return Value previously recorded with add() or null if outside of range
  28779. */
  28780. history(i: number): number;
  28781. /**
  28782. * Returns true if enough samples have been taken to completely fill the sliding window
  28783. * @return true if sample-set saturated
  28784. */
  28785. isSaturated(): boolean;
  28786. /**
  28787. * Resets the rolling average (equivalent to 0 samples taken so far)
  28788. */
  28789. reset(): void;
  28790. /**
  28791. * Wraps a value around the sample range boundaries
  28792. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28793. * @return Wrapped position in sample range
  28794. */
  28795. protected _wrapPosition(i: number): number;
  28796. }
  28797. }
  28798. declare module BABYLON {
  28799. /**
  28800. * Helper class that provides a small promise polyfill
  28801. */
  28802. class PromisePolyfill {
  28803. /**
  28804. * Static function used to check if the polyfill is required
  28805. * If this is the case then the function will inject the polyfill to window.Promise
  28806. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28807. */
  28808. static Apply(force?: boolean): void;
  28809. }
  28810. }
  28811. declare module BABYLON {
  28812. /**
  28813. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28815. */
  28816. class SceneOptimization {
  28817. /**
  28818. * Defines the priority of this optimization (0 by default which means first in the list)
  28819. */
  28820. priority: number;
  28821. /**
  28822. * Gets a string describing the action executed by the current optimization
  28823. * @returns description string
  28824. */
  28825. getDescription(): string;
  28826. /**
  28827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28828. * @param scene defines the current scene where to apply this optimization
  28829. * @param optimizer defines the current optimizer
  28830. * @returns true if everything that can be done was applied
  28831. */
  28832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28833. /**
  28834. * Creates the SceneOptimization object
  28835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28836. * @param desc defines the description associated with the optimization
  28837. */
  28838. constructor(
  28839. /**
  28840. * Defines the priority of this optimization (0 by default which means first in the list)
  28841. */
  28842. priority?: number);
  28843. }
  28844. /**
  28845. * Defines an optimization used to reduce the size of render target textures
  28846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28847. */
  28848. class TextureOptimization extends SceneOptimization {
  28849. /**
  28850. * Defines the priority of this optimization (0 by default which means first in the list)
  28851. */
  28852. priority: number;
  28853. /**
  28854. * 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
  28855. */
  28856. maximumSize: number;
  28857. /**
  28858. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28859. */
  28860. step: number;
  28861. /**
  28862. * Gets a string describing the action executed by the current optimization
  28863. * @returns description string
  28864. */
  28865. getDescription(): string;
  28866. /**
  28867. * Creates the TextureOptimization object
  28868. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28869. * @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
  28870. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28871. */
  28872. constructor(
  28873. /**
  28874. * Defines the priority of this optimization (0 by default which means first in the list)
  28875. */
  28876. priority?: number,
  28877. /**
  28878. * 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
  28879. */
  28880. maximumSize?: number,
  28881. /**
  28882. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28883. */
  28884. step?: number);
  28885. /**
  28886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28887. * @param scene defines the current scene where to apply this optimization
  28888. * @param optimizer defines the current optimizer
  28889. * @returns true if everything that can be done was applied
  28890. */
  28891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28892. }
  28893. /**
  28894. * Defines an optimization used to increase or decrease the rendering resolution
  28895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28896. */
  28897. class HardwareScalingOptimization extends SceneOptimization {
  28898. /**
  28899. * Defines the priority of this optimization (0 by default which means first in the list)
  28900. */
  28901. priority: number;
  28902. /**
  28903. * Defines the maximum scale to use (2 by default)
  28904. */
  28905. maximumScale: number;
  28906. /**
  28907. * Defines the step to use between two passes (0.5 by default)
  28908. */
  28909. step: number;
  28910. private _currentScale;
  28911. private _directionOffset;
  28912. /**
  28913. * Gets a string describing the action executed by the current optimization
  28914. * @return description string
  28915. */
  28916. getDescription(): string;
  28917. /**
  28918. * Creates the HardwareScalingOptimization object
  28919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28920. * @param maximumScale defines the maximum scale to use (2 by default)
  28921. * @param step defines the step to use between two passes (0.5 by default)
  28922. */
  28923. constructor(
  28924. /**
  28925. * Defines the priority of this optimization (0 by default which means first in the list)
  28926. */
  28927. priority?: number,
  28928. /**
  28929. * Defines the maximum scale to use (2 by default)
  28930. */
  28931. maximumScale?: number,
  28932. /**
  28933. * Defines the step to use between two passes (0.5 by default)
  28934. */
  28935. step?: number);
  28936. /**
  28937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28938. * @param scene defines the current scene where to apply this optimization
  28939. * @param optimizer defines the current optimizer
  28940. * @returns true if everything that can be done was applied
  28941. */
  28942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28943. }
  28944. /**
  28945. * Defines an optimization used to remove shadows
  28946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28947. */
  28948. class ShadowsOptimization extends SceneOptimization {
  28949. /**
  28950. * Gets a string describing the action executed by the current optimization
  28951. * @return description string
  28952. */
  28953. getDescription(): string;
  28954. /**
  28955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28956. * @param scene defines the current scene where to apply this optimization
  28957. * @param optimizer defines the current optimizer
  28958. * @returns true if everything that can be done was applied
  28959. */
  28960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28961. }
  28962. /**
  28963. * Defines an optimization used to turn post-processes off
  28964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28965. */
  28966. class PostProcessesOptimization extends SceneOptimization {
  28967. /**
  28968. * Gets a string describing the action executed by the current optimization
  28969. * @return description string
  28970. */
  28971. getDescription(): string;
  28972. /**
  28973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28974. * @param scene defines the current scene where to apply this optimization
  28975. * @param optimizer defines the current optimizer
  28976. * @returns true if everything that can be done was applied
  28977. */
  28978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28979. }
  28980. /**
  28981. * Defines an optimization used to turn lens flares off
  28982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28983. */
  28984. class LensFlaresOptimization extends SceneOptimization {
  28985. /**
  28986. * Gets a string describing the action executed by the current optimization
  28987. * @return description string
  28988. */
  28989. getDescription(): string;
  28990. /**
  28991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28992. * @param scene defines the current scene where to apply this optimization
  28993. * @param optimizer defines the current optimizer
  28994. * @returns true if everything that can be done was applied
  28995. */
  28996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28997. }
  28998. /**
  28999. * Defines an optimization based on user defined callback.
  29000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29001. */
  29002. class CustomOptimization extends SceneOptimization {
  29003. /**
  29004. * Callback called to apply the custom optimization.
  29005. */
  29006. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  29007. /**
  29008. * Callback called to get custom description
  29009. */
  29010. onGetDescription: () => string;
  29011. /**
  29012. * Gets a string describing the action executed by the current optimization
  29013. * @returns description string
  29014. */
  29015. getDescription(): string;
  29016. /**
  29017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29018. * @param scene defines the current scene where to apply this optimization
  29019. * @param optimizer defines the current optimizer
  29020. * @returns true if everything that can be done was applied
  29021. */
  29022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29023. }
  29024. /**
  29025. * Defines an optimization used to turn particles off
  29026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29027. */
  29028. class ParticlesOptimization extends SceneOptimization {
  29029. /**
  29030. * Gets a string describing the action executed by the current optimization
  29031. * @return description string
  29032. */
  29033. getDescription(): string;
  29034. /**
  29035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29036. * @param scene defines the current scene where to apply this optimization
  29037. * @param optimizer defines the current optimizer
  29038. * @returns true if everything that can be done was applied
  29039. */
  29040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29041. }
  29042. /**
  29043. * Defines an optimization used to turn render targets off
  29044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29045. */
  29046. class RenderTargetsOptimization extends SceneOptimization {
  29047. /**
  29048. * Gets a string describing the action executed by the current optimization
  29049. * @return description string
  29050. */
  29051. getDescription(): string;
  29052. /**
  29053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29054. * @param scene defines the current scene where to apply this optimization
  29055. * @param optimizer defines the current optimizer
  29056. * @returns true if everything that can be done was applied
  29057. */
  29058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29059. }
  29060. /**
  29061. * Defines an optimization used to merge meshes with compatible materials
  29062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29063. */
  29064. class MergeMeshesOptimization extends SceneOptimization {
  29065. private static _UpdateSelectionTree;
  29066. /**
  29067. * Gets or sets a boolean which defines if optimization octree has to be updated
  29068. */
  29069. /**
  29070. * Gets or sets a boolean which defines if optimization octree has to be updated
  29071. */
  29072. static UpdateSelectionTree: boolean;
  29073. /**
  29074. * Gets a string describing the action executed by the current optimization
  29075. * @return description string
  29076. */
  29077. getDescription(): string;
  29078. private _canBeMerged;
  29079. /**
  29080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29081. * @param scene defines the current scene where to apply this optimization
  29082. * @param optimizer defines the current optimizer
  29083. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  29084. * @returns true if everything that can be done was applied
  29085. */
  29086. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  29087. }
  29088. /**
  29089. * Defines a list of options used by SceneOptimizer
  29090. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29091. */
  29092. class SceneOptimizerOptions {
  29093. /**
  29094. * Defines the target frame rate to reach (60 by default)
  29095. */
  29096. targetFrameRate: number;
  29097. /**
  29098. * Defines the interval between two checkes (2000ms by default)
  29099. */
  29100. trackerDuration: number;
  29101. /**
  29102. * Gets the list of optimizations to apply
  29103. */
  29104. optimizations: SceneOptimization[];
  29105. /**
  29106. * Creates a new list of options used by SceneOptimizer
  29107. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  29108. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  29109. */
  29110. constructor(
  29111. /**
  29112. * Defines the target frame rate to reach (60 by default)
  29113. */
  29114. targetFrameRate?: number,
  29115. /**
  29116. * Defines the interval between two checkes (2000ms by default)
  29117. */
  29118. trackerDuration?: number);
  29119. /**
  29120. * Add a new optimization
  29121. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  29122. * @returns the current SceneOptimizerOptions
  29123. */
  29124. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  29125. /**
  29126. * Add a new custom optimization
  29127. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  29128. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  29129. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29130. * @returns the current SceneOptimizerOptions
  29131. */
  29132. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  29133. /**
  29134. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  29135. * @param targetFrameRate defines the target frame rate (60 by default)
  29136. * @returns a SceneOptimizerOptions object
  29137. */
  29138. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29139. /**
  29140. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  29141. * @param targetFrameRate defines the target frame rate (60 by default)
  29142. * @returns a SceneOptimizerOptions object
  29143. */
  29144. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29145. /**
  29146. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  29147. * @param targetFrameRate defines the target frame rate (60 by default)
  29148. * @returns a SceneOptimizerOptions object
  29149. */
  29150. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29151. }
  29152. /**
  29153. * Class used to run optimizations in order to reach a target frame rate
  29154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29155. */
  29156. class SceneOptimizer implements IDisposable {
  29157. private _isRunning;
  29158. private _options;
  29159. private _scene;
  29160. private _currentPriorityLevel;
  29161. private _targetFrameRate;
  29162. private _trackerDuration;
  29163. private _currentFrameRate;
  29164. private _sceneDisposeObserver;
  29165. private _improvementMode;
  29166. /**
  29167. * Defines an observable called when the optimizer reaches the target frame rate
  29168. */
  29169. onSuccessObservable: Observable<SceneOptimizer>;
  29170. /**
  29171. * Defines an observable called when the optimizer enables an optimization
  29172. */
  29173. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  29174. /**
  29175. * Defines an observable called when the optimizer is not able to reach the target frame rate
  29176. */
  29177. onFailureObservable: Observable<SceneOptimizer>;
  29178. /**
  29179. * Gets a boolean indicating if the optimizer is in improvement mode
  29180. */
  29181. readonly isInImprovementMode: boolean;
  29182. /**
  29183. * Gets the current priority level (0 at start)
  29184. */
  29185. readonly currentPriorityLevel: number;
  29186. /**
  29187. * Gets the current frame rate checked by the SceneOptimizer
  29188. */
  29189. readonly currentFrameRate: number;
  29190. /**
  29191. * Gets or sets the current target frame rate (60 by default)
  29192. */
  29193. /**
  29194. * Gets or sets the current target frame rate (60 by default)
  29195. */
  29196. targetFrameRate: number;
  29197. /**
  29198. * Gets or sets the current interval between two checks (every 2000ms by default)
  29199. */
  29200. /**
  29201. * Gets or sets the current interval between two checks (every 2000ms by default)
  29202. */
  29203. trackerDuration: number;
  29204. /**
  29205. * Gets the list of active optimizations
  29206. */
  29207. readonly optimizations: SceneOptimization[];
  29208. /**
  29209. * Creates a new SceneOptimizer
  29210. * @param scene defines the scene to work on
  29211. * @param options defines the options to use with the SceneOptimizer
  29212. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  29213. * @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)
  29214. */
  29215. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  29216. /**
  29217. * Stops the current optimizer
  29218. */
  29219. stop(): void;
  29220. /**
  29221. * Reset the optimizer to initial step (current priority level = 0)
  29222. */
  29223. reset(): void;
  29224. /**
  29225. * Start the optimizer. By default it will try to reach a specific framerate
  29226. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  29227. */
  29228. start(): void;
  29229. private _checkCurrentState();
  29230. /**
  29231. * Release all resources
  29232. */
  29233. dispose(): void;
  29234. /**
  29235. * Helper function to create a SceneOptimizer with one single line of code
  29236. * @param scene defines the scene to work on
  29237. * @param options defines the options to use with the SceneOptimizer
  29238. * @param onSuccess defines a callback to call on success
  29239. * @param onFailure defines a callback to call on failure
  29240. * @returns the new SceneOptimizer object
  29241. */
  29242. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  29243. }
  29244. }
  29245. declare module BABYLON {
  29246. class SceneSerializer {
  29247. static ClearCache(): void;
  29248. static Serialize(scene: Scene): any;
  29249. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  29250. }
  29251. }
  29252. declare module BABYLON {
  29253. class SmartArray<T> {
  29254. data: Array<T>;
  29255. length: number;
  29256. protected _id: number;
  29257. [index: number]: T;
  29258. constructor(capacity: number);
  29259. push(value: T): void;
  29260. forEach(func: (content: T) => void): void;
  29261. sort(compareFn: (a: T, b: T) => number): void;
  29262. reset(): void;
  29263. dispose(): void;
  29264. concat(array: any): void;
  29265. indexOf(value: T): number;
  29266. contains(value: T): boolean;
  29267. private static _GlobalId;
  29268. }
  29269. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  29270. private _duplicateId;
  29271. [index: number]: T;
  29272. push(value: T): void;
  29273. pushNoDuplicate(value: T): boolean;
  29274. reset(): void;
  29275. concatWithNoDuplicate(array: any): void;
  29276. }
  29277. }
  29278. declare module BABYLON {
  29279. /**
  29280. * This class implement a typical dictionary using a string as key and the generic type T as value.
  29281. * The underlying implementation relies on an associative array to ensure the best performances.
  29282. * The value can be anything including 'null' but except 'undefined'
  29283. */
  29284. class StringDictionary<T> {
  29285. /**
  29286. * This will clear this dictionary and copy the content from the 'source' one.
  29287. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  29288. * @param source the dictionary to take the content from and copy to this dictionary
  29289. */
  29290. copyFrom(source: StringDictionary<T>): void;
  29291. /**
  29292. * Get a value based from its key
  29293. * @param key the given key to get the matching value from
  29294. * @return the value if found, otherwise undefined is returned
  29295. */
  29296. get(key: string): T | undefined;
  29297. /**
  29298. * Get a value from its key or add it if it doesn't exist.
  29299. * This method will ensure you that a given key/data will be present in the dictionary.
  29300. * @param key the given key to get the matching value from
  29301. * @param factory the factory that will create the value if the key is not present in the dictionary.
  29302. * The factory will only be invoked if there's no data for the given key.
  29303. * @return the value corresponding to the key.
  29304. */
  29305. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  29306. /**
  29307. * Get a value from its key if present in the dictionary otherwise add it
  29308. * @param key the key to get the value from
  29309. * @param val if there's no such key/value pair in the dictionary add it with this value
  29310. * @return the value corresponding to the key
  29311. */
  29312. getOrAdd(key: string, val: T): T;
  29313. /**
  29314. * Check if there's a given key in the dictionary
  29315. * @param key the key to check for
  29316. * @return true if the key is present, false otherwise
  29317. */
  29318. contains(key: string): boolean;
  29319. /**
  29320. * Add a new key and its corresponding value
  29321. * @param key the key to add
  29322. * @param value the value corresponding to the key
  29323. * @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
  29324. */
  29325. add(key: string, value: T): boolean;
  29326. set(key: string, value: T): boolean;
  29327. /**
  29328. * Get the element of the given key and remove it from the dictionary
  29329. * @param key
  29330. */
  29331. getAndRemove(key: string): Nullable<T>;
  29332. /**
  29333. * Remove a key/value from the dictionary.
  29334. * @param key the key to remove
  29335. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  29336. */
  29337. remove(key: string): boolean;
  29338. /**
  29339. * Clear the whole content of the dictionary
  29340. */
  29341. clear(): void;
  29342. readonly count: number;
  29343. /**
  29344. * Execute a callback on each key/val of the dictionary.
  29345. * Note that you can remove any element in this dictionary in the callback implementation
  29346. * @param callback the callback to execute on a given key/value pair
  29347. */
  29348. forEach(callback: (key: string, val: T) => void): void;
  29349. /**
  29350. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  29351. * If the callback returns null or undefined the method will iterate to the next key/value pair
  29352. * Note that you can remove any element in this dictionary in the callback implementation
  29353. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  29354. */
  29355. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  29356. private _count;
  29357. private _data;
  29358. }
  29359. }
  29360. declare module BABYLON {
  29361. class Tags {
  29362. static EnableFor(obj: any): void;
  29363. static DisableFor(obj: any): void;
  29364. static HasTags(obj: any): boolean;
  29365. static GetTags(obj: any, asString?: boolean): any;
  29366. static AddTagsTo(obj: any, tagsString: string): void;
  29367. static _AddTagTo(obj: any, tag: string): void;
  29368. static RemoveTagsFrom(obj: any, tagsString: string): void;
  29369. static _RemoveTagFrom(obj: any, tag: string): void;
  29370. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  29371. }
  29372. }
  29373. declare module BABYLON {
  29374. class TextureTools {
  29375. /**
  29376. * Uses the GPU to create a copy texture rescaled at a given size
  29377. * @param texture Texture to copy from
  29378. * @param width Desired width
  29379. * @param height Desired height
  29380. * @return Generated texture
  29381. */
  29382. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  29383. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  29384. private static _environmentBRDFBase64Texture;
  29385. }
  29386. }
  29387. declare module BABYLON {
  29388. class TGATools {
  29389. private static _TYPE_INDEXED;
  29390. private static _TYPE_RGB;
  29391. private static _TYPE_GREY;
  29392. private static _TYPE_RLE_INDEXED;
  29393. private static _TYPE_RLE_RGB;
  29394. private static _TYPE_RLE_GREY;
  29395. private static _ORIGIN_MASK;
  29396. private static _ORIGIN_SHIFT;
  29397. private static _ORIGIN_BL;
  29398. private static _ORIGIN_BR;
  29399. private static _ORIGIN_UL;
  29400. private static _ORIGIN_UR;
  29401. static GetTGAHeader(data: Uint8Array): any;
  29402. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  29403. 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;
  29404. 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;
  29405. 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;
  29406. 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;
  29407. 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;
  29408. 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;
  29409. }
  29410. }
  29411. declare module BABYLON {
  29412. interface IAnimatable {
  29413. animations: Array<Animation>;
  29414. }
  29415. class LoadFileError extends Error {
  29416. request: XMLHttpRequest | undefined;
  29417. private static _setPrototypeOf;
  29418. constructor(message: string, request?: XMLHttpRequest | undefined);
  29419. }
  29420. class RetryStrategy {
  29421. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29422. }
  29423. interface IFileRequest {
  29424. /**
  29425. * Raised when the request is complete (success or error).
  29426. */
  29427. onCompleteObservable: Observable<IFileRequest>;
  29428. /**
  29429. * Aborts the request for a file.
  29430. */
  29431. abort: () => void;
  29432. }
  29433. class Tools {
  29434. static BaseUrl: string;
  29435. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29436. /**
  29437. * Default behaviour for cors in the application.
  29438. * It can be a string if the expected behavior is identical in the entire app.
  29439. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29440. */
  29441. static CorsBehavior: string | ((url: string | string[]) => string);
  29442. static UseFallbackTexture: boolean;
  29443. /**
  29444. * Use this object to register external classes like custom textures or material
  29445. * to allow the laoders to instantiate them
  29446. */
  29447. static RegisteredExternalClasses: {
  29448. [key: string]: Object;
  29449. };
  29450. static fallbackTexture: string;
  29451. /**
  29452. * Interpolates between a and b via alpha
  29453. * @param a The lower value (returned when alpha = 0)
  29454. * @param b The upper value (returned when alpha = 1)
  29455. * @param alpha The interpolation-factor
  29456. * @return The mixed value
  29457. */
  29458. static Mix(a: number, b: number, alpha: number): number;
  29459. static Instantiate(className: string): any;
  29460. /**
  29461. * Provides a slice function that will work even on IE
  29462. * @param data defines the array to slice
  29463. * @param start defines the start of the data (optional)
  29464. * @param end defines the end of the data (optional)
  29465. * @returns the new sliced array
  29466. */
  29467. static Slice<T>(data: T, start?: number, end?: number): T;
  29468. static SetImmediate(action: () => void): void;
  29469. static IsExponentOfTwo(value: number): boolean;
  29470. private static _tmpFloatArray;
  29471. /**
  29472. * Returns the nearest 32-bit single precision float representation of a Number
  29473. * @param value A Number. If the parameter is of a different type, it will get converted
  29474. * to a number or to NaN if it cannot be converted
  29475. * @returns number
  29476. */
  29477. static FloatRound(value: number): number;
  29478. /**
  29479. * Find the next highest power of two.
  29480. * @param x Number to start search from.
  29481. * @return Next highest power of two.
  29482. */
  29483. static CeilingPOT(x: number): number;
  29484. /**
  29485. * Find the next lowest power of two.
  29486. * @param x Number to start search from.
  29487. * @return Next lowest power of two.
  29488. */
  29489. static FloorPOT(x: number): number;
  29490. /**
  29491. * Find the nearest power of two.
  29492. * @param x Number to start search from.
  29493. * @return Next nearest power of two.
  29494. */
  29495. static NearestPOT(x: number): number;
  29496. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29497. static GetFilename(path: string): string;
  29498. /**
  29499. * Extracts the "folder" part of a path (everything before the filename).
  29500. * @param uri The URI to extract the info from
  29501. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29502. * @returns The "folder" part of the path
  29503. */
  29504. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29505. static GetDOMTextContent(element: HTMLElement): string;
  29506. static ToDegrees(angle: number): number;
  29507. static ToRadians(angle: number): number;
  29508. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29509. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29510. minimum: Vector3;
  29511. maximum: Vector3;
  29512. };
  29513. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29514. minimum: Vector3;
  29515. maximum: Vector3;
  29516. };
  29517. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  29518. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  29519. minimum: Vector2;
  29520. maximum: Vector2;
  29521. };
  29522. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29523. static GetPointerPrefix(): string;
  29524. /**
  29525. * @param func - the function to be called
  29526. * @param requester - the object that will request the next frame. Falls back to window.
  29527. */
  29528. static QueueNewFrame(func: () => void, requester?: any): number;
  29529. static RequestFullscreen(element: HTMLElement): void;
  29530. static ExitFullscreen(): void;
  29531. static SetCorsBehavior(url: string | string[], element: {
  29532. crossOrigin: string | null;
  29533. }): void;
  29534. static CleanUrl(url: string): string;
  29535. static PreprocessUrl: (url: string) => string;
  29536. /**
  29537. * Loads an image as an HTMLImageElement.
  29538. * @param input url string, ArrayBuffer, or Blob to load
  29539. * @param onLoad callback called when the image successfully loads
  29540. * @param onError callback called when the image fails to load
  29541. * @param database database for caching
  29542. * @returns the HTMLImageElement of the loaded image
  29543. */
  29544. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  29545. 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;
  29546. /**
  29547. * Load a script (identified by an url). When the url returns, the
  29548. * content of this file is added into a new script element, attached to the DOM (body element)
  29549. */
  29550. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29551. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29552. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29553. static FileAsURL(content: string): string;
  29554. static Format(value: number, decimals?: number): string;
  29555. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29556. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29557. static IsEmpty(obj: any): boolean;
  29558. static RegisterTopRootEvents(events: {
  29559. name: string;
  29560. handler: Nullable<(e: FocusEvent) => any>;
  29561. }[]): void;
  29562. static UnregisterTopRootEvents(events: {
  29563. name: string;
  29564. handler: Nullable<(e: FocusEvent) => any>;
  29565. }[]): void;
  29566. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29567. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29568. /**
  29569. * Downloads a blob in the browser
  29570. * @param blob defines the blob to download
  29571. * @param fileName defines the name of the downloaded file
  29572. */
  29573. static Download(blob: Blob, fileName: string): void;
  29574. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29575. /**
  29576. * Generates an image screenshot from the specified camera.
  29577. *
  29578. * @param engine The engine to use for rendering
  29579. * @param camera The camera to use for rendering
  29580. * @param size This parameter can be set to a single number or to an object with the
  29581. * following (optional) properties: precision, width, height. If a single number is passed,
  29582. * it will be used for both width and height. If an object is passed, the screenshot size
  29583. * will be derived from the parameters. The precision property is a multiplier allowing
  29584. * rendering at a higher or lower resolution.
  29585. * @param successCallback The callback receives a single parameter which contains the
  29586. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29587. * src parameter of an <img> to display it.
  29588. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29589. * Check your browser for supported MIME types.
  29590. * @param samples Texture samples (default: 1)
  29591. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29592. * @param fileName A name for for the downloaded file.
  29593. * @constructor
  29594. */
  29595. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29596. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  29597. /**
  29598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29599. * Be aware Math.random() could cause collisions, but:
  29600. * "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"
  29601. */
  29602. static RandomId(): string;
  29603. /**
  29604. * Test if the given uri is a base64 string.
  29605. * @param uri The uri to test
  29606. * @return True if the uri is a base64 string or false otherwise.
  29607. */
  29608. static IsBase64(uri: string): boolean;
  29609. /**
  29610. * Decode the given base64 uri.
  29611. * @param uri The uri to decode
  29612. * @return The decoded base64 data.
  29613. */
  29614. static DecodeBase64(uri: string): ArrayBuffer;
  29615. private static _NoneLogLevel;
  29616. private static _MessageLogLevel;
  29617. private static _WarningLogLevel;
  29618. private static _ErrorLogLevel;
  29619. private static _LogCache;
  29620. static errorsCount: number;
  29621. static OnNewCacheEntry: (entry: string) => void;
  29622. static readonly NoneLogLevel: number;
  29623. static readonly MessageLogLevel: number;
  29624. static readonly WarningLogLevel: number;
  29625. static readonly ErrorLogLevel: number;
  29626. static readonly AllLogLevel: number;
  29627. private static _AddLogEntry(entry);
  29628. private static _FormatMessage(message);
  29629. private static _LogDisabled(message);
  29630. private static _LogEnabled(message);
  29631. private static _WarnDisabled(message);
  29632. private static _WarnEnabled(message);
  29633. private static _ErrorDisabled(message);
  29634. private static _ErrorEnabled(message);
  29635. static Log: (message: string) => void;
  29636. static Warn: (message: string) => void;
  29637. static Error: (message: string) => void;
  29638. static readonly LogCache: string;
  29639. static ClearLogCache(): void;
  29640. static LogLevels: number;
  29641. static IsWindowObjectExist(): boolean;
  29642. private static _PerformanceNoneLogLevel;
  29643. private static _PerformanceUserMarkLogLevel;
  29644. private static _PerformanceConsoleLogLevel;
  29645. private static _performance;
  29646. static readonly PerformanceNoneLogLevel: number;
  29647. static readonly PerformanceUserMarkLogLevel: number;
  29648. static readonly PerformanceConsoleLogLevel: number;
  29649. static PerformanceLogLevel: number;
  29650. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29651. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29652. static _StartUserMark(counterName: string, condition?: boolean): void;
  29653. static _EndUserMark(counterName: string, condition?: boolean): void;
  29654. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29655. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29656. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29657. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29658. static readonly Now: number;
  29659. /**
  29660. * This method will return the name of the class used to create the instance of the given object.
  29661. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29662. * @param object the object to get the class name from
  29663. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29664. */
  29665. static GetClassName(object: any, isType?: boolean): string;
  29666. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29667. /**
  29668. * This method will return the name of the full name of the class, including its owning module (if any).
  29669. * 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).
  29670. * @param object the object to get the class name from
  29671. * @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.
  29672. */
  29673. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29674. /**
  29675. * 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.
  29676. * @param array
  29677. */
  29678. static arrayOrStringFeeder(array: any): (i: number) => number;
  29679. /**
  29680. * Compute the hashCode of a stream of number
  29681. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29682. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29683. * @return the hash code computed
  29684. */
  29685. static hashCodeFromStream(feeder: (index: number) => number): number;
  29686. /**
  29687. * Returns a promise that resolves after the given amount of time.
  29688. * @param delay Number of milliseconds to delay
  29689. * @returns Promise that resolves after the given amount of time
  29690. */
  29691. static DelayAsync(delay: number): Promise<void>;
  29692. }
  29693. /**
  29694. * This class is used to track a performance counter which is number based.
  29695. * The user has access to many properties which give statistics of different nature
  29696. *
  29697. * The implementer can track two kinds of Performance Counter: time and count
  29698. * 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.
  29699. * 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.
  29700. */
  29701. class PerfCounter {
  29702. static Enabled: boolean;
  29703. /**
  29704. * Returns the smallest value ever
  29705. */
  29706. readonly min: number;
  29707. /**
  29708. * Returns the biggest value ever
  29709. */
  29710. readonly max: number;
  29711. /**
  29712. * Returns the average value since the performance counter is running
  29713. */
  29714. readonly average: number;
  29715. /**
  29716. * Returns the average value of the last second the counter was monitored
  29717. */
  29718. readonly lastSecAverage: number;
  29719. /**
  29720. * Returns the current value
  29721. */
  29722. readonly current: number;
  29723. readonly total: number;
  29724. readonly count: number;
  29725. constructor();
  29726. /**
  29727. * Call this method to start monitoring a new frame.
  29728. * 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.
  29729. */
  29730. fetchNewFrame(): void;
  29731. /**
  29732. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29733. * @param newCount the count value to add to the monitored count
  29734. * @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.
  29735. */
  29736. addCount(newCount: number, fetchResult: boolean): void;
  29737. /**
  29738. * Start monitoring this performance counter
  29739. */
  29740. beginMonitoring(): void;
  29741. /**
  29742. * Compute the time lapsed since the previous beginMonitoring() call.
  29743. * @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
  29744. */
  29745. endMonitoring(newFrame?: boolean): void;
  29746. private _fetchResult();
  29747. private _startMonitoringTime;
  29748. private _min;
  29749. private _max;
  29750. private _average;
  29751. private _current;
  29752. private _totalValueCount;
  29753. private _totalAccumulated;
  29754. private _lastSecAverage;
  29755. private _lastSecAccumulated;
  29756. private _lastSecTime;
  29757. private _lastSecValueCount;
  29758. }
  29759. /**
  29760. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29761. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29762. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29763. * @param name The name of the class, case should be preserved
  29764. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29765. */
  29766. function className(name: string, module?: string): (target: Object) => void;
  29767. /**
  29768. * An implementation of a loop for asynchronous functions.
  29769. */
  29770. class AsyncLoop {
  29771. iterations: number;
  29772. private _fn;
  29773. private _successCallback;
  29774. index: number;
  29775. private _done;
  29776. /**
  29777. * Constroctor.
  29778. * @param iterations the number of iterations.
  29779. * @param _fn the function to run each iteration
  29780. * @param _successCallback the callback that will be called upon succesful execution
  29781. * @param offset starting offset.
  29782. */
  29783. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  29784. /**
  29785. * Execute the next iteration. Must be called after the last iteration was finished.
  29786. */
  29787. executeNext(): void;
  29788. /**
  29789. * Break the loop and run the success callback.
  29790. */
  29791. breakLoop(): void;
  29792. /**
  29793. * Helper function
  29794. */
  29795. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  29796. /**
  29797. * A for-loop that will run a given number of iterations synchronous and the rest async.
  29798. * @param iterations total number of iterations
  29799. * @param syncedIterations number of synchronous iterations in each async iteration.
  29800. * @param fn the function to call each iteration.
  29801. * @param callback a success call back that will be called when iterating stops.
  29802. * @param breakFunction a break condition (optional)
  29803. * @param timeout timeout settings for the setTimeout function. default - 0.
  29804. * @constructor
  29805. */
  29806. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  29807. }
  29808. }
  29809. declare module BABYLON {
  29810. /**
  29811. * Defines the potential axis of a Joystick
  29812. */
  29813. enum JoystickAxis {
  29814. /** X axis */
  29815. X = 0,
  29816. /** Y axis */
  29817. Y = 1,
  29818. /** Z axis */
  29819. Z = 2,
  29820. }
  29821. /**
  29822. * Class used to define virtual joystick (used in touch mode)
  29823. */
  29824. class VirtualJoystick {
  29825. /**
  29826. * Gets or sets a boolean indicating that left and right values must be inverted
  29827. */
  29828. reverseLeftRight: boolean;
  29829. /**
  29830. * Gets or sets a boolean indicating that up and down values must be inverted
  29831. */
  29832. reverseUpDown: boolean;
  29833. /**
  29834. * Gets the offset value for the position (ie. the change of the position value)
  29835. */
  29836. deltaPosition: Vector3;
  29837. /**
  29838. * Gets a boolean indicating if the virtual joystick was pressed
  29839. */
  29840. pressed: boolean;
  29841. private static _globalJoystickIndex;
  29842. private static vjCanvas;
  29843. private static vjCanvasContext;
  29844. private static vjCanvasWidth;
  29845. private static vjCanvasHeight;
  29846. private static halfWidth;
  29847. private _action;
  29848. private _axisTargetedByLeftAndRight;
  29849. private _axisTargetedByUpAndDown;
  29850. private _joystickSensibility;
  29851. private _inversedSensibility;
  29852. private _joystickPointerID;
  29853. private _joystickColor;
  29854. private _joystickPointerPos;
  29855. private _joystickPreviousPointerPos;
  29856. private _joystickPointerStartPos;
  29857. private _deltaJoystickVector;
  29858. private _leftJoystick;
  29859. private _touches;
  29860. private _onPointerDownHandlerRef;
  29861. private _onPointerMoveHandlerRef;
  29862. private _onPointerUpHandlerRef;
  29863. private _onResize;
  29864. /**
  29865. * Creates a new virtual joystick
  29866. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29867. */
  29868. constructor(leftJoystick?: boolean);
  29869. /**
  29870. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29871. * @param newJoystickSensibility defines the new sensibility
  29872. */
  29873. setJoystickSensibility(newJoystickSensibility: number): void;
  29874. private _onPointerDown(e);
  29875. private _onPointerMove(e);
  29876. private _onPointerUp(e);
  29877. /**
  29878. * Change the color of the virtual joystick
  29879. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29880. */
  29881. setJoystickColor(newColor: string): void;
  29882. /**
  29883. * Defines a callback to call when the joystick is touched
  29884. * @param action defines the callback
  29885. */
  29886. setActionOnTouch(action: () => any): void;
  29887. /**
  29888. * Defines which axis you'd like to control for left & right
  29889. * @param axis defines the axis to use
  29890. */
  29891. setAxisForLeftRight(axis: JoystickAxis): void;
  29892. /**
  29893. * Defines which axis you'd like to control for up & down
  29894. * @param axis defines the axis to use
  29895. */
  29896. setAxisForUpDown(axis: JoystickAxis): void;
  29897. private _drawVirtualJoystick();
  29898. /**
  29899. * Release internal HTML canvas
  29900. */
  29901. releaseCanvas(): void;
  29902. }
  29903. }
  29904. declare module BABYLON {
  29905. /**
  29906. * Helper class to push actions to a pool of workers.
  29907. */
  29908. class WorkerPool implements IDisposable {
  29909. private _workerInfos;
  29910. private _pendingActions;
  29911. /**
  29912. * Constructor
  29913. * @param workers Array of workers to use for actions
  29914. */
  29915. constructor(workers: Array<Worker>);
  29916. /**
  29917. * Terminates all workers and clears any pending actions.
  29918. */
  29919. dispose(): void;
  29920. /**
  29921. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29922. * pended until a worker has completed its action.
  29923. * @param action The action to perform. Call onComplete when the action is complete.
  29924. */
  29925. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29926. private _execute(workerInfo, action);
  29927. }
  29928. }
  29929. declare module BABYLON {
  29930. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29931. readonly name: string;
  29932. private _zoomStopsAnimation;
  29933. private _idleRotationSpeed;
  29934. private _idleRotationWaitTime;
  29935. private _idleRotationSpinupTime;
  29936. /**
  29937. * Gets the flag that indicates if user zooming should stop animation.
  29938. */
  29939. /**
  29940. * Sets the flag that indicates if user zooming should stop animation.
  29941. */
  29942. zoomStopsAnimation: boolean;
  29943. /**
  29944. * Gets the default speed at which the camera rotates around the model.
  29945. */
  29946. /**
  29947. * Sets the default speed at which the camera rotates around the model.
  29948. */
  29949. idleRotationSpeed: number;
  29950. /**
  29951. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29952. */
  29953. /**
  29954. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29955. */
  29956. idleRotationWaitTime: number;
  29957. /**
  29958. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29959. */
  29960. /**
  29961. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29962. */
  29963. idleRotationSpinupTime: number;
  29964. /**
  29965. * Gets a value indicating if the camera is currently rotating because of this behavior
  29966. */
  29967. readonly rotationInProgress: boolean;
  29968. private _onPrePointerObservableObserver;
  29969. private _onAfterCheckInputsObserver;
  29970. private _attachedCamera;
  29971. private _isPointerDown;
  29972. private _lastFrameTime;
  29973. private _lastInteractionTime;
  29974. private _cameraRotationSpeed;
  29975. init(): void;
  29976. attach(camera: ArcRotateCamera): void;
  29977. detach(): void;
  29978. /**
  29979. * Returns true if user is scrolling.
  29980. * @return true if user is scrolling.
  29981. */
  29982. private _userIsZooming();
  29983. private _lastFrameRadius;
  29984. private _shouldAnimationStopForInteraction();
  29985. /**
  29986. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29987. */
  29988. private _applyUserInteraction();
  29989. private _userIsMoving();
  29990. }
  29991. }
  29992. declare module BABYLON {
  29993. /**
  29994. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29995. */
  29996. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29997. readonly name: string;
  29998. /**
  29999. * The easing function used by animations
  30000. */
  30001. static EasingFunction: BackEase;
  30002. /**
  30003. * The easing mode used by animations
  30004. */
  30005. static EasingMode: number;
  30006. /**
  30007. * The duration of the animation, in milliseconds
  30008. */
  30009. transitionDuration: number;
  30010. /**
  30011. * Length of the distance animated by the transition when lower radius is reached
  30012. */
  30013. lowerRadiusTransitionRange: number;
  30014. /**
  30015. * Length of the distance animated by the transition when upper radius is reached
  30016. */
  30017. upperRadiusTransitionRange: number;
  30018. private _autoTransitionRange;
  30019. /**
  30020. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30021. */
  30022. /**
  30023. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30024. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  30025. */
  30026. autoTransitionRange: boolean;
  30027. private _attachedCamera;
  30028. private _onAfterCheckInputsObserver;
  30029. private _onMeshTargetChangedObserver;
  30030. init(): void;
  30031. attach(camera: ArcRotateCamera): void;
  30032. detach(): void;
  30033. private _radiusIsAnimating;
  30034. private _radiusBounceTransition;
  30035. private _animatables;
  30036. private _cachedWheelPrecision;
  30037. /**
  30038. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  30039. * @param radiusLimit The limit to check against.
  30040. * @return Bool to indicate if at limit.
  30041. */
  30042. private _isRadiusAtLimit(radiusLimit);
  30043. /**
  30044. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  30045. * @param radiusDelta The delta by which to animate to. Can be negative.
  30046. */
  30047. private _applyBoundRadiusAnimation(radiusDelta);
  30048. /**
  30049. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  30050. */
  30051. protected _clearAnimationLocks(): void;
  30052. /**
  30053. * Stops and removes all animations that have been applied to the camera
  30054. */
  30055. stopAllAnimations(): void;
  30056. }
  30057. }
  30058. declare module BABYLON {
  30059. class FramingBehavior implements Behavior<ArcRotateCamera> {
  30060. readonly name: string;
  30061. private _mode;
  30062. private _radiusScale;
  30063. private _positionScale;
  30064. private _defaultElevation;
  30065. private _elevationReturnTime;
  30066. private _elevationReturnWaitTime;
  30067. private _zoomStopsAnimation;
  30068. private _framingTime;
  30069. /**
  30070. * The easing function used by animations
  30071. */
  30072. static EasingFunction: ExponentialEase;
  30073. /**
  30074. * The easing mode used by animations
  30075. */
  30076. static EasingMode: number;
  30077. /**
  30078. * Gets current mode used by the behavior.
  30079. */
  30080. /**
  30081. * Sets the current mode used by the behavior
  30082. */
  30083. mode: number;
  30084. /**
  30085. * Gets the scale applied to the radius
  30086. */
  30087. /**
  30088. * Sets the scale applied to the radius (1 by default)
  30089. */
  30090. radiusScale: number;
  30091. /**
  30092. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  30093. */
  30094. /**
  30095. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  30096. */
  30097. positionScale: number;
  30098. /**
  30099. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  30100. * behaviour is triggered, in radians.
  30101. */
  30102. /**
  30103. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  30104. * behaviour is triggered, in radians.
  30105. */
  30106. defaultElevation: number;
  30107. /**
  30108. * Gets the time (in milliseconds) taken to return to the default beta position.
  30109. * Negative value indicates camera should not return to default.
  30110. */
  30111. /**
  30112. * Sets the time (in milliseconds) taken to return to the default beta position.
  30113. * Negative value indicates camera should not return to default.
  30114. */
  30115. elevationReturnTime: number;
  30116. /**
  30117. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30118. */
  30119. /**
  30120. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30121. */
  30122. elevationReturnWaitTime: number;
  30123. /**
  30124. * Gets the flag that indicates if user zooming should stop animation.
  30125. */
  30126. /**
  30127. * Sets the flag that indicates if user zooming should stop animation.
  30128. */
  30129. zoomStopsAnimation: boolean;
  30130. /**
  30131. * Gets the transition time when framing the mesh, in milliseconds
  30132. */
  30133. /**
  30134. * Sets the transition time when framing the mesh, in milliseconds
  30135. */
  30136. framingTime: number;
  30137. private _onPrePointerObservableObserver;
  30138. private _onAfterCheckInputsObserver;
  30139. private _onMeshTargetChangedObserver;
  30140. private _attachedCamera;
  30141. private _isPointerDown;
  30142. private _lastInteractionTime;
  30143. init(): void;
  30144. attach(camera: ArcRotateCamera): void;
  30145. detach(): void;
  30146. private _animatables;
  30147. private _betaIsAnimating;
  30148. private _betaTransition;
  30149. private _radiusTransition;
  30150. private _vectorTransition;
  30151. /**
  30152. * Targets the given mesh and updates zoom level accordingly.
  30153. * @param mesh The mesh to target.
  30154. * @param radius Optional. If a cached radius position already exists, overrides default.
  30155. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30158. */
  30159. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30160. /**
  30161. * Targets the given mesh with its children and updates zoom level accordingly.
  30162. * @param mesh The mesh to target.
  30163. * @param radius Optional. If a cached radius position already exists, overrides default.
  30164. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30165. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30166. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30167. */
  30168. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30169. /**
  30170. * Targets the given meshes with their children and updates zoom level accordingly.
  30171. * @param meshes The mesh to target.
  30172. * @param radius Optional. If a cached radius position already exists, overrides default.
  30173. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30174. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30175. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30176. */
  30177. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30178. /**
  30179. * Targets the given mesh and updates zoom level accordingly.
  30180. * @param mesh The mesh to target.
  30181. * @param radius Optional. If a cached radius position already exists, overrides default.
  30182. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30183. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30184. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30185. */
  30186. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30187. /**
  30188. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  30189. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  30190. * frustum width.
  30191. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  30192. * to fully enclose the mesh in the viewing frustum.
  30193. */
  30194. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  30195. /**
  30196. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  30197. * is automatically returned to its default position (expected to be above ground plane).
  30198. */
  30199. private _maintainCameraAboveGround();
  30200. /**
  30201. * Returns the frustum slope based on the canvas ratio and camera FOV
  30202. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  30203. */
  30204. private _getFrustumSlope();
  30205. /**
  30206. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  30207. */
  30208. private _clearAnimationLocks();
  30209. /**
  30210. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30211. */
  30212. private _applyUserInteraction();
  30213. /**
  30214. * Stops and removes all animations that have been applied to the camera
  30215. */
  30216. stopAllAnimations(): void;
  30217. /**
  30218. * Gets a value indicating if the user is moving the camera
  30219. */
  30220. readonly isUserIsMoving: boolean;
  30221. /**
  30222. * The camera can move all the way towards the mesh.
  30223. */
  30224. static IgnoreBoundsSizeMode: number;
  30225. /**
  30226. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  30227. */
  30228. static FitFrustumSidesMode: number;
  30229. }
  30230. }
  30231. declare module BABYLON {
  30232. /**
  30233. * A behavior that when attached to a mesh will allow the mesh to be scaled
  30234. */
  30235. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  30236. private _dragBehaviorA;
  30237. private _dragBehaviorB;
  30238. private _startDistance;
  30239. private _initialScale;
  30240. private _targetScale;
  30241. private _ownerNode;
  30242. private _sceneRenderObserver;
  30243. constructor();
  30244. /**
  30245. * The name of the behavior
  30246. */
  30247. readonly name: string;
  30248. /**
  30249. * Initializes the behavior
  30250. */
  30251. init(): void;
  30252. private _getCurrentDistance();
  30253. /**
  30254. * Attaches the scale behavior the passed in mesh
  30255. * @param ownerNode The mesh that will be scaled around once attached
  30256. */
  30257. attach(ownerNode: Mesh): void;
  30258. /**
  30259. * Detaches the behavior from the mesh
  30260. */
  30261. detach(): void;
  30262. }
  30263. }
  30264. declare module BABYLON {
  30265. /**
  30266. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  30267. */
  30268. class PointerDragBehavior implements Behavior<Mesh> {
  30269. private options;
  30270. private _attachedNode;
  30271. private _dragPlane;
  30272. private _scene;
  30273. private _pointerObserver;
  30274. private static _planeScene;
  30275. /**
  30276. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30277. */
  30278. currentDraggingPointerID: number;
  30279. /**
  30280. * The last position where the pointer hit the drag plane in world space
  30281. */
  30282. lastDragPosition: Vector3;
  30283. /**
  30284. * If the behavior is currently in a dragging state
  30285. */
  30286. dragging: boolean;
  30287. /**
  30288. * 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)
  30289. */
  30290. dragDeltaRatio: number;
  30291. private _debugMode;
  30292. private _moving;
  30293. /**
  30294. * Fires each time the attached mesh is dragged with the pointer
  30295. * * delta between last drag position and current drag position in world space
  30296. * * dragDistance along the drag axis
  30297. * * dragPlaneNormal normal of the current drag plane used during the drag
  30298. * * dragPlanePoint in world space where the drag intersects the drag plane
  30299. */
  30300. onDragObservable: Observable<{
  30301. delta: Vector3;
  30302. dragPlanePoint: Vector3;
  30303. dragPlaneNormal: Vector3;
  30304. dragDistance: number;
  30305. pointerId: number;
  30306. }>;
  30307. /**
  30308. * Fires each time a drag begins (eg. mouse down on mesh)
  30309. */
  30310. onDragStartObservable: Observable<{
  30311. dragPlanePoint: Vector3;
  30312. pointerId: number;
  30313. }>;
  30314. /**
  30315. * Fires each time a drag ends (eg. mouse release after drag)
  30316. */
  30317. onDragEndObservable: Observable<{
  30318. dragPlanePoint: Vector3;
  30319. pointerId: number;
  30320. }>;
  30321. /**
  30322. * If the attached mesh should be moved when dragged
  30323. */
  30324. moveAttached: boolean;
  30325. /**
  30326. * If the drag behavior will react to drag events (Default: true)
  30327. */
  30328. enabled: boolean;
  30329. /**
  30330. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  30331. */
  30332. useObjectOrienationForDragging: boolean;
  30333. /**
  30334. * Creates a pointer drag behavior that can be attached to a mesh
  30335. * @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)
  30336. */
  30337. constructor(options: {
  30338. dragAxis?: Vector3;
  30339. dragPlaneNormal?: Vector3;
  30340. });
  30341. /**
  30342. * The name of the behavior
  30343. */
  30344. readonly name: string;
  30345. /**
  30346. * Initializes the behavior
  30347. */
  30348. init(): void;
  30349. private _tmpVector;
  30350. private _worldDragAxis;
  30351. /**
  30352. * Attaches the drag behavior the passed in mesh
  30353. * @param ownerNode The mesh that will be dragged around once attached
  30354. */
  30355. attach(ownerNode: Mesh): void;
  30356. releaseDrag(): void;
  30357. private _pickWithRayOnDragPlane(ray);
  30358. private _pointA;
  30359. private _pointB;
  30360. private _pointC;
  30361. private _lineA;
  30362. private _lineB;
  30363. private _localAxis;
  30364. private _lookAt;
  30365. private _updateDragPlanePosition(ray, dragPlanePosition);
  30366. /**
  30367. * Detaches the behavior from the mesh
  30368. */
  30369. detach(): void;
  30370. }
  30371. }
  30372. declare module BABYLON {
  30373. /**
  30374. * 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
  30375. */
  30376. class SixDofDragBehavior implements Behavior<Mesh> {
  30377. private static _virtualScene;
  30378. private _ownerNode;
  30379. private _sceneRenderObserver;
  30380. private _scene;
  30381. private _targetPosition;
  30382. private _virtualOriginMesh;
  30383. private _virtualDragMesh;
  30384. private _pointerObserver;
  30385. /**
  30386. * 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: 5)
  30387. */
  30388. private zDragFactor;
  30389. /**
  30390. * If the behavior is currently in a dragging state
  30391. */
  30392. dragging: boolean;
  30393. /**
  30394. * 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)
  30395. */
  30396. dragDeltaRatio: number;
  30397. /**
  30398. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30399. */
  30400. currentDraggingPointerID: number;
  30401. constructor();
  30402. /**
  30403. * The name of the behavior
  30404. */
  30405. readonly name: string;
  30406. /**
  30407. * Initializes the behavior
  30408. */
  30409. init(): void;
  30410. /**
  30411. * Attaches the scale behavior the passed in mesh
  30412. * @param ownerNode The mesh that will be scaled around once attached
  30413. */
  30414. attach(ownerNode: Mesh): void;
  30415. /**
  30416. * Detaches the behavior from the mesh
  30417. */
  30418. detach(): void;
  30419. }
  30420. }
  30421. declare module BABYLON {
  30422. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  30423. camera: ArcRotateCamera;
  30424. gamepad: Nullable<Gamepad>;
  30425. private _onGamepadConnectedObserver;
  30426. private _onGamepadDisconnectedObserver;
  30427. gamepadRotationSensibility: number;
  30428. gamepadMoveSensibility: number;
  30429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30430. detachControl(element: Nullable<HTMLElement>): void;
  30431. checkInputs(): void;
  30432. getClassName(): string;
  30433. getSimpleName(): string;
  30434. }
  30435. }
  30436. declare module BABYLON {
  30437. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  30438. camera: ArcRotateCamera;
  30439. private _keys;
  30440. keysUp: number[];
  30441. keysDown: number[];
  30442. keysLeft: number[];
  30443. keysRight: number[];
  30444. keysReset: number[];
  30445. panningSensibility: number;
  30446. zoomingSensibility: number;
  30447. useAltToZoom: boolean;
  30448. private _ctrlPressed;
  30449. private _altPressed;
  30450. private _onCanvasBlurObserver;
  30451. private _onKeyboardObserver;
  30452. private _engine;
  30453. private _scene;
  30454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30455. detachControl(element: Nullable<HTMLElement>): void;
  30456. checkInputs(): void;
  30457. getClassName(): string;
  30458. getSimpleName(): string;
  30459. }
  30460. }
  30461. declare module BABYLON {
  30462. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  30463. camera: ArcRotateCamera;
  30464. private _wheel;
  30465. private _observer;
  30466. wheelPrecision: number;
  30467. /**
  30468. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  30469. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  30470. */
  30471. wheelDeltaPercentage: number;
  30472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30473. detachControl(element: Nullable<HTMLElement>): void;
  30474. getClassName(): string;
  30475. getSimpleName(): string;
  30476. }
  30477. }
  30478. declare module BABYLON {
  30479. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  30480. camera: ArcRotateCamera;
  30481. buttons: number[];
  30482. angularSensibilityX: number;
  30483. angularSensibilityY: number;
  30484. pinchPrecision: number;
  30485. /**
  30486. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  30487. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  30488. */
  30489. pinchDeltaPercentage: number;
  30490. panningSensibility: number;
  30491. multiTouchPanning: boolean;
  30492. multiTouchPanAndZoom: boolean;
  30493. private _isPanClick;
  30494. pinchInwards: boolean;
  30495. private _pointerInput;
  30496. private _observer;
  30497. private _onMouseMove;
  30498. private _onGestureStart;
  30499. private _onGesture;
  30500. private _MSGestureHandler;
  30501. private _onLostFocus;
  30502. private _onContextMenu;
  30503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30504. detachControl(element: Nullable<HTMLElement>): void;
  30505. getClassName(): string;
  30506. getSimpleName(): string;
  30507. }
  30508. }
  30509. declare module BABYLON {
  30510. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  30511. camera: ArcRotateCamera;
  30512. alphaCorrection: number;
  30513. betaCorrection: number;
  30514. gammaCorrection: number;
  30515. private _alpha;
  30516. private _gamma;
  30517. private _dirty;
  30518. private _deviceOrientationHandler;
  30519. constructor();
  30520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30521. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  30522. checkInputs(): void;
  30523. detachControl(element: Nullable<HTMLElement>): void;
  30524. getClassName(): string;
  30525. getSimpleName(): string;
  30526. }
  30527. }
  30528. declare module BABYLON {
  30529. /**
  30530. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  30531. * Screen rotation is taken into account.
  30532. */
  30533. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  30534. private _camera;
  30535. private _screenOrientationAngle;
  30536. private _constantTranform;
  30537. private _screenQuaternion;
  30538. private _alpha;
  30539. private _beta;
  30540. private _gamma;
  30541. constructor();
  30542. camera: FreeCamera;
  30543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30544. private _orientationChanged;
  30545. private _deviceOrientation;
  30546. detachControl(element: Nullable<HTMLElement>): void;
  30547. checkInputs(): void;
  30548. getClassName(): string;
  30549. getSimpleName(): string;
  30550. }
  30551. }
  30552. declare module BABYLON {
  30553. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  30554. camera: FreeCamera;
  30555. gamepad: Nullable<Gamepad>;
  30556. private _onGamepadConnectedObserver;
  30557. private _onGamepadDisconnectedObserver;
  30558. gamepadAngularSensibility: number;
  30559. gamepadMoveSensibility: number;
  30560. private _cameraTransform;
  30561. private _deltaTransform;
  30562. private _vector3;
  30563. private _vector2;
  30564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30565. detachControl(element: Nullable<HTMLElement>): void;
  30566. checkInputs(): void;
  30567. getClassName(): string;
  30568. getSimpleName(): string;
  30569. }
  30570. }
  30571. declare module BABYLON {
  30572. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  30573. camera: FreeCamera;
  30574. private _keys;
  30575. private _onCanvasBlurObserver;
  30576. private _onKeyboardObserver;
  30577. private _engine;
  30578. private _scene;
  30579. keysUp: number[];
  30580. keysDown: number[];
  30581. keysLeft: number[];
  30582. keysRight: number[];
  30583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30584. detachControl(element: Nullable<HTMLElement>): void;
  30585. checkInputs(): void;
  30586. getClassName(): string;
  30587. _onLostFocus(e: FocusEvent): void;
  30588. getSimpleName(): string;
  30589. }
  30590. }
  30591. declare module BABYLON {
  30592. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  30593. touchEnabled: boolean;
  30594. camera: FreeCamera;
  30595. buttons: number[];
  30596. angularSensibility: number;
  30597. private _pointerInput;
  30598. private _onMouseMove;
  30599. private _observer;
  30600. private previousPosition;
  30601. constructor(touchEnabled?: boolean);
  30602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30603. detachControl(element: Nullable<HTMLElement>): void;
  30604. getClassName(): string;
  30605. getSimpleName(): string;
  30606. }
  30607. }
  30608. declare module BABYLON {
  30609. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  30610. camera: FreeCamera;
  30611. private _offsetX;
  30612. private _offsetY;
  30613. private _pointerPressed;
  30614. private _pointerInput;
  30615. private _observer;
  30616. private _onLostFocus;
  30617. touchAngularSensibility: number;
  30618. touchMoveSensibility: number;
  30619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30620. detachControl(element: Nullable<HTMLElement>): void;
  30621. checkInputs(): void;
  30622. getClassName(): string;
  30623. getSimpleName(): string;
  30624. }
  30625. }
  30626. declare module BABYLON {
  30627. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  30628. camera: FreeCamera;
  30629. private _leftjoystick;
  30630. private _rightjoystick;
  30631. getLeftJoystick(): VirtualJoystick;
  30632. getRightJoystick(): VirtualJoystick;
  30633. checkInputs(): void;
  30634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30635. detachControl(element: Nullable<HTMLElement>): void;
  30636. getClassName(): string;
  30637. getSimpleName(): string;
  30638. }
  30639. }
  30640. declare module BABYLON {
  30641. class VRCameraMetrics {
  30642. hResolution: number;
  30643. vResolution: number;
  30644. hScreenSize: number;
  30645. vScreenSize: number;
  30646. vScreenCenter: number;
  30647. eyeToScreenDistance: number;
  30648. lensSeparationDistance: number;
  30649. interpupillaryDistance: number;
  30650. distortionK: number[];
  30651. chromaAbCorrection: number[];
  30652. postProcessScaleFactor: number;
  30653. lensCenterOffset: number;
  30654. compensateDistortion: boolean;
  30655. readonly aspectRatio: number;
  30656. readonly aspectRatioFov: number;
  30657. readonly leftHMatrix: Matrix;
  30658. readonly rightHMatrix: Matrix;
  30659. readonly leftPreViewMatrix: Matrix;
  30660. readonly rightPreViewMatrix: Matrix;
  30661. static GetDefault(): VRCameraMetrics;
  30662. }
  30663. }
  30664. declare module BABYLON {
  30665. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  30666. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30667. getClassName(): string;
  30668. }
  30669. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  30670. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30671. getClassName(): string;
  30672. }
  30673. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  30674. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30675. getClassName(): string;
  30676. }
  30677. }
  30678. declare module BABYLON {
  30679. /**
  30680. * Options to modify the vr teleportation behavior.
  30681. */
  30682. interface VRTeleportationOptions {
  30683. /**
  30684. * The name of the mesh which should be used as the teleportation floor. (default: null)
  30685. */
  30686. floorMeshName?: string;
  30687. /**
  30688. * A list of meshes to be used as the teleportation floor. (default: empty)
  30689. */
  30690. floorMeshes?: Mesh[];
  30691. }
  30692. /**
  30693. * Options to modify the vr experience helper's behavior.
  30694. */
  30695. interface VRExperienceHelperOptions extends WebVROptions {
  30696. /**
  30697. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  30698. */
  30699. createDeviceOrientationCamera?: boolean;
  30700. /**
  30701. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  30702. */
  30703. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  30704. /**
  30705. * Uses the main button on the controller to toggle the laser casted. (default: true)
  30706. */
  30707. laserToggle?: boolean;
  30708. /**
  30709. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  30710. */
  30711. floorMeshes?: Mesh[];
  30712. }
  30713. /**
  30714. * Helps to quickly add VR support to an existing scene.
  30715. * See http://doc.babylonjs.com/how_to/webvr_helper
  30716. */
  30717. class VRExperienceHelper {
  30718. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  30719. private _scene;
  30720. private _position;
  30721. private _btnVR;
  30722. private _btnVRDisplayed;
  30723. private _webVRsupported;
  30724. private _webVRready;
  30725. private _webVRrequesting;
  30726. private _webVRpresenting;
  30727. private _fullscreenVRpresenting;
  30728. private _canvas;
  30729. private _webVRCamera;
  30730. private _vrDeviceOrientationCamera;
  30731. private _deviceOrientationCamera;
  30732. private _existingCamera;
  30733. private _onKeyDown;
  30734. private _onVrDisplayPresentChange;
  30735. private _onVRDisplayChanged;
  30736. private _onVRRequestPresentStart;
  30737. private _onVRRequestPresentComplete;
  30738. /**
  30739. * Observable raised when entering VR.
  30740. */
  30741. onEnteringVRObservable: Observable<VRExperienceHelper>;
  30742. /**
  30743. * Observable raised when exiting VR.
  30744. */
  30745. onExitingVRObservable: Observable<VRExperienceHelper>;
  30746. /**
  30747. * Observable raised when controller mesh is loaded.
  30748. */
  30749. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30750. /** Return this.onEnteringVRObservable
  30751. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  30752. */
  30753. readonly onEnteringVR: Observable<VRExperienceHelper>;
  30754. /** Return this.onExitingVRObservable
  30755. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  30756. */
  30757. readonly onExitingVR: Observable<VRExperienceHelper>;
  30758. /** Return this.onControllerMeshLoadedObservable
  30759. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  30760. */
  30761. readonly onControllerMeshLoaded: Observable<WebVRController>;
  30762. private _rayLength;
  30763. private _useCustomVRButton;
  30764. private _teleportationRequested;
  30765. private _teleportActive;
  30766. private _floorMeshName;
  30767. private _floorMeshesCollection;
  30768. private _rotationAllowed;
  30769. private _teleportBackwardsVector;
  30770. private _teleportationTarget;
  30771. private _isDefaultTeleportationTarget;
  30772. private _postProcessMove;
  30773. private _teleportationFillColor;
  30774. private _teleportationBorderColor;
  30775. private _rotationAngle;
  30776. private _haloCenter;
  30777. private _cameraGazer;
  30778. private _padSensibilityUp;
  30779. private _padSensibilityDown;
  30780. private leftController;
  30781. private rightController;
  30782. /**
  30783. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  30784. */
  30785. onNewMeshSelected: Observable<AbstractMesh>;
  30786. /**
  30787. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  30788. */
  30789. onNewMeshPicked: Observable<PickingInfo>;
  30790. private _circleEase;
  30791. /**
  30792. * Observable raised before camera teleportation
  30793. */
  30794. onBeforeCameraTeleport: Observable<Vector3>;
  30795. /**
  30796. * Observable raised after camera teleportation
  30797. */
  30798. onAfterCameraTeleport: Observable<Vector3>;
  30799. /**
  30800. * Observable raised when current selected mesh gets unselected
  30801. */
  30802. onSelectedMeshUnselected: Observable<AbstractMesh>;
  30803. private _raySelectionPredicate;
  30804. /**
  30805. * To be optionaly changed by user to define custom ray selection
  30806. */
  30807. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  30808. /**
  30809. * To be optionaly changed by user to define custom selection logic (after ray selection)
  30810. */
  30811. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  30812. /**
  30813. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  30814. */
  30815. teleportationEnabled: boolean;
  30816. private _defaultHeight;
  30817. private _teleportationInitialized;
  30818. private _interactionsEnabled;
  30819. private _interactionsRequested;
  30820. private _displayGaze;
  30821. private _displayLaserPointer;
  30822. /**
  30823. * The mesh used to display where the user is going to teleport.
  30824. */
  30825. /**
  30826. * Sets the mesh to be used to display where the user is going to teleport.
  30827. */
  30828. teleportationTarget: Mesh;
  30829. /**
  30830. * The mesh used to display where the user is selecting,
  30831. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  30832. * See http://doc.babylonjs.com/resources/baking_transformations
  30833. */
  30834. gazeTrackerMesh: Mesh;
  30835. /**
  30836. * If the ray of the gaze should be displayed.
  30837. */
  30838. /**
  30839. * Sets if the ray of the gaze should be displayed.
  30840. */
  30841. displayGaze: boolean;
  30842. /**
  30843. * If the ray of the LaserPointer should be displayed.
  30844. */
  30845. /**
  30846. * Sets if the ray of the LaserPointer should be displayed.
  30847. */
  30848. displayLaserPointer: boolean;
  30849. /**
  30850. * The deviceOrientationCamera used as the camera when not in VR.
  30851. */
  30852. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  30853. /**
  30854. * Based on the current WebVR support, returns the current VR camera used.
  30855. */
  30856. readonly currentVRCamera: Nullable<Camera>;
  30857. /**
  30858. * The webVRCamera which is used when in VR.
  30859. */
  30860. readonly webVRCamera: WebVRFreeCamera;
  30861. /**
  30862. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  30863. */
  30864. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  30865. private readonly _teleportationRequestInitiated;
  30866. /**
  30867. * Instantiates a VRExperienceHelper.
  30868. * Helps to quickly add VR support to an existing scene.
  30869. * @param scene The scene the VRExperienceHelper belongs to.
  30870. * @param webVROptions Options to modify the vr experience helper's behavior.
  30871. */
  30872. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30873. private _onDefaultMeshLoaded(webVRController);
  30874. private _onResize;
  30875. private _onFullscreenChange;
  30876. /**
  30877. * Gets a value indicating if we are currently in VR mode.
  30878. */
  30879. readonly isInVRMode: boolean;
  30880. private onVrDisplayPresentChange();
  30881. private onVRDisplayChanged(eventArgs);
  30882. private moveButtonToBottomRight();
  30883. private displayVRButton();
  30884. private updateButtonVisibility();
  30885. /**
  30886. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30887. * Otherwise, will use the fullscreen API.
  30888. */
  30889. enterVR(): void;
  30890. /**
  30891. * Attempt to exit VR, or fullscreen.
  30892. */
  30893. exitVR(): void;
  30894. /**
  30895. * The position of the vr experience helper.
  30896. */
  30897. /**
  30898. * Sets the position of the vr experience helper.
  30899. */
  30900. position: Vector3;
  30901. /**
  30902. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30903. */
  30904. enableInteractions(): void;
  30905. private readonly _noControllerIsActive;
  30906. private beforeRender;
  30907. private _isTeleportationFloor(mesh);
  30908. /**
  30909. * Adds a floor mesh to be used for teleportation.
  30910. * @param floorMesh the mesh to be used for teleportation.
  30911. */
  30912. addFloorMesh(floorMesh: Mesh): void;
  30913. /**
  30914. * Removes a floor mesh from being used for teleportation.
  30915. * @param floorMesh the mesh to be removed.
  30916. */
  30917. removeFloorMesh(floorMesh: Mesh): void;
  30918. /**
  30919. * Enables interactions and teleportation using the VR controllers and gaze.
  30920. * @param vrTeleportationOptions options to modify teleportation behavior.
  30921. */
  30922. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30923. private _onNewGamepadConnected;
  30924. private _tryEnableInteractionOnController;
  30925. private _onNewGamepadDisconnected;
  30926. private _enableInteractionOnController(controller);
  30927. private _checkTeleportWithRay(stateObject, gazer);
  30928. private _checkRotate(stateObject, gazer);
  30929. private _checkTeleportBackwards(stateObject, gazer);
  30930. private _enableTeleportationOnController(controller);
  30931. private _createTeleportationCircles();
  30932. private _displayTeleportationTarget();
  30933. private _hideTeleportationTarget();
  30934. private _rotateCamera(right);
  30935. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30936. private _workingVector;
  30937. private _workingQuaternion;
  30938. private _workingMatrix;
  30939. private _teleportCamera(location);
  30940. private _convertNormalToDirectionOfRay(normal, ray);
  30941. private _castRayAndSelectObject(gazer);
  30942. private _notifySelectedMeshUnselected(mesh);
  30943. /**
  30944. * Sets the color of the laser ray from the vr controllers.
  30945. * @param color new color for the ray.
  30946. */
  30947. changeLaserColor(color: Color3): void;
  30948. /**
  30949. * Sets the color of the ray from the vr headsets gaze.
  30950. * @param color new color for the ray.
  30951. */
  30952. changeGazeColor(color: Color3): void;
  30953. /**
  30954. * Exits VR and disposes of the vr experience helper
  30955. */
  30956. dispose(): void;
  30957. /**
  30958. * Gets the name of the VRExperienceHelper class
  30959. * @returns "VRExperienceHelper"
  30960. */
  30961. getClassName(): string;
  30962. }
  30963. }
  30964. declare module BABYLON {
  30965. /**
  30966. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30967. * IMPORTANT!! The data is right-hand data.
  30968. * @export
  30969. * @interface DevicePose
  30970. */
  30971. interface DevicePose {
  30972. /**
  30973. * The position of the device, values in array are [x,y,z].
  30974. */
  30975. readonly position: Nullable<Float32Array>;
  30976. /**
  30977. * The linearVelocity of the device, values in array are [x,y,z].
  30978. */
  30979. readonly linearVelocity: Nullable<Float32Array>;
  30980. /**
  30981. * The linearAcceleration of the device, values in array are [x,y,z].
  30982. */
  30983. readonly linearAcceleration: Nullable<Float32Array>;
  30984. /**
  30985. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30986. */
  30987. readonly orientation: Nullable<Float32Array>;
  30988. /**
  30989. * The angularVelocity of the device, values in array are [x,y,z].
  30990. */
  30991. readonly angularVelocity: Nullable<Float32Array>;
  30992. /**
  30993. * The angularAcceleration of the device, values in array are [x,y,z].
  30994. */
  30995. readonly angularAcceleration: Nullable<Float32Array>;
  30996. }
  30997. /**
  30998. * Interface representing a pose controlled object in Babylon.
  30999. * A pose controlled object has both regular pose values as well as pose values
  31000. * from an external device such as a VR head mounted display
  31001. */
  31002. interface PoseControlled {
  31003. /**
  31004. * The position of the object in babylon space.
  31005. */
  31006. position: Vector3;
  31007. /**
  31008. * The rotation quaternion of the object in babylon space.
  31009. */
  31010. rotationQuaternion: Quaternion;
  31011. /**
  31012. * The position of the device in babylon space.
  31013. */
  31014. devicePosition?: Vector3;
  31015. /**
  31016. * The rotation quaternion of the device in babylon space.
  31017. */
  31018. deviceRotationQuaternion: Quaternion;
  31019. /**
  31020. * The raw pose coming from the device.
  31021. */
  31022. rawPose: Nullable<DevicePose>;
  31023. /**
  31024. * The scale of the device to be used when translating from device space to babylon space.
  31025. */
  31026. deviceScaleFactor: number;
  31027. /**
  31028. * Updates the poseControlled values based on the input device pose.
  31029. * @param poseData the pose data to update the object with
  31030. */
  31031. updateFromDevice(poseData: DevicePose): void;
  31032. }
  31033. /**
  31034. * Set of options to customize the webVRCamera
  31035. */
  31036. interface WebVROptions {
  31037. /**
  31038. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  31039. */
  31040. trackPosition?: boolean;
  31041. /**
  31042. * Sets the scale of the vrDevice in babylon space. (default: 1)
  31043. */
  31044. positionScale?: number;
  31045. /**
  31046. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  31047. */
  31048. displayName?: string;
  31049. /**
  31050. * Should the native controller meshes be initialized. (default: true)
  31051. */
  31052. controllerMeshes?: boolean;
  31053. /**
  31054. * Creating a default HemiLight only on controllers. (default: true)
  31055. */
  31056. defaultLightingOnControllers?: boolean;
  31057. /**
  31058. * If you don't want to use the default VR button of the helper. (default: false)
  31059. */
  31060. useCustomVRButton?: boolean;
  31061. /**
  31062. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  31063. */
  31064. customVRButton?: HTMLButtonElement;
  31065. /**
  31066. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  31067. */
  31068. rayLength?: number;
  31069. /**
  31070. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  31071. */
  31072. defaultHeight?: number;
  31073. }
  31074. /**
  31075. * This represents a WebVR camera.
  31076. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  31077. * @example http://doc.babylonjs.com/how_to/webvr_camera
  31078. */
  31079. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  31080. private webVROptions;
  31081. /**
  31082. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  31083. */
  31084. _vrDevice: any;
  31085. /**
  31086. * The rawPose of the vrDevice.
  31087. */
  31088. rawPose: Nullable<DevicePose>;
  31089. private _onVREnabled;
  31090. private _specsVersion;
  31091. private _attached;
  31092. private _frameData;
  31093. protected _descendants: Array<Node>;
  31094. private _deviceRoomPosition;
  31095. private _deviceRoomRotationQuaternion;
  31096. private _standingMatrix;
  31097. /**
  31098. * Represents device position in babylon space.
  31099. */
  31100. devicePosition: Vector3;
  31101. /**
  31102. * Represents device rotation in babylon space.
  31103. */
  31104. deviceRotationQuaternion: Quaternion;
  31105. /**
  31106. * The scale of the device to be used when translating from device space to babylon space.
  31107. */
  31108. deviceScaleFactor: number;
  31109. private _deviceToWorld;
  31110. private _worldToDevice;
  31111. /**
  31112. * References to the webVR controllers for the vrDevice.
  31113. */
  31114. controllers: Array<WebVRController>;
  31115. /**
  31116. * Emits an event when a controller is attached.
  31117. */
  31118. onControllersAttachedObservable: Observable<WebVRController[]>;
  31119. /**
  31120. * Emits an event when a controller's mesh has been loaded;
  31121. */
  31122. onControllerMeshLoadedObservable: Observable<WebVRController>;
  31123. /**
  31124. * If the rig cameras be used as parent instead of this camera.
  31125. */
  31126. rigParenting: boolean;
  31127. private _lightOnControllers;
  31128. private _defaultHeight?;
  31129. /**
  31130. * Instantiates a WebVRFreeCamera.
  31131. * @param name The name of the WebVRFreeCamera
  31132. * @param position The starting anchor position for the camera
  31133. * @param scene The scene the camera belongs to
  31134. * @param webVROptions a set of customizable options for the webVRCamera
  31135. */
  31136. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  31137. /**
  31138. * Gets the device distance from the ground in meters.
  31139. * @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.
  31140. */
  31141. deviceDistanceToRoomGround(): number;
  31142. /**
  31143. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  31144. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  31145. */
  31146. useStandingMatrix(callback?: (bool: boolean) => void): void;
  31147. /**
  31148. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  31149. * @returns A promise with a boolean set to if the standing matrix is supported.
  31150. */
  31151. useStandingMatrixAsync(): Promise<boolean>;
  31152. /**
  31153. * Disposes the camera
  31154. */
  31155. dispose(): void;
  31156. /**
  31157. * Gets a vrController by name.
  31158. * @param name The name of the controller to retreive
  31159. * @returns the controller matching the name specified or null if not found
  31160. */
  31161. getControllerByName(name: string): Nullable<WebVRController>;
  31162. private _leftController;
  31163. /**
  31164. * The controller corrisponding to the users left hand.
  31165. */
  31166. readonly leftController: Nullable<WebVRController>;
  31167. private _rightController;
  31168. /**
  31169. * The controller corrisponding to the users right hand.
  31170. */
  31171. readonly rightController: Nullable<WebVRController>;
  31172. /**
  31173. * Casts a ray forward from the vrCamera's gaze.
  31174. * @param length Length of the ray (default: 100)
  31175. * @returns the ray corrisponding to the gaze
  31176. */
  31177. getForwardRay(length?: number): Ray;
  31178. /**
  31179. * Updates the camera based on device's frame data
  31180. */
  31181. _checkInputs(): void;
  31182. /**
  31183. * Updates the poseControlled values based on the input device pose.
  31184. * @param poseData Pose coming from the device
  31185. */
  31186. updateFromDevice(poseData: DevicePose): void;
  31187. /**
  31188. * WebVR's attach control will start broadcasting frames to the device.
  31189. * Note that in certain browsers (chrome for example) this function must be called
  31190. * within a user-interaction callback. Example:
  31191. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  31192. *
  31193. * @param element html element to attach the vrDevice to
  31194. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  31195. */
  31196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31197. /**
  31198. * Detaches the camera from the html element and disables VR
  31199. *
  31200. * @param element html element to detach from
  31201. */
  31202. detachControl(element: HTMLElement): void;
  31203. /**
  31204. * @returns the name of this class
  31205. */
  31206. getClassName(): string;
  31207. /**
  31208. * Calls resetPose on the vrDisplay
  31209. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  31210. */
  31211. resetToCurrentRotation(): void;
  31212. /**
  31213. * Updates the rig cameras (left and right eye)
  31214. */
  31215. _updateRigCameras(): void;
  31216. private _workingVector;
  31217. private _oneVector;
  31218. private _workingMatrix;
  31219. private updateCacheCalled;
  31220. /**
  31221. * Updates the cached values of the camera
  31222. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  31223. */
  31224. _updateCache(ignoreParentClass?: boolean): void;
  31225. /**
  31226. * Updates the current device position and rotation in the babylon world
  31227. */
  31228. update(): void;
  31229. /**
  31230. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  31231. * @returns an identity matrix
  31232. */
  31233. _getViewMatrix(): Matrix;
  31234. /**
  31235. * This function is called by the two RIG cameras.
  31236. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  31237. */
  31238. protected _getWebVRViewMatrix(): Matrix;
  31239. protected _getWebVRProjectionMatrix(): Matrix;
  31240. private _onGamepadConnectedObserver;
  31241. private _onGamepadDisconnectedObserver;
  31242. /**
  31243. * Initializes the controllers and their meshes
  31244. */
  31245. initControllers(): void;
  31246. }
  31247. }
  31248. declare module BABYLON {
  31249. interface IOctreeContainer<T> {
  31250. blocks: Array<OctreeBlock<T>>;
  31251. }
  31252. class Octree<T> {
  31253. maxDepth: number;
  31254. blocks: Array<OctreeBlock<T>>;
  31255. dynamicContent: T[];
  31256. private _maxBlockCapacity;
  31257. private _selectionContent;
  31258. private _creationFunc;
  31259. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  31260. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  31261. addMesh(entry: T): void;
  31262. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  31263. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  31264. intersectsRay(ray: Ray): SmartArray<T>;
  31265. 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;
  31266. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  31267. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  31268. }
  31269. }
  31270. declare module BABYLON {
  31271. class OctreeBlock<T> {
  31272. entries: T[];
  31273. blocks: Array<OctreeBlock<T>>;
  31274. private _depth;
  31275. private _maxDepth;
  31276. private _capacity;
  31277. private _minPoint;
  31278. private _maxPoint;
  31279. private _boundingVectors;
  31280. private _creationFunc;
  31281. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  31282. readonly capacity: number;
  31283. readonly minPoint: Vector3;
  31284. readonly maxPoint: Vector3;
  31285. addEntry(entry: T): void;
  31286. addEntries(entries: T[]): void;
  31287. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31288. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31289. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  31290. createInnerBlocks(): void;
  31291. }
  31292. }
  31293. declare module BABYLON {
  31294. /**
  31295. * Google Daydream controller
  31296. */
  31297. class DaydreamController extends WebVRController {
  31298. /**
  31299. * Base Url for the controller model.
  31300. */
  31301. static MODEL_BASE_URL: string;
  31302. /**
  31303. * File name for the controller model.
  31304. */
  31305. static MODEL_FILENAME: string;
  31306. /**
  31307. * Gamepad Id prefix used to identify Daydream Controller.
  31308. */
  31309. static readonly GAMEPAD_ID_PREFIX: string;
  31310. /**
  31311. * Creates a new DaydreamController from a gamepad
  31312. * @param vrGamepad the gamepad that the controller should be created from
  31313. */
  31314. constructor(vrGamepad: any);
  31315. /**
  31316. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31317. * @param scene scene in which to add meshes
  31318. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31319. */
  31320. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31321. /**
  31322. * Called once for each button that changed state since the last frame
  31323. * @param buttonIdx Which button index changed
  31324. * @param state New state of the button
  31325. * @param changes Which properties on the state changed since last frame
  31326. */
  31327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31328. }
  31329. }
  31330. declare module BABYLON {
  31331. /**
  31332. * Gear VR Controller
  31333. */
  31334. class GearVRController extends WebVRController {
  31335. /**
  31336. * Base Url for the controller model.
  31337. */
  31338. static MODEL_BASE_URL: string;
  31339. /**
  31340. * File name for the controller model.
  31341. */
  31342. static MODEL_FILENAME: string;
  31343. /**
  31344. * Gamepad Id prefix used to identify this controller.
  31345. */
  31346. static readonly GAMEPAD_ID_PREFIX: string;
  31347. private readonly _buttonIndexToObservableNameMap;
  31348. /**
  31349. * Creates a new GearVRController from a gamepad
  31350. * @param vrGamepad the gamepad that the controller should be created from
  31351. */
  31352. constructor(vrGamepad: any);
  31353. /**
  31354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31355. * @param scene scene in which to add meshes
  31356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31357. */
  31358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31359. /**
  31360. * Called once for each button that changed state since the last frame
  31361. * @param buttonIdx Which button index changed
  31362. * @param state New state of the button
  31363. * @param changes Which properties on the state changed since last frame
  31364. */
  31365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31366. }
  31367. }
  31368. declare module BABYLON {
  31369. /**
  31370. * Generic Controller
  31371. */
  31372. class GenericController extends WebVRController {
  31373. /**
  31374. * Base Url for the controller model.
  31375. */
  31376. static readonly MODEL_BASE_URL: string;
  31377. /**
  31378. * File name for the controller model.
  31379. */
  31380. static readonly MODEL_FILENAME: string;
  31381. /**
  31382. * Creates a new GenericController from a gamepad
  31383. * @param vrGamepad the gamepad that the controller should be created from
  31384. */
  31385. constructor(vrGamepad: any);
  31386. /**
  31387. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31388. * @param scene scene in which to add meshes
  31389. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31390. */
  31391. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31392. /**
  31393. * Called once for each button that changed state since the last frame
  31394. * @param buttonIdx Which button index changed
  31395. * @param state New state of the button
  31396. * @param changes Which properties on the state changed since last frame
  31397. */
  31398. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31399. }
  31400. }
  31401. declare module BABYLON {
  31402. /**
  31403. * Oculus Touch Controller
  31404. */
  31405. class OculusTouchController extends WebVRController {
  31406. /**
  31407. * Base Url for the controller model.
  31408. */
  31409. static MODEL_BASE_URL: string;
  31410. /**
  31411. * File name for the left controller model.
  31412. */
  31413. static MODEL_LEFT_FILENAME: string;
  31414. /**
  31415. * File name for the right controller model.
  31416. */
  31417. static MODEL_RIGHT_FILENAME: string;
  31418. /**
  31419. * Fired when the secondary trigger on this controller is modified
  31420. */
  31421. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31422. /**
  31423. * Fired when the thumb rest on this controller is modified
  31424. */
  31425. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  31426. /**
  31427. * Creates a new OculusTouchController from a gamepad
  31428. * @param vrGamepad the gamepad that the controller should be created from
  31429. */
  31430. constructor(vrGamepad: any);
  31431. /**
  31432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31433. * @param scene scene in which to add meshes
  31434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31435. */
  31436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31437. /**
  31438. * Fired when the A button on this controller is modified
  31439. */
  31440. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31441. /**
  31442. * Fired when the B button on this controller is modified
  31443. */
  31444. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31445. /**
  31446. * Fired when the X button on this controller is modified
  31447. */
  31448. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31449. /**
  31450. * Fired when the Y button on this controller is modified
  31451. */
  31452. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31453. /**
  31454. * Called once for each button that changed state since the last frame
  31455. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  31456. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  31457. * 2) secondary trigger (same)
  31458. * 3) A (right) X (left), touch, pressed = value
  31459. * 4) B / Y
  31460. * 5) thumb rest
  31461. * @param buttonIdx Which button index changed
  31462. * @param state New state of the button
  31463. * @param changes Which properties on the state changed since last frame
  31464. */
  31465. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31466. }
  31467. }
  31468. declare module BABYLON {
  31469. /**
  31470. * Defines the types of pose enabled controllers that are supported
  31471. */
  31472. enum PoseEnabledControllerType {
  31473. /**
  31474. * HTC Vive
  31475. */
  31476. VIVE = 0,
  31477. /**
  31478. * Oculus Rift
  31479. */
  31480. OCULUS = 1,
  31481. /**
  31482. * Windows mixed reality
  31483. */
  31484. WINDOWS = 2,
  31485. /**
  31486. * Samsung gear VR
  31487. */
  31488. GEAR_VR = 3,
  31489. /**
  31490. * Google Daydream
  31491. */
  31492. DAYDREAM = 4,
  31493. /**
  31494. * Generic
  31495. */
  31496. GENERIC = 5,
  31497. }
  31498. /**
  31499. * Defines the MutableGamepadButton interface for the state of a gamepad button
  31500. */
  31501. interface MutableGamepadButton {
  31502. /**
  31503. * Value of the button/trigger
  31504. */
  31505. value: number;
  31506. /**
  31507. * If the button/trigger is currently touched
  31508. */
  31509. touched: boolean;
  31510. /**
  31511. * If the button/trigger is currently pressed
  31512. */
  31513. pressed: boolean;
  31514. }
  31515. /**
  31516. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  31517. * @hidden
  31518. */
  31519. interface ExtendedGamepadButton extends GamepadButton {
  31520. /**
  31521. * If the button/trigger is currently pressed
  31522. */
  31523. readonly pressed: boolean;
  31524. /**
  31525. * If the button/trigger is currently touched
  31526. */
  31527. readonly touched: boolean;
  31528. /**
  31529. * Value of the button/trigger
  31530. */
  31531. readonly value: number;
  31532. }
  31533. /**
  31534. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31535. */
  31536. class PoseEnabledControllerHelper {
  31537. /**
  31538. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31539. * @param vrGamepad the gamepad to initialized
  31540. * @returns a vr controller of the type the gamepad identified as
  31541. */
  31542. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  31543. }
  31544. /**
  31545. * Defines the PoseEnabledController object that contains state of a vr capable controller
  31546. */
  31547. class PoseEnabledController extends Gamepad implements PoseControlled {
  31548. private _deviceRoomPosition;
  31549. private _deviceRoomRotationQuaternion;
  31550. /**
  31551. * The device position in babylon space
  31552. */
  31553. devicePosition: Vector3;
  31554. /**
  31555. * The device rotation in babylon space
  31556. */
  31557. deviceRotationQuaternion: Quaternion;
  31558. /**
  31559. * The scale factor of the device in babylon space
  31560. */
  31561. deviceScaleFactor: number;
  31562. /**
  31563. * (Likely devicePosition should be used instead) The device position in its room space
  31564. */
  31565. position: Vector3;
  31566. /**
  31567. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  31568. */
  31569. rotationQuaternion: Quaternion;
  31570. /**
  31571. * The type of controller (Eg. Windows mixed reality)
  31572. */
  31573. controllerType: PoseEnabledControllerType;
  31574. protected _calculatedPosition: Vector3;
  31575. private _calculatedRotation;
  31576. /**
  31577. * The raw pose from the device
  31578. */
  31579. rawPose: DevicePose;
  31580. /**
  31581. * Internal, the mesh attached to the controller
  31582. */
  31583. _mesh: Nullable<AbstractMesh>;
  31584. private _poseControlledCamera;
  31585. private _leftHandSystemQuaternion;
  31586. /**
  31587. * Internal, matrix used to convert room space to babylon space
  31588. */
  31589. _deviceToWorld: Matrix;
  31590. /**
  31591. * Node to be used when casting a ray from the controller
  31592. */
  31593. _pointingPoseNode: Nullable<AbstractMesh>;
  31594. /**
  31595. * Name of the child mesh that can be used to cast a ray from the controller
  31596. */
  31597. static readonly POINTING_POSE: string;
  31598. /**
  31599. * Creates a new PoseEnabledController from a gamepad
  31600. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  31601. */
  31602. constructor(browserGamepad: any);
  31603. private _workingMatrix;
  31604. /**
  31605. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  31606. */
  31607. update(): void;
  31608. /**
  31609. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  31610. * @param poseData raw pose fromthe device
  31611. */
  31612. updateFromDevice(poseData: DevicePose): void;
  31613. /**
  31614. * @hidden
  31615. */
  31616. _meshAttachedObservable: Observable<AbstractMesh>;
  31617. /**
  31618. * Attaches a mesh to the controller
  31619. * @param mesh the mesh to be attached
  31620. */
  31621. attachToMesh(mesh: AbstractMesh): void;
  31622. /**
  31623. * Attaches the controllers mesh to a camera
  31624. * @param camera the camera the mesh should be attached to
  31625. */
  31626. attachToPoseControlledCamera(camera: TargetCamera): void;
  31627. /**
  31628. * Disposes of the controller
  31629. */
  31630. dispose(): void;
  31631. /**
  31632. * The mesh that is attached to the controller
  31633. */
  31634. readonly mesh: Nullable<AbstractMesh>;
  31635. /**
  31636. * Gets the ray of the controller in the direction the controller is pointing
  31637. * @param length the length the resulting ray should be
  31638. * @returns a ray in the direction the controller is pointing
  31639. */
  31640. getForwardRay(length?: number): Ray;
  31641. }
  31642. }
  31643. declare module BABYLON {
  31644. /**
  31645. * Vive Controller
  31646. */
  31647. class ViveController extends WebVRController {
  31648. /**
  31649. * Base Url for the controller model.
  31650. */
  31651. static MODEL_BASE_URL: string;
  31652. /**
  31653. * File name for the controller model.
  31654. */
  31655. static MODEL_FILENAME: string;
  31656. /**
  31657. * Creates a new ViveController from a gamepad
  31658. * @param vrGamepad the gamepad that the controller should be created from
  31659. */
  31660. constructor(vrGamepad: any);
  31661. /**
  31662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31663. * @param scene scene in which to add meshes
  31664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31665. */
  31666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31667. /**
  31668. * Fired when the left button on this controller is modified
  31669. */
  31670. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31671. /**
  31672. * Fired when the right button on this controller is modified
  31673. */
  31674. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31675. /**
  31676. * Fired when the menu button on this controller is modified
  31677. */
  31678. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31679. /**
  31680. * Called once for each button that changed state since the last frame
  31681. * Vive mapping:
  31682. * 0: touchpad
  31683. * 1: trigger
  31684. * 2: left AND right buttons
  31685. * 3: menu button
  31686. * @param buttonIdx Which button index changed
  31687. * @param state New state of the button
  31688. * @param changes Which properties on the state changed since last frame
  31689. */
  31690. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31691. }
  31692. }
  31693. declare module BABYLON {
  31694. /**
  31695. * Defines the WebVRController object that represents controllers tracked in 3D space
  31696. */
  31697. abstract class WebVRController extends PoseEnabledController {
  31698. /**
  31699. * Internal, the default controller model for the controller
  31700. */
  31701. protected _defaultModel: AbstractMesh;
  31702. /**
  31703. * Fired when the trigger state has changed
  31704. */
  31705. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31706. /**
  31707. * Fired when the main button state has changed
  31708. */
  31709. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31710. /**
  31711. * Fired when the secondary button state has changed
  31712. */
  31713. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31714. /**
  31715. * Fired when the pad state has changed
  31716. */
  31717. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  31718. /**
  31719. * Fired when controllers stick values have changed
  31720. */
  31721. onPadValuesChangedObservable: Observable<StickValues>;
  31722. /**
  31723. * Array of button availible on the controller
  31724. */
  31725. protected _buttons: Array<MutableGamepadButton>;
  31726. private _onButtonStateChange;
  31727. /**
  31728. * Fired when a controller button's state has changed
  31729. * @param callback the callback containing the button that was modified
  31730. */
  31731. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  31732. /**
  31733. * X and Y axis corrisponding to the controllers joystick
  31734. */
  31735. pad: StickValues;
  31736. /**
  31737. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31738. */
  31739. hand: string;
  31740. /**
  31741. * The default controller model for the controller
  31742. */
  31743. readonly defaultModel: AbstractMesh;
  31744. /**
  31745. * Creates a new WebVRController from a gamepad
  31746. * @param vrGamepad the gamepad that the WebVRController should be created from
  31747. */
  31748. constructor(vrGamepad: any);
  31749. /**
  31750. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31751. */
  31752. update(): void;
  31753. /**
  31754. * Function to be called when a button is modified
  31755. */
  31756. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31757. /**
  31758. * Loads a mesh and attaches it to the controller
  31759. * @param scene the scene the mesh should be added to
  31760. * @param meshLoaded callback for when the mesh has been loaded
  31761. */
  31762. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31763. private _setButtonValue(newState, currentState, buttonIndex);
  31764. private _changes;
  31765. private _checkChanges(newState, currentState);
  31766. /**
  31767. * Disposes of th webVRCOntroller
  31768. */
  31769. dispose(): void;
  31770. }
  31771. }
  31772. declare module BABYLON {
  31773. /**
  31774. * Defines the WindowsMotionController object that the state of the windows motion controller
  31775. */
  31776. class WindowsMotionController extends WebVRController {
  31777. /**
  31778. * The base url used to load the left and right controller models
  31779. */
  31780. static MODEL_BASE_URL: string;
  31781. /**
  31782. * The name of the left controller model file
  31783. */
  31784. static MODEL_LEFT_FILENAME: string;
  31785. /**
  31786. * The name of the right controller model file
  31787. */
  31788. static MODEL_RIGHT_FILENAME: string;
  31789. /**
  31790. * The controller name prefix for this controller type
  31791. */
  31792. static readonly GAMEPAD_ID_PREFIX: string;
  31793. /**
  31794. * The controller id pattern for this controller type
  31795. */
  31796. private static readonly GAMEPAD_ID_PATTERN;
  31797. private _loadedMeshInfo;
  31798. private readonly _mapping;
  31799. /**
  31800. * Fired when the trackpad on this controller is clicked
  31801. */
  31802. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  31803. /**
  31804. * Fired when the trackpad on this controller is modified
  31805. */
  31806. onTrackpadValuesChangedObservable: Observable<StickValues>;
  31807. /**
  31808. * The current x and y values of this controller's trackpad
  31809. */
  31810. trackpad: StickValues;
  31811. /**
  31812. * Creates a new WindowsMotionController from a gamepad
  31813. * @param vrGamepad the gamepad that the controller should be created from
  31814. */
  31815. constructor(vrGamepad: any);
  31816. /**
  31817. * Fired when the trigger on this controller is modified
  31818. */
  31819. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31820. /**
  31821. * Fired when the menu button on this controller is modified
  31822. */
  31823. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31824. /**
  31825. * Fired when the grip button on this controller is modified
  31826. */
  31827. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31828. /**
  31829. * Fired when the thumbstick button on this controller is modified
  31830. */
  31831. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31832. /**
  31833. * Fired when the touchpad button on this controller is modified
  31834. */
  31835. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31836. /**
  31837. * Fired when the touchpad values on this controller are modified
  31838. */
  31839. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  31840. private _updateTrackpad();
  31841. /**
  31842. * Called once per frame by the engine.
  31843. */
  31844. update(): void;
  31845. /**
  31846. * Called once for each button that changed state since the last frame
  31847. * @param buttonIdx Which button index changed
  31848. * @param state New state of the button
  31849. * @param changes Which properties on the state changed since last frame
  31850. */
  31851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31852. /**
  31853. * Moves the buttons on the controller mesh based on their current state
  31854. * @param buttonName the name of the button to move
  31855. * @param buttonValue the value of the button which determines the buttons new position
  31856. */
  31857. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  31858. /**
  31859. * Moves the axis on the controller mesh based on its current state
  31860. * @param axis the index of the axis
  31861. * @param axisValue the value of the axis which determines the meshes new position
  31862. * @hidden
  31863. */
  31864. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  31865. /**
  31866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31867. * @param scene scene in which to add meshes
  31868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31869. */
  31870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  31871. /**
  31872. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  31873. * can be transformed by button presses and axes values, based on this._mapping.
  31874. *
  31875. * @param scene scene in which the meshes exist
  31876. * @param meshes list of meshes that make up the controller model to process
  31877. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  31878. */
  31879. private processModel(scene, meshes);
  31880. private createMeshInfo(rootNode);
  31881. /**
  31882. * Gets the ray of the controller in the direction the controller is pointing
  31883. * @param length the length the resulting ray should be
  31884. * @returns a ray in the direction the controller is pointing
  31885. */
  31886. getForwardRay(length?: number): Ray;
  31887. /**
  31888. * Disposes of the controller
  31889. */
  31890. dispose(): void;
  31891. }
  31892. }
  31893. declare module BABYLON {
  31894. /**
  31895. * Background material used to create an efficient environement around your scene.
  31896. */
  31897. class BackgroundMaterial extends PushMaterial {
  31898. /**
  31899. * Standard reflectance value at parallel view angle.
  31900. */
  31901. static StandardReflectance0: number;
  31902. /**
  31903. * Standard reflectance value at grazing angle.
  31904. */
  31905. static StandardReflectance90: number;
  31906. protected _primaryColor: Color3;
  31907. /**
  31908. * Key light Color (multiply against the environement texture)
  31909. */
  31910. primaryColor: Color3;
  31911. protected __perceptualColor: Nullable<Color3>;
  31912. /**
  31913. * Experimental Internal Use Only.
  31914. *
  31915. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31916. * This acts as a helper to set the primary color to a more "human friendly" value.
  31917. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31918. * output color as close as possible from the chosen value.
  31919. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31920. * part of lighting setup.)
  31921. */
  31922. _perceptualColor: Nullable<Color3>;
  31923. protected _primaryColorShadowLevel: float;
  31924. /**
  31925. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31926. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31927. */
  31928. primaryColorShadowLevel: float;
  31929. protected _primaryColorHighlightLevel: float;
  31930. /**
  31931. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31932. * The primary color is used at the level chosen to define what the white area would look.
  31933. */
  31934. primaryColorHighlightLevel: float;
  31935. protected _reflectionTexture: Nullable<BaseTexture>;
  31936. /**
  31937. * Reflection Texture used in the material.
  31938. * Should be author in a specific way for the best result (refer to the documentation).
  31939. */
  31940. reflectionTexture: Nullable<BaseTexture>;
  31941. protected _reflectionBlur: float;
  31942. /**
  31943. * Reflection Texture level of blur.
  31944. *
  31945. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31946. * texture twice.
  31947. */
  31948. reflectionBlur: float;
  31949. protected _diffuseTexture: Nullable<BaseTexture>;
  31950. /**
  31951. * Diffuse Texture used in the material.
  31952. * Should be author in a specific way for the best result (refer to the documentation).
  31953. */
  31954. diffuseTexture: Nullable<BaseTexture>;
  31955. protected _shadowLights: Nullable<IShadowLight[]>;
  31956. /**
  31957. * Specify the list of lights casting shadow on the material.
  31958. * All scene shadow lights will be included if null.
  31959. */
  31960. shadowLights: Nullable<IShadowLight[]>;
  31961. protected _shadowLevel: float;
  31962. /**
  31963. * Helps adjusting the shadow to a softer level if required.
  31964. * 0 means black shadows and 1 means no shadows.
  31965. */
  31966. shadowLevel: float;
  31967. protected _sceneCenter: Vector3;
  31968. /**
  31969. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31970. * It is usually zero but might be interesting to modify according to your setup.
  31971. */
  31972. sceneCenter: Vector3;
  31973. protected _opacityFresnel: boolean;
  31974. /**
  31975. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31976. * This helps ensuring a nice transition when the camera goes under the ground.
  31977. */
  31978. opacityFresnel: boolean;
  31979. protected _reflectionFresnel: boolean;
  31980. /**
  31981. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31982. * This helps adding a mirror texture on the ground.
  31983. */
  31984. reflectionFresnel: boolean;
  31985. protected _reflectionFalloffDistance: number;
  31986. /**
  31987. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31988. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31989. */
  31990. reflectionFalloffDistance: number;
  31991. protected _reflectionAmount: number;
  31992. /**
  31993. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31994. */
  31995. reflectionAmount: number;
  31996. protected _reflectionReflectance0: number;
  31997. /**
  31998. * This specifies the weight of the reflection at grazing angle.
  31999. */
  32000. reflectionReflectance0: number;
  32001. protected _reflectionReflectance90: number;
  32002. /**
  32003. * This specifies the weight of the reflection at a perpendicular point of view.
  32004. */
  32005. reflectionReflectance90: number;
  32006. /**
  32007. * Sets the reflection reflectance fresnel values according to the default standard
  32008. * empirically know to work well :-)
  32009. */
  32010. reflectionStandardFresnelWeight: number;
  32011. protected _useRGBColor: boolean;
  32012. /**
  32013. * Helps to directly use the maps channels instead of their level.
  32014. */
  32015. useRGBColor: boolean;
  32016. protected _enableNoise: boolean;
  32017. /**
  32018. * This helps reducing the banding effect that could occur on the background.
  32019. */
  32020. enableNoise: boolean;
  32021. /**
  32022. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  32023. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  32024. * Recommended to be keep at 1.0 except for special cases.
  32025. */
  32026. fovMultiplier: number;
  32027. private _fovMultiplier;
  32028. /**
  32029. * Enable the FOV adjustment feature controlled by fovMultiplier.
  32030. */
  32031. useEquirectangularFOV: boolean;
  32032. private _maxSimultaneousLights;
  32033. /**
  32034. * Number of Simultaneous lights allowed on the material.
  32035. */
  32036. maxSimultaneousLights: int;
  32037. /**
  32038. * Default configuration related to image processing available in the Background Material.
  32039. */
  32040. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32041. /**
  32042. * Keep track of the image processing observer to allow dispose and replace.
  32043. */
  32044. private _imageProcessingObserver;
  32045. /**
  32046. * Attaches a new image processing configuration to the PBR Material.
  32047. * @param configuration (if null the scene configuration will be use)
  32048. */
  32049. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32050. /**
  32051. * Gets the image processing configuration used either in this material.
  32052. */
  32053. /**
  32054. * Sets the Default image processing configuration used either in the this material.
  32055. *
  32056. * If sets to null, the scene one is in use.
  32057. */
  32058. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  32059. /**
  32060. * Gets wether the color curves effect is enabled.
  32061. */
  32062. /**
  32063. * Sets wether the color curves effect is enabled.
  32064. */
  32065. cameraColorCurvesEnabled: boolean;
  32066. /**
  32067. * Gets wether the color grading effect is enabled.
  32068. */
  32069. /**
  32070. * Gets wether the color grading effect is enabled.
  32071. */
  32072. cameraColorGradingEnabled: boolean;
  32073. /**
  32074. * Gets wether tonemapping is enabled or not.
  32075. */
  32076. /**
  32077. * Sets wether tonemapping is enabled or not
  32078. */
  32079. cameraToneMappingEnabled: boolean;
  32080. /**
  32081. * The camera exposure used on this material.
  32082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32083. * This corresponds to a photographic exposure.
  32084. */
  32085. /**
  32086. * The camera exposure used on this material.
  32087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32088. * This corresponds to a photographic exposure.
  32089. */
  32090. cameraExposure: float;
  32091. /**
  32092. * Gets The camera contrast used on this material.
  32093. */
  32094. /**
  32095. * Sets The camera contrast used on this material.
  32096. */
  32097. cameraContrast: float;
  32098. /**
  32099. * Gets the Color Grading 2D Lookup Texture.
  32100. */
  32101. /**
  32102. * Sets the Color Grading 2D Lookup Texture.
  32103. */
  32104. cameraColorGradingTexture: Nullable<BaseTexture>;
  32105. /**
  32106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32108. * 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;
  32109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32110. */
  32111. /**
  32112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32114. * 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;
  32115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32116. */
  32117. cameraColorCurves: Nullable<ColorCurves>;
  32118. /**
  32119. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  32120. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  32121. */
  32122. switchToBGR: boolean;
  32123. private _renderTargets;
  32124. private _reflectionControls;
  32125. private _white;
  32126. private _primaryShadowColor;
  32127. private _primaryHighlightColor;
  32128. /**
  32129. * Instantiates a Background Material in the given scene
  32130. * @param name The friendly name of the material
  32131. * @param scene The scene to add the material to
  32132. */
  32133. constructor(name: string, scene: Scene);
  32134. /**
  32135. * The entire material has been created in order to prevent overdraw.
  32136. * @returns false
  32137. */
  32138. needAlphaTesting(): boolean;
  32139. /**
  32140. * The entire material has been created in order to prevent overdraw.
  32141. * @returns true if blending is enable
  32142. */
  32143. needAlphaBlending(): boolean;
  32144. /**
  32145. * Checks wether the material is ready to be rendered for a given mesh.
  32146. * @param mesh The mesh to render
  32147. * @param subMesh The submesh to check against
  32148. * @param useInstances Specify wether or not the material is used with instances
  32149. * @returns true if all the dependencies are ready (Textures, Effects...)
  32150. */
  32151. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32152. /**
  32153. * Compute the primary color according to the chosen perceptual color.
  32154. */
  32155. private _computePrimaryColorFromPerceptualColor();
  32156. /**
  32157. * Compute the highlights and shadow colors according to their chosen levels.
  32158. */
  32159. private _computePrimaryColors();
  32160. /**
  32161. * Build the uniform buffer used in the material.
  32162. */
  32163. buildUniformLayout(): void;
  32164. /**
  32165. * Unbind the material.
  32166. */
  32167. unbind(): void;
  32168. /**
  32169. * Bind only the world matrix to the material.
  32170. * @param world The world matrix to bind.
  32171. */
  32172. bindOnlyWorldMatrix(world: Matrix): void;
  32173. /**
  32174. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  32175. * @param world The world matrix to bind.
  32176. * @param subMesh The submesh to bind for.
  32177. */
  32178. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32179. /**
  32180. * Dispose the material.
  32181. * @param forceDisposeEffect Force disposal of the associated effect.
  32182. * @param forceDisposeTextures Force disposal of the associated textures.
  32183. */
  32184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32185. /**
  32186. * Clones the material.
  32187. * @param name The cloned name.
  32188. * @returns The cloned material.
  32189. */
  32190. clone(name: string): BackgroundMaterial;
  32191. /**
  32192. * Serializes the current material to its JSON representation.
  32193. * @returns The JSON representation.
  32194. */
  32195. serialize(): any;
  32196. /**
  32197. * Gets the class name of the material
  32198. * @returns "BackgroundMaterial"
  32199. */
  32200. getClassName(): string;
  32201. /**
  32202. * Parse a JSON input to create back a background material.
  32203. * @param source The JSON data to parse
  32204. * @param scene The scene to create the parsed material in
  32205. * @param rootUrl The root url of the assets the material depends upon
  32206. * @returns the instantiated BackgroundMaterial.
  32207. */
  32208. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  32209. }
  32210. }
  32211. declare module BABYLON {
  32212. /**
  32213. * The Physically based material base class of BJS.
  32214. *
  32215. * This offers the main features of a standard PBR material.
  32216. * For more information, please refer to the documentation :
  32217. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32218. */
  32219. abstract class PBRBaseMaterial extends PushMaterial {
  32220. /**
  32221. * Intensity of the direct lights e.g. the four lights available in your scene.
  32222. * This impacts both the direct diffuse and specular highlights.
  32223. */
  32224. protected _directIntensity: number;
  32225. /**
  32226. * Intensity of the emissive part of the material.
  32227. * This helps controlling the emissive effect without modifying the emissive color.
  32228. */
  32229. protected _emissiveIntensity: number;
  32230. /**
  32231. * Intensity of the environment e.g. how much the environment will light the object
  32232. * either through harmonics for rough material or through the refelction for shiny ones.
  32233. */
  32234. protected _environmentIntensity: number;
  32235. /**
  32236. * This is a special control allowing the reduction of the specular highlights coming from the
  32237. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32238. */
  32239. protected _specularIntensity: number;
  32240. /**
  32241. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32242. */
  32243. private _lightingInfos;
  32244. /**
  32245. * Debug Control allowing disabling the bump map on this material.
  32246. */
  32247. protected _disableBumpMap: boolean;
  32248. /**
  32249. * AKA Diffuse Texture in standard nomenclature.
  32250. */
  32251. protected _albedoTexture: BaseTexture;
  32252. /**
  32253. * AKA Occlusion Texture in other nomenclature.
  32254. */
  32255. protected _ambientTexture: BaseTexture;
  32256. /**
  32257. * AKA Occlusion Texture Intensity in other nomenclature.
  32258. */
  32259. protected _ambientTextureStrength: number;
  32260. /**
  32261. * Stores the alpha values in a texture.
  32262. */
  32263. protected _opacityTexture: BaseTexture;
  32264. /**
  32265. * Stores the reflection values in a texture.
  32266. */
  32267. protected _reflectionTexture: BaseTexture;
  32268. /**
  32269. * Stores the refraction values in a texture.
  32270. */
  32271. protected _refractionTexture: BaseTexture;
  32272. /**
  32273. * Stores the emissive values in a texture.
  32274. */
  32275. protected _emissiveTexture: BaseTexture;
  32276. /**
  32277. * AKA Specular texture in other nomenclature.
  32278. */
  32279. protected _reflectivityTexture: BaseTexture;
  32280. /**
  32281. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32282. */
  32283. protected _metallicTexture: BaseTexture;
  32284. /**
  32285. * Specifies the metallic scalar of the metallic/roughness workflow.
  32286. * Can also be used to scale the metalness values of the metallic texture.
  32287. */
  32288. protected _metallic: number;
  32289. /**
  32290. * Specifies the roughness scalar of the metallic/roughness workflow.
  32291. * Can also be used to scale the roughness values of the metallic texture.
  32292. */
  32293. protected _roughness: number;
  32294. /**
  32295. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32296. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32297. */
  32298. protected _microSurfaceTexture: BaseTexture;
  32299. /**
  32300. * Stores surface normal data used to displace a mesh in a texture.
  32301. */
  32302. protected _bumpTexture: BaseTexture;
  32303. /**
  32304. * Stores the pre-calculated light information of a mesh in a texture.
  32305. */
  32306. protected _lightmapTexture: BaseTexture;
  32307. /**
  32308. * The color of a material in ambient lighting.
  32309. */
  32310. protected _ambientColor: Color3;
  32311. /**
  32312. * AKA Diffuse Color in other nomenclature.
  32313. */
  32314. protected _albedoColor: Color3;
  32315. /**
  32316. * AKA Specular Color in other nomenclature.
  32317. */
  32318. protected _reflectivityColor: Color3;
  32319. /**
  32320. * The color applied when light is reflected from a material.
  32321. */
  32322. protected _reflectionColor: Color3;
  32323. /**
  32324. * The color applied when light is emitted from a material.
  32325. */
  32326. protected _emissiveColor: Color3;
  32327. /**
  32328. * AKA Glossiness in other nomenclature.
  32329. */
  32330. protected _microSurface: number;
  32331. /**
  32332. * source material index of refraction (IOR)' / 'destination material IOR.
  32333. */
  32334. protected _indexOfRefraction: number;
  32335. /**
  32336. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32337. */
  32338. protected _invertRefractionY: boolean;
  32339. /**
  32340. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32341. * Materials half opaque for instance using refraction could benefit from this control.
  32342. */
  32343. protected _linkRefractionWithTransparency: boolean;
  32344. /**
  32345. * Specifies that the material will use the light map as a show map.
  32346. */
  32347. protected _useLightmapAsShadowmap: boolean;
  32348. /**
  32349. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32350. * makes the reflect vector face the model (under horizon).
  32351. */
  32352. protected _useHorizonOcclusion: boolean;
  32353. /**
  32354. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32355. * too much the area relying on ambient texture to define their ambient occlusion.
  32356. */
  32357. protected _useRadianceOcclusion: boolean;
  32358. /**
  32359. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32360. */
  32361. protected _useAlphaFromAlbedoTexture: boolean;
  32362. /**
  32363. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32364. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32365. */
  32366. protected _useSpecularOverAlpha: boolean;
  32367. /**
  32368. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32369. */
  32370. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32371. /**
  32372. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32373. */
  32374. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32375. /**
  32376. * Specifies if the metallic texture contains the roughness information in its green channel.
  32377. */
  32378. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32379. /**
  32380. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32381. */
  32382. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32383. /**
  32384. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32385. */
  32386. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32387. /**
  32388. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32389. */
  32390. protected _useAmbientInGrayScale: boolean;
  32391. /**
  32392. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32393. * The material will try to infer what glossiness each pixel should be.
  32394. */
  32395. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32396. /**
  32397. * BJS is using an harcoded light falloff based on a manually sets up range.
  32398. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32399. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32400. */
  32401. protected _usePhysicalLightFalloff: boolean;
  32402. /**
  32403. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32404. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32405. */
  32406. protected _useRadianceOverAlpha: boolean;
  32407. /**
  32408. * Allows using an object space normal map (instead of tangent space).
  32409. */
  32410. protected _useObjectSpaceNormalMap: boolean;
  32411. /**
  32412. * Allows using the bump map in parallax mode.
  32413. */
  32414. protected _useParallax: boolean;
  32415. /**
  32416. * Allows using the bump map in parallax occlusion mode.
  32417. */
  32418. protected _useParallaxOcclusion: boolean;
  32419. /**
  32420. * Controls the scale bias of the parallax mode.
  32421. */
  32422. protected _parallaxScaleBias: number;
  32423. /**
  32424. * If sets to true, disables all the lights affecting the material.
  32425. */
  32426. protected _disableLighting: boolean;
  32427. /**
  32428. * Number of Simultaneous lights allowed on the material.
  32429. */
  32430. protected _maxSimultaneousLights: number;
  32431. /**
  32432. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32433. */
  32434. protected _invertNormalMapX: boolean;
  32435. /**
  32436. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32437. */
  32438. protected _invertNormalMapY: boolean;
  32439. /**
  32440. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32441. */
  32442. protected _twoSidedLighting: boolean;
  32443. /**
  32444. * Defines the alpha limits in alpha test mode.
  32445. */
  32446. protected _alphaCutOff: number;
  32447. /**
  32448. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32449. */
  32450. protected _forceAlphaTest: boolean;
  32451. /**
  32452. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32453. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32454. */
  32455. protected _useAlphaFresnel: boolean;
  32456. /**
  32457. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32458. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32459. */
  32460. protected _useLinearAlphaFresnel: boolean;
  32461. /**
  32462. * The transparency mode of the material.
  32463. */
  32464. protected _transparencyMode: Nullable<number>;
  32465. /**
  32466. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32467. * from cos thetav and roughness:
  32468. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32469. */
  32470. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32471. /**
  32472. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32473. */
  32474. protected _forceIrradianceInFragment: boolean;
  32475. /**
  32476. * Force normal to face away from face.
  32477. */
  32478. protected _forceNormalForward: boolean;
  32479. /**
  32480. * Enables specular anti aliasing in the PBR shader.
  32481. * It will both interacts on the Geometry for analytical and IBL lighting.
  32482. * It also prefilter the roughness map based on the bump values.
  32483. */
  32484. protected _enableSpecularAntiAliasing: boolean;
  32485. /**
  32486. * Default configuration related to image processing available in the PBR Material.
  32487. */
  32488. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32489. /**
  32490. * Keep track of the image processing observer to allow dispose and replace.
  32491. */
  32492. private _imageProcessingObserver;
  32493. /**
  32494. * Attaches a new image processing configuration to the PBR Material.
  32495. * @param configuration
  32496. */
  32497. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32498. /**
  32499. * Stores the available render targets.
  32500. */
  32501. private _renderTargets;
  32502. /**
  32503. * Sets the global ambient color for the material used in lighting calculations.
  32504. */
  32505. private _globalAmbientColor;
  32506. /**
  32507. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32508. */
  32509. private _useLogarithmicDepth;
  32510. /**
  32511. * If set to true, no lighting calculations will be applied.
  32512. */
  32513. private _unlit;
  32514. /**
  32515. * Instantiates a new PBRMaterial instance.
  32516. *
  32517. * @param name The material name
  32518. * @param scene The scene the material will be use in.
  32519. */
  32520. constructor(name: string, scene: Scene);
  32521. /**
  32522. * Gets the name of the material class.
  32523. */
  32524. getClassName(): string;
  32525. /**
  32526. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32527. */
  32528. /**
  32529. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32530. */
  32531. useLogarithmicDepth: boolean;
  32532. /**
  32533. * Gets the current transparency mode.
  32534. */
  32535. /**
  32536. * Sets the transparency mode of the material.
  32537. *
  32538. * | Value | Type | Description |
  32539. * | ----- | ----------------------------------- | ----------- |
  32540. * | 0 | OPAQUE | |
  32541. * | 1 | ALPHATEST | |
  32542. * | 2 | ALPHABLEND | |
  32543. * | 3 | ALPHATESTANDBLEND | |
  32544. *
  32545. */
  32546. transparencyMode: Nullable<number>;
  32547. /**
  32548. * Returns true if alpha blending should be disabled.
  32549. */
  32550. private readonly _disableAlphaBlending;
  32551. /**
  32552. * Specifies whether or not this material should be rendered in alpha blend mode.
  32553. */
  32554. needAlphaBlending(): boolean;
  32555. /**
  32556. * Specifies if the mesh will require alpha blending.
  32557. * @param mesh - BJS mesh.
  32558. */
  32559. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32560. /**
  32561. * Specifies whether or not this material should be rendered in alpha test mode.
  32562. */
  32563. needAlphaTesting(): boolean;
  32564. /**
  32565. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32566. */
  32567. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32568. /**
  32569. * Gets the texture used for the alpha test.
  32570. */
  32571. getAlphaTestTexture(): BaseTexture;
  32572. /**
  32573. * Stores the reflectivity values based on metallic roughness workflow.
  32574. */
  32575. private static _scaledReflectivity;
  32576. /**
  32577. * Specifies that the submesh is ready to be used.
  32578. * @param mesh - BJS mesh.
  32579. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32580. * @param useInstances - Specifies that instances should be used.
  32581. * @returns - boolean indicating that the submesh is ready or not.
  32582. */
  32583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32584. /**
  32585. * Specifies if the material uses metallic roughness workflow.
  32586. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32587. */
  32588. isMetallicWorkflow(): boolean;
  32589. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32590. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32591. /**
  32592. * Force shader compilation
  32593. */
  32594. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32595. clipPlane: boolean;
  32596. }>): void;
  32597. /**
  32598. * Initializes the uniform buffer layout for the shader.
  32599. */
  32600. buildUniformLayout(): void;
  32601. /**
  32602. * Unbinds the textures.
  32603. */
  32604. unbind(): void;
  32605. /**
  32606. * Binds the submesh data.
  32607. * @param world - The world matrix.
  32608. * @param mesh - The BJS mesh.
  32609. * @param subMesh - A submesh of the BJS mesh.
  32610. */
  32611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32612. /**
  32613. * Returns the animatable textures.
  32614. * @returns - Array of animatable textures.
  32615. */
  32616. getAnimatables(): IAnimatable[];
  32617. /**
  32618. * Returns the texture used for reflections.
  32619. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32620. */
  32621. private _getReflectionTexture();
  32622. /**
  32623. * Returns the texture used for refraction or null if none is used.
  32624. * @returns - Refection texture if present. If no refraction texture and refraction
  32625. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32626. */
  32627. private _getRefractionTexture();
  32628. /**
  32629. * Disposes the resources of the material.
  32630. * @param forceDisposeEffect - Forces the disposal of effects.
  32631. * @param forceDisposeTextures - Forces the disposal of all textures.
  32632. */
  32633. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32634. }
  32635. }
  32636. declare module BABYLON {
  32637. /**
  32638. * The Physically based simple base material of BJS.
  32639. *
  32640. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32641. * It is used as the base class for both the specGloss and metalRough conventions.
  32642. */
  32643. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32644. /**
  32645. * Number of Simultaneous lights allowed on the material.
  32646. */
  32647. maxSimultaneousLights: number;
  32648. /**
  32649. * If sets to true, disables all the lights affecting the material.
  32650. */
  32651. disableLighting: boolean;
  32652. /**
  32653. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32654. */
  32655. environmentTexture: BaseTexture;
  32656. /**
  32657. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32658. */
  32659. invertNormalMapX: boolean;
  32660. /**
  32661. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32662. */
  32663. invertNormalMapY: boolean;
  32664. /**
  32665. * Normal map used in the model.
  32666. */
  32667. normalTexture: BaseTexture;
  32668. /**
  32669. * Emissivie color used to self-illuminate the model.
  32670. */
  32671. emissiveColor: Color3;
  32672. /**
  32673. * Emissivie texture used to self-illuminate the model.
  32674. */
  32675. emissiveTexture: BaseTexture;
  32676. /**
  32677. * Occlusion Channel Strenght.
  32678. */
  32679. occlusionStrength: number;
  32680. /**
  32681. * Occlusion Texture of the material (adding extra occlusion effects).
  32682. */
  32683. occlusionTexture: BaseTexture;
  32684. /**
  32685. * Defines the alpha limits in alpha test mode.
  32686. */
  32687. alphaCutOff: number;
  32688. /**
  32689. * Gets the current double sided mode.
  32690. */
  32691. /**
  32692. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32693. */
  32694. doubleSided: boolean;
  32695. lightmapTexture: BaseTexture;
  32696. useLightmapAsShadowmap: boolean;
  32697. /**
  32698. * Return the active textures of the material.
  32699. */
  32700. getActiveTextures(): BaseTexture[];
  32701. hasTexture(texture: BaseTexture): boolean;
  32702. /**
  32703. * Instantiates a new PBRMaterial instance.
  32704. *
  32705. * @param name The material name
  32706. * @param scene The scene the material will be use in.
  32707. */
  32708. constructor(name: string, scene: Scene);
  32709. getClassName(): string;
  32710. }
  32711. }
  32712. declare module BABYLON {
  32713. /**
  32714. * The Physically based material of BJS.
  32715. *
  32716. * This offers the main features of a standard PBR material.
  32717. * For more information, please refer to the documentation :
  32718. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32719. */
  32720. class PBRMaterial extends PBRBaseMaterial {
  32721. private static _PBRMATERIAL_OPAQUE;
  32722. /**
  32723. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32724. */
  32725. static readonly PBRMATERIAL_OPAQUE: number;
  32726. /**
  32727. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32728. */
  32729. private static _PBRMATERIAL_ALPHATEST;
  32730. /**
  32731. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32732. */
  32733. static readonly PBRMATERIAL_ALPHATEST: number;
  32734. /**
  32735. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32736. */
  32737. private static _PBRMATERIAL_ALPHABLEND;
  32738. /**
  32739. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32740. */
  32741. static readonly PBRMATERIAL_ALPHABLEND: number;
  32742. /**
  32743. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32744. * They are also discarded below the alpha cutoff threshold to improve performances.
  32745. */
  32746. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32747. /**
  32748. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32749. * They are also discarded below the alpha cutoff threshold to improve performances.
  32750. */
  32751. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32752. /**
  32753. * Intensity of the direct lights e.g. the four lights available in your scene.
  32754. * This impacts both the direct diffuse and specular highlights.
  32755. */
  32756. directIntensity: number;
  32757. /**
  32758. * Intensity of the emissive part of the material.
  32759. * This helps controlling the emissive effect without modifying the emissive color.
  32760. */
  32761. emissiveIntensity: number;
  32762. /**
  32763. * Intensity of the environment e.g. how much the environment will light the object
  32764. * either through harmonics for rough material or through the refelction for shiny ones.
  32765. */
  32766. environmentIntensity: number;
  32767. /**
  32768. * This is a special control allowing the reduction of the specular highlights coming from the
  32769. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32770. */
  32771. specularIntensity: number;
  32772. /**
  32773. * Debug Control allowing disabling the bump map on this material.
  32774. */
  32775. disableBumpMap: boolean;
  32776. /**
  32777. * AKA Diffuse Texture in standard nomenclature.
  32778. */
  32779. albedoTexture: BaseTexture;
  32780. /**
  32781. * AKA Occlusion Texture in other nomenclature.
  32782. */
  32783. ambientTexture: BaseTexture;
  32784. /**
  32785. * AKA Occlusion Texture Intensity in other nomenclature.
  32786. */
  32787. ambientTextureStrength: number;
  32788. /**
  32789. * Stores the alpha values in a texture.
  32790. */
  32791. opacityTexture: BaseTexture;
  32792. /**
  32793. * Stores the reflection values in a texture.
  32794. */
  32795. reflectionTexture: Nullable<BaseTexture>;
  32796. /**
  32797. * Stores the emissive values in a texture.
  32798. */
  32799. emissiveTexture: BaseTexture;
  32800. /**
  32801. * AKA Specular texture in other nomenclature.
  32802. */
  32803. reflectivityTexture: BaseTexture;
  32804. /**
  32805. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32806. */
  32807. metallicTexture: BaseTexture;
  32808. /**
  32809. * Specifies the metallic scalar of the metallic/roughness workflow.
  32810. * Can also be used to scale the metalness values of the metallic texture.
  32811. */
  32812. metallic: number;
  32813. /**
  32814. * Specifies the roughness scalar of the metallic/roughness workflow.
  32815. * Can also be used to scale the roughness values of the metallic texture.
  32816. */
  32817. roughness: number;
  32818. /**
  32819. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32820. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32821. */
  32822. microSurfaceTexture: BaseTexture;
  32823. /**
  32824. * Stores surface normal data used to displace a mesh in a texture.
  32825. */
  32826. bumpTexture: BaseTexture;
  32827. /**
  32828. * Stores the pre-calculated light information of a mesh in a texture.
  32829. */
  32830. lightmapTexture: BaseTexture;
  32831. /**
  32832. * Stores the refracted light information in a texture.
  32833. */
  32834. refractionTexture: BaseTexture;
  32835. /**
  32836. * The color of a material in ambient lighting.
  32837. */
  32838. ambientColor: Color3;
  32839. /**
  32840. * AKA Diffuse Color in other nomenclature.
  32841. */
  32842. albedoColor: Color3;
  32843. /**
  32844. * AKA Specular Color in other nomenclature.
  32845. */
  32846. reflectivityColor: Color3;
  32847. /**
  32848. * The color reflected from the material.
  32849. */
  32850. reflectionColor: Color3;
  32851. /**
  32852. * The color emitted from the material.
  32853. */
  32854. emissiveColor: Color3;
  32855. /**
  32856. * AKA Glossiness in other nomenclature.
  32857. */
  32858. microSurface: number;
  32859. /**
  32860. * source material index of refraction (IOR)' / 'destination material IOR.
  32861. */
  32862. indexOfRefraction: number;
  32863. /**
  32864. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32865. */
  32866. invertRefractionY: boolean;
  32867. /**
  32868. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32869. * Materials half opaque for instance using refraction could benefit from this control.
  32870. */
  32871. linkRefractionWithTransparency: boolean;
  32872. useLightmapAsShadowmap: boolean;
  32873. /**
  32874. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32875. */
  32876. useAlphaFromAlbedoTexture: boolean;
  32877. /**
  32878. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32879. */
  32880. forceAlphaTest: boolean;
  32881. /**
  32882. * Defines the alpha limits in alpha test mode.
  32883. */
  32884. alphaCutOff: number;
  32885. /**
  32886. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32887. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32888. */
  32889. useSpecularOverAlpha: boolean;
  32890. /**
  32891. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32892. */
  32893. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32894. /**
  32895. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32896. */
  32897. useRoughnessFromMetallicTextureAlpha: boolean;
  32898. /**
  32899. * Specifies if the metallic texture contains the roughness information in its green channel.
  32900. */
  32901. useRoughnessFromMetallicTextureGreen: boolean;
  32902. /**
  32903. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32904. */
  32905. useMetallnessFromMetallicTextureBlue: boolean;
  32906. /**
  32907. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32908. */
  32909. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32910. /**
  32911. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32912. */
  32913. useAmbientInGrayScale: boolean;
  32914. /**
  32915. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32916. * The material will try to infer what glossiness each pixel should be.
  32917. */
  32918. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32919. /**
  32920. * BJS is using an harcoded light falloff based on a manually sets up range.
  32921. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32922. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32923. */
  32924. usePhysicalLightFalloff: boolean;
  32925. /**
  32926. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32927. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32928. */
  32929. useRadianceOverAlpha: boolean;
  32930. /**
  32931. * Allows using an object space normal map (instead of tangent space).
  32932. */
  32933. useObjectSpaceNormalMap: boolean;
  32934. /**
  32935. * Allows using the bump map in parallax mode.
  32936. */
  32937. useParallax: boolean;
  32938. /**
  32939. * Allows using the bump map in parallax occlusion mode.
  32940. */
  32941. useParallaxOcclusion: boolean;
  32942. /**
  32943. * Controls the scale bias of the parallax mode.
  32944. */
  32945. parallaxScaleBias: number;
  32946. /**
  32947. * If sets to true, disables all the lights affecting the material.
  32948. */
  32949. disableLighting: boolean;
  32950. /**
  32951. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32952. */
  32953. forceIrradianceInFragment: boolean;
  32954. /**
  32955. * Number of Simultaneous lights allowed on the material.
  32956. */
  32957. maxSimultaneousLights: number;
  32958. /**
  32959. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32960. */
  32961. invertNormalMapX: boolean;
  32962. /**
  32963. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32964. */
  32965. invertNormalMapY: boolean;
  32966. /**
  32967. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32968. */
  32969. twoSidedLighting: boolean;
  32970. /**
  32971. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32972. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32973. */
  32974. useAlphaFresnel: boolean;
  32975. /**
  32976. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32977. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32978. */
  32979. useLinearAlphaFresnel: boolean;
  32980. /**
  32981. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32982. * And/Or occlude the blended part.
  32983. */
  32984. environmentBRDFTexture: Nullable<BaseTexture>;
  32985. /**
  32986. * Force normal to face away from face.
  32987. */
  32988. forceNormalForward: boolean;
  32989. /**
  32990. * Enables specular anti aliasing in the PBR shader.
  32991. * It will both interacts on the Geometry for analytical and IBL lighting.
  32992. * It also prefilter the roughness map based on the bump values.
  32993. */
  32994. enableSpecularAntiAliasing: boolean;
  32995. /**
  32996. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32997. * makes the reflect vector face the model (under horizon).
  32998. */
  32999. useHorizonOcclusion: boolean;
  33000. /**
  33001. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33002. * too much the area relying on ambient texture to define their ambient occlusion.
  33003. */
  33004. useRadianceOcclusion: boolean;
  33005. /**
  33006. * If set to true, no lighting calculations will be applied.
  33007. */
  33008. unlit: boolean;
  33009. /**
  33010. * Gets the image processing configuration used either in this material.
  33011. */
  33012. /**
  33013. * Sets the Default image processing configuration used either in the this material.
  33014. *
  33015. * If sets to null, the scene one is in use.
  33016. */
  33017. imageProcessingConfiguration: ImageProcessingConfiguration;
  33018. /**
  33019. * Gets wether the color curves effect is enabled.
  33020. */
  33021. /**
  33022. * Sets wether the color curves effect is enabled.
  33023. */
  33024. cameraColorCurvesEnabled: boolean;
  33025. /**
  33026. * Gets wether the color grading effect is enabled.
  33027. */
  33028. /**
  33029. * Gets wether the color grading effect is enabled.
  33030. */
  33031. cameraColorGradingEnabled: boolean;
  33032. /**
  33033. * Gets wether tonemapping is enabled or not.
  33034. */
  33035. /**
  33036. * Sets wether tonemapping is enabled or not
  33037. */
  33038. cameraToneMappingEnabled: boolean;
  33039. /**
  33040. * The camera exposure used on this material.
  33041. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33042. * This corresponds to a photographic exposure.
  33043. */
  33044. /**
  33045. * The camera exposure used on this material.
  33046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33047. * This corresponds to a photographic exposure.
  33048. */
  33049. cameraExposure: number;
  33050. /**
  33051. * Gets The camera contrast used on this material.
  33052. */
  33053. /**
  33054. * Sets The camera contrast used on this material.
  33055. */
  33056. cameraContrast: number;
  33057. /**
  33058. * Gets the Color Grading 2D Lookup Texture.
  33059. */
  33060. /**
  33061. * Sets the Color Grading 2D Lookup Texture.
  33062. */
  33063. cameraColorGradingTexture: Nullable<BaseTexture>;
  33064. /**
  33065. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33066. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33067. * 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;
  33068. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33069. */
  33070. /**
  33071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33073. * 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;
  33074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33075. */
  33076. cameraColorCurves: Nullable<ColorCurves>;
  33077. /**
  33078. * Instantiates a new PBRMaterial instance.
  33079. *
  33080. * @param name The material name
  33081. * @param scene The scene the material will be use in.
  33082. */
  33083. constructor(name: string, scene: Scene);
  33084. /**
  33085. * Returns the name of this material class.
  33086. */
  33087. getClassName(): string;
  33088. /**
  33089. * Returns an array of the actively used textures.
  33090. * @returns - Array of BaseTextures
  33091. */
  33092. getActiveTextures(): BaseTexture[];
  33093. /**
  33094. * Checks to see if a texture is used in the material.
  33095. * @param texture - Base texture to use.
  33096. * @returns - Boolean specifying if a texture is used in the material.
  33097. */
  33098. hasTexture(texture: BaseTexture): boolean;
  33099. /**
  33100. * Makes a duplicate of the current material.
  33101. * @param name - name to use for the new material.
  33102. */
  33103. clone(name: string): PBRMaterial;
  33104. /**
  33105. * Serializes this PBR Material.
  33106. * @returns - An object with the serialized material.
  33107. */
  33108. serialize(): any;
  33109. /**
  33110. * Parses a PBR Material from a serialized object.
  33111. * @param source - Serialized object.
  33112. * @param scene - BJS scene instance.
  33113. * @param rootUrl - url for the scene object
  33114. * @returns - PBRMaterial
  33115. */
  33116. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  33117. }
  33118. }
  33119. declare module BABYLON {
  33120. /**
  33121. * The PBR material of BJS following the metal roughness convention.
  33122. *
  33123. * This fits to the PBR convention in the GLTF definition:
  33124. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  33125. */
  33126. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  33127. /**
  33128. * The base color has two different interpretations depending on the value of metalness.
  33129. * When the material is a metal, the base color is the specific measured reflectance value
  33130. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  33131. * of the material.
  33132. */
  33133. baseColor: Color3;
  33134. /**
  33135. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  33136. * well as opacity information in the alpha channel.
  33137. */
  33138. baseTexture: BaseTexture;
  33139. /**
  33140. * Specifies the metallic scalar value of the material.
  33141. * Can also be used to scale the metalness values of the metallic texture.
  33142. */
  33143. metallic: number;
  33144. /**
  33145. * Specifies the roughness scalar value of the material.
  33146. * Can also be used to scale the roughness values of the metallic texture.
  33147. */
  33148. roughness: number;
  33149. /**
  33150. * Texture containing both the metallic value in the B channel and the
  33151. * roughness value in the G channel to keep better precision.
  33152. */
  33153. metallicRoughnessTexture: BaseTexture;
  33154. /**
  33155. * Instantiates a new PBRMetalRoughnessMaterial instance.
  33156. *
  33157. * @param name The material name
  33158. * @param scene The scene the material will be use in.
  33159. */
  33160. constructor(name: string, scene: Scene);
  33161. /**
  33162. * Return the currrent class name of the material.
  33163. */
  33164. getClassName(): string;
  33165. /**
  33166. * Return the active textures of the material.
  33167. */
  33168. getActiveTextures(): BaseTexture[];
  33169. /**
  33170. * Checks to see if a texture is used in the material.
  33171. * @param texture - Base texture to use.
  33172. * @returns - Boolean specifying if a texture is used in the material.
  33173. */
  33174. hasTexture(texture: BaseTexture): boolean;
  33175. /**
  33176. * Makes a duplicate of the current material.
  33177. * @param name - name to use for the new material.
  33178. */
  33179. clone(name: string): PBRMetallicRoughnessMaterial;
  33180. /**
  33181. * Serialize the material to a parsable JSON object.
  33182. */
  33183. serialize(): any;
  33184. /**
  33185. * Parses a JSON object correponding to the serialize function.
  33186. */
  33187. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33188. }
  33189. }
  33190. declare module BABYLON {
  33191. /**
  33192. * The PBR material of BJS following the specular glossiness convention.
  33193. *
  33194. * This fits to the PBR convention in the GLTF definition:
  33195. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33196. */
  33197. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33198. /**
  33199. * Specifies the diffuse color of the material.
  33200. */
  33201. diffuseColor: Color3;
  33202. /**
  33203. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33204. * channel.
  33205. */
  33206. diffuseTexture: BaseTexture;
  33207. /**
  33208. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33209. */
  33210. specularColor: Color3;
  33211. /**
  33212. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33213. */
  33214. glossiness: number;
  33215. /**
  33216. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33217. */
  33218. specularGlossinessTexture: BaseTexture;
  33219. /**
  33220. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33221. *
  33222. * @param name The material name
  33223. * @param scene The scene the material will be use in.
  33224. */
  33225. constructor(name: string, scene: Scene);
  33226. /**
  33227. * Return the currrent class name of the material.
  33228. */
  33229. getClassName(): string;
  33230. /**
  33231. * Return the active textures of the material.
  33232. */
  33233. getActiveTextures(): BaseTexture[];
  33234. /**
  33235. * Checks to see if a texture is used in the material.
  33236. * @param texture - Base texture to use.
  33237. * @returns - Boolean specifying if a texture is used in the material.
  33238. */
  33239. hasTexture(texture: BaseTexture): boolean;
  33240. /**
  33241. * Makes a duplicate of the current material.
  33242. * @param name - name to use for the new material.
  33243. */
  33244. clone(name: string): PBRSpecularGlossinessMaterial;
  33245. /**
  33246. * Serialize the material to a parsable JSON object.
  33247. */
  33248. serialize(): any;
  33249. /**
  33250. * Parses a JSON object correponding to the serialize function.
  33251. */
  33252. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33253. }
  33254. }
  33255. declare module BABYLON {
  33256. class BaseTexture {
  33257. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33258. name: string;
  33259. private _hasAlpha;
  33260. hasAlpha: boolean;
  33261. getAlphaFromRGB: boolean;
  33262. level: number;
  33263. coordinatesIndex: number;
  33264. private _coordinatesMode;
  33265. /**
  33266. * How a texture is mapped.
  33267. *
  33268. * | Value | Type | Description |
  33269. * | ----- | ----------------------------------- | ----------- |
  33270. * | 0 | EXPLICIT_MODE | |
  33271. * | 1 | SPHERICAL_MODE | |
  33272. * | 2 | PLANAR_MODE | |
  33273. * | 3 | CUBIC_MODE | |
  33274. * | 4 | PROJECTION_MODE | |
  33275. * | 5 | SKYBOX_MODE | |
  33276. * | 6 | INVCUBIC_MODE | |
  33277. * | 7 | EQUIRECTANGULAR_MODE | |
  33278. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33279. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33280. */
  33281. coordinatesMode: number;
  33282. /**
  33283. * | Value | Type | Description |
  33284. * | ----- | ------------------ | ----------- |
  33285. * | 0 | CLAMP_ADDRESSMODE | |
  33286. * | 1 | WRAP_ADDRESSMODE | |
  33287. * | 2 | MIRROR_ADDRESSMODE | |
  33288. */
  33289. wrapU: number;
  33290. /**
  33291. * | Value | Type | Description |
  33292. * | ----- | ------------------ | ----------- |
  33293. * | 0 | CLAMP_ADDRESSMODE | |
  33294. * | 1 | WRAP_ADDRESSMODE | |
  33295. * | 2 | MIRROR_ADDRESSMODE | |
  33296. */
  33297. wrapV: number;
  33298. /**
  33299. * | Value | Type | Description |
  33300. * | ----- | ------------------ | ----------- |
  33301. * | 0 | CLAMP_ADDRESSMODE | |
  33302. * | 1 | WRAP_ADDRESSMODE | |
  33303. * | 2 | MIRROR_ADDRESSMODE | |
  33304. */
  33305. wrapR: number;
  33306. anisotropicFilteringLevel: number;
  33307. isCube: boolean;
  33308. is3D: boolean;
  33309. gammaSpace: boolean;
  33310. /**
  33311. * Gets whether or not the texture contains RGBD data.
  33312. */
  33313. readonly isRGBD: boolean;
  33314. invertZ: boolean;
  33315. lodLevelInAlpha: boolean;
  33316. lodGenerationOffset: number;
  33317. lodGenerationScale: number;
  33318. isRenderTarget: boolean;
  33319. readonly uid: string;
  33320. toString(): string;
  33321. getClassName(): string;
  33322. animations: Animation[];
  33323. /**
  33324. * An event triggered when the texture is disposed.
  33325. */
  33326. onDisposeObservable: Observable<BaseTexture>;
  33327. private _onDisposeObserver;
  33328. onDispose: () => void;
  33329. delayLoadState: number;
  33330. private _scene;
  33331. _texture: Nullable<InternalTexture>;
  33332. private _uid;
  33333. readonly isBlocking: boolean;
  33334. constructor(scene: Nullable<Scene>);
  33335. getScene(): Nullable<Scene>;
  33336. getTextureMatrix(): Matrix;
  33337. getReflectionTextureMatrix(): Matrix;
  33338. getInternalTexture(): Nullable<InternalTexture>;
  33339. isReadyOrNotBlocking(): boolean;
  33340. isReady(): boolean;
  33341. private _cachedSize;
  33342. getSize(): ISize;
  33343. getBaseSize(): ISize;
  33344. scale(ratio: number): void;
  33345. readonly canRescale: boolean;
  33346. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  33347. _rebuild(): void;
  33348. delayLoad(): void;
  33349. clone(): Nullable<BaseTexture>;
  33350. readonly textureType: number;
  33351. readonly textureFormat: number;
  33352. /**
  33353. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33354. * This will returns an RGBA array buffer containing either in values (0-255) or
  33355. * float values (0-1) depending of the underlying buffer type.
  33356. * @param faceIndex The face of the texture to read (in case of cube texture)
  33357. * @param level The LOD level of the texture to read (in case of Mip Maps)
  33358. * @returns The Array buffer containing the pixels data.
  33359. */
  33360. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  33361. releaseInternalTexture(): void;
  33362. sphericalPolynomial: Nullable<SphericalPolynomial>;
  33363. readonly _lodTextureHigh: Nullable<BaseTexture>;
  33364. readonly _lodTextureMid: Nullable<BaseTexture>;
  33365. readonly _lodTextureLow: Nullable<BaseTexture>;
  33366. dispose(): void;
  33367. serialize(): any;
  33368. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33369. }
  33370. }
  33371. declare module BABYLON {
  33372. /**
  33373. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  33374. * It can help converting any input color in a desired output one. This can then be used to create effects
  33375. * from sepia, black and white to sixties or futuristic rendering...
  33376. *
  33377. * The only supported format is currently 3dl.
  33378. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  33379. */
  33380. class ColorGradingTexture extends BaseTexture {
  33381. /**
  33382. * The current texture matrix. (will always be identity in color grading texture)
  33383. */
  33384. private _textureMatrix;
  33385. /**
  33386. * The texture URL.
  33387. */
  33388. url: string;
  33389. /**
  33390. * Empty line regex stored for GC.
  33391. */
  33392. private static _noneEmptyLineRegex;
  33393. private _engine;
  33394. /**
  33395. * Instantiates a ColorGradingTexture from the following parameters.
  33396. *
  33397. * @param url The location of the color gradind data (currently only supporting 3dl)
  33398. * @param scene The scene the texture will be used in
  33399. */
  33400. constructor(url: string, scene: Scene);
  33401. /**
  33402. * Returns the texture matrix used in most of the material.
  33403. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  33404. */
  33405. getTextureMatrix(): Matrix;
  33406. /**
  33407. * Occurs when the file being loaded is a .3dl LUT file.
  33408. */
  33409. private load3dlTexture();
  33410. /**
  33411. * Starts the loading process of the texture.
  33412. */
  33413. private loadTexture();
  33414. /**
  33415. * Clones the color gradind texture.
  33416. */
  33417. clone(): ColorGradingTexture;
  33418. /**
  33419. * Called during delayed load for textures.
  33420. */
  33421. delayLoad(): void;
  33422. /**
  33423. * Parses a color grading texture serialized by Babylon.
  33424. * @param parsedTexture The texture information being parsedTexture
  33425. * @param scene The scene to load the texture in
  33426. * @param rootUrl The root url of the data assets to load
  33427. * @return A color gradind texture
  33428. */
  33429. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  33430. /**
  33431. * Serializes the LUT texture to json format.
  33432. */
  33433. serialize(): any;
  33434. }
  33435. }
  33436. declare module BABYLON {
  33437. class CubeTexture extends BaseTexture {
  33438. url: string;
  33439. coordinatesMode: number;
  33440. /**
  33441. * Gets or sets the center of the bounding box associated with the cube texture
  33442. * It must define where the camera used to render the texture was set
  33443. */
  33444. boundingBoxPosition: Vector3;
  33445. private _boundingBoxSize;
  33446. /**
  33447. * Gets or sets the size of the bounding box associated with the cube texture
  33448. * When defined, the cubemap will switch to local mode
  33449. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33450. * @example https://www.babylonjs-playground.com/#RNASML
  33451. */
  33452. boundingBoxSize: Vector3;
  33453. protected _rotationY: number;
  33454. /**
  33455. * Gets texture matrix rotation angle around Y axis radians.
  33456. */
  33457. /**
  33458. * Sets texture matrix rotation angle around Y axis in radians.
  33459. */
  33460. rotationY: number;
  33461. private _noMipmap;
  33462. private _files;
  33463. private _extensions;
  33464. private _textureMatrix;
  33465. private _format;
  33466. private _createPolynomials;
  33467. /** @hidden */
  33468. readonly _prefiltered: boolean;
  33469. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33470. /**
  33471. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33472. * @param url defines the url of the prefiltered texture
  33473. * @param scene defines the scene the texture is attached to
  33474. * @param forcedExtension defines the extension of the file if different from the url
  33475. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33476. * @return the prefiltered texture
  33477. */
  33478. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33479. /**
  33480. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33481. * as prefiltered data.
  33482. * @param rootUrl defines the url of the texture or the root name of the six images
  33483. * @param scene defines the scene the texture is attached to
  33484. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33485. * @param noMipmap defines if mipmaps should be created or not
  33486. * @param files defines the six files to load for the different faces
  33487. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33488. * @param onError defines a callback triggered in case of error during load
  33489. * @param format defines the internal format to use for the texture once loaded
  33490. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33491. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33492. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  33494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  33495. * @return the cube texture
  33496. */
  33497. 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);
  33498. delayLoad(): void;
  33499. getReflectionTextureMatrix(): Matrix;
  33500. setReflectionTextureMatrix(value: Matrix): void;
  33501. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33502. clone(): CubeTexture;
  33503. }
  33504. }
  33505. declare module BABYLON {
  33506. /**
  33507. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33508. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33509. */
  33510. class DynamicTexture extends Texture {
  33511. private _generateMipMaps;
  33512. private _canvas;
  33513. private _context;
  33514. private _engine;
  33515. /**
  33516. * Creates a {BABYLON.DynamicTexture}
  33517. * @param name defines the name of the texture
  33518. * @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
  33519. * @param scene defines the scene where you want the texture
  33520. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33521. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33522. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33523. */
  33524. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33525. /**
  33526. * Gets the current state of canRescale
  33527. */
  33528. readonly canRescale: boolean;
  33529. private _recreate(textureSize);
  33530. /**
  33531. * Scales the texture
  33532. * @param ratio the scale factor to apply to both width and height
  33533. */
  33534. scale(ratio: number): void;
  33535. /**
  33536. * Resizes the texture
  33537. * @param width the new width
  33538. * @param height the new height
  33539. */
  33540. scaleTo(width: number, height: number): void;
  33541. /**
  33542. * Gets the context of the canvas used by the texture
  33543. * @returns the canvas context of the dynamic texture
  33544. */
  33545. getContext(): CanvasRenderingContext2D;
  33546. /**
  33547. * Clears the texture
  33548. */
  33549. clear(): void;
  33550. /**
  33551. * Updates the texture
  33552. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33553. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33554. */
  33555. update(invertY?: boolean, premulAlpha?: boolean): void;
  33556. /**
  33557. * Draws text onto the texture
  33558. * @param text defines the text to be drawn
  33559. * @param x defines the placement of the text from the left
  33560. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33561. * @param font defines the font to be used with font-style, font-size, font-name
  33562. * @param color defines the color used for the text
  33563. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33564. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33565. * @param update defines whether texture is immediately update (default is true)
  33566. */
  33567. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33568. /**
  33569. * Clones the texture
  33570. * @returns the clone of the texture.
  33571. */
  33572. clone(): DynamicTexture;
  33573. /** @hidden */
  33574. _rebuild(): void;
  33575. }
  33576. }
  33577. declare module BABYLON {
  33578. /**
  33579. * This represents a texture coming from an HDR input.
  33580. *
  33581. * The only supported format is currently panorama picture stored in RGBE format.
  33582. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33583. */
  33584. class HDRCubeTexture extends BaseTexture {
  33585. private static _facesMapping;
  33586. private _generateHarmonics;
  33587. private _noMipmap;
  33588. private _textureMatrix;
  33589. private _size;
  33590. private _onLoad;
  33591. private _onError;
  33592. /**
  33593. * The texture URL.
  33594. */
  33595. url: string;
  33596. /**
  33597. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33598. */
  33599. coordinatesMode: number;
  33600. protected _isBlocking: boolean;
  33601. /**
  33602. * Gets wether or not the texture is blocking during loading.
  33603. */
  33604. /**
  33605. * Sets wether or not the texture is blocking during loading.
  33606. */
  33607. isBlocking: boolean;
  33608. protected _rotationY: number;
  33609. /**
  33610. * Gets texture matrix rotation angle around Y axis radians.
  33611. */
  33612. /**
  33613. * Sets texture matrix rotation angle around Y axis in radians.
  33614. */
  33615. rotationY: number;
  33616. /**
  33617. * Gets or sets the center of the bounding box associated with the cube texture
  33618. * It must define where the camera used to render the texture was set
  33619. */
  33620. boundingBoxPosition: Vector3;
  33621. private _boundingBoxSize;
  33622. /**
  33623. * Gets or sets the size of the bounding box associated with the cube texture
  33624. * When defined, the cubemap will switch to local mode
  33625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33626. * @example https://www.babylonjs-playground.com/#RNASML
  33627. */
  33628. boundingBoxSize: Vector3;
  33629. /**
  33630. * Instantiates an HDRTexture from the following parameters.
  33631. *
  33632. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33633. * @param scene The scene the texture will be used in
  33634. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33635. * @param noMipmap Forces to not generate the mipmap if true
  33636. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33637. * @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)
  33638. * @param reserved Reserved flag for internal use.
  33639. */
  33640. 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>);
  33641. /**
  33642. * Occurs when the file is raw .hdr file.
  33643. */
  33644. private loadTexture();
  33645. clone(): HDRCubeTexture;
  33646. delayLoad(): void;
  33647. getReflectionTextureMatrix(): Matrix;
  33648. setReflectionTextureMatrix(value: Matrix): void;
  33649. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33650. serialize(): any;
  33651. }
  33652. }
  33653. declare module BABYLON {
  33654. /**
  33655. * Class used to store data associated with WebGL texture data for the engine
  33656. * This class should not be used directly
  33657. */
  33658. class InternalTexture implements IInternalTextureTracker {
  33659. /**
  33660. * The source of the texture data is unknown
  33661. */
  33662. static DATASOURCE_UNKNOWN: number;
  33663. /**
  33664. * Texture data comes from an URL
  33665. */
  33666. static DATASOURCE_URL: number;
  33667. /**
  33668. * Texture data is only used for temporary storage
  33669. */
  33670. static DATASOURCE_TEMP: number;
  33671. /**
  33672. * Texture data comes from raw data (ArrayBuffer)
  33673. */
  33674. static DATASOURCE_RAW: number;
  33675. /**
  33676. * Texture content is dynamic (video or dynamic texture)
  33677. */
  33678. static DATASOURCE_DYNAMIC: number;
  33679. /**
  33680. * Texture content is generated by rendering to it
  33681. */
  33682. static DATASOURCE_RENDERTARGET: number;
  33683. /**
  33684. * Texture content is part of a multi render target process
  33685. */
  33686. static DATASOURCE_MULTIRENDERTARGET: number;
  33687. /**
  33688. * Texture data comes from a cube data file
  33689. */
  33690. static DATASOURCE_CUBE: number;
  33691. /**
  33692. * Texture data comes from a raw cube data
  33693. */
  33694. static DATASOURCE_CUBERAW: number;
  33695. /**
  33696. * Texture data come from a prefiltered cube data file
  33697. */
  33698. static DATASOURCE_CUBEPREFILTERED: number;
  33699. /**
  33700. * Texture content is raw 3D data
  33701. */
  33702. static DATASOURCE_RAW3D: number;
  33703. /**
  33704. * Texture content is a depth texture
  33705. */
  33706. static DATASOURCE_DEPTHTEXTURE: number;
  33707. /**
  33708. * Defines if the texture is ready
  33709. */
  33710. isReady: boolean;
  33711. /**
  33712. * Defines if the texture is a cube texture
  33713. */
  33714. isCube: boolean;
  33715. /**
  33716. * Defines if the texture contains 3D data
  33717. */
  33718. is3D: boolean;
  33719. /**
  33720. * Gets the URL used to load this texture
  33721. */
  33722. url: string;
  33723. /**
  33724. * Gets the sampling mode of the texture
  33725. */
  33726. samplingMode: number;
  33727. /**
  33728. * Gets a boolean indicating if the texture needs mipmaps generation
  33729. */
  33730. generateMipMaps: boolean;
  33731. /**
  33732. * Gets the number of samples used by the texture (WebGL2+ only)
  33733. */
  33734. samples: number;
  33735. /**
  33736. * Gets the type of the texture
  33737. */
  33738. type: number;
  33739. /**
  33740. * Gets the format of the texture
  33741. */
  33742. format: number;
  33743. /**
  33744. * Observable called when the texture is loaded
  33745. */
  33746. onLoadedObservable: Observable<InternalTexture>;
  33747. /**
  33748. * Gets the width of the texture
  33749. */
  33750. width: number;
  33751. /**
  33752. * Gets the height of the texture
  33753. */
  33754. height: number;
  33755. /**
  33756. * Gets the depth of the texture
  33757. */
  33758. depth: number;
  33759. /**
  33760. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33761. */
  33762. baseWidth: number;
  33763. /**
  33764. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33765. */
  33766. baseHeight: number;
  33767. /**
  33768. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33769. */
  33770. baseDepth: number;
  33771. /**
  33772. * Gets a boolean indicating if the texture is inverted on Y axis
  33773. */
  33774. invertY: boolean;
  33775. /**
  33776. * Gets or set the previous tracker in the list
  33777. */
  33778. previous: Nullable<IInternalTextureTracker>;
  33779. /**
  33780. * Gets or set the next tracker in the list
  33781. */
  33782. next: Nullable<IInternalTextureTracker>;
  33783. /** @hidden */
  33784. _initialSlot: number;
  33785. /** @hidden */
  33786. _designatedSlot: number;
  33787. /** @hidden */
  33788. _dataSource: number;
  33789. /** @hidden */
  33790. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  33791. /** @hidden */
  33792. _bufferView: Nullable<ArrayBufferView>;
  33793. /** @hidden */
  33794. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33795. /** @hidden */
  33796. _size: number;
  33797. /** @hidden */
  33798. _extension: string;
  33799. /** @hidden */
  33800. _files: Nullable<string[]>;
  33801. /** @hidden */
  33802. _workingCanvas: HTMLCanvasElement;
  33803. /** @hidden */
  33804. _workingContext: CanvasRenderingContext2D;
  33805. /** @hidden */
  33806. _framebuffer: Nullable<WebGLFramebuffer>;
  33807. /** @hidden */
  33808. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33809. /** @hidden */
  33810. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33811. /** @hidden */
  33812. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33813. /** @hidden */
  33814. _attachments: Nullable<number[]>;
  33815. /** @hidden */
  33816. _cachedCoordinatesMode: Nullable<number>;
  33817. /** @hidden */
  33818. _cachedWrapU: Nullable<number>;
  33819. /** @hidden */
  33820. _cachedWrapV: Nullable<number>;
  33821. /** @hidden */
  33822. _cachedWrapR: Nullable<number>;
  33823. /** @hidden */
  33824. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33825. /** @hidden */
  33826. _isDisabled: boolean;
  33827. /** @hidden */
  33828. _compression: Nullable<string>;
  33829. /** @hidden */
  33830. _generateStencilBuffer: boolean;
  33831. /** @hidden */
  33832. _generateDepthBuffer: boolean;
  33833. /** @hidden */
  33834. _comparisonFunction: number;
  33835. /** @hidden */
  33836. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33837. /** @hidden */
  33838. _lodGenerationScale: number;
  33839. /** @hidden */
  33840. _lodGenerationOffset: number;
  33841. /** @hidden */
  33842. _lodTextureHigh: BaseTexture;
  33843. /** @hidden */
  33844. _lodTextureMid: BaseTexture;
  33845. /** @hidden */
  33846. _lodTextureLow: BaseTexture;
  33847. /** @hidden */
  33848. _isRGBD: boolean;
  33849. /** @hidden */
  33850. _webGLTexture: Nullable<WebGLTexture>;
  33851. /** @hidden */
  33852. _references: number;
  33853. private _engine;
  33854. /**
  33855. * Gets the Engine the texture belongs to.
  33856. * @returns The babylon engine
  33857. */
  33858. getEngine(): Engine;
  33859. /**
  33860. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33861. */
  33862. readonly dataSource: number;
  33863. /**
  33864. * Creates a new InternalTexture
  33865. * @param engine defines the engine to use
  33866. * @param dataSource defines the type of data that will be used
  33867. */
  33868. constructor(engine: Engine, dataSource: number);
  33869. /**
  33870. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33871. */
  33872. incrementReferences(): void;
  33873. /**
  33874. * Change the size of the texture (not the size of the content)
  33875. * @param width defines the new width
  33876. * @param height defines the new height
  33877. * @param depth defines the new depth (1 by default)
  33878. */
  33879. updateSize(width: int, height: int, depth?: int): void;
  33880. /** @hidden */
  33881. _rebuild(): void;
  33882. _swapAndDie(target: InternalTexture): void;
  33883. /**
  33884. * Dispose the current allocated resources
  33885. */
  33886. dispose(): void;
  33887. }
  33888. }
  33889. declare module BABYLON {
  33890. /**
  33891. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33892. */
  33893. interface IInternalTextureTracker {
  33894. /**
  33895. * Gets or set the previous tracker in the list
  33896. */
  33897. previous: Nullable<IInternalTextureTracker>;
  33898. /**
  33899. * Gets or set the next tracker in the list
  33900. */
  33901. next: Nullable<IInternalTextureTracker>;
  33902. }
  33903. /**
  33904. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33905. */
  33906. class DummyInternalTextureTracker {
  33907. /**
  33908. * Gets or set the previous tracker in the list
  33909. */
  33910. previous: Nullable<IInternalTextureTracker>;
  33911. /**
  33912. * Gets or set the next tracker in the list
  33913. */
  33914. next: Nullable<IInternalTextureTracker>;
  33915. }
  33916. }
  33917. declare module BABYLON {
  33918. class MirrorTexture extends RenderTargetTexture {
  33919. private scene;
  33920. mirrorPlane: Plane;
  33921. private _transformMatrix;
  33922. private _mirrorMatrix;
  33923. private _savedViewMatrix;
  33924. private _blurX;
  33925. private _blurY;
  33926. private _adaptiveBlurKernel;
  33927. private _blurKernelX;
  33928. private _blurKernelY;
  33929. private _blurRatio;
  33930. blurRatio: number;
  33931. adaptiveBlurKernel: number;
  33932. blurKernel: number;
  33933. blurKernelX: number;
  33934. blurKernelY: number;
  33935. private _autoComputeBlurKernel();
  33936. protected _onRatioRescale(): void;
  33937. private _updateGammaSpace();
  33938. private _imageProcessingConfigChangeObserver;
  33939. constructor(name: string, size: number | {
  33940. width: number;
  33941. height: number;
  33942. } | {
  33943. ratio: number;
  33944. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33945. private _preparePostProcesses();
  33946. clone(): MirrorTexture;
  33947. serialize(): any;
  33948. dispose(): void;
  33949. }
  33950. }
  33951. declare module BABYLON {
  33952. interface IMultiRenderTargetOptions {
  33953. generateMipMaps?: boolean;
  33954. types?: number[];
  33955. samplingModes?: number[];
  33956. generateDepthBuffer?: boolean;
  33957. generateStencilBuffer?: boolean;
  33958. generateDepthTexture?: boolean;
  33959. textureCount?: number;
  33960. doNotChangeAspectRatio?: boolean;
  33961. defaultType?: number;
  33962. }
  33963. class MultiRenderTarget extends RenderTargetTexture {
  33964. private _internalTextures;
  33965. private _textures;
  33966. readonly isSupported: boolean;
  33967. private _multiRenderTargetOptions;
  33968. readonly textures: Texture[];
  33969. readonly depthTexture: Texture;
  33970. wrapU: number;
  33971. wrapV: number;
  33972. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33973. _rebuild(): void;
  33974. private _createInternalTextures();
  33975. private _createTextures();
  33976. samples: number;
  33977. resize(size: any): void;
  33978. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33979. dispose(): void;
  33980. releaseInternalTextures(): void;
  33981. }
  33982. }
  33983. declare module BABYLON {
  33984. class RawTexture extends Texture {
  33985. format: number;
  33986. private _engine;
  33987. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33988. update(data: ArrayBufferView): void;
  33989. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33990. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33991. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33992. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33993. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33994. }
  33995. }
  33996. declare module BABYLON {
  33997. /**
  33998. * Class used to store 3D textures containing user data
  33999. */
  34000. class RawTexture3D extends Texture {
  34001. /** Gets or sets the texture format to use */
  34002. format: number;
  34003. private _engine;
  34004. /**
  34005. * Create a new RawTexture3D
  34006. * @param data defines the data of the texture
  34007. * @param width defines the width of the texture
  34008. * @param height defines the height of the texture
  34009. * @param depth defines the depth of the texture
  34010. * @param format defines the texture format to use
  34011. * @param scene defines the hosting scene
  34012. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  34013. * @param invertY defines if texture must be stored with Y axis inverted
  34014. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  34015. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  34016. */
  34017. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  34018. /** Gets or sets the texture format to use */
  34019. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  34020. /**
  34021. * Update the texture with new data
  34022. * @param data defines the data to store in the texture
  34023. */
  34024. update(data: ArrayBufferView): void;
  34025. }
  34026. }
  34027. declare module BABYLON {
  34028. /**
  34029. * Creates a refraction texture used by refraction channel of the standard material.
  34030. * @param name the texture name
  34031. * @param size size of the underlying texture
  34032. * @param scene root scene
  34033. */
  34034. class RefractionTexture extends RenderTargetTexture {
  34035. refractionPlane: Plane;
  34036. depth: number;
  34037. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  34038. clone(): RefractionTexture;
  34039. serialize(): any;
  34040. }
  34041. }
  34042. declare module BABYLON {
  34043. class RenderTargetTexture extends Texture {
  34044. isCube: boolean;
  34045. static _REFRESHRATE_RENDER_ONCE: number;
  34046. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34047. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34048. static readonly REFRESHRATE_RENDER_ONCE: number;
  34049. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34050. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34051. /**
  34052. * Use this predicate to dynamically define the list of mesh you want to render.
  34053. * If set, the renderList property will be overwritten.
  34054. */
  34055. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  34056. /**
  34057. * Use this list to define the list of mesh you want to render.
  34058. */
  34059. renderList: Nullable<Array<AbstractMesh>>;
  34060. renderParticles: boolean;
  34061. renderSprites: boolean;
  34062. coordinatesMode: number;
  34063. activeCamera: Nullable<Camera>;
  34064. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  34065. useCameraPostProcesses: boolean;
  34066. ignoreCameraViewport: boolean;
  34067. private _postProcessManager;
  34068. private _postProcesses;
  34069. private _resizeObserver;
  34070. /**
  34071. * An event triggered when the texture is unbind.
  34072. */
  34073. onBeforeBindObservable: Observable<RenderTargetTexture>;
  34074. /**
  34075. * An event triggered when the texture is unbind.
  34076. */
  34077. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  34078. private _onAfterUnbindObserver;
  34079. onAfterUnbind: () => void;
  34080. /**
  34081. * An event triggered before rendering the texture
  34082. */
  34083. onBeforeRenderObservable: Observable<number>;
  34084. private _onBeforeRenderObserver;
  34085. onBeforeRender: (faceIndex: number) => void;
  34086. /**
  34087. * An event triggered after rendering the texture
  34088. */
  34089. onAfterRenderObservable: Observable<number>;
  34090. private _onAfterRenderObserver;
  34091. onAfterRender: (faceIndex: number) => void;
  34092. /**
  34093. * An event triggered after the texture clear
  34094. */
  34095. onClearObservable: Observable<Engine>;
  34096. private _onClearObserver;
  34097. onClear: (Engine: Engine) => void;
  34098. clearColor: Color4;
  34099. protected _size: number | {
  34100. width: number;
  34101. height: number;
  34102. };
  34103. protected _initialSizeParameter: number | {
  34104. width: number;
  34105. height: number;
  34106. } | {
  34107. ratio: number;
  34108. };
  34109. protected _sizeRatio: Nullable<number>;
  34110. _generateMipMaps: boolean;
  34111. protected _renderingManager: RenderingManager;
  34112. _waitingRenderList: string[];
  34113. protected _doNotChangeAspectRatio: boolean;
  34114. protected _currentRefreshId: number;
  34115. protected _refreshRate: number;
  34116. protected _textureMatrix: Matrix;
  34117. protected _samples: number;
  34118. protected _renderTargetOptions: RenderTargetCreationOptions;
  34119. readonly renderTargetOptions: RenderTargetCreationOptions;
  34120. protected _engine: Engine;
  34121. protected _onRatioRescale(): void;
  34122. /**
  34123. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  34124. * It must define where the camera used to render the texture is set
  34125. */
  34126. boundingBoxPosition: Vector3;
  34127. private _boundingBoxSize;
  34128. /**
  34129. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  34130. * When defined, the cubemap will switch to local mode
  34131. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34132. * @example https://www.babylonjs-playground.com/#RNASML
  34133. */
  34134. boundingBoxSize: Vector3;
  34135. /**
  34136. * In case the RTT has been created with a depth texture, get the associated
  34137. * depth texture.
  34138. * Otherwise, return null.
  34139. */
  34140. depthStencilTexture: Nullable<InternalTexture>;
  34141. /**
  34142. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  34143. * or used a shadow, depth texture...
  34144. * @param name The friendly name of the texture
  34145. * @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)
  34146. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  34147. * @param generateMipMaps True if mip maps need to be generated after render.
  34148. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  34149. * @param type The type of the buffer in the RTT (int, half float, float...)
  34150. * @param isCube True if a cube texture needs to be created
  34151. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  34152. * @param generateDepthBuffer True to generate a depth buffer
  34153. * @param generateStencilBuffer True to generate a stencil buffer
  34154. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  34155. */
  34156. constructor(name: string, size: number | {
  34157. width: number;
  34158. height: number;
  34159. } | {
  34160. ratio: number;
  34161. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  34162. /**
  34163. * Creates a depth stencil texture.
  34164. * This is only available in WebGL 2 or with the depth texture extension available.
  34165. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  34166. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  34167. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  34168. */
  34169. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  34170. private _processSizeParameter(size);
  34171. samples: number;
  34172. resetRefreshCounter(): void;
  34173. refreshRate: number;
  34174. addPostProcess(postProcess: PostProcess): void;
  34175. clearPostProcesses(dispose?: boolean): void;
  34176. removePostProcess(postProcess: PostProcess): void;
  34177. _shouldRender(): boolean;
  34178. getRenderSize(): number;
  34179. getRenderWidth(): number;
  34180. getRenderHeight(): number;
  34181. readonly canRescale: boolean;
  34182. scale(ratio: number): void;
  34183. getReflectionTextureMatrix(): Matrix;
  34184. resize(size: number | {
  34185. width: number;
  34186. height: number;
  34187. } | {
  34188. ratio: number;
  34189. }): void;
  34190. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  34191. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  34192. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34193. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  34194. /**
  34195. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34196. * This allowed control for front to back rendering or reversly depending of the special needs.
  34197. *
  34198. * @param renderingGroupId The rendering group id corresponding to its index
  34199. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34200. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34201. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34202. */
  34203. 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;
  34204. /**
  34205. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34206. *
  34207. * @param renderingGroupId The rendering group id corresponding to its index
  34208. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34209. */
  34210. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34211. clone(): RenderTargetTexture;
  34212. serialize(): any;
  34213. disposeFramebufferObjects(): void;
  34214. dispose(): void;
  34215. _rebuild(): void;
  34216. /**
  34217. * Clear the info related to rendering groups preventing retention point in material dispose.
  34218. */
  34219. freeRenderingGroups(): void;
  34220. }
  34221. }
  34222. declare module BABYLON {
  34223. class Texture extends BaseTexture {
  34224. static NEAREST_SAMPLINGMODE: number;
  34225. static NEAREST_NEAREST_MIPLINEAR: number;
  34226. static BILINEAR_SAMPLINGMODE: number;
  34227. static LINEAR_LINEAR_MIPNEAREST: number;
  34228. static TRILINEAR_SAMPLINGMODE: number;
  34229. static LINEAR_LINEAR_MIPLINEAR: number;
  34230. static NEAREST_NEAREST_MIPNEAREST: number;
  34231. static NEAREST_LINEAR_MIPNEAREST: number;
  34232. static NEAREST_LINEAR_MIPLINEAR: number;
  34233. static NEAREST_LINEAR: number;
  34234. static NEAREST_NEAREST: number;
  34235. static LINEAR_NEAREST_MIPNEAREST: number;
  34236. static LINEAR_NEAREST_MIPLINEAR: number;
  34237. static LINEAR_LINEAR: number;
  34238. static LINEAR_NEAREST: number;
  34239. static EXPLICIT_MODE: number;
  34240. static SPHERICAL_MODE: number;
  34241. static PLANAR_MODE: number;
  34242. static CUBIC_MODE: number;
  34243. static PROJECTION_MODE: number;
  34244. static SKYBOX_MODE: number;
  34245. static INVCUBIC_MODE: number;
  34246. static EQUIRECTANGULAR_MODE: number;
  34247. static FIXED_EQUIRECTANGULAR_MODE: number;
  34248. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34249. static CLAMP_ADDRESSMODE: number;
  34250. static WRAP_ADDRESSMODE: number;
  34251. static MIRROR_ADDRESSMODE: number;
  34252. /**
  34253. * 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
  34254. */
  34255. static UseSerializedUrlIfAny: boolean;
  34256. url: Nullable<string>;
  34257. uOffset: number;
  34258. vOffset: number;
  34259. uScale: number;
  34260. vScale: number;
  34261. uAng: number;
  34262. vAng: number;
  34263. wAng: number;
  34264. /**
  34265. * Defines the center of rotation (U)
  34266. */
  34267. uRotationCenter: number;
  34268. /**
  34269. * Defines the center of rotation (V)
  34270. */
  34271. vRotationCenter: number;
  34272. /**
  34273. * Defines the center of rotation (W)
  34274. */
  34275. wRotationCenter: number;
  34276. readonly noMipmap: boolean;
  34277. private _noMipmap;
  34278. _invertY: boolean;
  34279. private _rowGenerationMatrix;
  34280. private _cachedTextureMatrix;
  34281. private _projectionModeMatrix;
  34282. private _t0;
  34283. private _t1;
  34284. private _t2;
  34285. private _cachedUOffset;
  34286. private _cachedVOffset;
  34287. private _cachedUScale;
  34288. private _cachedVScale;
  34289. private _cachedUAng;
  34290. private _cachedVAng;
  34291. private _cachedWAng;
  34292. private _cachedProjectionMatrixId;
  34293. private _cachedCoordinatesMode;
  34294. _samplingMode: number;
  34295. /** @hidden */
  34296. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34297. private _deleteBuffer;
  34298. protected _format: Nullable<number>;
  34299. private _delayedOnLoad;
  34300. private _delayedOnError;
  34301. protected _onLoadObservable: Nullable<Observable<Texture>>;
  34302. protected _isBlocking: boolean;
  34303. isBlocking: boolean;
  34304. readonly samplingMode: number;
  34305. 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);
  34306. /**
  34307. * Update the url (and optional buffer) of this texture if url was null during construction.
  34308. * @param url the url of the texture
  34309. * @param buffer the buffer of the texture (defaults to null)
  34310. */
  34311. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  34312. delayLoad(): void;
  34313. updateSamplingMode(samplingMode: number): void;
  34314. private _prepareRowForTextureGeneration(x, y, z, t);
  34315. getTextureMatrix(): Matrix;
  34316. getReflectionTextureMatrix(): Matrix;
  34317. clone(): Texture;
  34318. readonly onLoadObservable: Observable<Texture>;
  34319. serialize(): any;
  34320. getClassName(): string;
  34321. dispose(): void;
  34322. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  34323. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  34324. 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;
  34325. }
  34326. }
  34327. declare module BABYLON {
  34328. /**
  34329. * Settings for finer control over video usage
  34330. */
  34331. interface VideoTextureSettings {
  34332. /**
  34333. * Applies `autoplay` to video, if specified
  34334. */
  34335. autoPlay?: boolean;
  34336. /**
  34337. * Applies `loop` to video, if specified
  34338. */
  34339. loop?: boolean;
  34340. /**
  34341. * Automatically updates internal texture from video at every frame in the render loop
  34342. */
  34343. autoUpdateTexture: boolean;
  34344. /**
  34345. * Image src displayed during the video loading or until the user interacts with the video.
  34346. */
  34347. poster?: string;
  34348. }
  34349. class VideoTexture extends Texture {
  34350. /**
  34351. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34352. */
  34353. readonly autoUpdateTexture: boolean;
  34354. /**
  34355. * The video instance used by the texture internally
  34356. */
  34357. readonly video: HTMLVideoElement;
  34358. private _onUserActionRequestedObservable;
  34359. readonly onUserActionRequestedObservable: Observable<Texture>;
  34360. private _generateMipMaps;
  34361. private _engine;
  34362. private _stillImageCaptured;
  34363. /**
  34364. * Creates a video texture.
  34365. * Sample : https://doc.babylonjs.com/how_to/video_texture
  34366. * @param {string | null} name optional name, will detect from video source, if not defined
  34367. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  34368. * @param {BABYLON.Scene} scene is obviously the current scene.
  34369. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34370. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  34371. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34372. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  34373. */
  34374. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34375. private _getName(src);
  34376. private _getVideo(src);
  34377. private _createInternalTexture;
  34378. private reset;
  34379. /**
  34380. * Internal method to initiate `update`.
  34381. */
  34382. _rebuild(): void;
  34383. /**
  34384. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34385. */
  34386. update(): void;
  34387. /**
  34388. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34389. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34390. */
  34391. updateTexture(isVisible: boolean): void;
  34392. protected _updateInternalTexture: (e?: Event | undefined) => void;
  34393. /**
  34394. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34395. * @param url New url.
  34396. */
  34397. updateURL(url: string): void;
  34398. dispose(): void;
  34399. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34400. minWidth: number;
  34401. maxWidth: number;
  34402. minHeight: number;
  34403. maxHeight: number;
  34404. deviceId: string;
  34405. }): void;
  34406. }
  34407. }
  34408. declare module BABYLON {
  34409. /**
  34410. * Interface to implement to create a shadow generator compatible with BJS.
  34411. */
  34412. interface IShadowGenerator {
  34413. /**
  34414. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34415. * @returns The render target texture if present otherwise, null
  34416. */
  34417. getShadowMap(): Nullable<RenderTargetTexture>;
  34418. /**
  34419. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34420. * @returns The render target texture if the shadow map is present otherwise, null
  34421. */
  34422. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34423. /**
  34424. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34425. * @param subMesh The submesh we want to render in the shadow map
  34426. * @param useInstances Defines wether will draw in the map using instances
  34427. * @returns true if ready otherwise, false
  34428. */
  34429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34430. /**
  34431. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34432. * @param defines Defines of the material we want to update
  34433. * @param lightIndex Index of the light in the enabled light list of the material
  34434. */
  34435. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34436. /**
  34437. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34438. * defined in the generator but impacting the effect).
  34439. * It implies the unifroms available on the materials are the standard BJS ones.
  34440. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34441. * @param effect The effect we are binfing the information for
  34442. */
  34443. bindShadowLight(lightIndex: string, effect: Effect): void;
  34444. /**
  34445. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34446. * (eq to shadow prjection matrix * light transform matrix)
  34447. * @returns The transform matrix used to create the shadow map
  34448. */
  34449. getTransformMatrix(): Matrix;
  34450. /**
  34451. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34452. * Cube and 2D textures for instance.
  34453. */
  34454. recreateShadowMap(): void;
  34455. /**
  34456. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34457. * @param onCompiled Callback triggered at the and of the effects compilation
  34458. * @param options Sets of optional options forcing the compilation with different modes
  34459. */
  34460. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34461. useInstances: boolean;
  34462. }>): void;
  34463. /**
  34464. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34465. * @param options Sets of optional options forcing the compilation with different modes
  34466. * @returns A promise that resolves when the compilation completes
  34467. */
  34468. forceCompilationAsync(options?: Partial<{
  34469. useInstances: boolean;
  34470. }>): Promise<void>;
  34471. /**
  34472. * Serializes the shadow generator setup to a json object.
  34473. * @returns The serialized JSON object
  34474. */
  34475. serialize(): any;
  34476. /**
  34477. * Disposes the Shadow map and related Textures and effects.
  34478. */
  34479. dispose(): void;
  34480. }
  34481. /**
  34482. * Default implementation IShadowGenerator.
  34483. * This is the main object responsible of generating shadows in the framework.
  34484. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34485. */
  34486. class ShadowGenerator implements IShadowGenerator {
  34487. /**
  34488. * Shadow generator mode None: no filtering applied.
  34489. */
  34490. static readonly FILTER_NONE: number;
  34491. /**
  34492. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34493. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34494. */
  34495. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34496. /**
  34497. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34498. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34499. */
  34500. static readonly FILTER_POISSONSAMPLING: number;
  34501. /**
  34502. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34503. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34504. */
  34505. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34506. /**
  34507. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34508. * edge artifacts on steep falloff.
  34509. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34510. */
  34511. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34512. /**
  34513. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34514. * edge artifacts on steep falloff.
  34515. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34516. */
  34517. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34518. /**
  34519. * Shadow generator mode PCF: Percentage Closer Filtering
  34520. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34521. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34522. */
  34523. static readonly FILTER_PCF: number;
  34524. /**
  34525. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34526. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34527. * Contact Hardening
  34528. */
  34529. static readonly FILTER_PCSS: number;
  34530. /**
  34531. * Reserved for PCF and PCSS
  34532. * Highest Quality.
  34533. *
  34534. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34535. *
  34536. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34537. */
  34538. static readonly QUALITY_HIGH: number;
  34539. /**
  34540. * Reserved for PCF and PCSS
  34541. * Good tradeoff for quality/perf cross devices
  34542. *
  34543. * Execute PCF on a 3*3 kernel.
  34544. *
  34545. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34546. */
  34547. static readonly QUALITY_MEDIUM: number;
  34548. /**
  34549. * Reserved for PCF and PCSS
  34550. * The lowest quality but the fastest.
  34551. *
  34552. * Execute PCF on a 1*1 kernel.
  34553. *
  34554. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34555. */
  34556. static readonly QUALITY_LOW: number;
  34557. private _bias;
  34558. /**
  34559. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34560. */
  34561. /**
  34562. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34563. */
  34564. bias: number;
  34565. private _normalBias;
  34566. /**
  34567. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34568. */
  34569. /**
  34570. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34571. */
  34572. normalBias: number;
  34573. private _blurBoxOffset;
  34574. /**
  34575. * Gets the blur box offset: offset applied during the blur pass.
  34576. * Only usefull if useKernelBlur = false
  34577. */
  34578. /**
  34579. * Sets the blur box offset: offset applied during the blur pass.
  34580. * Only usefull if useKernelBlur = false
  34581. */
  34582. blurBoxOffset: number;
  34583. private _blurScale;
  34584. /**
  34585. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  34586. * 2 means half of the size.
  34587. */
  34588. /**
  34589. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  34590. * 2 means half of the size.
  34591. */
  34592. blurScale: number;
  34593. private _blurKernel;
  34594. /**
  34595. * Gets the blur kernel: kernel size of the blur pass.
  34596. * Only usefull if useKernelBlur = true
  34597. */
  34598. /**
  34599. * Sets the blur kernel: kernel size of the blur pass.
  34600. * Only usefull if useKernelBlur = true
  34601. */
  34602. blurKernel: number;
  34603. private _useKernelBlur;
  34604. /**
  34605. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  34606. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34607. */
  34608. /**
  34609. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  34610. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34611. */
  34612. useKernelBlur: boolean;
  34613. private _depthScale;
  34614. /**
  34615. * Gets the depth scale used in ESM mode.
  34616. */
  34617. /**
  34618. * Sets the depth scale used in ESM mode.
  34619. * This can override the scale stored on the light.
  34620. */
  34621. depthScale: number;
  34622. private _filter;
  34623. /**
  34624. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  34625. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34626. */
  34627. /**
  34628. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  34629. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34630. */
  34631. filter: number;
  34632. /**
  34633. * Gets if the current filter is set to Poisson Sampling.
  34634. */
  34635. /**
  34636. * Sets the current filter to Poisson Sampling.
  34637. */
  34638. usePoissonSampling: boolean;
  34639. /**
  34640. * Gets if the current filter is set to VSM.
  34641. * DEPRECATED. Should use useExponentialShadowMap instead.
  34642. */
  34643. /**
  34644. * Sets the current filter is to VSM.
  34645. * DEPRECATED. Should use useExponentialShadowMap instead.
  34646. */
  34647. useVarianceShadowMap: boolean;
  34648. /**
  34649. * Gets if the current filter is set to blurred VSM.
  34650. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34651. */
  34652. /**
  34653. * Sets the current filter is to blurred VSM.
  34654. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34655. */
  34656. useBlurVarianceShadowMap: boolean;
  34657. /**
  34658. * Gets if the current filter is set to ESM.
  34659. */
  34660. /**
  34661. * Sets the current filter is to ESM.
  34662. */
  34663. useExponentialShadowMap: boolean;
  34664. /**
  34665. * Gets if the current filter is set to filtered ESM.
  34666. */
  34667. /**
  34668. * Gets if the current filter is set to filtered ESM.
  34669. */
  34670. useBlurExponentialShadowMap: boolean;
  34671. /**
  34672. * Gets if the current filter is set to "close ESM" (using the inverse of the
  34673. * exponential to prevent steep falloff artifacts).
  34674. */
  34675. /**
  34676. * Sets the current filter to "close ESM" (using the inverse of the
  34677. * exponential to prevent steep falloff artifacts).
  34678. */
  34679. useCloseExponentialShadowMap: boolean;
  34680. /**
  34681. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  34682. * exponential to prevent steep falloff artifacts).
  34683. */
  34684. /**
  34685. * Sets the current filter to filtered "close ESM" (using the inverse of the
  34686. * exponential to prevent steep falloff artifacts).
  34687. */
  34688. useBlurCloseExponentialShadowMap: boolean;
  34689. /**
  34690. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  34691. */
  34692. /**
  34693. * Sets the current filter to "PCF" (percentage closer filtering).
  34694. */
  34695. usePercentageCloserFiltering: boolean;
  34696. private _filteringQuality;
  34697. /**
  34698. * Gets the PCF or PCSS Quality.
  34699. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34700. */
  34701. /**
  34702. * Sets the PCF or PCSS Quality.
  34703. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34704. */
  34705. filteringQuality: number;
  34706. /**
  34707. * Gets if the current filter is set to "PCSS" (contact hardening).
  34708. */
  34709. /**
  34710. * Sets the current filter to "PCSS" (contact hardening).
  34711. */
  34712. useContactHardeningShadow: boolean;
  34713. private _contactHardeningLightSizeUVRatio;
  34714. /**
  34715. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34716. * Using a ratio helps keeping shape stability independently of the map size.
  34717. *
  34718. * It does not account for the light projection as it was having too much
  34719. * instability during the light setup or during light position changes.
  34720. *
  34721. * Only valid if useContactHardeningShadow is true.
  34722. */
  34723. /**
  34724. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34725. * Using a ratio helps keeping shape stability independently of the map size.
  34726. *
  34727. * It does not account for the light projection as it was having too much
  34728. * instability during the light setup or during light position changes.
  34729. *
  34730. * Only valid if useContactHardeningShadow is true.
  34731. */
  34732. contactHardeningLightSizeUVRatio: number;
  34733. private _darkness;
  34734. /**
  34735. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34736. * 0 means strongest and 1 would means no shadow.
  34737. * @returns the darkness.
  34738. */
  34739. getDarkness(): number;
  34740. /**
  34741. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34742. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34743. * @returns the shadow generator allowing fluent coding.
  34744. */
  34745. setDarkness(darkness: number): ShadowGenerator;
  34746. private _transparencyShadow;
  34747. /**
  34748. * Sets the ability to have transparent shadow (boolean).
  34749. * @param transparent True if transparent else False
  34750. * @returns the shadow generator allowing fluent coding
  34751. */
  34752. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  34753. private _shadowMap;
  34754. private _shadowMap2;
  34755. /**
  34756. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34757. * @returns The render target texture if present otherwise, null
  34758. */
  34759. getShadowMap(): Nullable<RenderTargetTexture>;
  34760. /**
  34761. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34762. * @returns The render target texture if the shadow map is present otherwise, null
  34763. */
  34764. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34765. /**
  34766. * Helper function to add a mesh and its descendants to the list of shadow casters.
  34767. * @param mesh Mesh to add
  34768. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  34769. * @returns the Shadow Generator itself
  34770. */
  34771. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34772. /**
  34773. * Helper function to remove a mesh and its descendants from the list of shadow casters
  34774. * @param mesh Mesh to remove
  34775. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  34776. * @returns the Shadow Generator itself
  34777. */
  34778. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34779. /**
  34780. * Controls the extent to which the shadows fade out at the edge of the frustum
  34781. * Used only by directionals and spots
  34782. */
  34783. frustumEdgeFalloff: number;
  34784. private _light;
  34785. /**
  34786. * Returns the associated light object.
  34787. * @returns the light generating the shadow
  34788. */
  34789. getLight(): IShadowLight;
  34790. /**
  34791. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  34792. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  34793. * It might on the other hand introduce peter panning.
  34794. */
  34795. forceBackFacesOnly: boolean;
  34796. private _scene;
  34797. private _lightDirection;
  34798. private _effect;
  34799. private _viewMatrix;
  34800. private _projectionMatrix;
  34801. private _transformMatrix;
  34802. private _cachedPosition;
  34803. private _cachedDirection;
  34804. private _cachedDefines;
  34805. private _currentRenderID;
  34806. private _boxBlurPostprocess;
  34807. private _kernelBlurXPostprocess;
  34808. private _kernelBlurYPostprocess;
  34809. private _blurPostProcesses;
  34810. private _mapSize;
  34811. private _currentFaceIndex;
  34812. private _currentFaceIndexCache;
  34813. private _textureType;
  34814. private _defaultTextureMatrix;
  34815. /**
  34816. * Creates a ShadowGenerator object.
  34817. * A ShadowGenerator is the required tool to use the shadows.
  34818. * Each light casting shadows needs to use its own ShadowGenerator.
  34819. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  34820. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  34821. * @param light The light object generating the shadows.
  34822. * @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.
  34823. */
  34824. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  34825. private _initializeGenerator();
  34826. private _initializeShadowMap();
  34827. private _initializeBlurRTTAndPostProcesses();
  34828. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  34829. private _renderSubMeshForShadowMap(subMesh);
  34830. private _applyFilterValues();
  34831. /**
  34832. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34833. * @param onCompiled Callback triggered at the and of the effects compilation
  34834. * @param options Sets of optional options forcing the compilation with different modes
  34835. */
  34836. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34837. useInstances: boolean;
  34838. }>): void;
  34839. /**
  34840. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34841. * @param options Sets of optional options forcing the compilation with different modes
  34842. * @returns A promise that resolves when the compilation completes
  34843. */
  34844. forceCompilationAsync(options?: Partial<{
  34845. useInstances: boolean;
  34846. }>): Promise<void>;
  34847. /**
  34848. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34849. * @param subMesh The submesh we want to render in the shadow map
  34850. * @param useInstances Defines wether will draw in the map using instances
  34851. * @returns true if ready otherwise, false
  34852. */
  34853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34854. /**
  34855. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34856. * @param defines Defines of the material we want to update
  34857. * @param lightIndex Index of the light in the enabled light list of the material
  34858. */
  34859. prepareDefines(defines: any, lightIndex: number): void;
  34860. /**
  34861. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34862. * defined in the generator but impacting the effect).
  34863. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34864. * @param effect The effect we are binfing the information for
  34865. */
  34866. bindShadowLight(lightIndex: string, effect: Effect): void;
  34867. /**
  34868. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34869. * (eq to shadow prjection matrix * light transform matrix)
  34870. * @returns The transform matrix used to create the shadow map
  34871. */
  34872. getTransformMatrix(): Matrix;
  34873. /**
  34874. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34875. * Cube and 2D textures for instance.
  34876. */
  34877. recreateShadowMap(): void;
  34878. private _disposeBlurPostProcesses();
  34879. private _disposeRTTandPostProcesses();
  34880. /**
  34881. * Disposes the ShadowGenerator.
  34882. * Returns nothing.
  34883. */
  34884. dispose(): void;
  34885. /**
  34886. * Serializes the shadow generator setup to a json object.
  34887. * @returns The serialized JSON object
  34888. */
  34889. serialize(): any;
  34890. /**
  34891. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  34892. * @param parsedShadowGenerator The JSON object to parse
  34893. * @param scene The scene to create the shadow map for
  34894. * @returns The parsed shadow generator
  34895. */
  34896. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  34897. }
  34898. }
  34899. declare module BABYLON {
  34900. }
  34901. declare var DracoDecoderModule: any;
  34902. declare var WebAssembly: any;
  34903. declare module BABYLON {
  34904. /**
  34905. * Configuration for Draco compression
  34906. */
  34907. interface IDracoCompressionConfiguration {
  34908. /**
  34909. * Configuration for the decoder.
  34910. */
  34911. decoder?: {
  34912. /**
  34913. * The url to the WebAssembly module.
  34914. */
  34915. wasmUrl?: string;
  34916. /**
  34917. * The url to the WebAssembly binary.
  34918. */
  34919. wasmBinaryUrl?: string;
  34920. /**
  34921. * The url to the fallback JavaScript module.
  34922. */
  34923. fallbackUrl?: string;
  34924. };
  34925. }
  34926. /**
  34927. * Draco compression (https://google.github.io/draco/)
  34928. *
  34929. * This class wraps the Draco module.
  34930. *
  34931. * **Encoder**
  34932. *
  34933. * The encoder is not currently implemented.
  34934. *
  34935. * **Decoder**
  34936. *
  34937. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  34938. *
  34939. * To update the configuration, use the following code:
  34940. * ```javascript
  34941. * BABYLON.DracoCompression.Configuration = {
  34942. * decoder: {
  34943. * wasmUrl: "<url to the WebAssembly library>",
  34944. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  34945. * fallbackUrl: "<url to the fallback JavaScript library>",
  34946. * }
  34947. * };
  34948. * ```
  34949. *
  34950. * 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.
  34951. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  34952. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  34953. *
  34954. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  34955. * ```javascript
  34956. * var dracoCompression = new BABYLON.DracoCompression();
  34957. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  34958. * [BABYLON.VertexBuffer.PositionKind]: 0
  34959. * });
  34960. * ```
  34961. *
  34962. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  34963. */
  34964. class DracoCompression implements IDisposable {
  34965. private static _DecoderModulePromise;
  34966. /**
  34967. * The configuration. Defaults to the following urls:
  34968. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  34969. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  34970. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  34971. */
  34972. static Configuration: IDracoCompressionConfiguration;
  34973. /**
  34974. * Returns true if the decoder is available.
  34975. */
  34976. static readonly DecoderAvailable: boolean;
  34977. /**
  34978. * Constructor
  34979. */
  34980. constructor();
  34981. /**
  34982. * Stop all async operations and release resources.
  34983. */
  34984. dispose(): void;
  34985. /**
  34986. * Decode Draco compressed mesh data to vertex data.
  34987. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  34988. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  34989. * @returns A promise that resolves with the decoded vertex data
  34990. */
  34991. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  34992. [kind: string]: number;
  34993. }): Promise<VertexData>;
  34994. private static _GetDecoderModule();
  34995. private static _LoadScriptAsync(url);
  34996. private static _LoadFileAsync(url);
  34997. }
  34998. }
  34999. declare module BABYLON {
  35000. /**
  35001. * Particle emitter emitting particles from the inside of a box.
  35002. * It emits the particles randomly between 2 given directions.
  35003. */
  35004. class BoxParticleEmitter implements IParticleEmitterType {
  35005. /**
  35006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35007. */
  35008. direction1: Vector3;
  35009. /**
  35010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35011. */
  35012. direction2: Vector3;
  35013. /**
  35014. * 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.
  35015. */
  35016. minEmitBox: Vector3;
  35017. /**
  35018. * 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.
  35019. */
  35020. maxEmitBox: Vector3;
  35021. /**
  35022. * Creates a new instance BoxParticleEmitter
  35023. */
  35024. constructor();
  35025. /**
  35026. * Called by the particle System when the direction is computed for the created particle.
  35027. * @param worldMatrix is the world matrix of the particle system
  35028. * @param directionToUpdate is the direction vector to update with the result
  35029. * @param particle is the particle we are computed the direction for
  35030. */
  35031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35032. /**
  35033. * Called by the particle System when the position is computed for the created particle.
  35034. * @param worldMatrix is the world matrix of the particle system
  35035. * @param positionToUpdate is the position vector to update with the result
  35036. * @param particle is the particle we are computed the position for
  35037. */
  35038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35039. /**
  35040. * Clones the current emitter and returns a copy of it
  35041. * @returns the new emitter
  35042. */
  35043. clone(): BoxParticleEmitter;
  35044. /**
  35045. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35046. * @param effect defines the update shader
  35047. */
  35048. applyToShader(effect: Effect): void;
  35049. /**
  35050. * Returns a string to use to update the GPU particles update shader
  35051. * @returns a string containng the defines string
  35052. */
  35053. getEffectDefines(): string;
  35054. /**
  35055. * Returns the string "BoxEmitter"
  35056. * @returns a string containing the class name
  35057. */
  35058. getClassName(): string;
  35059. /**
  35060. * Serializes the particle system to a JSON object.
  35061. * @returns the JSON object
  35062. */
  35063. serialize(): any;
  35064. /**
  35065. * Parse properties from a JSON object
  35066. * @param serializationObject defines the JSON object
  35067. */
  35068. parse(serializationObject: any): void;
  35069. }
  35070. }
  35071. declare module BABYLON {
  35072. /**
  35073. * Particle emitter emitting particles from the inside of a cone.
  35074. * It emits the particles alongside the cone volume from the base to the particle.
  35075. * The emission direction might be randomized.
  35076. */
  35077. class ConeParticleEmitter implements IParticleEmitterType {
  35078. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35079. directionRandomizer: number;
  35080. private _radius;
  35081. private _angle;
  35082. private _height;
  35083. /**
  35084. * Gets or sets the radius of the emission cone
  35085. */
  35086. radius: number;
  35087. /**
  35088. * Gets or sets the angle of the emission cone
  35089. */
  35090. angle: number;
  35091. private _buildHeight();
  35092. /**
  35093. * Creates a new instance ConeParticleEmitter
  35094. * @param radius the radius of the emission cone (1 by default)
  35095. * @param angles the cone base angle (PI by default)
  35096. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  35097. */
  35098. constructor(radius?: number, angle?: number,
  35099. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35100. directionRandomizer?: number);
  35101. /**
  35102. * Called by the particle System when the direction is computed for the created particle.
  35103. * @param worldMatrix is the world matrix of the particle system
  35104. * @param directionToUpdate is the direction vector to update with the result
  35105. * @param particle is the particle we are computed the direction for
  35106. */
  35107. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35108. /**
  35109. * Called by the particle System when the position is computed for the created particle.
  35110. * @param worldMatrix is the world matrix of the particle system
  35111. * @param positionToUpdate is the position vector to update with the result
  35112. * @param particle is the particle we are computed the position for
  35113. */
  35114. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35115. /**
  35116. * Clones the current emitter and returns a copy of it
  35117. * @returns the new emitter
  35118. */
  35119. clone(): ConeParticleEmitter;
  35120. /**
  35121. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35122. * @param effect defines the update shader
  35123. */
  35124. applyToShader(effect: Effect): void;
  35125. /**
  35126. * Returns a string to use to update the GPU particles update shader
  35127. * @returns a string containng the defines string
  35128. */
  35129. getEffectDefines(): string;
  35130. /**
  35131. * Returns the string "BoxEmitter"
  35132. * @returns a string containing the class name
  35133. */
  35134. getClassName(): string;
  35135. /**
  35136. * Serializes the particle system to a JSON object.
  35137. * @returns the JSON object
  35138. */
  35139. serialize(): any;
  35140. /**
  35141. * Parse properties from a JSON object
  35142. * @param serializationObject defines the JSON object
  35143. */
  35144. parse(serializationObject: any): void;
  35145. }
  35146. }
  35147. declare module BABYLON {
  35148. /**
  35149. * Particle emitter represents a volume emitting particles.
  35150. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  35151. */
  35152. interface IParticleEmitterType {
  35153. /**
  35154. * Called by the particle System when the direction is computed for the created particle.
  35155. * @param worldMatrix is the world matrix of the particle system
  35156. * @param directionToUpdate is the direction vector to update with the result
  35157. * @param particle is the particle we are computed the direction for
  35158. */
  35159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35160. /**
  35161. * Called by the particle System when the position is computed for the created particle.
  35162. * @param worldMatrix is the world matrix of the particle system
  35163. * @param positionToUpdate is the position vector to update with the result
  35164. * @param particle is the particle we are computed the position for
  35165. */
  35166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35167. /**
  35168. * Clones the current emitter and returns a copy of it
  35169. * @returns the new emitter
  35170. */
  35171. clone(): IParticleEmitterType;
  35172. /**
  35173. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35174. * @param effect defines the update shader
  35175. */
  35176. applyToShader(effect: Effect): void;
  35177. /**
  35178. * Returns a string to use to update the GPU particles update shader
  35179. * @returns the effect defines string
  35180. */
  35181. getEffectDefines(): string;
  35182. /**
  35183. * Returns a string representing the class name
  35184. * @returns a string containing the class name
  35185. */
  35186. getClassName(): string;
  35187. /**
  35188. * Serializes the particle system to a JSON object.
  35189. * @returns the JSON object
  35190. */
  35191. serialize(): any;
  35192. /**
  35193. * Parse properties from a JSON object
  35194. * @param serializationObject defines the JSON object
  35195. */
  35196. parse(serializationObject: any): void;
  35197. }
  35198. }
  35199. declare module BABYLON {
  35200. /**
  35201. * Particle emitter emitting particles from the inside of a sphere.
  35202. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  35203. */
  35204. class SphereParticleEmitter implements IParticleEmitterType {
  35205. /**
  35206. * The radius of the emission sphere.
  35207. */
  35208. radius: number;
  35209. /**
  35210. * How much to randomize the particle direction [0-1].
  35211. */
  35212. directionRandomizer: number;
  35213. /**
  35214. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  35215. */
  35216. radiusRange: number;
  35217. /**
  35218. * Creates a new instance SphereParticleEmitter
  35219. * @param radius the radius of the emission sphere (1 by default)
  35220. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  35221. */
  35222. constructor(
  35223. /**
  35224. * The radius of the emission sphere.
  35225. */
  35226. radius?: number,
  35227. /**
  35228. * How much to randomize the particle direction [0-1].
  35229. */
  35230. directionRandomizer?: number);
  35231. /**
  35232. * Called by the particle System when the direction is computed for the created particle.
  35233. * @param worldMatrix is the world matrix of the particle system
  35234. * @param directionToUpdate is the direction vector to update with the result
  35235. * @param particle is the particle we are computed the direction for
  35236. */
  35237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35238. /**
  35239. * Called by the particle System when the position is computed for the created particle.
  35240. * @param worldMatrix is the world matrix of the particle system
  35241. * @param positionToUpdate is the position vector to update with the result
  35242. * @param particle is the particle we are computed the position for
  35243. */
  35244. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35245. /**
  35246. * Clones the current emitter and returns a copy of it
  35247. * @returns the new emitter
  35248. */
  35249. clone(): SphereParticleEmitter;
  35250. /**
  35251. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35252. * @param effect defines the update shader
  35253. */
  35254. applyToShader(effect: Effect): void;
  35255. /**
  35256. * Returns a string to use to update the GPU particles update shader
  35257. * @returns a string containng the defines string
  35258. */
  35259. getEffectDefines(): string;
  35260. /**
  35261. * Returns the string "SphereParticleEmitter"
  35262. * @returns a string containing the class name
  35263. */
  35264. getClassName(): string;
  35265. /**
  35266. * Serializes the particle system to a JSON object.
  35267. * @returns the JSON object
  35268. */
  35269. serialize(): any;
  35270. /**
  35271. * Parse properties from a JSON object
  35272. * @param serializationObject defines the JSON object
  35273. */
  35274. parse(serializationObject: any): void;
  35275. }
  35276. /**
  35277. * Particle emitter emitting particles from the inside of a sphere.
  35278. * It emits the particles randomly between two vectors.
  35279. */
  35280. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  35281. /**
  35282. * The min limit of the emission direction.
  35283. */
  35284. direction1: Vector3;
  35285. /**
  35286. * The max limit of the emission direction.
  35287. */
  35288. direction2: Vector3;
  35289. /**
  35290. * Creates a new instance SphereDirectedParticleEmitter
  35291. * @param radius the radius of the emission sphere (1 by default)
  35292. * @param direction1 the min limit of the emission direction (up vector by default)
  35293. * @param direction2 the max limit of the emission direction (up vector by default)
  35294. */
  35295. constructor(radius?: number,
  35296. /**
  35297. * The min limit of the emission direction.
  35298. */
  35299. direction1?: Vector3,
  35300. /**
  35301. * The max limit of the emission direction.
  35302. */
  35303. direction2?: Vector3);
  35304. /**
  35305. * Called by the particle System when the direction is computed for the created particle.
  35306. * @param worldMatrix is the world matrix of the particle system
  35307. * @param directionToUpdate is the direction vector to update with the result
  35308. * @param particle is the particle we are computed the direction for
  35309. */
  35310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35311. /**
  35312. * Clones the current emitter and returns a copy of it
  35313. * @returns the new emitter
  35314. */
  35315. clone(): SphereDirectedParticleEmitter;
  35316. /**
  35317. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35318. * @param effect defines the update shader
  35319. */
  35320. applyToShader(effect: Effect): void;
  35321. /**
  35322. * Returns a string to use to update the GPU particles update shader
  35323. * @returns a string containng the defines string
  35324. */
  35325. getEffectDefines(): string;
  35326. /**
  35327. * Returns the string "SphereDirectedParticleEmitter"
  35328. * @returns a string containing the class name
  35329. */
  35330. getClassName(): string;
  35331. /**
  35332. * Serializes the particle system to a JSON object.
  35333. * @returns the JSON object
  35334. */
  35335. serialize(): any;
  35336. /**
  35337. * Parse properties from a JSON object
  35338. * @param serializationObject defines the JSON object
  35339. */
  35340. parse(serializationObject: any): void;
  35341. }
  35342. }
  35343. declare module BABYLON {
  35344. class CannonJSPlugin implements IPhysicsEnginePlugin {
  35345. private _useDeltaForWorldStep;
  35346. world: any;
  35347. name: string;
  35348. private _physicsMaterials;
  35349. private _fixedTimeStep;
  35350. BJSCANNON: any;
  35351. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  35352. setGravity(gravity: Vector3): void;
  35353. setTimeStep(timeStep: number): void;
  35354. getTimeStep(): number;
  35355. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35356. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35357. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35358. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35359. private _processChildMeshes(mainImpostor);
  35360. removePhysicsBody(impostor: PhysicsImpostor): void;
  35361. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35362. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35363. private _addMaterial(name, friction, restitution);
  35364. private _checkWithEpsilon(value);
  35365. private _createShape(impostor);
  35366. private _createHeightmap(object, pointDepth?);
  35367. private _minus90X;
  35368. private _plus90X;
  35369. private _tmpPosition;
  35370. private _tmpDeltaPosition;
  35371. private _tmpUnityRotation;
  35372. private _updatePhysicsBodyTransformation(impostor);
  35373. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35374. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35375. isSupported(): boolean;
  35376. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35377. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35378. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35379. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35380. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35381. getBodyMass(impostor: PhysicsImpostor): number;
  35382. getBodyFriction(impostor: PhysicsImpostor): number;
  35383. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35384. getBodyRestitution(impostor: PhysicsImpostor): number;
  35385. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35386. sleepBody(impostor: PhysicsImpostor): void;
  35387. wakeUpBody(impostor: PhysicsImpostor): void;
  35388. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35389. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  35390. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  35391. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35392. getRadius(impostor: PhysicsImpostor): number;
  35393. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35394. dispose(): void;
  35395. private _extendNamespace();
  35396. }
  35397. }
  35398. declare module BABYLON {
  35399. class OimoJSPlugin implements IPhysicsEnginePlugin {
  35400. world: any;
  35401. name: string;
  35402. BJSOIMO: any;
  35403. constructor(iterations?: number);
  35404. setGravity(gravity: Vector3): void;
  35405. setTimeStep(timeStep: number): void;
  35406. getTimeStep(): number;
  35407. private _tmpImpostorsArray;
  35408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35412. private _tmpPositionVector;
  35413. removePhysicsBody(impostor: PhysicsImpostor): void;
  35414. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35415. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35416. isSupported(): boolean;
  35417. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35424. getBodyMass(impostor: PhysicsImpostor): number;
  35425. getBodyFriction(impostor: PhysicsImpostor): number;
  35426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35427. getBodyRestitution(impostor: PhysicsImpostor): number;
  35428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35429. sleepBody(impostor: PhysicsImpostor): void;
  35430. wakeUpBody(impostor: PhysicsImpostor): void;
  35431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35432. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  35433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  35434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35435. getRadius(impostor: PhysicsImpostor): number;
  35436. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35437. dispose(): void;
  35438. }
  35439. }
  35440. declare module BABYLON {
  35441. /**
  35442. * This represents a set of one or more post processes in Babylon.
  35443. * A post process can be used to apply a shader to a texture after it is rendered.
  35444. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  35445. */
  35446. class PostProcessRenderEffect {
  35447. private _postProcesses;
  35448. private _getPostProcesses;
  35449. private _singleInstance;
  35450. private _cameras;
  35451. private _indicesForCamera;
  35452. /**
  35453. * Name of the effect
  35454. */
  35455. _name: string;
  35456. /**
  35457. * Instantiates a post process render effect.
  35458. * A post process can be used to apply a shader to a texture after it is rendered.
  35459. * @param engine The engine the effect is tied to
  35460. * @param name The name of the effect
  35461. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  35462. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  35463. */
  35464. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  35465. /**
  35466. * Checks if all the post processes in the effect are supported.
  35467. */
  35468. readonly isSupported: boolean;
  35469. /**
  35470. * Updates the current state of the effect
  35471. */
  35472. _update(): void;
  35473. /**
  35474. * Attaches the effect on cameras
  35475. * @param cameras The camera to attach to.
  35476. */
  35477. _attachCameras(cameras: Camera): void;
  35478. /**
  35479. * Attaches the effect on cameras
  35480. * @param cameras The camera to attach to.
  35481. */
  35482. _attachCameras(cameras: Camera[]): void;
  35483. /**
  35484. * Detatches the effect on cameras
  35485. * @param cameras The camera to detatch from.
  35486. */
  35487. _detachCameras(cameras: Camera): void;
  35488. /**
  35489. * Detatches the effect on cameras
  35490. * @param cameras The camera to detatch from.
  35491. */
  35492. _detachCameras(cameras: Camera[]): void;
  35493. /**
  35494. * Enables the effect on given cameras
  35495. * @param cameras The camera to enable.
  35496. */
  35497. _enable(cameras: Camera): void;
  35498. /**
  35499. * Enables the effect on given cameras
  35500. * @param cameras The camera to enable.
  35501. */
  35502. _enable(cameras: Nullable<Camera[]>): void;
  35503. /**
  35504. * Disables the effect on the given cameras
  35505. * @param cameras The camera to disable.
  35506. */
  35507. _disable(cameras: Camera): void;
  35508. /**
  35509. * Disables the effect on the given cameras
  35510. * @param cameras The camera to disable.
  35511. */
  35512. _disable(cameras: Nullable<Camera[]>): void;
  35513. /**
  35514. * Gets a list of the post processes contained in the effect.
  35515. * @param camera The camera to get the post processes on.
  35516. * @returns The list of the post processes in the effect.
  35517. */
  35518. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  35519. }
  35520. }
  35521. declare module BABYLON {
  35522. class PostProcessRenderPipeline {
  35523. private engine;
  35524. private _renderEffects;
  35525. private _renderEffectsForIsolatedPass;
  35526. protected _cameras: Camera[];
  35527. _name: string;
  35528. constructor(engine: Engine, name: string);
  35529. getClassName(): string;
  35530. readonly isSupported: boolean;
  35531. addEffect(renderEffect: PostProcessRenderEffect): void;
  35532. _rebuild(): void;
  35533. _enableEffect(renderEffectName: string, cameras: Camera): void;
  35534. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  35535. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  35536. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  35537. _attachCameras(cameras: Camera, unique: boolean): void;
  35538. _attachCameras(cameras: Camera[], unique: boolean): void;
  35539. _detachCameras(cameras: Camera): void;
  35540. _detachCameras(cameras: Nullable<Camera[]>): void;
  35541. _update(): void;
  35542. _reset(): void;
  35543. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  35544. dispose(): void;
  35545. }
  35546. }
  35547. declare module BABYLON {
  35548. class PostProcessRenderPipelineManager {
  35549. private _renderPipelines;
  35550. constructor();
  35551. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  35552. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  35553. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  35554. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  35555. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  35556. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35557. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35558. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35559. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35560. update(): void;
  35561. _rebuild(): void;
  35562. dispose(): void;
  35563. }
  35564. }
  35565. declare module BABYLON {
  35566. /**
  35567. * Helper class dealing with the extraction of spherical polynomial dataArray
  35568. * from a cube map.
  35569. */
  35570. class CubeMapToSphericalPolynomialTools {
  35571. private static FileFaces;
  35572. /**
  35573. * Converts a texture to the according Spherical Polynomial data.
  35574. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35575. *
  35576. * @param texture The texture to extract the information from.
  35577. * @return The Spherical Polynomial data.
  35578. */
  35579. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  35580. /**
  35581. * Converts a cubemap to the according Spherical Polynomial data.
  35582. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35583. *
  35584. * @param cubeInfo The Cube map to extract the information from.
  35585. * @return The Spherical Polynomial data.
  35586. */
  35587. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  35588. }
  35589. }
  35590. declare module BABYLON {
  35591. /**
  35592. * Header information of HDR texture files.
  35593. */
  35594. interface HDRInfo {
  35595. /**
  35596. * The height of the texture in pixels.
  35597. */
  35598. height: number;
  35599. /**
  35600. * The width of the texture in pixels.
  35601. */
  35602. width: number;
  35603. /**
  35604. * The index of the beginning of the data in the binary file.
  35605. */
  35606. dataPosition: number;
  35607. }
  35608. /**
  35609. * This groups tools to convert HDR texture to native colors array.
  35610. */
  35611. class HDRTools {
  35612. private static Ldexp(mantissa, exponent);
  35613. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  35614. private static readStringLine(uint8array, startIndex);
  35615. /**
  35616. * Reads header information from an RGBE texture stored in a native array.
  35617. * More information on this format are available here:
  35618. * https://en.wikipedia.org/wiki/RGBE_image_format
  35619. *
  35620. * @param uint8array The binary file stored in native array.
  35621. * @return The header information.
  35622. */
  35623. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  35624. /**
  35625. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  35626. * This RGBE texture needs to store the information as a panorama.
  35627. *
  35628. * More information on this format are available here:
  35629. * https://en.wikipedia.org/wiki/RGBE_image_format
  35630. *
  35631. * @param buffer The binary file stored in an array buffer.
  35632. * @param size The expected size of the extracted cubemap.
  35633. * @return The Cube Map information.
  35634. */
  35635. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  35636. /**
  35637. * Returns the pixels data extracted from an RGBE texture.
  35638. * This pixels will be stored left to right up to down in the R G B order in one array.
  35639. *
  35640. * More information on this format are available here:
  35641. * https://en.wikipedia.org/wiki/RGBE_image_format
  35642. *
  35643. * @param uint8array The binary file stored in an array buffer.
  35644. * @param hdrInfo The header information of the file.
  35645. * @return The pixels data in RGB right to left up to down order.
  35646. */
  35647. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  35648. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  35649. }
  35650. }
  35651. declare module BABYLON {
  35652. /**
  35653. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  35654. */
  35655. interface CubeMapInfo {
  35656. /**
  35657. * The pixel array for the front face.
  35658. * This is stored in format, left to right, up to down format.
  35659. */
  35660. front: Nullable<ArrayBufferView>;
  35661. /**
  35662. * The pixel array for the back face.
  35663. * This is stored in format, left to right, up to down format.
  35664. */
  35665. back: Nullable<ArrayBufferView>;
  35666. /**
  35667. * The pixel array for the left face.
  35668. * This is stored in format, left to right, up to down format.
  35669. */
  35670. left: Nullable<ArrayBufferView>;
  35671. /**
  35672. * The pixel array for the right face.
  35673. * This is stored in format, left to right, up to down format.
  35674. */
  35675. right: Nullable<ArrayBufferView>;
  35676. /**
  35677. * The pixel array for the up face.
  35678. * This is stored in format, left to right, up to down format.
  35679. */
  35680. up: Nullable<ArrayBufferView>;
  35681. /**
  35682. * The pixel array for the down face.
  35683. * This is stored in format, left to right, up to down format.
  35684. */
  35685. down: Nullable<ArrayBufferView>;
  35686. /**
  35687. * The size of the cubemap stored.
  35688. *
  35689. * Each faces will be size * size pixels.
  35690. */
  35691. size: number;
  35692. /**
  35693. * The format of the texture.
  35694. *
  35695. * RGBA, RGB.
  35696. */
  35697. format: number;
  35698. /**
  35699. * The type of the texture data.
  35700. *
  35701. * UNSIGNED_INT, FLOAT.
  35702. */
  35703. type: number;
  35704. /**
  35705. * Specifies whether the texture is in gamma space.
  35706. */
  35707. gammaSpace: boolean;
  35708. }
  35709. /**
  35710. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  35711. */
  35712. class PanoramaToCubeMapTools {
  35713. private static FACE_FRONT;
  35714. private static FACE_BACK;
  35715. private static FACE_RIGHT;
  35716. private static FACE_LEFT;
  35717. private static FACE_DOWN;
  35718. private static FACE_UP;
  35719. /**
  35720. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  35721. *
  35722. * @param float32Array The source data.
  35723. * @param inputWidth The width of the input panorama.
  35724. * @param inputhHeight The height of the input panorama.
  35725. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  35726. * @return The cubemap data
  35727. */
  35728. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  35729. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  35730. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. class CustomProceduralTexture extends ProceduralTexture {
  35735. private _animate;
  35736. private _time;
  35737. private _config;
  35738. private _texturePath;
  35739. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  35740. private loadJson(jsonUrl);
  35741. isReady(): boolean;
  35742. render(useCameraPostProcess?: boolean): void;
  35743. updateTextures(): void;
  35744. updateShaderUniforms(): void;
  35745. animate: boolean;
  35746. }
  35747. }
  35748. declare module BABYLON {
  35749. class ProceduralTexture extends Texture {
  35750. isCube: boolean;
  35751. private _size;
  35752. _generateMipMaps: boolean;
  35753. isEnabled: boolean;
  35754. private _currentRefreshId;
  35755. private _refreshRate;
  35756. onGenerated: () => void;
  35757. private _vertexBuffers;
  35758. private _indexBuffer;
  35759. private _effect;
  35760. private _uniforms;
  35761. private _samplers;
  35762. private _fragment;
  35763. _textures: {
  35764. [key: string]: Texture;
  35765. };
  35766. private _floats;
  35767. private _floatsArrays;
  35768. private _colors3;
  35769. private _colors4;
  35770. private _vectors2;
  35771. private _vectors3;
  35772. private _matrices;
  35773. private _fallbackTexture;
  35774. private _fallbackTextureUsed;
  35775. private _engine;
  35776. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  35777. private _createIndexBuffer();
  35778. _rebuild(): void;
  35779. reset(): void;
  35780. isReady(): boolean;
  35781. resetRefreshCounter(): void;
  35782. setFragment(fragment: any): void;
  35783. refreshRate: number;
  35784. _shouldRender(): boolean;
  35785. getRenderSize(): number;
  35786. resize(size: number, generateMipMaps: boolean): void;
  35787. private _checkUniform(uniformName);
  35788. setTexture(name: string, texture: Texture): ProceduralTexture;
  35789. setFloat(name: string, value: number): ProceduralTexture;
  35790. setFloats(name: string, value: number[]): ProceduralTexture;
  35791. setColor3(name: string, value: Color3): ProceduralTexture;
  35792. setColor4(name: string, value: Color4): ProceduralTexture;
  35793. setVector2(name: string, value: Vector2): ProceduralTexture;
  35794. setVector3(name: string, value: Vector3): ProceduralTexture;
  35795. setMatrix(name: string, value: Matrix): ProceduralTexture;
  35796. render(useCameraPostProcess?: boolean): void;
  35797. clone(): ProceduralTexture;
  35798. dispose(): void;
  35799. }
  35800. }
  35801. declare module BABYLON {
  35802. /**
  35803. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  35804. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  35805. */
  35806. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35807. private _scene;
  35808. private _originalCameras;
  35809. /**
  35810. * ID of the sharpen post process,
  35811. */
  35812. private readonly SharpenPostProcessId;
  35813. /**
  35814. * ID of the image processing post process;
  35815. */
  35816. readonly ImageProcessingPostProcessId: string;
  35817. /**
  35818. * ID of the Fast Approximate Anti-Aliasing post process;
  35819. */
  35820. readonly FxaaPostProcessId: string;
  35821. /**
  35822. * ID of the chromatic aberration post process,
  35823. */
  35824. private readonly ChromaticAberrationPostProcessId;
  35825. /**
  35826. * ID of the grain post process
  35827. */
  35828. private readonly GrainPostProcessId;
  35829. /**
  35830. * Sharpen post process which will apply a sharpen convolution to enhance edges
  35831. */
  35832. sharpen: SharpenPostProcess;
  35833. private _sharpenEffect;
  35834. private bloom;
  35835. /**
  35836. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  35837. */
  35838. depthOfField: DepthOfFieldEffect;
  35839. /**
  35840. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  35841. */
  35842. fxaa: FxaaPostProcess;
  35843. /**
  35844. * Image post processing pass used to perform operations such as tone mapping or color grading.
  35845. */
  35846. imageProcessing: ImageProcessingPostProcess;
  35847. /**
  35848. * Chromatic aberration post process which will shift rgb colors in the image
  35849. */
  35850. chromaticAberration: ChromaticAberrationPostProcess;
  35851. private _chromaticAberrationEffect;
  35852. /**
  35853. * Grain post process which add noise to the image
  35854. */
  35855. grain: GrainPostProcess;
  35856. private _grainEffect;
  35857. /**
  35858. * Glow post process which adds a glow to emmisive areas of the image
  35859. */
  35860. private _glowLayer;
  35861. /**
  35862. * Animations which can be used to tweak settings over a period of time
  35863. */
  35864. animations: Animation[];
  35865. private _imageProcessingConfigurationObserver;
  35866. private _sharpenEnabled;
  35867. private _bloomEnabled;
  35868. private _depthOfFieldEnabled;
  35869. private _depthOfFieldBlurLevel;
  35870. private _fxaaEnabled;
  35871. private _imageProcessingEnabled;
  35872. private _defaultPipelineTextureType;
  35873. private _bloomScale;
  35874. private _chromaticAberrationEnabled;
  35875. private _grainEnabled;
  35876. private _buildAllowed;
  35877. /**
  35878. * Enable or disable the sharpen process from the pipeline
  35879. */
  35880. sharpenEnabled: boolean;
  35881. private _resizeObserver;
  35882. private _hardwareScaleLevel;
  35883. private _bloomKernel;
  35884. /**
  35885. * Specifies the size of the bloom blur kernel, relative to the final output size
  35886. */
  35887. bloomKernel: number;
  35888. /**
  35889. * Specifies the weight of the bloom in the final rendering
  35890. */
  35891. private _bloomWeight;
  35892. /**
  35893. * Specifies the luma threshold for the area that will be blurred by the bloom
  35894. */
  35895. private _bloomThreshold;
  35896. private _hdr;
  35897. /**
  35898. * The strength of the bloom.
  35899. */
  35900. bloomWeight: number;
  35901. /**
  35902. * The strength of the bloom.
  35903. */
  35904. bloomThreshold: number;
  35905. /**
  35906. * The scale of the bloom, lower value will provide better performance.
  35907. */
  35908. bloomScale: number;
  35909. /**
  35910. * Enable or disable the bloom from the pipeline
  35911. */
  35912. bloomEnabled: boolean;
  35913. private _rebuildBloom();
  35914. /**
  35915. * If the depth of field is enabled.
  35916. */
  35917. depthOfFieldEnabled: boolean;
  35918. /**
  35919. * Blur level of the depth of field effect. (Higher blur will effect performance)
  35920. */
  35921. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  35922. /**
  35923. * If the anti aliasing is enabled.
  35924. */
  35925. fxaaEnabled: boolean;
  35926. private _samples;
  35927. /**
  35928. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  35929. */
  35930. samples: number;
  35931. /**
  35932. * If image processing is enabled.
  35933. */
  35934. imageProcessingEnabled: boolean;
  35935. /**
  35936. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  35937. */
  35938. glowLayerEnabled: boolean;
  35939. /**
  35940. * Enable or disable the chromaticAberration process from the pipeline
  35941. */
  35942. chromaticAberrationEnabled: boolean;
  35943. /**
  35944. * Enable or disable the grain process from the pipeline
  35945. */
  35946. grainEnabled: boolean;
  35947. /**
  35948. * @constructor
  35949. * @param {string} name - The rendering pipeline name (default: "")
  35950. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  35951. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  35952. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  35953. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  35954. */
  35955. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  35956. /**
  35957. * Force the compilation of the entire pipeline.
  35958. */
  35959. prepare(): void;
  35960. private _hasCleared;
  35961. private _prevPostProcess;
  35962. private _prevPrevPostProcess;
  35963. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  35964. private _buildPipeline();
  35965. private _disposePostProcesses(disposeNonRecreated?);
  35966. /**
  35967. * Dispose of the pipeline and stop all post processes
  35968. */
  35969. dispose(): void;
  35970. /**
  35971. * Serialize the rendering pipeline (Used when exporting)
  35972. * @returns the serialized object
  35973. */
  35974. serialize(): any;
  35975. /**
  35976. * Parse the serialized pipeline
  35977. * @param source Source pipeline.
  35978. * @param scene The scene to load the pipeline to.
  35979. * @param rootUrl The URL of the serialized pipeline.
  35980. * @returns An instantiated pipeline from the serialized object.
  35981. */
  35982. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  35983. }
  35984. }
  35985. declare module BABYLON {
  35986. class LensRenderingPipeline extends PostProcessRenderPipeline {
  35987. /**
  35988. * The chromatic aberration PostProcess id in the pipeline
  35989. */
  35990. LensChromaticAberrationEffect: string;
  35991. /**
  35992. * The highlights enhancing PostProcess id in the pipeline
  35993. */
  35994. HighlightsEnhancingEffect: string;
  35995. /**
  35996. * The depth-of-field PostProcess id in the pipeline
  35997. */
  35998. LensDepthOfFieldEffect: string;
  35999. private _scene;
  36000. private _depthTexture;
  36001. private _grainTexture;
  36002. private _chromaticAberrationPostProcess;
  36003. private _highlightsPostProcess;
  36004. private _depthOfFieldPostProcess;
  36005. private _edgeBlur;
  36006. private _grainAmount;
  36007. private _chromaticAberration;
  36008. private _distortion;
  36009. private _highlightsGain;
  36010. private _highlightsThreshold;
  36011. private _dofDistance;
  36012. private _dofAperture;
  36013. private _dofDarken;
  36014. private _dofPentagon;
  36015. private _blurNoise;
  36016. /**
  36017. * @constructor
  36018. *
  36019. * Effect parameters are as follow:
  36020. * {
  36021. * chromatic_aberration: number; // from 0 to x (1 for realism)
  36022. * edge_blur: number; // from 0 to x (1 for realism)
  36023. * distortion: number; // from 0 to x (1 for realism)
  36024. * grain_amount: number; // from 0 to 1
  36025. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  36026. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  36027. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  36028. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  36029. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  36030. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  36031. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  36032. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  36033. * }
  36034. * Note: if an effect parameter is unset, effect is disabled
  36035. *
  36036. * @param {string} name - The rendering pipeline name
  36037. * @param {object} parameters - An object containing all parameters (see above)
  36038. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36039. * @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)
  36040. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36041. */
  36042. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  36043. setEdgeBlur(amount: number): void;
  36044. disableEdgeBlur(): void;
  36045. setGrainAmount(amount: number): void;
  36046. disableGrain(): void;
  36047. setChromaticAberration(amount: number): void;
  36048. disableChromaticAberration(): void;
  36049. setEdgeDistortion(amount: number): void;
  36050. disableEdgeDistortion(): void;
  36051. setFocusDistance(amount: number): void;
  36052. disableDepthOfField(): void;
  36053. setAperture(amount: number): void;
  36054. setDarkenOutOfFocus(amount: number): void;
  36055. enablePentagonBokeh(): void;
  36056. disablePentagonBokeh(): void;
  36057. enableNoiseBlur(): void;
  36058. disableNoiseBlur(): void;
  36059. setHighlightsGain(amount: number): void;
  36060. setHighlightsThreshold(amount: number): void;
  36061. disableHighlights(): void;
  36062. /**
  36063. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  36064. */
  36065. dispose(disableDepthRender?: boolean): void;
  36066. private _createChromaticAberrationPostProcess(ratio);
  36067. private _createHighlightsPostProcess(ratio);
  36068. private _createDepthOfFieldPostProcess(ratio);
  36069. private _createGrainTexture();
  36070. }
  36071. }
  36072. declare module BABYLON {
  36073. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  36074. /**
  36075. * The PassPostProcess id in the pipeline that contains the original scene color
  36076. */
  36077. SSAOOriginalSceneColorEffect: string;
  36078. /**
  36079. * The SSAO PostProcess id in the pipeline
  36080. */
  36081. SSAORenderEffect: string;
  36082. /**
  36083. * The horizontal blur PostProcess id in the pipeline
  36084. */
  36085. SSAOBlurHRenderEffect: string;
  36086. /**
  36087. * The vertical blur PostProcess id in the pipeline
  36088. */
  36089. SSAOBlurVRenderEffect: string;
  36090. /**
  36091. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  36092. */
  36093. SSAOCombineRenderEffect: string;
  36094. /**
  36095. * The output strength of the SSAO post-process. Default value is 1.0.
  36096. */
  36097. totalStrength: number;
  36098. /**
  36099. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  36100. */
  36101. maxZ: number;
  36102. /**
  36103. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  36104. */
  36105. minZAspect: number;
  36106. /**
  36107. * Number of samples used for the SSAO calculations. Default value is 8
  36108. */
  36109. private _samples;
  36110. /**
  36111. * Ratio object used for SSAO ratio and blur ratio
  36112. */
  36113. private _ratio;
  36114. /**
  36115. * Dynamically generated sphere sampler.
  36116. */
  36117. private _sampleSphere;
  36118. /**
  36119. * Blur filter offsets
  36120. */
  36121. private _samplerOffsets;
  36122. samples: number;
  36123. /**
  36124. * Are we using bilateral blur ?
  36125. */
  36126. private _expensiveBlur;
  36127. expensiveBlur: boolean;
  36128. /**
  36129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  36130. */
  36131. radius: number;
  36132. /**
  36133. * The base color of the SSAO post-process
  36134. * The final result is "base + ssao" between [0, 1]
  36135. */
  36136. base: number;
  36137. /**
  36138. * Support test.
  36139. */
  36140. static readonly IsSupported: boolean;
  36141. private _scene;
  36142. private _depthTexture;
  36143. private _normalTexture;
  36144. private _randomTexture;
  36145. private _originalColorPostProcess;
  36146. private _ssaoPostProcess;
  36147. private _blurHPostProcess;
  36148. private _blurVPostProcess;
  36149. private _ssaoCombinePostProcess;
  36150. private _firstUpdate;
  36151. /**
  36152. * @constructor
  36153. * @param {string} name - The rendering pipeline name
  36154. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36155. * @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 }
  36156. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36157. */
  36158. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36159. /**
  36160. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36161. */
  36162. dispose(disableGeometryBufferRenderer?: boolean): void;
  36163. private _createBlurPostProcess(ssaoRatio, blurRatio);
  36164. _rebuild(): void;
  36165. private _generateHemisphere();
  36166. private _createSSAOPostProcess(ratio);
  36167. private _createSSAOCombinePostProcess(ratio);
  36168. private _createRandomTexture();
  36169. /**
  36170. * Serialize the rendering pipeline (Used when exporting)
  36171. * @returns the serialized object
  36172. */
  36173. serialize(): any;
  36174. /**
  36175. * Parse the serialized pipeline
  36176. * @param source Source pipeline.
  36177. * @param scene The scene to load the pipeline to.
  36178. * @param rootUrl The URL of the serialized pipeline.
  36179. * @returns An instantiated pipeline from the serialized object.
  36180. */
  36181. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  36182. }
  36183. }
  36184. declare module BABYLON {
  36185. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  36186. /**
  36187. * The PassPostProcess id in the pipeline that contains the original scene color
  36188. */
  36189. SSAOOriginalSceneColorEffect: string;
  36190. /**
  36191. * The SSAO PostProcess id in the pipeline
  36192. */
  36193. SSAORenderEffect: string;
  36194. /**
  36195. * The horizontal blur PostProcess id in the pipeline
  36196. */
  36197. SSAOBlurHRenderEffect: string;
  36198. /**
  36199. * The vertical blur PostProcess id in the pipeline
  36200. */
  36201. SSAOBlurVRenderEffect: string;
  36202. /**
  36203. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  36204. */
  36205. SSAOCombineRenderEffect: string;
  36206. /**
  36207. * The output strength of the SSAO post-process. Default value is 1.0.
  36208. */
  36209. totalStrength: number;
  36210. /**
  36211. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  36212. */
  36213. radius: number;
  36214. /**
  36215. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  36216. * Must not be equal to fallOff and superior to fallOff.
  36217. * Default value is 0.975
  36218. */
  36219. area: number;
  36220. /**
  36221. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  36222. * Must not be equal to area and inferior to area.
  36223. * Default value is 0.0
  36224. */
  36225. fallOff: number;
  36226. /**
  36227. * The base color of the SSAO post-process
  36228. * The final result is "base + ssao" between [0, 1]
  36229. */
  36230. base: number;
  36231. private _scene;
  36232. private _depthTexture;
  36233. private _randomTexture;
  36234. private _originalColorPostProcess;
  36235. private _ssaoPostProcess;
  36236. private _blurHPostProcess;
  36237. private _blurVPostProcess;
  36238. private _ssaoCombinePostProcess;
  36239. private _firstUpdate;
  36240. /**
  36241. * @constructor
  36242. * @param {string} name - The rendering pipeline name
  36243. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36244. * @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 }
  36245. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36246. */
  36247. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36248. /**
  36249. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36250. */
  36251. dispose(disableDepthRender?: boolean): void;
  36252. private _createBlurPostProcess(ratio);
  36253. _rebuild(): void;
  36254. private _createSSAOPostProcess(ratio);
  36255. private _createSSAOCombinePostProcess(ratio);
  36256. private _createRandomTexture();
  36257. }
  36258. }
  36259. declare module BABYLON {
  36260. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36261. /**
  36262. * Public members
  36263. */
  36264. originalPostProcess: Nullable<PostProcess>;
  36265. downSampleX4PostProcess: Nullable<PostProcess>;
  36266. brightPassPostProcess: Nullable<PostProcess>;
  36267. blurHPostProcesses: PostProcess[];
  36268. blurVPostProcesses: PostProcess[];
  36269. textureAdderPostProcess: Nullable<PostProcess>;
  36270. volumetricLightPostProcess: Nullable<PostProcess>;
  36271. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  36272. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  36273. volumetricLightMergePostProces: Nullable<PostProcess>;
  36274. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  36275. luminancePostProcess: Nullable<PostProcess>;
  36276. luminanceDownSamplePostProcesses: PostProcess[];
  36277. hdrPostProcess: Nullable<PostProcess>;
  36278. textureAdderFinalPostProcess: Nullable<PostProcess>;
  36279. lensFlareFinalPostProcess: Nullable<PostProcess>;
  36280. hdrFinalPostProcess: Nullable<PostProcess>;
  36281. lensFlarePostProcess: Nullable<PostProcess>;
  36282. lensFlareComposePostProcess: Nullable<PostProcess>;
  36283. motionBlurPostProcess: Nullable<PostProcess>;
  36284. depthOfFieldPostProcess: Nullable<PostProcess>;
  36285. brightThreshold: number;
  36286. blurWidth: number;
  36287. horizontalBlur: boolean;
  36288. exposure: number;
  36289. lensTexture: Nullable<Texture>;
  36290. volumetricLightCoefficient: number;
  36291. volumetricLightPower: number;
  36292. volumetricLightBlurScale: number;
  36293. sourceLight: Nullable<SpotLight | DirectionalLight>;
  36294. hdrMinimumLuminance: number;
  36295. hdrDecreaseRate: number;
  36296. hdrIncreaseRate: number;
  36297. lensColorTexture: Nullable<Texture>;
  36298. lensFlareStrength: number;
  36299. lensFlareGhostDispersal: number;
  36300. lensFlareHaloWidth: number;
  36301. lensFlareDistortionStrength: number;
  36302. lensStarTexture: Nullable<Texture>;
  36303. lensFlareDirtTexture: Nullable<Texture>;
  36304. depthOfFieldDistance: number;
  36305. depthOfFieldBlurWidth: number;
  36306. motionStrength: number;
  36307. animations: Animation[];
  36308. /**
  36309. * Private members
  36310. */
  36311. private _scene;
  36312. private _currentDepthOfFieldSource;
  36313. private _basePostProcess;
  36314. private _hdrCurrentLuminance;
  36315. private _floatTextureType;
  36316. private _ratio;
  36317. private _bloomEnabled;
  36318. private _depthOfFieldEnabled;
  36319. private _vlsEnabled;
  36320. private _lensFlareEnabled;
  36321. private _hdrEnabled;
  36322. private _motionBlurEnabled;
  36323. private _motionBlurSamples;
  36324. private _volumetricLightStepsCount;
  36325. BloomEnabled: boolean;
  36326. DepthOfFieldEnabled: boolean;
  36327. LensFlareEnabled: boolean;
  36328. HDREnabled: boolean;
  36329. VLSEnabled: boolean;
  36330. MotionBlurEnabled: boolean;
  36331. volumetricLightStepsCount: number;
  36332. motionBlurSamples: number;
  36333. /**
  36334. * @constructor
  36335. * @param {string} name - The rendering pipeline name
  36336. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36337. * @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)
  36338. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  36339. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36340. */
  36341. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  36342. private _buildPipeline();
  36343. private _createDownSampleX4PostProcess(scene, ratio);
  36344. private _createBrightPassPostProcess(scene, ratio);
  36345. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  36346. private _createTextureAdderPostProcess(scene, ratio);
  36347. private _createVolumetricLightPostProcess(scene, ratio);
  36348. private _createLuminancePostProcesses(scene, textureType);
  36349. private _createHdrPostProcess(scene, ratio);
  36350. private _createLensFlarePostProcess(scene, ratio);
  36351. private _createDepthOfFieldPostProcess(scene, ratio);
  36352. private _createMotionBlurPostProcess(scene, ratio);
  36353. private _getDepthTexture();
  36354. private _disposePostProcesses();
  36355. /**
  36356. * Dispose of the pipeline and stop all post processes
  36357. */
  36358. dispose(): void;
  36359. /**
  36360. * Serialize the rendering pipeline (Used when exporting)
  36361. * @returns the serialized object
  36362. */
  36363. serialize(): any;
  36364. /**
  36365. * Parse the serialized pipeline
  36366. * @param source Source pipeline.
  36367. * @param scene The scene to load the pipeline to.
  36368. * @param rootUrl The URL of the serialized pipeline.
  36369. * @returns An instantiated pipeline from the serialized object.
  36370. */
  36371. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  36372. static LuminanceSteps: number;
  36373. }
  36374. }