babylon.d.ts 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567
  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. RED: number;
  239. RG: number;
  240. UNSIGNED_INT_24_8: number;
  241. DEPTH24_STENCIL8: number;
  242. drawBuffers(buffers: number[]): void;
  243. readBuffer(src: number): void;
  244. readonly COLOR_ATTACHMENT0: number;
  245. readonly COLOR_ATTACHMENT1: number;
  246. readonly COLOR_ATTACHMENT2: number;
  247. readonly COLOR_ATTACHMENT3: number;
  248. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  249. ANY_SAMPLES_PASSED: number;
  250. QUERY_RESULT_AVAILABLE: number;
  251. QUERY_RESULT: number;
  252. }
  253. interface Document {
  254. mozCancelFullScreen(): void;
  255. msCancelFullScreen(): void;
  256. mozFullScreen: boolean;
  257. msIsFullScreen: boolean;
  258. fullscreen: boolean;
  259. mozPointerLockElement: HTMLElement;
  260. msPointerLockElement: HTMLElement;
  261. webkitPointerLockElement: HTMLElement;
  262. }
  263. interface HTMLCanvasElement {
  264. msRequestPointerLock?(): void;
  265. mozRequestPointerLock?(): void;
  266. webkitRequestPointerLock?(): void;
  267. }
  268. interface CanvasRenderingContext2D {
  269. msImageSmoothingEnabled: boolean;
  270. }
  271. interface WebGLBuffer {
  272. references: number;
  273. capacity: number;
  274. is32Bits: boolean;
  275. }
  276. interface WebGLProgram {
  277. transformFeedback?: WebGLTransformFeedback | null;
  278. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  279. }
  280. interface MouseEvent {
  281. mozMovementX: number;
  282. mozMovementY: number;
  283. webkitMovementX: number;
  284. webkitMovementY: number;
  285. msMovementX: number;
  286. msMovementY: number;
  287. }
  288. interface Navigator {
  289. mozGetVRDevices: (any: any) => any;
  290. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  291. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  292. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  293. webkitGetGamepads(): Gamepad[];
  294. msGetGamepads(): Gamepad[];
  295. webkitGamepads(): Gamepad[];
  296. }
  297. interface HTMLVideoElement {
  298. mozSrcObject: any;
  299. }
  300. interface Screen {
  301. orientation: string;
  302. mozOrientation: string;
  303. }
  304. interface Math {
  305. fround(x: number): number;
  306. imul(a: number, b: number): number;
  307. }
  308. interface EXT_disjoint_timer_query {
  309. QUERY_COUNTER_BITS_EXT: number;
  310. TIME_ELAPSED_EXT: number;
  311. TIMESTAMP_EXT: number;
  312. GPU_DISJOINT_EXT: number;
  313. QUERY_RESULT_EXT: number;
  314. QUERY_RESULT_AVAILABLE_EXT: number;
  315. queryCounterEXT(query: WebGLQuery, target: number): void;
  316. createQueryEXT(): WebGLQuery;
  317. beginQueryEXT(target: number, query: WebGLQuery): void;
  318. endQueryEXT(target: number): void;
  319. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  320. deleteQueryEXT(query: WebGLQuery): void;
  321. }
  322. interface WebGLUniformLocation {
  323. _currentState: any;
  324. }
  325. declare module BABYLON {
  326. /**
  327. * Node is the basic class for all scene objects (Mesh, Light Camera).
  328. */
  329. class Node {
  330. /**
  331. * Gets or sets the name of the node
  332. */
  333. name: string;
  334. /**
  335. * Gets or sets the id of the node
  336. */
  337. id: string;
  338. /**
  339. * Gets or sets the unique id of the node
  340. */
  341. uniqueId: number;
  342. /**
  343. * Gets or sets a string used to store user defined state for the node
  344. */
  345. state: string;
  346. /**
  347. * Gets or sets an object used to store user defined information for the node
  348. */
  349. metadata: any;
  350. /**
  351. * Gets or sets a boolean used to define if the node must be serialized
  352. */
  353. doNotSerialize: boolean;
  354. /** @hidden */
  355. _isDisposed: boolean;
  356. /**
  357. * Gets a list of Animations associated with the node
  358. */
  359. animations: Animation[];
  360. private _ranges;
  361. /**
  362. * Callback raised when the node is ready to be used
  363. */
  364. onReady: (node: Node) => void;
  365. private _isEnabled;
  366. private _isReady;
  367. /** @hidden */
  368. _currentRenderId: number;
  369. private _parentRenderId;
  370. protected _childRenderId: number;
  371. /** @hidden */
  372. _waitingParentId: Nullable<string>;
  373. private _scene;
  374. /** @hidden */
  375. _cache: any;
  376. private _parentNode;
  377. private _children;
  378. /**
  379. * Gets a boolean indicating if the node has been disposed
  380. * @returns true if the node was disposed
  381. */
  382. isDisposed(): boolean;
  383. /**
  384. * Gets or sets the parent of the node
  385. */
  386. parent: Nullable<Node>;
  387. private _animationPropertiesOverride;
  388. /**
  389. * Gets or sets the animation properties override
  390. */
  391. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  392. /**
  393. * Gets a string idenfifying the name of the class
  394. * @returns "Node" string
  395. */
  396. getClassName(): string;
  397. /**
  398. * An event triggered when the mesh is disposed
  399. */
  400. onDisposeObservable: Observable<Node>;
  401. private _onDisposeObserver;
  402. /**
  403. * Sets a callback that will be raised when the node will be disposed
  404. */
  405. onDispose: () => void;
  406. /**
  407. * Creates a new Node
  408. * @param {string} name - the name and id to be given to this node
  409. * @param {BABYLON.Scene} the scene this node will be added to
  410. */
  411. constructor(name: string, scene?: Nullable<Scene>);
  412. /**
  413. * Gets the scene of the node
  414. * @returns a {BABYLON.Scene}
  415. */
  416. getScene(): Scene;
  417. /**
  418. * Gets the engine of the node
  419. * @returns a {BABYLON.Engine}
  420. */
  421. getEngine(): Engine;
  422. private _behaviors;
  423. /**
  424. * Attach a behavior to the node
  425. * @see http://doc.babylonjs.com/features/behaviour
  426. * @param behavior defines the behavior to attach
  427. * @returns the current Node
  428. */
  429. addBehavior(behavior: Behavior<Node>): Node;
  430. /**
  431. * Remove an attached behavior
  432. * @see http://doc.babylonjs.com/features/behaviour
  433. * @param behavior defines the behavior to attach
  434. * @returns the current Node
  435. */
  436. removeBehavior(behavior: Behavior<Node>): Node;
  437. /**
  438. * Gets the list of attached behaviors
  439. * @see http://doc.babylonjs.com/features/behaviour
  440. */
  441. readonly behaviors: Behavior<Node>[];
  442. /**
  443. * Gets an attached behavior by name
  444. * @param name defines the name of the behavior to look for
  445. * @see http://doc.babylonjs.com/features/behaviour
  446. * @returns null if behavior was not found else the requested behavior
  447. */
  448. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  449. /**
  450. * Returns the world matrix of the node
  451. * @returns a matrix containing the node's world matrix
  452. */
  453. getWorldMatrix(): Matrix;
  454. /** @hidden */
  455. _getWorldMatrixDeterminant(): number;
  456. /** @hidden */
  457. _initCache(): void;
  458. /** @hidden */
  459. updateCache(force?: boolean): void;
  460. /** @hidden */
  461. _updateCache(ignoreParentClass?: boolean): void;
  462. /** @hidden */
  463. _isSynchronized(): boolean;
  464. /** @hidden */
  465. _markSyncedWithParent(): void;
  466. /** @hidden */
  467. isSynchronizedWithParent(): boolean;
  468. /** @hidden */
  469. isSynchronized(updateCache?: boolean): boolean;
  470. /** @hidden */
  471. hasNewParent(update?: boolean): boolean;
  472. /**
  473. * Is this node ready to be used/rendered
  474. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  475. * @return true if the node is ready
  476. */
  477. isReady(completeCheck?: boolean): boolean;
  478. /**
  479. * Is this node enabled?
  480. * 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
  481. * @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
  482. * @return whether this node (and its parent) is enabled
  483. */
  484. isEnabled(checkAncestors?: boolean): boolean;
  485. /**
  486. * Set the enabled state of this node
  487. * @param value defines the new enabled state
  488. */
  489. setEnabled(value: boolean): void;
  490. /**
  491. * Is this node a descendant of the given node?
  492. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  493. * @param ancestor defines the parent node to inspect
  494. * @returns a boolean indicating if this node is a descendant of the given node
  495. */
  496. isDescendantOf(ancestor: Node): boolean;
  497. /** @hidden */
  498. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  499. /**
  500. * Will return all nodes that have this node as ascendant
  501. * @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
  502. * @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
  503. * @return all children nodes of all types
  504. */
  505. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  506. /**
  507. * Get all child-meshes of this node
  508. * @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
  509. * @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
  510. * @returns an array of {BABYLON.AbstractMesh}
  511. */
  512. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  513. /**
  514. * Get all child-transformNodes of this node
  515. * @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
  516. * @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
  517. * @returns an array of {BABYLON.TransformNode}
  518. */
  519. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  520. /**
  521. * Get all direct children of this node
  522. * @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
  523. * @returns an array of {BABYLON.Node}
  524. */
  525. getChildren(predicate?: (node: Node) => boolean): Node[];
  526. /** @hidden */
  527. _setReady(state: boolean): void;
  528. /**
  529. * Get an animation by name
  530. * @param name defines the name of the animation to look for
  531. * @returns null if not found else the requested animation
  532. */
  533. getAnimationByName(name: string): Nullable<Animation>;
  534. /**
  535. * Creates an animation range for this node
  536. * @param name defines the name of the range
  537. * @param from defines the starting key
  538. * @param to defines the end key
  539. */
  540. createAnimationRange(name: string, from: number, to: number): void;
  541. /**
  542. * Delete a specific animation range
  543. * @param name defines the name of the range to delete
  544. * @param deleteFrames defines if animation frames from the range must be deleted as well
  545. */
  546. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  547. /**
  548. * Get an animation range by name
  549. * @param name defines the name of the animation range to look for
  550. * @returns null if not found else the requested animation range
  551. */
  552. getAnimationRange(name: string): Nullable<AnimationRange>;
  553. /**
  554. * Will start the animation sequence
  555. * @param name defines the range frames for animation sequence
  556. * @param loop defines if the animation should loop (false by default)
  557. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  558. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  559. * @returns the object created for this animation. If range does not exist, it will return null
  560. */
  561. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  562. /**
  563. * Serialize animation ranges into a JSON compatible object
  564. * @returns serialization object
  565. */
  566. serializeAnimationRanges(): any;
  567. /**
  568. * Computes the world matrix of the node
  569. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  570. * @returns the world matrix
  571. */
  572. computeWorldMatrix(force?: boolean): Matrix;
  573. /**
  574. * Releases resources associated with this node.
  575. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  576. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  577. */
  578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  579. /**
  580. * Parse animation range data from a serialization object and store them into a given node
  581. * @param node defines where to store the animation ranges
  582. * @param parsedNode defines the serialization object to read data from
  583. * @param scene defines the hosting scene
  584. */
  585. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  586. }
  587. }
  588. declare module BABYLON {
  589. /**
  590. * Define an interface for all classes that will hold resources
  591. */
  592. interface IDisposable {
  593. /**
  594. * Releases all held resources
  595. */
  596. dispose(): void;
  597. }
  598. /**
  599. * Interface used to let developers provide their own mesh selection mechanism
  600. */
  601. interface IActiveMeshCandidateProvider {
  602. /**
  603. * Return the list of active meshes
  604. * @param scene defines the current scene
  605. * @returns the list of active meshes
  606. */
  607. getMeshes(scene: Scene): AbstractMesh[];
  608. /**
  609. * Indicates if the meshes have been checked to make sure they are isEnabled()
  610. */
  611. readonly checksIsEnabled: boolean;
  612. }
  613. /**
  614. * This class is used by the onRenderingGroupObservable
  615. */
  616. class RenderingGroupInfo {
  617. /**
  618. * The Scene that being rendered
  619. */
  620. scene: Scene;
  621. /**
  622. * The camera currently used for the rendering pass
  623. */
  624. camera: Nullable<Camera>;
  625. /**
  626. * The ID of the renderingGroup being processed
  627. */
  628. renderingGroupId: number;
  629. /**
  630. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  631. */
  632. renderStage: number;
  633. /**
  634. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  635. * This stage will be fired no matter what
  636. */
  637. static STAGE_PRECLEAR: number;
  638. /**
  639. * Called before opaque object are rendered.
  640. * This stage will be fired only if there's 3D Opaque content to render
  641. */
  642. static STAGE_PREOPAQUE: number;
  643. /**
  644. * Called after the opaque objects are rendered and before the transparent ones
  645. * This stage will be fired only if there's 3D transparent content to render
  646. */
  647. static STAGE_PRETRANSPARENT: number;
  648. /**
  649. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  650. * This stage will be fired no matter what
  651. */
  652. static STAGE_POSTTRANSPARENT: number;
  653. }
  654. /**
  655. * Represents a scene to be rendered by the engine.
  656. * @see http://doc.babylonjs.com/features/scene
  657. */
  658. class Scene implements IAnimatable {
  659. private static _FOGMODE_NONE;
  660. private static _FOGMODE_EXP;
  661. private static _FOGMODE_EXP2;
  662. private static _FOGMODE_LINEAR;
  663. private static _uniqueIdCounter;
  664. /**
  665. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  667. */
  668. static MinDeltaTime: number;
  669. /**
  670. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MaxDeltaTime: number;
  674. /** The fog is deactivated */
  675. static readonly FOGMODE_NONE: number;
  676. /** The fog density is following an exponential function */
  677. static readonly FOGMODE_EXP: number;
  678. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  679. static readonly FOGMODE_EXP2: number;
  680. /** The fog density is following a linear function. */
  681. static readonly FOGMODE_LINEAR: number;
  682. /**
  683. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  684. */
  685. autoClear: boolean;
  686. /**
  687. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  688. */
  689. autoClearDepthAndStencil: boolean;
  690. /**
  691. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  692. */
  693. clearColor: Color4;
  694. /**
  695. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  696. */
  697. ambientColor: Color3;
  698. /** @hidden */
  699. _environmentBRDFTexture: BaseTexture;
  700. /** @hidden */
  701. protected _environmentTexture: BaseTexture;
  702. /**
  703. * Texture used in all pbr material as the reflection texture.
  704. * As in the majority of the scene they are the same (exception for multi room and so on),
  705. * this is easier to reference from here than from all the materials.
  706. */
  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 set here than in all the materials.
  711. */
  712. environmentTexture: BaseTexture;
  713. /** @hidden */
  714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  715. /**
  716. * Default image processing configuration used either in the rendering
  717. * Forward main pass or through the imageProcessingPostProcess if present.
  718. * As in the majority of the scene they are the same (exception for multi camera),
  719. * this is easier to reference from here than from all the materials and post process.
  720. *
  721. * No setter as we it is a shared configuration, you can set the values instead.
  722. */
  723. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  724. private _forceWireframe;
  725. /**
  726. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  727. */
  728. forceWireframe: boolean;
  729. private _forcePointsCloud;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  732. */
  733. forcePointsCloud: boolean;
  734. /**
  735. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  736. */
  737. forceShowBoundingBoxes: boolean;
  738. /**
  739. * Gets or sets the active clipplane
  740. */
  741. clipPlane: Nullable<Plane>;
  742. /**
  743. * Gets or sets a boolean indicating if animations are enabled
  744. */
  745. animationsEnabled: boolean;
  746. private _animationPropertiesOverride;
  747. /**
  748. * Gets or sets the animation properties override
  749. */
  750. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  751. /**
  752. * Gets or sets a boolean indicating if a constant deltatime has to be used
  753. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  754. */
  755. useConstantAnimationDeltaTime: boolean;
  756. /**
  757. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  758. * Please note that it requires to run a ray cast through the scene on every frame
  759. */
  760. constantlyUpdateMeshUnderPointer: boolean;
  761. /**
  762. * Defines the HTML cursor to use when hovering over interactive elements
  763. */
  764. hoverCursor: string;
  765. /**
  766. * Defines the HTML default cursor to use (empty by default)
  767. */
  768. defaultCursor: string;
  769. /**
  770. * This is used to call preventDefault() on pointer down
  771. * in order to block unwanted artifacts like system double clicks
  772. */
  773. preventDefaultOnPointerDown: boolean;
  774. /**
  775. * Gets or sets user defined metadata
  776. */
  777. metadata: any;
  778. /**
  779. * Gets the name of the plugin used to load this scene (null by default)
  780. */
  781. loadingPluginName: string;
  782. /**
  783. * Use this array to add regular expressions used to disable offline support for specific urls
  784. */
  785. disableOfflineSupportExceptionRules: RegExp[];
  786. private _spritePredicate;
  787. /**
  788. * An event triggered when the scene is disposed.
  789. */
  790. onDisposeObservable: Observable<Scene>;
  791. private _onDisposeObserver;
  792. /** Sets a function to be executed when this scene is disposed. */
  793. onDispose: () => void;
  794. /**
  795. * An event triggered before rendering the scene (right after animations and physics)
  796. */
  797. onBeforeRenderObservable: Observable<Scene>;
  798. private _onBeforeRenderObserver;
  799. /** Sets a function to be executed before rendering this scene */
  800. beforeRender: Nullable<() => void>;
  801. /**
  802. * An event triggered after rendering the scene
  803. */
  804. onAfterRenderObservable: Observable<Scene>;
  805. private _onAfterRenderObserver;
  806. /** Sets a function to be executed after rendering this scene */
  807. afterRender: Nullable<() => void>;
  808. /**
  809. * An event triggered before animating the scene
  810. */
  811. onBeforeAnimationsObservable: Observable<Scene>;
  812. /**
  813. * An event triggered after animations processing
  814. */
  815. onAfterAnimationsObservable: Observable<Scene>;
  816. /**
  817. * An event triggered before draw calls are ready to be sent
  818. */
  819. onBeforeDrawPhaseObservable: Observable<Scene>;
  820. /**
  821. * An event triggered after draw calls have been sent
  822. */
  823. onAfterDrawPhaseObservable: Observable<Scene>;
  824. /**
  825. * An event triggered when physic simulation is about to be run
  826. */
  827. onBeforePhysicsObservable: Observable<Scene>;
  828. /**
  829. * An event triggered when physic simulation has been done
  830. */
  831. onAfterPhysicsObservable: Observable<Scene>;
  832. /**
  833. * An event triggered when the scene is ready
  834. */
  835. onReadyObservable: Observable<Scene>;
  836. /**
  837. * An event triggered before rendering a camera
  838. */
  839. onBeforeCameraRenderObservable: Observable<Camera>;
  840. private _onBeforeCameraRenderObserver;
  841. /** Sets a function to be executed before rendering a camera*/
  842. beforeCameraRender: () => void;
  843. /**
  844. * An event triggered after rendering a camera
  845. */
  846. onAfterCameraRenderObservable: Observable<Camera>;
  847. private _onAfterCameraRenderObserver;
  848. /** Sets a function to be executed after rendering a camera*/
  849. afterCameraRender: () => void;
  850. /**
  851. * An event triggered when active meshes evaluation is about to start
  852. */
  853. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when active meshes evaluation is done
  856. */
  857. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when particles rendering is about to start
  860. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  861. */
  862. onBeforeParticlesRenderingObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is done
  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. onAfterParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when sprites rendering is about to start
  870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  871. */
  872. onBeforeSpritesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  880. */
  881. onDataLoadedObservable: Observable<Scene>;
  882. /**
  883. * An event triggered when a camera is created
  884. */
  885. onNewCameraAddedObservable: Observable<Camera>;
  886. /**
  887. * An event triggered when a camera is removed
  888. */
  889. onCameraRemovedObservable: Observable<Camera>;
  890. /**
  891. * An event triggered when a light is created
  892. */
  893. onNewLightAddedObservable: Observable<Light>;
  894. /**
  895. * An event triggered when a light is removed
  896. */
  897. onLightRemovedObservable: Observable<Light>;
  898. /**
  899. * An event triggered when a geometry is created
  900. */
  901. onNewGeometryAddedObservable: Observable<Geometry>;
  902. /**
  903. * An event triggered when a geometry is removed
  904. */
  905. onGeometryRemovedObservable: Observable<Geometry>;
  906. /**
  907. * An event triggered when a transform node is created
  908. */
  909. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  910. /**
  911. * An event triggered when a transform node is removed
  912. */
  913. onTransformNodeRemovedObservable: Observable<TransformNode>;
  914. /**
  915. * An event triggered when a mesh is created
  916. */
  917. onNewMeshAddedObservable: Observable<AbstractMesh>;
  918. /**
  919. * An event triggered when a mesh is removed
  920. */
  921. onMeshRemovedObservable: Observable<AbstractMesh>;
  922. /**
  923. * An event triggered when render targets are about to be rendered
  924. * Can happen multiple times per frame.
  925. */
  926. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  927. /**
  928. * An event triggered when render targets were rendered.
  929. * Can happen multiple times per frame.
  930. */
  931. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered before calculating deterministic simulation step
  934. */
  935. onBeforeStepObservable: Observable<Scene>;
  936. /**
  937. * An event triggered after calculating deterministic simulation step
  938. */
  939. onAfterStepObservable: Observable<Scene>;
  940. /**
  941. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  942. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  943. * 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)
  944. */
  945. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  946. /**
  947. * Gets a list of Animations associated with the scene
  948. */
  949. animations: Animation[];
  950. private _registeredForLateAnimationBindings;
  951. /**
  952. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  953. */
  954. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  955. /**
  956. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  957. */
  958. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  959. /**
  960. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  961. */
  962. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  963. private _onPointerMove;
  964. private _onPointerDown;
  965. private _onPointerUp;
  966. /** Deprecated. Use onPointerObservable instead */
  967. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  968. /** Deprecated. Use onPointerObservable instead */
  969. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  970. /** Deprecated. Use onPointerObservable instead */
  971. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  972. /** Deprecated. Use onPointerObservable instead */
  973. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  974. private _gamepadManager;
  975. /**
  976. * Gets the gamepad manager associated with the scene
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  978. */
  979. readonly gamepadManager: GamepadManager;
  980. /**
  981. * 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).
  982. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  983. */
  984. onPrePointerObservable: Observable<PointerInfoPre>;
  985. /**
  986. * Observable event triggered each time an input event is received from the rendering canvas
  987. */
  988. onPointerObservable: Observable<PointerInfo>;
  989. /**
  990. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  991. */
  992. readonly unTranslatedPointer: Vector2;
  993. /** The distance in pixel that you have to move to prevent some events */
  994. static DragMovementThreshold: number;
  995. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  996. static LongPressDelay: number;
  997. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  998. static DoubleClickDelay: number;
  999. /** If you need to check double click without raising a single click at first click, enable this flag */
  1000. static ExclusiveDoubleClickMode: boolean;
  1001. private _initClickEvent;
  1002. private _initActionManager;
  1003. private _delayedSimpleClick;
  1004. private _delayedSimpleClickTimeout;
  1005. private _previousDelayedSimpleClickTimeout;
  1006. private _meshPickProceed;
  1007. private _previousButtonPressed;
  1008. private _currentPickResult;
  1009. private _previousPickResult;
  1010. private _totalPointersPressed;
  1011. private _doubleClickOccured;
  1012. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1013. cameraToUseForPointers: Nullable<Camera>;
  1014. private _pointerX;
  1015. private _pointerY;
  1016. private _unTranslatedPointerX;
  1017. private _unTranslatedPointerY;
  1018. private _startingPointerPosition;
  1019. private _previousStartingPointerPosition;
  1020. private _startingPointerTime;
  1021. private _previousStartingPointerTime;
  1022. private _pointerCaptures;
  1023. private _timeAccumulator;
  1024. private _currentStepId;
  1025. private _currentInternalStep;
  1026. /** @hidden */
  1027. _mirroredCameraPosition: Nullable<Vector3>;
  1028. /**
  1029. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1030. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1031. */
  1032. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1033. /**
  1034. * Observable event triggered each time an keyboard event is received from the hosting window
  1035. */
  1036. onKeyboardObservable: Observable<KeyboardInfo>;
  1037. private _onKeyDown;
  1038. private _onKeyUp;
  1039. private _onCanvasFocusObserver;
  1040. private _onCanvasBlurObserver;
  1041. private _useRightHandedSystem;
  1042. /**
  1043. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1044. */
  1045. useRightHandedSystem: boolean;
  1046. /**
  1047. * Sets the step Id used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @param newStepId defines the step Id
  1050. */
  1051. setStepId(newStepId: number): void;
  1052. /**
  1053. * Gets the step Id used by deterministic lock step
  1054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1055. * @returns the step Id
  1056. */
  1057. getStepId(): number;
  1058. /**
  1059. * Gets the internal step used by deterministic lock step
  1060. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1061. * @returns the internal step
  1062. */
  1063. getInternalStep(): number;
  1064. private _fogEnabled;
  1065. /**
  1066. * Gets or sets a boolean indicating if fog is enabled on this scene
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogEnabled: boolean;
  1070. private _fogMode;
  1071. /**
  1072. * Gets or sets the fog mode to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. */
  1075. fogMode: number;
  1076. /**
  1077. * Gets or sets the fog color to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogColor: Color3;
  1081. /**
  1082. * Gets or sets the fog density to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogDensity: number;
  1086. /**
  1087. * Gets or sets the fog start distance to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogStart: number;
  1091. /**
  1092. * Gets or sets the fog end distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogEnd: number;
  1096. private _shadowsEnabled;
  1097. /**
  1098. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1099. */
  1100. shadowsEnabled: boolean;
  1101. private _lightsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if lights are enabled on this scene
  1104. */
  1105. lightsEnabled: boolean;
  1106. /**
  1107. * All of the lights added to this scene
  1108. * @see http://doc.babylonjs.com/babylon101/lights
  1109. */
  1110. lights: Light[];
  1111. /** All of the cameras added to this scene.
  1112. * @see http://doc.babylonjs.com/babylon101/cameras
  1113. */
  1114. cameras: Camera[];
  1115. /** All of the active cameras added to this scene. */
  1116. activeCameras: Camera[];
  1117. /** The current active camera */
  1118. activeCamera: Nullable<Camera>;
  1119. /**
  1120. * All of the tranform nodes added to this scene
  1121. * @see http://doc.babylonjs.com/how_to/transformnode
  1122. */
  1123. transformNodes: TransformNode[];
  1124. /**
  1125. * All of the (abstract) meshes added to this scene
  1126. */
  1127. meshes: AbstractMesh[];
  1128. /**
  1129. * All of the animation groups added to this scene
  1130. * @see http://doc.babylonjs.com/how_to/group
  1131. */
  1132. animationGroups: AnimationGroup[];
  1133. private _geometries;
  1134. /**
  1135. * All of the materials added to this scene
  1136. * @see http://doc.babylonjs.com/babylon101/materials
  1137. */
  1138. materials: Material[];
  1139. /**
  1140. * All of the multi-materials added to this scene
  1141. * @see http://doc.babylonjs.com/how_to/multi_materials
  1142. */
  1143. multiMaterials: MultiMaterial[];
  1144. private _defaultMaterial;
  1145. /** The default material used on meshes when no material is affected */
  1146. /** The default material used on meshes when no material is affected */
  1147. defaultMaterial: Material;
  1148. private _texturesEnabled;
  1149. /**
  1150. * Gets or sets a boolean indicating if textures are enabled on this scene
  1151. */
  1152. texturesEnabled: boolean;
  1153. /**
  1154. * All of the textures added to this scene
  1155. */
  1156. textures: BaseTexture[];
  1157. /**
  1158. * Gets or sets a boolean indicating if particles are enabled on this scene
  1159. */
  1160. particlesEnabled: boolean;
  1161. /**
  1162. * All of the particle systems added to this scene
  1163. * @see http://doc.babylonjs.com/babylon101/particles
  1164. */
  1165. particleSystems: IParticleSystem[];
  1166. /**
  1167. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1168. */
  1169. spritesEnabled: boolean;
  1170. /**
  1171. * All of the sprite managers added to this scene
  1172. * @see http://doc.babylonjs.com/babylon101/sprites
  1173. */
  1174. spriteManagers: SpriteManager[];
  1175. /**
  1176. * The list of layers (background and foreground) of the scene
  1177. */
  1178. layers: Layer[];
  1179. /**
  1180. * The list of effect layers (highlights/glow) added to the scene
  1181. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1182. * @see http://doc.babylonjs.com/how_to/glow_layer
  1183. */
  1184. effectLayers: EffectLayer[];
  1185. private _skeletonsEnabled;
  1186. /**
  1187. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1188. */
  1189. skeletonsEnabled: boolean;
  1190. /**
  1191. * The list of skeletons added to the scene
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1193. */
  1194. skeletons: Skeleton[];
  1195. /**
  1196. * The list of morph target managers added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1198. */
  1199. morphTargetManagers: MorphTargetManager[];
  1200. /**
  1201. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1202. */
  1203. lensFlaresEnabled: boolean;
  1204. /**
  1205. * The list of lens flare system added to the scene
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1207. */
  1208. lensFlareSystems: LensFlareSystem[];
  1209. /**
  1210. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1212. */
  1213. collisionsEnabled: boolean;
  1214. private _workerCollisions;
  1215. /** @hidden */
  1216. collisionCoordinator: ICollisionCoordinator;
  1217. /**
  1218. * Defines the gravity applied to this scene (used only for collisions)
  1219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1220. */
  1221. gravity: Vector3;
  1222. /**
  1223. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1224. */
  1225. postProcessesEnabled: boolean;
  1226. /**
  1227. * The list of postprocesses added to the scene
  1228. */
  1229. postProcesses: PostProcess[];
  1230. /**
  1231. * Gets the current postprocess manager
  1232. */
  1233. postProcessManager: PostProcessManager;
  1234. private _postProcessRenderPipelineManager;
  1235. /**
  1236. * Gets the postprocess render pipeline manager
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1238. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1239. */
  1240. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1241. /**
  1242. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1243. */
  1244. renderTargetsEnabled: boolean;
  1245. /**
  1246. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1247. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1248. */
  1249. dumpNextRenderTargets: boolean;
  1250. /**
  1251. * The list of user defined render targets added to the scene
  1252. */
  1253. customRenderTargets: RenderTargetTexture[];
  1254. /**
  1255. * Defines if texture loading must be delayed
  1256. * If true, textures will only be loaded when they need to be rendered
  1257. */
  1258. useDelayedTextureLoading: boolean;
  1259. /**
  1260. * Gets the list of meshes imported to the scene through SceneLoader
  1261. */
  1262. importedMeshesFiles: String[];
  1263. /**
  1264. * Gets or sets a boolean indicating if probes are enabled on this scene
  1265. */
  1266. probesEnabled: boolean;
  1267. /**
  1268. * The list of reflection probes added to the scene
  1269. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1270. */
  1271. reflectionProbes: ReflectionProbe[];
  1272. /**
  1273. * @hidden
  1274. */
  1275. database: Database;
  1276. /**
  1277. * Gets or sets the action manager associated with the scene
  1278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1279. */
  1280. actionManager: ActionManager;
  1281. /** @hidden */
  1282. _actionManagers: ActionManager[];
  1283. private _meshesForIntersections;
  1284. /**
  1285. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1286. */
  1287. proceduralTexturesEnabled: boolean;
  1288. /**
  1289. * The list of procedural textures added to the scene
  1290. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1291. */
  1292. proceduralTextures: ProceduralTexture[];
  1293. private _mainSoundTrack;
  1294. /**
  1295. * The list of sound tracks added to the scene
  1296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1297. */
  1298. soundTracks: SoundTrack[];
  1299. private _audioEnabled;
  1300. private _headphone;
  1301. /**
  1302. * Gets the main soundtrack associated with the scene
  1303. */
  1304. readonly mainSoundTrack: SoundTrack;
  1305. /**
  1306. * Gets or sets the VRExperienceHelper attached to the scene
  1307. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1308. * @ignorenaming
  1309. */
  1310. VRHelper: VRExperienceHelper;
  1311. /**
  1312. * Gets or sets the simplification queue attached to the scene
  1313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1314. */
  1315. simplificationQueue: SimplificationQueue;
  1316. private _engine;
  1317. private _totalVertices;
  1318. /** @hidden */
  1319. _activeIndices: PerfCounter;
  1320. /** @hidden */
  1321. _activeParticles: PerfCounter;
  1322. /** @hidden */
  1323. _activeBones: PerfCounter;
  1324. private _animationRatio;
  1325. private _animationTimeLast;
  1326. private _animationTime;
  1327. /**
  1328. * Gets or sets a general scale for animation speed
  1329. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1330. */
  1331. animationTimeScale: number;
  1332. /** @hidden */
  1333. _cachedMaterial: Nullable<Material>;
  1334. /** @hidden */
  1335. _cachedEffect: Nullable<Effect>;
  1336. /** @hidden */
  1337. _cachedVisibility: Nullable<number>;
  1338. private _renderId;
  1339. private _executeWhenReadyTimeoutId;
  1340. private _intermediateRendering;
  1341. private _viewUpdateFlag;
  1342. private _projectionUpdateFlag;
  1343. private _alternateViewUpdateFlag;
  1344. private _alternateProjectionUpdateFlag;
  1345. /** @hidden */
  1346. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1347. private _activeRequests;
  1348. private _pendingData;
  1349. private _isDisposed;
  1350. /**
  1351. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1352. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1353. */
  1354. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1355. private _activeMeshes;
  1356. private _processedMaterials;
  1357. private _renderTargets;
  1358. /** @hidden */
  1359. _activeParticleSystems: SmartArray<IParticleSystem>;
  1360. private _activeSkeletons;
  1361. private _softwareSkinnedMeshes;
  1362. private _renderingManager;
  1363. private _physicsEngine;
  1364. /** @hidden */
  1365. _activeAnimatables: Animatable[];
  1366. private _transformMatrix;
  1367. private _sceneUbo;
  1368. private _alternateSceneUbo;
  1369. private _pickWithRayInverseMatrix;
  1370. private _boundingBoxRenderer;
  1371. private _outlineRenderer;
  1372. private _viewMatrix;
  1373. private _projectionMatrix;
  1374. private _alternateViewMatrix;
  1375. private _alternateProjectionMatrix;
  1376. private _alternateTransformMatrix;
  1377. private _useAlternateCameraConfiguration;
  1378. private _alternateRendering;
  1379. /** @hidden */
  1380. _forcedViewPosition: Nullable<Vector3>;
  1381. /** @hidden */
  1382. readonly _isAlternateRenderingEnabled: boolean;
  1383. private _frustumPlanes;
  1384. /**
  1385. * Gets the list of frustum planes (built from the active camera)
  1386. */
  1387. readonly frustumPlanes: Plane[];
  1388. /**
  1389. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1390. * This is useful if there are more lights that the maximum simulteanous authorized
  1391. */
  1392. requireLightSorting: boolean;
  1393. private _selectionOctree;
  1394. private _pointerOverMesh;
  1395. private _pointerOverSprite;
  1396. private _debugLayer;
  1397. private _depthRenderer;
  1398. private _geometryBufferRenderer;
  1399. /**
  1400. * Gets the current geometry buffer associated to the scene.
  1401. */
  1402. /**
  1403. * Sets the current geometry buffer for the scene.
  1404. */
  1405. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1406. private _pickedDownMesh;
  1407. private _pickedUpMesh;
  1408. private _pickedDownSprite;
  1409. private _externalData;
  1410. private _uid;
  1411. /**
  1412. * Creates a new Scene
  1413. * @param engine defines the engine to use to render this scene
  1414. */
  1415. constructor(engine: Engine);
  1416. /**
  1417. * Gets the debug layer associated with the scene
  1418. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1419. */
  1420. readonly debugLayer: DebugLayer;
  1421. /**
  1422. * Gets a boolean indicating if collisions are processed on a web worker
  1423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1424. */
  1425. workerCollisions: boolean;
  1426. /**
  1427. * Gets the octree used to boost mesh selection (picking)
  1428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1429. */
  1430. readonly selectionOctree: Octree<AbstractMesh>;
  1431. /**
  1432. * Gets the mesh that is currently under the pointer
  1433. */
  1434. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1435. /**
  1436. * Gets the current on-screen X position of the pointer
  1437. */
  1438. readonly pointerX: number;
  1439. /**
  1440. * Gets the current on-screen Y position of the pointer
  1441. */
  1442. readonly pointerY: number;
  1443. /**
  1444. * Gets the cached material (ie. the latest rendered one)
  1445. * @returns the cached material
  1446. */
  1447. getCachedMaterial(): Nullable<Material>;
  1448. /**
  1449. * Gets the cached effect (ie. the latest rendered one)
  1450. * @returns the cached effect
  1451. */
  1452. getCachedEffect(): Nullable<Effect>;
  1453. /**
  1454. * Gets the cached visibility state (ie. the latest rendered one)
  1455. * @returns the cached visibility state
  1456. */
  1457. getCachedVisibility(): Nullable<number>;
  1458. /**
  1459. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1460. * @param material defines the current material
  1461. * @param effect defines the current effect
  1462. * @param visibility defines the current visibility state
  1463. * @returns true if one parameter is not cached
  1464. */
  1465. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1466. /**
  1467. * Gets the bounding box renderer associated with the scene
  1468. * @returns a BoundingBoxRenderer
  1469. */
  1470. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1471. /**
  1472. * Gets the outline renderer associated with the scene
  1473. * @returns a OutlineRenderer
  1474. */
  1475. getOutlineRenderer(): OutlineRenderer;
  1476. /**
  1477. * Gets the engine associated with the scene
  1478. * @returns an Engine
  1479. */
  1480. getEngine(): Engine;
  1481. /**
  1482. * Gets the total number of vertices rendered per frame
  1483. * @returns the total number of vertices rendered per frame
  1484. */
  1485. getTotalVertices(): number;
  1486. /**
  1487. * Gets the performance counter for total vertices
  1488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1489. */
  1490. readonly totalVerticesPerfCounter: PerfCounter;
  1491. /**
  1492. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1493. * @returns the total number of active indices rendered per frame
  1494. */
  1495. getActiveIndices(): number;
  1496. /**
  1497. * Gets the performance counter for active indices
  1498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1499. */
  1500. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1501. /**
  1502. * Gets the total number of active particles rendered per frame
  1503. * @returns the total number of active particles rendered per frame
  1504. */
  1505. getActiveParticles(): number;
  1506. /**
  1507. * Gets the performance counter for active particles
  1508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1509. */
  1510. readonly activeParticlesPerfCounter: PerfCounter;
  1511. /**
  1512. * Gets the total number of active bones rendered per frame
  1513. * @returns the total number of active bones rendered per frame
  1514. */
  1515. getActiveBones(): number;
  1516. /**
  1517. * Gets the performance counter for active bones
  1518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1519. */
  1520. readonly activeBonesPerfCounter: PerfCounter;
  1521. /** @hidden */
  1522. getInterFramePerfCounter(): number;
  1523. /** @hidden */
  1524. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1525. /** @hidden */
  1526. getLastFrameDuration(): number;
  1527. /** @hidden */
  1528. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1529. /** @hidden */
  1530. getEvaluateActiveMeshesDuration(): number;
  1531. /** @hidden */
  1532. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1533. /**
  1534. * Gets the array of active meshes
  1535. * @returns an array of AbstractMesh
  1536. */
  1537. getActiveMeshes(): SmartArray<AbstractMesh>;
  1538. /** @hidden */
  1539. getRenderTargetsDuration(): number;
  1540. /** @hidden */
  1541. getRenderDuration(): number;
  1542. /** @hidden */
  1543. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1544. /** @hidden */
  1545. getParticlesDuration(): number;
  1546. /** @hidden */
  1547. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1548. /** @hidden */
  1549. getSpritesDuration(): number;
  1550. /** @hidden */
  1551. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1552. /**
  1553. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1554. * @returns a number
  1555. */
  1556. getAnimationRatio(): number;
  1557. /**
  1558. * Gets an unique Id for the current frame
  1559. * @returns a number
  1560. */
  1561. getRenderId(): number;
  1562. /** Call this function if you want to manually increment the render Id*/
  1563. incrementRenderId(): void;
  1564. private _updatePointerPosition(evt);
  1565. private _createUbo();
  1566. private _createAlternateUbo();
  1567. /**
  1568. * Use this method to simulate a pointer move on a mesh
  1569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1572. * @returns the current scene
  1573. */
  1574. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1575. private _processPointerMove(pickResult, evt);
  1576. /**
  1577. * Use this method to simulate a pointer down on a mesh
  1578. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1579. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1580. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1581. * @returns the current scene
  1582. */
  1583. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1584. private _processPointerDown(pickResult, evt);
  1585. /**
  1586. * Use this method to simulate a pointer up on a mesh
  1587. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1588. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1589. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1590. * @returns the current scene
  1591. */
  1592. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1593. private _processPointerUp(pickResult, evt, clickInfo);
  1594. /**
  1595. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1596. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1597. * @returns true if the pointer was captured
  1598. */
  1599. isPointerCaptured(pointerId?: number): boolean;
  1600. /**
  1601. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1602. * @param attachUp defines if you want to attach events to pointerup
  1603. * @param attachDown defines if you want to attach events to pointerdown
  1604. * @param attachMove defines if you want to attach events to pointermove
  1605. */
  1606. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1607. /** Detaches all event handlers*/
  1608. detachControl(): void;
  1609. /**
  1610. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1611. * Delay loaded resources are not taking in account
  1612. * @return true if all required resources are ready
  1613. */
  1614. isReady(): boolean;
  1615. /** Resets all cached information relative to material (including effect and visibility) */
  1616. resetCachedMaterial(): void;
  1617. /**
  1618. * Registers a function to be called before every frame render
  1619. * @param func defines the function to register
  1620. */
  1621. registerBeforeRender(func: () => void): void;
  1622. /**
  1623. * Unregisters a function called before every frame render
  1624. * @param func defines the function to unregister
  1625. */
  1626. unregisterBeforeRender(func: () => void): void;
  1627. /**
  1628. * Registers a function to be called after every frame render
  1629. * @param func defines the function to register
  1630. */
  1631. registerAfterRender(func: () => void): void;
  1632. /**
  1633. * Unregisters a function called after every frame render
  1634. * @param func defines the function to unregister
  1635. */
  1636. unregisterAfterRender(func: () => void): void;
  1637. private _executeOnceBeforeRender(func);
  1638. /**
  1639. * The provided function will run before render once and will be disposed afterwards.
  1640. * A timeout delay can be provided so that the function will be executed in N ms.
  1641. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1642. * @param func The function to be executed.
  1643. * @param timeout optional delay in ms
  1644. */
  1645. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1646. /** @hidden */
  1647. _addPendingData(data: any): void;
  1648. /** @hidden */
  1649. _removePendingData(data: any): void;
  1650. /**
  1651. * Returns the number of items waiting to be loaded
  1652. * @returns the number of items waiting to be loaded
  1653. */
  1654. getWaitingItemsCount(): number;
  1655. /**
  1656. * Returns a boolean indicating if the scene is still loading data
  1657. */
  1658. readonly isLoading: boolean;
  1659. /**
  1660. * Registers a function to be executed when the scene is ready
  1661. * @param {Function} func - the function to be executed
  1662. */
  1663. executeWhenReady(func: () => void): void;
  1664. /**
  1665. * Returns a promise that resolves when the scene is ready
  1666. * @returns A promise that resolves when the scene is ready
  1667. */
  1668. whenReadyAsync(): Promise<void>;
  1669. /** @hidden */
  1670. _checkIsReady(): void;
  1671. /**
  1672. * Will start the animation sequence of a given target
  1673. * @param target defines the target
  1674. * @param from defines from which frame should animation start
  1675. * @param to defines until which frame should animation run.
  1676. * @param weight defines the weight to apply to the animation (1.0 by default)
  1677. * @param loop defines if the animation loops
  1678. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1679. * @param onAnimationEnd defines the function to be executed when the animation ends
  1680. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1681. * @returns the animatable object created for this animation
  1682. */
  1683. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1684. /**
  1685. * Will start the animation sequence of a given target
  1686. * @param target defines the target
  1687. * @param from defines from which frame should animation start
  1688. * @param to defines until which frame should animation run.
  1689. * @param loop defines if the animation loops
  1690. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1691. * @param onAnimationEnd defines the function to be executed when the animation ends
  1692. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1693. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1694. * @returns the animatable object created for this animation
  1695. */
  1696. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1697. /**
  1698. * Begin a new animation on a given node
  1699. * @param target defines the target where the animation will take place
  1700. * @param animations defines the list of animations to start
  1701. * @param from defines the initial value
  1702. * @param to defines the final value
  1703. * @param loop defines if you want animation to loop (off by default)
  1704. * @param speedRatio defines the speed ratio to apply to all animations
  1705. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1706. * @returns the list of created animatables
  1707. */
  1708. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1709. /**
  1710. * Begin a new animation on a given node and its hierarchy
  1711. * @param target defines the root node where the animation will take place
  1712. * @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.
  1713. * @param animations defines the list of animations to start
  1714. * @param from defines the initial value
  1715. * @param to defines the final value
  1716. * @param loop defines if you want animation to loop (off by default)
  1717. * @param speedRatio defines the speed ratio to apply to all animations
  1718. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1719. * @returns the list of animatables created for all nodes
  1720. */
  1721. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1722. /**
  1723. * Gets the animatable associated with a specific target
  1724. * @param target defines the target of the animatable
  1725. * @returns the required animatable if found
  1726. */
  1727. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1728. /**
  1729. * Gets all animatables associated with a given target
  1730. * @param target defines the target to look animatables for
  1731. * @returns an array of Animatables
  1732. */
  1733. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1734. /**
  1735. * Gets all animatable attached to the scene
  1736. */
  1737. readonly animatables: Animatable[];
  1738. /**
  1739. * Will stop the animation of the given target
  1740. * @param target - the target
  1741. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1742. */
  1743. stopAnimation(target: any, animationName?: string): void;
  1744. /**
  1745. * Stops and removes all animations that have been applied to the scene
  1746. */
  1747. stopAllAnimations(): void;
  1748. private _animate();
  1749. /** @hidden */
  1750. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1751. private _processLateAnimationBindingsForMatrices(holder);
  1752. private _processLateAnimationBindingsForQuaternions(holder);
  1753. private _processLateAnimationBindings();
  1754. /** @hidden */
  1755. _switchToAlternateCameraConfiguration(active: boolean): void;
  1756. /**
  1757. * Gets the current view matrix
  1758. * @returns a Matrix
  1759. */
  1760. getViewMatrix(): Matrix;
  1761. /**
  1762. * Gets the current projection matrix
  1763. * @returns a Matrix
  1764. */
  1765. getProjectionMatrix(): Matrix;
  1766. /**
  1767. * Gets the current transform matrix
  1768. * @returns a Matrix made of View * Projection
  1769. */
  1770. getTransformMatrix(): Matrix;
  1771. /**
  1772. * Sets the current transform matrix
  1773. * @param view defines the View matrix to use
  1774. * @param projection defines the Projection matrix to use
  1775. */
  1776. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1777. /** @hidden */
  1778. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1779. /**
  1780. * Gets the uniform buffer used to store scene data
  1781. * @returns a UniformBuffer
  1782. */
  1783. getSceneUniformBuffer(): UniformBuffer;
  1784. /**
  1785. * Gets an unique (relatively to the current scene) Id
  1786. * @returns an unique number for the scene
  1787. */
  1788. getUniqueId(): number;
  1789. /**
  1790. * Add a mesh to the list of scene's meshes
  1791. * @param newMesh defines the mesh to add
  1792. * @param recursive if all child meshes should also be added to the scene
  1793. */
  1794. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1795. /**
  1796. * Remove a mesh for the list of scene's meshes
  1797. * @param toRemove defines the mesh to remove
  1798. * @param recursive if all child meshes should also be removed from the scene
  1799. * @returns the index where the mesh was in the mesh list
  1800. */
  1801. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1802. /**
  1803. * Add a transform node to the list of scene's transform nodes
  1804. * @param newTransformNode defines the transform node to add
  1805. */
  1806. addTransformNode(newTransformNode: TransformNode): void;
  1807. /**
  1808. * Remove a transform node for the list of scene's transform nodes
  1809. * @param toRemove defines the transform node to remove
  1810. * @returns the index where the transform node was in the transform node list
  1811. */
  1812. removeTransformNode(toRemove: TransformNode): number;
  1813. /**
  1814. * Remove a skeleton for the list of scene's skeletons
  1815. * @param toRemove defines the skeleton to remove
  1816. * @returns the index where the skeleton was in the skeleton list
  1817. */
  1818. removeSkeleton(toRemove: Skeleton): number;
  1819. /**
  1820. * Remove a morph target for the list of scene's morph targets
  1821. * @param toRemove defines the morph target to remove
  1822. * @returns the index where the morph target was in the morph target list
  1823. */
  1824. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1825. /**
  1826. * Remove a light for the list of scene's lights
  1827. * @param toRemove defines the light to remove
  1828. * @returns the index where the light was in the light list
  1829. */
  1830. removeLight(toRemove: Light): number;
  1831. /**
  1832. * Remove a camera for the list of scene's cameras
  1833. * @param toRemove defines the camera to remove
  1834. * @returns the index where the camera was in the camera list
  1835. */
  1836. removeCamera(toRemove: Camera): number;
  1837. /**
  1838. * Remove a particle system for the list of scene's particle systems
  1839. * @param toRemove defines the particle system to remove
  1840. * @returns the index where the particle system was in the particle system list
  1841. */
  1842. removeParticleSystem(toRemove: IParticleSystem): number;
  1843. /**
  1844. * Remove a animation for the list of scene's animations
  1845. * @param toRemove defines the animation to remove
  1846. * @returns the index where the animation was in the animation list
  1847. */
  1848. removeAnimation(toRemove: Animation): number;
  1849. /**
  1850. * Removes the given animation group from this scene.
  1851. * @param toRemove The animation group to remove
  1852. * @returns The index of the removed animation group
  1853. */
  1854. removeAnimationGroup(toRemove: AnimationGroup): number;
  1855. /**
  1856. * Removes the given multi-material from this scene.
  1857. * @param toRemove The multi-material to remove
  1858. * @returns The index of the removed multi-material
  1859. */
  1860. removeMultiMaterial(toRemove: MultiMaterial): number;
  1861. /**
  1862. * Removes the given material from this scene.
  1863. * @param toRemove The material to remove
  1864. * @returns The index of the removed material
  1865. */
  1866. removeMaterial(toRemove: Material): number;
  1867. /**
  1868. * Removes the given lens flare system from this scene.
  1869. * @param toRemove The lens flare system to remove
  1870. * @returns The index of the removed lens flare system
  1871. */
  1872. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1873. /**
  1874. * Removes the given action manager from this scene.
  1875. * @param toRemove The action manager to remove
  1876. * @returns The index of the removed action manager
  1877. */
  1878. removeActionManager(toRemove: ActionManager): number;
  1879. /**
  1880. * Removes the given effect layer from this scene.
  1881. * @param toRemove defines the effect layer to remove
  1882. * @returns the index of the removed effect layer
  1883. */
  1884. removeEffectLayer(toRemove: EffectLayer): number;
  1885. /**
  1886. * Removes the given texture from this scene.
  1887. * @param toRemove The texture to remove
  1888. * @returns The index of the removed texture
  1889. */
  1890. removeTexture(toRemove: BaseTexture): number;
  1891. /**
  1892. * Adds the given light to this scene
  1893. * @param newLight The light to add
  1894. */
  1895. addLight(newLight: Light): void;
  1896. /**
  1897. * Sorts the list list based on light priorities
  1898. */
  1899. sortLightsByPriority(): void;
  1900. /**
  1901. * Adds the given camera to this scene
  1902. * @param newCamera The camera to add
  1903. */
  1904. addCamera(newCamera: Camera): void;
  1905. /**
  1906. * Adds the given skeleton to this scene
  1907. * @param newSkeleton The skeleton to add
  1908. */
  1909. addSkeleton(newSkeleton: Skeleton): void;
  1910. /**
  1911. * Adds the given particle system to this scene
  1912. * @param newParticleSystem The particle system to add
  1913. */
  1914. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1915. /**
  1916. * Adds the given animation to this scene
  1917. * @param newAnimation The animation to add
  1918. */
  1919. addAnimation(newAnimation: Animation): void;
  1920. /**
  1921. * Adds the given animation group to this scene.
  1922. * @param newAnimationGroup The animation group to add
  1923. */
  1924. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1925. /**
  1926. * Adds the given multi-material to this scene
  1927. * @param newMultiMaterial The multi-material to add
  1928. */
  1929. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1930. /**
  1931. * Adds the given material to this scene
  1932. * @param newMaterial The material to add
  1933. */
  1934. addMaterial(newMaterial: Material): void;
  1935. /**
  1936. * Adds the given morph target to this scene
  1937. * @param newMorphTargetManager The morph target to add
  1938. */
  1939. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1940. /**
  1941. * Adds the given geometry to this scene
  1942. * @param newGeometry The geometry to add
  1943. */
  1944. addGeometry(newGeometry: Geometry): void;
  1945. /**
  1946. * Adds the given lens flare system to this scene
  1947. * @param newLensFlareSystem The lens flare system to add
  1948. */
  1949. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1950. /**
  1951. * Adds the given effect layer to this scene
  1952. * @param newEffectLayer defines the effect layer to add
  1953. */
  1954. addEffectLayer(newEffectLayer: EffectLayer): void;
  1955. /**
  1956. * Adds the given action manager to this scene
  1957. * @param newActionManager The action manager to add
  1958. */
  1959. addActionManager(newActionManager: ActionManager): void;
  1960. /**
  1961. * Adds the given texture to this scene.
  1962. * @param newTexture The texture to add
  1963. */
  1964. addTexture(newTexture: BaseTexture): void;
  1965. /**
  1966. * Switch active camera
  1967. * @param newCamera defines the new active camera
  1968. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1969. */
  1970. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1971. /**
  1972. * sets the active camera of the scene using its ID
  1973. * @param id defines the camera's ID
  1974. * @return the new active camera or null if none found.
  1975. */
  1976. setActiveCameraByID(id: string): Nullable<Camera>;
  1977. /**
  1978. * sets the active camera of the scene using its name
  1979. * @param name defines the camera's name
  1980. * @returns the new active camera or null if none found.
  1981. */
  1982. setActiveCameraByName(name: string): Nullable<Camera>;
  1983. /**
  1984. * get an animation group using its name
  1985. * @param name defines the material's name
  1986. * @return the animation group or null if none found.
  1987. */
  1988. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1989. /**
  1990. * get a material using its id
  1991. * @param id defines the material's ID
  1992. * @return the material or null if none found.
  1993. */
  1994. getMaterialByID(id: string): Nullable<Material>;
  1995. /**
  1996. * Gets a material using its name
  1997. * @param name defines the material's name
  1998. * @return the material or null if none found.
  1999. */
  2000. getMaterialByName(name: string): Nullable<Material>;
  2001. /**
  2002. * Gets a lens flare system using its name
  2003. * @param name defines the name to look for
  2004. * @returns the lens flare system or null if not found
  2005. */
  2006. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2007. /**
  2008. * Gets a lens flare system using its id
  2009. * @param id defines the id to look for
  2010. * @returns the lens flare system or null if not found
  2011. */
  2012. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2013. /**
  2014. * Gets a camera using its id
  2015. * @param id defines the id to look for
  2016. * @returns the camera or null if not found
  2017. */
  2018. getCameraByID(id: string): Nullable<Camera>;
  2019. /**
  2020. * Gets a camera using its unique id
  2021. * @param uniqueId defines the unique id to look for
  2022. * @returns the camera or null if not found
  2023. */
  2024. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2025. /**
  2026. * Gets a camera using its name
  2027. * @param name defines the camera's name
  2028. * @return the camera or null if none found.
  2029. */
  2030. getCameraByName(name: string): Nullable<Camera>;
  2031. /**
  2032. * Gets a bone using its id
  2033. * @param id defines the bone's id
  2034. * @return the bone or null if not found
  2035. */
  2036. getBoneByID(id: string): Nullable<Bone>;
  2037. /**
  2038. * Gets a bone using its id
  2039. * @param name defines the bone's name
  2040. * @return the bone or null if not found
  2041. */
  2042. getBoneByName(name: string): Nullable<Bone>;
  2043. /**
  2044. * Gets a light node using its name
  2045. * @param name defines the the light's name
  2046. * @return the light or null if none found.
  2047. */
  2048. getLightByName(name: string): Nullable<Light>;
  2049. /**
  2050. * Gets a light node using its id
  2051. * @param id defines the light's id
  2052. * @return the light or null if none found.
  2053. */
  2054. getLightByID(id: string): Nullable<Light>;
  2055. /**
  2056. * Gets a light node using its scene-generated unique ID
  2057. * @param uniqueId defines the light's unique id
  2058. * @return the light or null if none found.
  2059. */
  2060. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2061. /**
  2062. * Gets a particle system by id
  2063. * @param id defines the particle system id
  2064. * @return the corresponding system or null if none found
  2065. */
  2066. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2067. /**
  2068. * Gets a geometry using its ID
  2069. * @param id defines the geometry's id
  2070. * @return the geometry or null if none found.
  2071. */
  2072. getGeometryByID(id: string): Nullable<Geometry>;
  2073. /**
  2074. * Add a new geometry to this scene
  2075. * @param geometry defines the geometry to be added to the scene.
  2076. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2077. * @return a boolean defining if the geometry was added or not
  2078. */
  2079. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2080. /**
  2081. * Removes an existing geometry
  2082. * @param geometry defines the geometry to be removed from the scene
  2083. * @return a boolean defining if the geometry was removed or not
  2084. */
  2085. removeGeometry(geometry: Geometry): boolean;
  2086. /**
  2087. * Gets the list of geometries attached to the scene
  2088. * @returns an array of Geometry
  2089. */
  2090. getGeometries(): Geometry[];
  2091. /**
  2092. * Gets the first added mesh found of a given ID
  2093. * @param id defines the id to search for
  2094. * @return the mesh found or null if not found at all
  2095. */
  2096. getMeshByID(id: string): Nullable<AbstractMesh>;
  2097. /**
  2098. * Gets a list of meshes using their id
  2099. * @param id defines the id to search for
  2100. * @returns a list of meshes
  2101. */
  2102. getMeshesByID(id: string): Array<AbstractMesh>;
  2103. /**
  2104. * Gets the first added transform node found of a given ID
  2105. * @param id defines the id to search for
  2106. * @return the found transform node or null if not found at all.
  2107. */
  2108. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2109. /**
  2110. * Gets a list of transform nodes using their id
  2111. * @param id defines the id to search for
  2112. * @returns a list of transform nodes
  2113. */
  2114. getTransformNodesByID(id: string): Array<TransformNode>;
  2115. /**
  2116. * Gets a mesh with its auto-generated unique id
  2117. * @param uniqueId defines the unique id to search for
  2118. * @return the found mesh or null if not found at all.
  2119. */
  2120. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2121. /**
  2122. * Gets a the last added mesh using a given id
  2123. * @param id defines the id to search for
  2124. * @return the found mesh or null if not found at all.
  2125. */
  2126. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2127. /**
  2128. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2129. * @param id defines the id to search for
  2130. * @return the found node or null if not found at all
  2131. */
  2132. getLastEntryByID(id: string): Nullable<Node>;
  2133. /**
  2134. * Gets a node (Mesh, Camera, Light) using a given id
  2135. * @param id defines the id to search for
  2136. * @return the found node or null if not found at all
  2137. */
  2138. getNodeByID(id: string): Nullable<Node>;
  2139. /**
  2140. * Gets a node (Mesh, Camera, Light) using a given name
  2141. * @param name defines the name to search for
  2142. * @return the found node or null if not found at all.
  2143. */
  2144. getNodeByName(name: string): Nullable<Node>;
  2145. /**
  2146. * Gets a mesh using a given name
  2147. * @param name defines the name to search for
  2148. * @return the found mesh or null if not found at all.
  2149. */
  2150. getMeshByName(name: string): Nullable<AbstractMesh>;
  2151. /**
  2152. * Gets a transform node using a given name
  2153. * @param name defines the name to search for
  2154. * @return the found transform node or null if not found at all.
  2155. */
  2156. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2157. /**
  2158. * Gets a sound using a given name
  2159. * @param name defines the name to search for
  2160. * @return the found sound or null if not found at all.
  2161. */
  2162. getSoundByName(name: string): Nullable<Sound>;
  2163. /**
  2164. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2165. * @param id defines the id to search for
  2166. * @return the found skeleton or null if not found at all.
  2167. */
  2168. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2169. /**
  2170. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2171. * @param id defines the id to search for
  2172. * @return the found skeleton or null if not found at all.
  2173. */
  2174. getSkeletonById(id: string): Nullable<Skeleton>;
  2175. /**
  2176. * Gets a skeleton using a given name
  2177. * @param name defines the name to search for
  2178. * @return the found skeleton or null if not found at all.
  2179. */
  2180. getSkeletonByName(name: string): Nullable<Skeleton>;
  2181. /**
  2182. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2183. * @param id defines the id to search for
  2184. * @return the found morph target manager or null if not found at all.
  2185. */
  2186. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2187. /**
  2188. * Gets a boolean indicating if the given mesh is active
  2189. * @param mesh defines the mesh to look for
  2190. * @returns true if the mesh is in the active list
  2191. */
  2192. isActiveMesh(mesh: AbstractMesh): boolean;
  2193. /**
  2194. * Return a the first highlight layer of the scene with a given name.
  2195. * @param name The name of the highlight layer to look for.
  2196. * @return The highlight layer if found otherwise null.
  2197. */
  2198. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2199. /**
  2200. * Return a the first highlight layer of the scene with a given name.
  2201. * @param name The name of the highlight layer to look for.
  2202. * @return The highlight layer if found otherwise null.
  2203. */
  2204. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2205. /**
  2206. * Return a unique id as a string which can serve as an identifier for the scene
  2207. */
  2208. readonly uid: string;
  2209. /**
  2210. * Add an externaly attached data from its key.
  2211. * This method call will fail and return false, if such key already exists.
  2212. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2213. * @param key the unique key that identifies the data
  2214. * @param data the data object to associate to the key for this Engine instance
  2215. * @return true if no such key were already present and the data was added successfully, false otherwise
  2216. */
  2217. addExternalData<T>(key: string, data: T): boolean;
  2218. /**
  2219. * Get an externaly attached data from its key
  2220. * @param key the unique key that identifies the data
  2221. * @return the associated data, if present (can be null), or undefined if not present
  2222. */
  2223. getExternalData<T>(key: string): Nullable<T>;
  2224. /**
  2225. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2226. * @param key the unique key that identifies the data
  2227. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2228. * @return the associated data, can be null if the factory returned null.
  2229. */
  2230. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2231. /**
  2232. * Remove an externaly attached data from the Engine instance
  2233. * @param key the unique key that identifies the data
  2234. * @return true if the data was successfully removed, false if it doesn't exist
  2235. */
  2236. removeExternalData(key: string): boolean;
  2237. private _evaluateSubMesh(subMesh, mesh);
  2238. /**
  2239. * Clear the processed materials smart array preventing retention point in material dispose.
  2240. */
  2241. freeProcessedMaterials(): void;
  2242. /**
  2243. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2244. */
  2245. freeActiveMeshes(): void;
  2246. /**
  2247. * Clear the info related to rendering groups preventing retention points during dispose.
  2248. */
  2249. freeRenderingGroups(): void;
  2250. /** @hidden */
  2251. _isInIntermediateRendering(): boolean;
  2252. private _activeMeshCandidateProvider;
  2253. /**
  2254. * Defines the current active mesh candidate provider
  2255. * @param provider defines the provider to use
  2256. */
  2257. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2258. /**
  2259. * Gets the current active mesh candidate provider
  2260. * @returns the current active mesh candidate provider
  2261. */
  2262. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2263. private _activeMeshesFrozen;
  2264. /**
  2265. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2266. * @returns the current scene
  2267. */
  2268. freezeActiveMeshes(): Scene;
  2269. /**
  2270. * Use this function to restart evaluating active meshes on every frame
  2271. * @returns the current scene
  2272. */
  2273. unfreezeActiveMeshes(): Scene;
  2274. private _evaluateActiveMeshes();
  2275. private _activeMesh(sourceMesh, mesh);
  2276. /**
  2277. * Update the transform matrix to update from the current active camera
  2278. * @param force defines a boolean used to force the update even if cache is up to date
  2279. */
  2280. updateTransformMatrix(force?: boolean): void;
  2281. /**
  2282. * 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)
  2283. * @param alternateCamera defines the camera to use
  2284. */
  2285. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2286. private _renderForCamera(camera, rigParent?);
  2287. private _processSubCameras(camera);
  2288. private _checkIntersections();
  2289. /**
  2290. * Render the scene
  2291. */
  2292. render(): void;
  2293. private _updateAudioParameters();
  2294. /**
  2295. * Gets or sets if audio support is enabled
  2296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2297. */
  2298. audioEnabled: boolean;
  2299. private _disableAudio();
  2300. private _enableAudio();
  2301. /**
  2302. * Gets or sets if audio will be output to headphones
  2303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2304. */
  2305. headphone: boolean;
  2306. private _switchAudioModeForHeadphones();
  2307. private _switchAudioModeForNormalSpeakers();
  2308. /**
  2309. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2310. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2311. * @returns the created depth renderer
  2312. */
  2313. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2314. /**
  2315. * Disables a depth renderer for a given camera
  2316. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2317. */
  2318. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2319. /**
  2320. * Enables a GeometryBufferRender and associates it with the scene
  2321. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2322. * @returns the GeometryBufferRenderer
  2323. */
  2324. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2325. /**
  2326. * Disables the GeometryBufferRender associated with the scene
  2327. */
  2328. disableGeometryBufferRenderer(): void;
  2329. /**
  2330. * Freeze all materials
  2331. * A frozen material will not be updatable but should be faster to render
  2332. */
  2333. freezeMaterials(): void;
  2334. /**
  2335. * Unfreeze all materials
  2336. * A frozen material will not be updatable but should be faster to render
  2337. */
  2338. unfreezeMaterials(): void;
  2339. /**
  2340. * Releases all held ressources
  2341. */
  2342. dispose(): void;
  2343. /**
  2344. * Gets if the scene is already disposed
  2345. */
  2346. readonly isDisposed: boolean;
  2347. /**
  2348. * Releases sounds & soundtracks
  2349. */
  2350. disposeSounds(): void;
  2351. /**
  2352. * Get the world extend vectors with an optional filter
  2353. *
  2354. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2355. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2356. */
  2357. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2358. min: Vector3;
  2359. max: Vector3;
  2360. };
  2361. /**
  2362. * Creates or updates the octree used to boost selection (picking)
  2363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2364. * @param maxCapacity defines the maximum capacity per leaf
  2365. * @param maxDepth defines the maximum depth of the octree
  2366. * @returns an octree of AbstractMesh
  2367. */
  2368. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2369. /**
  2370. * Creates a ray that can be used to pick in the scene
  2371. * @param x defines the x coordinate of the origin (on-screen)
  2372. * @param y defines the y coordinate of the origin (on-screen)
  2373. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2374. * @param camera defines the camera to use for the picking
  2375. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2376. * @returns a Ray
  2377. */
  2378. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2379. /**
  2380. * Creates a ray that can be used to pick in the scene
  2381. * @param x defines the x coordinate of the origin (on-screen)
  2382. * @param y defines the y coordinate of the origin (on-screen)
  2383. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2384. * @param result defines the ray where to store the picking ray
  2385. * @param camera defines the camera to use for the picking
  2386. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2387. * @returns the current scene
  2388. */
  2389. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2390. /**
  2391. * Creates a ray that can be used to pick in the scene
  2392. * @param x defines the x coordinate of the origin (on-screen)
  2393. * @param y defines the y coordinate of the origin (on-screen)
  2394. * @param camera defines the camera to use for the picking
  2395. * @returns a Ray
  2396. */
  2397. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): 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 result defines the ray where to store the picking ray
  2403. * @param camera defines the camera to use for the picking
  2404. * @returns the current scene
  2405. */
  2406. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2407. private _internalPick(rayFunction, predicate?, fastCheck?);
  2408. private _internalMultiPick(rayFunction, predicate?);
  2409. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2410. private _tempPickingRay;
  2411. /** Launch a ray to try to pick a mesh in the scene
  2412. * @param x position on screen
  2413. * @param y position on screen
  2414. * @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
  2415. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2416. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2417. * @returns a PickingInfo
  2418. */
  2419. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2420. /** Launch a ray to try to pick a sprite in the scene
  2421. * @param x position on screen
  2422. * @param y position on screen
  2423. * @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
  2424. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2425. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2426. * @returns a PickingInfo
  2427. */
  2428. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2429. private _cachedRayForTransform;
  2430. /** Use the given ray to pick a mesh in the scene
  2431. * @param ray The ray to use to pick meshes
  2432. * @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
  2433. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2434. * @returns a PickingInfo
  2435. */
  2436. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2437. /**
  2438. * Launch a ray to try to pick a mesh in the scene
  2439. * @param x X position on screen
  2440. * @param y Y position on screen
  2441. * @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
  2442. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2443. * @returns an array of PickingInfo
  2444. */
  2445. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2446. /**
  2447. * Launch a ray to try to pick a mesh in the scene
  2448. * @param ray Ray to use
  2449. * @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
  2450. * @returns an array of PickingInfo
  2451. */
  2452. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2453. /**
  2454. * Force the value of meshUnderPointer
  2455. * @param mesh defines the mesh to use
  2456. */
  2457. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2458. /**
  2459. * Gets the mesh under the pointer
  2460. * @returns a Mesh or null if no mesh is under the pointer
  2461. */
  2462. getPointerOverMesh(): Nullable<AbstractMesh>;
  2463. /**
  2464. * Force the sprite under the pointer
  2465. * @param sprite defines the sprite to use
  2466. */
  2467. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2468. /**
  2469. * Gets the sprite under the pointer
  2470. * @returns a Sprite or null if no sprite is under the pointer
  2471. */
  2472. getPointerOverSprite(): Nullable<Sprite>;
  2473. /**
  2474. * Gets the current physics engine
  2475. * @returns a PhysicsEngine or null if none attached
  2476. */
  2477. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2478. /**
  2479. * Enables physics to the current scene
  2480. * @param gravity defines the scene's gravity for the physics engine
  2481. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2482. * @return a boolean indicating if the physics engine was initialized
  2483. */
  2484. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2485. /**
  2486. * Disables and disposes the physics engine associated with the scene
  2487. */
  2488. disablePhysicsEngine(): void;
  2489. /**
  2490. * Gets a boolean indicating if there is an active physics engine
  2491. * @returns a boolean indicating if there is an active physics engine
  2492. */
  2493. isPhysicsEnabled(): boolean;
  2494. /**
  2495. * Deletes a physics compound impostor
  2496. * @param compound defines the compound to delete
  2497. */
  2498. deleteCompoundImpostor(compound: any): void;
  2499. /** @hidden */
  2500. _rebuildGeometries(): void;
  2501. /** @hidden */
  2502. _rebuildTextures(): void;
  2503. /**
  2504. * Creates a default light for the scene.
  2505. * @param replace Whether to replace the existing lights in the scene.
  2506. */
  2507. createDefaultLight(replace?: boolean): void;
  2508. /**
  2509. * Creates a default camera for the scene.
  2510. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2511. * @param replace Whether to replace the existing active camera in the scene.
  2512. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2513. */
  2514. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2515. /**
  2516. * Creates a default camera and a default light
  2517. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2518. * @param replace defines if the camera and/or light will replace the existing ones
  2519. * @param attachCameraControls defines if attachControl will be called on the new camera
  2520. */
  2521. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2522. /**
  2523. * Creates a new sky box
  2524. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2525. * @param environmentTexture defines the texture to use as environment texture
  2526. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2527. * @param scale defines the overall scale of the skybox
  2528. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2529. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2530. * @returns a new mesh holding the sky box
  2531. */
  2532. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2533. /**
  2534. * Creates a new environment
  2535. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2536. * @param options defines the options you can use to configure the environment
  2537. * @returns the new EnvironmentHelper
  2538. */
  2539. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2540. /**
  2541. * Creates a new VREXperienceHelper
  2542. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2543. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2544. * @returns a new VREXperienceHelper
  2545. */
  2546. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2547. private _getByTags(list, tagsQuery, forEach?);
  2548. /**
  2549. * Get a list of meshes by tags
  2550. * @param tagsQuery defines the tags query to use
  2551. * @param forEach defines a predicate used to filter results
  2552. * @returns an array of Mesh
  2553. */
  2554. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2555. /**
  2556. * Get a list of cameras by tags
  2557. * @param tagsQuery defines the tags query to use
  2558. * @param forEach defines a predicate used to filter results
  2559. * @returns an array of Camera
  2560. */
  2561. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2562. /**
  2563. * Get a list of lights by tags
  2564. * @param tagsQuery defines the tags query to use
  2565. * @param forEach defines a predicate used to filter results
  2566. * @returns an array of Light
  2567. */
  2568. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2569. /**
  2570. * Get a list of materials by tags
  2571. * @param tagsQuery defines the tags query to use
  2572. * @param forEach defines a predicate used to filter results
  2573. * @returns an array of Material
  2574. */
  2575. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2576. /**
  2577. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2578. * This allowed control for front to back rendering or reversly depending of the special needs.
  2579. *
  2580. * @param renderingGroupId The rendering group id corresponding to its index
  2581. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2582. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2583. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2584. */
  2585. 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;
  2586. /**
  2587. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2588. *
  2589. * @param renderingGroupId The rendering group id corresponding to its index
  2590. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2591. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2592. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2593. */
  2594. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2595. /**
  2596. * Will flag all materials as dirty to trigger new shader compilation
  2597. * @param flag defines the flag used to specify which material part must be marked as dirty
  2598. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2599. */
  2600. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2601. /** @hidden */
  2602. _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;
  2603. /** @hidden */
  2604. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2605. }
  2606. }
  2607. declare module BABYLON {
  2608. type Nullable<T> = T | null;
  2609. type float = number;
  2610. type double = number;
  2611. type int = number;
  2612. type FloatArray = number[] | Float32Array;
  2613. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2614. /**
  2615. * Alias for types that can be used by a Buffer or VertexBuffer.
  2616. */
  2617. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2618. }
  2619. declare module BABYLON {
  2620. /**
  2621. * The action to be carried out following a trigger
  2622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2623. */
  2624. class Action {
  2625. /** the trigger, with or without parameters, for the action */
  2626. triggerOptions: any;
  2627. /**
  2628. * Trigger for the action
  2629. */
  2630. trigger: number;
  2631. /**
  2632. * Internal only - manager for action
  2633. * @hidden
  2634. */
  2635. _actionManager: ActionManager;
  2636. private _nextActiveAction;
  2637. private _child;
  2638. private _condition?;
  2639. private _triggerParameter;
  2640. /**
  2641. * An event triggered prior to action being executed.
  2642. */
  2643. onBeforeExecuteObservable: Observable<Action>;
  2644. /**
  2645. * Creates a new Action
  2646. * @param triggerOptions the trigger, with or without parameters, for the action
  2647. * @param condition an optional determinant of action
  2648. */
  2649. constructor(
  2650. /** the trigger, with or without parameters, for the action */
  2651. triggerOptions: any, condition?: Condition);
  2652. /**
  2653. * Internal only
  2654. * @hidden
  2655. */
  2656. _prepare(): void;
  2657. /**
  2658. * Gets the trigger parameters
  2659. * @returns the trigger parameters
  2660. */
  2661. getTriggerParameter(): any;
  2662. /**
  2663. * Internal only - executes current action event
  2664. * @hidden
  2665. */
  2666. _executeCurrent(evt?: ActionEvent): void;
  2667. /**
  2668. * Execute placeholder for child classes
  2669. * @param evt optional action event
  2670. */
  2671. execute(evt?: ActionEvent): void;
  2672. /**
  2673. * Skips to next active action
  2674. */
  2675. skipToNextActiveAction(): void;
  2676. /**
  2677. * Adds action to chain of actions, may be a DoNothingAction
  2678. * @param action defines the next action to execute
  2679. * @returns The action passed in
  2680. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2681. */
  2682. then(action: Action): Action;
  2683. /**
  2684. * Internal only
  2685. * @hidden
  2686. */
  2687. _getProperty(propertyPath: string): string;
  2688. /**
  2689. * Internal only
  2690. * @hidden
  2691. */
  2692. _getEffectiveTarget(target: any, propertyPath: string): any;
  2693. /**
  2694. * Serialize placeholder for child classes
  2695. * @param parent of child
  2696. * @returns the serialized object
  2697. */
  2698. serialize(parent: any): any;
  2699. /**
  2700. * Internal only called by serialize
  2701. * @hidden
  2702. */
  2703. protected _serialize(serializedAction: any, parent?: any): any;
  2704. /**
  2705. * Internal only
  2706. * @hidden
  2707. */
  2708. static _SerializeValueAsString: (value: any) => string;
  2709. /**
  2710. * Internal only
  2711. * @hidden
  2712. */
  2713. static _GetTargetProperty: (target: Scene | Node) => {
  2714. name: string;
  2715. targetType: string;
  2716. value: string;
  2717. };
  2718. }
  2719. }
  2720. declare module BABYLON {
  2721. /**
  2722. * ActionEvent is the event being sent when an action is triggered.
  2723. */
  2724. class ActionEvent {
  2725. /** The mesh or sprite that triggered the action */
  2726. source: any;
  2727. /** The X mouse cursor position at the time of the event */
  2728. pointerX: number;
  2729. /** The Y mouse cursor position at the time of the event */
  2730. pointerY: number;
  2731. /** The mesh that is currently pointed at (can be null) */
  2732. meshUnderPointer: Nullable<AbstractMesh>;
  2733. /** the original (browser) event that triggered the ActionEvent */
  2734. sourceEvent: any;
  2735. /** additional data for the event */
  2736. additionalData: any;
  2737. /**
  2738. * Creates a new ActionEvent
  2739. * @param source The mesh or sprite that triggered the action
  2740. * @param pointerX The X mouse cursor position at the time of the event
  2741. * @param pointerY The Y mouse cursor position at the time of the event
  2742. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2743. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2744. * @param additionalData additional data for the event
  2745. */
  2746. constructor(
  2747. /** The mesh or sprite that triggered the action */
  2748. source: any,
  2749. /** The X mouse cursor position at the time of the event */
  2750. pointerX: number,
  2751. /** The Y mouse cursor position at the time of the event */
  2752. pointerY: number,
  2753. /** The mesh that is currently pointed at (can be null) */
  2754. meshUnderPointer: Nullable<AbstractMesh>,
  2755. /** the original (browser) event that triggered the ActionEvent */
  2756. sourceEvent?: any,
  2757. /** additional data for the event */
  2758. additionalData?: any);
  2759. /**
  2760. * Helper function to auto-create an ActionEvent from a source mesh.
  2761. * @param source The source mesh that triggered the event
  2762. * @param evt The original (browser) event
  2763. * @param additionalData additional data for the event
  2764. * @returns the new ActionEvent
  2765. */
  2766. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2767. /**
  2768. * Helper function to auto-create an ActionEvent from a source sprite
  2769. * @param source The source sprite that triggered the event
  2770. * @param scene Scene associated with the sprite
  2771. * @param evt The original (browser) event
  2772. * @param additionalData additional data for the event
  2773. * @returns the new ActionEvent
  2774. */
  2775. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2776. /**
  2777. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2778. * @param scene the scene where the event occurred
  2779. * @param evt The original (browser) event
  2780. * @returns the new ActionEvent
  2781. */
  2782. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2783. /**
  2784. * Helper function to auto-create an ActionEvent from a primitive
  2785. * @param prim defines the target primitive
  2786. * @param pointerPos defines the pointer position
  2787. * @param evt The original (browser) event
  2788. * @param additionalData additional data for the event
  2789. * @returns the new ActionEvent
  2790. */
  2791. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2792. }
  2793. /**
  2794. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2795. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2797. */
  2798. class ActionManager {
  2799. private static _NothingTrigger;
  2800. private static _OnPickTrigger;
  2801. private static _OnLeftPickTrigger;
  2802. private static _OnRightPickTrigger;
  2803. private static _OnCenterPickTrigger;
  2804. private static _OnPickDownTrigger;
  2805. private static _OnDoublePickTrigger;
  2806. private static _OnPickUpTrigger;
  2807. private static _OnLongPressTrigger;
  2808. private static _OnPointerOverTrigger;
  2809. private static _OnPointerOutTrigger;
  2810. private static _OnEveryFrameTrigger;
  2811. private static _OnIntersectionEnterTrigger;
  2812. private static _OnIntersectionExitTrigger;
  2813. private static _OnKeyDownTrigger;
  2814. private static _OnKeyUpTrigger;
  2815. private static _OnPickOutTrigger;
  2816. /**
  2817. * Nothing
  2818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2819. */
  2820. static readonly NothingTrigger: number;
  2821. /**
  2822. * On pick
  2823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2824. */
  2825. static readonly OnPickTrigger: number;
  2826. /**
  2827. * On left pick
  2828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2829. */
  2830. static readonly OnLeftPickTrigger: number;
  2831. /**
  2832. * On right pick
  2833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2834. */
  2835. static readonly OnRightPickTrigger: number;
  2836. /**
  2837. * On center pick
  2838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2839. */
  2840. static readonly OnCenterPickTrigger: number;
  2841. /**
  2842. * On pick down
  2843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2844. */
  2845. static readonly OnPickDownTrigger: number;
  2846. /**
  2847. * On double pick
  2848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2849. */
  2850. static readonly OnDoublePickTrigger: number;
  2851. /**
  2852. * On pick up
  2853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2854. */
  2855. static readonly OnPickUpTrigger: number;
  2856. /**
  2857. * On pick out.
  2858. * This trigger will only be raised if you also declared a OnPickDown
  2859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2860. */
  2861. static readonly OnPickOutTrigger: number;
  2862. /**
  2863. * On long press
  2864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2865. */
  2866. static readonly OnLongPressTrigger: number;
  2867. /**
  2868. * On pointer over
  2869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2870. */
  2871. static readonly OnPointerOverTrigger: number;
  2872. /**
  2873. * On pointer out
  2874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2875. */
  2876. static readonly OnPointerOutTrigger: number;
  2877. /**
  2878. * On every frame
  2879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2880. */
  2881. static readonly OnEveryFrameTrigger: number;
  2882. /**
  2883. * On intersection enter
  2884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2885. */
  2886. static readonly OnIntersectionEnterTrigger: number;
  2887. /**
  2888. * On intersection exit
  2889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2890. */
  2891. static readonly OnIntersectionExitTrigger: number;
  2892. /**
  2893. * On key down
  2894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2895. */
  2896. static readonly OnKeyDownTrigger: number;
  2897. /**
  2898. * On key up
  2899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2900. */
  2901. static readonly OnKeyUpTrigger: number;
  2902. /** Gets the list of active triggers */
  2903. static Triggers: {
  2904. [key: string]: number;
  2905. };
  2906. /** Gets the list of actions */
  2907. actions: Action[];
  2908. /** Gets the cursor to use when hovering items */
  2909. hoverCursor: string;
  2910. private _scene;
  2911. /**
  2912. * Creates a new action manager
  2913. * @param scene defines the hosting scene
  2914. */
  2915. constructor(scene: Scene);
  2916. /**
  2917. * Releases all associated resources
  2918. */
  2919. dispose(): void;
  2920. /**
  2921. * Gets hosting scene
  2922. * @returns the hosting scene
  2923. */
  2924. getScene(): Scene;
  2925. /**
  2926. * Does this action manager handles actions of any of the given triggers
  2927. * @param triggers defines the triggers to be tested
  2928. * @return a boolean indicating whether one (or more) of the triggers is handled
  2929. */
  2930. hasSpecificTriggers(triggers: number[]): boolean;
  2931. /**
  2932. * Does this action manager handles actions of a given trigger
  2933. * @param trigger defines the trigger to be tested
  2934. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2935. * @return whether the trigger is handled
  2936. */
  2937. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2938. /**
  2939. * Does this action manager has pointer triggers
  2940. */
  2941. readonly hasPointerTriggers: boolean;
  2942. /**
  2943. * Does this action manager has pick triggers
  2944. */
  2945. readonly hasPickTriggers: boolean;
  2946. /**
  2947. * Does exist one action manager with at least one trigger
  2948. **/
  2949. static readonly HasTriggers: boolean;
  2950. /**
  2951. * Does exist one action manager with at least one pick trigger
  2952. **/
  2953. static readonly HasPickTriggers: boolean;
  2954. /**
  2955. * Does exist one action manager that handles actions of a given trigger
  2956. * @param trigger defines the trigger to be tested
  2957. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2958. **/
  2959. static HasSpecificTrigger(trigger: number): boolean;
  2960. /**
  2961. * Registers an action to this action manager
  2962. * @param action defines the action to be registered
  2963. * @return the action amended (prepared) after registration
  2964. */
  2965. registerAction(action: Action): Nullable<Action>;
  2966. /**
  2967. * Unregisters an action to this action manager
  2968. * @param action defines the action to be unregistered
  2969. * @return a boolean indicating whether the action has been unregistered
  2970. */
  2971. unregisterAction(action: Action): Boolean;
  2972. /**
  2973. * Process a specific trigger
  2974. * @param trigger defines the trigger to process
  2975. * @param evt defines the event details to be processed
  2976. */
  2977. processTrigger(trigger: number, evt?: ActionEvent): void;
  2978. /** @hidden */
  2979. _getEffectiveTarget(target: any, propertyPath: string): any;
  2980. /** @hidden */
  2981. _getProperty(propertyPath: string): string;
  2982. /**
  2983. * Serialize this manager to a JSON object
  2984. * @param name defines the property name to store this manager
  2985. * @returns a JSON representation of this manager
  2986. */
  2987. serialize(name: string): any;
  2988. /**
  2989. * Creates a new ActionManager from a JSON data
  2990. * @param parsedActions defines the JSON data to read from
  2991. * @param object defines the hosting mesh
  2992. * @param scene defines the hosting scene
  2993. */
  2994. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2995. /**
  2996. * Get a trigger name by index
  2997. * @param trigger defines the trigger index
  2998. * @returns a trigger name
  2999. */
  3000. static GetTriggerName(trigger: number): string;
  3001. }
  3002. }
  3003. declare module BABYLON {
  3004. /**
  3005. * A Condition applied to an Action
  3006. */
  3007. class Condition {
  3008. /**
  3009. * Internal only - manager for action
  3010. * @hidden
  3011. */
  3012. _actionManager: ActionManager;
  3013. /**
  3014. * Internal only
  3015. * @hidden
  3016. */
  3017. _evaluationId: number;
  3018. /**
  3019. * Internal only
  3020. * @hidden
  3021. */
  3022. _currentResult: boolean;
  3023. /**
  3024. * Creates a new Condition
  3025. * @param actionManager the manager of the action the condition is applied to
  3026. */
  3027. constructor(actionManager: ActionManager);
  3028. /**
  3029. * Check if the current condition is valid
  3030. * @returns a boolean
  3031. */
  3032. isValid(): boolean;
  3033. /**
  3034. * Internal only
  3035. * @hidden
  3036. */
  3037. _getProperty(propertyPath: string): string;
  3038. /**
  3039. * Internal only
  3040. * @hidden
  3041. */
  3042. _getEffectiveTarget(target: any, propertyPath: string): any;
  3043. /**
  3044. * Serialize placeholder for child classes
  3045. * @returns the serialized object
  3046. */
  3047. serialize(): any;
  3048. /**
  3049. * Internal only
  3050. * @hidden
  3051. */
  3052. protected _serialize(serializedCondition: any): any;
  3053. }
  3054. /**
  3055. * Defines specific conditional operators as extensions of Condition
  3056. */
  3057. class ValueCondition extends Condition {
  3058. /** path to specify the property of the target the conditional operator uses */
  3059. propertyPath: string;
  3060. /** the value compared by the conditional operator against the current value of the property */
  3061. value: any;
  3062. /** the conditional operator, default ValueCondition.IsEqual */
  3063. operator: number;
  3064. /**
  3065. * Internal only
  3066. * @hidden
  3067. */
  3068. private static _IsEqual;
  3069. /**
  3070. * Internal only
  3071. * @hidden
  3072. */
  3073. private static _IsDifferent;
  3074. /**
  3075. * Internal only
  3076. * @hidden
  3077. */
  3078. private static _IsGreater;
  3079. /**
  3080. * Internal only
  3081. * @hidden
  3082. */
  3083. private static _IsLesser;
  3084. /**
  3085. * returns the number for IsEqual
  3086. */
  3087. static readonly IsEqual: number;
  3088. /**
  3089. * Returns the number for IsDifferent
  3090. */
  3091. static readonly IsDifferent: number;
  3092. /**
  3093. * Returns the number for IsGreater
  3094. */
  3095. static readonly IsGreater: number;
  3096. /**
  3097. * Returns the number for IsLesser
  3098. */
  3099. static readonly IsLesser: number;
  3100. /**
  3101. * Internal only The action manager for the condition
  3102. * @hidden
  3103. */
  3104. _actionManager: ActionManager;
  3105. /**
  3106. * Internal only
  3107. * @hidden
  3108. */
  3109. private _target;
  3110. /**
  3111. * Internal only
  3112. * @hidden
  3113. */
  3114. private _effectiveTarget;
  3115. /**
  3116. * Internal only
  3117. * @hidden
  3118. */
  3119. private _property;
  3120. /**
  3121. * Creates a new ValueCondition
  3122. * @param actionManager manager for the action the condition applies to
  3123. * @param target for the action
  3124. * @param propertyPath path to specify the property of the target the conditional operator uses
  3125. * @param value the value compared by the conditional operator against the current value of the property
  3126. * @param operator the conditional operator, default ValueCondition.IsEqual
  3127. */
  3128. constructor(actionManager: ActionManager, target: any,
  3129. /** path to specify the property of the target the conditional operator uses */
  3130. propertyPath: string,
  3131. /** the value compared by the conditional operator against the current value of the property */
  3132. value: any,
  3133. /** the conditional operator, default ValueCondition.IsEqual */
  3134. operator?: number);
  3135. /**
  3136. * Compares the given value with the property value for the specified conditional operator
  3137. * @returns the result of the comparison
  3138. */
  3139. isValid(): boolean;
  3140. /**
  3141. * Serialize the ValueCondition into a JSON compatible object
  3142. * @returns serialization object
  3143. */
  3144. serialize(): any;
  3145. /**
  3146. * Gets the name of the conditional operator for the ValueCondition
  3147. * @param operator the conditional operator
  3148. * @returns the name
  3149. */
  3150. static GetOperatorName(operator: number): string;
  3151. }
  3152. /**
  3153. * Defines a predicate condition as an extension of Condition
  3154. */
  3155. class PredicateCondition extends Condition {
  3156. /** defines the predicate function used to validate the condition */
  3157. predicate: () => boolean;
  3158. /**
  3159. * Internal only - manager for action
  3160. * @hidden
  3161. */
  3162. _actionManager: ActionManager;
  3163. /**
  3164. * Creates a new PredicateCondition
  3165. * @param actionManager manager for the action the condition applies to
  3166. * @param predicate defines the predicate function used to validate the condition
  3167. */
  3168. constructor(actionManager: ActionManager,
  3169. /** defines the predicate function used to validate the condition */
  3170. predicate: () => boolean);
  3171. /**
  3172. * @returns the validity of the predicate condition
  3173. */
  3174. isValid(): boolean;
  3175. }
  3176. /**
  3177. * Defines a state condition as an extension of Condition
  3178. */
  3179. class StateCondition extends Condition {
  3180. value: string;
  3181. /**
  3182. * Internal only - manager for action
  3183. * @hidden
  3184. */
  3185. _actionManager: ActionManager;
  3186. /**
  3187. * Internal only
  3188. * @hidden
  3189. */
  3190. private _target;
  3191. /**
  3192. * Creates a new StateCondition
  3193. * @param actionManager manager for the action the condition applies to
  3194. * @param target of the condition
  3195. * @param value to compare with target state
  3196. */
  3197. constructor(actionManager: ActionManager, target: any, value: string);
  3198. /**
  3199. * @returns the validity of the state
  3200. */
  3201. isValid(): boolean;
  3202. /**
  3203. * Serialize the StateCondition into a JSON compatible object
  3204. * @returns serialization object
  3205. */
  3206. serialize(): any;
  3207. }
  3208. }
  3209. declare module BABYLON {
  3210. class SwitchBooleanAction extends Action {
  3211. propertyPath: string;
  3212. private _target;
  3213. private _effectiveTarget;
  3214. private _property;
  3215. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3216. _prepare(): void;
  3217. execute(): void;
  3218. serialize(parent: any): any;
  3219. }
  3220. class SetStateAction extends Action {
  3221. value: string;
  3222. private _target;
  3223. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3224. execute(): void;
  3225. serialize(parent: any): any;
  3226. }
  3227. class SetValueAction extends Action {
  3228. propertyPath: string;
  3229. value: any;
  3230. private _target;
  3231. private _effectiveTarget;
  3232. private _property;
  3233. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3234. _prepare(): void;
  3235. execute(): void;
  3236. serialize(parent: any): any;
  3237. }
  3238. class IncrementValueAction extends Action {
  3239. propertyPath: string;
  3240. value: any;
  3241. private _target;
  3242. private _effectiveTarget;
  3243. private _property;
  3244. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3245. _prepare(): void;
  3246. execute(): void;
  3247. serialize(parent: any): any;
  3248. }
  3249. class PlayAnimationAction extends Action {
  3250. from: number;
  3251. to: number;
  3252. loop: boolean | undefined;
  3253. private _target;
  3254. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3255. _prepare(): void;
  3256. execute(): void;
  3257. serialize(parent: any): any;
  3258. }
  3259. class StopAnimationAction extends Action {
  3260. private _target;
  3261. constructor(triggerOptions: any, target: any, condition?: Condition);
  3262. _prepare(): void;
  3263. execute(): void;
  3264. serialize(parent: any): any;
  3265. }
  3266. class DoNothingAction extends Action {
  3267. constructor(triggerOptions?: any, condition?: Condition);
  3268. execute(): void;
  3269. serialize(parent: any): any;
  3270. }
  3271. class CombineAction extends Action {
  3272. children: Action[];
  3273. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3274. _prepare(): void;
  3275. execute(evt: ActionEvent): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class ExecuteCodeAction extends Action {
  3279. func: (evt: ActionEvent) => void;
  3280. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3281. execute(evt: ActionEvent): void;
  3282. }
  3283. class SetParentAction extends Action {
  3284. private _parent;
  3285. private _target;
  3286. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3287. _prepare(): void;
  3288. execute(): void;
  3289. serialize(parent: any): any;
  3290. }
  3291. class PlaySoundAction extends Action {
  3292. private _sound;
  3293. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3294. _prepare(): void;
  3295. execute(): void;
  3296. serialize(parent: any): any;
  3297. }
  3298. class StopSoundAction extends Action {
  3299. private _sound;
  3300. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3301. _prepare(): void;
  3302. execute(): void;
  3303. serialize(parent: any): any;
  3304. }
  3305. }
  3306. declare module BABYLON {
  3307. class InterpolateValueAction extends Action {
  3308. propertyPath: string;
  3309. value: any;
  3310. duration: number;
  3311. stopOtherAnimations: boolean | undefined;
  3312. onInterpolationDone: (() => void) | undefined;
  3313. private _target;
  3314. private _effectiveTarget;
  3315. private _property;
  3316. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3317. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3318. _prepare(): void;
  3319. execute(): void;
  3320. serialize(parent: any): any;
  3321. }
  3322. }
  3323. declare module BABYLON {
  3324. class Animatable {
  3325. target: any;
  3326. fromFrame: number;
  3327. toFrame: number;
  3328. loopAnimation: boolean;
  3329. onAnimationEnd: (() => void) | null | undefined;
  3330. private _localDelayOffset;
  3331. private _pausedDelay;
  3332. private _runtimeAnimations;
  3333. private _paused;
  3334. private _scene;
  3335. private _speedRatio;
  3336. private _weight;
  3337. private _syncRoot;
  3338. animationStarted: boolean;
  3339. /**
  3340. * Observer raised when the animation ends
  3341. */
  3342. onAnimationEndObservable: Observable<Animatable>;
  3343. /**
  3344. * Gets the root Animatable used to synchronize and normalize animations
  3345. */
  3346. readonly syncRoot: Animatable;
  3347. /**
  3348. * Gets the current frame of the first RuntimeAnimation
  3349. * Used to synchronize Animatables
  3350. */
  3351. readonly masterFrame: number;
  3352. /**
  3353. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3354. */
  3355. weight: number;
  3356. /**
  3357. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3358. */
  3359. speedRatio: number;
  3360. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3361. /**
  3362. * Synchronize and normalize current Animatable with a source Animatable
  3363. * This is useful when using animation weights and when animations are not of the same length
  3364. * @param root defines the root Animatable to synchronize with
  3365. * @returns the current Animatable
  3366. */
  3367. syncWith(root: Animatable): Animatable;
  3368. getAnimations(): RuntimeAnimation[];
  3369. appendAnimations(target: any, animations: Animation[]): void;
  3370. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3371. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3372. reset(): void;
  3373. enableBlending(blendingSpeed: number): void;
  3374. disableBlending(): void;
  3375. goToFrame(frame: number): void;
  3376. pause(): void;
  3377. restart(): void;
  3378. private _raiseOnAnimationEnd();
  3379. stop(animationName?: string): void;
  3380. /**
  3381. * Wait asynchronously for the animation to end
  3382. * @returns a promise which will be fullfilled when the animation ends
  3383. */
  3384. waitAsync(): Promise<Animatable>;
  3385. /** @hidden */
  3386. _animate(delay: number): boolean;
  3387. }
  3388. }
  3389. declare module BABYLON {
  3390. /**
  3391. * Represents the range of an animation
  3392. */
  3393. class AnimationRange {
  3394. /**The name of the animation range**/
  3395. name: string;
  3396. /**The starting frame of the animation */
  3397. from: number;
  3398. /**The ending frame of the animation*/
  3399. to: number;
  3400. /**
  3401. * Initializes the range of an animation
  3402. * @param name The name of the animation range
  3403. * @param from The starting frame of the animation
  3404. * @param to The ending frame of the animation
  3405. */
  3406. constructor(
  3407. /**The name of the animation range**/
  3408. name: string,
  3409. /**The starting frame of the animation */
  3410. from: number,
  3411. /**The ending frame of the animation*/
  3412. to: number);
  3413. /**
  3414. * Makes a copy of the animation range
  3415. * @returns A copy of the animation range
  3416. */
  3417. clone(): AnimationRange;
  3418. }
  3419. /**
  3420. * Composed of a frame, and an action function
  3421. */
  3422. class AnimationEvent {
  3423. /** The frame for which the event is triggered **/
  3424. frame: number;
  3425. /** The event to perform when triggered **/
  3426. action: () => void;
  3427. /** Specifies if the event should be triggered only once**/
  3428. onlyOnce: boolean | undefined;
  3429. /**
  3430. * Specifies if the animation event is done
  3431. */
  3432. isDone: boolean;
  3433. /**
  3434. * Initializes the animation event
  3435. * @param frame The frame for which the event is triggered
  3436. * @param action The event to perform when triggered
  3437. * @param onlyOnce Specifies if the event should be triggered only once
  3438. */
  3439. constructor(
  3440. /** The frame for which the event is triggered **/
  3441. frame: number,
  3442. /** The event to perform when triggered **/
  3443. action: () => void,
  3444. /** Specifies if the event should be triggered only once**/
  3445. onlyOnce?: boolean | undefined);
  3446. /** @hidden */
  3447. _clone(): AnimationEvent;
  3448. }
  3449. /**
  3450. * A cursor which tracks a point on a path
  3451. */
  3452. class PathCursor {
  3453. private path;
  3454. /**
  3455. * Stores path cursor callbacks for when an onchange event is triggered
  3456. */
  3457. private _onchange;
  3458. /**
  3459. * The value of the path cursor
  3460. */
  3461. value: number;
  3462. /**
  3463. * The animation array of the path cursor
  3464. */
  3465. animations: Animation[];
  3466. /**
  3467. * Initializes the path cursor
  3468. * @param path The path to track
  3469. */
  3470. constructor(path: Path2);
  3471. /**
  3472. * Gets the cursor point on the path
  3473. * @returns A point on the path cursor at the cursor location
  3474. */
  3475. getPoint(): Vector3;
  3476. /**
  3477. * Moves the cursor ahead by the step amount
  3478. * @param step The amount to move the cursor forward
  3479. * @returns This path cursor
  3480. */
  3481. moveAhead(step?: number): PathCursor;
  3482. /**
  3483. * Moves the cursor behind by the step amount
  3484. * @param step The amount to move the cursor back
  3485. * @returns This path cursor
  3486. */
  3487. moveBack(step?: number): PathCursor;
  3488. /**
  3489. * Moves the cursor by the step amount
  3490. * If the step amount is greater than one, an exception is thrown
  3491. * @param step The amount to move the cursor
  3492. * @returns This path cursor
  3493. */
  3494. move(step: number): PathCursor;
  3495. /**
  3496. * Ensures that the value is limited between zero and one
  3497. * @returns This path cursor
  3498. */
  3499. private ensureLimits();
  3500. /**
  3501. * Runs onchange callbacks on change (used by the animation engine)
  3502. * @returns This path cursor
  3503. */
  3504. private raiseOnChange();
  3505. /**
  3506. * Executes a function on change
  3507. * @param f A path cursor onchange callback
  3508. * @returns This path cursor
  3509. */
  3510. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3511. }
  3512. /**
  3513. * Defines an interface which represents an animation key frame
  3514. */
  3515. interface IAnimationKey {
  3516. /**
  3517. * Frame of the key frame
  3518. */
  3519. frame: number;
  3520. /**
  3521. * Value at the specifies key frame
  3522. */
  3523. value: any;
  3524. /**
  3525. * The input tangent for the cubic hermite spline
  3526. */
  3527. inTangent?: any;
  3528. /**
  3529. * The output tangent for the cubic hermite spline
  3530. */
  3531. outTangent?: any;
  3532. /**
  3533. * The animation interpolation type
  3534. */
  3535. interpolation?: AnimationKeyInterpolation;
  3536. }
  3537. /**
  3538. * Enum for the animation key frame interpolation type
  3539. */
  3540. enum AnimationKeyInterpolation {
  3541. /**
  3542. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3543. */
  3544. STEP = 1,
  3545. }
  3546. /**
  3547. * Class used to store any kind of animation
  3548. */
  3549. class Animation {
  3550. /**Name of the animation */
  3551. name: string;
  3552. /**Property to animate */
  3553. targetProperty: string;
  3554. /**The frames per second of the animation */
  3555. framePerSecond: number;
  3556. /**The data type of the animation */
  3557. dataType: number;
  3558. /**The loop mode of the animation */
  3559. loopMode: number | undefined;
  3560. /**Specifies if blending should be enabled */
  3561. enableBlending: boolean | undefined;
  3562. /**
  3563. * Use matrix interpolation instead of using direct key value when animating matrices
  3564. */
  3565. static AllowMatricesInterpolation: boolean;
  3566. /**
  3567. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3568. */
  3569. static AllowMatrixDecomposeForInterpolation: boolean;
  3570. /**
  3571. * Stores the key frames of the animation
  3572. */
  3573. private _keys;
  3574. /**
  3575. * Stores the easing function of the animation
  3576. */
  3577. private _easingFunction;
  3578. /**
  3579. * @hidden Internal use only
  3580. */
  3581. _runtimeAnimations: RuntimeAnimation[];
  3582. /**
  3583. * The set of event that will be linked to this animation
  3584. */
  3585. private _events;
  3586. /**
  3587. * Stores an array of target property paths
  3588. */
  3589. targetPropertyPath: string[];
  3590. /**
  3591. * Stores the blending speed of the animation
  3592. */
  3593. blendingSpeed: number;
  3594. /**
  3595. * Stores the animation ranges for the animation
  3596. */
  3597. private _ranges;
  3598. /**
  3599. * @hidden Internal use
  3600. */
  3601. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3602. /**
  3603. * Sets up an animation
  3604. * @param property The property to animate
  3605. * @param animationType The animation type to apply
  3606. * @param framePerSecond The frames per second of the animation
  3607. * @param easingFunction The easing function used in the animation
  3608. * @returns The created animation
  3609. */
  3610. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3611. /**
  3612. * Create and start an animation on a node
  3613. * @param name defines the name of the global animation that will be run on all nodes
  3614. * @param node defines the root node where the animation will take place
  3615. * @param targetProperty defines property to animate
  3616. * @param framePerSecond defines the number of frame per second yo use
  3617. * @param totalFrame defines the number of frames in total
  3618. * @param from defines the initial value
  3619. * @param to defines the final value
  3620. * @param loopMode defines which loop mode you want to use (off by default)
  3621. * @param easingFunction defines the easing function to use (linear by default)
  3622. * @param onAnimationEnd defines the callback to call when animation end
  3623. * @returns the animatable created for this animation
  3624. */
  3625. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3626. /**
  3627. * Create and start an animation on a node and its descendants
  3628. * @param name defines the name of the global animation that will be run on all nodes
  3629. * @param node defines the root node where the animation will take place
  3630. * @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
  3631. * @param targetProperty defines property to animate
  3632. * @param framePerSecond defines the number of frame per second to use
  3633. * @param totalFrame defines the number of frames in total
  3634. * @param from defines the initial value
  3635. * @param to defines the final value
  3636. * @param loopMode defines which loop mode you want to use (off by default)
  3637. * @param easingFunction defines the easing function to use (linear by default)
  3638. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3639. * @returns the list of animatables created for all nodes
  3640. * @example https://www.babylonjs-playground.com/#MH0VLI
  3641. */
  3642. 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[]>;
  3643. /**
  3644. * Creates a new animation, merges it with the existing animations and starts it
  3645. * @param name Name of the animation
  3646. * @param node Node which contains the scene that begins the animations
  3647. * @param targetProperty Specifies which property to animate
  3648. * @param framePerSecond The frames per second of the animation
  3649. * @param totalFrame The total number of frames
  3650. * @param from The frame at the beginning of the animation
  3651. * @param to The frame at the end of the animation
  3652. * @param loopMode Specifies the loop mode of the animation
  3653. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3654. * @param onAnimationEnd Callback to run once the animation is complete
  3655. * @returns Nullable animation
  3656. */
  3657. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3658. /**
  3659. * Transition property of an host to the target Value
  3660. * @param property The property to transition
  3661. * @param targetValue The target Value of the property
  3662. * @param host The object where the property to animate belongs
  3663. * @param scene Scene used to run the animation
  3664. * @param frameRate Framerate (in frame/s) to use
  3665. * @param transition The transition type we want to use
  3666. * @param duration The duration of the animation, in milliseconds
  3667. * @param onAnimationEnd Callback trigger at the end of the animation
  3668. * @returns Nullable animation
  3669. */
  3670. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3671. /**
  3672. * Return the array of runtime animations currently using this animation
  3673. */
  3674. readonly runtimeAnimations: RuntimeAnimation[];
  3675. /**
  3676. * Specifies if any of the runtime animations are currently running
  3677. */
  3678. readonly hasRunningRuntimeAnimations: boolean;
  3679. /**
  3680. * Initializes the animation
  3681. * @param name Name of the animation
  3682. * @param targetProperty Property to animate
  3683. * @param framePerSecond The frames per second of the animation
  3684. * @param dataType The data type of the animation
  3685. * @param loopMode The loop mode of the animation
  3686. * @param enableBlendings Specifies if blending should be enabled
  3687. */
  3688. constructor(
  3689. /**Name of the animation */
  3690. name: string,
  3691. /**Property to animate */
  3692. targetProperty: string,
  3693. /**The frames per second of the animation */
  3694. framePerSecond: number,
  3695. /**The data type of the animation */
  3696. dataType: number,
  3697. /**The loop mode of the animation */
  3698. loopMode?: number | undefined,
  3699. /**Specifies if blending should be enabled */
  3700. enableBlending?: boolean | undefined);
  3701. /**
  3702. * Converts the animation to a string
  3703. * @param fullDetails support for multiple levels of logging within scene loading
  3704. * @returns String form of the animation
  3705. */
  3706. toString(fullDetails?: boolean): string;
  3707. /**
  3708. * Add an event to this animation
  3709. * @param event Event to add
  3710. */
  3711. addEvent(event: AnimationEvent): void;
  3712. /**
  3713. * Remove all events found at the given frame
  3714. * @param frame The frame to remove events from
  3715. */
  3716. removeEvents(frame: number): void;
  3717. /**
  3718. * Retrieves all the events from the animation
  3719. * @returns Events from the animation
  3720. */
  3721. getEvents(): AnimationEvent[];
  3722. /**
  3723. * Creates an animation range
  3724. * @param name Name of the animation range
  3725. * @param from Starting frame of the animation range
  3726. * @param to Ending frame of the animation
  3727. */
  3728. createRange(name: string, from: number, to: number): void;
  3729. /**
  3730. * Deletes an animation range by name
  3731. * @param name Name of the animation range to delete
  3732. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3733. */
  3734. deleteRange(name: string, deleteFrames?: boolean): void;
  3735. /**
  3736. * Gets the animation range by name, or null if not defined
  3737. * @param name Name of the animation range
  3738. * @returns Nullable animation range
  3739. */
  3740. getRange(name: string): Nullable<AnimationRange>;
  3741. /**
  3742. * Gets the key frames from the animation
  3743. * @returns The key frames of the animation
  3744. */
  3745. getKeys(): Array<IAnimationKey>;
  3746. /**
  3747. * Gets the highest frame rate of the animation
  3748. * @returns Highest frame rate of the animation
  3749. */
  3750. getHighestFrame(): number;
  3751. /**
  3752. * Gets the easing function of the animation
  3753. * @returns Easing function of the animation
  3754. */
  3755. getEasingFunction(): IEasingFunction;
  3756. /**
  3757. * Sets the easing function of the animation
  3758. * @param easingFunction A custom mathematical formula for animation
  3759. */
  3760. setEasingFunction(easingFunction: EasingFunction): void;
  3761. /**
  3762. * Interpolates a scalar linearly
  3763. * @param startValue Start value of the animation curve
  3764. * @param endValue End value of the animation curve
  3765. * @param gradient Scalar amount to interpolate
  3766. * @returns Interpolated scalar value
  3767. */
  3768. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3769. /**
  3770. * Interpolates a scalar cubically
  3771. * @param startValue Start value of the animation curve
  3772. * @param outTangent End tangent of the animation
  3773. * @param endValue End value of the animation curve
  3774. * @param inTangent Start tangent of the animation curve
  3775. * @param gradient Scalar amount to interpolate
  3776. * @returns Interpolated scalar value
  3777. */
  3778. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3779. /**
  3780. * Interpolates a quaternion using a spherical linear interpolation
  3781. * @param startValue Start value of the animation curve
  3782. * @param endValue End value of the animation curve
  3783. * @param gradient Scalar amount to interpolate
  3784. * @returns Interpolated quaternion value
  3785. */
  3786. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3787. /**
  3788. * Interpolates a quaternion cubically
  3789. * @param startValue Start value of the animation curve
  3790. * @param outTangent End tangent of the animation curve
  3791. * @param endValue End value of the animation curve
  3792. * @param inTangent Start tangent of the animation curve
  3793. * @param gradient Scalar amount to interpolate
  3794. * @returns Interpolated quaternion value
  3795. */
  3796. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3797. /**
  3798. * Interpolates a Vector3 linearl
  3799. * @param startValue Start value of the animation curve
  3800. * @param endValue End value of the animation curve
  3801. * @param gradient Scalar amount to interpolate
  3802. * @returns Interpolated scalar value
  3803. */
  3804. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3805. /**
  3806. * Interpolates a Vector3 cubically
  3807. * @param startValue Start value of the animation curve
  3808. * @param outTangent End tangent of the animation
  3809. * @param endValue End value of the animation curve
  3810. * @param inTangent Start tangent of the animation curve
  3811. * @param gradient Scalar amount to interpolate
  3812. * @returns InterpolatedVector3 value
  3813. */
  3814. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3815. /**
  3816. * Interpolates a Vector2 linearly
  3817. * @param startValue Start value of the animation curve
  3818. * @param endValue End value of the animation curve
  3819. * @param gradient Scalar amount to interpolate
  3820. * @returns Interpolated Vector2 value
  3821. */
  3822. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3823. /**
  3824. * Interpolates a Vector2 cubically
  3825. * @param startValue Start value of the animation curve
  3826. * @param outTangent End tangent of the animation
  3827. * @param endValue End value of the animation curve
  3828. * @param inTangent Start tangent of the animation curve
  3829. * @param gradient Scalar amount to interpolate
  3830. * @returns Interpolated Vector2 value
  3831. */
  3832. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3833. /**
  3834. * Interpolates a size linearly
  3835. * @param startValue Start value of the animation curve
  3836. * @param endValue End value of the animation curve
  3837. * @param gradient Scalar amount to interpolate
  3838. * @returns Interpolated Size value
  3839. */
  3840. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3841. /**
  3842. * Interpolates a Color3 linearly
  3843. * @param startValue Start value of the animation curve
  3844. * @param endValue End value of the animation curve
  3845. * @param gradient Scalar amount to interpolate
  3846. * @returns Interpolated Color3 value
  3847. */
  3848. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3849. /**
  3850. * @hidden Internal use only
  3851. */
  3852. _getKeyValue(value: any): any;
  3853. /**
  3854. * @hidden Internal use only
  3855. */
  3856. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3857. /**
  3858. * Defines the function to use to interpolate matrices
  3859. * @param startValue defines the start matrix
  3860. * @param endValue defines the end matrix
  3861. * @param gradient defines the gradient between both matrices
  3862. * @param result defines an optional target matrix where to store the interpolation
  3863. * @returns the interpolated matrix
  3864. */
  3865. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3866. /**
  3867. * Makes a copy of the animation
  3868. * @returns Cloned animation
  3869. */
  3870. clone(): Animation;
  3871. /**
  3872. * Sets the key frames of the animation
  3873. * @param values The animation key frames to set
  3874. */
  3875. setKeys(values: Array<IAnimationKey>): void;
  3876. /**
  3877. * Serializes the animation to an object
  3878. * @returns Serialized object
  3879. */
  3880. serialize(): any;
  3881. /**
  3882. * Float animation type
  3883. */
  3884. private static _ANIMATIONTYPE_FLOAT;
  3885. /**
  3886. * Vector3 animation type
  3887. */
  3888. private static _ANIMATIONTYPE_VECTOR3;
  3889. /**
  3890. * Quaternion animation type
  3891. */
  3892. private static _ANIMATIONTYPE_QUATERNION;
  3893. /**
  3894. * Matrix animation type
  3895. */
  3896. private static _ANIMATIONTYPE_MATRIX;
  3897. /**
  3898. * Color3 animation type
  3899. */
  3900. private static _ANIMATIONTYPE_COLOR3;
  3901. /**
  3902. * Vector2 animation type
  3903. */
  3904. private static _ANIMATIONTYPE_VECTOR2;
  3905. /**
  3906. * Size animation type
  3907. */
  3908. private static _ANIMATIONTYPE_SIZE;
  3909. /**
  3910. * Relative Loop Mode
  3911. */
  3912. private static _ANIMATIONLOOPMODE_RELATIVE;
  3913. /**
  3914. * Cycle Loop Mode
  3915. */
  3916. private static _ANIMATIONLOOPMODE_CYCLE;
  3917. /**
  3918. * Constant Loop Mode
  3919. */
  3920. private static _ANIMATIONLOOPMODE_CONSTANT;
  3921. /**
  3922. * Get the float animation type
  3923. */
  3924. static readonly ANIMATIONTYPE_FLOAT: number;
  3925. /**
  3926. * Get the Vector3 animation type
  3927. */
  3928. static readonly ANIMATIONTYPE_VECTOR3: number;
  3929. /**
  3930. * Get the Vectpr2 animation type
  3931. */
  3932. static readonly ANIMATIONTYPE_VECTOR2: number;
  3933. /**
  3934. * Get the Size animation type
  3935. */
  3936. static readonly ANIMATIONTYPE_SIZE: number;
  3937. /**
  3938. * Get the Quaternion animation type
  3939. */
  3940. static readonly ANIMATIONTYPE_QUATERNION: number;
  3941. /**
  3942. * Get the Matrix animation type
  3943. */
  3944. static readonly ANIMATIONTYPE_MATRIX: number;
  3945. /**
  3946. * Get the Color3 animation type
  3947. */
  3948. static readonly ANIMATIONTYPE_COLOR3: number;
  3949. /**
  3950. * Get the Relative Loop Mode
  3951. */
  3952. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3953. /**
  3954. * Get the Cycle Loop Mode
  3955. */
  3956. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3957. /**
  3958. * Get the Constant Loop Mode
  3959. */
  3960. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3961. /** @hidden */
  3962. static _UniversalLerp(left: any, right: any, amount: number): any;
  3963. /**
  3964. * Parses an animation object and creates an animation
  3965. * @param parsedAnimation Parsed animation object
  3966. * @returns Animation object
  3967. */
  3968. static Parse(parsedAnimation: any): Animation;
  3969. /**
  3970. * Appends the serialized animations from the source animations
  3971. * @param source Source containing the animations
  3972. * @param destination Target to store the animations
  3973. */
  3974. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3975. }
  3976. }
  3977. declare module BABYLON {
  3978. /**
  3979. * This class defines the direct association between an animation and a target
  3980. */
  3981. class TargetedAnimation {
  3982. animation: Animation;
  3983. target: any;
  3984. }
  3985. /**
  3986. * Use this class to create coordinated animations on multiple targets
  3987. */
  3988. class AnimationGroup implements IDisposable {
  3989. name: string;
  3990. private _scene;
  3991. private _targetedAnimations;
  3992. private _animatables;
  3993. private _from;
  3994. private _to;
  3995. private _isStarted;
  3996. private _speedRatio;
  3997. onAnimationEndObservable: Observable<TargetedAnimation>;
  3998. /**
  3999. * Gets the first frame
  4000. */
  4001. readonly from: number;
  4002. /**
  4003. * Gets the last frame
  4004. */
  4005. readonly to: number;
  4006. /**
  4007. * Define if the animations are started
  4008. */
  4009. readonly isStarted: boolean;
  4010. /**
  4011. * Gets or sets the speed ratio to use for all animations
  4012. */
  4013. /**
  4014. * Gets or sets the speed ratio to use for all animations
  4015. */
  4016. speedRatio: number;
  4017. /**
  4018. * Gets the targeted animations for this animation group
  4019. */
  4020. readonly targetedAnimations: Array<TargetedAnimation>;
  4021. /**
  4022. * returning the list of animatables controlled by this animation group.
  4023. */
  4024. readonly animatables: Array<Animatable>;
  4025. constructor(name: string, scene?: Nullable<Scene>);
  4026. /**
  4027. * Add an animation (with its target) in the group
  4028. * @param animation defines the animation we want to add
  4029. * @param target defines the target of the animation
  4030. * @returns the {BABYLON.TargetedAnimation} object
  4031. */
  4032. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4033. /**
  4034. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4035. * It can add constant keys at begin or end
  4036. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4037. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4038. */
  4039. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4040. /**
  4041. * Start all animations on given targets
  4042. * @param loop defines if animations must loop
  4043. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4044. * @param from defines the from key (optional)
  4045. * @param to defines the to key (optional)
  4046. * @returns the current animation group
  4047. */
  4048. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4049. /**
  4050. * Pause all animations
  4051. */
  4052. pause(): AnimationGroup;
  4053. /**
  4054. * Play all animations to initial state
  4055. * This function will start() the animations if they were not started or will restart() them if they were paused
  4056. * @param loop defines if animations must loop
  4057. */
  4058. play(loop?: boolean): AnimationGroup;
  4059. /**
  4060. * Reset all animations to initial state
  4061. */
  4062. reset(): AnimationGroup;
  4063. /**
  4064. * Restart animations from key 0
  4065. */
  4066. restart(): AnimationGroup;
  4067. /**
  4068. * Stop all animations
  4069. */
  4070. stop(): AnimationGroup;
  4071. /**
  4072. * Set animation weight for all animatables
  4073. * @param weight defines the weight to use
  4074. * @return the animationGroup
  4075. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4076. */
  4077. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4078. /**
  4079. * Synchronize and normalize all animatables with a source animatable
  4080. * @param root defines the root animatable to synchronize with
  4081. * @return the animationGroup
  4082. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4083. */
  4084. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4085. /**
  4086. * Goes to a specific frame in this animation group
  4087. * @param frame the frame number to go to
  4088. * @return the animationGroup
  4089. */
  4090. goToFrame(frame: number): AnimationGroup;
  4091. /**
  4092. * Dispose all associated resources
  4093. */
  4094. dispose(): void;
  4095. }
  4096. }
  4097. declare module BABYLON {
  4098. /**
  4099. * Class used to override all child animations of a given target
  4100. */
  4101. class AnimationPropertiesOverride {
  4102. /**
  4103. * Gets or sets a value indicating if animation blending must be used
  4104. */
  4105. enableBlending: boolean;
  4106. /**
  4107. * Gets or sets the blending speed to use when enableBlending is true
  4108. */
  4109. blendingSpeed: number;
  4110. /**
  4111. * Gets or sets the default loop mode to use
  4112. */
  4113. loopMode: number;
  4114. }
  4115. }
  4116. declare module BABYLON {
  4117. interface IEasingFunction {
  4118. ease(gradient: number): number;
  4119. }
  4120. class EasingFunction implements IEasingFunction {
  4121. private static _EASINGMODE_EASEIN;
  4122. private static _EASINGMODE_EASEOUT;
  4123. private static _EASINGMODE_EASEINOUT;
  4124. static readonly EASINGMODE_EASEIN: number;
  4125. static readonly EASINGMODE_EASEOUT: number;
  4126. static readonly EASINGMODE_EASEINOUT: number;
  4127. private _easingMode;
  4128. setEasingMode(easingMode: number): void;
  4129. getEasingMode(): number;
  4130. easeInCore(gradient: number): number;
  4131. ease(gradient: number): number;
  4132. }
  4133. class CircleEase extends EasingFunction implements IEasingFunction {
  4134. easeInCore(gradient: number): number;
  4135. }
  4136. class BackEase extends EasingFunction implements IEasingFunction {
  4137. amplitude: number;
  4138. constructor(amplitude?: number);
  4139. easeInCore(gradient: number): number;
  4140. }
  4141. class BounceEase extends EasingFunction implements IEasingFunction {
  4142. bounces: number;
  4143. bounciness: number;
  4144. constructor(bounces?: number, bounciness?: number);
  4145. easeInCore(gradient: number): number;
  4146. }
  4147. class CubicEase extends EasingFunction implements IEasingFunction {
  4148. easeInCore(gradient: number): number;
  4149. }
  4150. class ElasticEase extends EasingFunction implements IEasingFunction {
  4151. oscillations: number;
  4152. springiness: number;
  4153. constructor(oscillations?: number, springiness?: number);
  4154. easeInCore(gradient: number): number;
  4155. }
  4156. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4157. exponent: number;
  4158. constructor(exponent?: number);
  4159. easeInCore(gradient: number): number;
  4160. }
  4161. class PowerEase extends EasingFunction implements IEasingFunction {
  4162. power: number;
  4163. constructor(power?: number);
  4164. easeInCore(gradient: number): number;
  4165. }
  4166. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4167. easeInCore(gradient: number): number;
  4168. }
  4169. class QuarticEase extends EasingFunction implements IEasingFunction {
  4170. easeInCore(gradient: number): number;
  4171. }
  4172. class QuinticEase extends EasingFunction implements IEasingFunction {
  4173. easeInCore(gradient: number): number;
  4174. }
  4175. class SineEase extends EasingFunction implements IEasingFunction {
  4176. easeInCore(gradient: number): number;
  4177. }
  4178. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4179. x1: number;
  4180. y1: number;
  4181. x2: number;
  4182. y2: number;
  4183. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4184. easeInCore(gradient: number): number;
  4185. }
  4186. }
  4187. declare module BABYLON {
  4188. /**
  4189. * Defines a runtime animation
  4190. */
  4191. class RuntimeAnimation {
  4192. private _events;
  4193. /**
  4194. * The current frame of the runtime animation
  4195. */
  4196. private _currentFrame;
  4197. /**
  4198. * The animation used by the runtime animation
  4199. */
  4200. private _animation;
  4201. /**
  4202. * The target of the runtime animation
  4203. */
  4204. private _target;
  4205. /**
  4206. * The initiating animatable
  4207. */
  4208. private _host;
  4209. /**
  4210. * The original value of the runtime animation
  4211. */
  4212. private _originalValue;
  4213. /**
  4214. * The original blend value of the runtime animation
  4215. */
  4216. private _originalBlendValue;
  4217. /**
  4218. * The offsets cache of the runtime animation
  4219. */
  4220. private _offsetsCache;
  4221. /**
  4222. * The high limits cache of the runtime animation
  4223. */
  4224. private _highLimitsCache;
  4225. /**
  4226. * Specifies if the runtime animation has been stopped
  4227. */
  4228. private _stopped;
  4229. /**
  4230. * The blending factor of the runtime animation
  4231. */
  4232. private _blendingFactor;
  4233. /**
  4234. * The BabylonJS scene
  4235. */
  4236. private _scene;
  4237. /**
  4238. * The current value of the runtime animation
  4239. */
  4240. private _currentValue;
  4241. /** @hidden */
  4242. _workValue: any;
  4243. /**
  4244. * The active target of the runtime animation
  4245. */
  4246. private _activeTarget;
  4247. /**
  4248. * The target path of the runtime animation
  4249. */
  4250. private _targetPath;
  4251. /**
  4252. * The weight of the runtime animation
  4253. */
  4254. private _weight;
  4255. /**
  4256. * The ratio offset of the runtime animation
  4257. */
  4258. private _ratioOffset;
  4259. /**
  4260. * The previous delay of the runtime animation
  4261. */
  4262. private _previousDelay;
  4263. /**
  4264. * The previous ratio of the runtime animation
  4265. */
  4266. private _previousRatio;
  4267. /**
  4268. * Gets the current frame of the runtime animation
  4269. */
  4270. readonly currentFrame: number;
  4271. /**
  4272. * Gets the weight of the runtime animation
  4273. */
  4274. readonly weight: number;
  4275. /**
  4276. * Gets the current value of the runtime animation
  4277. */
  4278. readonly currentValue: any;
  4279. /**
  4280. * Gets the target path of the runtime animation
  4281. */
  4282. readonly targetPath: string;
  4283. /**
  4284. * Gets the actual target of the runtime animation
  4285. */
  4286. readonly target: any;
  4287. /**
  4288. * Create a new RuntimeAnimation object
  4289. * @param target defines the target of the animation
  4290. * @param animation defines the source animation object
  4291. * @param scene defines the hosting scene
  4292. * @param host defines the initiating Animatable
  4293. */
  4294. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4295. /**
  4296. * Gets the animation from the runtime animation
  4297. */
  4298. readonly animation: Animation;
  4299. /**
  4300. * Resets the runtime animation to the beginning
  4301. * @param restoreOriginal defines whether to restore the target property to the original value
  4302. */
  4303. reset(restoreOriginal?: boolean): void;
  4304. /**
  4305. * Specifies if the runtime animation is stopped
  4306. * @returns Boolean specifying if the runtime animation is stopped
  4307. */
  4308. isStopped(): boolean;
  4309. /**
  4310. * Disposes of the runtime animation
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Interpolates the animation from the current frame
  4315. * @param currentFrame The frame to interpolate the animation to
  4316. * @param repeatCount The number of times that the animation should loop
  4317. * @param loopMode The type of looping mode to use
  4318. * @param offsetValue Animation offset value
  4319. * @param highLimitValue The high limit value
  4320. * @returns The interpolated value
  4321. */
  4322. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4323. /**
  4324. * Apply the interpolated value to the target
  4325. * @param currentValue defines the value computed by the animation
  4326. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4327. */
  4328. setValue(currentValue: any, weight?: number): void;
  4329. private _setValue(target, currentValue, weight, targetIndex?);
  4330. /**
  4331. * Gets the loop pmode of the runtime animation
  4332. * @returns Loop Mode
  4333. */
  4334. private _getCorrectLoopMode();
  4335. /**
  4336. * Move the current animation to a given frame
  4337. * @param frame defines the frame to move to
  4338. */
  4339. goToFrame(frame: number): void;
  4340. /**
  4341. * @hidden Internal use only
  4342. */
  4343. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4344. /**
  4345. * Execute the current animation
  4346. * @param delay defines the delay to add to the current frame
  4347. * @param from defines the lower bound of the animation range
  4348. * @param to defines the upper bound of the animation range
  4349. * @param loop defines if the current animation must loop
  4350. * @param speedRatio defines the current speed ratio
  4351. * @param weight defines the weight of the animation (default is -1 so no weight)
  4352. * @returns a boolean indicating if the animation has ended
  4353. */
  4354. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4355. }
  4356. }
  4357. declare module BABYLON {
  4358. /**
  4359. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4361. */
  4362. class Analyser {
  4363. /**
  4364. * Gets or sets the smoothing
  4365. * @ignorenaming
  4366. */
  4367. SMOOTHING: number;
  4368. /**
  4369. * Gets or sets the FFT table size
  4370. * @ignorenaming
  4371. */
  4372. FFT_SIZE: number;
  4373. /**
  4374. * Gets or sets the bar graph amplitude
  4375. * @ignorenaming
  4376. */
  4377. BARGRAPHAMPLITUDE: number;
  4378. /**
  4379. * Gets or sets the position of the debug canvas
  4380. * @ignorenaming
  4381. */
  4382. DEBUGCANVASPOS: {
  4383. x: number;
  4384. y: number;
  4385. };
  4386. /**
  4387. * Gets or sets the debug canvas size
  4388. * @ignorenaming
  4389. */
  4390. DEBUGCANVASSIZE: {
  4391. width: number;
  4392. height: number;
  4393. };
  4394. private _byteFreqs;
  4395. private _byteTime;
  4396. private _floatFreqs;
  4397. private _webAudioAnalyser;
  4398. private _debugCanvas;
  4399. private _debugCanvasContext;
  4400. private _scene;
  4401. private _registerFunc;
  4402. private _audioEngine;
  4403. /**
  4404. * Creates a new analyser
  4405. * @param scene defines hosting scene
  4406. */
  4407. constructor(scene: Scene);
  4408. /**
  4409. * Get the number of data values you will have to play with for the visualization
  4410. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4411. * @returns a number
  4412. */
  4413. getFrequencyBinCount(): number;
  4414. /**
  4415. * Gets the current frequency data as a byte array
  4416. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4417. * @returns a Uint8Array
  4418. */
  4419. getByteFrequencyData(): Uint8Array;
  4420. /**
  4421. * Gets the current waveform as a byte array
  4422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4423. * @returns a Uint8Array
  4424. */
  4425. getByteTimeDomainData(): Uint8Array;
  4426. /**
  4427. * Gets the current frequency data as a float array
  4428. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4429. * @returns a Float32Array
  4430. */
  4431. getFloatFrequencyData(): Float32Array;
  4432. /**
  4433. * Renders the debug canvas
  4434. */
  4435. drawDebugCanvas(): void;
  4436. /**
  4437. * Stops rendering the debug canvas and removes it
  4438. */
  4439. stopDebugCanvas(): void;
  4440. /**
  4441. * Connects two audio nodes
  4442. * @param inputAudioNode defines first node to connect
  4443. * @param outputAudioNode defines second node to connect
  4444. */
  4445. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4446. /**
  4447. * Releases all associated resources
  4448. */
  4449. dispose(): void;
  4450. }
  4451. }
  4452. declare module BABYLON {
  4453. class AudioEngine {
  4454. private _audioContext;
  4455. private _audioContextInitialized;
  4456. canUseWebAudio: boolean;
  4457. masterGain: GainNode;
  4458. private _connectedAnalyser;
  4459. WarnedWebAudioUnsupported: boolean;
  4460. unlocked: boolean;
  4461. onAudioUnlocked: () => any;
  4462. isMP3supported: boolean;
  4463. isOGGsupported: boolean;
  4464. readonly audioContext: Nullable<AudioContext>;
  4465. constructor();
  4466. private _unlockiOSaudio();
  4467. private _initializeAudioContext();
  4468. dispose(): void;
  4469. getGlobalVolume(): number;
  4470. setGlobalVolume(newVolume: number): void;
  4471. connectToAnalyser(analyser: Analyser): void;
  4472. }
  4473. }
  4474. declare module BABYLON {
  4475. class Sound {
  4476. name: string;
  4477. autoplay: boolean;
  4478. loop: boolean;
  4479. useCustomAttenuation: boolean;
  4480. soundTrackId: number;
  4481. spatialSound: boolean;
  4482. refDistance: number;
  4483. rolloffFactor: number;
  4484. maxDistance: number;
  4485. distanceModel: string;
  4486. private _panningModel;
  4487. onended: () => any;
  4488. private _playbackRate;
  4489. private _streaming;
  4490. private _startTime;
  4491. private _startOffset;
  4492. private _position;
  4493. private _localDirection;
  4494. private _volume;
  4495. private _isReadyToPlay;
  4496. isPlaying: boolean;
  4497. isPaused: boolean;
  4498. private _isDirectional;
  4499. private _readyToPlayCallback;
  4500. private _audioBuffer;
  4501. private _soundSource;
  4502. private _streamingSource;
  4503. private _soundPanner;
  4504. private _soundGain;
  4505. private _inputAudioNode;
  4506. private _ouputAudioNode;
  4507. private _coneInnerAngle;
  4508. private _coneOuterAngle;
  4509. private _coneOuterGain;
  4510. private _scene;
  4511. private _connectedMesh;
  4512. private _customAttenuationFunction;
  4513. private _registerFunc;
  4514. private _isOutputConnected;
  4515. private _htmlAudioElement;
  4516. private _urlType;
  4517. /**
  4518. * Create a sound and attach it to a scene
  4519. * @param name Name of your sound
  4520. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4521. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4522. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4523. */
  4524. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4525. dispose(): void;
  4526. isReady(): boolean;
  4527. private _soundLoaded(audioData);
  4528. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4529. updateOptions(options: any): void;
  4530. private _createSpatialParameters();
  4531. private _updateSpatialParameters();
  4532. switchPanningModelToHRTF(): void;
  4533. switchPanningModelToEqualPower(): void;
  4534. private _switchPanningModel();
  4535. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4536. /**
  4537. * Transform this sound into a directional source
  4538. * @param coneInnerAngle Size of the inner cone in degree
  4539. * @param coneOuterAngle Size of the outer cone in degree
  4540. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4541. */
  4542. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4543. setPosition(newPosition: Vector3): void;
  4544. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4545. private _updateDirection();
  4546. updateDistanceFromListener(): void;
  4547. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4548. /**
  4549. * Play the sound
  4550. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4551. * @param offset (optional) Start the sound setting it at a specific time
  4552. */
  4553. play(time?: number, offset?: number): void;
  4554. private _onended();
  4555. /**
  4556. * Stop the sound
  4557. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4558. */
  4559. stop(time?: number): void;
  4560. pause(): void;
  4561. setVolume(newVolume: number, time?: number): void;
  4562. setPlaybackRate(newPlaybackRate: number): void;
  4563. getVolume(): number;
  4564. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4565. detachFromMesh(): void;
  4566. private _onRegisterAfterWorldMatrixUpdate(node);
  4567. clone(): Nullable<Sound>;
  4568. getAudioBuffer(): AudioBuffer | null;
  4569. serialize(): any;
  4570. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. class SoundTrack {
  4575. private _outputAudioNode;
  4576. private _scene;
  4577. id: number;
  4578. soundCollection: Array<Sound>;
  4579. private _isMainTrack;
  4580. private _connectedAnalyser;
  4581. private _options;
  4582. private _isInitialized;
  4583. constructor(scene: Scene, options?: any);
  4584. private _initializeSoundTrackAudioGraph();
  4585. dispose(): void;
  4586. AddSound(sound: Sound): void;
  4587. RemoveSound(sound: Sound): void;
  4588. setVolume(newVolume: number): void;
  4589. switchPanningModelToHRTF(): void;
  4590. switchPanningModelToEqualPower(): void;
  4591. connectToAnalyser(analyser: Analyser): void;
  4592. }
  4593. }
  4594. declare module BABYLON {
  4595. interface Behavior<T extends Node> {
  4596. name: string;
  4597. init(): void;
  4598. attach(node: T): void;
  4599. detach(): void;
  4600. }
  4601. }
  4602. declare module BABYLON {
  4603. /**
  4604. * Class used to store bone information
  4605. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4606. */
  4607. class Bone extends Node {
  4608. /**
  4609. * defines the bone name
  4610. */
  4611. name: string;
  4612. private static _tmpVecs;
  4613. private static _tmpQuat;
  4614. private static _tmpMats;
  4615. /**
  4616. * Gets the list of child bones
  4617. */
  4618. children: Bone[];
  4619. /** Gets the animations associated with this bone */
  4620. animations: Animation[];
  4621. /**
  4622. * Gets or sets bone length
  4623. */
  4624. length: number;
  4625. /**
  4626. * @hidden Internal only
  4627. * Set this value to map this bone to a different index in the transform matrices
  4628. * Set this value to -1 to exclude the bone from the transform matrices
  4629. */
  4630. _index: Nullable<number>;
  4631. private _skeleton;
  4632. private _localMatrix;
  4633. private _restPose;
  4634. private _baseMatrix;
  4635. private _absoluteTransform;
  4636. private _invertedAbsoluteTransform;
  4637. private _parent;
  4638. private _scalingDeterminant;
  4639. private _worldTransform;
  4640. private _localScaling;
  4641. private _localRotation;
  4642. private _localPosition;
  4643. private _needToDecompose;
  4644. private _needToCompose;
  4645. /** @hidden */
  4646. /** @hidden */
  4647. _matrix: Matrix;
  4648. /**
  4649. * Create a new bone
  4650. * @param name defines the bone name
  4651. * @param skeleton defines the parent skeleton
  4652. * @param parentBone defines the parent (can be null if the bone is the root)
  4653. * @param localMatrix defines the local matrix
  4654. * @param restPose defines the rest pose matrix
  4655. * @param baseMatrix defines the base matrix
  4656. * @param index defines index of the bone in the hiearchy
  4657. */
  4658. constructor(
  4659. /**
  4660. * defines the bone name
  4661. */
  4662. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4663. /**
  4664. * Gets the parent skeleton
  4665. * @returns a skeleton
  4666. */
  4667. getSkeleton(): Skeleton;
  4668. /**
  4669. * Gets parent bone
  4670. * @returns a bone or null if the bone is the root of the bone hierarchy
  4671. */
  4672. getParent(): Nullable<Bone>;
  4673. /**
  4674. * Sets the parent bone
  4675. * @param parent defines the parent (can be null if the bone is the root)
  4676. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4677. */
  4678. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4679. /**
  4680. * Gets the local matrix
  4681. * @returns a matrix
  4682. */
  4683. getLocalMatrix(): Matrix;
  4684. /**
  4685. * Gets the base matrix (initial matrix which remains unchanged)
  4686. * @returns a matrix
  4687. */
  4688. getBaseMatrix(): Matrix;
  4689. /**
  4690. * Gets the rest pose matrix
  4691. * @returns a matrix
  4692. */
  4693. getRestPose(): Matrix;
  4694. /**
  4695. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4696. */
  4697. getWorldMatrix(): Matrix;
  4698. /**
  4699. * Sets the local matrix to rest pose matrix
  4700. */
  4701. returnToRest(): void;
  4702. /**
  4703. * Gets the inverse of the absolute transform matrix.
  4704. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4705. * @returns a matrix
  4706. */
  4707. getInvertedAbsoluteTransform(): Matrix;
  4708. /**
  4709. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4710. * @returns a matrix
  4711. */
  4712. getAbsoluteTransform(): Matrix;
  4713. /** Gets or sets current position (in local space) */
  4714. position: Vector3;
  4715. /** Gets or sets current rotation (in local space) */
  4716. rotation: Vector3;
  4717. /** Gets or sets current rotation quaternion (in local space) */
  4718. rotationQuaternion: Quaternion;
  4719. /** Gets or sets current scaling (in local space) */
  4720. scaling: Vector3;
  4721. /**
  4722. * Gets the animation properties override
  4723. */
  4724. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4725. private _decompose();
  4726. private _compose();
  4727. /**
  4728. * Update the base and local matrices
  4729. * @param matrix defines the new base or local matrix
  4730. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4731. * @param updateLocalMatrix defines if the local matrix should be updated
  4732. */
  4733. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4734. /** @hidden */
  4735. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4736. /**
  4737. * Flag the bone as dirty (Forcing it to update everything)
  4738. */
  4739. markAsDirty(): void;
  4740. private _markAsDirtyAndCompose();
  4741. private _markAsDirtyAndDecompose();
  4742. /**
  4743. * Copy an animation range from another bone
  4744. * @param source defines the source bone
  4745. * @param rangeName defines the range name to copy
  4746. * @param frameOffset defines the frame offset
  4747. * @param rescaleAsRequired defines if rescaling must be applied if required
  4748. * @param skelDimensionsRatio defines the scaling ratio
  4749. * @returns true if operation was successful
  4750. */
  4751. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4752. /**
  4753. * Translate the bone in local or world space
  4754. * @param vec The amount to translate the bone
  4755. * @param space The space that the translation is in
  4756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4757. */
  4758. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4759. /**
  4760. * Set the postion of the bone in local or world space
  4761. * @param position The position to set the bone
  4762. * @param space The space that the position is in
  4763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4764. */
  4765. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4766. /**
  4767. * Set the absolute position of the bone (world space)
  4768. * @param position The position to set the bone
  4769. * @param mesh The mesh that this bone is attached to
  4770. */
  4771. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4772. /**
  4773. * Scale the bone on the x, y and z axes (in local space)
  4774. * @param x The amount to scale the bone on the x axis
  4775. * @param y The amount to scale the bone on the y axis
  4776. * @param z The amount to scale the bone on the z axis
  4777. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4778. */
  4779. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4780. /**
  4781. * Set the bone scaling in local space
  4782. * @param scale defines the scaling vector
  4783. */
  4784. setScale(scale: Vector3): void;
  4785. /**
  4786. * Gets the current scaling in local space
  4787. * @returns the current scaling vector
  4788. */
  4789. getScale(): Vector3;
  4790. /**
  4791. * Gets the current scaling in local space and stores it in a target vector
  4792. * @param result defines the target vector
  4793. */
  4794. getScaleToRef(result: Vector3): void;
  4795. /**
  4796. * Set the yaw, pitch, and roll of the bone in local or world space
  4797. * @param yaw The rotation of the bone on the y axis
  4798. * @param pitch The rotation of the bone on the x axis
  4799. * @param roll The rotation of the bone on the z axis
  4800. * @param space The space that the axes of rotation are in
  4801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4802. */
  4803. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4804. /**
  4805. * Add a rotation to the bone on an axis in local or world space
  4806. * @param axis The axis to rotate the bone on
  4807. * @param amount The amount to rotate the bone
  4808. * @param space The space that the axis is in
  4809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4810. */
  4811. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4812. /**
  4813. * Set the rotation of the bone to a particular axis angle in local or world space
  4814. * @param axis The axis to rotate the bone on
  4815. * @param angle The angle that the bone should be rotated to
  4816. * @param space The space that the axis is in
  4817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4818. */
  4819. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4820. /**
  4821. * Set the euler rotation of the bone in local of world space
  4822. * @param rotation The euler rotation that the bone should be set to
  4823. * @param space The space that the rotation is in
  4824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4825. */
  4826. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4827. /**
  4828. * Set the quaternion rotation of the bone in local of world space
  4829. * @param quat The quaternion rotation that the bone should be set to
  4830. * @param space The space that the rotation is in
  4831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4832. */
  4833. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4834. /**
  4835. * Set the rotation matrix of the bone in local of world space
  4836. * @param rotMat The rotation matrix that the bone should be set to
  4837. * @param space The space that the rotation is in
  4838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4839. */
  4840. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4841. private _rotateWithMatrix(rmat, space?, mesh?);
  4842. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4843. /**
  4844. * Get the position of the bone in local or world space
  4845. * @param space The space that the returned position is in
  4846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4847. * @returns The position of the bone
  4848. */
  4849. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4850. /**
  4851. * Copy the position of the bone to a vector3 in local or world space
  4852. * @param space The space that the returned position is in
  4853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4854. * @param result The vector3 to copy the position to
  4855. */
  4856. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4857. /**
  4858. * Get the absolute position of the bone (world space)
  4859. * @param mesh The mesh that this bone is attached to
  4860. * @returns The absolute position of the bone
  4861. */
  4862. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4863. /**
  4864. * Copy the absolute position of the bone (world space) to the result param
  4865. * @param mesh The mesh that this bone is attached to
  4866. * @param result The vector3 to copy the absolute position to
  4867. */
  4868. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4869. /**
  4870. * Compute the absolute transforms of this bone and its children
  4871. */
  4872. computeAbsoluteTransforms(): void;
  4873. /**
  4874. * Get the world direction from an axis that is in the local space of the bone
  4875. * @param localAxis The local direction that is used to compute the world direction
  4876. * @param mesh The mesh that this bone is attached to
  4877. * @returns The world direction
  4878. */
  4879. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4880. /**
  4881. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4882. * @param localAxis The local direction that is used to compute the world direction
  4883. * @param mesh The mesh that this bone is attached to
  4884. * @param result The vector3 that the world direction will be copied to
  4885. */
  4886. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4887. /**
  4888. * Get the euler rotation of the bone in local or world space
  4889. * @param space The space that the rotation should be in
  4890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4891. * @returns The euler rotation
  4892. */
  4893. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4894. /**
  4895. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4896. * @param space The space that the rotation should be in
  4897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4898. * @param result The vector3 that the rotation should be copied to
  4899. */
  4900. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4901. /**
  4902. * Get the quaternion rotation of the bone in either local or world space
  4903. * @param space The space that the rotation should be in
  4904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4905. * @returns The quaternion rotation
  4906. */
  4907. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4908. /**
  4909. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4910. * @param space The space that the rotation should be in
  4911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4912. * @param result The quaternion that the rotation should be copied to
  4913. */
  4914. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4915. /**
  4916. * Get the rotation matrix of the bone in local or world space
  4917. * @param space The space that the rotation should be in
  4918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4919. * @returns The rotation matrix
  4920. */
  4921. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4922. /**
  4923. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4924. * @param space The space that the rotation should be in
  4925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4926. * @param result The quaternion that the rotation should be copied to
  4927. */
  4928. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4929. /**
  4930. * Get the world position of a point that is in the local space of the bone
  4931. * @param position The local position
  4932. * @param mesh The mesh that this bone is attached to
  4933. * @returns The world position
  4934. */
  4935. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4936. /**
  4937. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4938. * @param position The local position
  4939. * @param mesh The mesh that this bone is attached to
  4940. * @param result The vector3 that the world position should be copied to
  4941. */
  4942. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4943. /**
  4944. * Get the local position of a point that is in world space
  4945. * @param position The world position
  4946. * @param mesh The mesh that this bone is attached to
  4947. * @returns The local position
  4948. */
  4949. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4950. /**
  4951. * Get the local position of a point that is in world space and copy it to the result param
  4952. * @param position The world position
  4953. * @param mesh The mesh that this bone is attached to
  4954. * @param result The vector3 that the local position should be copied to
  4955. */
  4956. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4957. }
  4958. }
  4959. declare module BABYLON {
  4960. /**
  4961. * Class used to apply inverse kinematics to bones
  4962. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4963. */
  4964. class BoneIKController {
  4965. private static _tmpVecs;
  4966. private static _tmpQuat;
  4967. private static _tmpMats;
  4968. /**
  4969. * Gets or sets the target mesh
  4970. */
  4971. targetMesh: AbstractMesh;
  4972. /** Gets or sets the mesh used as pole */
  4973. poleTargetMesh: AbstractMesh;
  4974. /**
  4975. * Gets or sets the bone used as pole
  4976. */
  4977. poleTargetBone: Nullable<Bone>;
  4978. /**
  4979. * Gets or sets the target position
  4980. */
  4981. targetPosition: Vector3;
  4982. /**
  4983. * Gets or sets the pole target position
  4984. */
  4985. poleTargetPosition: Vector3;
  4986. /**
  4987. * Gets or sets the pole target local offset
  4988. */
  4989. poleTargetLocalOffset: Vector3;
  4990. /**
  4991. * Gets or sets the pole angle
  4992. */
  4993. poleAngle: number;
  4994. /**
  4995. * Gets or sets the mesh associated with the controller
  4996. */
  4997. mesh: AbstractMesh;
  4998. /**
  4999. * 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)
  5000. */
  5001. slerpAmount: number;
  5002. private _bone1Quat;
  5003. private _bone1Mat;
  5004. private _bone2Ang;
  5005. private _bone1;
  5006. private _bone2;
  5007. private _bone1Length;
  5008. private _bone2Length;
  5009. private _maxAngle;
  5010. private _maxReach;
  5011. private _rightHandedSystem;
  5012. private _bendAxis;
  5013. private _slerping;
  5014. private _adjustRoll;
  5015. /**
  5016. * Gets or sets maximum allowed angle
  5017. */
  5018. maxAngle: number;
  5019. /**
  5020. * Creates a new BoneIKController
  5021. * @param mesh defines the mesh to control
  5022. * @param bone defines the bone to control
  5023. * @param options defines options to set up the controller
  5024. */
  5025. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5026. targetMesh?: AbstractMesh;
  5027. poleTargetMesh?: AbstractMesh;
  5028. poleTargetBone?: Bone;
  5029. poleTargetLocalOffset?: Vector3;
  5030. poleAngle?: number;
  5031. bendAxis?: Vector3;
  5032. maxAngle?: number;
  5033. slerpAmount?: number;
  5034. });
  5035. private _setMaxAngle(ang);
  5036. /**
  5037. * Force the controller to update the bones
  5038. */
  5039. update(): void;
  5040. }
  5041. }
  5042. declare module BABYLON {
  5043. /**
  5044. * Class used to make a bone look toward a point in space
  5045. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5046. */
  5047. class BoneLookController {
  5048. private static _tmpVecs;
  5049. private static _tmpQuat;
  5050. private static _tmpMats;
  5051. /**
  5052. * The target Vector3 that the bone will look at
  5053. */
  5054. target: Vector3;
  5055. /**
  5056. * The mesh that the bone is attached to
  5057. */
  5058. mesh: AbstractMesh;
  5059. /**
  5060. * The bone that will be looking to the target
  5061. */
  5062. bone: Bone;
  5063. /**
  5064. * The up axis of the coordinate system that is used when the bone is rotated
  5065. */
  5066. upAxis: Vector3;
  5067. /**
  5068. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5069. */
  5070. upAxisSpace: Space;
  5071. /**
  5072. * Used to make an adjustment to the yaw of the bone
  5073. */
  5074. adjustYaw: number;
  5075. /**
  5076. * Used to make an adjustment to the pitch of the bone
  5077. */
  5078. adjustPitch: number;
  5079. /**
  5080. * Used to make an adjustment to the roll of the bone
  5081. */
  5082. adjustRoll: number;
  5083. /**
  5084. * 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)
  5085. */
  5086. slerpAmount: number;
  5087. private _minYaw;
  5088. private _maxYaw;
  5089. private _minPitch;
  5090. private _maxPitch;
  5091. private _minYawSin;
  5092. private _minYawCos;
  5093. private _maxYawSin;
  5094. private _maxYawCos;
  5095. private _midYawConstraint;
  5096. private _minPitchTan;
  5097. private _maxPitchTan;
  5098. private _boneQuat;
  5099. private _slerping;
  5100. private _transformYawPitch;
  5101. private _transformYawPitchInv;
  5102. private _firstFrameSkipped;
  5103. private _yawRange;
  5104. private _fowardAxis;
  5105. /**
  5106. * Gets or sets the minimum yaw angle that the bone can look to
  5107. */
  5108. minYaw: number;
  5109. /**
  5110. * Gets or sets the maximum yaw angle that the bone can look to
  5111. */
  5112. maxYaw: number;
  5113. /**
  5114. * Gets or sets the minimum pitch angle that the bone can look to
  5115. */
  5116. minPitch: number;
  5117. /**
  5118. * Gets or sets the maximum pitch angle that the bone can look to
  5119. */
  5120. maxPitch: number;
  5121. /**
  5122. * Create a BoneLookController
  5123. * @param mesh the mesh that the bone belongs to
  5124. * @param bone the bone that will be looking to the target
  5125. * @param target the target Vector3 to look at
  5126. * @param settings optional settings:
  5127. * * maxYaw: the maximum angle the bone will yaw to
  5128. * * minYaw: the minimum angle the bone will yaw to
  5129. * * maxPitch: the maximum angle the bone will pitch to
  5130. * * minPitch: the minimum angle the bone will yaw to
  5131. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5132. * * upAxis: the up axis of the coordinate system
  5133. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5134. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5135. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5136. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5137. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5138. * * adjustRoll: used to make an adjustment to the roll of the bone
  5139. **/
  5140. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5141. maxYaw?: number;
  5142. minYaw?: number;
  5143. maxPitch?: number;
  5144. minPitch?: number;
  5145. slerpAmount?: number;
  5146. upAxis?: Vector3;
  5147. upAxisSpace?: Space;
  5148. yawAxis?: Vector3;
  5149. pitchAxis?: Vector3;
  5150. adjustYaw?: number;
  5151. adjustPitch?: number;
  5152. adjustRoll?: number;
  5153. });
  5154. /**
  5155. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5156. */
  5157. update(): void;
  5158. private _getAngleDiff(ang1, ang2);
  5159. private _getAngleBetween(ang1, ang2);
  5160. private _isAngleBetween(ang, ang1, ang2);
  5161. }
  5162. }
  5163. declare module BABYLON {
  5164. /**
  5165. * Class used to handle skinning animations
  5166. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5167. */
  5168. class Skeleton implements IAnimatable {
  5169. /** defines the skeleton name */
  5170. name: string;
  5171. /** defines the skeleton Id */
  5172. id: string;
  5173. /**
  5174. * Gets the list of child bones
  5175. */
  5176. bones: Bone[];
  5177. /**
  5178. * Gets an estimate of the dimension of the skeleton at rest
  5179. */
  5180. dimensionsAtRest: Vector3;
  5181. /**
  5182. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5183. */
  5184. needInitialSkinMatrix: boolean;
  5185. /**
  5186. * Gets the list of animations attached to this skeleton
  5187. */
  5188. animations: Array<Animation>;
  5189. private _scene;
  5190. private _isDirty;
  5191. private _transformMatrices;
  5192. private _meshesWithPoseMatrix;
  5193. private _animatables;
  5194. private _identity;
  5195. private _synchronizedWithMesh;
  5196. private _ranges;
  5197. private _lastAbsoluteTransformsUpdateId;
  5198. /**
  5199. * Specifies if the skeleton should be serialized
  5200. */
  5201. doNotSerialize: boolean;
  5202. private _animationPropertiesOverride;
  5203. /**
  5204. * Gets or sets the animation properties override
  5205. */
  5206. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5207. /**
  5208. * An observable triggered before computing the skeleton's matrices
  5209. */
  5210. onBeforeComputeObservable: Observable<Skeleton>;
  5211. /**
  5212. * Creates a new skeleton
  5213. * @param name defines the skeleton name
  5214. * @param id defines the skeleton Id
  5215. * @param scene defines the hosting scene
  5216. */
  5217. constructor(
  5218. /** defines the skeleton name */
  5219. name: string,
  5220. /** defines the skeleton Id */
  5221. id: string, scene: Scene);
  5222. /**
  5223. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5224. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5225. * @returns a Float32Array containing matrices data
  5226. */
  5227. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5228. /**
  5229. * Gets the current hosting scene
  5230. * @returns a scene object
  5231. */
  5232. getScene(): Scene;
  5233. /**
  5234. * Gets a string representing the current skeleton data
  5235. * @param fullDetails defines a boolean indicating if we want a verbose version
  5236. * @returns a string representing the current skeleton data
  5237. */
  5238. toString(fullDetails?: boolean): string;
  5239. /**
  5240. * Get bone's index searching by name
  5241. * @param name defines bone's name to search for
  5242. * @return the indice of the bone. Returns -1 if not found
  5243. */
  5244. getBoneIndexByName(name: string): number;
  5245. /**
  5246. * Creater a new animation range
  5247. * @param name defines the name of the range
  5248. * @param from defines the start key
  5249. * @param to defines the end key
  5250. */
  5251. createAnimationRange(name: string, from: number, to: number): void;
  5252. /**
  5253. * Delete a specific animation range
  5254. * @param name defines the name of the range
  5255. * @param deleteFrames defines if frames must be removed as well
  5256. */
  5257. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5258. /**
  5259. * Gets a specific animation range
  5260. * @param name defines the name of the range to look for
  5261. * @returns the requested animation range or null if not found
  5262. */
  5263. getAnimationRange(name: string): Nullable<AnimationRange>;
  5264. /**
  5265. * Gets the list of all animation ranges defined on this skeleton
  5266. * @returns an array
  5267. */
  5268. getAnimationRanges(): Nullable<AnimationRange>[];
  5269. /**
  5270. * Copy animation range from a source skeleton.
  5271. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5272. * @param source defines the source skeleton
  5273. * @param name defines the name of the range to copy
  5274. * @param rescaleAsRequired defines if rescaling must be applied if required
  5275. * @returns true if operation was successful
  5276. */
  5277. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5278. /**
  5279. * Forces the skeleton to go to rest pose
  5280. */
  5281. returnToRest(): void;
  5282. private _getHighestAnimationFrame();
  5283. /**
  5284. * Begin a specific animation range
  5285. * @param name defines the name of the range to start
  5286. * @param loop defines if looping must be turned on (false by default)
  5287. * @param speedRatio defines the speed ratio to apply (1 by default)
  5288. * @param onAnimationEnd defines a callback which will be called when animation will end
  5289. * @returns a new animatable
  5290. */
  5291. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5292. /** @hidden */
  5293. _markAsDirty(): void;
  5294. /** @hidden */
  5295. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5296. /** @hidden */
  5297. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5298. /** @hidden */
  5299. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5300. /**
  5301. * Build all resources required to render a skeleton
  5302. */
  5303. prepare(): void;
  5304. /**
  5305. * Gets the list of animatables currently running for this skeleton
  5306. * @returns an array of animatables
  5307. */
  5308. getAnimatables(): IAnimatable[];
  5309. /**
  5310. * Clone the current skeleton
  5311. * @param name defines the name of the new skeleton
  5312. * @param id defines the id of the enw skeleton
  5313. * @returns the new skeleton
  5314. */
  5315. clone(name: string, id: string): Skeleton;
  5316. /**
  5317. * Enable animation blending for this skeleton
  5318. * @param blendingSpeed defines the blending speed to apply
  5319. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5320. */
  5321. enableBlending(blendingSpeed?: number): void;
  5322. /**
  5323. * Releases all resources associated with the current skeleton
  5324. */
  5325. dispose(): void;
  5326. /**
  5327. * Serialize the skeleton in a JSON object
  5328. * @returns a JSON object
  5329. */
  5330. serialize(): any;
  5331. /**
  5332. * Creates a new skeleton from serialized data
  5333. * @param parsedSkeleton defines the serialized data
  5334. * @param scene defines the hosting scene
  5335. * @returns a new skeleton
  5336. */
  5337. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5338. /**
  5339. * Compute all node absolute transforms
  5340. * @param forceUpdate defines if computation must be done even if cache is up to date
  5341. */
  5342. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5343. /**
  5344. * Gets the root pose matrix
  5345. * @returns a matrix
  5346. */
  5347. getPoseMatrix(): Nullable<Matrix>;
  5348. /**
  5349. * Sorts bones per internal index
  5350. */
  5351. sortBones(): void;
  5352. private _sortBones(index, bones, visited);
  5353. }
  5354. }
  5355. declare module BABYLON {
  5356. class Collider {
  5357. /** Define if a collision was found */
  5358. collisionFound: boolean;
  5359. /**
  5360. * Define last intersection point in local space
  5361. */
  5362. intersectionPoint: Vector3;
  5363. /**
  5364. * Define last collided mesh
  5365. */
  5366. collidedMesh: Nullable<AbstractMesh>;
  5367. private _collisionPoint;
  5368. private _planeIntersectionPoint;
  5369. private _tempVector;
  5370. private _tempVector2;
  5371. private _tempVector3;
  5372. private _tempVector4;
  5373. private _edge;
  5374. private _baseToVertex;
  5375. private _destinationPoint;
  5376. private _slidePlaneNormal;
  5377. private _displacementVector;
  5378. _radius: Vector3;
  5379. _retry: number;
  5380. private _velocity;
  5381. private _basePoint;
  5382. private _epsilon;
  5383. _velocityWorldLength: number;
  5384. _basePointWorld: Vector3;
  5385. private _velocityWorld;
  5386. private _normalizedVelocity;
  5387. _initialVelocity: Vector3;
  5388. _initialPosition: Vector3;
  5389. private _nearestDistance;
  5390. private _collisionMask;
  5391. collisionMask: number;
  5392. /**
  5393. * Gets the plane normal used to compute the sliding response (in local space)
  5394. */
  5395. readonly slidePlaneNormal: Vector3;
  5396. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5397. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5398. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5399. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5400. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5401. _getResponse(pos: Vector3, vel: Vector3): void;
  5402. }
  5403. }
  5404. declare module BABYLON {
  5405. var CollisionWorker: string;
  5406. interface ICollisionCoordinator {
  5407. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5408. init(scene: Scene): void;
  5409. destroy(): void;
  5410. onMeshAdded(mesh: AbstractMesh): void;
  5411. onMeshUpdated(mesh: AbstractMesh): void;
  5412. onMeshRemoved(mesh: AbstractMesh): void;
  5413. onGeometryAdded(geometry: Geometry): void;
  5414. onGeometryUpdated(geometry: Geometry): void;
  5415. onGeometryDeleted(geometry: Geometry): void;
  5416. }
  5417. interface SerializedMesh {
  5418. id: string;
  5419. name: string;
  5420. uniqueId: number;
  5421. geometryId: Nullable<string>;
  5422. sphereCenter: Array<number>;
  5423. sphereRadius: number;
  5424. boxMinimum: Array<number>;
  5425. boxMaximum: Array<number>;
  5426. worldMatrixFromCache: any;
  5427. subMeshes: Array<SerializedSubMesh>;
  5428. checkCollisions: boolean;
  5429. }
  5430. interface SerializedSubMesh {
  5431. position: number;
  5432. verticesStart: number;
  5433. verticesCount: number;
  5434. indexStart: number;
  5435. indexCount: number;
  5436. hasMaterial: boolean;
  5437. sphereCenter: Array<number>;
  5438. sphereRadius: number;
  5439. boxMinimum: Array<number>;
  5440. boxMaximum: Array<number>;
  5441. }
  5442. /**
  5443. * Interface describing the value associated with a geometry
  5444. */
  5445. interface SerializedGeometry {
  5446. /**
  5447. * Defines the unique ID of the geometry
  5448. */
  5449. id: string;
  5450. /**
  5451. * Defines the array containing the positions
  5452. */
  5453. positions: Float32Array;
  5454. /**
  5455. * Defines the array containing the indices
  5456. */
  5457. indices: Uint32Array;
  5458. /**
  5459. * Defines the array containing the normals
  5460. */
  5461. normals: Float32Array;
  5462. }
  5463. interface BabylonMessage {
  5464. taskType: WorkerTaskType;
  5465. payload: InitPayload | CollidePayload | UpdatePayload;
  5466. }
  5467. interface SerializedColliderToWorker {
  5468. position: Array<number>;
  5469. velocity: Array<number>;
  5470. radius: Array<number>;
  5471. }
  5472. /** Defines supported task for worker process */
  5473. enum WorkerTaskType {
  5474. /** Initialization */
  5475. INIT = 0,
  5476. /** Update of geometry */
  5477. UPDATE = 1,
  5478. /** Evaluate collision */
  5479. COLLIDE = 2,
  5480. }
  5481. interface WorkerReply {
  5482. error: WorkerReplyType;
  5483. taskType: WorkerTaskType;
  5484. payload?: any;
  5485. }
  5486. interface CollisionReplyPayload {
  5487. newPosition: Array<number>;
  5488. collisionId: number;
  5489. collidedMeshUniqueId: number;
  5490. }
  5491. interface InitPayload {
  5492. }
  5493. interface CollidePayload {
  5494. collisionId: number;
  5495. collider: SerializedColliderToWorker;
  5496. maximumRetry: number;
  5497. excludedMeshUniqueId: Nullable<number>;
  5498. }
  5499. interface UpdatePayload {
  5500. updatedMeshes: {
  5501. [n: number]: SerializedMesh;
  5502. };
  5503. updatedGeometries: {
  5504. [s: string]: SerializedGeometry;
  5505. };
  5506. removedMeshes: Array<number>;
  5507. removedGeometries: Array<string>;
  5508. }
  5509. /** Defines kind of replies returned by worker */
  5510. enum WorkerReplyType {
  5511. /** Success */
  5512. SUCCESS = 0,
  5513. /** Unkown error */
  5514. UNKNOWN_ERROR = 1,
  5515. }
  5516. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5517. private _scene;
  5518. private _scaledPosition;
  5519. private _scaledVelocity;
  5520. private _collisionsCallbackArray;
  5521. private _init;
  5522. private _runningUpdated;
  5523. private _worker;
  5524. private _addUpdateMeshesList;
  5525. private _addUpdateGeometriesList;
  5526. private _toRemoveMeshesArray;
  5527. private _toRemoveGeometryArray;
  5528. constructor();
  5529. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5530. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5531. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5532. init(scene: Scene): void;
  5533. destroy(): void;
  5534. onMeshAdded(mesh: AbstractMesh): void;
  5535. onMeshUpdated: (transformNode: TransformNode) => void;
  5536. onMeshRemoved(mesh: AbstractMesh): void;
  5537. onGeometryAdded(geometry: Geometry): void;
  5538. onGeometryUpdated: (geometry: Geometry) => void;
  5539. onGeometryDeleted(geometry: Geometry): void;
  5540. private _afterRender;
  5541. private _onMessageFromWorker;
  5542. }
  5543. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5544. private _scene;
  5545. private _scaledPosition;
  5546. private _scaledVelocity;
  5547. private _finalPosition;
  5548. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5549. init(scene: Scene): void;
  5550. destroy(): void;
  5551. onMeshAdded(mesh: AbstractMesh): void;
  5552. onMeshUpdated(mesh: AbstractMesh): void;
  5553. onMeshRemoved(mesh: AbstractMesh): void;
  5554. onGeometryAdded(geometry: Geometry): void;
  5555. onGeometryUpdated(geometry: Geometry): void;
  5556. onGeometryDeleted(geometry: Geometry): void;
  5557. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5558. }
  5559. }
  5560. declare function importScripts(...urls: string[]): void;
  5561. declare const safePostMessage: any;
  5562. declare module BABYLON {
  5563. var WorkerIncluded: boolean;
  5564. class CollisionCache {
  5565. private _meshes;
  5566. private _geometries;
  5567. getMeshes(): {
  5568. [n: number]: SerializedMesh;
  5569. };
  5570. getGeometries(): {
  5571. [s: number]: SerializedGeometry;
  5572. };
  5573. getMesh(id: any): SerializedMesh;
  5574. addMesh(mesh: SerializedMesh): void;
  5575. removeMesh(uniqueId: number): void;
  5576. getGeometry(id: string): SerializedGeometry;
  5577. addGeometry(geometry: SerializedGeometry): void;
  5578. removeGeometry(id: string): void;
  5579. }
  5580. class CollideWorker {
  5581. collider: Collider;
  5582. private _collisionCache;
  5583. private finalPosition;
  5584. private collisionsScalingMatrix;
  5585. private collisionTranformationMatrix;
  5586. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5587. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5588. private checkCollision(mesh);
  5589. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5590. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5591. private checkSubmeshCollision(subMesh);
  5592. }
  5593. interface ICollisionDetector {
  5594. onInit(payload: InitPayload): void;
  5595. onUpdate(payload: UpdatePayload): void;
  5596. onCollision(payload: CollidePayload): void;
  5597. }
  5598. class CollisionDetectorTransferable implements ICollisionDetector {
  5599. private _collisionCache;
  5600. onInit(payload: InitPayload): void;
  5601. onUpdate(payload: UpdatePayload): void;
  5602. onCollision(payload: CollidePayload): void;
  5603. }
  5604. }
  5605. declare module BABYLON {
  5606. class IntersectionInfo {
  5607. bu: Nullable<number>;
  5608. bv: Nullable<number>;
  5609. distance: number;
  5610. faceId: number;
  5611. subMeshId: number;
  5612. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5613. }
  5614. class PickingInfo {
  5615. hit: boolean;
  5616. distance: number;
  5617. pickedPoint: Nullable<Vector3>;
  5618. pickedMesh: Nullable<AbstractMesh>;
  5619. bu: number;
  5620. bv: number;
  5621. faceId: number;
  5622. subMeshId: number;
  5623. pickedSprite: Nullable<Sprite>;
  5624. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5625. getTextureCoordinates(): Nullable<Vector2>;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. class BoundingBox implements ICullable {
  5630. vectors: Vector3[];
  5631. center: Vector3;
  5632. centerWorld: Vector3;
  5633. extendSize: Vector3;
  5634. extendSizeWorld: Vector3;
  5635. directions: Vector3[];
  5636. vectorsWorld: Vector3[];
  5637. minimumWorld: Vector3;
  5638. maximumWorld: Vector3;
  5639. minimum: Vector3;
  5640. maximum: Vector3;
  5641. private _worldMatrix;
  5642. /**
  5643. * Creates a new bounding box
  5644. * @param min defines the minimum vector (in local space)
  5645. * @param max defines the maximum vector (in local space)
  5646. */
  5647. constructor(min: Vector3, max: Vector3);
  5648. /**
  5649. * Recreates the entire bounding box from scratch
  5650. * @param min defines the new minimum vector (in local space)
  5651. * @param max defines the new maximum vector (in local space)
  5652. */
  5653. reConstruct(min: Vector3, max: Vector3): void;
  5654. getWorldMatrix(): Matrix;
  5655. setWorldMatrix(matrix: Matrix): BoundingBox;
  5656. _update(world: Matrix): void;
  5657. isInFrustum(frustumPlanes: Plane[]): boolean;
  5658. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5659. intersectsPoint(point: Vector3): boolean;
  5660. intersectsSphere(sphere: BoundingSphere): boolean;
  5661. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5662. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5663. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5664. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5665. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5666. }
  5667. }
  5668. declare module BABYLON {
  5669. interface ICullable {
  5670. isInFrustum(frustumPlanes: Plane[]): boolean;
  5671. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5672. }
  5673. class BoundingInfo implements ICullable {
  5674. minimum: Vector3;
  5675. maximum: Vector3;
  5676. boundingBox: BoundingBox;
  5677. boundingSphere: BoundingSphere;
  5678. private _isLocked;
  5679. constructor(minimum: Vector3, maximum: Vector3);
  5680. isLocked: boolean;
  5681. update(world: Matrix): void;
  5682. /**
  5683. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5684. * @param center New center of the bounding info
  5685. * @param extend New extend of the bounding info
  5686. */
  5687. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5688. isInFrustum(frustumPlanes: Plane[]): boolean;
  5689. /**
  5690. * Gets the world distance between the min and max points of the bounding box
  5691. */
  5692. readonly diagonalLength: number;
  5693. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5694. _checkCollision(collider: Collider): boolean;
  5695. intersectsPoint(point: Vector3): boolean;
  5696. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5697. }
  5698. }
  5699. declare module BABYLON {
  5700. class BoundingSphere {
  5701. center: Vector3;
  5702. radius: number;
  5703. centerWorld: Vector3;
  5704. radiusWorld: number;
  5705. minimum: Vector3;
  5706. maximum: Vector3;
  5707. private _tempRadiusVector;
  5708. /**
  5709. * Creates a new bounding sphere
  5710. * @param min defines the minimum vector (in local space)
  5711. * @param max defines the maximum vector (in local space)
  5712. */
  5713. constructor(min: Vector3, max: Vector3);
  5714. /**
  5715. * Recreates the entire bounding sphere from scratch
  5716. * @param min defines the new minimum vector (in local space)
  5717. * @param max defines the new maximum vector (in local space)
  5718. */
  5719. reConstruct(min: Vector3, max: Vector3): void;
  5720. _update(world: Matrix): void;
  5721. isInFrustum(frustumPlanes: Plane[]): boolean;
  5722. intersectsPoint(point: Vector3): boolean;
  5723. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5724. }
  5725. }
  5726. declare module BABYLON {
  5727. class Ray {
  5728. origin: Vector3;
  5729. direction: Vector3;
  5730. length: number;
  5731. private _edge1;
  5732. private _edge2;
  5733. private _pvec;
  5734. private _tvec;
  5735. private _qvec;
  5736. private _tmpRay;
  5737. constructor(origin: Vector3, direction: Vector3, length?: number);
  5738. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5739. intersectsBox(box: BoundingBox): boolean;
  5740. intersectsSphere(sphere: BoundingSphere): boolean;
  5741. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5742. intersectsPlane(plane: Plane): Nullable<number>;
  5743. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5744. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5745. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5746. private static smallnum;
  5747. private static rayl;
  5748. /**
  5749. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5750. * @param sega the first point of the segment to test the intersection against
  5751. * @param segb the second point of the segment to test the intersection against
  5752. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5753. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5754. */
  5755. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5756. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5757. static Zero(): Ray;
  5758. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5759. /**
  5760. * 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
  5761. * transformed to the given world matrix.
  5762. * @param origin The origin point
  5763. * @param end The end point
  5764. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5765. */
  5766. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5767. static Transform(ray: Ray, matrix: Matrix): Ray;
  5768. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5769. }
  5770. }
  5771. declare module BABYLON {
  5772. class ArcRotateCamera extends TargetCamera {
  5773. alpha: number;
  5774. beta: number;
  5775. radius: number;
  5776. protected _target: Vector3;
  5777. protected _targetHost: Nullable<AbstractMesh>;
  5778. target: Vector3;
  5779. inertialAlphaOffset: number;
  5780. inertialBetaOffset: number;
  5781. inertialRadiusOffset: number;
  5782. lowerAlphaLimit: Nullable<number>;
  5783. upperAlphaLimit: Nullable<number>;
  5784. lowerBetaLimit: number;
  5785. upperBetaLimit: number;
  5786. lowerRadiusLimit: Nullable<number>;
  5787. upperRadiusLimit: Nullable<number>;
  5788. inertialPanningX: number;
  5789. inertialPanningY: number;
  5790. pinchToPanMaxDistance: number;
  5791. panningDistanceLimit: Nullable<number>;
  5792. panningOriginTarget: Vector3;
  5793. panningInertia: number;
  5794. angularSensibilityX: number;
  5795. angularSensibilityY: number;
  5796. pinchPrecision: number;
  5797. pinchDeltaPercentage: number;
  5798. panningSensibility: number;
  5799. keysUp: number[];
  5800. keysDown: number[];
  5801. keysLeft: number[];
  5802. keysRight: number[];
  5803. wheelPrecision: number;
  5804. wheelDeltaPercentage: number;
  5805. zoomOnFactor: number;
  5806. targetScreenOffset: Vector2;
  5807. allowUpsideDown: boolean;
  5808. _viewMatrix: Matrix;
  5809. _useCtrlForPanning: boolean;
  5810. _panningMouseButton: number;
  5811. inputs: ArcRotateCameraInputsManager;
  5812. _reset: () => void;
  5813. panningAxis: Vector3;
  5814. protected _localDirection: Vector3;
  5815. protected _transformedDirection: Vector3;
  5816. private _bouncingBehavior;
  5817. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5818. useBouncingBehavior: boolean;
  5819. private _framingBehavior;
  5820. readonly framingBehavior: Nullable<FramingBehavior>;
  5821. useFramingBehavior: boolean;
  5822. private _autoRotationBehavior;
  5823. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5824. useAutoRotationBehavior: boolean;
  5825. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5826. onCollide: (collidedMesh: AbstractMesh) => void;
  5827. checkCollisions: boolean;
  5828. collisionRadius: Vector3;
  5829. protected _collider: Collider;
  5830. protected _previousPosition: Vector3;
  5831. protected _collisionVelocity: Vector3;
  5832. protected _newPosition: Vector3;
  5833. protected _previousAlpha: number;
  5834. protected _previousBeta: number;
  5835. protected _previousRadius: number;
  5836. protected _collisionTriggered: boolean;
  5837. protected _targetBoundingCenter: Nullable<Vector3>;
  5838. private _computationVector;
  5839. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5840. _initCache(): void;
  5841. _updateCache(ignoreParentClass?: boolean): void;
  5842. protected _getTargetPosition(): Vector3;
  5843. /**
  5844. * Store current camera state (fov, position, etc..)
  5845. */
  5846. private _storedAlpha;
  5847. private _storedBeta;
  5848. private _storedRadius;
  5849. private _storedTarget;
  5850. storeState(): Camera;
  5851. /**
  5852. * Restored camera state. You must call storeState() first
  5853. */
  5854. _restoreStateValues(): boolean;
  5855. _isSynchronizedViewMatrix(): boolean;
  5856. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5857. detachControl(element: HTMLElement): void;
  5858. _checkInputs(): void;
  5859. protected _checkLimits(): void;
  5860. rebuildAnglesAndRadius(): void;
  5861. setPosition(position: Vector3): void;
  5862. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5863. _getViewMatrix(): Matrix;
  5864. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5865. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5866. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5867. min: Vector3;
  5868. max: Vector3;
  5869. distance: number;
  5870. }, doNotUpdateMaxZ?: boolean): void;
  5871. /**
  5872. * @override
  5873. * Override Camera.createRigCamera
  5874. */
  5875. createRigCamera(name: string, cameraIndex: number): Camera;
  5876. /**
  5877. * @override
  5878. * Override Camera._updateRigCameras
  5879. */
  5880. _updateRigCameras(): void;
  5881. dispose(): void;
  5882. getClassName(): string;
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5887. constructor(camera: ArcRotateCamera);
  5888. addMouseWheel(): ArcRotateCameraInputsManager;
  5889. addPointers(): ArcRotateCameraInputsManager;
  5890. addKeyboard(): ArcRotateCameraInputsManager;
  5891. addGamepad(): ArcRotateCameraInputsManager;
  5892. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5893. }
  5894. }
  5895. declare module BABYLON {
  5896. class Camera extends Node {
  5897. inputs: CameraInputsManager<Camera>;
  5898. private static _PERSPECTIVE_CAMERA;
  5899. private static _ORTHOGRAPHIC_CAMERA;
  5900. private static _FOVMODE_VERTICAL_FIXED;
  5901. private static _FOVMODE_HORIZONTAL_FIXED;
  5902. private static _RIG_MODE_NONE;
  5903. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5904. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5905. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5906. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5907. private static _RIG_MODE_VR;
  5908. private static _RIG_MODE_WEBVR;
  5909. static readonly PERSPECTIVE_CAMERA: number;
  5910. static readonly ORTHOGRAPHIC_CAMERA: number;
  5911. /**
  5912. * This is the default FOV mode for perspective cameras.
  5913. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5914. *
  5915. */
  5916. static readonly FOVMODE_VERTICAL_FIXED: number;
  5917. /**
  5918. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5919. *
  5920. */
  5921. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5922. static readonly RIG_MODE_NONE: number;
  5923. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5924. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5925. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5926. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5927. static readonly RIG_MODE_VR: number;
  5928. static readonly RIG_MODE_WEBVR: number;
  5929. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5930. static UseAlternateWebVRRendering: boolean;
  5931. position: Vector3;
  5932. /**
  5933. * The vector the camera should consider as up.
  5934. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5935. */
  5936. upVector: Vector3;
  5937. orthoLeft: Nullable<number>;
  5938. orthoRight: Nullable<number>;
  5939. orthoBottom: Nullable<number>;
  5940. orthoTop: Nullable<number>;
  5941. /**
  5942. * FOV is set in Radians. (default is 0.8)
  5943. */
  5944. fov: number;
  5945. minZ: number;
  5946. maxZ: number;
  5947. inertia: number;
  5948. mode: number;
  5949. isIntermediate: boolean;
  5950. viewport: Viewport;
  5951. /**
  5952. * Restricts the camera to viewing objects with the same layerMask.
  5953. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5954. */
  5955. layerMask: number;
  5956. /**
  5957. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5958. */
  5959. fovMode: number;
  5960. cameraRigMode: number;
  5961. interaxialDistance: number;
  5962. isStereoscopicSideBySide: boolean;
  5963. _cameraRigParams: any;
  5964. _rigCameras: Camera[];
  5965. _rigPostProcess: Nullable<PostProcess>;
  5966. protected _webvrViewMatrix: Matrix;
  5967. _skipRendering: boolean;
  5968. _alternateCamera: Camera;
  5969. customRenderTargets: RenderTargetTexture[];
  5970. onViewMatrixChangedObservable: Observable<Camera>;
  5971. onProjectionMatrixChangedObservable: Observable<Camera>;
  5972. onAfterCheckInputsObservable: Observable<Camera>;
  5973. onRestoreStateObservable: Observable<Camera>;
  5974. private _computedViewMatrix;
  5975. _projectionMatrix: Matrix;
  5976. private _doNotComputeProjectionMatrix;
  5977. private _worldMatrix;
  5978. _postProcesses: Nullable<PostProcess>[];
  5979. private _transformMatrix;
  5980. _activeMeshes: SmartArray<AbstractMesh>;
  5981. protected _globalPosition: Vector3;
  5982. private _frustumPlanes;
  5983. private _refreshFrustumPlanes;
  5984. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5985. private _storedFov;
  5986. private _stateStored;
  5987. /**
  5988. * Store current camera state (fov, position, etc..)
  5989. */
  5990. storeState(): Camera;
  5991. /**
  5992. * Restores the camera state values if it has been stored. You must call storeState() first
  5993. */
  5994. protected _restoreStateValues(): boolean;
  5995. /**
  5996. * Restored camera state. You must call storeState() first
  5997. */
  5998. restoreState(): boolean;
  5999. getClassName(): string;
  6000. /**
  6001. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6002. */
  6003. toString(fullDetails?: boolean): string;
  6004. readonly globalPosition: Vector3;
  6005. getActiveMeshes(): SmartArray<AbstractMesh>;
  6006. isActiveMesh(mesh: Mesh): boolean;
  6007. /**
  6008. * Is this camera ready to be used/rendered
  6009. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6010. * @return true if the camera is ready
  6011. */
  6012. isReady(completeCheck?: boolean): boolean;
  6013. _initCache(): void;
  6014. _updateCache(ignoreParentClass?: boolean): void;
  6015. _isSynchronized(): boolean;
  6016. _isSynchronizedViewMatrix(): boolean;
  6017. _isSynchronizedProjectionMatrix(): boolean;
  6018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6019. detachControl(element: HTMLElement): void;
  6020. update(): void;
  6021. _checkInputs(): void;
  6022. readonly rigCameras: Camera[];
  6023. readonly rigPostProcess: Nullable<PostProcess>;
  6024. /**
  6025. * Internal, gets the first post proces.
  6026. * @returns the first post process to be run on this camera.
  6027. */
  6028. _getFirstPostProcess(): Nullable<PostProcess>;
  6029. private _cascadePostProcessesToRigCams();
  6030. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6031. detachPostProcess(postProcess: PostProcess): void;
  6032. getWorldMatrix(): Matrix;
  6033. _getViewMatrix(): Matrix;
  6034. getViewMatrix(force?: boolean): Matrix;
  6035. freezeProjectionMatrix(projection?: Matrix): void;
  6036. unfreezeProjectionMatrix(): void;
  6037. getProjectionMatrix(force?: boolean): Matrix;
  6038. getTranformationMatrix(): Matrix;
  6039. private updateFrustumPlanes();
  6040. isInFrustum(target: ICullable): boolean;
  6041. isCompletelyInFrustum(target: ICullable): boolean;
  6042. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6043. /**
  6044. * Releases resources associated with this node.
  6045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6047. */
  6048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6049. readonly leftCamera: Nullable<FreeCamera>;
  6050. readonly rightCamera: Nullable<FreeCamera>;
  6051. getLeftTarget(): Nullable<Vector3>;
  6052. getRightTarget(): Nullable<Vector3>;
  6053. setCameraRigMode(mode: number, rigParams: any): void;
  6054. private _getVRProjectionMatrix();
  6055. protected _updateCameraRotationMatrix(): void;
  6056. protected _updateWebVRCameraRotationMatrix(): void;
  6057. /**
  6058. * This function MUST be overwritten by the different WebVR cameras available.
  6059. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6060. */
  6061. protected _getWebVRProjectionMatrix(): Matrix;
  6062. /**
  6063. * This function MUST be overwritten by the different WebVR cameras available.
  6064. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6065. */
  6066. protected _getWebVRViewMatrix(): Matrix;
  6067. setCameraRigParameter(name: string, value: any): void;
  6068. /**
  6069. * needs to be overridden by children so sub has required properties to be copied
  6070. */
  6071. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6072. /**
  6073. * May need to be overridden by children
  6074. */
  6075. _updateRigCameras(): void;
  6076. _setupInputs(): void;
  6077. serialize(): any;
  6078. clone(name: string): Camera;
  6079. getDirection(localAxis: Vector3): Vector3;
  6080. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6081. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6082. computeWorldMatrix(): Matrix;
  6083. static Parse(parsedCamera: any, scene: Scene): Camera;
  6084. }
  6085. }
  6086. declare module BABYLON {
  6087. var CameraInputTypes: {};
  6088. interface ICameraInput<TCamera extends Camera> {
  6089. camera: Nullable<TCamera>;
  6090. getClassName(): string;
  6091. getSimpleName(): string;
  6092. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6093. detachControl: (element: Nullable<HTMLElement>) => void;
  6094. checkInputs?: () => void;
  6095. }
  6096. interface CameraInputsMap<TCamera extends Camera> {
  6097. [name: string]: ICameraInput<TCamera>;
  6098. [idx: number]: ICameraInput<TCamera>;
  6099. }
  6100. class CameraInputsManager<TCamera extends Camera> {
  6101. attached: CameraInputsMap<TCamera>;
  6102. attachedElement: Nullable<HTMLElement>;
  6103. noPreventDefault: boolean;
  6104. camera: TCamera;
  6105. checkInputs: () => void;
  6106. constructor(camera: TCamera);
  6107. /**
  6108. * Add an input method to a camera.
  6109. * builtin inputs example: camera.inputs.addGamepad();
  6110. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6111. * @param input camera input method
  6112. */
  6113. add(input: ICameraInput<TCamera>): void;
  6114. /**
  6115. * Remove a specific input method from a camera
  6116. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6117. * @param inputToRemove camera input method
  6118. */
  6119. remove(inputToRemove: ICameraInput<TCamera>): void;
  6120. removeByType(inputType: string): void;
  6121. private _addCheckInputs(fn);
  6122. attachInput(input: ICameraInput<TCamera>): void;
  6123. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6124. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6125. rebuildInputCheck(): void;
  6126. /**
  6127. * Remove all attached input methods from a camera
  6128. */
  6129. clear(): void;
  6130. serialize(serializedCamera: any): void;
  6131. parse(parsedCamera: any): void;
  6132. }
  6133. }
  6134. declare module BABYLON {
  6135. /**
  6136. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6137. * being tilted forward or back and left or right.
  6138. */
  6139. class DeviceOrientationCamera extends FreeCamera {
  6140. private _initialQuaternion;
  6141. private _quaternionCache;
  6142. /**
  6143. * Creates a new device orientation camera
  6144. * @param name The name of the camera
  6145. * @param position The start position camera
  6146. * @param scene The scene the camera belongs to
  6147. */
  6148. constructor(name: string, position: Vector3, scene: Scene);
  6149. /**
  6150. * Gets the current instance class name ("DeviceOrientationCamera").
  6151. * This helps avoiding instanceof at run time.
  6152. * @returns the class name
  6153. */
  6154. getClassName(): string;
  6155. /**
  6156. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6157. */
  6158. _checkInputs(): void;
  6159. /**
  6160. * Reset the camera to its default orientation on the specified axis only.
  6161. * @param axis The axis to reset
  6162. */
  6163. resetToCurrentRotation(axis?: Axis): void;
  6164. }
  6165. }
  6166. declare module BABYLON {
  6167. class FollowCamera extends TargetCamera {
  6168. radius: number;
  6169. rotationOffset: number;
  6170. heightOffset: number;
  6171. cameraAcceleration: number;
  6172. maxCameraSpeed: number;
  6173. lockedTarget: Nullable<AbstractMesh>;
  6174. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6175. private getRadians(degrees);
  6176. private follow(cameraTarget);
  6177. _checkInputs(): void;
  6178. getClassName(): string;
  6179. }
  6180. class ArcFollowCamera extends TargetCamera {
  6181. alpha: number;
  6182. beta: number;
  6183. radius: number;
  6184. target: Nullable<AbstractMesh>;
  6185. private _cartesianCoordinates;
  6186. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6187. private follow();
  6188. _checkInputs(): void;
  6189. getClassName(): string;
  6190. }
  6191. }
  6192. declare module BABYLON {
  6193. class FreeCamera extends TargetCamera {
  6194. ellipsoid: Vector3;
  6195. ellipsoidOffset: Vector3;
  6196. checkCollisions: boolean;
  6197. applyGravity: boolean;
  6198. inputs: FreeCameraInputsManager;
  6199. /**
  6200. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6201. * Higher values reduce sensitivity.
  6202. */
  6203. /**
  6204. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6205. * Higher values reduce sensitivity.
  6206. */
  6207. angularSensibility: number;
  6208. keysUp: number[];
  6209. keysDown: number[];
  6210. keysLeft: number[];
  6211. keysRight: number[];
  6212. onCollide: (collidedMesh: AbstractMesh) => void;
  6213. private _collider;
  6214. private _needMoveForGravity;
  6215. private _oldPosition;
  6216. private _diffPosition;
  6217. private _newPosition;
  6218. _localDirection: Vector3;
  6219. _transformedDirection: Vector3;
  6220. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6222. detachControl(element: HTMLElement): void;
  6223. private _collisionMask;
  6224. collisionMask: number;
  6225. _collideWithWorld(displacement: Vector3): void;
  6226. private _onCollisionPositionChange;
  6227. _checkInputs(): void;
  6228. _decideIfNeedsToMove(): boolean;
  6229. _updatePosition(): void;
  6230. dispose(): void;
  6231. getClassName(): string;
  6232. }
  6233. }
  6234. declare module BABYLON {
  6235. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6236. constructor(camera: FreeCamera);
  6237. addKeyboard(): FreeCameraInputsManager;
  6238. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6239. addGamepad(): FreeCameraInputsManager;
  6240. addDeviceOrientation(): FreeCameraInputsManager;
  6241. addTouch(): FreeCameraInputsManager;
  6242. addVirtualJoystick(): FreeCameraInputsManager;
  6243. }
  6244. }
  6245. declare module BABYLON {
  6246. class GamepadCamera extends UniversalCamera {
  6247. gamepadAngularSensibility: number;
  6248. gamepadMoveSensibility: number;
  6249. constructor(name: string, position: Vector3, scene: Scene);
  6250. getClassName(): string;
  6251. }
  6252. }
  6253. declare module BABYLON {
  6254. /**
  6255. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6256. */
  6257. class AnaglyphFreeCamera extends FreeCamera {
  6258. /**
  6259. * Creates a new AnaglyphFreeCamera
  6260. * @param name defines camera name
  6261. * @param position defines initial position
  6262. * @param interaxialDistance defines distance between each color axis
  6263. * @param scene defines the hosting scene
  6264. */
  6265. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6266. /**
  6267. * Gets camera class name
  6268. * @returns AnaglyphFreeCamera
  6269. */
  6270. getClassName(): string;
  6271. }
  6272. /**
  6273. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6274. */
  6275. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6276. /**
  6277. * Creates a new AnaglyphArcRotateCamera
  6278. * @param name defines camera name
  6279. * @param alpha defines alpha angle (in radians)
  6280. * @param beta defines beta angle (in radians)
  6281. * @param radius defines radius
  6282. * @param target defines camera target
  6283. * @param interaxialDistance defines distance between each color axis
  6284. * @param scene defines the hosting scene
  6285. */
  6286. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6287. /**
  6288. * Gets camera class name
  6289. * @returns AnaglyphArcRotateCamera
  6290. */
  6291. getClassName(): string;
  6292. }
  6293. /**
  6294. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6295. */
  6296. class AnaglyphGamepadCamera extends GamepadCamera {
  6297. /**
  6298. * Creates a new AnaglyphGamepadCamera
  6299. * @param name defines camera name
  6300. * @param position defines initial position
  6301. * @param interaxialDistance defines distance between each color axis
  6302. * @param scene defines the hosting scene
  6303. */
  6304. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6305. /**
  6306. * Gets camera class name
  6307. * @returns AnaglyphGamepadCamera
  6308. */
  6309. getClassName(): string;
  6310. }
  6311. /**
  6312. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6313. */
  6314. class AnaglyphUniversalCamera extends UniversalCamera {
  6315. /**
  6316. * Creates a new AnaglyphUniversalCamera
  6317. * @param name defines camera name
  6318. * @param position defines initial position
  6319. * @param interaxialDistance defines distance between each color axis
  6320. * @param scene defines the hosting scene
  6321. */
  6322. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6323. /**
  6324. * Gets camera class name
  6325. * @returns AnaglyphUniversalCamera
  6326. */
  6327. getClassName(): string;
  6328. }
  6329. /**
  6330. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6331. */
  6332. class StereoscopicFreeCamera extends FreeCamera {
  6333. /**
  6334. * Creates a new StereoscopicFreeCamera
  6335. * @param name defines camera name
  6336. * @param position defines initial position
  6337. * @param interaxialDistance defines distance between each color axis
  6338. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6339. * @param scene defines the hosting scene
  6340. */
  6341. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6342. /**
  6343. * Gets camera class name
  6344. * @returns StereoscopicFreeCamera
  6345. */
  6346. getClassName(): string;
  6347. }
  6348. /**
  6349. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6350. */
  6351. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6352. /**
  6353. * Creates a new StereoscopicArcRotateCamera
  6354. * @param name defines camera name
  6355. * @param alpha defines alpha angle (in radians)
  6356. * @param beta defines beta angle (in radians)
  6357. * @param radius defines radius
  6358. * @param target defines camera target
  6359. * @param interaxialDistance defines distance between each color axis
  6360. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6361. * @param scene defines the hosting scene
  6362. */
  6363. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6364. /**
  6365. * Gets camera class name
  6366. * @returns StereoscopicArcRotateCamera
  6367. */
  6368. getClassName(): string;
  6369. }
  6370. /**
  6371. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6372. */
  6373. class StereoscopicGamepadCamera extends GamepadCamera {
  6374. /**
  6375. * Creates a new StereoscopicGamepadCamera
  6376. * @param name defines camera name
  6377. * @param position defines initial position
  6378. * @param interaxialDistance defines distance between each color axis
  6379. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6380. * @param scene defines the hosting scene
  6381. */
  6382. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6383. /**
  6384. * Gets camera class name
  6385. * @returns StereoscopicGamepadCamera
  6386. */
  6387. getClassName(): string;
  6388. }
  6389. /**
  6390. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6391. */
  6392. class StereoscopicUniversalCamera extends UniversalCamera {
  6393. /**
  6394. * Creates a new StereoscopicUniversalCamera
  6395. * @param name defines camera name
  6396. * @param position defines initial position
  6397. * @param interaxialDistance defines distance between each color axis
  6398. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6399. * @param scene defines the hosting scene
  6400. */
  6401. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6402. /**
  6403. * Gets camera class name
  6404. * @returns StereoscopicUniversalCamera
  6405. */
  6406. getClassName(): string;
  6407. }
  6408. }
  6409. declare module BABYLON {
  6410. class TargetCamera extends Camera {
  6411. cameraDirection: Vector3;
  6412. cameraRotation: Vector2;
  6413. rotation: Vector3;
  6414. rotationQuaternion: Quaternion;
  6415. speed: number;
  6416. noRotationConstraint: boolean;
  6417. lockedTarget: any;
  6418. _currentTarget: Vector3;
  6419. _viewMatrix: Matrix;
  6420. _camMatrix: Matrix;
  6421. _cameraTransformMatrix: Matrix;
  6422. _cameraRotationMatrix: Matrix;
  6423. private _rigCamTransformMatrix;
  6424. _referencePoint: Vector3;
  6425. private _currentUpVector;
  6426. _transformedReferencePoint: Vector3;
  6427. protected _globalCurrentTarget: Vector3;
  6428. protected _globalCurrentUpVector: Vector3;
  6429. _reset: () => void;
  6430. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6431. getFrontPosition(distance: number): Vector3;
  6432. _getLockedTargetPosition(): Nullable<Vector3>;
  6433. /**
  6434. * Store current camera state (fov, position, etc..)
  6435. */
  6436. private _storedPosition;
  6437. private _storedRotation;
  6438. private _storedRotationQuaternion;
  6439. storeState(): Camera;
  6440. /**
  6441. * Restored camera state. You must call storeState() first
  6442. */
  6443. _restoreStateValues(): boolean;
  6444. _initCache(): void;
  6445. _updateCache(ignoreParentClass?: boolean): void;
  6446. _isSynchronizedViewMatrix(): boolean;
  6447. _computeLocalCameraSpeed(): number;
  6448. setTarget(target: Vector3): void;
  6449. /**
  6450. * Return the current target position of the camera. This value is expressed in local space.
  6451. */
  6452. getTarget(): Vector3;
  6453. _decideIfNeedsToMove(): boolean;
  6454. _updatePosition(): void;
  6455. _checkInputs(): void;
  6456. protected _updateCameraRotationMatrix(): void;
  6457. _getViewMatrix(): Matrix;
  6458. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6459. /**
  6460. * @override
  6461. * Override Camera.createRigCamera
  6462. */
  6463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6464. /**
  6465. * @override
  6466. * Override Camera._updateRigCameras
  6467. */
  6468. _updateRigCameras(): void;
  6469. private _getRigCamPosition(halfSpace, result);
  6470. getClassName(): string;
  6471. }
  6472. }
  6473. declare module BABYLON {
  6474. class TouchCamera extends FreeCamera {
  6475. touchAngularSensibility: number;
  6476. touchMoveSensibility: number;
  6477. constructor(name: string, position: Vector3, scene: Scene);
  6478. getClassName(): string;
  6479. _setupInputs(): void;
  6480. }
  6481. }
  6482. declare module BABYLON {
  6483. class UniversalCamera extends TouchCamera {
  6484. gamepadAngularSensibility: number;
  6485. gamepadMoveSensibility: number;
  6486. constructor(name: string, position: Vector3, scene: Scene);
  6487. getClassName(): string;
  6488. }
  6489. }
  6490. declare module BABYLON {
  6491. class VirtualJoysticksCamera extends FreeCamera {
  6492. constructor(name: string, position: Vector3, scene: Scene);
  6493. getClassName(): string;
  6494. }
  6495. }
  6496. interface VRDisplay extends EventTarget {
  6497. /**
  6498. * Dictionary of capabilities describing the VRDisplay.
  6499. */
  6500. readonly capabilities: VRDisplayCapabilities;
  6501. /**
  6502. * z-depth defining the far plane of the eye view frustum
  6503. * enables mapping of values in the render target depth
  6504. * attachment to scene coordinates. Initially set to 10000.0.
  6505. */
  6506. depthFar: number;
  6507. /**
  6508. * z-depth defining the near plane of the eye view frustum
  6509. * enables mapping of values in the render target depth
  6510. * attachment to scene coordinates. Initially set to 0.01.
  6511. */
  6512. depthNear: number;
  6513. /**
  6514. * An identifier for this distinct VRDisplay. Used as an
  6515. * association point in the Gamepad API.
  6516. */
  6517. readonly displayId: number;
  6518. /**
  6519. * A display name, a user-readable name identifying it.
  6520. */
  6521. readonly displayName: string;
  6522. readonly isConnected: boolean;
  6523. readonly isPresenting: boolean;
  6524. /**
  6525. * If this VRDisplay supports room-scale experiences, the optional
  6526. * stage attribute contains details on the room-scale parameters.
  6527. */
  6528. readonly stageParameters: VRStageParameters | null;
  6529. /**
  6530. * Passing the value returned by `requestAnimationFrame` to
  6531. * `cancelAnimationFrame` will unregister the callback.
  6532. */
  6533. cancelAnimationFrame(handle: number): void;
  6534. /**
  6535. * Stops presenting to the VRDisplay.
  6536. */
  6537. exitPresent(): Promise<void>;
  6538. getEyeParameters(whichEye: string): VREyeParameters;
  6539. /**
  6540. * Populates the passed VRFrameData with the information required to render
  6541. * the current frame.
  6542. */
  6543. getFrameData(frameData: VRFrameData): boolean;
  6544. /**
  6545. * Get the layers currently being presented.
  6546. */
  6547. getLayers(): VRLayer[];
  6548. /**
  6549. * Return a VRPose containing the future predicted pose of the VRDisplay
  6550. * when the current frame will be presented. The value returned will not
  6551. * change until JavaScript has returned control to the browser.
  6552. *
  6553. * The VRPose will contain the position, orientation, velocity,
  6554. * and acceleration of each of these properties.
  6555. */
  6556. getPose(): VRPose;
  6557. /**
  6558. * Return the current instantaneous pose of the VRDisplay, with no
  6559. * prediction applied.
  6560. */
  6561. getImmediatePose(): VRPose;
  6562. /**
  6563. * The callback passed to `requestAnimationFrame` will be called
  6564. * any time a new frame should be rendered. When the VRDisplay is
  6565. * presenting the callback will be called at the native refresh
  6566. * rate of the HMD. When not presenting this function acts
  6567. * identically to how window.requestAnimationFrame acts. Content should
  6568. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6569. * asynchronously from other displays and at differing refresh rates.
  6570. */
  6571. requestAnimationFrame(callback: FrameRequestCallback): number;
  6572. /**
  6573. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6574. * Repeat calls while already presenting will update the VRLayers being displayed.
  6575. */
  6576. requestPresent(layers: VRLayer[]): Promise<void>;
  6577. /**
  6578. * Reset the pose for this display, treating its current position and
  6579. * orientation as the "origin/zero" values. VRPose.position,
  6580. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6581. * updated when calling resetPose(). This should be called in only
  6582. * sitting-space experiences.
  6583. */
  6584. resetPose(): void;
  6585. /**
  6586. * The VRLayer provided to the VRDisplay will be captured and presented
  6587. * in the HMD. Calling this function has the same effect on the source
  6588. * canvas as any other operation that uses its source image, and canvases
  6589. * created without preserveDrawingBuffer set to true will be cleared.
  6590. */
  6591. submitFrame(pose?: VRPose): void;
  6592. }
  6593. declare var VRDisplay: {
  6594. prototype: VRDisplay;
  6595. new (): VRDisplay;
  6596. };
  6597. interface VRLayer {
  6598. leftBounds?: number[] | null;
  6599. rightBounds?: number[] | null;
  6600. source?: HTMLCanvasElement | null;
  6601. }
  6602. interface VRDisplayCapabilities {
  6603. readonly canPresent: boolean;
  6604. readonly hasExternalDisplay: boolean;
  6605. readonly hasOrientation: boolean;
  6606. readonly hasPosition: boolean;
  6607. readonly maxLayers: number;
  6608. }
  6609. interface VREyeParameters {
  6610. /** @deprecated */
  6611. readonly fieldOfView: VRFieldOfView;
  6612. readonly offset: Float32Array;
  6613. readonly renderHeight: number;
  6614. readonly renderWidth: number;
  6615. }
  6616. interface VRFieldOfView {
  6617. readonly downDegrees: number;
  6618. readonly leftDegrees: number;
  6619. readonly rightDegrees: number;
  6620. readonly upDegrees: number;
  6621. }
  6622. interface VRFrameData {
  6623. readonly leftProjectionMatrix: Float32Array;
  6624. readonly leftViewMatrix: Float32Array;
  6625. readonly pose: VRPose;
  6626. readonly rightProjectionMatrix: Float32Array;
  6627. readonly rightViewMatrix: Float32Array;
  6628. readonly timestamp: number;
  6629. }
  6630. interface VRPose {
  6631. readonly angularAcceleration: Float32Array | null;
  6632. readonly angularVelocity: Float32Array | null;
  6633. readonly linearAcceleration: Float32Array | null;
  6634. readonly linearVelocity: Float32Array | null;
  6635. readonly orientation: Float32Array | null;
  6636. readonly position: Float32Array | null;
  6637. readonly timestamp: number;
  6638. }
  6639. interface VRStageParameters {
  6640. sittingToStandingTransform?: Float32Array;
  6641. sizeX?: number;
  6642. sizeY?: number;
  6643. }
  6644. interface Navigator {
  6645. getVRDisplays(): Promise<VRDisplay[]>;
  6646. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6647. }
  6648. interface Window {
  6649. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6650. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6651. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6652. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6653. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6654. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6655. }
  6656. interface Gamepad {
  6657. readonly displayId: number;
  6658. }
  6659. /**
  6660. * Module Debug contains the (visual) components to debug a scene correctly
  6661. */
  6662. declare module BABYLON.Debug {
  6663. /**
  6664. * The Axes viewer will show 3 axes in a specific point in space
  6665. */
  6666. class AxesViewer {
  6667. private _xline;
  6668. private _yline;
  6669. private _zline;
  6670. private _xmesh;
  6671. private _ymesh;
  6672. private _zmesh;
  6673. scene: Nullable<Scene>;
  6674. scaleLines: number;
  6675. constructor(scene: Scene, scaleLines?: number);
  6676. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6677. dispose(): void;
  6678. }
  6679. }
  6680. declare module BABYLON.Debug {
  6681. /**
  6682. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6683. */
  6684. class BoneAxesViewer extends AxesViewer {
  6685. mesh: Nullable<Mesh>;
  6686. bone: Nullable<Bone>;
  6687. pos: Vector3;
  6688. xaxis: Vector3;
  6689. yaxis: Vector3;
  6690. zaxis: Vector3;
  6691. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6692. update(): void;
  6693. dispose(): void;
  6694. }
  6695. }
  6696. declare module BABYLON {
  6697. class DebugLayer {
  6698. private _scene;
  6699. static InspectorURL: string;
  6700. private _inspector;
  6701. private BJSINSPECTOR;
  6702. constructor(scene: Scene);
  6703. /** Creates the inspector window. */
  6704. private _createInspector(config?);
  6705. isVisible(): boolean;
  6706. hide(): void;
  6707. show(config?: {
  6708. popup?: boolean;
  6709. initialTab?: number;
  6710. parentElement?: HTMLElement;
  6711. newColors?: {
  6712. backgroundColor?: string;
  6713. backgroundColorLighter?: string;
  6714. backgroundColorLighter2?: string;
  6715. backgroundColorLighter3?: string;
  6716. color?: string;
  6717. colorTop?: string;
  6718. colorBot?: string;
  6719. };
  6720. }): void;
  6721. }
  6722. }
  6723. declare module BABYLON.Debug {
  6724. /**
  6725. * Used to show the physics impostor around the specific mesh.
  6726. */
  6727. class PhysicsViewer {
  6728. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6729. protected _meshes: Array<Nullable<AbstractMesh>>;
  6730. protected _scene: Nullable<Scene>;
  6731. protected _numMeshes: number;
  6732. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6733. private _renderFunction;
  6734. private _debugBoxMesh;
  6735. private _debugSphereMesh;
  6736. private _debugMaterial;
  6737. constructor(scene: Scene);
  6738. protected _updateDebugMeshes(): void;
  6739. showImpostor(impostor: PhysicsImpostor): void;
  6740. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6741. private _getDebugMaterial(scene);
  6742. private _getDebugBoxMesh(scene);
  6743. private _getDebugSphereMesh(scene);
  6744. private _getDebugMesh(impostor, scene);
  6745. dispose(): void;
  6746. }
  6747. }
  6748. declare module BABYLON {
  6749. class RayHelper {
  6750. ray: Nullable<Ray>;
  6751. private _renderPoints;
  6752. private _renderLine;
  6753. private _renderFunction;
  6754. private _scene;
  6755. private _updateToMeshFunction;
  6756. private _attachedToMesh;
  6757. private _meshSpaceDirection;
  6758. private _meshSpaceOrigin;
  6759. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6760. constructor(ray: Ray);
  6761. show(scene: Scene, color: Color3): void;
  6762. hide(): void;
  6763. private _render();
  6764. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6765. detachFromMesh(): void;
  6766. private _updateToMesh();
  6767. dispose(): void;
  6768. }
  6769. }
  6770. declare module BABYLON.Debug {
  6771. /**
  6772. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  6773. */
  6774. class SkeletonViewer {
  6775. skeleton: Skeleton;
  6776. mesh: AbstractMesh;
  6777. autoUpdateBonesMatrices: boolean;
  6778. renderingGroupId: number;
  6779. color: Color3;
  6780. private _scene;
  6781. private _debugLines;
  6782. private _debugMesh;
  6783. private _isEnabled;
  6784. private _renderFunction;
  6785. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  6786. isEnabled: boolean;
  6787. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6788. private _getLinesForBonesWithLength(bones, meshMat);
  6789. private _getLinesForBonesNoLength(bones, meshMat);
  6790. update(): void;
  6791. dispose(): void;
  6792. }
  6793. }
  6794. declare module BABYLON {
  6795. /**
  6796. * Interface for attribute information associated with buffer instanciation
  6797. */
  6798. class InstancingAttributeInfo {
  6799. /**
  6800. * Index/offset of the attribute in the vertex shader
  6801. */
  6802. index: number;
  6803. /**
  6804. * size of the attribute, 1, 2, 3 or 4
  6805. */
  6806. attributeSize: number;
  6807. /**
  6808. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6809. * default is FLOAT
  6810. */
  6811. attribyteType: number;
  6812. /**
  6813. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6814. */
  6815. normalized: boolean;
  6816. /**
  6817. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6818. */
  6819. offset: number;
  6820. /**
  6821. * Name of the GLSL attribute, for debugging purpose only
  6822. */
  6823. attributeName: string;
  6824. }
  6825. /**
  6826. * Define options used to create a render target texture
  6827. */
  6828. class RenderTargetCreationOptions {
  6829. /**
  6830. * Specifies is mipmaps must be generated
  6831. */
  6832. generateMipMaps?: boolean;
  6833. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6834. generateDepthBuffer?: boolean;
  6835. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6836. generateStencilBuffer?: boolean;
  6837. /** Defines texture type (int by default) */
  6838. type?: number;
  6839. /** Defines sampling mode (trilinear by default) */
  6840. samplingMode?: number;
  6841. /** Defines format (RGBA by default) */
  6842. format?: number;
  6843. }
  6844. /**
  6845. * Define options used to create a depth texture
  6846. */
  6847. class DepthTextureCreationOptions {
  6848. /** Specifies whether or not a stencil should be allocated in the texture */
  6849. generateStencil?: boolean;
  6850. /** Specifies whether or not bilinear filtering is enable on the texture */
  6851. bilinearFiltering?: boolean;
  6852. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6853. comparisonFunction?: number;
  6854. /** Specifies if the created texture is a cube texture */
  6855. isCube?: boolean;
  6856. }
  6857. /**
  6858. * Class used to describe the capabilities of the engine relatively to the current browser
  6859. */
  6860. class EngineCapabilities {
  6861. /** Maximum textures units per fragment shader */
  6862. maxTexturesImageUnits: number;
  6863. /** Maximum texture units per vertex shader */
  6864. maxVertexTextureImageUnits: number;
  6865. /** Maximum textures units in the entire pipeline */
  6866. maxCombinedTexturesImageUnits: number;
  6867. /** Maximum texture size */
  6868. maxTextureSize: number;
  6869. /** Maximum cube texture size */
  6870. maxCubemapTextureSize: number;
  6871. /** Maximum render texture size */
  6872. maxRenderTextureSize: number;
  6873. /** Maximum number of vertex attributes */
  6874. maxVertexAttribs: number;
  6875. /** Maximum number of varyings */
  6876. maxVaryingVectors: number;
  6877. /** Maximum number of uniforms per vertex shader */
  6878. maxVertexUniformVectors: number;
  6879. /** Maximum number of uniforms per fragment shader */
  6880. maxFragmentUniformVectors: number;
  6881. /** Defines if standard derivates (dx/dy) are supported */
  6882. standardDerivatives: boolean;
  6883. /** Defines if s3tc texture compression is supported */
  6884. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6885. /** Defines if pvrtc texture compression is supported */
  6886. pvrtc: any;
  6887. /** Defines if etc1 texture compression is supported */
  6888. etc1: any;
  6889. /** Defines if etc2 texture compression is supported */
  6890. etc2: any;
  6891. /** Defines if astc texture compression is supported */
  6892. astc: any;
  6893. /** Defines if float textures are supported */
  6894. textureFloat: boolean;
  6895. /** Defines if vertex array objects are supported */
  6896. vertexArrayObject: boolean;
  6897. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6898. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6899. /** Gets the maximum level of anisotropy supported */
  6900. maxAnisotropy: number;
  6901. /** Defines if instancing is supported */
  6902. instancedArrays: boolean;
  6903. /** Defines if 32 bits indices are supported */
  6904. uintIndices: boolean;
  6905. /** Defines if high precision shaders are supported */
  6906. highPrecisionShaderSupported: boolean;
  6907. /** Defines if depth reading in the fragment shader is supported */
  6908. fragmentDepthSupported: boolean;
  6909. /** Defines if float texture linear filtering is supported*/
  6910. textureFloatLinearFiltering: boolean;
  6911. /** Defines if rendering to float textures is supported */
  6912. textureFloatRender: boolean;
  6913. /** Defines if half float textures are supported*/
  6914. textureHalfFloat: boolean;
  6915. /** Defines if half float texture linear filtering is supported*/
  6916. textureHalfFloatLinearFiltering: boolean;
  6917. /** Defines if rendering to half float textures is supported */
  6918. textureHalfFloatRender: boolean;
  6919. /** Defines if textureLOD shader command is supported */
  6920. textureLOD: boolean;
  6921. /** Defines if draw buffers extension is supported */
  6922. drawBuffersExtension: boolean;
  6923. /** Defines if depth textures are supported */
  6924. depthTextureExtension: boolean;
  6925. /** Defines if float color buffer are supported */
  6926. colorBufferFloat: boolean;
  6927. /** Gets disjoint timer query extension (null if not supported) */
  6928. timerQuery: EXT_disjoint_timer_query;
  6929. /** Defines if timestamp can be used with timer query */
  6930. canUseTimestampForTimerQuery: boolean;
  6931. }
  6932. /** Interface defining initialization parameters for Engine class */
  6933. interface EngineOptions extends WebGLContextAttributes {
  6934. /**
  6935. * Defines if the engine should no exceed a specified device ratio
  6936. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6937. */
  6938. limitDeviceRatio?: number;
  6939. /**
  6940. * Defines if webvr should be enabled automatically
  6941. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6942. */
  6943. autoEnableWebVR?: boolean;
  6944. /**
  6945. * Defines if webgl2 should be turned off even if supported
  6946. * @see http://doc.babylonjs.com/features/webgl2
  6947. */
  6948. disableWebGL2Support?: boolean;
  6949. /**
  6950. * Defines if webaudio should be initialized as well
  6951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6952. */
  6953. audioEngine?: boolean;
  6954. /**
  6955. * Defines if animations should run using a deterministic lock step
  6956. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6957. */
  6958. deterministicLockstep?: boolean;
  6959. /** Defines the maximum steps to use with deterministic lock step mode */
  6960. lockstepMaxSteps?: number;
  6961. /**
  6962. * Defines that engine should ignore context lost events
  6963. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6964. */
  6965. doNotHandleContextLost?: boolean;
  6966. }
  6967. /**
  6968. * Defines the interface used by display changed events
  6969. */
  6970. interface IDisplayChangedEventArgs {
  6971. /** Gets the vrDisplay object (if any) */
  6972. vrDisplay: Nullable<any>;
  6973. /** Gets a boolean indicating if webVR is supported */
  6974. vrSupported: boolean;
  6975. }
  6976. /**
  6977. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6978. */
  6979. class Engine {
  6980. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6981. static ExceptionList: ({
  6982. key: string;
  6983. capture: string;
  6984. captureConstraint: number;
  6985. targets: string[];
  6986. } | {
  6987. key: string;
  6988. capture: null;
  6989. captureConstraint: null;
  6990. targets: string[];
  6991. })[];
  6992. /** Gets the list of created engines */
  6993. static Instances: Engine[];
  6994. /**
  6995. * Gets the latest created engine
  6996. */
  6997. static readonly LastCreatedEngine: Nullable<Engine>;
  6998. /**
  6999. * Gets the latest created scene
  7000. */
  7001. static readonly LastCreatedScene: Nullable<Scene>;
  7002. /**
  7003. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7004. * @param flag defines which part of the materials must be marked as dirty
  7005. * @param predicate defines a predicate used to filter which materials should be affected
  7006. */
  7007. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7008. private static _ALPHA_DISABLE;
  7009. private static _ALPHA_ADD;
  7010. private static _ALPHA_COMBINE;
  7011. private static _ALPHA_SUBTRACT;
  7012. private static _ALPHA_MULTIPLY;
  7013. private static _ALPHA_MAXIMIZED;
  7014. private static _ALPHA_ONEONE;
  7015. private static _ALPHA_PREMULTIPLIED;
  7016. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  7017. private static _ALPHA_INTERPOLATE;
  7018. private static _ALPHA_SCREENMODE;
  7019. private static _DELAYLOADSTATE_NONE;
  7020. private static _DELAYLOADSTATE_LOADED;
  7021. private static _DELAYLOADSTATE_LOADING;
  7022. private static _DELAYLOADSTATE_NOTLOADED;
  7023. private static _TEXTUREFORMAT_ALPHA;
  7024. private static _TEXTUREFORMAT_LUMINANCE;
  7025. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7026. private static _TEXTUREFORMAT_RGB;
  7027. private static _TEXTUREFORMAT_RGBA;
  7028. private static _TEXTUREFORMAT_R32F;
  7029. private static _TEXTUREFORMAT_RG32F;
  7030. private static _TEXTUREFORMAT_RGB32F;
  7031. private static _TEXTUREFORMAT_RGBA32F;
  7032. private static _TEXTURETYPE_UNSIGNED_INT;
  7033. private static _TEXTURETYPE_FLOAT;
  7034. private static _TEXTURETYPE_HALF_FLOAT;
  7035. private static _NEVER;
  7036. private static _ALWAYS;
  7037. private static _LESS;
  7038. private static _EQUAL;
  7039. private static _LEQUAL;
  7040. private static _GREATER;
  7041. private static _GEQUAL;
  7042. private static _NOTEQUAL;
  7043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7044. static readonly NEVER: number;
  7045. /** 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 */
  7046. static readonly ALWAYS: number;
  7047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7048. static readonly LESS: number;
  7049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7050. static readonly EQUAL: number;
  7051. /** 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 */
  7052. static readonly LEQUAL: number;
  7053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7054. static readonly GREATER: number;
  7055. /** 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 */
  7056. static readonly GEQUAL: number;
  7057. /** 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 */
  7058. static readonly NOTEQUAL: number;
  7059. private static _KEEP;
  7060. private static _REPLACE;
  7061. private static _INCR;
  7062. private static _DECR;
  7063. private static _INVERT;
  7064. private static _INCR_WRAP;
  7065. private static _DECR_WRAP;
  7066. /** Passed to stencilOperation to specify that stencil value must be kept */
  7067. static readonly KEEP: number;
  7068. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7069. static readonly REPLACE: number;
  7070. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7071. static readonly INCR: number;
  7072. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7073. static readonly DECR: number;
  7074. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7075. static readonly INVERT: number;
  7076. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7077. static readonly INCR_WRAP: number;
  7078. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7079. static readonly DECR_WRAP: number;
  7080. /** Defines that alpha blending is disabled */
  7081. static readonly ALPHA_DISABLE: number;
  7082. /** Defines that alpha blending to SRC + DEST */
  7083. static readonly ALPHA_ONEONE: number;
  7084. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7085. static readonly ALPHA_ADD: number;
  7086. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7087. static readonly ALPHA_COMBINE: number;
  7088. /** Defines that alpha blending to DEST - SRC * DEST */
  7089. static readonly ALPHA_SUBTRACT: number;
  7090. /** Defines that alpha blending to SRC * DEST */
  7091. static readonly ALPHA_MULTIPLY: number;
  7092. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7093. static readonly ALPHA_MAXIMIZED: number;
  7094. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7095. static readonly ALPHA_PREMULTIPLIED: number;
  7096. /**
  7097. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7098. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7099. */
  7100. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7101. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7102. static readonly ALPHA_INTERPOLATE: number;
  7103. /**
  7104. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7105. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7106. */
  7107. static readonly ALPHA_SCREENMODE: number;
  7108. /** Defines that the ressource is not delayed*/
  7109. static readonly DELAYLOADSTATE_NONE: number;
  7110. /** Defines that the ressource was successfully delay loaded */
  7111. static readonly DELAYLOADSTATE_LOADED: number;
  7112. /** Defines that the ressource is currently delay loading */
  7113. static readonly DELAYLOADSTATE_LOADING: number;
  7114. /** Defines that the ressource is delayed and has not started loading */
  7115. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7116. /** ALPHA */
  7117. static readonly TEXTUREFORMAT_ALPHA: number;
  7118. /** LUMINANCE */
  7119. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7120. /**
  7121. * R32F
  7122. */
  7123. static readonly TEXTUREFORMAT_R32F: number;
  7124. /**
  7125. * RG32F
  7126. */
  7127. static readonly TEXTUREFORMAT_RG32F: number;
  7128. /**
  7129. * RGB32F
  7130. */
  7131. static readonly TEXTUREFORMAT_RGB32F: number;
  7132. /**
  7133. * RGBA32F
  7134. */
  7135. static readonly TEXTUREFORMAT_RGBA32F: number;
  7136. /** LUMINANCE_ALPHA */
  7137. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7138. /** RGB */
  7139. static readonly TEXTUREFORMAT_RGB: number;
  7140. /** RGBA */
  7141. static readonly TEXTUREFORMAT_RGBA: number;
  7142. /** UNSIGNED_INT */
  7143. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7144. /** FLOAT */
  7145. static readonly TEXTURETYPE_FLOAT: number;
  7146. /** HALF_FLOAT */
  7147. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7148. private static _SCALEMODE_FLOOR;
  7149. private static _SCALEMODE_NEAREST;
  7150. private static _SCALEMODE_CEILING;
  7151. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7152. static readonly SCALEMODE_FLOOR: number;
  7153. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7154. static readonly SCALEMODE_NEAREST: number;
  7155. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7156. static readonly SCALEMODE_CEILING: number;
  7157. /**
  7158. * Returns the current version of the framework
  7159. */
  7160. static readonly Version: string;
  7161. /**
  7162. * Gets or sets the epsilon value used by collision engine
  7163. */
  7164. static CollisionsEpsilon: number;
  7165. /**
  7166. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7167. */
  7168. static CodeRepository: string;
  7169. /**
  7170. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7171. */
  7172. static ShadersRepository: string;
  7173. /**
  7174. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7175. */
  7176. forcePOTTextures: boolean;
  7177. /**
  7178. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7179. */
  7180. isFullscreen: boolean;
  7181. /**
  7182. * Gets a boolean indicating if the pointer is currently locked
  7183. */
  7184. isPointerLock: boolean;
  7185. /**
  7186. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7187. */
  7188. cullBackFaces: boolean;
  7189. /**
  7190. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7191. */
  7192. renderEvenInBackground: boolean;
  7193. /**
  7194. * Gets or sets a boolean indicating that cache can be kept between frames
  7195. */
  7196. preventCacheWipeBetweenFrames: boolean;
  7197. /**
  7198. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7199. **/
  7200. enableOfflineSupport: boolean;
  7201. /**
  7202. * 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)
  7203. **/
  7204. disableManifestCheck: boolean;
  7205. /**
  7206. * Gets the list of created scenes
  7207. */
  7208. scenes: Scene[];
  7209. /**
  7210. * Gets the list of created postprocesses
  7211. */
  7212. postProcesses: PostProcess[];
  7213. /**
  7214. * Observable event triggered each time the rendering canvas is resized
  7215. */
  7216. onResizeObservable: Observable<Engine>;
  7217. /**
  7218. * Observable event triggered each time the canvas loses focus
  7219. */
  7220. onCanvasBlurObservable: Observable<Engine>;
  7221. /**
  7222. * Observable event triggered each time the canvas gains focus
  7223. */
  7224. onCanvasFocusObservable: Observable<Engine>;
  7225. /**
  7226. * Observable event triggered each time the canvas receives pointerout event
  7227. */
  7228. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7229. /**
  7230. * Observable event triggered before each texture is initialized
  7231. */
  7232. onBeforeTextureInitObservable: Observable<Texture>;
  7233. private _vrDisplay;
  7234. private _vrSupported;
  7235. private _oldSize;
  7236. private _oldHardwareScaleFactor;
  7237. private _vrExclusivePointerMode;
  7238. private _webVRInitPromise;
  7239. /**
  7240. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7241. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7242. */
  7243. readonly isInVRExclusivePointerMode: boolean;
  7244. /**
  7245. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7246. */
  7247. disableUniformBuffers: boolean;
  7248. /** @hidden */
  7249. _uniformBuffers: UniformBuffer[];
  7250. /**
  7251. * Gets a boolean indicating that the engine supports uniform buffers
  7252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7253. */
  7254. readonly supportsUniformBuffers: boolean;
  7255. /**
  7256. * Observable raised when the engine begins a new frame
  7257. */
  7258. onBeginFrameObservable: Observable<Engine>;
  7259. /**
  7260. * Observable raised when the engine ends the current frame
  7261. */
  7262. onEndFrameObservable: Observable<Engine>;
  7263. /**
  7264. * Observable raised when the engine is about to compile a shader
  7265. */
  7266. onBeforeShaderCompilationObservable: Observable<Engine>;
  7267. /**
  7268. * Observable raised when the engine has jsut compiled a shader
  7269. */
  7270. onAfterShaderCompilationObservable: Observable<Engine>;
  7271. private _gl;
  7272. private _renderingCanvas;
  7273. private _windowIsBackground;
  7274. private _webGLVersion;
  7275. /**
  7276. * Gets a boolean indicating that only power of 2 textures are supported
  7277. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7278. */
  7279. readonly needPOTTextures: boolean;
  7280. /** @hidden */
  7281. _badOS: boolean;
  7282. /** @hidden */
  7283. _badDesktopOS: boolean;
  7284. /**
  7285. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7286. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7287. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7288. */
  7289. disableTextureBindingOptimization: boolean;
  7290. /**
  7291. * Gets the audio engine
  7292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7293. * @ignorenaming
  7294. */
  7295. static audioEngine: AudioEngine;
  7296. private _onFocus;
  7297. private _onBlur;
  7298. private _onCanvasPointerOut;
  7299. private _onCanvasBlur;
  7300. private _onCanvasFocus;
  7301. private _onFullscreenChange;
  7302. private _onPointerLockChange;
  7303. private _onVRDisplayPointerRestricted;
  7304. private _onVRDisplayPointerUnrestricted;
  7305. private _onVrDisplayConnect;
  7306. private _onVrDisplayDisconnect;
  7307. private _onVrDisplayPresentChange;
  7308. /**
  7309. * Observable signaled when VR display mode changes
  7310. */
  7311. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7312. /**
  7313. * Observable signaled when VR request present is complete
  7314. */
  7315. onVRRequestPresentComplete: Observable<boolean>;
  7316. /**
  7317. * Observable signaled when VR request present starts
  7318. */
  7319. onVRRequestPresentStart: Observable<Engine>;
  7320. private _hardwareScalingLevel;
  7321. /** @hidden */
  7322. protected _caps: EngineCapabilities;
  7323. private _pointerLockRequested;
  7324. private _isStencilEnable;
  7325. private _colorWrite;
  7326. private _loadingScreen;
  7327. /** @hidden */
  7328. _drawCalls: PerfCounter;
  7329. /** @hidden */
  7330. _textureCollisions: PerfCounter;
  7331. private _glVersion;
  7332. private _glRenderer;
  7333. private _glVendor;
  7334. private _videoTextureSupported;
  7335. private _renderingQueueLaunched;
  7336. private _activeRenderLoops;
  7337. private _deterministicLockstep;
  7338. private _lockstepMaxSteps;
  7339. /**
  7340. * Observable signaled when a context lost event is raised
  7341. */
  7342. onContextLostObservable: Observable<Engine>;
  7343. /**
  7344. * Observable signaled when a context restored event is raised
  7345. */
  7346. onContextRestoredObservable: Observable<Engine>;
  7347. private _onContextLost;
  7348. private _onContextRestored;
  7349. private _contextWasLost;
  7350. private _doNotHandleContextLost;
  7351. private _performanceMonitor;
  7352. private _fps;
  7353. private _deltaTime;
  7354. /**
  7355. * Turn this value on if you want to pause FPS computation when in background
  7356. */
  7357. disablePerformanceMonitorInBackground: boolean;
  7358. /**
  7359. * Gets the performance monitor attached to this engine
  7360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7361. */
  7362. readonly performanceMonitor: PerformanceMonitor;
  7363. /** @hidden */
  7364. protected _depthCullingState: _DepthCullingState;
  7365. /** @hidden */
  7366. protected _stencilState: _StencilState;
  7367. /** @hidden */
  7368. protected _alphaState: _AlphaState;
  7369. /** @hidden */
  7370. protected _alphaMode: number;
  7371. protected _internalTexturesCache: InternalTexture[];
  7372. /** @hidden */
  7373. protected _activeChannel: number;
  7374. private _currentTextureChannel;
  7375. /** @hidden */
  7376. protected _boundTexturesCache: {
  7377. [key: string]: Nullable<InternalTexture>;
  7378. };
  7379. /** @hidden */
  7380. protected _currentEffect: Nullable<Effect>;
  7381. /** @hidden */
  7382. protected _currentProgram: Nullable<WebGLProgram>;
  7383. private _compiledEffects;
  7384. private _vertexAttribArraysEnabled;
  7385. /** @hidden */
  7386. protected _cachedViewport: Nullable<Viewport>;
  7387. private _cachedVertexArrayObject;
  7388. /** @hidden */
  7389. protected _cachedVertexBuffers: any;
  7390. /** @hidden */
  7391. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7392. /** @hidden */
  7393. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7394. /** @hidden */
  7395. protected _currentRenderTarget: Nullable<InternalTexture>;
  7396. private _uintIndicesCurrentlySet;
  7397. private _currentBoundBuffer;
  7398. /** @hidden */
  7399. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7400. private _currentBufferPointers;
  7401. private _currentInstanceLocations;
  7402. private _currentInstanceBuffers;
  7403. private _textureUnits;
  7404. private _firstBoundInternalTextureTracker;
  7405. private _lastBoundInternalTextureTracker;
  7406. private _workingCanvas;
  7407. private _workingContext;
  7408. private _rescalePostProcess;
  7409. private _dummyFramebuffer;
  7410. private _externalData;
  7411. private _bindedRenderFunction;
  7412. private _vaoRecordInProgress;
  7413. private _mustWipeVertexAttributes;
  7414. private _emptyTexture;
  7415. private _emptyCubeTexture;
  7416. private _emptyTexture3D;
  7417. private _frameHandler;
  7418. private _nextFreeTextureSlots;
  7419. private _maxSimultaneousTextures;
  7420. private _activeRequests;
  7421. private _texturesSupported;
  7422. private _textureFormatInUse;
  7423. /**
  7424. * Gets the list of texture formats supported
  7425. */
  7426. readonly texturesSupported: Array<string>;
  7427. /**
  7428. * Gets the list of texture formats in use
  7429. */
  7430. readonly textureFormatInUse: Nullable<string>;
  7431. /**
  7432. * Gets the current viewport
  7433. */
  7434. readonly currentViewport: Nullable<Viewport>;
  7435. /**
  7436. * Gets the default empty texture
  7437. */
  7438. readonly emptyTexture: InternalTexture;
  7439. /**
  7440. * Gets the default empty 3D texture
  7441. */
  7442. readonly emptyTexture3D: InternalTexture;
  7443. /**
  7444. * Gets the default empty cube texture
  7445. */
  7446. readonly emptyCubeTexture: InternalTexture;
  7447. /**
  7448. * Creates a new engine
  7449. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7450. * @param antialias defines enable antialiasing (default: false)
  7451. * @param options defines further options to be sent to the getContext() function
  7452. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7453. */
  7454. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7455. private _rebuildInternalTextures();
  7456. private _rebuildEffects();
  7457. private _rebuildBuffers();
  7458. private _initGLContext();
  7459. /**
  7460. * Gets version of the current webGL context
  7461. */
  7462. readonly webGLVersion: number;
  7463. /**
  7464. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7465. */
  7466. readonly isStencilEnable: boolean;
  7467. private _prepareWorkingCanvas();
  7468. /**
  7469. * Reset the texture cache to empty state
  7470. */
  7471. resetTextureCache(): void;
  7472. /**
  7473. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7475. * @returns true if engine is in deterministic lock step mode
  7476. */
  7477. isDeterministicLockStep(): boolean;
  7478. /**
  7479. * Gets the max steps when engine is running in deterministic lock step
  7480. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7481. * @returns the max steps
  7482. */
  7483. getLockstepMaxSteps(): number;
  7484. /**
  7485. * Gets an object containing information about the current webGL context
  7486. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7487. */
  7488. getGlInfo(): {
  7489. vendor: string;
  7490. renderer: string;
  7491. version: string;
  7492. };
  7493. /**
  7494. * Gets current aspect ratio
  7495. * @param camera defines the camera to use to get the aspect ratio
  7496. * @param useScreen defines if screen size must be used (or the current render target if any)
  7497. * @returns a number defining the aspect ratio
  7498. */
  7499. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7500. /**
  7501. * Gets current screen aspect ratio
  7502. * @returns a number defining the aspect ratio
  7503. */
  7504. getScreenAspectRatio(): number;
  7505. /**
  7506. * Gets the current render width
  7507. * @param useScreen defines if screen size must be used (or the current render target if any)
  7508. * @returns a number defining the current render width
  7509. */
  7510. getRenderWidth(useScreen?: boolean): number;
  7511. /**
  7512. * Gets the current render height
  7513. * @param useScreen defines if screen size must be used (or the current render target if any)
  7514. * @returns a number defining the current render height
  7515. */
  7516. getRenderHeight(useScreen?: boolean): number;
  7517. /**
  7518. * Gets the HTML canvas attached with the current webGL context
  7519. * @returns a HTML canvas
  7520. */
  7521. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7522. /**
  7523. * Gets the client rect of the HTML canvas attached with the current webGL context
  7524. * @returns a client rectanglee
  7525. */
  7526. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7527. /**
  7528. * Defines the hardware scaling level.
  7529. * By default the hardware scaling level is computed from the window device ratio.
  7530. * 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.
  7531. * @param level defines the level to use
  7532. */
  7533. setHardwareScalingLevel(level: number): void;
  7534. /**
  7535. * Gets the current hardware scaling level.
  7536. * By default the hardware scaling level is computed from the window device ratio.
  7537. * 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.
  7538. * @returns a number indicating the current hardware scaling level
  7539. */
  7540. getHardwareScalingLevel(): number;
  7541. /**
  7542. * Gets the list of loaded textures
  7543. * @returns an array containing all loaded textures
  7544. */
  7545. getLoadedTexturesCache(): InternalTexture[];
  7546. /**
  7547. * Gets the object containing all engine capabilities
  7548. * @returns the EngineCapabilities object
  7549. */
  7550. getCaps(): EngineCapabilities;
  7551. /** @hidden */
  7552. readonly drawCalls: number;
  7553. /** @hidden */
  7554. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7555. /**
  7556. * Gets the current depth function
  7557. * @returns a number defining the depth function
  7558. */
  7559. getDepthFunction(): Nullable<number>;
  7560. /**
  7561. * Sets the current depth function
  7562. * @param depthFunc defines the function to use
  7563. */
  7564. setDepthFunction(depthFunc: number): void;
  7565. /**
  7566. * Sets the current depth function to GREATER
  7567. */
  7568. setDepthFunctionToGreater(): void;
  7569. /**
  7570. * Sets the current depth function to GEQUAL
  7571. */
  7572. setDepthFunctionToGreaterOrEqual(): void;
  7573. /**
  7574. * Sets the current depth function to LESS
  7575. */
  7576. setDepthFunctionToLess(): void;
  7577. /**
  7578. * Sets the current depth function to LEQUAL
  7579. */
  7580. setDepthFunctionToLessOrEqual(): void;
  7581. /**
  7582. * Gets a boolean indicating if stencil buffer is enabled
  7583. * @returns the current stencil buffer state
  7584. */
  7585. getStencilBuffer(): boolean;
  7586. /**
  7587. * Enable or disable the stencil buffer
  7588. * @param enable defines if the stencil buffer must be enabled or disabled
  7589. */
  7590. setStencilBuffer(enable: boolean): void;
  7591. /**
  7592. * Gets the current stencil mask
  7593. * @returns a number defining the new stencil mask to use
  7594. */
  7595. getStencilMask(): number;
  7596. /**
  7597. * Sets the current stencil mask
  7598. * @param mask defines the new stencil mask to use
  7599. */
  7600. setStencilMask(mask: number): void;
  7601. /**
  7602. * Gets the current stencil function
  7603. * @returns a number defining the stencil function to use
  7604. */
  7605. getStencilFunction(): number;
  7606. /**
  7607. * Gets the current stencil reference value
  7608. * @returns a number defining the stencil reference value to use
  7609. */
  7610. getStencilFunctionReference(): number;
  7611. /**
  7612. * Gets the current stencil mask
  7613. * @returns a number defining the stencil mask to use
  7614. */
  7615. getStencilFunctionMask(): number;
  7616. /**
  7617. * Sets the current stencil function
  7618. * @param stencilFunc defines the new stencil function to use
  7619. */
  7620. setStencilFunction(stencilFunc: number): void;
  7621. /**
  7622. * Sets the current stencil reference
  7623. * @param reference defines the new stencil reference to use
  7624. */
  7625. setStencilFunctionReference(reference: number): void;
  7626. /**
  7627. * Sets the current stencil mask
  7628. * @param mask defines the new stencil mask to use
  7629. */
  7630. setStencilFunctionMask(mask: number): void;
  7631. /**
  7632. * Gets the current stencil operation when stencil fails
  7633. * @returns a number defining stencil operation to use when stencil fails
  7634. */
  7635. getStencilOperationFail(): number;
  7636. /**
  7637. * Gets the current stencil operation when depth fails
  7638. * @returns a number defining stencil operation to use when depth fails
  7639. */
  7640. getStencilOperationDepthFail(): number;
  7641. /**
  7642. * Gets the current stencil operation when stencil passes
  7643. * @returns a number defining stencil operation to use when stencil passes
  7644. */
  7645. getStencilOperationPass(): number;
  7646. /**
  7647. * Sets the stencil operation to use when stencil fails
  7648. * @param operation defines the stencil operation to use when stencil fails
  7649. */
  7650. setStencilOperationFail(operation: number): void;
  7651. /**
  7652. * Sets the stencil operation to use when depth fails
  7653. * @param operation defines the stencil operation to use when depth fails
  7654. */
  7655. setStencilOperationDepthFail(operation: number): void;
  7656. /**
  7657. * Sets the stencil operation to use when stencil passes
  7658. * @param operation defines the stencil operation to use when stencil passes
  7659. */
  7660. setStencilOperationPass(operation: number): void;
  7661. /**
  7662. * Sets a boolean indicating if the dithering state is enabled or disabled
  7663. * @param value defines the dithering state
  7664. */
  7665. setDitheringState(value: boolean): void;
  7666. /**
  7667. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7668. * @param value defines the rasterizer state
  7669. */
  7670. setRasterizerState(value: boolean): void;
  7671. /**
  7672. * stop executing a render loop function and remove it from the execution array
  7673. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7674. */
  7675. stopRenderLoop(renderFunction?: () => void): void;
  7676. /** @hidden */
  7677. _renderLoop(): void;
  7678. /**
  7679. * Register and execute a render loop. The engine can have more than one render function
  7680. * @param renderFunction defines the function to continuously execute
  7681. */
  7682. runRenderLoop(renderFunction: () => void): void;
  7683. /**
  7684. * Toggle full screen mode
  7685. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7686. * @param options defines an option object to be sent to the requestFullscreen function
  7687. */
  7688. switchFullscreen(requestPointerLock: boolean): void;
  7689. /**
  7690. * Clear the current render buffer or the current render target (if any is set up)
  7691. * @param color defines the color to use
  7692. * @param backBuffer defines if the back buffer must be cleared
  7693. * @param depth defines if the depth buffer must be cleared
  7694. * @param stencil defines if the stencil buffer must be cleared
  7695. */
  7696. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7697. /**
  7698. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7699. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7700. * @param y defines the y-coordinate of the corner of the clear rectangle
  7701. * @param width defines the width of the clear rectangle
  7702. * @param height defines the height of the clear rectangle
  7703. * @param clearColor defines the clear color
  7704. */
  7705. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7706. /**
  7707. * Set the WebGL's viewport
  7708. * @param viewport defines the viewport element to be used
  7709. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7710. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7711. */
  7712. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7713. /**
  7714. * Directly set the WebGL Viewport
  7715. * @param x defines the x coordinate of the viewport (in screen space)
  7716. * @param y defines the y coordinate of the viewport (in screen space)
  7717. * @param width defines the width of the viewport (in screen space)
  7718. * @param height defines the height of the viewport (in screen space)
  7719. * @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
  7720. */
  7721. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7722. /**
  7723. * Begin a new frame
  7724. */
  7725. beginFrame(): void;
  7726. /**
  7727. * Enf the current frame
  7728. */
  7729. endFrame(): void;
  7730. /**
  7731. * Resize the view according to the canvas' size
  7732. */
  7733. resize(): void;
  7734. /**
  7735. * Force a specific size of the canvas
  7736. * @param width defines the new canvas' width
  7737. * @param height defines the new canvas' height
  7738. */
  7739. setSize(width: number, height: number): void;
  7740. /**
  7741. * Gets a boolean indicating if a webVR device was detected
  7742. * @returns true if a webVR device was detected
  7743. */
  7744. isVRDevicePresent(): boolean;
  7745. /**
  7746. * Gets the current webVR device
  7747. * @returns the current webVR device (or null)
  7748. */
  7749. getVRDevice(): any;
  7750. /**
  7751. * Initializes a webVR display and starts listening to display change events
  7752. * The onVRDisplayChangedObservable will be notified upon these changes
  7753. * @returns The onVRDisplayChangedObservable
  7754. */
  7755. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7756. /**
  7757. * Initializes a webVR display and starts listening to display change events
  7758. * The onVRDisplayChangedObservable will be notified upon these changes
  7759. * @returns A promise containing a VRDisplay and if vr is supported
  7760. */
  7761. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7762. /**
  7763. * Call this function to switch to webVR mode
  7764. * Will do nothing if webVR is not supported or if there is no webVR device
  7765. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7766. */
  7767. enableVR(): void;
  7768. /**
  7769. * Call this function to leave webVR mode
  7770. * Will do nothing if webVR is not supported or if there is no webVR device
  7771. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7772. */
  7773. disableVR(): void;
  7774. private _onVRFullScreenTriggered;
  7775. private _getVRDisplaysAsync();
  7776. /**
  7777. * Binds the frame buffer to the specified texture.
  7778. * @param texture The texture to render to or null for the default canvas
  7779. * @param faceIndex The face of the texture to render to in case of cube texture
  7780. * @param requiredWidth The width of the target to render to
  7781. * @param requiredHeight The height of the target to render to
  7782. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7783. * @param depthStencilTexture The depth stencil texture to use to render
  7784. */
  7785. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7786. private bindUnboundFramebuffer(framebuffer);
  7787. /**
  7788. * Unbind the current render target texture from the webGL context
  7789. * @param texture defines the render target texture to unbind
  7790. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7791. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7792. */
  7793. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7794. /**
  7795. * Unbind a list of render target textures from the webGL context
  7796. * This is used only when drawBuffer extension or webGL2 are active
  7797. * @param textures defines the render target textures to unbind
  7798. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7799. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7800. */
  7801. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7802. /**
  7803. * Force the mipmap generation for the given render target texture
  7804. * @param texture defines the render target texture to use
  7805. */
  7806. generateMipMapsForCubemap(texture: InternalTexture): void;
  7807. /**
  7808. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7809. */
  7810. flushFramebuffer(): void;
  7811. /**
  7812. * Unbind the current render target and bind the default framebuffer
  7813. */
  7814. restoreDefaultFramebuffer(): void;
  7815. /**
  7816. * Create an uniform buffer
  7817. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7818. * @param elements defines the content of the uniform buffer
  7819. * @returns the webGL uniform buffer
  7820. */
  7821. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7822. /**
  7823. * Create a dynamic uniform buffer
  7824. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7825. * @param elements defines the content of the uniform buffer
  7826. * @returns the webGL uniform buffer
  7827. */
  7828. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7829. /**
  7830. * Update an existing uniform buffer
  7831. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7832. * @param uniformBuffer defines the target uniform buffer
  7833. * @param elements defines the content to update
  7834. * @param offset defines the offset in the uniform buffer where update should start
  7835. * @param count defines the size of the data to update
  7836. */
  7837. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7838. private _resetVertexBufferBinding();
  7839. /**
  7840. * Creates a vertex buffer
  7841. * @param data the data for the vertex buffer
  7842. * @returns the new WebGL static buffer
  7843. */
  7844. createVertexBuffer(data: DataArray): WebGLBuffer;
  7845. /**
  7846. * Creates a dynamic vertex buffer
  7847. * @param data the data for the dynamic vertex buffer
  7848. * @returns the new WebGL dynamic buffer
  7849. */
  7850. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7851. /**
  7852. * Update a dynamic index buffer
  7853. * @param indexBuffer defines the target index buffer
  7854. * @param indices defines the data to update
  7855. * @param offset defines the offset in the target index buffer where update should start
  7856. */
  7857. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7858. /**
  7859. * Updates a dynamic vertex buffer.
  7860. * @param vertexBuffer the vertex buffer to update
  7861. * @param data the data used to update the vertex buffer
  7862. * @param byteOffset the byte offset of the data
  7863. * @param byteLength the byte length of the data
  7864. */
  7865. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7866. private _resetIndexBufferBinding();
  7867. /**
  7868. * Creates a new index buffer
  7869. * @param indices defines the content of the index buffer
  7870. * @param updatable defines if the index buffer must be updatable
  7871. * @returns a new webGL buffer
  7872. */
  7873. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7874. /**
  7875. * Bind a webGL buffer to the webGL context
  7876. * @param buffer defines the buffer to bind
  7877. */
  7878. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7879. /**
  7880. * Bind an uniform buffer to the current webGL context
  7881. * @param buffer defines the buffer to bind
  7882. */
  7883. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7884. /**
  7885. * Bind a buffer to the current webGL context at a given location
  7886. * @param buffer defines the buffer to bind
  7887. * @param location defines the index where to bind the buffer
  7888. */
  7889. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7890. /**
  7891. * Bind a specific block at a given index in a specific shader program
  7892. * @param shaderProgram defines the shader program
  7893. * @param blockName defines the block name
  7894. * @param index defines the index where to bind the block
  7895. */
  7896. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7897. private bindIndexBuffer(buffer);
  7898. private bindBuffer(buffer, target);
  7899. /**
  7900. * update the bound buffer with the given data
  7901. * @param data defines the data to update
  7902. */
  7903. updateArrayBuffer(data: Float32Array): void;
  7904. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7905. private _bindIndexBufferWithCache(indexBuffer);
  7906. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7907. /**
  7908. * Records a vertex array object
  7909. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7910. * @param vertexBuffers defines the list of vertex buffers to store
  7911. * @param indexBuffer defines the index buffer to store
  7912. * @param effect defines the effect to store
  7913. * @returns the new vertex array object
  7914. */
  7915. recordVertexArrayObject(vertexBuffers: {
  7916. [key: string]: VertexBuffer;
  7917. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7918. /**
  7919. * Bind a specific vertex array object
  7920. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7921. * @param vertexArrayObject defines the vertex array object to bind
  7922. * @param indexBuffer defines the index buffer to bind
  7923. */
  7924. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7925. /**
  7926. * Bind webGl buffers directly to the webGL context
  7927. * @param vertexBuffer defines the vertex buffer to bind
  7928. * @param indexBuffer defines the index buffer to bind
  7929. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7930. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7931. * @param effect defines the effect associated with the vertex buffer
  7932. */
  7933. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7934. private _unbindVertexArrayObject();
  7935. /**
  7936. * Bind a list of vertex buffers to the webGL context
  7937. * @param vertexBuffers defines the list of vertex buffers to bind
  7938. * @param indexBuffer defines the index buffer to bind
  7939. * @param effect defines the effect associated with the vertex buffers
  7940. */
  7941. bindBuffers(vertexBuffers: {
  7942. [key: string]: Nullable<VertexBuffer>;
  7943. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7944. /**
  7945. * Unbind all instance attributes
  7946. */
  7947. unbindInstanceAttributes(): void;
  7948. /**
  7949. * Release and free the memory of a vertex array object
  7950. * @param vao defines the vertex array object to delete
  7951. */
  7952. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7953. /** @hidden */
  7954. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7955. /**
  7956. * Creates a webGL buffer to use with instanciation
  7957. * @param capacity defines the size of the buffer
  7958. * @returns the webGL buffer
  7959. */
  7960. createInstancesBuffer(capacity: number): WebGLBuffer;
  7961. /**
  7962. * Delete a webGL buffer used with instanciation
  7963. * @param buffer defines the webGL buffer to delete
  7964. */
  7965. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7966. /**
  7967. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7968. * @param instancesBuffer defines the webGL buffer to update and bind
  7969. * @param data defines the data to store in the buffer
  7970. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7971. */
  7972. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7973. /**
  7974. * Apply all cached states (depth, culling, stencil and alpha)
  7975. */
  7976. applyStates(): void;
  7977. /**
  7978. * Send a draw order
  7979. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7980. * @param indexStart defines the starting index
  7981. * @param indexCount defines the number of index to draw
  7982. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7983. */
  7984. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7985. /**
  7986. * Draw a list of points
  7987. * @param verticesStart defines the index of first vertex to draw
  7988. * @param verticesCount defines the count of vertices to draw
  7989. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7990. */
  7991. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7992. /**
  7993. * Draw a list of unindexed primitives
  7994. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7995. * @param verticesStart defines the index of first vertex to draw
  7996. * @param verticesCount defines the count of vertices to draw
  7997. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7998. */
  7999. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8000. /**
  8001. * Draw a list of indexed primitives
  8002. * @param fillMode defines the primitive to use
  8003. * @param indexStart defines the starting index
  8004. * @param indexCount defines the number of index to draw
  8005. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8006. */
  8007. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8008. /**
  8009. * Draw a list of unindexed primitives
  8010. * @param fillMode defines the primitive to use
  8011. * @param verticesStart defines the index of first vertex to draw
  8012. * @param verticesCount defines the count of vertices to draw
  8013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8014. */
  8015. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8016. private _drawMode(fillMode);
  8017. /** @hidden */
  8018. _releaseEffect(effect: Effect): void;
  8019. /** @hidden */
  8020. _deleteProgram(program: WebGLProgram): void;
  8021. /**
  8022. * Create a new effect (used to store vertex/fragment shaders)
  8023. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8024. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8025. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8026. * @param samplers defines an array of string used to represent textures
  8027. * @param defines defines the string containing the defines to use to compile the shaders
  8028. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8029. * @param onCompiled defines a function to call when the effect creation is successful
  8030. * @param onError defines a function to call when the effect creation has failed
  8031. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8032. * @returns the new Effect
  8033. */
  8034. 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;
  8035. /**
  8036. * Create an effect to use with particle systems
  8037. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8038. * @param uniformsNames defines a list of attribute names
  8039. * @param samplers defines an array of string used to represent textures
  8040. * @param defines defines the string containing the defines to use to compile the shaders
  8041. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8042. * @param onCompiled defines a function to call when the effect creation is successful
  8043. * @param onError defines a function to call when the effect creation has failed
  8044. * @returns the new Effect
  8045. */
  8046. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8047. /**
  8048. * Directly creates a webGL program
  8049. * @param vertexCode defines the vertex shader code to use
  8050. * @param fragmentCode defines the fragment shader code to use
  8051. * @param context defines the webGL context to use (if not set, the current one will be used)
  8052. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8053. * @returns the new webGL program
  8054. */
  8055. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8056. /**
  8057. * Creates a webGL program
  8058. * @param vertexCode defines the vertex shader code to use
  8059. * @param fragmentCode defines the fragment shader code to use
  8060. * @param defines defines the string containing the defines to use to compile the shaders
  8061. * @param context defines the webGL context to use (if not set, the current one will be used)
  8062. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8063. * @returns the new webGL program
  8064. */
  8065. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8066. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8067. /**
  8068. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8069. * @param shaderProgram defines the webGL program to use
  8070. * @param uniformsNames defines the list of uniform names
  8071. * @returns an array of webGL uniform locations
  8072. */
  8073. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8074. /**
  8075. * Gets the lsit of active attributes for a given webGL program
  8076. * @param shaderProgram defines the webGL program to use
  8077. * @param attributesNames defines the list of attribute names to get
  8078. * @returns an array of indices indicating the offset of each attribute
  8079. */
  8080. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8081. /**
  8082. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8083. * @param effect defines the effect to activate
  8084. */
  8085. enableEffect(effect: Nullable<Effect>): void;
  8086. /**
  8087. * Set the value of an uniform to an array of int32
  8088. * @param uniform defines the webGL uniform location where to store the value
  8089. * @param array defines the array of int32 to store
  8090. */
  8091. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8092. /**
  8093. * Set the value of an uniform to an array of int32 (stored as vec2)
  8094. * @param uniform defines the webGL uniform location where to store the value
  8095. * @param array defines the array of int32 to store
  8096. */
  8097. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8098. /**
  8099. * Set the value of an uniform to an array of int32 (stored as vec3)
  8100. * @param uniform defines the webGL uniform location where to store the value
  8101. * @param array defines the array of int32 to store
  8102. */
  8103. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8104. /**
  8105. * Set the value of an uniform to an array of int32 (stored as vec4)
  8106. * @param uniform defines the webGL uniform location where to store the value
  8107. * @param array defines the array of int32 to store
  8108. */
  8109. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8110. /**
  8111. * Set the value of an uniform to an array of float32
  8112. * @param uniform defines the webGL uniform location where to store the value
  8113. * @param array defines the array of float32 to store
  8114. */
  8115. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8116. /**
  8117. * Set the value of an uniform to an array of float32 (stored as vec2)
  8118. * @param uniform defines the webGL uniform location where to store the value
  8119. * @param array defines the array of float32 to store
  8120. */
  8121. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8122. /**
  8123. * Set the value of an uniform to an array of float32 (stored as vec3)
  8124. * @param uniform defines the webGL uniform location where to store the value
  8125. * @param array defines the array of float32 to store
  8126. */
  8127. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8128. /**
  8129. * Set the value of an uniform to an array of float32 (stored as vec4)
  8130. * @param uniform defines the webGL uniform location where to store the value
  8131. * @param array defines the array of float32 to store
  8132. */
  8133. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8134. /**
  8135. * Set the value of an uniform to an array of number
  8136. * @param uniform defines the webGL uniform location where to store the value
  8137. * @param array defines the array of number to store
  8138. */
  8139. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8140. /**
  8141. * Set the value of an uniform to an array of number (stored as vec2)
  8142. * @param uniform defines the webGL uniform location where to store the value
  8143. * @param array defines the array of number to store
  8144. */
  8145. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8146. /**
  8147. * Set the value of an uniform to an array of number (stored as vec3)
  8148. * @param uniform defines the webGL uniform location where to store the value
  8149. * @param array defines the array of number to store
  8150. */
  8151. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8152. /**
  8153. * Set the value of an uniform to an array of number (stored as vec4)
  8154. * @param uniform defines the webGL uniform location where to store the value
  8155. * @param array defines the array of number to store
  8156. */
  8157. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8158. /**
  8159. * Set the value of an uniform to an array of float32 (stored as matrices)
  8160. * @param uniform defines the webGL uniform location where to store the value
  8161. * @param matrices defines the array of float32 to store
  8162. */
  8163. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8164. /**
  8165. * Set the value of an uniform to a matrix
  8166. * @param uniform defines the webGL uniform location where to store the value
  8167. * @param matrix defines the matrix to store
  8168. */
  8169. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8170. /**
  8171. * Set the value of an uniform to a matrix (3x3)
  8172. * @param uniform defines the webGL uniform location where to store the value
  8173. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8174. */
  8175. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8176. /**
  8177. * Set the value of an uniform to a matrix (2x2)
  8178. * @param uniform defines the webGL uniform location where to store the value
  8179. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8180. */
  8181. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8182. /**
  8183. * Set the value of an uniform to a number (int)
  8184. * @param uniform defines the webGL uniform location where to store the value
  8185. * @param value defines the int number to store
  8186. */
  8187. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8188. /**
  8189. * Set the value of an uniform to a number (float)
  8190. * @param uniform defines the webGL uniform location where to store the value
  8191. * @param value defines the float number to store
  8192. */
  8193. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8194. /**
  8195. * Set the value of an uniform to a vec2
  8196. * @param uniform defines the webGL uniform location where to store the value
  8197. * @param x defines the 1st component of the value
  8198. * @param y defines the 2nd component of the value
  8199. */
  8200. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8201. /**
  8202. * Set the value of an uniform to a vec3
  8203. * @param uniform defines the webGL uniform location where to store the value
  8204. * @param x defines the 1st component of the value
  8205. * @param y defines the 2nd component of the value
  8206. * @param z defines the 3rd component of the value
  8207. */
  8208. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8209. /**
  8210. * Set the value of an uniform to a boolean
  8211. * @param uniform defines the webGL uniform location where to store the value
  8212. * @param bool defines the boolean to store
  8213. */
  8214. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8215. /**
  8216. * Set the value of an uniform to a vec4
  8217. * @param uniform defines the webGL uniform location where to store the value
  8218. * @param x defines the 1st component of the value
  8219. * @param y defines the 2nd component of the value
  8220. * @param z defines the 3rd component of the value
  8221. * @param w defines the 4th component of the value
  8222. */
  8223. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8224. /**
  8225. * Set the value of an uniform to a Color3
  8226. * @param uniform defines the webGL uniform location where to store the value
  8227. * @param color3 defines the color to store
  8228. */
  8229. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8230. /**
  8231. * Set the value of an uniform to a Color3 and an alpha value
  8232. * @param uniform defines the webGL uniform location where to store the value
  8233. * @param color3 defines the color to store
  8234. * @param alpha defines the alpha component to store
  8235. */
  8236. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8237. /**
  8238. * Sets a Color4 on a uniform variable
  8239. * @param uniform defines the uniform location
  8240. * @param color4 defines the value to be set
  8241. */
  8242. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8243. /**
  8244. * Set various states to the webGL context
  8245. * @param culling defines backface culling state
  8246. * @param zOffset defines the value to apply to zOffset (0 by default)
  8247. * @param force defines if states must be applied even if cache is up to date
  8248. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8249. */
  8250. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8251. /**
  8252. * Set the z offset to apply to current rendering
  8253. * @param value defines the offset to apply
  8254. */
  8255. setZOffset(value: number): void;
  8256. /**
  8257. * Gets the current value of the zOffset
  8258. * @returns the current zOffset state
  8259. */
  8260. getZOffset(): number;
  8261. /**
  8262. * Enable or disable depth buffering
  8263. * @param enable defines the state to set
  8264. */
  8265. setDepthBuffer(enable: boolean): void;
  8266. /**
  8267. * Gets a boolean indicating if depth writing is enabled
  8268. * @returns the current depth writing state
  8269. */
  8270. getDepthWrite(): boolean;
  8271. /**
  8272. * Enable or disable depth writing
  8273. * @param enable defines the state to set
  8274. */
  8275. setDepthWrite(enable: boolean): void;
  8276. /**
  8277. * Enable or disable color writing
  8278. * @param enable defines the state to set
  8279. */
  8280. setColorWrite(enable: boolean): void;
  8281. /**
  8282. * Gets a boolean indicating if color writing is enabled
  8283. * @returns the current color writing state
  8284. */
  8285. getColorWrite(): boolean;
  8286. /**
  8287. * Sets alpha constants used by some alpha blending modes
  8288. * @param r defines the red component
  8289. * @param g defines the green component
  8290. * @param b defines the blue component
  8291. * @param a defines the alpha component
  8292. */
  8293. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8294. /**
  8295. * Sets the current alpha mode
  8296. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8297. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8299. */
  8300. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8301. /**
  8302. * Gets the current alpha mode
  8303. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8304. * @returns the current alpha mode
  8305. */
  8306. getAlphaMode(): number;
  8307. /**
  8308. * Force the entire cache to be cleared
  8309. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8310. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8311. */
  8312. wipeCaches(bruteForce?: boolean): void;
  8313. /**
  8314. * Set the compressed texture format to use, based on the formats you have, and the formats
  8315. * supported by the hardware / browser.
  8316. *
  8317. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8318. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8319. * to API arguments needed to compressed textures. This puts the burden on the container
  8320. * generator to house the arcane code for determining these for current & future formats.
  8321. *
  8322. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8323. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8324. *
  8325. * Note: The result of this call is not taken into account when a texture is base64.
  8326. *
  8327. * @param formatsAvailable defines the list of those format families you have created
  8328. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8329. *
  8330. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8331. * @returns The extension selected.
  8332. */
  8333. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8334. /** @hidden */
  8335. _createTexture(): WebGLTexture;
  8336. /**
  8337. * Usually called from BABYLON.Texture.ts.
  8338. * Passed information to create a WebGLTexture
  8339. * @param urlArg defines a value which contains one of the following:
  8340. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8341. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8342. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8343. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8344. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8345. * @param scene needed for loading to the correct scene
  8346. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8347. * @param onLoad optional callback to be called upon successful completion
  8348. * @param onError optional callback to be called upon failure
  8349. * @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
  8350. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8351. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8352. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8353. */
  8354. 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;
  8355. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8356. /**
  8357. * Update a raw texture
  8358. * @param texture defines the texture to update
  8359. * @param data defines the data to store in the texture
  8360. * @param format defines the format of the data
  8361. * @param invertY defines if data must be stored with Y axis inverted
  8362. * @param compression defines the compression used (null by default)
  8363. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8364. */
  8365. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8366. /**
  8367. * Creates a raw texture
  8368. * @param data defines the data to store in the texture
  8369. * @param width defines the width of the texture
  8370. * @param height defines the height of the texture
  8371. * @param format defines the format of the data
  8372. * @param generateMipMaps defines if the engine should generate the mip levels
  8373. * @param invertY defines if data must be stored with Y axis inverted
  8374. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8375. * @param compression defines the compression used (null by default)
  8376. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8377. * @returns the raw texture inside an InternalTexture
  8378. */
  8379. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8380. /**
  8381. * Creates a dynamic texture
  8382. * @param width defines the width of the texture
  8383. * @param height defines the height of the texture
  8384. * @param generateMipMaps defines if the engine should generate the mip levels
  8385. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8386. * @returns the dynamic texture inside an InternalTexture
  8387. */
  8388. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8389. /**
  8390. * Update the sampling mode of a given texture
  8391. * @param samplingMode defines the required sampling mode
  8392. * @param texture defines the texture to update
  8393. */
  8394. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8395. /**
  8396. * Update the content of a dynamic texture
  8397. * @param texture defines the texture to update
  8398. * @param canvas defines the canvas containing the source
  8399. * @param invertY defines if data must be stored with Y axis inverted
  8400. * @param premulAlpha defines if alpha is stored as premultiplied
  8401. * @param format defines the format of the data
  8402. */
  8403. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8404. /**
  8405. * Update a video texture
  8406. * @param texture defines the texture to update
  8407. * @param video defines the video element to use
  8408. * @param invertY defines if data must be stored with Y axis inverted
  8409. */
  8410. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8411. /**
  8412. * Updates a depth texture Comparison Mode and Function.
  8413. * If the comparison Function is equal to 0, the mode will be set to none.
  8414. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8415. * @param texture The texture to set the comparison function for
  8416. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8417. */
  8418. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8419. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8420. /**
  8421. * Creates a depth stencil texture.
  8422. * This is only available in WebGL 2 or with the depth texture extension available.
  8423. * @param size The size of face edge in the texture.
  8424. * @param options The options defining the texture.
  8425. * @returns The texture
  8426. */
  8427. createDepthStencilTexture(size: number | {
  8428. width: number;
  8429. height: number;
  8430. }, options: DepthTextureCreationOptions): InternalTexture;
  8431. /**
  8432. * Creates a depth stencil texture.
  8433. * This is only available in WebGL 2 or with the depth texture extension available.
  8434. * @param size The size of face edge in the texture.
  8435. * @param options The options defining the texture.
  8436. * @returns The texture
  8437. */
  8438. private _createDepthStencilTexture(size, options);
  8439. /**
  8440. * Creates a depth stencil cube texture.
  8441. * This is only available in WebGL 2.
  8442. * @param size The size of face edge in the cube texture.
  8443. * @param options The options defining the cube texture.
  8444. * @returns The cube texture
  8445. */
  8446. private _createDepthStencilCubeTexture(size, options);
  8447. /**
  8448. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8449. * @param renderTarget The render target to set the frame buffer for
  8450. */
  8451. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8452. /**
  8453. * Creates a new render target texture
  8454. * @param size defines the size of the texture
  8455. * @param options defines the options used to create the texture
  8456. * @returns a new render target texture stored in an InternalTexture
  8457. */
  8458. createRenderTargetTexture(size: number | {
  8459. width: number;
  8460. height: number;
  8461. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8462. /**
  8463. * Create a multi render target texture
  8464. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8465. * @param size defines the size of the texture
  8466. * @param options defines the creation options
  8467. * @returns the cube texture as an InternalTexture
  8468. */
  8469. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8470. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8471. /**
  8472. * Updates the sample count of a render target texture
  8473. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8474. * @param texture defines the texture to update
  8475. * @param samples defines the sample count to set
  8476. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8477. */
  8478. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8479. /**
  8480. * Update the sample count for a given multiple render target texture
  8481. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8482. * @param textures defines the textures to update
  8483. * @param samples defines the sample count to set
  8484. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8485. */
  8486. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8487. /** @hidden */
  8488. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8489. /** @hidden */
  8490. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8491. /**
  8492. * Creates a new render target cube texture
  8493. * @param size defines the size of the texture
  8494. * @param options defines the options used to create the texture
  8495. * @returns a new render target cube texture stored in an InternalTexture
  8496. */
  8497. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8498. /**
  8499. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8500. * @param rootUrl defines the url where the file to load is located
  8501. * @param scene defines the current scene
  8502. * @param scale defines scale to apply to the mip map selection
  8503. * @param offset defines offset to apply to the mip map selection
  8504. * @param onLoad defines an optional callback raised when the texture is loaded
  8505. * @param onError defines an optional callback raised if there is an issue to load the texture
  8506. * @param format defines the format of the data
  8507. * @param forcedExtension defines the extension to use to pick the right loader
  8508. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8509. * @returns the cube texture as an InternalTexture
  8510. */
  8511. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8512. /**
  8513. * Creates a cube texture
  8514. * @param rootUrl defines the url where the files to load is located
  8515. * @param scene defines the current scene
  8516. * @param files defines the list of files to load (1 per face)
  8517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8518. * @param onLoad defines an optional callback raised when the texture is loaded
  8519. * @param onError defines an optional callback raised if there is an issue to load the texture
  8520. * @param format defines the format of the data
  8521. * @param forcedExtension defines the extension to use to pick the right loader
  8522. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8523. * @returns the cube texture as an InternalTexture
  8524. */
  8525. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8526. private setCubeMapTextureParams(gl, loadMipmap);
  8527. /**
  8528. * Update a raw cube texture
  8529. * @param texture defines the texture to udpdate
  8530. * @param data defines the data to store
  8531. * @param format defines the data format
  8532. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8533. * @param invertY defines if data must be stored with Y axis inverted
  8534. * @param compression defines the compression used (null by default)
  8535. * @param level defines which level of the texture to update
  8536. */
  8537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8538. /**
  8539. * Creates a new raw cube texture
  8540. * @param data defines the array of data to use to create each face
  8541. * @param size defines the size of the textures
  8542. * @param format defines the format of the data
  8543. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8544. * @param generateMipMaps defines if the engine should generate the mip levels
  8545. * @param invertY defines if data must be stored with Y axis inverted
  8546. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8547. * @param compression defines the compression used (null by default)
  8548. * @returns the cube texture as an InternalTexture
  8549. */
  8550. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8551. /**
  8552. * Creates a new raw cube texture from a specified url
  8553. * @param url defines the url where the data is located
  8554. * @param scene defines the current scene
  8555. * @param size defines the size of the textures
  8556. * @param format defines the format of the data
  8557. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8558. * @param noMipmap defines if the engine should avoid generating the mip levels
  8559. * @param callback defines a callback used to extract texture data from loaded data
  8560. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8561. * @param onLoad defines a callback called when texture is loaded
  8562. * @param onError defines a callback called if there is an error
  8563. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8564. * @param invertY defines if data must be stored with Y axis inverted
  8565. * @returns the cube texture as an InternalTexture
  8566. */
  8567. 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;
  8568. /**
  8569. * Update a raw 3D texture
  8570. * @param texture defines the texture to update
  8571. * @param data defines the data to store
  8572. * @param format defines the data format
  8573. * @param invertY defines if data must be stored with Y axis inverted
  8574. * @param compression defines the used compression (can be null)
  8575. */
  8576. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  8577. /**
  8578. * Creates a new raw 3D texture
  8579. * @param data defines the data used to create the texture
  8580. * @param width defines the width of the texture
  8581. * @param height defines the height of the texture
  8582. * @param depth defines the depth of the texture
  8583. * @param format defines the format of the texture
  8584. * @param generateMipMaps defines if the engine must generate mip levels
  8585. * @param invertY defines if data must be stored with Y axis inverted
  8586. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8587. * @param compression defines the compressed used (can be null)
  8588. * @returns a new raw 3D texture (stored in an InternalTexture)
  8589. */
  8590. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8591. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8592. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8593. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8594. /** @hidden */
  8595. _releaseFramebufferObjects(texture: InternalTexture): void;
  8596. /** @hidden */
  8597. _releaseTexture(texture: InternalTexture): void;
  8598. private setProgram(program);
  8599. private _boundUniforms;
  8600. /**
  8601. * Binds an effect to the webGL context
  8602. * @param effect defines the effect to bind
  8603. */
  8604. bindSamplers(effect: Effect): void;
  8605. private _moveBoundTextureOnTop(internalTexture);
  8606. private _getCorrectTextureChannel(channel, internalTexture);
  8607. private _linkTrackers(previous, next);
  8608. private _removeDesignatedSlot(internalTexture);
  8609. private _activateCurrentTexture();
  8610. /** @hidden */
  8611. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8612. /** @hidden */
  8613. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8614. /**
  8615. * Sets a texture to the webGL context from a postprocess
  8616. * @param channel defines the channel to use
  8617. * @param postProcess defines the source postprocess
  8618. */
  8619. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8620. /**
  8621. * Binds the output of the passed in post process to the texture channel specified
  8622. * @param channel The channel the texture should be bound to
  8623. * @param postProcess The post process which's output should be bound
  8624. */
  8625. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8626. /**
  8627. * Unbind all textures from the webGL context
  8628. */
  8629. unbindAllTextures(): void;
  8630. /**
  8631. * Sets a texture to the according uniform.
  8632. * @param channel The texture channel
  8633. * @param uniform The uniform to set
  8634. * @param texture The texture to apply
  8635. */
  8636. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8637. /**
  8638. * Sets a depth stencil texture from a render target to the according uniform.
  8639. * @param channel The texture channel
  8640. * @param uniform The uniform to set
  8641. * @param texture The render target texture containing the depth stencil texture to apply
  8642. */
  8643. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8644. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8645. private _getTextureWrapMode(mode);
  8646. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8647. /**
  8648. * Sets an array of texture to the webGL context
  8649. * @param channel defines the channel where the texture array must be set
  8650. * @param uniform defines the associated uniform location
  8651. * @param textures defines the array of textures to bind
  8652. */
  8653. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8654. /** @hidden */
  8655. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8656. private _setTextureParameterFloat(target, parameter, value, texture);
  8657. private _setTextureParameterInteger(target, parameter, value, texture?);
  8658. /**
  8659. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8660. * @param x defines the x coordinate of the rectangle where pixels must be read
  8661. * @param y defines the y coordinate of the rectangle where pixels must be read
  8662. * @param width defines the width of the rectangle where pixels must be read
  8663. * @param height defines the height of the rectangle where pixels must be read
  8664. * @returns a Uint8Array containing RGBA colors
  8665. */
  8666. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8667. /**
  8668. * Add an externaly attached data from its key.
  8669. * This method call will fail and return false, if such key already exists.
  8670. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8671. * @param key the unique key that identifies the data
  8672. * @param data the data object to associate to the key for this Engine instance
  8673. * @return true if no such key were already present and the data was added successfully, false otherwise
  8674. */
  8675. addExternalData<T>(key: string, data: T): boolean;
  8676. /**
  8677. * Get an externaly attached data from its key
  8678. * @param key the unique key that identifies the data
  8679. * @return the associated data, if present (can be null), or undefined if not present
  8680. */
  8681. getExternalData<T>(key: string): T;
  8682. /**
  8683. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8684. * @param key the unique key that identifies the data
  8685. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8686. * @return the associated data, can be null if the factory returned null.
  8687. */
  8688. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8689. /**
  8690. * Remove an externaly attached data from the Engine instance
  8691. * @param key the unique key that identifies the data
  8692. * @return true if the data was successfully removed, false if it doesn't exist
  8693. */
  8694. removeExternalData(key: string): boolean;
  8695. /**
  8696. * Unbind all vertex attributes from the webGL context
  8697. */
  8698. unbindAllAttributes(): void;
  8699. /**
  8700. * 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
  8701. */
  8702. releaseEffects(): void;
  8703. /**
  8704. * Dispose and release all associated resources
  8705. */
  8706. dispose(): void;
  8707. /**
  8708. * Display the loading screen
  8709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8710. */
  8711. displayLoadingUI(): void;
  8712. /**
  8713. * Hide the loading screen
  8714. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8715. */
  8716. hideLoadingUI(): void;
  8717. /**
  8718. * Gets the current loading screen object
  8719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8720. */
  8721. /**
  8722. * Sets the current loading screen object
  8723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8724. */
  8725. loadingScreen: ILoadingScreen;
  8726. /**
  8727. * Sets the current loading screen text
  8728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8729. */
  8730. loadingUIText: string;
  8731. /**
  8732. * Sets the current loading screen background color
  8733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8734. */
  8735. loadingUIBackgroundColor: string;
  8736. /**
  8737. * Attach a new callback raised when context lost event is fired
  8738. * @param callback defines the callback to call
  8739. */
  8740. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8741. /**
  8742. * Attach a new callback raised when context restored event is fired
  8743. * @param callback defines the callback to call
  8744. */
  8745. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8746. /**
  8747. * Gets the source code of the vertex shader associated with a specific webGL program
  8748. * @param program defines the program to use
  8749. * @returns a string containing the source code of the vertex shader associated with the program
  8750. */
  8751. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8752. /**
  8753. * Gets the source code of the fragment shader associated with a specific webGL program
  8754. * @param program defines the program to use
  8755. * @returns a string containing the source code of the fragment shader associated with the program
  8756. */
  8757. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8758. /**
  8759. * Get the current error code of the webGL context
  8760. * @returns the error code
  8761. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8762. */
  8763. getError(): number;
  8764. /**
  8765. * Gets the current framerate
  8766. * @returns a number representing the framerate
  8767. */
  8768. getFps(): number;
  8769. /**
  8770. * Gets the time spent between current and previous frame
  8771. * @returns a number representing the delta time in ms
  8772. */
  8773. getDeltaTime(): number;
  8774. private _measureFps();
  8775. /** @hidden */
  8776. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  8777. private _canRenderToFloatFramebuffer();
  8778. private _canRenderToHalfFloatFramebuffer();
  8779. private _canRenderToFramebuffer(type);
  8780. /** @hidden */
  8781. _getWebGLTextureType(type: number): number;
  8782. private _getInternalFormat(format);
  8783. /** @hidden */
  8784. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8785. /** @hidden */
  8786. _getRGBAMultiSampleBufferFormat(type: number): number;
  8787. /**
  8788. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8789. * @return the new query
  8790. */
  8791. createQuery(): WebGLQuery;
  8792. /**
  8793. * Delete and release a webGL query
  8794. * @param query defines the query to delete
  8795. * @return the current engine
  8796. */
  8797. deleteQuery(query: WebGLQuery): Engine;
  8798. /**
  8799. * Check if a given query has resolved and got its value
  8800. * @param query defines the query to check
  8801. * @returns true if the query got its value
  8802. */
  8803. isQueryResultAvailable(query: WebGLQuery): boolean;
  8804. /**
  8805. * Gets the value of a given query
  8806. * @param query defines the query to check
  8807. * @returns the value of the query
  8808. */
  8809. getQueryResult(query: WebGLQuery): number;
  8810. /**
  8811. * Initiates an occlusion query
  8812. * @param algorithmType defines the algorithm to use
  8813. * @param query defines the query to use
  8814. * @returns the current engine
  8815. * @see http://doc.babylonjs.com/features/occlusionquery
  8816. */
  8817. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8818. /**
  8819. * Ends an occlusion query
  8820. * @see http://doc.babylonjs.com/features/occlusionquery
  8821. * @param algorithmType defines the algorithm to use
  8822. * @returns the current engine
  8823. */
  8824. endOcclusionQuery(algorithmType: number): Engine;
  8825. private _createTimeQuery();
  8826. private _deleteTimeQuery(query);
  8827. private _getTimeQueryResult(query);
  8828. private _getTimeQueryAvailability(query);
  8829. private _currentNonTimestampToken;
  8830. /**
  8831. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8832. * Please note that only one query can be issued at a time
  8833. * @returns a time token used to track the time span
  8834. */
  8835. startTimeQuery(): Nullable<_TimeToken>;
  8836. /**
  8837. * Ends a time query
  8838. * @param token defines the token used to measure the time span
  8839. * @returns the time spent (in ns)
  8840. */
  8841. endTimeQuery(token: _TimeToken): int;
  8842. private getGlAlgorithmType(algorithmType);
  8843. /**
  8844. * Creates a webGL transform feedback object
  8845. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8846. * @returns the webGL transform feedback object
  8847. */
  8848. createTransformFeedback(): WebGLTransformFeedback;
  8849. /**
  8850. * Delete a webGL transform feedback object
  8851. * @param value defines the webGL transform feedback object to delete
  8852. */
  8853. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8854. /**
  8855. * Bind a webGL transform feedback object to the webgl context
  8856. * @param value defines the webGL transform feedback object to bind
  8857. */
  8858. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8859. /**
  8860. * Begins a transform feedback operation
  8861. * @param usePoints defines if points or triangles must be used
  8862. */
  8863. beginTransformFeedback(usePoints?: boolean): void;
  8864. /**
  8865. * Ends a transform feedback operation
  8866. */
  8867. endTransformFeedback(): void;
  8868. /**
  8869. * Specify the varyings to use with transform feedback
  8870. * @param program defines the associated webGL program
  8871. * @param value defines the list of strings representing the varying names
  8872. */
  8873. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8874. /**
  8875. * Bind a webGL buffer for a transform feedback operation
  8876. * @param value defines the webGL buffer to bind
  8877. */
  8878. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8879. /** @hidden */
  8880. _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;
  8881. /** @hidden */
  8882. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8883. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8884. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8885. /**
  8886. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8887. * @returns true if the engine can be created
  8888. * @ignorenaming
  8889. */
  8890. static isSupported(): boolean;
  8891. }
  8892. }
  8893. declare module BABYLON {
  8894. class NullEngineOptions {
  8895. renderWidth: number;
  8896. renderHeight: number;
  8897. textureSize: number;
  8898. deterministicLockstep: boolean;
  8899. lockstepMaxSteps: number;
  8900. }
  8901. /**
  8902. * The null engine class provides support for headless version of babylon.js.
  8903. * This can be used in server side scenario or for testing purposes
  8904. */
  8905. class NullEngine extends Engine {
  8906. private _options;
  8907. isDeterministicLockStep(): boolean;
  8908. getLockstepMaxSteps(): number;
  8909. getHardwareScalingLevel(): number;
  8910. constructor(options?: NullEngineOptions);
  8911. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8912. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8913. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8914. getRenderWidth(useScreen?: boolean): number;
  8915. getRenderHeight(useScreen?: boolean): number;
  8916. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8917. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8918. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8919. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8920. bindSamplers(effect: Effect): void;
  8921. enableEffect(effect: Effect): void;
  8922. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8923. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8924. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8925. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8926. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8927. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8928. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8929. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8930. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8931. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8932. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8933. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8934. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8935. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8936. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8937. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8938. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8939. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8940. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8941. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8942. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8943. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8944. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8945. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8946. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8947. bindBuffers(vertexBuffers: {
  8948. [key: string]: VertexBuffer;
  8949. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8950. wipeCaches(bruteForce?: boolean): void;
  8951. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8952. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8953. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8954. _createTexture(): WebGLTexture;
  8955. _releaseTexture(texture: InternalTexture): void;
  8956. 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;
  8957. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8958. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8959. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8960. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8961. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8962. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8963. /**
  8964. * Updates a dynamic vertex buffer.
  8965. * @param vertexBuffer the vertex buffer to update
  8966. * @param data the data used to update the vertex buffer
  8967. * @param byteOffset the byte offset of the data (optional)
  8968. * @param byteLength the byte length of the data (optional)
  8969. */
  8970. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8971. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8972. _bindTexture(channel: number, texture: InternalTexture): void;
  8973. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8974. releaseEffects(): void;
  8975. }
  8976. }
  8977. interface WebGLRenderingContext {
  8978. readonly RASTERIZER_DISCARD: number;
  8979. readonly DEPTH_COMPONENT24: number;
  8980. readonly TEXTURE_3D: number;
  8981. readonly TEXTURE_2D_ARRAY: number;
  8982. readonly TEXTURE_COMPARE_FUNC: number;
  8983. readonly TEXTURE_COMPARE_MODE: number;
  8984. readonly COMPARE_REF_TO_TEXTURE: number;
  8985. readonly TEXTURE_WRAP_R: number;
  8986. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8987. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8988. 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;
  8989. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8990. readonly TRANSFORM_FEEDBACK: number;
  8991. readonly INTERLEAVED_ATTRIBS: number;
  8992. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8993. createTransformFeedback(): WebGLTransformFeedback;
  8994. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8995. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8996. beginTransformFeedback(primitiveMode: number): void;
  8997. endTransformFeedback(): void;
  8998. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8999. }
  9000. interface ImageBitmap {
  9001. readonly width: number;
  9002. readonly height: number;
  9003. close(): void;
  9004. }
  9005. interface WebGLQuery extends WebGLObject {
  9006. }
  9007. declare var WebGLQuery: {
  9008. prototype: WebGLQuery;
  9009. new (): WebGLQuery;
  9010. };
  9011. interface WebGLSampler extends WebGLObject {
  9012. }
  9013. declare var WebGLSampler: {
  9014. prototype: WebGLSampler;
  9015. new (): WebGLSampler;
  9016. };
  9017. interface WebGLSync extends WebGLObject {
  9018. }
  9019. declare var WebGLSync: {
  9020. prototype: WebGLSync;
  9021. new (): WebGLSync;
  9022. };
  9023. interface WebGLTransformFeedback extends WebGLObject {
  9024. }
  9025. declare var WebGLTransformFeedback: {
  9026. prototype: WebGLTransformFeedback;
  9027. new (): WebGLTransformFeedback;
  9028. };
  9029. interface WebGLVertexArrayObject extends WebGLObject {
  9030. }
  9031. declare var WebGLVertexArrayObject: {
  9032. prototype: WebGLVertexArrayObject;
  9033. new (): WebGLVertexArrayObject;
  9034. };
  9035. declare module BABYLON {
  9036. class KeyboardEventTypes {
  9037. static _KEYDOWN: number;
  9038. static _KEYUP: number;
  9039. static readonly KEYDOWN: number;
  9040. static readonly KEYUP: number;
  9041. }
  9042. class KeyboardInfo {
  9043. type: number;
  9044. event: KeyboardEvent;
  9045. constructor(type: number, event: KeyboardEvent);
  9046. }
  9047. /**
  9048. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9049. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9050. */
  9051. class KeyboardInfoPre extends KeyboardInfo {
  9052. constructor(type: number, event: KeyboardEvent);
  9053. skipOnPointerObservable: boolean;
  9054. }
  9055. }
  9056. declare module BABYLON {
  9057. class PointerEventTypes {
  9058. static _POINTERDOWN: number;
  9059. static _POINTERUP: number;
  9060. static _POINTERMOVE: number;
  9061. static _POINTERWHEEL: number;
  9062. static _POINTERPICK: number;
  9063. static _POINTERTAP: number;
  9064. static _POINTERDOUBLETAP: number;
  9065. static readonly POINTERDOWN: number;
  9066. static readonly POINTERUP: number;
  9067. static readonly POINTERMOVE: number;
  9068. static readonly POINTERWHEEL: number;
  9069. static readonly POINTERPICK: number;
  9070. static readonly POINTERTAP: number;
  9071. static readonly POINTERDOUBLETAP: number;
  9072. }
  9073. class PointerInfoBase {
  9074. type: number;
  9075. event: PointerEvent | MouseWheelEvent;
  9076. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9077. }
  9078. /**
  9079. * This class is used to store pointer related info for the onPrePointerObservable event.
  9080. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9081. */
  9082. class PointerInfoPre extends PointerInfoBase {
  9083. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9084. localPosition: Vector2;
  9085. skipOnPointerObservable: boolean;
  9086. }
  9087. /**
  9088. * This type contains all the data related to a pointer event in Babylon.js.
  9089. * 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.
  9090. */
  9091. class PointerInfo extends PointerInfoBase {
  9092. pickInfo: Nullable<PickingInfo>;
  9093. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9094. }
  9095. }
  9096. declare module BABYLON {
  9097. /**
  9098. * This class can be used to get instrumentation data from a Babylon engine
  9099. */
  9100. class EngineInstrumentation implements IDisposable {
  9101. engine: Engine;
  9102. private _captureGPUFrameTime;
  9103. private _gpuFrameTimeToken;
  9104. private _gpuFrameTime;
  9105. private _captureShaderCompilationTime;
  9106. private _shaderCompilationTime;
  9107. private _onBeginFrameObserver;
  9108. private _onEndFrameObserver;
  9109. private _onBeforeShaderCompilationObserver;
  9110. private _onAfterShaderCompilationObserver;
  9111. /**
  9112. * Gets the perf counter used for GPU frame time
  9113. */
  9114. readonly gpuFrameTimeCounter: PerfCounter;
  9115. /**
  9116. * Gets the GPU frame time capture status
  9117. */
  9118. /**
  9119. * Enable or disable the GPU frame time capture
  9120. */
  9121. captureGPUFrameTime: boolean;
  9122. /**
  9123. * Gets the perf counter used for shader compilation time
  9124. */
  9125. readonly shaderCompilationTimeCounter: PerfCounter;
  9126. /**
  9127. * Gets the shader compilation time capture status
  9128. */
  9129. /**
  9130. * Enable or disable the shader compilation time capture
  9131. */
  9132. captureShaderCompilationTime: boolean;
  9133. constructor(engine: Engine);
  9134. dispose(): void;
  9135. }
  9136. }
  9137. declare module BABYLON {
  9138. /**
  9139. * This class can be used to get instrumentation data from a Babylon engine
  9140. */
  9141. class SceneInstrumentation implements IDisposable {
  9142. scene: Scene;
  9143. private _captureActiveMeshesEvaluationTime;
  9144. private _activeMeshesEvaluationTime;
  9145. private _captureRenderTargetsRenderTime;
  9146. private _renderTargetsRenderTime;
  9147. private _captureFrameTime;
  9148. private _frameTime;
  9149. private _captureRenderTime;
  9150. private _renderTime;
  9151. private _captureInterFrameTime;
  9152. private _interFrameTime;
  9153. private _captureParticlesRenderTime;
  9154. private _particlesRenderTime;
  9155. private _captureSpritesRenderTime;
  9156. private _spritesRenderTime;
  9157. private _capturePhysicsTime;
  9158. private _physicsTime;
  9159. private _captureAnimationsTime;
  9160. private _animationsTime;
  9161. private _onBeforeActiveMeshesEvaluationObserver;
  9162. private _onAfterActiveMeshesEvaluationObserver;
  9163. private _onBeforeRenderTargetsRenderObserver;
  9164. private _onAfterRenderTargetsRenderObserver;
  9165. private _onAfterRenderObserver;
  9166. private _onBeforeDrawPhaseObserver;
  9167. private _onAfterDrawPhaseObserver;
  9168. private _onBeforeAnimationsObserver;
  9169. private _onBeforeParticlesRenderingObserver;
  9170. private _onAfterParticlesRenderingObserver;
  9171. private _onBeforeSpritesRenderingObserver;
  9172. private _onAfterSpritesRenderingObserver;
  9173. private _onBeforePhysicsObserver;
  9174. private _onAfterPhysicsObserver;
  9175. private _onAfterAnimationsObserver;
  9176. /**
  9177. * Gets the perf counter used for active meshes evaluation time
  9178. */
  9179. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9180. /**
  9181. * Gets the active meshes evaluation time capture status
  9182. */
  9183. /**
  9184. * Enable or disable the active meshes evaluation time capture
  9185. */
  9186. captureActiveMeshesEvaluationTime: boolean;
  9187. /**
  9188. * Gets the perf counter used for render targets render time
  9189. */
  9190. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9191. /**
  9192. * Gets the render targets render time capture status
  9193. */
  9194. /**
  9195. * Enable or disable the render targets render time capture
  9196. */
  9197. captureRenderTargetsRenderTime: boolean;
  9198. /**
  9199. * Gets the perf counter used for particles render time
  9200. */
  9201. readonly particlesRenderTimeCounter: PerfCounter;
  9202. /**
  9203. * Gets the particles render time capture status
  9204. */
  9205. /**
  9206. * Enable or disable the particles render time capture
  9207. */
  9208. captureParticlesRenderTime: boolean;
  9209. /**
  9210. * Gets the perf counter used for sprites render time
  9211. */
  9212. readonly spritesRenderTimeCounter: PerfCounter;
  9213. /**
  9214. * Gets the sprites render time capture status
  9215. */
  9216. /**
  9217. * Enable or disable the sprites render time capture
  9218. */
  9219. captureSpritesRenderTime: boolean;
  9220. /**
  9221. * Gets the perf counter used for physics time
  9222. */
  9223. readonly physicsTimeCounter: PerfCounter;
  9224. /**
  9225. * Gets the physics time capture status
  9226. */
  9227. /**
  9228. * Enable or disable the physics time capture
  9229. */
  9230. capturePhysicsTime: boolean;
  9231. /**
  9232. * Gets the perf counter used for animations time
  9233. */
  9234. readonly animationsTimeCounter: PerfCounter;
  9235. /**
  9236. * Gets the animations time capture status
  9237. */
  9238. /**
  9239. * Enable or disable the animations time capture
  9240. */
  9241. captureAnimationsTime: boolean;
  9242. /**
  9243. * Gets the perf counter used for frame time capture
  9244. */
  9245. readonly frameTimeCounter: PerfCounter;
  9246. /**
  9247. * Gets the frame time capture status
  9248. */
  9249. /**
  9250. * Enable or disable the frame time capture
  9251. */
  9252. captureFrameTime: boolean;
  9253. /**
  9254. * Gets the perf counter used for inter-frames time capture
  9255. */
  9256. readonly interFrameTimeCounter: PerfCounter;
  9257. /**
  9258. * Gets the inter-frames time capture status
  9259. */
  9260. /**
  9261. * Enable or disable the inter-frames time capture
  9262. */
  9263. captureInterFrameTime: boolean;
  9264. /**
  9265. * Gets the perf counter used for render time capture
  9266. */
  9267. readonly renderTimeCounter: PerfCounter;
  9268. /**
  9269. * Gets the render time capture status
  9270. */
  9271. /**
  9272. * Enable or disable the render time capture
  9273. */
  9274. captureRenderTime: boolean;
  9275. /**
  9276. * Gets the perf counter used for draw calls
  9277. */
  9278. readonly drawCallsCounter: PerfCounter;
  9279. /**
  9280. * Gets the perf counter used for texture collisions
  9281. */
  9282. readonly textureCollisionsCounter: PerfCounter;
  9283. constructor(scene: Scene);
  9284. dispose(): void;
  9285. }
  9286. }
  9287. declare module BABYLON {
  9288. /**
  9289. * @hidden
  9290. **/
  9291. class _TimeToken {
  9292. _startTimeQuery: Nullable<WebGLQuery>;
  9293. _endTimeQuery: Nullable<WebGLQuery>;
  9294. _timeElapsedQuery: Nullable<WebGLQuery>;
  9295. _timeElapsedQueryEnded: boolean;
  9296. }
  9297. }
  9298. declare module BABYLON {
  9299. class StickValues {
  9300. x: number;
  9301. y: number;
  9302. constructor(x: number, y: number);
  9303. }
  9304. interface GamepadButtonChanges {
  9305. changed: boolean;
  9306. pressChanged: boolean;
  9307. touchChanged: boolean;
  9308. valueChanged: boolean;
  9309. }
  9310. class Gamepad {
  9311. id: string;
  9312. index: number;
  9313. browserGamepad: any;
  9314. type: number;
  9315. private _leftStick;
  9316. private _rightStick;
  9317. _isConnected: boolean;
  9318. private _leftStickAxisX;
  9319. private _leftStickAxisY;
  9320. private _rightStickAxisX;
  9321. private _rightStickAxisY;
  9322. private _onleftstickchanged;
  9323. private _onrightstickchanged;
  9324. static GAMEPAD: number;
  9325. static GENERIC: number;
  9326. static XBOX: number;
  9327. static POSE_ENABLED: number;
  9328. protected _invertLeftStickY: boolean;
  9329. readonly isConnected: boolean;
  9330. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9331. onleftstickchanged(callback: (values: StickValues) => void): void;
  9332. onrightstickchanged(callback: (values: StickValues) => void): void;
  9333. leftStick: StickValues;
  9334. rightStick: StickValues;
  9335. update(): void;
  9336. dispose(): void;
  9337. }
  9338. class GenericPad extends Gamepad {
  9339. private _buttons;
  9340. private _onbuttondown;
  9341. private _onbuttonup;
  9342. onButtonDownObservable: Observable<number>;
  9343. onButtonUpObservable: Observable<number>;
  9344. onbuttondown(callback: (buttonPressed: number) => void): void;
  9345. onbuttonup(callback: (buttonReleased: number) => void): void;
  9346. constructor(id: string, index: number, browserGamepad: any);
  9347. private _setButtonValue(newValue, currentValue, buttonIndex);
  9348. update(): void;
  9349. dispose(): void;
  9350. }
  9351. }
  9352. declare module BABYLON {
  9353. class GamepadManager {
  9354. private _scene;
  9355. private _babylonGamepads;
  9356. private _oneGamepadConnected;
  9357. _isMonitoring: boolean;
  9358. private _gamepadEventSupported;
  9359. private _gamepadSupport;
  9360. onGamepadConnectedObservable: Observable<Gamepad>;
  9361. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9362. private _onGamepadConnectedEvent;
  9363. private _onGamepadDisconnectedEvent;
  9364. constructor(_scene?: Scene | undefined);
  9365. readonly gamepads: Gamepad[];
  9366. getGamepadByType(type?: number): Nullable<Gamepad>;
  9367. dispose(): void;
  9368. private _addNewGamepad(gamepad);
  9369. private _startMonitoringGamepads();
  9370. private _stopMonitoringGamepads();
  9371. _checkGamepadsStatus(): void;
  9372. private _updateGamepadObjects();
  9373. }
  9374. }
  9375. declare module BABYLON {
  9376. /**
  9377. * Defines supported buttons for XBox360 compatible gamepads
  9378. */
  9379. enum Xbox360Button {
  9380. /** A */
  9381. A = 0,
  9382. /** B */
  9383. B = 1,
  9384. /** X */
  9385. X = 2,
  9386. /** Y */
  9387. Y = 3,
  9388. /** Start */
  9389. Start = 4,
  9390. /** Back */
  9391. Back = 5,
  9392. /** Left button */
  9393. LB = 6,
  9394. /** Right button */
  9395. RB = 7,
  9396. /** Left stick */
  9397. LeftStick = 8,
  9398. /** Right stick */
  9399. RightStick = 9,
  9400. }
  9401. /** Defines values for XBox360 DPad */
  9402. enum Xbox360Dpad {
  9403. /** Up */
  9404. Up = 0,
  9405. /** Down */
  9406. Down = 1,
  9407. /** Left */
  9408. Left = 2,
  9409. /** Right */
  9410. Right = 3,
  9411. }
  9412. /**
  9413. * Defines a XBox360 gamepad
  9414. */
  9415. class Xbox360Pad extends Gamepad {
  9416. private _leftTrigger;
  9417. private _rightTrigger;
  9418. private _onlefttriggerchanged;
  9419. private _onrighttriggerchanged;
  9420. private _onbuttondown;
  9421. private _onbuttonup;
  9422. private _ondpaddown;
  9423. private _ondpadup;
  9424. /** Observable raised when a button is pressed */
  9425. onButtonDownObservable: Observable<Xbox360Button>;
  9426. /** Observable raised when a button is released */
  9427. onButtonUpObservable: Observable<Xbox360Button>;
  9428. /** Observable raised when a pad is pressed */
  9429. onPadDownObservable: Observable<Xbox360Dpad>;
  9430. /** Observable raised when a pad is released */
  9431. onPadUpObservable: Observable<Xbox360Dpad>;
  9432. private _buttonA;
  9433. private _buttonB;
  9434. private _buttonX;
  9435. private _buttonY;
  9436. private _buttonBack;
  9437. private _buttonStart;
  9438. private _buttonLB;
  9439. private _buttonRB;
  9440. private _buttonLeftStick;
  9441. private _buttonRightStick;
  9442. private _dPadUp;
  9443. private _dPadDown;
  9444. private _dPadLeft;
  9445. private _dPadRight;
  9446. private _isXboxOnePad;
  9447. /**
  9448. * Creates a new XBox360 gamepad object
  9449. * @param id defines the id of this gamepad
  9450. * @param index defines its index
  9451. * @param gamepad defines the internal HTML gamepad object
  9452. * @param xboxOne defines if it is a XBox One gamepad
  9453. */
  9454. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9455. /**
  9456. * Defines the callback to call when left trigger is pressed
  9457. * @param callback defines the callback to use
  9458. */
  9459. onlefttriggerchanged(callback: (value: number) => void): void;
  9460. /**
  9461. * Defines the callback to call when right trigger is pressed
  9462. * @param callback defines the callback to use
  9463. */
  9464. onrighttriggerchanged(callback: (value: number) => void): void;
  9465. /**
  9466. * Gets or sets left trigger value
  9467. */
  9468. leftTrigger: number;
  9469. /**
  9470. * Gets or sets right trigger value
  9471. */
  9472. rightTrigger: number;
  9473. /**
  9474. * Defines the callback to call when a button is pressed
  9475. * @param callback defines the callback to use
  9476. */
  9477. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9478. /**
  9479. * Defines the callback to call when a button is released
  9480. * @param callback defines the callback to use
  9481. */
  9482. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9483. /**
  9484. * Defines the callback to call when a pad is pressed
  9485. * @param callback defines the callback to use
  9486. */
  9487. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9488. /**
  9489. * Defines the callback to call when a pad is released
  9490. * @param callback defines the callback to use
  9491. */
  9492. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9493. private _setButtonValue(newValue, currentValue, buttonType);
  9494. private _setDPadValue(newValue, currentValue, buttonType);
  9495. /** Gets or sets value of A button */
  9496. buttonA: number;
  9497. /** Gets or sets value of B button */
  9498. buttonB: number;
  9499. /** Gets or sets value of X button */
  9500. buttonX: number;
  9501. /** Gets or sets value of Y button */
  9502. buttonY: number;
  9503. /** Gets or sets value of Start button */
  9504. buttonStart: number;
  9505. /** Gets or sets value of Back button */
  9506. buttonBack: number;
  9507. /** Gets or sets value of Left button */
  9508. buttonLB: number;
  9509. /** Gets or sets value of Right button */
  9510. buttonRB: number;
  9511. /** Gets or sets value of left stick */
  9512. buttonLeftStick: number;
  9513. /** Gets or sets value of right stick */
  9514. buttonRightStick: number;
  9515. /** Gets or sets value of DPad up */
  9516. dPadUp: number;
  9517. /** Gets or sets value of DPad down */
  9518. dPadDown: number;
  9519. /** Gets or sets value of DPad left */
  9520. dPadLeft: number;
  9521. /** Gets or sets value of DPad right */
  9522. dPadRight: number;
  9523. /**
  9524. * Force the gamepad to synchronize with device values
  9525. */
  9526. update(): void;
  9527. dispose(): void;
  9528. }
  9529. }
  9530. declare module BABYLON {
  9531. /**
  9532. * Represents the different options available during the creation of
  9533. * a Environment helper.
  9534. *
  9535. * This can control the default ground, skybox and image processing setup of your scene.
  9536. */
  9537. interface IEnvironmentHelperOptions {
  9538. /**
  9539. * Specifies wether or not to create a ground.
  9540. * True by default.
  9541. */
  9542. createGround: boolean;
  9543. /**
  9544. * Specifies the ground size.
  9545. * 15 by default.
  9546. */
  9547. groundSize: number;
  9548. /**
  9549. * The texture used on the ground for the main color.
  9550. * Comes from the BabylonJS CDN by default.
  9551. *
  9552. * Remarks: Can be either a texture or a url.
  9553. */
  9554. groundTexture: string | BaseTexture;
  9555. /**
  9556. * The color mixed in the ground texture by default.
  9557. * BabylonJS clearColor by default.
  9558. */
  9559. groundColor: Color3;
  9560. /**
  9561. * Specifies the ground opacity.
  9562. * 1 by default.
  9563. */
  9564. groundOpacity: number;
  9565. /**
  9566. * Enables the ground to receive shadows.
  9567. * True by default.
  9568. */
  9569. enableGroundShadow: boolean;
  9570. /**
  9571. * Helps preventing the shadow to be fully black on the ground.
  9572. * 0.5 by default.
  9573. */
  9574. groundShadowLevel: number;
  9575. /**
  9576. * Creates a mirror texture attach to the ground.
  9577. * false by default.
  9578. */
  9579. enableGroundMirror: boolean;
  9580. /**
  9581. * Specifies the ground mirror size ratio.
  9582. * 0.3 by default as the default kernel is 64.
  9583. */
  9584. groundMirrorSizeRatio: number;
  9585. /**
  9586. * Specifies the ground mirror blur kernel size.
  9587. * 64 by default.
  9588. */
  9589. groundMirrorBlurKernel: number;
  9590. /**
  9591. * Specifies the ground mirror visibility amount.
  9592. * 1 by default
  9593. */
  9594. groundMirrorAmount: number;
  9595. /**
  9596. * Specifies the ground mirror reflectance weight.
  9597. * This uses the standard weight of the background material to setup the fresnel effect
  9598. * of the mirror.
  9599. * 1 by default.
  9600. */
  9601. groundMirrorFresnelWeight: number;
  9602. /**
  9603. * Specifies the ground mirror Falloff distance.
  9604. * This can helps reducing the size of the reflection.
  9605. * 0 by Default.
  9606. */
  9607. groundMirrorFallOffDistance: number;
  9608. /**
  9609. * Specifies the ground mirror texture type.
  9610. * Unsigned Int by Default.
  9611. */
  9612. groundMirrorTextureType: number;
  9613. /**
  9614. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9615. * the shown objects.
  9616. */
  9617. groundYBias: number;
  9618. /**
  9619. * Specifies wether or not to create a skybox.
  9620. * True by default.
  9621. */
  9622. createSkybox: boolean;
  9623. /**
  9624. * Specifies the skybox size.
  9625. * 20 by default.
  9626. */
  9627. skyboxSize: number;
  9628. /**
  9629. * The texture used on the skybox for the main color.
  9630. * Comes from the BabylonJS CDN by default.
  9631. *
  9632. * Remarks: Can be either a texture or a url.
  9633. */
  9634. skyboxTexture: string | BaseTexture;
  9635. /**
  9636. * The color mixed in the skybox texture by default.
  9637. * BabylonJS clearColor by default.
  9638. */
  9639. skyboxColor: Color3;
  9640. /**
  9641. * The background rotation around the Y axis of the scene.
  9642. * This helps aligning the key lights of your scene with the background.
  9643. * 0 by default.
  9644. */
  9645. backgroundYRotation: number;
  9646. /**
  9647. * Compute automatically the size of the elements to best fit with the scene.
  9648. */
  9649. sizeAuto: boolean;
  9650. /**
  9651. * Default position of the rootMesh if autoSize is not true.
  9652. */
  9653. rootPosition: Vector3;
  9654. /**
  9655. * Sets up the image processing in the scene.
  9656. * true by default.
  9657. */
  9658. setupImageProcessing: boolean;
  9659. /**
  9660. * The texture used as your environment texture in the scene.
  9661. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9662. *
  9663. * Remarks: Can be either a texture or a url.
  9664. */
  9665. environmentTexture: string | BaseTexture;
  9666. /**
  9667. * The value of the exposure to apply to the scene.
  9668. * 0.6 by default if setupImageProcessing is true.
  9669. */
  9670. cameraExposure: number;
  9671. /**
  9672. * The value of the contrast to apply to the scene.
  9673. * 1.6 by default if setupImageProcessing is true.
  9674. */
  9675. cameraContrast: number;
  9676. /**
  9677. * Specifies wether or not tonemapping should be enabled in the scene.
  9678. * true by default if setupImageProcessing is true.
  9679. */
  9680. toneMappingEnabled: boolean;
  9681. }
  9682. /**
  9683. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9684. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9685. * It also helps with the default setup of your imageProcessing configuration.
  9686. */
  9687. class EnvironmentHelper {
  9688. /**
  9689. * Default ground texture URL.
  9690. */
  9691. private static _groundTextureCDNUrl;
  9692. /**
  9693. * Default skybox texture URL.
  9694. */
  9695. private static _skyboxTextureCDNUrl;
  9696. /**
  9697. * Default environment texture URL.
  9698. */
  9699. private static _environmentTextureCDNUrl;
  9700. /**
  9701. * Creates the default options for the helper.
  9702. */
  9703. private static _getDefaultOptions();
  9704. private _rootMesh;
  9705. /**
  9706. * Gets the root mesh created by the helper.
  9707. */
  9708. readonly rootMesh: Mesh;
  9709. private _skybox;
  9710. /**
  9711. * Gets the skybox created by the helper.
  9712. */
  9713. readonly skybox: Nullable<Mesh>;
  9714. private _skyboxTexture;
  9715. /**
  9716. * Gets the skybox texture created by the helper.
  9717. */
  9718. readonly skyboxTexture: Nullable<BaseTexture>;
  9719. private _skyboxMaterial;
  9720. /**
  9721. * Gets the skybox material created by the helper.
  9722. */
  9723. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9724. private _ground;
  9725. /**
  9726. * Gets the ground mesh created by the helper.
  9727. */
  9728. readonly ground: Nullable<Mesh>;
  9729. private _groundTexture;
  9730. /**
  9731. * Gets the ground texture created by the helper.
  9732. */
  9733. readonly groundTexture: Nullable<BaseTexture>;
  9734. private _groundMirror;
  9735. /**
  9736. * Gets the ground mirror created by the helper.
  9737. */
  9738. readonly groundMirror: Nullable<MirrorTexture>;
  9739. /**
  9740. * Gets the ground mirror render list to helps pushing the meshes
  9741. * you wish in the ground reflection.
  9742. */
  9743. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9744. private _groundMaterial;
  9745. /**
  9746. * Gets the ground material created by the helper.
  9747. */
  9748. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9749. /**
  9750. * Stores the creation options.
  9751. */
  9752. private readonly _scene;
  9753. private _options;
  9754. /**
  9755. * This observable will be notified with any error during the creation of the environment,
  9756. * mainly texture creation errors.
  9757. */
  9758. onErrorObservable: Observable<{
  9759. message?: string;
  9760. exception?: any;
  9761. }>;
  9762. /**
  9763. * constructor
  9764. * @param options
  9765. * @param scene The scene to add the material to
  9766. */
  9767. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9768. /**
  9769. * Updates the background according to the new options
  9770. * @param options
  9771. */
  9772. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9773. /**
  9774. * Sets the primary color of all the available elements.
  9775. * @param color the main color to affect to the ground and the background
  9776. */
  9777. setMainColor(color: Color3): void;
  9778. /**
  9779. * Setup the image processing according to the specified options.
  9780. */
  9781. private _setupImageProcessing();
  9782. /**
  9783. * Setup the environment texture according to the specified options.
  9784. */
  9785. private _setupEnvironmentTexture();
  9786. /**
  9787. * Setup the background according to the specified options.
  9788. */
  9789. private _setupBackground();
  9790. /**
  9791. * Get the scene sizes according to the setup.
  9792. */
  9793. private _getSceneSize();
  9794. /**
  9795. * Setup the ground according to the specified options.
  9796. */
  9797. private _setupGround(sceneSize);
  9798. /**
  9799. * Setup the ground material according to the specified options.
  9800. */
  9801. private _setupGroundMaterial();
  9802. /**
  9803. * Setup the ground diffuse texture according to the specified options.
  9804. */
  9805. private _setupGroundDiffuseTexture();
  9806. /**
  9807. * Setup the ground mirror texture according to the specified options.
  9808. */
  9809. private _setupGroundMirrorTexture(sceneSize);
  9810. /**
  9811. * Setup the ground to receive the mirror texture.
  9812. */
  9813. private _setupMirrorInGroundMaterial();
  9814. /**
  9815. * Setup the skybox according to the specified options.
  9816. */
  9817. private _setupSkybox(sceneSize);
  9818. /**
  9819. * Setup the skybox material according to the specified options.
  9820. */
  9821. private _setupSkyboxMaterial();
  9822. /**
  9823. * Setup the skybox reflection texture according to the specified options.
  9824. */
  9825. private _setupSkyboxReflectionTexture();
  9826. private _errorHandler;
  9827. /**
  9828. * Dispose all the elements created by the Helper.
  9829. */
  9830. dispose(): void;
  9831. }
  9832. }
  9833. declare module BABYLON {
  9834. /**
  9835. * Represents all the data needed to create a ParticleSystem.
  9836. */
  9837. interface IParticleSystemData {
  9838. /**
  9839. * ParticleSystem type
  9840. */
  9841. type: string;
  9842. /**
  9843. * Shape of the emitter
  9844. */
  9845. emitterType: string;
  9846. /**
  9847. * Maximum number of particles in the system
  9848. */
  9849. capacity: number;
  9850. /**
  9851. * Link for the texture file
  9852. */
  9853. textureFile: string;
  9854. /**
  9855. * minEmitBox Vector3
  9856. */
  9857. minEmitBox?: {
  9858. x: number;
  9859. y: number;
  9860. z: number;
  9861. };
  9862. /**
  9863. * maxEmitBox Vector3
  9864. */
  9865. maxEmitBox?: {
  9866. x: number;
  9867. y: number;
  9868. z: number;
  9869. };
  9870. /**
  9871. * color1 Color4
  9872. */
  9873. color1: {
  9874. r: number;
  9875. g: number;
  9876. b: number;
  9877. a: number;
  9878. };
  9879. /**
  9880. * color2 Color4
  9881. */
  9882. color2: {
  9883. r: number;
  9884. g: number;
  9885. b: number;
  9886. a: number;
  9887. };
  9888. /**
  9889. * colorDead Color4
  9890. */
  9891. colorDead: {
  9892. r: number;
  9893. g: number;
  9894. b: number;
  9895. a: number;
  9896. };
  9897. /**
  9898. * Minimum size of each particle
  9899. */
  9900. minSize: number;
  9901. /**
  9902. * Maximum size of each particle
  9903. */
  9904. maxSize: number;
  9905. /**
  9906. * Minimum lifetime for each particle
  9907. */
  9908. minLifeTime: number;
  9909. /**
  9910. * Maximum lifetime for each particle
  9911. */
  9912. maxLifeTime: number;
  9913. /**
  9914. * Emit rate
  9915. */
  9916. emitRate: number;
  9917. /**
  9918. * Blend Mode
  9919. */
  9920. blendMode: number;
  9921. /**
  9922. * gravity Vector3
  9923. */
  9924. gravity: {
  9925. x: number;
  9926. y: number;
  9927. z: number;
  9928. };
  9929. /**
  9930. * direction1 Vector3
  9931. */
  9932. direction1?: {
  9933. x: number;
  9934. y: number;
  9935. z: number;
  9936. };
  9937. /**
  9938. * direction2 Vector3
  9939. */
  9940. direction2?: {
  9941. x: number;
  9942. y: number;
  9943. z: number;
  9944. };
  9945. /**
  9946. * Minimum Angular Speed
  9947. */
  9948. minAngularSpeed: number;
  9949. /**
  9950. * Maximum Angular Speed
  9951. */
  9952. maxAngularSpeed: number;
  9953. /**
  9954. * Minimum Emit Power
  9955. */
  9956. minEmitPower: number;
  9957. /**
  9958. * Maximum Emit Power
  9959. */
  9960. maxEmitPower: number;
  9961. /**
  9962. * Update Speed
  9963. */
  9964. updateSpeed: number;
  9965. /**
  9966. * Radius
  9967. */
  9968. radius?: number;
  9969. /**
  9970. * Angle
  9971. */
  9972. angle?: number;
  9973. }
  9974. /**
  9975. * This class is made for on one-liner static method to help creating particle systems.
  9976. */
  9977. class ParticleHelper {
  9978. /**
  9979. * Base Assets URL.
  9980. */
  9981. private static _baseAssetsUrl;
  9982. private static _scene;
  9983. private static _emitter;
  9984. /**
  9985. * This is the main static method (one-liner) of this helper to create different particle systems.
  9986. * @param type This string represents the type to the particle system to create
  9987. * @param emitter The object where the particle system will start to emit from.
  9988. * @param scene The scene where the particle system should live.
  9989. * @param gpu If the system will use gpu.
  9990. * @returns the ParticleSystem created.
  9991. */
  9992. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  9993. private static _createSystem(data);
  9994. }
  9995. }
  9996. declare module BABYLON {
  9997. /**
  9998. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9999. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10000. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10001. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10002. */
  10003. class VideoDome extends Node {
  10004. /**
  10005. * The video texture being displayed on the sphere
  10006. */
  10007. protected _videoTexture: VideoTexture;
  10008. /**
  10009. * The skybox material
  10010. */
  10011. protected _material: BackgroundMaterial;
  10012. /**
  10013. * The surface used for the skybox
  10014. */
  10015. protected _mesh: Mesh;
  10016. /**
  10017. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10018. * Also see the options.resolution property.
  10019. */
  10020. fovMultiplier: number;
  10021. /**
  10022. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10023. * @param name Element's name, child elements will append suffixes for their own names.
  10024. * @param urlsOrVideo
  10025. * @param options An object containing optional or exposed sub element properties:
  10026. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  10027. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  10028. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  10029. * @param options **loop=true** Automatically loop video on end.
  10030. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  10031. */
  10032. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10033. resolution?: number;
  10034. clickToPlay?: boolean;
  10035. autoPlay?: boolean;
  10036. loop?: boolean;
  10037. size?: number;
  10038. }, scene: Scene);
  10039. /**
  10040. * Releases resources associated with this node.
  10041. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10042. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10043. */
  10044. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10045. }
  10046. }
  10047. declare module BABYLON {
  10048. /**
  10049. * Effect layer options. This helps customizing the behaviour
  10050. * of the effect layer.
  10051. */
  10052. interface IEffectLayerOptions {
  10053. /**
  10054. * Multiplication factor apply to the canvas size to compute the render target size
  10055. * used to generated the objects (the smaller the faster).
  10056. */
  10057. mainTextureRatio: number;
  10058. /**
  10059. * Enforces a fixed size texture to ensure effect stability across devices.
  10060. */
  10061. mainTextureFixedSize?: number;
  10062. /**
  10063. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10064. */
  10065. alphaBlendingMode: number;
  10066. /**
  10067. * The camera attached to the layer.
  10068. */
  10069. camera: Nullable<Camera>;
  10070. }
  10071. /**
  10072. * The effect layer Helps adding post process effect blended with the main pass.
  10073. *
  10074. * This can be for instance use to generate glow or higlight effects on the scene.
  10075. *
  10076. * The effect layer class can not be used directly and is intented to inherited from to be
  10077. * customized per effects.
  10078. */
  10079. abstract class EffectLayer {
  10080. private _vertexBuffers;
  10081. private _indexBuffer;
  10082. private _cachedDefines;
  10083. private _effectLayerMapGenerationEffect;
  10084. private _effectLayerOptions;
  10085. private _mergeEffect;
  10086. protected _scene: Scene;
  10087. protected _engine: Engine;
  10088. protected _maxSize: number;
  10089. protected _mainTextureDesiredSize: ISize;
  10090. protected _mainTexture: RenderTargetTexture;
  10091. protected _shouldRender: boolean;
  10092. protected _postProcesses: PostProcess[];
  10093. protected _textures: BaseTexture[];
  10094. protected _emissiveTextureAndColor: {
  10095. texture: Nullable<BaseTexture>;
  10096. color: Color4;
  10097. };
  10098. /**
  10099. * The name of the layer
  10100. */
  10101. name: string;
  10102. /**
  10103. * The clear color of the texture used to generate the glow map.
  10104. */
  10105. neutralColor: Color4;
  10106. /**
  10107. * Specifies wether the highlight layer is enabled or not.
  10108. */
  10109. isEnabled: boolean;
  10110. /**
  10111. * Gets the camera attached to the layer.
  10112. */
  10113. readonly camera: Nullable<Camera>;
  10114. /**
  10115. * An event triggered when the effect layer has been disposed.
  10116. */
  10117. onDisposeObservable: Observable<EffectLayer>;
  10118. /**
  10119. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10120. */
  10121. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10122. /**
  10123. * An event triggered when the generated texture is being merged in the scene.
  10124. */
  10125. onBeforeComposeObservable: Observable<EffectLayer>;
  10126. /**
  10127. * An event triggered when the generated texture has been merged in the scene.
  10128. */
  10129. onAfterComposeObservable: Observable<EffectLayer>;
  10130. /**
  10131. * An event triggered when the efffect layer changes its size.
  10132. */
  10133. onSizeChangedObservable: Observable<EffectLayer>;
  10134. /**
  10135. * Instantiates a new effect Layer and references it in the scene.
  10136. * @param name The name of the layer
  10137. * @param scene The scene to use the layer in
  10138. */
  10139. constructor(
  10140. /** The Friendly of the effect in the scene */
  10141. name: string, scene: Scene);
  10142. /**
  10143. * Get the effect name of the layer.
  10144. * @return The effect name
  10145. */
  10146. abstract getEffectName(): string;
  10147. /**
  10148. * Checks for the readiness of the element composing the layer.
  10149. * @param subMesh the mesh to check for
  10150. * @param useInstances specify wether or not to use instances to render the mesh
  10151. * @return true if ready otherwise, false
  10152. */
  10153. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10154. /**
  10155. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10156. * @returns true if the effect requires stencil during the main canvas render pass.
  10157. */
  10158. abstract needStencil(): boolean;
  10159. /**
  10160. * Create the merge effect. This is the shader use to blit the information back
  10161. * to the main canvas at the end of the scene rendering.
  10162. * @returns The effect containing the shader used to merge the effect on the main canvas
  10163. */
  10164. protected abstract _createMergeEffect(): Effect;
  10165. /**
  10166. * Creates the render target textures and post processes used in the effect layer.
  10167. */
  10168. protected abstract _createTextureAndPostProcesses(): void;
  10169. /**
  10170. * Implementation specific of rendering the generating effect on the main canvas.
  10171. * @param effect The effect used to render through
  10172. */
  10173. protected abstract _internalRender(effect: Effect): void;
  10174. /**
  10175. * Sets the required values for both the emissive texture and and the main color.
  10176. */
  10177. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10178. /**
  10179. * Free any resources and references associated to a mesh.
  10180. * Internal use
  10181. * @param mesh The mesh to free.
  10182. */
  10183. abstract _disposeMesh(mesh: Mesh): void;
  10184. /**
  10185. * Serializes this layer (Glow or Highlight for example)
  10186. * @returns a serialized layer object
  10187. */
  10188. abstract serialize?(): any;
  10189. /**
  10190. * Initializes the effect layer with the required options.
  10191. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10192. */
  10193. protected _init(options: Partial<IEffectLayerOptions>): void;
  10194. /**
  10195. * Generates the index buffer of the full screen quad blending to the main canvas.
  10196. */
  10197. private _generateIndexBuffer();
  10198. /**
  10199. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10200. */
  10201. private _genrateVertexBuffer();
  10202. /**
  10203. * Sets the main texture desired size which is the closest power of two
  10204. * of the engine canvas size.
  10205. */
  10206. private _setMainTextureSize();
  10207. /**
  10208. * Creates the main texture for the effect layer.
  10209. */
  10210. protected _createMainTexture(): void;
  10211. /**
  10212. * Checks for the readiness of the element composing the layer.
  10213. * @param subMesh the mesh to check for
  10214. * @param useInstances specify wether or not to use instances to render the mesh
  10215. * @param emissiveTexture the associated emissive texture used to generate the glow
  10216. * @return true if ready otherwise, false
  10217. */
  10218. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10219. /**
  10220. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10221. */
  10222. render(): void;
  10223. /**
  10224. * Determine if a given mesh will be used in the current effect.
  10225. * @param mesh mesh to test
  10226. * @returns true if the mesh will be used
  10227. */
  10228. hasMesh(mesh: AbstractMesh): boolean;
  10229. /**
  10230. * Returns true if the layer contains information to display, otherwise false.
  10231. * @returns true if the glow layer should be rendered
  10232. */
  10233. shouldRender(): boolean;
  10234. /**
  10235. * Returns true if the mesh should render, otherwise false.
  10236. * @param mesh The mesh to render
  10237. * @returns true if it should render otherwise false
  10238. */
  10239. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10240. /**
  10241. * Returns true if the mesh should render, otherwise false.
  10242. * @param mesh The mesh to render
  10243. * @returns true if it should render otherwise false
  10244. */
  10245. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10246. /**
  10247. * Renders the submesh passed in parameter to the generation map.
  10248. */
  10249. protected _renderSubMesh(subMesh: SubMesh): void;
  10250. /**
  10251. * Rebuild the required buffers.
  10252. * @hidden Internal use only.
  10253. */
  10254. _rebuild(): void;
  10255. /**
  10256. * Dispose only the render target textures and post process.
  10257. */
  10258. private _disposeTextureAndPostProcesses();
  10259. /**
  10260. * Dispose the highlight layer and free resources.
  10261. */
  10262. dispose(): void;
  10263. /**
  10264. * Gets the class name of the effect layer
  10265. * @returns the string with the class name of the effect layer
  10266. */
  10267. getClassName(): string;
  10268. /**
  10269. * Creates an effect layer from parsed effect layer data
  10270. * @param parsedEffectLayer defines effect layer data
  10271. * @param scene defines the current scene
  10272. * @param rootUrl defines the root URL containing the effect layer information
  10273. * @returns a parsed effect Layer
  10274. */
  10275. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10276. }
  10277. }
  10278. declare module BABYLON {
  10279. /**
  10280. * Glow layer options. This helps customizing the behaviour
  10281. * of the glow layer.
  10282. */
  10283. interface IGlowLayerOptions {
  10284. /**
  10285. * Multiplication factor apply to the canvas size to compute the render target size
  10286. * used to generated the glowing objects (the smaller the faster).
  10287. */
  10288. mainTextureRatio: number;
  10289. /**
  10290. * Enforces a fixed size texture to ensure resize independant blur.
  10291. */
  10292. mainTextureFixedSize?: number;
  10293. /**
  10294. * How big is the kernel of the blur texture.
  10295. */
  10296. blurKernelSize: number;
  10297. /**
  10298. * The camera attached to the layer.
  10299. */
  10300. camera: Nullable<Camera>;
  10301. /**
  10302. * Enable MSAA by chosing the number of samples.
  10303. */
  10304. mainTextureSamples?: number;
  10305. }
  10306. /**
  10307. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10308. *
  10309. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10310. * glowy meshes to your scene.
  10311. *
  10312. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10313. */
  10314. class GlowLayer extends EffectLayer {
  10315. /**
  10316. * Effect Name of the layer.
  10317. */
  10318. static readonly EffectName: string;
  10319. /**
  10320. * The default blur kernel size used for the glow.
  10321. */
  10322. static DefaultBlurKernelSize: number;
  10323. /**
  10324. * The default texture size ratio used for the glow.
  10325. */
  10326. static DefaultTextureRatio: number;
  10327. /**
  10328. * Gets the kernel size of the blur.
  10329. */
  10330. /**
  10331. * Sets the kernel size of the blur.
  10332. */
  10333. blurKernelSize: number;
  10334. /**
  10335. * Gets the glow intensity.
  10336. */
  10337. /**
  10338. * Sets the glow intensity.
  10339. */
  10340. intensity: number;
  10341. private _options;
  10342. private _intensity;
  10343. private _horizontalBlurPostprocess1;
  10344. private _verticalBlurPostprocess1;
  10345. private _horizontalBlurPostprocess2;
  10346. private _verticalBlurPostprocess2;
  10347. private _blurTexture1;
  10348. private _blurTexture2;
  10349. private _postProcesses1;
  10350. private _postProcesses2;
  10351. private _includedOnlyMeshes;
  10352. private _excludedMeshes;
  10353. /**
  10354. * Callback used to let the user override the color selection on a per mesh basis
  10355. */
  10356. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10357. /**
  10358. * Callback used to let the user override the texture selection on a per mesh basis
  10359. */
  10360. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10361. /**
  10362. * Instantiates a new glow Layer and references it to the scene.
  10363. * @param name The name of the layer
  10364. * @param scene The scene to use the layer in
  10365. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10366. */
  10367. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10368. /**
  10369. * Get the effect name of the layer.
  10370. * @return The effect name
  10371. */
  10372. getEffectName(): string;
  10373. /**
  10374. * Create the merge effect. This is the shader use to blit the information back
  10375. * to the main canvas at the end of the scene rendering.
  10376. */
  10377. protected _createMergeEffect(): Effect;
  10378. /**
  10379. * Creates the render target textures and post processes used in the glow layer.
  10380. */
  10381. protected _createTextureAndPostProcesses(): void;
  10382. /**
  10383. * Checks for the readiness of the element composing the layer.
  10384. * @param subMesh the mesh to check for
  10385. * @param useInstances specify wether or not to use instances to render the mesh
  10386. * @param emissiveTexture the associated emissive texture used to generate the glow
  10387. * @return true if ready otherwise, false
  10388. */
  10389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10390. /**
  10391. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10392. */
  10393. needStencil(): boolean;
  10394. /**
  10395. * Implementation specific of rendering the generating effect on the main canvas.
  10396. * @param effect The effect used to render through
  10397. */
  10398. protected _internalRender(effect: Effect): void;
  10399. /**
  10400. * Sets the required values for both the emissive texture and and the main color.
  10401. */
  10402. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10403. /**
  10404. * Returns true if the mesh should render, otherwise false.
  10405. * @param mesh The mesh to render
  10406. * @returns true if it should render otherwise false
  10407. */
  10408. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10409. /**
  10410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10411. * @param mesh The mesh to exclude from the glow layer
  10412. */
  10413. addExcludedMesh(mesh: Mesh): void;
  10414. /**
  10415. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10416. * @param mesh The mesh to remove
  10417. */
  10418. removeExcludedMesh(mesh: Mesh): void;
  10419. /**
  10420. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10421. * @param mesh The mesh to include in the glow layer
  10422. */
  10423. addIncludedOnlyMesh(mesh: Mesh): void;
  10424. /**
  10425. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10426. * @param mesh The mesh to remove
  10427. */
  10428. removeIncludedOnlyMesh(mesh: Mesh): void;
  10429. /**
  10430. * Determine if a given mesh will be used in the glow layer
  10431. * @param mesh The mesh to test
  10432. * @returns true if the mesh will be highlighted by the current glow layer
  10433. */
  10434. hasMesh(mesh: AbstractMesh): boolean;
  10435. /**
  10436. * Free any resources and references associated to a mesh.
  10437. * Internal use
  10438. * @param mesh The mesh to free.
  10439. */
  10440. _disposeMesh(mesh: Mesh): void;
  10441. /**
  10442. * Gets the class name of the effect layer
  10443. * @returns the string with the class name of the effect layer
  10444. */
  10445. getClassName(): string;
  10446. /**
  10447. * Serializes this glow layer
  10448. * @returns a serialized glow layer object
  10449. */
  10450. serialize(): any;
  10451. /**
  10452. * Creates a Glow Layer from parsed glow layer data
  10453. * @param parsedGlowLayer defines glow layer data
  10454. * @param scene defines the current scene
  10455. * @param rootUrl defines the root URL containing the glow layer information
  10456. * @returns a parsed Glow Layer
  10457. */
  10458. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10459. }
  10460. }
  10461. declare module BABYLON {
  10462. /**
  10463. * Highlight layer options. This helps customizing the behaviour
  10464. * of the highlight layer.
  10465. */
  10466. interface IHighlightLayerOptions {
  10467. /**
  10468. * Multiplication factor apply to the canvas size to compute the render target size
  10469. * used to generated the glowing objects (the smaller the faster).
  10470. */
  10471. mainTextureRatio: number;
  10472. /**
  10473. * Enforces a fixed size texture to ensure resize independant blur.
  10474. */
  10475. mainTextureFixedSize?: number;
  10476. /**
  10477. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10478. * of the picture to blur (the smaller the faster).
  10479. */
  10480. blurTextureSizeRatio: number;
  10481. /**
  10482. * How big in texel of the blur texture is the vertical blur.
  10483. */
  10484. blurVerticalSize: number;
  10485. /**
  10486. * How big in texel of the blur texture is the horizontal blur.
  10487. */
  10488. blurHorizontalSize: number;
  10489. /**
  10490. * Alpha blending mode used to apply the blur. Default is combine.
  10491. */
  10492. alphaBlendingMode: number;
  10493. /**
  10494. * The camera attached to the layer.
  10495. */
  10496. camera: Nullable<Camera>;
  10497. /**
  10498. * Should we display highlight as a solid stroke?
  10499. */
  10500. isStroke?: boolean;
  10501. }
  10502. /**
  10503. * The highlight layer Helps adding a glow effect around a mesh.
  10504. *
  10505. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10506. * glowy meshes to your scene.
  10507. *
  10508. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10509. */
  10510. class HighlightLayer extends EffectLayer {
  10511. name: string;
  10512. /**
  10513. * Effect Name of the highlight layer.
  10514. */
  10515. static readonly EffectName: string;
  10516. /**
  10517. * The neutral color used during the preparation of the glow effect.
  10518. * This is black by default as the blend operation is a blend operation.
  10519. */
  10520. static NeutralColor: Color4;
  10521. /**
  10522. * Stencil value used for glowing meshes.
  10523. */
  10524. static GlowingMeshStencilReference: number;
  10525. /**
  10526. * Stencil value used for the other meshes in the scene.
  10527. */
  10528. static NormalMeshStencilReference: number;
  10529. /**
  10530. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10531. */
  10532. innerGlow: boolean;
  10533. /**
  10534. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10535. */
  10536. outerGlow: boolean;
  10537. /**
  10538. * Gets the horizontal size of the blur.
  10539. */
  10540. /**
  10541. * Specifies the horizontal size of the blur.
  10542. */
  10543. blurHorizontalSize: number;
  10544. /**
  10545. * Gets the vertical size of the blur.
  10546. */
  10547. /**
  10548. * Specifies the vertical size of the blur.
  10549. */
  10550. blurVerticalSize: number;
  10551. /**
  10552. * An event triggered when the highlight layer is being blurred.
  10553. */
  10554. onBeforeBlurObservable: Observable<HighlightLayer>;
  10555. /**
  10556. * An event triggered when the highlight layer has been blurred.
  10557. */
  10558. onAfterBlurObservable: Observable<HighlightLayer>;
  10559. private _instanceGlowingMeshStencilReference;
  10560. private _options;
  10561. private _downSamplePostprocess;
  10562. private _horizontalBlurPostprocess;
  10563. private _verticalBlurPostprocess;
  10564. private _blurTexture;
  10565. private _meshes;
  10566. private _excludedMeshes;
  10567. /**
  10568. * Instantiates a new highlight Layer and references it to the scene..
  10569. * @param name The name of the layer
  10570. * @param scene The scene to use the layer in
  10571. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10572. */
  10573. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10574. /**
  10575. * Get the effect name of the layer.
  10576. * @return The effect name
  10577. */
  10578. getEffectName(): string;
  10579. /**
  10580. * Create the merge effect. This is the shader use to blit the information back
  10581. * to the main canvas at the end of the scene rendering.
  10582. */
  10583. protected _createMergeEffect(): Effect;
  10584. /**
  10585. * Creates the render target textures and post processes used in the highlight layer.
  10586. */
  10587. protected _createTextureAndPostProcesses(): void;
  10588. /**
  10589. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10590. */
  10591. needStencil(): boolean;
  10592. /**
  10593. * Checks for the readiness of the element composing the layer.
  10594. * @param subMesh the mesh to check for
  10595. * @param useInstances specify wether or not to use instances to render the mesh
  10596. * @param emissiveTexture the associated emissive texture used to generate the glow
  10597. * @return true if ready otherwise, false
  10598. */
  10599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10600. /**
  10601. * Implementation specific of rendering the generating effect on the main canvas.
  10602. * @param effect The effect used to render through
  10603. */
  10604. protected _internalRender(effect: Effect): void;
  10605. /**
  10606. * Returns true if the layer contains information to display, otherwise false.
  10607. */
  10608. shouldRender(): boolean;
  10609. /**
  10610. * Returns true if the mesh should render, otherwise false.
  10611. * @param mesh The mesh to render
  10612. * @returns true if it should render otherwise false
  10613. */
  10614. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10615. /**
  10616. * Sets the required values for both the emissive texture and and the main color.
  10617. */
  10618. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10619. /**
  10620. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10621. * @param mesh The mesh to exclude from the highlight layer
  10622. */
  10623. addExcludedMesh(mesh: Mesh): void;
  10624. /**
  10625. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10626. * @param mesh The mesh to highlight
  10627. */
  10628. removeExcludedMesh(mesh: Mesh): void;
  10629. /**
  10630. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10631. * @param mesh mesh to test
  10632. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10633. */
  10634. hasMesh(mesh: AbstractMesh): boolean;
  10635. /**
  10636. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10637. * @param mesh The mesh to highlight
  10638. * @param color The color of the highlight
  10639. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10640. */
  10641. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10642. /**
  10643. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10644. * @param mesh The mesh to highlight
  10645. */
  10646. removeMesh(mesh: Mesh): void;
  10647. /**
  10648. * Force the stencil to the normal expected value for none glowing parts
  10649. */
  10650. private _defaultStencilReference(mesh);
  10651. /**
  10652. * Free any resources and references associated to a mesh.
  10653. * Internal use
  10654. * @param mesh The mesh to free.
  10655. */
  10656. _disposeMesh(mesh: Mesh): void;
  10657. /**
  10658. * Dispose the highlight layer and free resources.
  10659. */
  10660. dispose(): void;
  10661. /**
  10662. * Gets the class name of the effect layer
  10663. * @returns the string with the class name of the effect layer
  10664. */
  10665. getClassName(): string;
  10666. /**
  10667. * Serializes this Highlight layer
  10668. * @returns a serialized Highlight layer object
  10669. */
  10670. serialize(): any;
  10671. /**
  10672. * Creates a Highlight layer from parsed Highlight layer data
  10673. * @param parsedHightlightLayer defines the Highlight layer data
  10674. * @param scene defines the current scene
  10675. * @param rootUrl defines the root URL containing the Highlight layer information
  10676. * @returns a parsed Highlight layer
  10677. */
  10678. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10679. }
  10680. }
  10681. declare module BABYLON {
  10682. class Layer {
  10683. name: string;
  10684. texture: Nullable<Texture>;
  10685. isBackground: boolean;
  10686. color: Color4;
  10687. scale: Vector2;
  10688. offset: Vector2;
  10689. alphaBlendingMode: number;
  10690. alphaTest: boolean;
  10691. layerMask: number;
  10692. private _scene;
  10693. private _vertexBuffers;
  10694. private _indexBuffer;
  10695. private _effect;
  10696. private _alphaTestEffect;
  10697. /**
  10698. * An event triggered when the layer is disposed.
  10699. */
  10700. onDisposeObservable: Observable<Layer>;
  10701. private _onDisposeObserver;
  10702. onDispose: () => void;
  10703. /**
  10704. * An event triggered before rendering the scene
  10705. */
  10706. onBeforeRenderObservable: Observable<Layer>;
  10707. private _onBeforeRenderObserver;
  10708. onBeforeRender: () => void;
  10709. /**
  10710. * An event triggered after rendering the scene
  10711. */
  10712. onAfterRenderObservable: Observable<Layer>;
  10713. private _onAfterRenderObserver;
  10714. onAfterRender: () => void;
  10715. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10716. private _createIndexBuffer();
  10717. _rebuild(): void;
  10718. render(): void;
  10719. dispose(): void;
  10720. }
  10721. }
  10722. declare module BABYLON {
  10723. class LensFlare {
  10724. size: number;
  10725. position: number;
  10726. color: Color3;
  10727. texture: Nullable<Texture>;
  10728. alphaMode: number;
  10729. private _system;
  10730. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10731. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10732. dispose(): void;
  10733. }
  10734. }
  10735. declare module BABYLON {
  10736. class LensFlareSystem {
  10737. name: string;
  10738. lensFlares: LensFlare[];
  10739. borderLimit: number;
  10740. viewportBorder: number;
  10741. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10742. layerMask: number;
  10743. id: string;
  10744. private _scene;
  10745. private _emitter;
  10746. private _vertexBuffers;
  10747. private _indexBuffer;
  10748. private _effect;
  10749. private _positionX;
  10750. private _positionY;
  10751. private _isEnabled;
  10752. constructor(name: string, emitter: any, scene: Scene);
  10753. isEnabled: boolean;
  10754. getScene(): Scene;
  10755. getEmitter(): any;
  10756. setEmitter(newEmitter: any): void;
  10757. getEmitterPosition(): Vector3;
  10758. computeEffectivePosition(globalViewport: Viewport): boolean;
  10759. _isVisible(): boolean;
  10760. render(): boolean;
  10761. dispose(): void;
  10762. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10763. serialize(): any;
  10764. }
  10765. }
  10766. declare module BABYLON {
  10767. interface ILoadingScreen {
  10768. displayLoadingUI: () => void;
  10769. hideLoadingUI: () => void;
  10770. loadingUIBackgroundColor: string;
  10771. loadingUIText: string;
  10772. }
  10773. class DefaultLoadingScreen implements ILoadingScreen {
  10774. private _renderingCanvas;
  10775. private _loadingText;
  10776. private _loadingDivBackgroundColor;
  10777. private _loadingDiv;
  10778. private _loadingTextDiv;
  10779. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  10780. displayLoadingUI(): void;
  10781. hideLoadingUI(): void;
  10782. loadingUIText: string;
  10783. loadingUIBackgroundColor: string;
  10784. private _resizeLoadingUI;
  10785. }
  10786. }
  10787. declare module BABYLON {
  10788. class SceneLoaderProgressEvent {
  10789. readonly lengthComputable: boolean;
  10790. readonly loaded: number;
  10791. readonly total: number;
  10792. constructor(lengthComputable: boolean, loaded: number, total: number);
  10793. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  10794. }
  10795. interface ISceneLoaderPluginExtensions {
  10796. [extension: string]: {
  10797. isBinary: boolean;
  10798. };
  10799. }
  10800. interface ISceneLoaderPluginFactory {
  10801. name: string;
  10802. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  10803. canDirectLoad?: (data: string) => boolean;
  10804. }
  10805. interface ISceneLoaderPlugin {
  10806. /**
  10807. * The friendly name of this plugin.
  10808. */
  10809. name: string;
  10810. /**
  10811. * The file extensions supported by this plugin.
  10812. */
  10813. extensions: string | ISceneLoaderPluginExtensions;
  10814. /**
  10815. * Import meshes into a scene.
  10816. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10817. * @param scene The scene to import into
  10818. * @param data The data to import
  10819. * @param rootUrl The root url for scene and resources
  10820. * @param meshes The meshes array to import into
  10821. * @param particleSystems The particle systems array to import into
  10822. * @param skeletons The skeletons array to import into
  10823. * @param onError The callback when import fails
  10824. * @returns True if successful or false otherwise
  10825. */
  10826. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  10827. /**
  10828. * Load into a scene.
  10829. * @param scene The scene to load into
  10830. * @param data The data to import
  10831. * @param rootUrl The root url for scene and resources
  10832. * @param onError The callback when import fails
  10833. * @returns true if successful or false otherwise
  10834. */
  10835. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  10836. /**
  10837. * The callback that returns true if the data can be directly loaded.
  10838. */
  10839. canDirectLoad?: (data: string) => boolean;
  10840. /**
  10841. * The callback that allows custom handling of the root url based on the response url.
  10842. */
  10843. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  10844. /**
  10845. * Load into an asset container.
  10846. * @param scene The scene to load into
  10847. * @param data The data to import
  10848. * @param rootUrl The root url for scene and resources
  10849. * @param onError The callback when import fails
  10850. * @returns The loaded asset container
  10851. */
  10852. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  10853. }
  10854. interface ISceneLoaderPluginAsync {
  10855. /**
  10856. * The friendly name of this plugin.
  10857. */
  10858. name: string;
  10859. /**
  10860. * The file extensions supported by this plugin.
  10861. */
  10862. extensions: string | ISceneLoaderPluginExtensions;
  10863. /**
  10864. * Import meshes into a scene.
  10865. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10866. * @param scene The scene to import into
  10867. * @param data The data to import
  10868. * @param rootUrl The root url for scene and resources
  10869. * @param onProgress The callback when the load progresses
  10870. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  10871. */
  10872. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  10873. meshes: AbstractMesh[];
  10874. particleSystems: ParticleSystem[];
  10875. skeletons: Skeleton[];
  10876. animationGroups: AnimationGroup[];
  10877. }>;
  10878. /**
  10879. * Load into a scene.
  10880. * @param scene The scene to load into
  10881. * @param data The data to import
  10882. * @param rootUrl The root url for scene and resources
  10883. * @param onProgress The callback when the load progresses
  10884. * @returns Nothing
  10885. */
  10886. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  10887. /**
  10888. * The callback that returns true if the data can be directly loaded.
  10889. */
  10890. canDirectLoad?: (data: string) => boolean;
  10891. /**
  10892. * The callback that allows custom handling of the root url based on the response url.
  10893. */
  10894. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  10895. /**
  10896. * Load into an asset container.
  10897. * @param scene The scene to load into
  10898. * @param data The data to import
  10899. * @param rootUrl The root url for scene and resources
  10900. * @param onProgress The callback when the load progresses
  10901. * @returns The loaded asset container
  10902. */
  10903. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  10904. }
  10905. class SceneLoader {
  10906. private static _ForceFullSceneLoadingForIncremental;
  10907. private static _ShowLoadingScreen;
  10908. private static _CleanBoneMatrixWeights;
  10909. static readonly NO_LOGGING: number;
  10910. static readonly MINIMAL_LOGGING: number;
  10911. static readonly SUMMARY_LOGGING: number;
  10912. static readonly DETAILED_LOGGING: number;
  10913. private static _loggingLevel;
  10914. static ForceFullSceneLoadingForIncremental: boolean;
  10915. static ShowLoadingScreen: boolean;
  10916. static loggingLevel: number;
  10917. static CleanBoneMatrixWeights: boolean;
  10918. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  10919. private static _registeredPlugins;
  10920. private static _getDefaultPlugin();
  10921. private static _getPluginForExtension(extension);
  10922. private static _getPluginForDirectLoad(data);
  10923. private static _getPluginForFilename(sceneFilename);
  10924. private static _getDirectLoad(sceneFilename);
  10925. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  10926. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  10927. static IsPluginForExtensionAvailable(extension: string): boolean;
  10928. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  10929. /**
  10930. * Import meshes into a scene
  10931. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10932. * @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)
  10933. * @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)
  10934. * @param scene the instance of BABYLON.Scene to append to
  10935. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  10936. * @param onProgress a callback with a progress event for each file being loaded
  10937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10938. * @param pluginExtension the extension used to determine the plugin
  10939. * @returns The loaded plugin
  10940. */
  10941. 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>;
  10942. /**
  10943. * Import meshes into a scene
  10944. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10945. * @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)
  10946. * @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)
  10947. * @param scene the instance of BABYLON.Scene to append to
  10948. * @param onProgress a callback with a progress event for each file being loaded
  10949. * @param pluginExtension the extension used to determine the plugin
  10950. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  10951. */
  10952. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  10953. meshes: AbstractMesh[];
  10954. particleSystems: ParticleSystem[];
  10955. skeletons: Skeleton[];
  10956. animationGroups: AnimationGroup[];
  10957. }>;
  10958. /**
  10959. * Load a scene
  10960. * @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)
  10961. * @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)
  10962. * @param engine is the instance of BABYLON.Engine to use to create the scene
  10963. * @param onSuccess a callback with the scene when import succeeds
  10964. * @param onProgress a callback with a progress event for each file being loaded
  10965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10966. * @param pluginExtension the extension used to determine the plugin
  10967. * @returns The loaded plugin
  10968. */
  10969. 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>;
  10970. /**
  10971. * Load a scene
  10972. * @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)
  10973. * @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)
  10974. * @param engine is the instance of BABYLON.Engine to use to create the scene
  10975. * @param onProgress a callback with a progress event for each file being loaded
  10976. * @param pluginExtension the extension used to determine the plugin
  10977. * @returns The loaded scene
  10978. */
  10979. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  10980. /**
  10981. * Append a scene
  10982. * @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)
  10983. * @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)
  10984. * @param scene is the instance of BABYLON.Scene to append to
  10985. * @param onSuccess a callback with the scene when import succeeds
  10986. * @param onProgress a callback with a progress event for each file being loaded
  10987. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10988. * @param pluginExtension the extension used to determine the plugin
  10989. * @returns The loaded plugin
  10990. */
  10991. 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>;
  10992. /**
  10993. * Append a scene
  10994. * @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)
  10995. * @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)
  10996. * @param scene is the instance of BABYLON.Scene to append to
  10997. * @param onProgress a callback with a progress event for each file being loaded
  10998. * @param pluginExtension the extension used to determine the plugin
  10999. * @returns The given scene
  11000. */
  11001. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11002. /**
  11003. * Load a scene into an asset container
  11004. * @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)
  11005. * @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)
  11006. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  11007. * @param onSuccess a callback with the scene when import succeeds
  11008. * @param onProgress a callback with a progress event for each file being loaded
  11009. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11010. * @param pluginExtension the extension used to determine the plugin
  11011. * @returns The loaded plugin
  11012. */
  11013. 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>;
  11014. /**
  11015. * Load a scene into an asset container
  11016. * @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)
  11017. * @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)
  11018. * @param scene is the instance of BABYLON.Scene to append to
  11019. * @param onProgress a callback with a progress event for each file being loaded
  11020. * @param pluginExtension the extension used to determine the plugin
  11021. * @returns The loaded asset container
  11022. */
  11023. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11024. }
  11025. }
  11026. declare module BABYLON {
  11027. /**
  11028. * A directional light is defined by a direction (what a surprise!).
  11029. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11030. * 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.
  11031. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11032. */
  11033. class DirectionalLight extends ShadowLight {
  11034. private _shadowFrustumSize;
  11035. /**
  11036. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11037. */
  11038. /**
  11039. * Specifies a fix frustum size for the shadow generation.
  11040. */
  11041. shadowFrustumSize: number;
  11042. private _shadowOrthoScale;
  11043. /**
  11044. * Gets the shadow projection scale against the optimal computed one.
  11045. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11046. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11047. */
  11048. /**
  11049. * Sets the shadow projection scale against the optimal computed one.
  11050. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11051. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11052. */
  11053. shadowOrthoScale: number;
  11054. /**
  11055. * Automatically compute the projection matrix to best fit (including all the casters)
  11056. * on each frame.
  11057. */
  11058. autoUpdateExtends: boolean;
  11059. private _orthoLeft;
  11060. private _orthoRight;
  11061. private _orthoTop;
  11062. private _orthoBottom;
  11063. /**
  11064. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11065. * The directional light is emitted from everywhere in the given direction.
  11066. * It can cast shawdows.
  11067. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11068. * @param name The friendly name of the light
  11069. * @param direction The direction of the light
  11070. * @param scene The scene the light belongs to
  11071. */
  11072. constructor(name: string, direction: Vector3, scene: Scene);
  11073. /**
  11074. * Returns the string "DirectionalLight".
  11075. * @return The class name
  11076. */
  11077. getClassName(): string;
  11078. /**
  11079. * Returns the integer 1.
  11080. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11081. */
  11082. getTypeID(): number;
  11083. /**
  11084. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11085. * Returns the DirectionalLight Shadow projection matrix.
  11086. */
  11087. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11088. /**
  11089. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11090. * Returns the DirectionalLight Shadow projection matrix.
  11091. */
  11092. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11093. /**
  11094. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11095. * Returns the DirectionalLight Shadow projection matrix.
  11096. */
  11097. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11098. protected _buildUniformLayout(): void;
  11099. /**
  11100. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11101. * @param effect The effect to update
  11102. * @param lightIndex The index of the light in the effect to update
  11103. * @returns The directional light
  11104. */
  11105. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11106. /**
  11107. * Gets the minZ used for shadow according to both the scene and the light.
  11108. *
  11109. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11110. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11111. * @param activeCamera The camera we are returning the min for
  11112. * @returns the depth min z
  11113. */
  11114. getDepthMinZ(activeCamera: Camera): number;
  11115. /**
  11116. * Gets the maxZ used for shadow according to both the scene and the light.
  11117. *
  11118. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11119. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11120. * @param activeCamera The camera we are returning the max for
  11121. * @returns the depth max z
  11122. */
  11123. getDepthMaxZ(activeCamera: Camera): number;
  11124. }
  11125. }
  11126. declare module BABYLON {
  11127. /**
  11128. * The HemisphericLight simulates the ambient environment light,
  11129. * so the passed direction is the light reflection direction, not the incoming direction.
  11130. */
  11131. class HemisphericLight extends Light {
  11132. /**
  11133. * The groundColor is the light in the opposite direction to the one specified during creation.
  11134. * 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.
  11135. */
  11136. groundColor: Color3;
  11137. /**
  11138. * The light reflection direction, not the incoming direction.
  11139. */
  11140. direction: Vector3;
  11141. private _worldMatrix;
  11142. /**
  11143. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11144. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11145. * The HemisphericLight can't cast shadows.
  11146. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11147. * @param name The friendly name of the light
  11148. * @param direction The direction of the light reflection
  11149. * @param scene The scene the light belongs to
  11150. */
  11151. constructor(name: string, direction: Vector3, scene: Scene);
  11152. protected _buildUniformLayout(): void;
  11153. /**
  11154. * Returns the string "HemisphericLight".
  11155. * @return The class name
  11156. */
  11157. getClassName(): string;
  11158. /**
  11159. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11160. * Returns the updated direction.
  11161. * @param target The target the direction should point to
  11162. * @return The computed direction
  11163. */
  11164. setDirectionToTarget(target: Vector3): Vector3;
  11165. /**
  11166. * Returns the shadow generator associated to the light.
  11167. * @returns Always null for hemispheric lights because it does not support shadows.
  11168. */
  11169. getShadowGenerator(): Nullable<ShadowGenerator>;
  11170. /**
  11171. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11172. * @param effect The effect to update
  11173. * @param lightIndex The index of the light in the effect to update
  11174. * @returns The hemispheric light
  11175. */
  11176. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11177. /**
  11178. * @hidden internal use only.
  11179. */
  11180. _getWorldMatrix(): Matrix;
  11181. /**
  11182. * Returns the integer 3.
  11183. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11184. */
  11185. getTypeID(): number;
  11186. }
  11187. }
  11188. declare module BABYLON {
  11189. /**
  11190. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11191. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11192. * 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.
  11193. */
  11194. abstract class Light extends Node {
  11195. private static _LIGHTMAP_DEFAULT;
  11196. private static _LIGHTMAP_SPECULAR;
  11197. private static _LIGHTMAP_SHADOWSONLY;
  11198. /**
  11199. * If every light affecting the material is in this lightmapMode,
  11200. * material.lightmapTexture adds or multiplies
  11201. * (depends on material.useLightmapAsShadowmap)
  11202. * after every other light calculations.
  11203. */
  11204. static readonly LIGHTMAP_DEFAULT: number;
  11205. /**
  11206. * material.lightmapTexture as only diffuse lighting from this light
  11207. * adds only specular lighting from this light
  11208. * adds dynamic shadows
  11209. */
  11210. static readonly LIGHTMAP_SPECULAR: number;
  11211. /**
  11212. * material.lightmapTexture as only lighting
  11213. * no light calculation from this light
  11214. * only adds dynamic shadows from this light
  11215. */
  11216. static readonly LIGHTMAP_SHADOWSONLY: number;
  11217. private static _INTENSITYMODE_AUTOMATIC;
  11218. private static _INTENSITYMODE_LUMINOUSPOWER;
  11219. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11220. private static _INTENSITYMODE_ILLUMINANCE;
  11221. private static _INTENSITYMODE_LUMINANCE;
  11222. /**
  11223. * Each light type uses the default quantity according to its type:
  11224. * point/spot lights use luminous intensity
  11225. * directional lights use illuminance
  11226. */
  11227. static readonly INTENSITYMODE_AUTOMATIC: number;
  11228. /**
  11229. * lumen (lm)
  11230. */
  11231. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11232. /**
  11233. * candela (lm/sr)
  11234. */
  11235. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11236. /**
  11237. * lux (lm/m^2)
  11238. */
  11239. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11240. /**
  11241. * nit (cd/m^2)
  11242. */
  11243. static readonly INTENSITYMODE_LUMINANCE: number;
  11244. private static _LIGHTTYPEID_POINTLIGHT;
  11245. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11246. private static _LIGHTTYPEID_SPOTLIGHT;
  11247. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11248. /**
  11249. * Light type const id of the point light.
  11250. */
  11251. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11252. /**
  11253. * Light type const id of the directional light.
  11254. */
  11255. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11256. /**
  11257. * Light type const id of the spot light.
  11258. */
  11259. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11260. /**
  11261. * Light type const id of the hemispheric light.
  11262. */
  11263. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11264. /**
  11265. * Diffuse gives the basic color to an object.
  11266. */
  11267. diffuse: Color3;
  11268. /**
  11269. * Specular produces a highlight color on an object.
  11270. * Note: This is note affecting PBR materials.
  11271. */
  11272. specular: Color3;
  11273. /**
  11274. * Strength of the light.
  11275. * Note: By default it is define in the framework own unit.
  11276. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11277. */
  11278. intensity: number;
  11279. /**
  11280. * Defines how far from the source the light is impacting in scene units.
  11281. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11282. */
  11283. range: number;
  11284. /**
  11285. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11286. * of light.
  11287. */
  11288. private _photometricScale;
  11289. private _intensityMode;
  11290. /**
  11291. * Gets the photometric scale used to interpret the intensity.
  11292. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11293. */
  11294. /**
  11295. * Sets the photometric scale used to interpret the intensity.
  11296. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11297. */
  11298. intensityMode: number;
  11299. private _radius;
  11300. /**
  11301. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11302. */
  11303. /**
  11304. * sets the light radius used by PBR Materials to simulate soft area lights.
  11305. */
  11306. radius: number;
  11307. private _renderPriority;
  11308. /**
  11309. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11310. * exceeding the number allowed of the materials.
  11311. */
  11312. renderPriority: number;
  11313. private _shadowEnabled;
  11314. /**
  11315. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11316. * the current shadow generator.
  11317. */
  11318. /**
  11319. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11320. * the current shadow generator.
  11321. */
  11322. shadowEnabled: boolean;
  11323. private _includedOnlyMeshes;
  11324. /**
  11325. * Gets the only meshes impacted by this light.
  11326. */
  11327. /**
  11328. * Sets the only meshes impacted by this light.
  11329. */
  11330. includedOnlyMeshes: AbstractMesh[];
  11331. private _excludedMeshes;
  11332. /**
  11333. * Gets the meshes not impacted by this light.
  11334. */
  11335. /**
  11336. * Sets the meshes not impacted by this light.
  11337. */
  11338. excludedMeshes: AbstractMesh[];
  11339. private _excludeWithLayerMask;
  11340. /**
  11341. * Gets the layer id use to find what meshes are not impacted by the light.
  11342. * Inactive if 0
  11343. */
  11344. /**
  11345. * Sets the layer id use to find what meshes are not impacted by the light.
  11346. * Inactive if 0
  11347. */
  11348. excludeWithLayerMask: number;
  11349. private _includeOnlyWithLayerMask;
  11350. /**
  11351. * Gets the layer id use to find what meshes are impacted by the light.
  11352. * Inactive if 0
  11353. */
  11354. /**
  11355. * Sets the layer id use to find what meshes are impacted by the light.
  11356. * Inactive if 0
  11357. */
  11358. includeOnlyWithLayerMask: number;
  11359. private _lightmapMode;
  11360. /**
  11361. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11362. */
  11363. /**
  11364. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11365. */
  11366. lightmapMode: number;
  11367. private _parentedWorldMatrix;
  11368. /**
  11369. * Shadow generator associted to the light.
  11370. * Internal use only.
  11371. */
  11372. _shadowGenerator: Nullable<IShadowGenerator>;
  11373. /**
  11374. * @hidden Internal use only.
  11375. */
  11376. _excludedMeshesIds: string[];
  11377. /**
  11378. * @hidden Internal use only.
  11379. */
  11380. _includedOnlyMeshesIds: string[];
  11381. /**
  11382. * The current light unifom buffer.
  11383. * @hidden Internal use only.
  11384. */
  11385. _uniformBuffer: UniformBuffer;
  11386. /**
  11387. * Creates a Light object in the scene.
  11388. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11389. * @param name The firendly name of the light
  11390. * @param scene The scene the light belongs too
  11391. */
  11392. constructor(name: string, scene: Scene);
  11393. protected abstract _buildUniformLayout(): void;
  11394. /**
  11395. * Sets the passed Effect "effect" with the Light information.
  11396. * @param effect The effect to update
  11397. * @param lightIndex The index of the light in the effect to update
  11398. * @returns The light
  11399. */
  11400. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11401. /**
  11402. * @hidden internal use only.
  11403. */
  11404. abstract _getWorldMatrix(): Matrix;
  11405. /**
  11406. * Returns the string "Light".
  11407. * @returns the class name
  11408. */
  11409. getClassName(): string;
  11410. /**
  11411. * Converts the light information to a readable string for debug purpose.
  11412. * @param fullDetails Supports for multiple levels of logging within scene loading
  11413. * @returns the human readable light info
  11414. */
  11415. toString(fullDetails?: boolean): string;
  11416. /**
  11417. * Set the enabled state of this node.
  11418. * @param value - the new enabled state
  11419. */
  11420. setEnabled(value: boolean): void;
  11421. /**
  11422. * Returns the Light associated shadow generator if any.
  11423. * @return the associated shadow generator.
  11424. */
  11425. getShadowGenerator(): Nullable<IShadowGenerator>;
  11426. /**
  11427. * Returns a Vector3, the absolute light position in the World.
  11428. * @returns the world space position of the light
  11429. */
  11430. getAbsolutePosition(): Vector3;
  11431. /**
  11432. * Specifies if the light will affect the passed mesh.
  11433. * @param mesh The mesh to test against the light
  11434. * @return true the mesh is affected otherwise, false.
  11435. */
  11436. canAffectMesh(mesh: AbstractMesh): boolean;
  11437. /**
  11438. * Computes and Returns the light World matrix.
  11439. * @returns the world matrix
  11440. */
  11441. getWorldMatrix(): Matrix;
  11442. /**
  11443. * Sort function to order lights for rendering.
  11444. * @param a First Light object to compare to second.
  11445. * @param b Second Light object to compare first.
  11446. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11447. */
  11448. static CompareLightsPriority(a: Light, b: Light): number;
  11449. /**
  11450. * Releases resources associated with this node.
  11451. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11452. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11453. */
  11454. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11455. /**
  11456. * Returns the light type ID (integer).
  11457. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11458. */
  11459. getTypeID(): number;
  11460. /**
  11461. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11462. * @returns the scaled intensity in intensity mode unit
  11463. */
  11464. getScaledIntensity(): number;
  11465. /**
  11466. * Returns a new Light object, named "name", from the current one.
  11467. * @param name The name of the cloned light
  11468. * @returns the new created light
  11469. */
  11470. clone(name: string): Nullable<Light>;
  11471. /**
  11472. * Serializes the current light into a Serialization object.
  11473. * @returns the serialized object.
  11474. */
  11475. serialize(): any;
  11476. /**
  11477. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11478. * This new light is named "name" and added to the passed scene.
  11479. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11480. * @param name The friendly name of the light
  11481. * @param scene The scene the new light will belong to
  11482. * @returns the constructor function
  11483. */
  11484. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11485. /**
  11486. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11487. * @param parsedLight The JSON representation of the light
  11488. * @param scene The scene to create the parsed light in
  11489. * @returns the created light after parsing
  11490. */
  11491. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11492. private _hookArrayForExcluded(array);
  11493. private _hookArrayForIncludedOnly(array);
  11494. private _resyncMeshes();
  11495. /**
  11496. * Forces the meshes to update their light related information in their rendering used effects
  11497. * @hidden Internal Use Only
  11498. */
  11499. _markMeshesAsLightDirty(): void;
  11500. /**
  11501. * Recomputes the cached photometric scale if needed.
  11502. */
  11503. private _computePhotometricScale();
  11504. /**
  11505. * Returns the Photometric Scale according to the light type and intensity mode.
  11506. */
  11507. private _getPhotometricScale();
  11508. /**
  11509. * Reorder the light in the scene according to their defined priority.
  11510. * @hidden Internal Use Only
  11511. */
  11512. _reorderLightsInScene(): void;
  11513. }
  11514. }
  11515. declare module BABYLON {
  11516. /**
  11517. * A point light is a light defined by an unique point in world space.
  11518. * The light is emitted in every direction from this point.
  11519. * A good example of a point light is a standard light bulb.
  11520. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11521. */
  11522. class PointLight extends ShadowLight {
  11523. private _shadowAngle;
  11524. /**
  11525. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11526. * This specifies what angle the shadow will use to be created.
  11527. *
  11528. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11529. */
  11530. /**
  11531. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11532. * This specifies what angle the shadow will use to be created.
  11533. *
  11534. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11535. */
  11536. shadowAngle: number;
  11537. /**
  11538. * Gets the direction if it has been set.
  11539. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11540. */
  11541. /**
  11542. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11543. */
  11544. direction: Vector3;
  11545. /**
  11546. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11547. * A PointLight emits the light in every direction.
  11548. * It can cast shadows.
  11549. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11550. * ```javascript
  11551. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11552. * ```
  11553. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11554. * @param name The light friendly name
  11555. * @param position The position of the point light in the scene
  11556. * @param scene The scene the lights belongs to
  11557. */
  11558. constructor(name: string, position: Vector3, scene: Scene);
  11559. /**
  11560. * Returns the string "PointLight"
  11561. * @returns the class name
  11562. */
  11563. getClassName(): string;
  11564. /**
  11565. * Returns the integer 0.
  11566. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11567. */
  11568. getTypeID(): number;
  11569. /**
  11570. * Specifies wether or not the shadowmap should be a cube texture.
  11571. * @returns true if the shadowmap needs to be a cube texture.
  11572. */
  11573. needCube(): boolean;
  11574. /**
  11575. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11576. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11577. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11578. */
  11579. getShadowDirection(faceIndex?: number): Vector3;
  11580. /**
  11581. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11582. * - fov = PI / 2
  11583. * - aspect ratio : 1.0
  11584. * - z-near and far equal to the active camera minZ and maxZ.
  11585. * Returns the PointLight.
  11586. */
  11587. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11588. protected _buildUniformLayout(): void;
  11589. /**
  11590. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11591. * @param effect The effect to update
  11592. * @param lightIndex The index of the light in the effect to update
  11593. * @returns The point light
  11594. */
  11595. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11596. }
  11597. }
  11598. declare module BABYLON {
  11599. /**
  11600. * Interface describing all the common properties and methods a shadow light needs to implement.
  11601. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11602. * as well as binding the different shadow properties to the effects.
  11603. */
  11604. interface IShadowLight extends Light {
  11605. /**
  11606. * The light id in the scene (used in scene.findLighById for instance)
  11607. */
  11608. id: string;
  11609. /**
  11610. * The position the shdow will be casted from.
  11611. */
  11612. position: Vector3;
  11613. /**
  11614. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11615. */
  11616. direction: Vector3;
  11617. /**
  11618. * The transformed position. Position of the light in world space taking parenting in account.
  11619. */
  11620. transformedPosition: Vector3;
  11621. /**
  11622. * The transformed direction. Direction of the light in world space taking parenting in account.
  11623. */
  11624. transformedDirection: Vector3;
  11625. /**
  11626. * The friendly name of the light in the scene.
  11627. */
  11628. name: string;
  11629. /**
  11630. * Defines the shadow projection clipping minimum z value.
  11631. */
  11632. shadowMinZ: number;
  11633. /**
  11634. * Defines the shadow projection clipping maximum z value.
  11635. */
  11636. shadowMaxZ: number;
  11637. /**
  11638. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11639. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11640. */
  11641. computeTransformedInformation(): boolean;
  11642. /**
  11643. * Gets the scene the light belongs to.
  11644. * @returns The scene
  11645. */
  11646. getScene(): Scene;
  11647. /**
  11648. * Callback defining a custom Projection Matrix Builder.
  11649. * This can be used to override the default projection matrix computation.
  11650. */
  11651. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11652. /**
  11653. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11654. * @param matrix The materix to updated with the projection information
  11655. * @param viewMatrix The transform matrix of the light
  11656. * @param renderList The list of mesh to render in the map
  11657. * @returns The current light
  11658. */
  11659. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11660. /**
  11661. * Gets the current depth scale used in ESM.
  11662. * @returns The scale
  11663. */
  11664. getDepthScale(): number;
  11665. /**
  11666. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11667. * @returns true if a cube texture needs to be use
  11668. */
  11669. needCube(): boolean;
  11670. /**
  11671. * Detects if the projection matrix requires to be recomputed this frame.
  11672. * @returns true if it requires to be recomputed otherwise, false.
  11673. */
  11674. needProjectionMatrixCompute(): boolean;
  11675. /**
  11676. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11677. */
  11678. forceProjectionMatrixCompute(): void;
  11679. /**
  11680. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11681. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11682. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11683. */
  11684. getShadowDirection(faceIndex?: number): Vector3;
  11685. /**
  11686. * Gets the minZ used for shadow according to both the scene and the light.
  11687. * @param activeCamera The camera we are returning the min for
  11688. * @returns the depth min z
  11689. */
  11690. getDepthMinZ(activeCamera: Camera): number;
  11691. /**
  11692. * Gets the maxZ used for shadow according to both the scene and the light.
  11693. * @param activeCamera The camera we are returning the max for
  11694. * @returns the depth max z
  11695. */
  11696. getDepthMaxZ(activeCamera: Camera): number;
  11697. }
  11698. /**
  11699. * Base implementation IShadowLight
  11700. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11701. */
  11702. abstract class ShadowLight extends Light implements IShadowLight {
  11703. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11704. protected _position: Vector3;
  11705. protected _setPosition(value: Vector3): void;
  11706. /**
  11707. * Sets the position the shadow will be casted from. Also use as the light position for both
  11708. * point and spot lights.
  11709. */
  11710. /**
  11711. * Sets the position the shadow will be casted from. Also use as the light position for both
  11712. * point and spot lights.
  11713. */
  11714. position: Vector3;
  11715. protected _direction: Vector3;
  11716. protected _setDirection(value: Vector3): void;
  11717. /**
  11718. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11719. * Also use as the light direction on spot and directional lights.
  11720. */
  11721. /**
  11722. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11723. * Also use as the light direction on spot and directional lights.
  11724. */
  11725. direction: Vector3;
  11726. private _shadowMinZ;
  11727. /**
  11728. * Gets the shadow projection clipping minimum z value.
  11729. */
  11730. /**
  11731. * Sets the shadow projection clipping minimum z value.
  11732. */
  11733. shadowMinZ: number;
  11734. private _shadowMaxZ;
  11735. /**
  11736. * Sets the shadow projection clipping maximum z value.
  11737. */
  11738. /**
  11739. * Gets the shadow projection clipping maximum z value.
  11740. */
  11741. shadowMaxZ: number;
  11742. /**
  11743. * Callback defining a custom Projection Matrix Builder.
  11744. * This can be used to override the default projection matrix computation.
  11745. */
  11746. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11747. /**
  11748. * The transformed position. Position of the light in world space taking parenting in account.
  11749. */
  11750. transformedPosition: Vector3;
  11751. /**
  11752. * The transformed direction. Direction of the light in world space taking parenting in account.
  11753. */
  11754. transformedDirection: Vector3;
  11755. private _worldMatrix;
  11756. private _needProjectionMatrixCompute;
  11757. /**
  11758. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11759. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11760. */
  11761. computeTransformedInformation(): boolean;
  11762. /**
  11763. * Return the depth scale used for the shadow map.
  11764. * @returns the depth scale.
  11765. */
  11766. getDepthScale(): number;
  11767. /**
  11768. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11769. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11770. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11771. */
  11772. getShadowDirection(faceIndex?: number): Vector3;
  11773. /**
  11774. * Returns the ShadowLight absolute position in the World.
  11775. * @returns the position vector in world space
  11776. */
  11777. getAbsolutePosition(): Vector3;
  11778. /**
  11779. * Sets the ShadowLight direction toward the passed target.
  11780. * @param target The point tot target in local space
  11781. * @returns the updated ShadowLight direction
  11782. */
  11783. setDirectionToTarget(target: Vector3): Vector3;
  11784. /**
  11785. * Returns the light rotation in euler definition.
  11786. * @returns the x y z rotation in local space.
  11787. */
  11788. getRotation(): Vector3;
  11789. /**
  11790. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11791. * @returns true if a cube texture needs to be use
  11792. */
  11793. needCube(): boolean;
  11794. /**
  11795. * Detects if the projection matrix requires to be recomputed this frame.
  11796. * @returns true if it requires to be recomputed otherwise, false.
  11797. */
  11798. needProjectionMatrixCompute(): boolean;
  11799. /**
  11800. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11801. */
  11802. forceProjectionMatrixCompute(): void;
  11803. /**
  11804. * Get the world matrix of the sahdow lights.
  11805. * @hidden Internal Use Only
  11806. */
  11807. _getWorldMatrix(): Matrix;
  11808. /**
  11809. * Gets the minZ used for shadow according to both the scene and the light.
  11810. * @param activeCamera The camera we are returning the min for
  11811. * @returns the depth min z
  11812. */
  11813. getDepthMinZ(activeCamera: Camera): number;
  11814. /**
  11815. * Gets the maxZ used for shadow according to both the scene and the light.
  11816. * @param activeCamera The camera we are returning the max for
  11817. * @returns the depth max z
  11818. */
  11819. getDepthMaxZ(activeCamera: Camera): number;
  11820. /**
  11821. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11822. * @param matrix The materix to updated with the projection information
  11823. * @param viewMatrix The transform matrix of the light
  11824. * @param renderList The list of mesh to render in the map
  11825. * @returns The current light
  11826. */
  11827. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /**
  11832. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11833. * These values define a cone of light starting from the position, emitting toward the direction.
  11834. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11835. * and the exponent defines the speed of the decay of the light with distance (reach).
  11836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11837. */
  11838. class SpotLight extends ShadowLight {
  11839. private _angle;
  11840. /**
  11841. * Gets the cone angle of the spot light in Radians.
  11842. */
  11843. /**
  11844. * Sets the cone angle of the spot light in Radians.
  11845. */
  11846. angle: number;
  11847. private _shadowAngleScale;
  11848. /**
  11849. * Allows scaling the angle of the light for shadow generation only.
  11850. */
  11851. /**
  11852. * Allows scaling the angle of the light for shadow generation only.
  11853. */
  11854. shadowAngleScale: number;
  11855. /**
  11856. * The light decay speed with the distance from the emission spot.
  11857. */
  11858. exponent: number;
  11859. private _projectionTextureMatrix;
  11860. /**
  11861. * Allows reading the projecton texture
  11862. */
  11863. readonly projectionTextureMatrix: Matrix;
  11864. protected _projectionTextureLightNear: number;
  11865. /**
  11866. * Gets the near clip of the Spotlight for texture projection.
  11867. */
  11868. /**
  11869. * Sets the near clip of the Spotlight for texture projection.
  11870. */
  11871. projectionTextureLightNear: number;
  11872. protected _projectionTextureLightFar: number;
  11873. /**
  11874. * Gets the far clip of the Spotlight for texture projection.
  11875. */
  11876. /**
  11877. * Sets the far clip of the Spotlight for texture projection.
  11878. */
  11879. projectionTextureLightFar: number;
  11880. protected _projectionTextureUpDirection: Vector3;
  11881. /**
  11882. * Gets the Up vector of the Spotlight for texture projection.
  11883. */
  11884. /**
  11885. * Sets the Up vector of the Spotlight for texture projection.
  11886. */
  11887. projectionTextureUpDirection: Vector3;
  11888. private _projectionTexture;
  11889. /**
  11890. * Gets the projection texture of the light.
  11891. */
  11892. /**
  11893. * Sets the projection texture of the light.
  11894. */
  11895. projectionTexture: Nullable<BaseTexture>;
  11896. private _projectionTextureViewLightDirty;
  11897. private _projectionTextureProjectionLightDirty;
  11898. private _projectionTextureDirty;
  11899. private _projectionTextureViewTargetVector;
  11900. private _projectionTextureViewLightMatrix;
  11901. private _projectionTextureProjectionLightMatrix;
  11902. private _projectionTextureScalingMatrix;
  11903. /**
  11904. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11905. * It can cast shadows.
  11906. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11907. * @param name The light friendly name
  11908. * @param position The position of the spot light in the scene
  11909. * @param direction The direction of the light in the scene
  11910. * @param angle The cone angle of the light in Radians
  11911. * @param exponent The light decay speed with the distance from the emission spot
  11912. * @param scene The scene the lights belongs to
  11913. */
  11914. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11915. /**
  11916. * Returns the string "SpotLight".
  11917. * @returns the class name
  11918. */
  11919. getClassName(): string;
  11920. /**
  11921. * Returns the integer 2.
  11922. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11923. */
  11924. getTypeID(): number;
  11925. /**
  11926. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11927. */
  11928. protected _setDirection(value: Vector3): void;
  11929. /**
  11930. * Overrides the position setter to recompute the projection texture view light Matrix.
  11931. */
  11932. protected _setPosition(value: Vector3): void;
  11933. /**
  11934. * 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.
  11935. * Returns the SpotLight.
  11936. */
  11937. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11938. protected _computeProjectionTextureViewLightMatrix(): void;
  11939. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11940. /**
  11941. * Main function for light texture projection matrix computing.
  11942. */
  11943. protected _computeProjectionTextureMatrix(): void;
  11944. protected _buildUniformLayout(): void;
  11945. /**
  11946. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11947. * @param effect The effect to update
  11948. * @param lightIndex The index of the light in the effect to update
  11949. * @returns The spot light
  11950. */
  11951. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11952. /**
  11953. * Disposes the light and the associated resources.
  11954. */
  11955. dispose(): void;
  11956. }
  11957. }
  11958. declare module BABYLON {
  11959. /**
  11960. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11961. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11962. * 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;
  11963. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11964. */
  11965. class ColorCurves {
  11966. private _dirty;
  11967. private _tempColor;
  11968. private _globalCurve;
  11969. private _highlightsCurve;
  11970. private _midtonesCurve;
  11971. private _shadowsCurve;
  11972. private _positiveCurve;
  11973. private _negativeCurve;
  11974. private _globalHue;
  11975. private _globalDensity;
  11976. private _globalSaturation;
  11977. private _globalExposure;
  11978. /**
  11979. * Gets the global Hue value.
  11980. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11981. */
  11982. /**
  11983. * Sets the global Hue value.
  11984. * 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).
  11985. */
  11986. globalHue: number;
  11987. /**
  11988. * Gets the global Density value.
  11989. * 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.
  11990. * Values less than zero provide a filter of opposite hue.
  11991. */
  11992. /**
  11993. * Sets the global Density value.
  11994. * 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.
  11995. * Values less than zero provide a filter of opposite hue.
  11996. */
  11997. globalDensity: number;
  11998. /**
  11999. * Gets the global Saturation value.
  12000. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  12001. */
  12002. /**
  12003. * Sets the global Saturation value.
  12004. * 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.
  12005. */
  12006. globalSaturation: number;
  12007. /**
  12008. * Gets the global Exposure value.
  12009. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12010. */
  12011. /**
  12012. * Sets the global Exposure value.
  12013. * 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.
  12014. */
  12015. globalExposure: number;
  12016. private _highlightsHue;
  12017. private _highlightsDensity;
  12018. private _highlightsSaturation;
  12019. private _highlightsExposure;
  12020. /**
  12021. * Gets the highlights Hue value.
  12022. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  12023. */
  12024. /**
  12025. * Sets the highlights Hue value.
  12026. * 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).
  12027. */
  12028. highlightsHue: number;
  12029. /**
  12030. * Gets the highlights Density value.
  12031. * 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.
  12032. * Values less than zero provide a filter of opposite hue.
  12033. */
  12034. /**
  12035. * Sets the highlights Density value.
  12036. * 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.
  12037. * Values less than zero provide a filter of opposite hue.
  12038. */
  12039. highlightsDensity: number;
  12040. /**
  12041. * Gets the highlights Saturation value.
  12042. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  12043. */
  12044. /**
  12045. * Sets the highlights Saturation value.
  12046. * 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.
  12047. */
  12048. highlightsSaturation: number;
  12049. /**
  12050. * Gets the highlights Exposure value.
  12051. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12052. */
  12053. /**
  12054. * Sets the highlights Exposure value.
  12055. * 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.
  12056. */
  12057. highlightsExposure: number;
  12058. private _midtonesHue;
  12059. private _midtonesDensity;
  12060. private _midtonesSaturation;
  12061. private _midtonesExposure;
  12062. /**
  12063. * Gets the midtones Hue value.
  12064. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  12065. */
  12066. /**
  12067. * Sets the midtones Hue value.
  12068. * 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).
  12069. */
  12070. midtonesHue: number;
  12071. /**
  12072. * Gets the midtones Density value.
  12073. * 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.
  12074. * Values less than zero provide a filter of opposite hue.
  12075. */
  12076. /**
  12077. * Sets the midtones Density value.
  12078. * 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.
  12079. * Values less than zero provide a filter of opposite hue.
  12080. */
  12081. midtonesDensity: number;
  12082. /**
  12083. * Gets the midtones Saturation value.
  12084. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  12085. */
  12086. /**
  12087. * Sets the midtones Saturation value.
  12088. * 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.
  12089. */
  12090. midtonesSaturation: number;
  12091. /**
  12092. * Gets the midtones Exposure value.
  12093. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12094. */
  12095. /**
  12096. * Sets the midtones Exposure value.
  12097. * 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.
  12098. */
  12099. midtonesExposure: number;
  12100. private _shadowsHue;
  12101. private _shadowsDensity;
  12102. private _shadowsSaturation;
  12103. private _shadowsExposure;
  12104. /**
  12105. * Gets the shadows Hue value.
  12106. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  12107. */
  12108. /**
  12109. * Sets the shadows Hue value.
  12110. * 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).
  12111. */
  12112. shadowsHue: number;
  12113. /**
  12114. * Gets the shadows Density value.
  12115. * 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.
  12116. * Values less than zero provide a filter of opposite hue.
  12117. */
  12118. /**
  12119. * Sets the shadows Density value.
  12120. * 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.
  12121. * Values less than zero provide a filter of opposite hue.
  12122. */
  12123. shadowsDensity: number;
  12124. /**
  12125. * Gets the shadows Saturation value.
  12126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  12127. */
  12128. /**
  12129. * Sets the shadows Saturation value.
  12130. * 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.
  12131. */
  12132. shadowsSaturation: number;
  12133. /**
  12134. * Gets the shadows Exposure value.
  12135. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12136. */
  12137. /**
  12138. * Sets the shadows Exposure value.
  12139. * 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.
  12140. */
  12141. shadowsExposure: number;
  12142. getClassName(): string;
  12143. /**
  12144. * Binds the color curves to the shader.
  12145. * @param colorCurves The color curve to bind
  12146. * @param effect The effect to bind to
  12147. */
  12148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12149. /**
  12150. * Prepare the list of uniforms associated with the ColorCurves effects.
  12151. * @param uniformsList The list of uniforms used in the effect
  12152. */
  12153. static PrepareUniforms(uniformsList: string[]): void;
  12154. /**
  12155. * Returns color grading data based on a hue, density, saturation and exposure value.
  12156. * @param filterHue The hue of the color filter.
  12157. * @param filterDensity The density of the color filter.
  12158. * @param saturation The saturation.
  12159. * @param exposure The exposure.
  12160. * @param result The result data container.
  12161. */
  12162. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12163. /**
  12164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12165. * @param value The input slider value in range [-100,100].
  12166. * @returns Adjusted value.
  12167. */
  12168. private static applyColorGradingSliderNonlinear(value);
  12169. /**
  12170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12171. * @param hue The hue (H) input.
  12172. * @param saturation The saturation (S) input.
  12173. * @param brightness The brightness (B) input.
  12174. * @result An RGBA color represented as Vector4.
  12175. */
  12176. private static fromHSBToRef(hue, saturation, brightness, result);
  12177. /**
  12178. * Returns a value clamped between min and max
  12179. * @param value The value to clamp
  12180. * @param min The minimum of value
  12181. * @param max The maximum of value
  12182. * @returns The clamped value.
  12183. */
  12184. private static clamp(value, min, max);
  12185. /**
  12186. * Clones the current color curve instance.
  12187. * @return The cloned curves
  12188. */
  12189. clone(): ColorCurves;
  12190. /**
  12191. * Serializes the current color curve instance to a json representation.
  12192. * @return a JSON representation
  12193. */
  12194. serialize(): any;
  12195. /**
  12196. * Parses the color curve from a json representation.
  12197. * @param source the JSON source to parse
  12198. * @return The parsed curves
  12199. */
  12200. static Parse(source: any): ColorCurves;
  12201. }
  12202. }
  12203. declare module BABYLON {
  12204. /**
  12205. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12206. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12207. */
  12208. class EffectFallbacks {
  12209. private _defines;
  12210. private _currentRank;
  12211. private _maxRank;
  12212. private _mesh;
  12213. /**
  12214. * Removes the fallback from the bound mesh.
  12215. */
  12216. unBindMesh(): void;
  12217. /**
  12218. * Adds a fallback on the specified property.
  12219. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12220. * @param define The name of the define in the shader
  12221. */
  12222. addFallback(rank: number, define: string): void;
  12223. /**
  12224. * Sets the mesh to use CPU skinning when needing to fallback.
  12225. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12226. * @param mesh The mesh to use the fallbacks.
  12227. */
  12228. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12229. /**
  12230. * Checks to see if more fallbacks are still availible.
  12231. */
  12232. readonly isMoreFallbacks: boolean;
  12233. /**
  12234. * Removes the defines that shoould be removed when falling back.
  12235. * @param currentDefines defines the current define statements for the shader.
  12236. * @param effect defines the current effect we try to compile
  12237. * @returns The resulting defines with defines of the current rank removed.
  12238. */
  12239. reduce(currentDefines: string, effect: Effect): string;
  12240. }
  12241. /**
  12242. * Options to be used when creating an effect.
  12243. */
  12244. class EffectCreationOptions {
  12245. /**
  12246. * Atrributes that will be used in the shader.
  12247. */
  12248. attributes: string[];
  12249. /**
  12250. * Uniform varible names that will be set in the shader.
  12251. */
  12252. uniformsNames: string[];
  12253. /**
  12254. * Uniform buffer varible names that will be set in the shader.
  12255. */
  12256. uniformBuffersNames: string[];
  12257. /**
  12258. * Sampler texture variable names that will be set in the shader.
  12259. */
  12260. samplers: string[];
  12261. /**
  12262. * Define statements that will be set in the shader.
  12263. */
  12264. defines: any;
  12265. /**
  12266. * Possible fallbacks for this effect to improve performance when needed.
  12267. */
  12268. fallbacks: Nullable<EffectFallbacks>;
  12269. /**
  12270. * Callback that will be called when the shader is compiled.
  12271. */
  12272. onCompiled: Nullable<(effect: Effect) => void>;
  12273. /**
  12274. * Callback that will be called if an error occurs during shader compilation.
  12275. */
  12276. onError: Nullable<(effect: Effect, errors: string) => void>;
  12277. /**
  12278. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12279. */
  12280. indexParameters: any;
  12281. /**
  12282. * Max number of lights that can be used in the shader.
  12283. */
  12284. maxSimultaneousLights: number;
  12285. /**
  12286. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12287. */
  12288. transformFeedbackVaryings: Nullable<string[]>;
  12289. }
  12290. /**
  12291. * Effect containing vertex and fragment shader that can be executed on an object.
  12292. */
  12293. class Effect {
  12294. /**
  12295. * Name of the effect.
  12296. */
  12297. name: any;
  12298. /**
  12299. * String container all the define statements that should be set on the shader.
  12300. */
  12301. defines: string;
  12302. /**
  12303. * Callback that will be called when the shader is compiled.
  12304. */
  12305. onCompiled: Nullable<(effect: Effect) => void>;
  12306. /**
  12307. * Callback that will be called if an error occurs during shader compilation.
  12308. */
  12309. onError: Nullable<(effect: Effect, errors: string) => void>;
  12310. /**
  12311. * Callback that will be called when effect is bound.
  12312. */
  12313. onBind: Nullable<(effect: Effect) => void>;
  12314. /**
  12315. * Unique ID of the effect.
  12316. */
  12317. uniqueId: number;
  12318. /**
  12319. * Observable that will be called when the shader is compiled.
  12320. */
  12321. onCompileObservable: Observable<Effect>;
  12322. /**
  12323. * Observable that will be called if an error occurs during shader compilation.
  12324. */
  12325. onErrorObservable: Observable<Effect>;
  12326. /**
  12327. * Observable that will be called when effect is bound.
  12328. */
  12329. onBindObservable: Observable<Effect>;
  12330. /** @hidden */
  12331. _bonesComputationForcedToCPU: boolean;
  12332. private static _uniqueIdSeed;
  12333. private _engine;
  12334. private _uniformBuffersNames;
  12335. private _uniformsNames;
  12336. private _samplers;
  12337. private _isReady;
  12338. private _compilationError;
  12339. private _attributesNames;
  12340. private _attributes;
  12341. private _uniforms;
  12342. /**
  12343. * Key for the effect.
  12344. */
  12345. _key: string;
  12346. private _indexParameters;
  12347. private _fallbacks;
  12348. private _vertexSourceCode;
  12349. private _fragmentSourceCode;
  12350. private _vertexSourceCodeOverride;
  12351. private _fragmentSourceCodeOverride;
  12352. private _transformFeedbackVaryings;
  12353. /**
  12354. * Compiled shader to webGL program.
  12355. */
  12356. _program: WebGLProgram;
  12357. private _valueCache;
  12358. private static _baseCache;
  12359. /**
  12360. * Instantiates an effect.
  12361. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12362. * @param baseName Name of the effect.
  12363. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12364. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12365. * @param samplers List of sampler variables that will be passed to the shader.
  12366. * @param engine Engine to be used to render the effect
  12367. * @param defines Define statements to be added to the shader.
  12368. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12369. * @param onCompiled Callback that will be called when the shader is compiled.
  12370. * @param onError Callback that will be called if an error occurs during shader compilation.
  12371. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12372. */
  12373. 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);
  12374. /**
  12375. * Unique key for this effect
  12376. */
  12377. readonly key: string;
  12378. /**
  12379. * If the effect has been compiled and prepared.
  12380. * @returns if the effect is compiled and prepared.
  12381. */
  12382. isReady(): boolean;
  12383. /**
  12384. * The engine the effect was initialized with.
  12385. * @returns the engine.
  12386. */
  12387. getEngine(): Engine;
  12388. /**
  12389. * The compiled webGL program for the effect
  12390. * @returns the webGL program.
  12391. */
  12392. getProgram(): WebGLProgram;
  12393. /**
  12394. * The set of names of attribute variables for the shader.
  12395. * @returns An array of attribute names.
  12396. */
  12397. getAttributesNames(): string[];
  12398. /**
  12399. * Returns the attribute at the given index.
  12400. * @param index The index of the attribute.
  12401. * @returns The location of the attribute.
  12402. */
  12403. getAttributeLocation(index: number): number;
  12404. /**
  12405. * Returns the attribute based on the name of the variable.
  12406. * @param name of the attribute to look up.
  12407. * @returns the attribute location.
  12408. */
  12409. getAttributeLocationByName(name: string): number;
  12410. /**
  12411. * The number of attributes.
  12412. * @returns the numnber of attributes.
  12413. */
  12414. getAttributesCount(): number;
  12415. /**
  12416. * Gets the index of a uniform variable.
  12417. * @param uniformName of the uniform to look up.
  12418. * @returns the index.
  12419. */
  12420. getUniformIndex(uniformName: string): number;
  12421. /**
  12422. * Returns the attribute based on the name of the variable.
  12423. * @param uniformName of the uniform to look up.
  12424. * @returns the location of the uniform.
  12425. */
  12426. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12427. /**
  12428. * Returns an array of sampler variable names
  12429. * @returns The array of sampler variable neames.
  12430. */
  12431. getSamplers(): string[];
  12432. /**
  12433. * The error from the last compilation.
  12434. * @returns the error string.
  12435. */
  12436. getCompilationError(): string;
  12437. /**
  12438. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12439. * @param func The callback to be used.
  12440. */
  12441. executeWhenCompiled(func: (effect: Effect) => void): void;
  12442. /** @hidden */
  12443. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12444. /** @hidden */
  12445. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12446. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12447. private _processShaderConversion(sourceCode, isFragment, callback);
  12448. private _processIncludes(sourceCode, callback);
  12449. private _processPrecision(source);
  12450. /**
  12451. * Recompiles the webGL program
  12452. * @param vertexSourceCode The source code for the vertex shader.
  12453. * @param fragmentSourceCode The source code for the fragment shader.
  12454. * @param onCompiled Callback called when completed.
  12455. * @param onError Callback called on error.
  12456. */
  12457. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12458. /**
  12459. * Gets the uniform locations of the the specified variable names
  12460. * @param names THe names of the variables to lookup.
  12461. * @returns Array of locations in the same order as variable names.
  12462. */
  12463. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12464. /**
  12465. * Prepares the effect
  12466. */
  12467. _prepareEffect(): void;
  12468. /**
  12469. * Checks if the effect is supported. (Must be called after compilation)
  12470. */
  12471. readonly isSupported: boolean;
  12472. /**
  12473. * Binds a texture to the engine to be used as output of the shader.
  12474. * @param channel Name of the output variable.
  12475. * @param texture Texture to bind.
  12476. */
  12477. _bindTexture(channel: string, texture: InternalTexture): void;
  12478. /**
  12479. * Sets a texture on the engine to be used in the shader.
  12480. * @param channel Name of the sampler variable.
  12481. * @param texture Texture to set.
  12482. */
  12483. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12484. /**
  12485. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12486. * @param channel Name of the sampler variable.
  12487. * @param texture Texture to set.
  12488. */
  12489. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12490. /**
  12491. * Sets an array of textures on the engine to be used in the shader.
  12492. * @param channel Name of the variable.
  12493. * @param textures Textures to set.
  12494. */
  12495. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12496. /**
  12497. * 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)
  12498. * @param channel Name of the sampler variable.
  12499. * @param postProcess Post process to get the input texture from.
  12500. */
  12501. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12502. /**
  12503. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12504. * 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)
  12505. * @param channel Name of the sampler variable.
  12506. * @param postProcess Post process to get the output texture from.
  12507. */
  12508. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12509. /** @hidden */
  12510. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12511. /** @hidden */
  12512. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12513. /** @hidden */
  12514. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12515. /** @hidden */
  12516. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12517. /**
  12518. * Binds a buffer to a uniform.
  12519. * @param buffer Buffer to bind.
  12520. * @param name Name of the uniform variable to bind to.
  12521. */
  12522. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12523. /**
  12524. * Binds block to a uniform.
  12525. * @param blockName Name of the block to bind.
  12526. * @param index Index to bind.
  12527. */
  12528. bindUniformBlock(blockName: string, index: number): void;
  12529. /**
  12530. * Sets an interger value on a uniform variable.
  12531. * @param uniformName Name of the variable.
  12532. * @param value Value to be set.
  12533. * @returns this effect.
  12534. */
  12535. setInt(uniformName: string, value: number): Effect;
  12536. /**
  12537. * Sets an int array on a uniform variable.
  12538. * @param uniformName Name of the variable.
  12539. * @param array array to be set.
  12540. * @returns this effect.
  12541. */
  12542. setIntArray(uniformName: string, array: Int32Array): Effect;
  12543. /**
  12544. * 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)
  12545. * @param uniformName Name of the variable.
  12546. * @param array array to be set.
  12547. * @returns this effect.
  12548. */
  12549. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12550. /**
  12551. * 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)
  12552. * @param uniformName Name of the variable.
  12553. * @param array array to be set.
  12554. * @returns this effect.
  12555. */
  12556. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12557. /**
  12558. * 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)
  12559. * @param uniformName Name of the variable.
  12560. * @param array array to be set.
  12561. * @returns this effect.
  12562. */
  12563. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12564. /**
  12565. * Sets an float array on a uniform variable.
  12566. * @param uniformName Name of the variable.
  12567. * @param array array to be set.
  12568. * @returns this effect.
  12569. */
  12570. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12571. /**
  12572. * 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)
  12573. * @param uniformName Name of the variable.
  12574. * @param array array to be set.
  12575. * @returns this effect.
  12576. */
  12577. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12578. /**
  12579. * 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)
  12580. * @param uniformName Name of the variable.
  12581. * @param array array to be set.
  12582. * @returns this effect.
  12583. */
  12584. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12585. /**
  12586. * 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)
  12587. * @param uniformName Name of the variable.
  12588. * @param array array to be set.
  12589. * @returns this effect.
  12590. */
  12591. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12592. /**
  12593. * Sets an array on a uniform variable.
  12594. * @param uniformName Name of the variable.
  12595. * @param array array to be set.
  12596. * @returns this effect.
  12597. */
  12598. setArray(uniformName: string, array: number[]): Effect;
  12599. /**
  12600. * 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)
  12601. * @param uniformName Name of the variable.
  12602. * @param array array to be set.
  12603. * @returns this effect.
  12604. */
  12605. setArray2(uniformName: string, array: number[]): Effect;
  12606. /**
  12607. * 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)
  12608. * @param uniformName Name of the variable.
  12609. * @param array array to be set.
  12610. * @returns this effect.
  12611. */
  12612. setArray3(uniformName: string, array: number[]): Effect;
  12613. /**
  12614. * 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)
  12615. * @param uniformName Name of the variable.
  12616. * @param array array to be set.
  12617. * @returns this effect.
  12618. */
  12619. setArray4(uniformName: string, array: number[]): Effect;
  12620. /**
  12621. * Sets matrices on a uniform variable.
  12622. * @param uniformName Name of the variable.
  12623. * @param matrices matrices to be set.
  12624. * @returns this effect.
  12625. */
  12626. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12627. /**
  12628. * Sets matrix on a uniform variable.
  12629. * @param uniformName Name of the variable.
  12630. * @param matrix matrix to be set.
  12631. * @returns this effect.
  12632. */
  12633. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12634. /**
  12635. * 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)
  12636. * @param uniformName Name of the variable.
  12637. * @param matrix matrix to be set.
  12638. * @returns this effect.
  12639. */
  12640. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12641. /**
  12642. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12643. * @param uniformName Name of the variable.
  12644. * @param matrix matrix to be set.
  12645. * @returns this effect.
  12646. */
  12647. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12648. /**
  12649. * Sets a float on a uniform variable.
  12650. * @param uniformName Name of the variable.
  12651. * @param value value to be set.
  12652. * @returns this effect.
  12653. */
  12654. setFloat(uniformName: string, value: number): Effect;
  12655. /**
  12656. * Sets a boolean on a uniform variable.
  12657. * @param uniformName Name of the variable.
  12658. * @param bool value to be set.
  12659. * @returns this effect.
  12660. */
  12661. setBool(uniformName: string, bool: boolean): Effect;
  12662. /**
  12663. * Sets a Vector2 on a uniform variable.
  12664. * @param uniformName Name of the variable.
  12665. * @param vector2 vector2 to be set.
  12666. * @returns this effect.
  12667. */
  12668. setVector2(uniformName: string, vector2: Vector2): Effect;
  12669. /**
  12670. * Sets a float2 on a uniform variable.
  12671. * @param uniformName Name of the variable.
  12672. * @param x First float in float2.
  12673. * @param y Second float in float2.
  12674. * @returns this effect.
  12675. */
  12676. setFloat2(uniformName: string, x: number, y: number): Effect;
  12677. /**
  12678. * Sets a Vector3 on a uniform variable.
  12679. * @param uniformName Name of the variable.
  12680. * @param vector3 Value to be set.
  12681. * @returns this effect.
  12682. */
  12683. setVector3(uniformName: string, vector3: Vector3): Effect;
  12684. /**
  12685. * Sets a float3 on a uniform variable.
  12686. * @param uniformName Name of the variable.
  12687. * @param x First float in float3.
  12688. * @param y Second float in float3.
  12689. * @param z Third float in float3.
  12690. * @returns this effect.
  12691. */
  12692. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12693. /**
  12694. * Sets a Vector4 on a uniform variable.
  12695. * @param uniformName Name of the variable.
  12696. * @param vector4 Value to be set.
  12697. * @returns this effect.
  12698. */
  12699. setVector4(uniformName: string, vector4: Vector4): Effect;
  12700. /**
  12701. * Sets a float4 on a uniform variable.
  12702. * @param uniformName Name of the variable.
  12703. * @param x First float in float4.
  12704. * @param y Second float in float4.
  12705. * @param z Third float in float4.
  12706. * @param w Fourth float in float4.
  12707. * @returns this effect.
  12708. */
  12709. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12710. /**
  12711. * Sets a Color3 on a uniform variable.
  12712. * @param uniformName Name of the variable.
  12713. * @param color3 Value to be set.
  12714. * @returns this effect.
  12715. */
  12716. setColor3(uniformName: string, color3: Color3): Effect;
  12717. /**
  12718. * Sets a Color4 on a uniform variable.
  12719. * @param uniformName Name of the variable.
  12720. * @param color3 Value to be set.
  12721. * @param alpha Alpha value to be set.
  12722. * @returns this effect.
  12723. */
  12724. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12725. /**
  12726. * Sets a Color4 on a uniform variable
  12727. * @param uniformName defines the name of the variable
  12728. * @param color4 defines the value to be set
  12729. * @returns this effect.
  12730. */
  12731. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12732. /**
  12733. * Store of each shader (The can be looked up using effect.key)
  12734. */
  12735. static ShadersStore: {
  12736. [key: string]: string;
  12737. };
  12738. /**
  12739. * Store of each included file for a shader (The can be looked up using effect.key)
  12740. */
  12741. static IncludesShadersStore: {
  12742. [key: string]: string;
  12743. };
  12744. /**
  12745. * Resets the cache of effects.
  12746. */
  12747. static ResetCache(): void;
  12748. }
  12749. }
  12750. declare module BABYLON {
  12751. class FresnelParameters {
  12752. private _isEnabled;
  12753. isEnabled: boolean;
  12754. leftColor: Color3;
  12755. rightColor: Color3;
  12756. bias: number;
  12757. power: number;
  12758. clone(): FresnelParameters;
  12759. serialize(): any;
  12760. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12761. }
  12762. }
  12763. declare module BABYLON {
  12764. /**
  12765. * Interface to follow in your material defines to integrate easily the
  12766. * Image proccessing functions.
  12767. * @hidden
  12768. */
  12769. interface IImageProcessingConfigurationDefines {
  12770. IMAGEPROCESSING: boolean;
  12771. VIGNETTE: boolean;
  12772. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12773. VIGNETTEBLENDMODEOPAQUE: boolean;
  12774. TONEMAPPING: boolean;
  12775. CONTRAST: boolean;
  12776. EXPOSURE: boolean;
  12777. COLORCURVES: boolean;
  12778. COLORGRADING: boolean;
  12779. COLORGRADING3D: boolean;
  12780. SAMPLER3DGREENDEPTH: boolean;
  12781. SAMPLER3DBGRMAP: boolean;
  12782. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12783. }
  12784. /**
  12785. * This groups together the common properties used for image processing either in direct forward pass
  12786. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12787. * or not.
  12788. */
  12789. class ImageProcessingConfiguration {
  12790. /**
  12791. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12792. */
  12793. colorCurves: Nullable<ColorCurves>;
  12794. private _colorCurvesEnabled;
  12795. /**
  12796. * Gets wether the color curves effect is enabled.
  12797. */
  12798. /**
  12799. * Sets wether the color curves effect is enabled.
  12800. */
  12801. colorCurvesEnabled: boolean;
  12802. /**
  12803. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12804. */
  12805. colorGradingTexture: Nullable<BaseTexture>;
  12806. private _colorGradingEnabled;
  12807. /**
  12808. * Gets wether the color grading effect is enabled.
  12809. */
  12810. /**
  12811. * Sets wether the color grading effect is enabled.
  12812. */
  12813. colorGradingEnabled: boolean;
  12814. private _colorGradingWithGreenDepth;
  12815. /**
  12816. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12817. */
  12818. /**
  12819. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12820. */
  12821. colorGradingWithGreenDepth: boolean;
  12822. private _colorGradingBGR;
  12823. /**
  12824. * Gets wether the color grading texture contains BGR values.
  12825. */
  12826. /**
  12827. * Sets wether the color grading texture contains BGR values.
  12828. */
  12829. colorGradingBGR: boolean;
  12830. _exposure: number;
  12831. /**
  12832. * Gets the Exposure used in the effect.
  12833. */
  12834. /**
  12835. * Sets the Exposure used in the effect.
  12836. */
  12837. exposure: number;
  12838. private _toneMappingEnabled;
  12839. /**
  12840. * Gets wether the tone mapping effect is enabled.
  12841. */
  12842. /**
  12843. * Sets wether the tone mapping effect is enabled.
  12844. */
  12845. toneMappingEnabled: boolean;
  12846. protected _contrast: number;
  12847. /**
  12848. * Gets the contrast used in the effect.
  12849. */
  12850. /**
  12851. * Sets the contrast used in the effect.
  12852. */
  12853. contrast: number;
  12854. /**
  12855. * Vignette stretch size.
  12856. */
  12857. vignetteStretch: number;
  12858. /**
  12859. * Vignette centre X Offset.
  12860. */
  12861. vignetteCentreX: number;
  12862. /**
  12863. * Vignette centre Y Offset.
  12864. */
  12865. vignetteCentreY: number;
  12866. /**
  12867. * Vignette weight or intensity of the vignette effect.
  12868. */
  12869. vignetteWeight: number;
  12870. /**
  12871. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12872. * if vignetteEnabled is set to true.
  12873. */
  12874. vignetteColor: Color4;
  12875. /**
  12876. * Camera field of view used by the Vignette effect.
  12877. */
  12878. vignetteCameraFov: number;
  12879. private _vignetteBlendMode;
  12880. /**
  12881. * Gets the vignette blend mode allowing different kind of effect.
  12882. */
  12883. /**
  12884. * Sets the vignette blend mode allowing different kind of effect.
  12885. */
  12886. vignetteBlendMode: number;
  12887. private _vignetteEnabled;
  12888. /**
  12889. * Gets wether the vignette effect is enabled.
  12890. */
  12891. /**
  12892. * Sets wether the vignette effect is enabled.
  12893. */
  12894. vignetteEnabled: boolean;
  12895. private _applyByPostProcess;
  12896. /**
  12897. * Gets wether the image processing is applied through a post process or not.
  12898. */
  12899. /**
  12900. * Sets wether the image processing is applied through a post process or not.
  12901. */
  12902. applyByPostProcess: boolean;
  12903. private _isEnabled;
  12904. /**
  12905. * Gets wether the image processing is enabled or not.
  12906. */
  12907. /**
  12908. * Sets wether the image processing is enabled or not.
  12909. */
  12910. isEnabled: boolean;
  12911. /**
  12912. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12913. */
  12914. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12915. /**
  12916. * Method called each time the image processing information changes requires to recompile the effect.
  12917. */
  12918. protected _updateParameters(): void;
  12919. getClassName(): string;
  12920. /**
  12921. * Prepare the list of uniforms associated with the Image Processing effects.
  12922. * @param uniformsList The list of uniforms used in the effect
  12923. * @param defines the list of defines currently in use
  12924. */
  12925. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12926. /**
  12927. * Prepare the list of samplers associated with the Image Processing effects.
  12928. * @param uniformsList The list of uniforms used in the effect
  12929. * @param defines the list of defines currently in use
  12930. */
  12931. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12932. /**
  12933. * Prepare the list of defines associated to the shader.
  12934. * @param defines the list of defines to complete
  12935. */
  12936. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12937. /**
  12938. * Returns true if all the image processing information are ready.
  12939. */
  12940. isReady(): boolean;
  12941. /**
  12942. * Binds the image processing to the shader.
  12943. * @param effect The effect to bind to
  12944. */
  12945. bind(effect: Effect, aspectRatio?: number): void;
  12946. /**
  12947. * Clones the current image processing instance.
  12948. * @return The cloned image processing
  12949. */
  12950. clone(): ImageProcessingConfiguration;
  12951. /**
  12952. * Serializes the current image processing instance to a json representation.
  12953. * @return a JSON representation
  12954. */
  12955. serialize(): any;
  12956. /**
  12957. * Parses the image processing from a json representation.
  12958. * @param source the JSON source to parse
  12959. * @return The parsed image processing
  12960. */
  12961. static Parse(source: any): ImageProcessingConfiguration;
  12962. private static _VIGNETTEMODE_MULTIPLY;
  12963. private static _VIGNETTEMODE_OPAQUE;
  12964. /**
  12965. * Used to apply the vignette as a mix with the pixel color.
  12966. */
  12967. static readonly VIGNETTEMODE_MULTIPLY: number;
  12968. /**
  12969. * Used to apply the vignette as a replacement of the pixel color.
  12970. */
  12971. static readonly VIGNETTEMODE_OPAQUE: number;
  12972. }
  12973. }
  12974. declare module BABYLON {
  12975. /**
  12976. * Manages the defines for the Material
  12977. */
  12978. class MaterialDefines {
  12979. private _keys;
  12980. private _isDirty;
  12981. /** @hidden */
  12982. _renderId: number;
  12983. /** @hidden */
  12984. _areLightsDirty: boolean;
  12985. /** @hidden */
  12986. _areAttributesDirty: boolean;
  12987. /** @hidden */
  12988. _areTexturesDirty: boolean;
  12989. /** @hidden */
  12990. _areFresnelDirty: boolean;
  12991. /** @hidden */
  12992. _areMiscDirty: boolean;
  12993. /** @hidden */
  12994. _areImageProcessingDirty: boolean;
  12995. /** @hidden */
  12996. _normals: boolean;
  12997. /** @hidden */
  12998. _uvs: boolean;
  12999. /** @hidden */
  13000. _needNormals: boolean;
  13001. /** @hidden */
  13002. _needUVs: boolean;
  13003. /**
  13004. * Specifies if the material needs to be re-calculated
  13005. */
  13006. readonly isDirty: boolean;
  13007. /**
  13008. * Marks the material to indicate that it has been re-calculated
  13009. */
  13010. markAsProcessed(): void;
  13011. /**
  13012. * Marks the material to indicate that it needs to be re-calculated
  13013. */
  13014. markAsUnprocessed(): void;
  13015. /**
  13016. * Marks the material to indicate all of its defines need to be re-calculated
  13017. */
  13018. markAllAsDirty(): void;
  13019. /**
  13020. * Marks the material to indicate that image processing needs to be re-calculated
  13021. */
  13022. markAsImageProcessingDirty(): void;
  13023. /**
  13024. * Marks the material to indicate the lights need to be re-calculated
  13025. */
  13026. markAsLightDirty(): void;
  13027. /**
  13028. * Marks the attribute state as changed
  13029. */
  13030. markAsAttributesDirty(): void;
  13031. /**
  13032. * Marks the texture state as changed
  13033. */
  13034. markAsTexturesDirty(): void;
  13035. /**
  13036. * Marks the fresnel state as changed
  13037. */
  13038. markAsFresnelDirty(): void;
  13039. /**
  13040. * Marks the misc state as changed
  13041. */
  13042. markAsMiscDirty(): void;
  13043. /**
  13044. * Rebuilds the material defines
  13045. */
  13046. rebuild(): void;
  13047. /**
  13048. * Specifies if two material defines are equal
  13049. * @param other - A material define instance to compare to
  13050. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13051. */
  13052. isEqual(other: MaterialDefines): boolean;
  13053. /**
  13054. * Clones this instance's defines to another instance
  13055. * @param other - material defines to clone values to
  13056. */
  13057. cloneTo(other: MaterialDefines): void;
  13058. /**
  13059. * Resets the material define values
  13060. */
  13061. reset(): void;
  13062. /**
  13063. * Converts the material define values to a string
  13064. * @returns - String of material define information
  13065. */
  13066. toString(): string;
  13067. }
  13068. /**
  13069. * Base class for the main features of a material in Babylon.js
  13070. */
  13071. class Material implements IAnimatable {
  13072. private static _TriangleFillMode;
  13073. private static _WireFrameFillMode;
  13074. private static _PointFillMode;
  13075. private static _PointListDrawMode;
  13076. private static _LineListDrawMode;
  13077. private static _LineLoopDrawMode;
  13078. private static _LineStripDrawMode;
  13079. private static _TriangleStripDrawMode;
  13080. private static _TriangleFanDrawMode;
  13081. /**
  13082. * Returns the triangle fill mode
  13083. */
  13084. static readonly TriangleFillMode: number;
  13085. /**
  13086. * Returns the wireframe mode
  13087. */
  13088. static readonly WireFrameFillMode: number;
  13089. /**
  13090. * Returns the point fill mode
  13091. */
  13092. static readonly PointFillMode: number;
  13093. /**
  13094. * Returns the point list draw mode
  13095. */
  13096. static readonly PointListDrawMode: number;
  13097. /**
  13098. * Returns the line list draw mode
  13099. */
  13100. static readonly LineListDrawMode: number;
  13101. /**
  13102. * Returns the line loop draw mode
  13103. */
  13104. static readonly LineLoopDrawMode: number;
  13105. /**
  13106. * Returns the line strip draw mode
  13107. */
  13108. static readonly LineStripDrawMode: number;
  13109. /**
  13110. * Returns the triangle strip draw mode
  13111. */
  13112. static readonly TriangleStripDrawMode: number;
  13113. /**
  13114. * Returns the triangle fan draw mode
  13115. */
  13116. static readonly TriangleFanDrawMode: number;
  13117. /**
  13118. * Stores the clock-wise side orientation
  13119. */
  13120. private static _ClockWiseSideOrientation;
  13121. /**
  13122. * Stores the counter clock-wise side orientation
  13123. */
  13124. private static _CounterClockWiseSideOrientation;
  13125. /**
  13126. * Returns the clock-wise side orientation
  13127. */
  13128. static readonly ClockWiseSideOrientation: number;
  13129. /**
  13130. * Returns the counter clock-wise side orientation
  13131. */
  13132. static readonly CounterClockWiseSideOrientation: number;
  13133. /**
  13134. * The dirty texture flag value
  13135. */
  13136. private static _TextureDirtyFlag;
  13137. /**
  13138. * The dirty light flag value
  13139. */
  13140. private static _LightDirtyFlag;
  13141. /**
  13142. * The dirty fresnel flag value
  13143. */
  13144. private static _FresnelDirtyFlag;
  13145. /**
  13146. * The dirty attribute flag value
  13147. */
  13148. private static _AttributesDirtyFlag;
  13149. /**
  13150. * The dirty misc flag value
  13151. */
  13152. private static _MiscDirtyFlag;
  13153. /**
  13154. * Returns the dirty texture flag value
  13155. */
  13156. static readonly TextureDirtyFlag: number;
  13157. /**
  13158. * Returns the dirty light flag value
  13159. */
  13160. static readonly LightDirtyFlag: number;
  13161. /**
  13162. * Returns the dirty fresnel flag value
  13163. */
  13164. static readonly FresnelDirtyFlag: number;
  13165. /**
  13166. * Returns the dirty attributes flag value
  13167. */
  13168. static readonly AttributesDirtyFlag: number;
  13169. /**
  13170. * Returns the dirty misc flag value
  13171. */
  13172. static readonly MiscDirtyFlag: number;
  13173. /**
  13174. * The ID of the material
  13175. */
  13176. id: string;
  13177. /**
  13178. * The name of the material
  13179. */
  13180. name: string;
  13181. /**
  13182. * Specifies if the ready state should be checked on each call
  13183. */
  13184. checkReadyOnEveryCall: boolean;
  13185. /**
  13186. * Specifies if the ready state should be checked once
  13187. */
  13188. checkReadyOnlyOnce: boolean;
  13189. /**
  13190. * The state of the material
  13191. */
  13192. state: string;
  13193. /**
  13194. * The alpha value of the material
  13195. */
  13196. protected _alpha: number;
  13197. /**
  13198. * Gets the alpha value of the material
  13199. */
  13200. /**
  13201. * Sets the alpha value of the material
  13202. */
  13203. alpha: number;
  13204. /**
  13205. * Specifies if back face culling is enabled
  13206. */
  13207. protected _backFaceCulling: boolean;
  13208. /**
  13209. * Gets the back-face culling state
  13210. */
  13211. /**
  13212. * Sets the back-face culling state
  13213. */
  13214. backFaceCulling: boolean;
  13215. /**
  13216. * Stores the value for side orientation
  13217. */
  13218. sideOrientation: number;
  13219. /**
  13220. * Callback triggered when the material is compiled
  13221. */
  13222. onCompiled: (effect: Effect) => void;
  13223. /**
  13224. * Callback triggered when an error occurs
  13225. */
  13226. onError: (effect: Effect, errors: string) => void;
  13227. /**
  13228. * Callback triggered to get the render target textures
  13229. */
  13230. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13231. /**
  13232. * Specifies if the material should be serialized
  13233. */
  13234. doNotSerialize: boolean;
  13235. /**
  13236. * Specifies if the effect should be stored on sub meshes
  13237. */
  13238. storeEffectOnSubMeshes: boolean;
  13239. /**
  13240. * Stores the animations for the material
  13241. */
  13242. animations: Array<Animation>;
  13243. /**
  13244. * An event triggered when the material is disposed
  13245. */
  13246. onDisposeObservable: Observable<Material>;
  13247. /**
  13248. * An observer which watches for dispose events
  13249. */
  13250. private _onDisposeObserver;
  13251. /**
  13252. * Called during a dispose event
  13253. */
  13254. onDispose: () => void;
  13255. /**
  13256. * An event triggered when the material is bound
  13257. */
  13258. onBindObservable: Observable<AbstractMesh>;
  13259. /**
  13260. * An observer which watches for bind events
  13261. */
  13262. private _onBindObserver;
  13263. /**
  13264. * Called during a bind event
  13265. */
  13266. onBind: (Mesh: AbstractMesh) => void;
  13267. /**
  13268. * An event triggered when the material is unbound
  13269. */
  13270. onUnBindObservable: Observable<Material>;
  13271. /**
  13272. * Stores the value of the alpha mode
  13273. */
  13274. private _alphaMode;
  13275. /**
  13276. * Gets the value of the alpha mode
  13277. */
  13278. /**
  13279. * Sets the value of the alpha mode.
  13280. *
  13281. * | Value | Type | Description |
  13282. * | --- | --- | --- |
  13283. * | 0 | ALPHA_DISABLE | |
  13284. * | 1 | ALPHA_ADD | |
  13285. * | 2 | ALPHA_COMBINE | |
  13286. * | 3 | ALPHA_SUBTRACT | |
  13287. * | 4 | ALPHA_MULTIPLY | |
  13288. * | 5 | ALPHA_MAXIMIZED | |
  13289. * | 6 | ALPHA_ONEONE | |
  13290. * | 7 | ALPHA_PREMULTIPLIED | |
  13291. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13292. * | 9 | ALPHA_INTERPOLATE | |
  13293. * | 10 | ALPHA_SCREENMODE | |
  13294. *
  13295. */
  13296. alphaMode: number;
  13297. /**
  13298. * Stores the state of the need depth pre-pass value
  13299. */
  13300. private _needDepthPrePass;
  13301. /**
  13302. * Gets the depth pre-pass value
  13303. */
  13304. /**
  13305. * Sets the need depth pre-pass value
  13306. */
  13307. needDepthPrePass: boolean;
  13308. /**
  13309. * Specifies if depth writing should be disabled
  13310. */
  13311. disableDepthWrite: boolean;
  13312. /**
  13313. * Specifies if depth writing should be forced
  13314. */
  13315. forceDepthWrite: boolean;
  13316. /**
  13317. * Specifies if there should be a separate pass for culling
  13318. */
  13319. separateCullingPass: boolean;
  13320. /**
  13321. * Stores the state specifing if fog should be enabled
  13322. */
  13323. private _fogEnabled;
  13324. /**
  13325. * Gets the value of the fog enabled state
  13326. */
  13327. /**
  13328. * Sets the state for enabling fog
  13329. */
  13330. fogEnabled: boolean;
  13331. /**
  13332. * Stores the size of points
  13333. */
  13334. pointSize: number;
  13335. /**
  13336. * Stores the z offset value
  13337. */
  13338. zOffset: number;
  13339. /**
  13340. * Gets a value specifying if wireframe mode is enabled
  13341. */
  13342. /**
  13343. * Sets the state of wireframe mode
  13344. */
  13345. wireframe: boolean;
  13346. /**
  13347. * Gets the value specifying if point clouds are enabled
  13348. */
  13349. /**
  13350. * Sets the state of point cloud mode
  13351. */
  13352. pointsCloud: boolean;
  13353. /**
  13354. * Gets the material fill mode
  13355. */
  13356. /**
  13357. * Sets the material fill mode
  13358. */
  13359. fillMode: number;
  13360. /**
  13361. * Stores the effects for the material
  13362. */
  13363. _effect: Nullable<Effect>;
  13364. /**
  13365. * Specifies if the material was previously ready
  13366. */
  13367. _wasPreviouslyReady: boolean;
  13368. /**
  13369. * Specifies if uniform buffers should be used
  13370. */
  13371. private _useUBO;
  13372. /**
  13373. * Stores a reference to the scene
  13374. */
  13375. private _scene;
  13376. /**
  13377. * Stores the fill mode state
  13378. */
  13379. private _fillMode;
  13380. /**
  13381. * Specifies if the depth write state should be cached
  13382. */
  13383. private _cachedDepthWriteState;
  13384. /**
  13385. * Stores the uniform buffer
  13386. */
  13387. protected _uniformBuffer: UniformBuffer;
  13388. /**
  13389. * Creates a material instance
  13390. * @param name defines the name of the material
  13391. * @param scene defines the scene to reference
  13392. * @param doNotAdd specifies if the material should be added to the scene
  13393. */
  13394. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13395. /**
  13396. * Returns a string representation of the current material
  13397. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13398. * @returns a string with material information
  13399. */
  13400. toString(fullDetails?: boolean): string;
  13401. /**
  13402. * Gets the class name of the material
  13403. * @returns a string with the class name of the material
  13404. */
  13405. getClassName(): string;
  13406. /**
  13407. * Specifies if updates for the material been locked
  13408. */
  13409. readonly isFrozen: boolean;
  13410. /**
  13411. * Locks updates for the material
  13412. */
  13413. freeze(): void;
  13414. /**
  13415. * Unlocks updates for the material
  13416. */
  13417. unfreeze(): void;
  13418. /**
  13419. * Specifies if the material is ready to be used
  13420. * @param mesh defines the mesh to check
  13421. * @param useInstances specifies if instances should be used
  13422. * @returns a boolean indicating if the material is ready to be used
  13423. */
  13424. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13425. /**
  13426. * Specifies that the submesh is ready to be used
  13427. * @param mesh defines the mesh to check
  13428. * @param subMesh defines which submesh to check
  13429. * @param useInstances specifies that instances should be used
  13430. * @returns a boolean indicating that the submesh is ready or not
  13431. */
  13432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13433. /**
  13434. * Returns the material effect
  13435. * @returns the effect associated with the material
  13436. */
  13437. getEffect(): Nullable<Effect>;
  13438. /**
  13439. * Returns the current scene
  13440. * @returns a Scene
  13441. */
  13442. getScene(): Scene;
  13443. /**
  13444. * Specifies if the material will require alpha blending
  13445. * @returns a boolean specifying if alpha blending is needed
  13446. */
  13447. needAlphaBlending(): boolean;
  13448. /**
  13449. * Specifies if the mesh will require alpha blending
  13450. * @param mesh defines the mesh to check
  13451. * @returns a boolean specifying if alpha blending is needed for the mesh
  13452. */
  13453. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13454. /**
  13455. * Specifies if this material should be rendered in alpha test mode
  13456. * @returns a boolean specifying if an alpha test is needed.
  13457. */
  13458. needAlphaTesting(): boolean;
  13459. /**
  13460. * Gets the texture used for the alpha test
  13461. * @returns the texture to use for alpha testing
  13462. */
  13463. getAlphaTestTexture(): Nullable<BaseTexture>;
  13464. /**
  13465. * Marks the material to indicate that it needs to be re-calculated
  13466. */
  13467. markDirty(): void;
  13468. /** @hidden */
  13469. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13470. /**
  13471. * Binds the material to the mesh
  13472. * @param world defines the world transformation matrix
  13473. * @param mesh defines the mesh to bind the material to
  13474. */
  13475. bind(world: Matrix, mesh?: Mesh): void;
  13476. /**
  13477. * Binds the submesh to the material
  13478. * @param world defines the world transformation matrix
  13479. * @param mesh defines the mesh containing the submesh
  13480. * @param subMesh defines the submesh to bind the material to
  13481. */
  13482. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13483. /**
  13484. * Binds the world matrix to the material
  13485. * @param world defines the world transformation matrix
  13486. */
  13487. bindOnlyWorldMatrix(world: Matrix): void;
  13488. /**
  13489. * Binds the scene's uniform buffer to the effect.
  13490. * @param effect defines the effect to bind to the scene uniform buffer
  13491. * @param sceneUbo defines the uniform buffer storing scene data
  13492. */
  13493. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13494. /**
  13495. * Binds the view matrix to the effect
  13496. * @param effect defines the effect to bind the view matrix to
  13497. */
  13498. bindView(effect: Effect): void;
  13499. /**
  13500. * Binds the view projection matrix to the effect
  13501. * @param effect defines the effect to bind the view projection matrix to
  13502. */
  13503. bindViewProjection(effect: Effect): void;
  13504. /**
  13505. * Specifies if material alpha testing should be turned on for the mesh
  13506. * @param mesh defines the mesh to check
  13507. */
  13508. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13509. /**
  13510. * Processes to execute after binding the material to a mesh
  13511. * @param mesh defines the rendered mesh
  13512. */
  13513. protected _afterBind(mesh?: Mesh): void;
  13514. /**
  13515. * Unbinds the material from the mesh
  13516. */
  13517. unbind(): void;
  13518. /**
  13519. * Gets the active textures from the material
  13520. * @returns an array of textures
  13521. */
  13522. getActiveTextures(): BaseTexture[];
  13523. /**
  13524. * Specifies if the material uses a texture
  13525. * @param texture defines the texture to check against the material
  13526. * @returns a boolean specifying if the material uses the texture
  13527. */
  13528. hasTexture(texture: BaseTexture): boolean;
  13529. /**
  13530. * Makes a duplicate of the material, and gives it a new name
  13531. * @param name defines the new name for the duplicated material
  13532. * @returns the cloned material
  13533. */
  13534. clone(name: string): Nullable<Material>;
  13535. /**
  13536. * Gets the meshes bound to the material
  13537. * @returns an array of meshes bound to the material
  13538. */
  13539. getBindedMeshes(): AbstractMesh[];
  13540. /**
  13541. * Force shader compilation
  13542. * @param mesh defines the mesh associated with this material
  13543. * @param onCompiled defines a function to execute once the material is compiled
  13544. * @param options defines the options to configure the compilation
  13545. */
  13546. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13547. clipPlane: boolean;
  13548. }>): void;
  13549. /**
  13550. * Force shader compilation
  13551. * @param mesh defines the mesh that will use this material
  13552. * @param options defines additional options for compiling the shaders
  13553. * @returns a promise that resolves when the compilation completes
  13554. */
  13555. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13556. clipPlane: boolean;
  13557. }>): Promise<void>;
  13558. /**
  13559. * Marks a define in the material to indicate that it needs to be re-computed
  13560. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13561. */
  13562. markAsDirty(flag: number): void;
  13563. /**
  13564. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13565. * @param func defines a function which checks material defines against the submeshes
  13566. */
  13567. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13568. /**
  13569. * Indicates that image processing needs to be re-calculated for all submeshes
  13570. */
  13571. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13572. /**
  13573. * Indicates that textures need to be re-calculated for all submeshes
  13574. */
  13575. protected _markAllSubMeshesAsTexturesDirty(): void;
  13576. /**
  13577. * Indicates that fresnel needs to be re-calculated for all submeshes
  13578. */
  13579. protected _markAllSubMeshesAsFresnelDirty(): void;
  13580. /**
  13581. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13582. */
  13583. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13584. /**
  13585. * Indicates that lights need to be re-calculated for all submeshes
  13586. */
  13587. protected _markAllSubMeshesAsLightsDirty(): void;
  13588. /**
  13589. * Indicates that attributes need to be re-calculated for all submeshes
  13590. */
  13591. protected _markAllSubMeshesAsAttributesDirty(): void;
  13592. /**
  13593. * Indicates that misc needs to be re-calculated for all submeshes
  13594. */
  13595. protected _markAllSubMeshesAsMiscDirty(): void;
  13596. /**
  13597. * Indicates that textures and misc need to be re-calculated for all submeshes
  13598. */
  13599. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13600. /**
  13601. * Disposes the material
  13602. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13603. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13604. */
  13605. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13606. /**
  13607. * Serializes this material
  13608. * @returns the serialized material object
  13609. */
  13610. serialize(): any;
  13611. /**
  13612. * Creates a MultiMaterial from parsed MultiMaterial data.
  13613. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13614. * @param scene defines the hosting scene
  13615. * @returns a new MultiMaterial
  13616. */
  13617. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13618. /**
  13619. * Creates a material from parsed material data
  13620. * @param parsedMaterial defines parsed material data
  13621. * @param scene defines the hosting scene
  13622. * @param rootUrl defines the root URL to use to load textures
  13623. * @returns a new material
  13624. */
  13625. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13626. }
  13627. }
  13628. declare module BABYLON {
  13629. /**
  13630. * "Static Class" containing the most commonly used helper while dealing with material for
  13631. * rendering purpose.
  13632. *
  13633. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13634. *
  13635. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13636. */
  13637. class MaterialHelper {
  13638. /**
  13639. * Bind the current view position to an effect.
  13640. * @param effect The effect to be bound
  13641. * @param scene The scene the eyes position is used from
  13642. */
  13643. static BindEyePosition(effect: Effect, scene: Scene): void;
  13644. /**
  13645. * Helps preparing the defines values about the UVs in used in the effect.
  13646. * UVs are shared as much as we can accross chanels in the shaders.
  13647. * @param texture The texture we are preparing the UVs for
  13648. * @param defines The defines to update
  13649. * @param key The chanel key "diffuse", "specular"... used in the shader
  13650. */
  13651. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13652. /**
  13653. * Binds a texture matrix value to its corrsponding uniform
  13654. * @param texture The texture to bind the matrix for
  13655. * @param uniformBuffer The uniform buffer receivin the data
  13656. * @param key The chanel key "diffuse", "specular"... used in the shader
  13657. */
  13658. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13659. /**
  13660. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13661. * @param mesh defines the current mesh
  13662. * @param scene defines the current scene
  13663. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13664. * @param pointsCloud defines if point cloud rendering has to be turned on
  13665. * @param fogEnabled defines if fog has to be turned on
  13666. * @param alphaTest defines if alpha testing has to be turned on
  13667. * @param defines defines the current list of defines
  13668. */
  13669. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13670. /**
  13671. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13672. * @param scene defines the current scene
  13673. * @param engine defines the current engine
  13674. * @param defines specifies the list of active defines
  13675. * @param useInstances defines if instances have to be turned on
  13676. * @param useClipPlane defines if clip plane have to be turned on
  13677. */
  13678. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13679. /**
  13680. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13681. * @param mesh The mesh containing the geometry data we will draw
  13682. * @param defines The defines to update
  13683. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13684. * @param useBones Precise whether bones should be used or not (override mesh info)
  13685. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13686. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13687. * @returns false if defines are considered not dirty and have not been checked
  13688. */
  13689. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13690. /**
  13691. * Prepares the defines related to the light information passed in parameter
  13692. * @param scene The scene we are intending to draw
  13693. * @param mesh The mesh the effect is compiling for
  13694. * @param defines The defines to update
  13695. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13696. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13697. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13698. * @returns true if normals will be required for the rest of the effect
  13699. */
  13700. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13701. /**
  13702. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13703. * that won t be acctive due to defines being turned off.
  13704. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13705. * @param samplersList The samplers list
  13706. * @param defines The defines helping in the list generation
  13707. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13708. */
  13709. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13710. /**
  13711. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13712. * @param defines The defines to update while falling back
  13713. * @param fallbacks The authorized effect fallbacks
  13714. * @param maxSimultaneousLights The maximum number of lights allowed
  13715. * @param rank the current rank of the Effect
  13716. * @returns The newly affected rank
  13717. */
  13718. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13719. /**
  13720. * Prepares the list of attributes required for morph targets according to the effect defines.
  13721. * @param attribs The current list of supported attribs
  13722. * @param mesh The mesh to prepare the morph targets attributes for
  13723. * @param defines The current Defines of the effect
  13724. */
  13725. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13726. /**
  13727. * Prepares the list of attributes required for bones according to the effect defines.
  13728. * @param attribs The current list of supported attribs
  13729. * @param mesh The mesh to prepare the bones attributes for
  13730. * @param defines The current Defines of the effect
  13731. * @param fallbacks The current efffect fallback strategy
  13732. */
  13733. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13734. /**
  13735. * Prepares the list of attributes required for instances according to the effect defines.
  13736. * @param attribs The current list of supported attribs
  13737. * @param defines The current Defines of the effect
  13738. */
  13739. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13740. /**
  13741. * Binds the light shadow information to the effect for the given mesh.
  13742. * @param light The light containing the generator
  13743. * @param scene The scene the lights belongs to
  13744. * @param mesh The mesh we are binding the information to render
  13745. * @param lightIndex The light index in the effect used to render the mesh
  13746. * @param effect The effect we are binding the data to
  13747. */
  13748. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13749. /**
  13750. * Binds the light information to the effect.
  13751. * @param light The light containing the generator
  13752. * @param effect The effect we are binding the data to
  13753. * @param lightIndex The light index in the effect used to render
  13754. */
  13755. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13756. /**
  13757. * Binds the lights information from the scene to the effect for the given mesh.
  13758. * @param scene The scene the lights belongs to
  13759. * @param mesh The mesh we are binding the information to render
  13760. * @param effect The effect we are binding the data to
  13761. * @param defines The generated defines for the effect
  13762. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13763. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13764. */
  13765. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13766. /**
  13767. * Binds the fog information from the scene to the effect for the given mesh.
  13768. * @param scene The scene the lights belongs to
  13769. * @param mesh The mesh we are binding the information to render
  13770. * @param effect The effect we are binding the data to
  13771. */
  13772. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13773. /**
  13774. * Binds the bones information from the mesh to the effect.
  13775. * @param mesh The mesh we are binding the information to render
  13776. * @param effect The effect we are binding the data to
  13777. */
  13778. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13779. /**
  13780. * Binds the morph targets information from the mesh to the effect.
  13781. * @param abstractMesh The mesh we are binding the information to render
  13782. * @param effect The effect we are binding the data to
  13783. */
  13784. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13785. /**
  13786. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13787. * @param defines The generated defines used in the effect
  13788. * @param effect The effect we are binding the data to
  13789. * @param scene The scene we are willing to render with logarithmic scale for
  13790. */
  13791. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13792. /**
  13793. * Binds the clip plane information from the scene to the effect.
  13794. * @param scene The scene the clip plane information are extracted from
  13795. * @param effect The effect we are binding the data to
  13796. */
  13797. static BindClipPlane(effect: Effect, scene: Scene): void;
  13798. }
  13799. }
  13800. declare module BABYLON {
  13801. class MultiMaterial extends Material {
  13802. private _subMaterials;
  13803. subMaterials: Nullable<Material>[];
  13804. constructor(name: string, scene: Scene);
  13805. private _hookArray(array);
  13806. getSubMaterial(index: number): Nullable<Material>;
  13807. getActiveTextures(): BaseTexture[];
  13808. getClassName(): string;
  13809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13810. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13811. serialize(): any;
  13812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13813. }
  13814. }
  13815. declare module BABYLON {
  13816. class PushMaterial extends Material {
  13817. protected _activeEffect: Effect;
  13818. protected _normalMatrix: Matrix;
  13819. constructor(name: string, scene: Scene);
  13820. getEffect(): Effect;
  13821. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13822. /**
  13823. * Binds the given world matrix to the active effect
  13824. *
  13825. * @param world the matrix to bind
  13826. */
  13827. bindOnlyWorldMatrix(world: Matrix): void;
  13828. /**
  13829. * Binds the given normal matrix to the active effect
  13830. *
  13831. * @param normalMatrix the matrix to bind
  13832. */
  13833. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13834. bind(world: Matrix, mesh?: Mesh): void;
  13835. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13836. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13837. }
  13838. }
  13839. declare module BABYLON {
  13840. class ShaderMaterial extends Material {
  13841. private _shaderPath;
  13842. private _options;
  13843. private _textures;
  13844. private _textureArrays;
  13845. private _floats;
  13846. private _ints;
  13847. private _floatsArrays;
  13848. private _colors3;
  13849. private _colors3Arrays;
  13850. private _colors4;
  13851. private _vectors2;
  13852. private _vectors3;
  13853. private _vectors4;
  13854. private _matrices;
  13855. private _matrices3x3;
  13856. private _matrices2x2;
  13857. private _vectors2Arrays;
  13858. private _vectors3Arrays;
  13859. private _cachedWorldViewMatrix;
  13860. private _renderId;
  13861. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13862. getClassName(): string;
  13863. needAlphaBlending(): boolean;
  13864. needAlphaTesting(): boolean;
  13865. private _checkUniform(uniformName);
  13866. setTexture(name: string, texture: Texture): ShaderMaterial;
  13867. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13868. setFloat(name: string, value: number): ShaderMaterial;
  13869. setInt(name: string, value: number): ShaderMaterial;
  13870. setFloats(name: string, value: number[]): ShaderMaterial;
  13871. setColor3(name: string, value: Color3): ShaderMaterial;
  13872. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13873. setColor4(name: string, value: Color4): ShaderMaterial;
  13874. setVector2(name: string, value: Vector2): ShaderMaterial;
  13875. setVector3(name: string, value: Vector3): ShaderMaterial;
  13876. setVector4(name: string, value: Vector4): ShaderMaterial;
  13877. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13878. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13879. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13880. setArray2(name: string, value: number[]): ShaderMaterial;
  13881. setArray3(name: string, value: number[]): ShaderMaterial;
  13882. private _checkCache(scene, mesh?, useInstances?);
  13883. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13884. bindOnlyWorldMatrix(world: Matrix): void;
  13885. bind(world: Matrix, mesh?: Mesh): void;
  13886. getActiveTextures(): BaseTexture[];
  13887. hasTexture(texture: BaseTexture): boolean;
  13888. clone(name: string): ShaderMaterial;
  13889. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13890. serialize(): any;
  13891. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13892. }
  13893. }
  13894. declare module BABYLON {
  13895. /** @hidden */
  13896. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13897. MAINUV1: boolean;
  13898. MAINUV2: boolean;
  13899. DIFFUSE: boolean;
  13900. DIFFUSEDIRECTUV: number;
  13901. AMBIENT: boolean;
  13902. AMBIENTDIRECTUV: number;
  13903. OPACITY: boolean;
  13904. OPACITYDIRECTUV: number;
  13905. OPACITYRGB: boolean;
  13906. REFLECTION: boolean;
  13907. EMISSIVE: boolean;
  13908. EMISSIVEDIRECTUV: number;
  13909. SPECULAR: boolean;
  13910. SPECULARDIRECTUV: number;
  13911. BUMP: boolean;
  13912. BUMPDIRECTUV: number;
  13913. PARALLAX: boolean;
  13914. PARALLAXOCCLUSION: boolean;
  13915. SPECULAROVERALPHA: boolean;
  13916. CLIPPLANE: boolean;
  13917. ALPHATEST: boolean;
  13918. DEPTHPREPASS: boolean;
  13919. ALPHAFROMDIFFUSE: boolean;
  13920. POINTSIZE: boolean;
  13921. FOG: boolean;
  13922. SPECULARTERM: boolean;
  13923. DIFFUSEFRESNEL: boolean;
  13924. OPACITYFRESNEL: boolean;
  13925. REFLECTIONFRESNEL: boolean;
  13926. REFRACTIONFRESNEL: boolean;
  13927. EMISSIVEFRESNEL: boolean;
  13928. FRESNEL: boolean;
  13929. NORMAL: boolean;
  13930. UV1: boolean;
  13931. UV2: boolean;
  13932. VERTEXCOLOR: boolean;
  13933. VERTEXALPHA: boolean;
  13934. NUM_BONE_INFLUENCERS: number;
  13935. BonesPerMesh: number;
  13936. INSTANCES: boolean;
  13937. GLOSSINESS: boolean;
  13938. ROUGHNESS: boolean;
  13939. EMISSIVEASILLUMINATION: boolean;
  13940. LINKEMISSIVEWITHDIFFUSE: boolean;
  13941. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13942. LIGHTMAP: boolean;
  13943. LIGHTMAPDIRECTUV: number;
  13944. OBJECTSPACE_NORMALMAP: boolean;
  13945. USELIGHTMAPASSHADOWMAP: boolean;
  13946. REFLECTIONMAP_3D: boolean;
  13947. REFLECTIONMAP_SPHERICAL: boolean;
  13948. REFLECTIONMAP_PLANAR: boolean;
  13949. REFLECTIONMAP_CUBIC: boolean;
  13950. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13951. REFLECTIONMAP_PROJECTION: boolean;
  13952. REFLECTIONMAP_SKYBOX: boolean;
  13953. REFLECTIONMAP_EXPLICIT: boolean;
  13954. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13955. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13956. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13957. INVERTCUBICMAP: boolean;
  13958. LOGARITHMICDEPTH: boolean;
  13959. REFRACTION: boolean;
  13960. REFRACTIONMAP_3D: boolean;
  13961. REFLECTIONOVERALPHA: boolean;
  13962. TWOSIDEDLIGHTING: boolean;
  13963. SHADOWFLOAT: boolean;
  13964. MORPHTARGETS: boolean;
  13965. MORPHTARGETS_NORMAL: boolean;
  13966. MORPHTARGETS_TANGENT: boolean;
  13967. NUM_MORPH_INFLUENCERS: number;
  13968. NONUNIFORMSCALING: boolean;
  13969. PREMULTIPLYALPHA: boolean;
  13970. IMAGEPROCESSING: boolean;
  13971. VIGNETTE: boolean;
  13972. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13973. VIGNETTEBLENDMODEOPAQUE: boolean;
  13974. TONEMAPPING: boolean;
  13975. CONTRAST: boolean;
  13976. COLORCURVES: boolean;
  13977. COLORGRADING: boolean;
  13978. COLORGRADING3D: boolean;
  13979. SAMPLER3DGREENDEPTH: boolean;
  13980. SAMPLER3DBGRMAP: boolean;
  13981. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13982. /**
  13983. * If the reflection texture on this material is in linear color space
  13984. * @hidden
  13985. */
  13986. IS_REFLECTION_LINEAR: boolean;
  13987. /**
  13988. * If the refraction texture on this material is in linear color space
  13989. * @hidden
  13990. */
  13991. IS_REFRACTION_LINEAR: boolean;
  13992. EXPOSURE: boolean;
  13993. constructor();
  13994. setReflectionMode(modeToEnable: string): void;
  13995. }
  13996. class StandardMaterial extends PushMaterial {
  13997. private _diffuseTexture;
  13998. diffuseTexture: Nullable<BaseTexture>;
  13999. private _ambientTexture;
  14000. ambientTexture: Nullable<BaseTexture>;
  14001. private _opacityTexture;
  14002. opacityTexture: Nullable<BaseTexture>;
  14003. private _reflectionTexture;
  14004. reflectionTexture: Nullable<BaseTexture>;
  14005. private _emissiveTexture;
  14006. emissiveTexture: Nullable<BaseTexture>;
  14007. private _specularTexture;
  14008. specularTexture: Nullable<BaseTexture>;
  14009. private _bumpTexture;
  14010. bumpTexture: Nullable<BaseTexture>;
  14011. private _lightmapTexture;
  14012. lightmapTexture: Nullable<BaseTexture>;
  14013. private _refractionTexture;
  14014. refractionTexture: Nullable<BaseTexture>;
  14015. ambientColor: Color3;
  14016. diffuseColor: Color3;
  14017. specularColor: Color3;
  14018. emissiveColor: Color3;
  14019. specularPower: number;
  14020. private _useAlphaFromDiffuseTexture;
  14021. useAlphaFromDiffuseTexture: boolean;
  14022. private _useEmissiveAsIllumination;
  14023. useEmissiveAsIllumination: boolean;
  14024. private _linkEmissiveWithDiffuse;
  14025. linkEmissiveWithDiffuse: boolean;
  14026. private _useSpecularOverAlpha;
  14027. useSpecularOverAlpha: boolean;
  14028. private _useReflectionOverAlpha;
  14029. useReflectionOverAlpha: boolean;
  14030. private _disableLighting;
  14031. disableLighting: boolean;
  14032. private _useObjectSpaceNormalMap;
  14033. /**
  14034. * Allows using an object space normal map (instead of tangent space).
  14035. */
  14036. useObjectSpaceNormalMap: boolean;
  14037. private _useParallax;
  14038. useParallax: boolean;
  14039. private _useParallaxOcclusion;
  14040. useParallaxOcclusion: boolean;
  14041. parallaxScaleBias: number;
  14042. private _roughness;
  14043. roughness: number;
  14044. indexOfRefraction: number;
  14045. invertRefractionY: boolean;
  14046. /**
  14047. * Defines the alpha limits in alpha test mode
  14048. */
  14049. alphaCutOff: number;
  14050. private _useLightmapAsShadowmap;
  14051. useLightmapAsShadowmap: boolean;
  14052. private _diffuseFresnelParameters;
  14053. diffuseFresnelParameters: FresnelParameters;
  14054. private _opacityFresnelParameters;
  14055. opacityFresnelParameters: FresnelParameters;
  14056. private _reflectionFresnelParameters;
  14057. reflectionFresnelParameters: FresnelParameters;
  14058. private _refractionFresnelParameters;
  14059. refractionFresnelParameters: FresnelParameters;
  14060. private _emissiveFresnelParameters;
  14061. emissiveFresnelParameters: FresnelParameters;
  14062. private _useReflectionFresnelFromSpecular;
  14063. useReflectionFresnelFromSpecular: boolean;
  14064. private _useGlossinessFromSpecularMapAlpha;
  14065. useGlossinessFromSpecularMapAlpha: boolean;
  14066. private _maxSimultaneousLights;
  14067. maxSimultaneousLights: number;
  14068. /**
  14069. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14070. */
  14071. private _invertNormalMapX;
  14072. invertNormalMapX: boolean;
  14073. /**
  14074. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14075. */
  14076. private _invertNormalMapY;
  14077. invertNormalMapY: boolean;
  14078. /**
  14079. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14080. */
  14081. private _twoSidedLighting;
  14082. twoSidedLighting: boolean;
  14083. /**
  14084. * Default configuration related to image processing available in the standard Material.
  14085. */
  14086. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14087. /**
  14088. * Gets the image processing configuration used either in this material.
  14089. */
  14090. /**
  14091. * Sets the Default image processing configuration used either in the this material.
  14092. *
  14093. * If sets to null, the scene one is in use.
  14094. */
  14095. imageProcessingConfiguration: ImageProcessingConfiguration;
  14096. /**
  14097. * Keep track of the image processing observer to allow dispose and replace.
  14098. */
  14099. private _imageProcessingObserver;
  14100. /**
  14101. * Attaches a new image processing configuration to the Standard Material.
  14102. * @param configuration
  14103. */
  14104. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14105. /**
  14106. * Gets wether the color curves effect is enabled.
  14107. */
  14108. /**
  14109. * Sets wether the color curves effect is enabled.
  14110. */
  14111. cameraColorCurvesEnabled: boolean;
  14112. /**
  14113. * Gets wether the color grading effect is enabled.
  14114. */
  14115. /**
  14116. * Gets wether the color grading effect is enabled.
  14117. */
  14118. cameraColorGradingEnabled: boolean;
  14119. /**
  14120. * Gets wether tonemapping is enabled or not.
  14121. */
  14122. /**
  14123. * Sets wether tonemapping is enabled or not
  14124. */
  14125. cameraToneMappingEnabled: boolean;
  14126. /**
  14127. * The camera exposure used on this material.
  14128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14129. * This corresponds to a photographic exposure.
  14130. */
  14131. /**
  14132. * The camera exposure used on this material.
  14133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14134. * This corresponds to a photographic exposure.
  14135. */
  14136. cameraExposure: number;
  14137. /**
  14138. * Gets The camera contrast used on this material.
  14139. */
  14140. /**
  14141. * Sets The camera contrast used on this material.
  14142. */
  14143. cameraContrast: number;
  14144. /**
  14145. * Gets the Color Grading 2D Lookup Texture.
  14146. */
  14147. /**
  14148. * Sets the Color Grading 2D Lookup Texture.
  14149. */
  14150. cameraColorGradingTexture: Nullable<BaseTexture>;
  14151. /**
  14152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14154. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  14155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14156. */
  14157. /**
  14158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14160. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  14161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14162. */
  14163. cameraColorCurves: Nullable<ColorCurves>;
  14164. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14165. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14166. protected _worldViewProjectionMatrix: Matrix;
  14167. protected _globalAmbientColor: Color3;
  14168. protected _useLogarithmicDepth: boolean;
  14169. constructor(name: string, scene: Scene);
  14170. getClassName(): string;
  14171. useLogarithmicDepth: boolean;
  14172. needAlphaBlending(): boolean;
  14173. needAlphaTesting(): boolean;
  14174. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14175. getAlphaTestTexture(): Nullable<BaseTexture>;
  14176. /**
  14177. * Child classes can use it to update shaders
  14178. */
  14179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14180. buildUniformLayout(): void;
  14181. unbind(): void;
  14182. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14183. getAnimatables(): IAnimatable[];
  14184. getActiveTextures(): BaseTexture[];
  14185. hasTexture(texture: BaseTexture): boolean;
  14186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14187. clone(name: string): StandardMaterial;
  14188. serialize(): any;
  14189. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14190. static _DiffuseTextureEnabled: boolean;
  14191. static DiffuseTextureEnabled: boolean;
  14192. static _AmbientTextureEnabled: boolean;
  14193. static AmbientTextureEnabled: boolean;
  14194. static _OpacityTextureEnabled: boolean;
  14195. static OpacityTextureEnabled: boolean;
  14196. static _ReflectionTextureEnabled: boolean;
  14197. static ReflectionTextureEnabled: boolean;
  14198. static _EmissiveTextureEnabled: boolean;
  14199. static EmissiveTextureEnabled: boolean;
  14200. static _SpecularTextureEnabled: boolean;
  14201. static SpecularTextureEnabled: boolean;
  14202. static _BumpTextureEnabled: boolean;
  14203. static BumpTextureEnabled: boolean;
  14204. static _LightmapTextureEnabled: boolean;
  14205. static LightmapTextureEnabled: boolean;
  14206. static _RefractionTextureEnabled: boolean;
  14207. static RefractionTextureEnabled: boolean;
  14208. static _ColorGradingTextureEnabled: boolean;
  14209. static ColorGradingTextureEnabled: boolean;
  14210. static _FresnelEnabled: boolean;
  14211. static FresnelEnabled: boolean;
  14212. }
  14213. }
  14214. declare module BABYLON {
  14215. class UniformBuffer {
  14216. private _engine;
  14217. private _buffer;
  14218. private _data;
  14219. private _bufferData;
  14220. private _dynamic?;
  14221. private _uniformLocations;
  14222. private _uniformSizes;
  14223. private _uniformLocationPointer;
  14224. private _needSync;
  14225. private _noUBO;
  14226. private _currentEffect;
  14227. private static _MAX_UNIFORM_SIZE;
  14228. private static _tempBuffer;
  14229. /**
  14230. * Wrapper for updateUniform.
  14231. * @method updateMatrix3x3
  14232. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14233. * @param {Float32Array} matrix
  14234. */
  14235. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14236. /**
  14237. * Wrapper for updateUniform.
  14238. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14239. * @param {Float32Array} matrix
  14240. */
  14241. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14242. /**
  14243. * Wrapper for updateUniform.
  14244. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14245. * @param {number} x
  14246. */
  14247. updateFloat: (name: string, x: number) => void;
  14248. /**
  14249. * Wrapper for updateUniform.
  14250. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14251. * @param {number} x
  14252. * @param {number} y
  14253. * @param {string} [suffix] Suffix to add to the uniform name.
  14254. */
  14255. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14256. /**
  14257. * Wrapper for updateUniform.
  14258. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14259. * @param {number} x
  14260. * @param {number} y
  14261. * @param {number} z
  14262. * @param {string} [suffix] Suffix to add to the uniform name.
  14263. */
  14264. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14265. /**
  14266. * Wrapper for updateUniform.
  14267. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14268. * @param {number} x
  14269. * @param {number} y
  14270. * @param {number} z
  14271. * @param {number} w
  14272. * @param {string} [suffix] Suffix to add to the uniform name.
  14273. */
  14274. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14275. /**
  14276. * Wrapper for updateUniform.
  14277. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14278. * @param {Matrix} A 4x4 matrix.
  14279. */
  14280. updateMatrix: (name: string, mat: Matrix) => void;
  14281. /**
  14282. * Wrapper for updateUniform.
  14283. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14284. * @param {Vector3} vector
  14285. */
  14286. updateVector3: (name: string, vector: Vector3) => void;
  14287. /**
  14288. * Wrapper for updateUniform.
  14289. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14290. * @param {Vector4} vector
  14291. */
  14292. updateVector4: (name: string, vector: Vector4) => void;
  14293. /**
  14294. * Wrapper for updateUniform.
  14295. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14296. * @param {Color3} color
  14297. * @param {string} [suffix] Suffix to add to the uniform name.
  14298. */
  14299. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14300. /**
  14301. * Wrapper for updateUniform.
  14302. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14303. * @param {Color3} color
  14304. * @param {number} alpha
  14305. * @param {string} [suffix] Suffix to add to the uniform name.
  14306. */
  14307. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14308. /**
  14309. * Uniform buffer objects.
  14310. *
  14311. * Handles blocks of uniform on the GPU.
  14312. *
  14313. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14314. *
  14315. * For more information, please refer to :
  14316. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14317. */
  14318. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14319. /**
  14320. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14321. * or just falling back on setUniformXXX calls.
  14322. */
  14323. readonly useUbo: boolean;
  14324. /**
  14325. * Indicates if the WebGL underlying uniform buffer is in sync
  14326. * with the javascript cache data.
  14327. */
  14328. readonly isSync: boolean;
  14329. /**
  14330. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14331. * Also, a dynamic UniformBuffer will disable cache verification and always
  14332. * update the underlying WebGL uniform buffer to the GPU.
  14333. */
  14334. isDynamic(): boolean;
  14335. /**
  14336. * The data cache on JS side.
  14337. */
  14338. getData(): Float32Array;
  14339. /**
  14340. * The underlying WebGL Uniform buffer.
  14341. */
  14342. getBuffer(): Nullable<WebGLBuffer>;
  14343. /**
  14344. * std140 layout specifies how to align data within an UBO structure.
  14345. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14346. * for specs.
  14347. */
  14348. private _fillAlignment(size);
  14349. /**
  14350. * Adds an uniform in the buffer.
  14351. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14352. * for the layout to be correct !
  14353. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14354. * @param {number|number[]} size Data size, or data directly.
  14355. */
  14356. addUniform(name: string, size: number | number[]): void;
  14357. /**
  14358. * Wrapper for addUniform.
  14359. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14360. * @param {Matrix} mat A 4x4 matrix.
  14361. */
  14362. addMatrix(name: string, mat: Matrix): void;
  14363. /**
  14364. * Wrapper for addUniform.
  14365. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14366. * @param {number} x
  14367. * @param {number} y
  14368. */
  14369. addFloat2(name: string, x: number, y: number): void;
  14370. /**
  14371. * Wrapper for addUniform.
  14372. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14373. * @param {number} x
  14374. * @param {number} y
  14375. * @param {number} z
  14376. */
  14377. addFloat3(name: string, x: number, y: number, z: number): void;
  14378. /**
  14379. * Wrapper for addUniform.
  14380. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14381. * @param {Color3} color
  14382. */
  14383. addColor3(name: string, color: Color3): void;
  14384. /**
  14385. * Wrapper for addUniform.
  14386. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14387. * @param {Color3} color
  14388. * @param {number} alpha
  14389. */
  14390. addColor4(name: string, color: Color3, alpha: number): void;
  14391. /**
  14392. * Wrapper for addUniform.
  14393. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14394. * @param {Vector3} vector
  14395. */
  14396. addVector3(name: string, vector: Vector3): void;
  14397. /**
  14398. * Wrapper for addUniform.
  14399. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14400. */
  14401. addMatrix3x3(name: string): void;
  14402. /**
  14403. * Wrapper for addUniform.
  14404. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14405. */
  14406. addMatrix2x2(name: string): void;
  14407. /**
  14408. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14409. */
  14410. create(): void;
  14411. _rebuild(): void;
  14412. /**
  14413. * Updates the WebGL Uniform Buffer on the GPU.
  14414. * If the `dynamic` flag is set to true, no cache comparison is done.
  14415. * Otherwise, the buffer will be updated only if the cache differs.
  14416. */
  14417. update(): void;
  14418. /**
  14419. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14420. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14421. * @param {number[]|Float32Array} data Flattened data
  14422. * @param {number} size Size of the data.
  14423. */
  14424. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14425. private _updateMatrix3x3ForUniform(name, matrix);
  14426. private _updateMatrix3x3ForEffect(name, matrix);
  14427. private _updateMatrix2x2ForEffect(name, matrix);
  14428. private _updateMatrix2x2ForUniform(name, matrix);
  14429. private _updateFloatForEffect(name, x);
  14430. private _updateFloatForUniform(name, x);
  14431. private _updateFloat2ForEffect(name, x, y, suffix?);
  14432. private _updateFloat2ForUniform(name, x, y, suffix?);
  14433. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14434. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14435. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14436. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14437. private _updateMatrixForEffect(name, mat);
  14438. private _updateMatrixForUniform(name, mat);
  14439. private _updateVector3ForEffect(name, vector);
  14440. private _updateVector3ForUniform(name, vector);
  14441. private _updateVector4ForEffect(name, vector);
  14442. private _updateVector4ForUniform(name, vector);
  14443. private _updateColor3ForEffect(name, color, suffix?);
  14444. private _updateColor3ForUniform(name, color, suffix?);
  14445. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14446. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14447. /**
  14448. * Sets a sampler uniform on the effect.
  14449. * @param {string} name Name of the sampler.
  14450. * @param {Texture} texture
  14451. */
  14452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14453. /**
  14454. * Directly updates the value of the uniform in the cache AND on the GPU.
  14455. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14456. * @param {number[]|Float32Array} data Flattened data
  14457. */
  14458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14459. /**
  14460. * Binds this uniform buffer to an effect.
  14461. * @param {Effect} effect
  14462. * @param {string} name Name of the uniform block in the shader.
  14463. */
  14464. bindToEffect(effect: Effect, name: string): void;
  14465. /**
  14466. * Disposes the uniform buffer.
  14467. */
  14468. dispose(): void;
  14469. }
  14470. }
  14471. declare module BABYLON {
  14472. class Scalar {
  14473. /**
  14474. * Two pi constants convenient for computation.
  14475. */
  14476. static TwoPi: number;
  14477. /**
  14478. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14479. */
  14480. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14481. /**
  14482. * Returns a string : the upper case translation of the number i to hexadecimal.
  14483. */
  14484. static ToHex(i: number): string;
  14485. /**
  14486. * Returns -1 if value is negative and +1 is value is positive.
  14487. * Returns the value itself if it's equal to zero.
  14488. */
  14489. static Sign(value: number): number;
  14490. /**
  14491. * Returns the value itself if it's between min and max.
  14492. * Returns min if the value is lower than min.
  14493. * Returns max if the value is greater than max.
  14494. */
  14495. static Clamp(value: number, min?: number, max?: number): number;
  14496. /**
  14497. * Returns the log2 of value.
  14498. */
  14499. static Log2(value: number): number;
  14500. /**
  14501. * Loops the value, so that it is never larger than length and never smaller than 0.
  14502. *
  14503. * This is similar to the modulo operator but it works with floating point numbers.
  14504. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14505. * With t = 5 and length = 2.5, the result would be 0.0.
  14506. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14507. */
  14508. static Repeat(value: number, length: number): number;
  14509. /**
  14510. * Normalize the value between 0.0 and 1.0 using min and max values
  14511. */
  14512. static Normalize(value: number, min: number, max: number): number;
  14513. /**
  14514. * Denormalize the value from 0.0 and 1.0 using min and max values
  14515. */
  14516. static Denormalize(normalized: number, min: number, max: number): number;
  14517. /**
  14518. * Calculates the shortest difference between two given angles given in degrees.
  14519. */
  14520. static DeltaAngle(current: number, target: number): number;
  14521. /**
  14522. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14523. *
  14524. * The returned value will move back and forth between 0 and length
  14525. */
  14526. static PingPong(tx: number, length: number): number;
  14527. /**
  14528. * Interpolates between min and max with smoothing at the limits.
  14529. *
  14530. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14531. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14532. */
  14533. static SmoothStep(from: number, to: number, tx: number): number;
  14534. /**
  14535. * Moves a value current towards target.
  14536. *
  14537. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14538. * Negative values of maxDelta pushes the value away from target.
  14539. */
  14540. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14541. /**
  14542. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14543. *
  14544. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14545. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14546. */
  14547. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14548. /**
  14549. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14550. */
  14551. static Lerp(start: number, end: number, amount: number): number;
  14552. /**
  14553. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14554. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14555. */
  14556. static LerpAngle(start: number, end: number, amount: number): number;
  14557. /**
  14558. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14559. */
  14560. static InverseLerp(a: number, b: number, value: number): number;
  14561. /**
  14562. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14563. */
  14564. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14565. /**
  14566. * Returns a random float number between and min and max values
  14567. */
  14568. static RandomRange(min: number, max: number): number;
  14569. /**
  14570. * This function returns percentage of a number in a given range.
  14571. *
  14572. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14573. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14574. */
  14575. static RangeToPercent(number: number, min: number, max: number): number;
  14576. /**
  14577. * This function returns number that corresponds to the percentage in a given range.
  14578. *
  14579. * PercentToRange(0.34,0,100) will return 34.
  14580. */
  14581. static PercentToRange(percent: number, min: number, max: number): number;
  14582. /**
  14583. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14584. * @param angle The angle to normalize in radian.
  14585. * @return The converted angle.
  14586. */
  14587. static NormalizeRadians(angle: number): number;
  14588. }
  14589. }
  14590. declare module BABYLON {
  14591. const ToGammaSpace: number;
  14592. const ToLinearSpace = 2.2;
  14593. const Epsilon = 0.001;
  14594. /**
  14595. * Class used to hold a RBG color
  14596. */
  14597. class Color3 {
  14598. /**
  14599. * Defines the red component (between 0 and 1, default is 0)
  14600. */
  14601. r: number;
  14602. /**
  14603. * Defines the green component (between 0 and 1, default is 0)
  14604. */
  14605. g: number;
  14606. /**
  14607. * Defines the blue component (between 0 and 1, default is 0)
  14608. */
  14609. b: number;
  14610. /**
  14611. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14612. * @param r defines the red component (between 0 and 1, default is 0)
  14613. * @param g defines the green component (between 0 and 1, default is 0)
  14614. * @param b defines the blue component (between 0 and 1, default is 0)
  14615. */
  14616. constructor(
  14617. /**
  14618. * Defines the red component (between 0 and 1, default is 0)
  14619. */
  14620. r?: number,
  14621. /**
  14622. * Defines the green component (between 0 and 1, default is 0)
  14623. */
  14624. g?: number,
  14625. /**
  14626. * Defines the blue component (between 0 and 1, default is 0)
  14627. */
  14628. b?: number);
  14629. /**
  14630. * Creates a string with the Color3 current values
  14631. * @returns the string representation of the Color3 object
  14632. */
  14633. toString(): string;
  14634. /**
  14635. * Returns the string "Color3"
  14636. * @returns "Color3"
  14637. */
  14638. getClassName(): string;
  14639. /**
  14640. * Compute the Color3 hash code
  14641. * @returns an unique number that can be used to hash Color3 objects
  14642. */
  14643. getHashCode(): number;
  14644. /**
  14645. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14646. * @param array defines the array where to store the r,g,b components
  14647. * @param index defines an optional index in the target array to define where to start storing values
  14648. * @returns the current Color3 object
  14649. */
  14650. toArray(array: FloatArray, index?: number): Color3;
  14651. /**
  14652. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14653. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14654. * @returns a new {BABYLON.Color4} object
  14655. */
  14656. toColor4(alpha?: number): Color4;
  14657. /**
  14658. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14659. * @returns the new array
  14660. */
  14661. asArray(): number[];
  14662. /**
  14663. * Returns the luminance value
  14664. * @returns a float value
  14665. */
  14666. toLuminance(): number;
  14667. /**
  14668. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14669. * @param otherColor defines the second operand
  14670. * @returns the new Color3 object
  14671. */
  14672. multiply(otherColor: Color3): Color3;
  14673. /**
  14674. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14675. * @param otherColor defines the second operand
  14676. * @param result defines the Color3 object where to store the result
  14677. * @returns the current Color3
  14678. */
  14679. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14680. /**
  14681. * Determines equality between Color3 objects
  14682. * @param otherColor defines the second operand
  14683. * @returns true if the rgb values are equal to the given ones
  14684. */
  14685. equals(otherColor: Color3): boolean;
  14686. /**
  14687. * Determines equality between the current Color3 object and a set of r,b,g values
  14688. * @param r defines the red component to check
  14689. * @param g defines the green component to check
  14690. * @param b defines the blue component to check
  14691. * @returns true if the rgb values are equal to the given ones
  14692. */
  14693. equalsFloats(r: number, g: number, b: number): boolean;
  14694. /**
  14695. * Multiplies in place each rgb value by scale
  14696. * @param scale defines the scaling factor
  14697. * @returns the updated Color3
  14698. */
  14699. scale(scale: number): Color3;
  14700. /**
  14701. * Multiplies the rgb values by scale and stores the result into "result"
  14702. * @param scale defines the scaling factor
  14703. * @param result defines the Color3 object where to store the result
  14704. * @returns the unmodified current Color3
  14705. */
  14706. scaleToRef(scale: number, result: Color3): Color3;
  14707. /**
  14708. * Scale the current Color3 values by a factor and add the result to a given Color3
  14709. * @param scale defines the scale factor
  14710. * @param result defines color to store the result into
  14711. * @returns the unmodified current Color3
  14712. */
  14713. scaleAndAddToRef(scale: number, result: Color3): Color3;
  14714. /**
  14715. * Clamps the rgb values by the min and max values and stores the result into "result"
  14716. * @param min defines minimum clamping value (default is 0)
  14717. * @param max defines maximum clamping value (default is 1)
  14718. * @param result defines color to store the result into
  14719. * @returns the original Color3
  14720. */
  14721. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14722. /**
  14723. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  14724. * @param otherColor defines the second operand
  14725. * @returns the new Color3
  14726. */
  14727. add(otherColor: Color3): Color3;
  14728. /**
  14729. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  14730. * @param otherColor defines the second operand
  14731. * @param result defines Color3 object to store the result into
  14732. * @returns the unmodified current Color3
  14733. */
  14734. addToRef(otherColor: Color3, result: Color3): Color3;
  14735. /**
  14736. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  14737. * @param otherColor defines the second operand
  14738. * @returns the new Color3
  14739. */
  14740. subtract(otherColor: Color3): Color3;
  14741. /**
  14742. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  14743. * @param otherColor defines the second operand
  14744. * @param result defines Color3 object to store the result into
  14745. * @returns the unmodified current Color3
  14746. */
  14747. subtractToRef(otherColor: Color3, result: Color3): Color3;
  14748. /**
  14749. * Copy the current object
  14750. * @returns a new Color3 copied the current one
  14751. */
  14752. clone(): Color3;
  14753. /**
  14754. * Copies the rgb values from the source in the current Color3
  14755. * @param source defines the source Color3 object
  14756. * @returns the updated Color3 object
  14757. */
  14758. copyFrom(source: Color3): Color3;
  14759. /**
  14760. * Updates the Color3 rgb values from the given floats
  14761. * @param r defines the red component to read from
  14762. * @param g defines the green component to read from
  14763. * @param b defines the blue component to read from
  14764. * @returns the current Color3 object
  14765. */
  14766. copyFromFloats(r: number, g: number, b: number): Color3;
  14767. /**
  14768. * Updates the Color3 rgb values from the given floats
  14769. * @param r defines the red component to read from
  14770. * @param g defines the green component to read from
  14771. * @param b defines the blue component to read from
  14772. * @returns the current Color3 object
  14773. */
  14774. set(r: number, g: number, b: number): Color3;
  14775. /**
  14776. * Compute the Color3 hexadecimal code as a string
  14777. * @returns a string containing the hexadecimal representation of the Color3 object
  14778. */
  14779. toHexString(): string;
  14780. /**
  14781. * Computes a new Color3 converted from the current one to linear space
  14782. * @returns a new Color3 object
  14783. */
  14784. toLinearSpace(): Color3;
  14785. /**
  14786. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  14787. * @param convertedColor defines the Color3 object where to store the linear space version
  14788. * @returns the unmodified Color3
  14789. */
  14790. toLinearSpaceToRef(convertedColor: Color3): Color3;
  14791. /**
  14792. * Computes a new Color3 converted from the current one to gamma space
  14793. * @returns a new Color3 object
  14794. */
  14795. toGammaSpace(): Color3;
  14796. /**
  14797. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  14798. * @param convertedColor defines the Color3 object where to store the gamma space version
  14799. * @returns the unmodified Color3
  14800. */
  14801. toGammaSpaceToRef(convertedColor: Color3): Color3;
  14802. /**
  14803. * Creates a new Color3 from the string containing valid hexadecimal values
  14804. * @param hex defines a string containing valid hexadecimal values
  14805. * @returns a new Color3 object
  14806. */
  14807. static FromHexString(hex: string): Color3;
  14808. /**
  14809. * Creates a new Vector3 from the starting index of the given array
  14810. * @param array defines the source array
  14811. * @param offset defines an offset in the source array
  14812. * @returns a new Color3 object
  14813. */
  14814. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  14815. /**
  14816. * Creates a new Color3 from integer values (< 256)
  14817. * @param r defines the red component to read from (value between 0 and 255)
  14818. * @param g defines the green component to read from (value between 0 and 255)
  14819. * @param b defines the blue component to read from (value between 0 and 255)
  14820. * @returns a new Color3 object
  14821. */
  14822. static FromInts(r: number, g: number, b: number): Color3;
  14823. /**
  14824. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  14825. * @param start defines the start Color3 value
  14826. * @param end defines the end Color3 value
  14827. * @param amount defines the gradient value between start and end
  14828. * @returns a new Color3 object
  14829. */
  14830. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  14831. /**
  14832. * Returns a Color3 value containing a red color
  14833. * @returns a new Color3 object
  14834. */
  14835. static Red(): Color3;
  14836. /**
  14837. * Returns a Color3 value containing a green color
  14838. * @returns a new Color3 object
  14839. */
  14840. static Green(): Color3;
  14841. /**
  14842. * Returns a Color3 value containing a blue color
  14843. * @returns a new Color3 object
  14844. */
  14845. static Blue(): Color3;
  14846. /**
  14847. * Returns a Color3 value containing a black color
  14848. * @returns a new Color3 object
  14849. */
  14850. static Black(): Color3;
  14851. /**
  14852. * Returns a Color3 value containing a white color
  14853. * @returns a new Color3 object
  14854. */
  14855. static White(): Color3;
  14856. /**
  14857. * Returns a Color3 value containing a purple color
  14858. * @returns a new Color3 object
  14859. */
  14860. static Purple(): Color3;
  14861. /**
  14862. * Returns a Color3 value containing a magenta color
  14863. * @returns a new Color3 object
  14864. */
  14865. static Magenta(): Color3;
  14866. /**
  14867. * Returns a Color3 value containing a yellow color
  14868. * @returns a new Color3 object
  14869. */
  14870. static Yellow(): Color3;
  14871. /**
  14872. * Returns a Color3 value containing a gray color
  14873. * @returns a new Color3 object
  14874. */
  14875. static Gray(): Color3;
  14876. /**
  14877. * Returns a Color3 value containing a teal color
  14878. * @returns a new Color3 object
  14879. */
  14880. static Teal(): Color3;
  14881. /**
  14882. * Returns a Color3 value containing a random color
  14883. * @returns a new Color3 object
  14884. */
  14885. static Random(): Color3;
  14886. }
  14887. /**
  14888. * Class used to hold a RBGA color
  14889. */
  14890. class Color4 {
  14891. /**
  14892. * Defines the red component (between 0 and 1, default is 0)
  14893. */
  14894. r: number;
  14895. /**
  14896. * Defines the green component (between 0 and 1, default is 0)
  14897. */
  14898. g: number;
  14899. /**
  14900. * Defines the blue component (between 0 and 1, default is 0)
  14901. */
  14902. b: number;
  14903. /**
  14904. * Defines the alpha component (between 0 and 1, default is 1)
  14905. */
  14906. a: number;
  14907. /**
  14908. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  14909. * @param r defines the red component (between 0 and 1, default is 0)
  14910. * @param g defines the green component (between 0 and 1, default is 0)
  14911. * @param b defines the blue component (between 0 and 1, default is 0)
  14912. * @param a defines the alpha component (between 0 and 1, default is 1)
  14913. */
  14914. constructor(
  14915. /**
  14916. * Defines the red component (between 0 and 1, default is 0)
  14917. */
  14918. r?: number,
  14919. /**
  14920. * Defines the green component (between 0 and 1, default is 0)
  14921. */
  14922. g?: number,
  14923. /**
  14924. * Defines the blue component (between 0 and 1, default is 0)
  14925. */
  14926. b?: number,
  14927. /**
  14928. * Defines the alpha component (between 0 and 1, default is 1)
  14929. */
  14930. a?: number);
  14931. /**
  14932. * Adds in place the given Color4 values to the current Color4 object
  14933. * @param right defines the second operand
  14934. * @returns the current updated Color4 object
  14935. */
  14936. addInPlace(right: Color4): Color4;
  14937. /**
  14938. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  14939. * @returns the new array
  14940. */
  14941. asArray(): number[];
  14942. /**
  14943. * Stores from the starting index in the given array the Color4 successive values
  14944. * @param array defines the array where to store the r,g,b components
  14945. * @param index defines an optional index in the target array to define where to start storing values
  14946. * @returns the current Color4 object
  14947. */
  14948. toArray(array: number[], index?: number): Color4;
  14949. /**
  14950. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  14951. * @param right defines the second operand
  14952. * @returns a new Color4 object
  14953. */
  14954. add(right: Color4): Color4;
  14955. /**
  14956. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  14957. * @param right defines the second operand
  14958. * @returns a new Color4 object
  14959. */
  14960. subtract(right: Color4): Color4;
  14961. /**
  14962. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  14963. * @param right defines the second operand
  14964. * @param result defines the Color4 object where to store the result
  14965. * @returns the current Color4 object
  14966. */
  14967. subtractToRef(right: Color4, result: Color4): Color4;
  14968. /**
  14969. * Creates a new Color4 with the current Color4 values multiplied by scale
  14970. * @param scale defines the scaling factor to apply
  14971. * @returns a new Color4 object
  14972. */
  14973. scale(scale: number): Color4;
  14974. /**
  14975. * Multiplies the current Color4 values by scale and stores the result in "result"
  14976. * @param scale defines the scaling factor to apply
  14977. * @param result defines the Color4 object where to store the result
  14978. * @returns the current unmodified Color4
  14979. */
  14980. scaleToRef(scale: number, result: Color4): Color4;
  14981. /**
  14982. * Scale the current Color4 values by a factor and add the result to a given Color4
  14983. * @param scale defines the scale factor
  14984. * @param result defines the Color4 object where to store the result
  14985. * @returns the unmodified current Color4
  14986. */
  14987. scaleAndAddToRef(scale: number, result: Color4): Color4;
  14988. /**
  14989. * Clamps the rgb values by the min and max values and stores the result into "result"
  14990. * @param min defines minimum clamping value (default is 0)
  14991. * @param max defines maximum clamping value (default is 1)
  14992. * @param result defines color to store the result into.
  14993. * @returns the cuurent Color4
  14994. */
  14995. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  14996. /**
  14997. * Multipy an Color4 value by another and return a new Color4 object
  14998. * @param color defines the Color4 value to multiply by
  14999. * @returns a new Color4 object
  15000. */
  15001. multiply(color: Color4): Color4;
  15002. /**
  15003. * Multipy a Color4 value by another and push the result in a reference value
  15004. * @param color defines the Color4 value to multiply by
  15005. * @param result defines the Color4 to fill the result in
  15006. * @returns the result Color4
  15007. */
  15008. multiplyToRef(color: Color4, result: Color4): Color4;
  15009. /**
  15010. * Creates a string with the Color4 current values
  15011. * @returns the string representation of the Color4 object
  15012. */
  15013. toString(): string;
  15014. /**
  15015. * Returns the string "Color4"
  15016. * @returns "Color4"
  15017. */
  15018. getClassName(): string;
  15019. /**
  15020. * Compute the Color4 hash code
  15021. * @returns an unique number that can be used to hash Color4 objects
  15022. */
  15023. getHashCode(): number;
  15024. /**
  15025. * Creates a new Color4 copied from the current one
  15026. * @returns a new Color4 object
  15027. */
  15028. clone(): Color4;
  15029. /**
  15030. * Copies the given Color4 values into the current one
  15031. * @param source defines the source Color4 object
  15032. * @returns the current updated Color4 object
  15033. */
  15034. copyFrom(source: Color4): Color4;
  15035. /**
  15036. * Copies the given float values into the current one
  15037. * @param r defines the red component to read from
  15038. * @param g defines the green component to read from
  15039. * @param b defines the blue component to read from
  15040. * @param a defines the alpha component to read from
  15041. * @returns the current updated Color4 object
  15042. */
  15043. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15044. /**
  15045. * Copies the given float values into the current one
  15046. * @param r defines the red component to read from
  15047. * @param g defines the green component to read from
  15048. * @param b defines the blue component to read from
  15049. * @param a defines the alpha component to read from
  15050. * @returns the current updated Color4 object
  15051. */
  15052. set(r: number, g: number, b: number, a: number): Color4;
  15053. /**
  15054. * Compute the Color4 hexadecimal code as a string
  15055. * @returns a string containing the hexadecimal representation of the Color4 object
  15056. */
  15057. toHexString(): string;
  15058. /**
  15059. * Computes a new Color4 converted from the current one to linear space
  15060. * @returns a new Color4 object
  15061. */
  15062. toLinearSpace(): Color4;
  15063. /**
  15064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15065. * @param convertedColor defines the Color4 object where to store the linear space version
  15066. * @returns the unmodified Color4
  15067. */
  15068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15069. /**
  15070. * Computes a new Color4 converted from the current one to gamma space
  15071. * @returns a new Color4 object
  15072. */
  15073. toGammaSpace(): Color4;
  15074. /**
  15075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15076. * @param convertedColor defines the Color4 object where to store the gamma space version
  15077. * @returns the unmodified Color4
  15078. */
  15079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15080. /**
  15081. * Creates a new Color4 from the string containing valid hexadecimal values
  15082. * @param hex defines a string containing valid hexadecimal values
  15083. * @returns a new Color4 object
  15084. */
  15085. static FromHexString(hex: string): Color4;
  15086. /**
  15087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15088. * @param left defines the start value
  15089. * @param right defines the end value
  15090. * @param amount defines the gradient factor
  15091. * @returns a new Color4 object
  15092. */
  15093. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15094. /**
  15095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15096. * @param left defines the start value
  15097. * @param right defines the end value
  15098. * @param amount defines the gradient factor
  15099. * @param result defines the Color4 object where to store data
  15100. */
  15101. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15102. /**
  15103. * Creates a new Color4 from the starting index element of the given array
  15104. * @param array defines the source array to read from
  15105. * @param offset defines the offset in the source array
  15106. * @returns a new Color4 object
  15107. */
  15108. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15109. /**
  15110. * Creates a new Color3 from integer values (< 256)
  15111. * @param r defines the red component to read from (value between 0 and 255)
  15112. * @param g defines the green component to read from (value between 0 and 255)
  15113. * @param b defines the blue component to read from (value between 0 and 255)
  15114. * @param a defines the alpha 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, a: number): Color4;
  15118. /**
  15119. * Check the content of a given array and convert it to an array containing RGBA data
  15120. * If the original array was already containing count * 4 values then it is returned directly
  15121. * @param colors defines the array to check
  15122. * @param count defines the number of RGBA data to expect
  15123. * @returns an array containing count * 4 values (RGBA)
  15124. */
  15125. static CheckColors4(colors: number[], count: number): number[];
  15126. }
  15127. /**
  15128. * Class representing a vector containing 2 coordinates
  15129. */
  15130. class Vector2 {
  15131. /** defines the first coordinate */
  15132. x: number;
  15133. /** defines the second coordinate */
  15134. y: number;
  15135. /**
  15136. * Creates a new Vector2 from the given x and y coordinates
  15137. * @param x defines the first coordinate
  15138. * @param y defines the second coordinate
  15139. */
  15140. constructor(
  15141. /** defines the first coordinate */
  15142. x: number,
  15143. /** defines the second coordinate */
  15144. y: number);
  15145. /**
  15146. * Gets a string with the Vector2 coordinates
  15147. * @returns a string with the Vector2 coordinates
  15148. */
  15149. toString(): string;
  15150. /**
  15151. * Gets class name
  15152. * @returns the string "Vector2"
  15153. */
  15154. getClassName(): string;
  15155. /**
  15156. * Gets current vector hash code
  15157. * @returns the Vector2 hash code as a number
  15158. */
  15159. getHashCode(): number;
  15160. /**
  15161. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15162. * @param array defines the source array
  15163. * @param index defines the offset in source array
  15164. * @returns the current Vector2
  15165. */
  15166. toArray(array: FloatArray, index?: number): Vector2;
  15167. /**
  15168. * Copy the current vector to an array
  15169. * @returns a new array with 2 elements: the Vector2 coordinates.
  15170. */
  15171. asArray(): number[];
  15172. /**
  15173. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15174. * @param source defines the source Vector2
  15175. * @returns the current updated Vector2
  15176. */
  15177. copyFrom(source: Vector2): Vector2;
  15178. /**
  15179. * Sets the Vector2 coordinates with the given floats
  15180. * @param x defines the first coordinate
  15181. * @param y defines the second coordinate
  15182. * @returns the current updated Vector2
  15183. */
  15184. copyFromFloats(x: number, y: number): Vector2;
  15185. /**
  15186. * Sets the Vector2 coordinates with the given floats
  15187. * @param x defines the first coordinate
  15188. * @param y defines the second coordinate
  15189. * @returns the current updated Vector2
  15190. */
  15191. set(x: number, y: number): Vector2;
  15192. /**
  15193. * Add another vector with the current one
  15194. * @param otherVector defines the other vector
  15195. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15196. */
  15197. add(otherVector: Vector2): Vector2;
  15198. /**
  15199. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15200. * @param otherVector defines the other vector
  15201. * @param result defines the target vector
  15202. * @returns the unmodified current Vector2
  15203. */
  15204. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15205. /**
  15206. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15207. * @param otherVector defines the other vector
  15208. * @returns the current updated Vector2
  15209. */
  15210. addInPlace(otherVector: Vector2): Vector2;
  15211. /**
  15212. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15213. * @param otherVector defines the other vector
  15214. * @returns a new Vector2
  15215. */
  15216. addVector3(otherVector: Vector3): Vector2;
  15217. /**
  15218. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15219. * @param otherVector defines the other vector
  15220. * @returns a new Vector2
  15221. */
  15222. subtract(otherVector: Vector2): Vector2;
  15223. /**
  15224. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15225. * @param otherVector defines the other vector
  15226. * @param result defines the target vector
  15227. * @returns the unmodified current Vector2
  15228. */
  15229. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15230. /**
  15231. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15232. * @param otherVector defines the other vector
  15233. * @returns the current updated Vector2
  15234. */
  15235. subtractInPlace(otherVector: Vector2): Vector2;
  15236. /**
  15237. * Multiplies in place the current Vector2 coordinates by the given ones
  15238. * @param otherVector defines the other vector
  15239. * @returns the current updated Vector2
  15240. */
  15241. multiplyInPlace(otherVector: Vector2): Vector2;
  15242. /**
  15243. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15244. * @param otherVector defines the other vector
  15245. * @returns a new Vector2
  15246. */
  15247. multiply(otherVector: Vector2): Vector2;
  15248. /**
  15249. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15250. * @param otherVector defines the other vector
  15251. * @param result defines the target vector
  15252. * @returns the unmodified current Vector2
  15253. */
  15254. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15255. /**
  15256. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15257. * @param x defines the first coordinate
  15258. * @param y defines the second coordinate
  15259. * @returns a new Vector2
  15260. */
  15261. multiplyByFloats(x: number, y: number): Vector2;
  15262. /**
  15263. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15264. * @param otherVector defines the other vector
  15265. * @returns a new Vector2
  15266. */
  15267. divide(otherVector: Vector2): Vector2;
  15268. /**
  15269. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15270. * @param otherVector defines the other vector
  15271. * @param result defines the target vector
  15272. * @returns the unmodified current Vector2
  15273. */
  15274. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15275. /**
  15276. * Divides the current Vector3 coordinates by the given ones
  15277. * @param otherVector defines the other vector
  15278. * @returns the current updated Vector2
  15279. */
  15280. divideInPlace(otherVector: Vector2): Vector2;
  15281. /**
  15282. * Gets a new Vector2 with current Vector2 negated coordinates
  15283. * @returns a new Vector2
  15284. */
  15285. negate(): Vector2;
  15286. /**
  15287. * Multiply the Vector2 coordinates by scale
  15288. * @param scale defines the scaling factor
  15289. * @returns the current updated Vector2
  15290. */
  15291. scaleInPlace(scale: number): Vector2;
  15292. /**
  15293. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15294. * @param scale defines the scaling factor
  15295. * @returns a new Vector2
  15296. */
  15297. scale(scale: number): Vector2;
  15298. /**
  15299. * Scale the current Vector2 values by a factor to a given Vector2
  15300. * @param scale defines the scale factor
  15301. * @param result defines the Vector2 object where to store the result
  15302. * @returns the unmodified current Vector2
  15303. */
  15304. scaleToRef(scale: number, result: Vector2): Vector2;
  15305. /**
  15306. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15307. * @param scale defines the scale factor
  15308. * @param result defines the Vector2 object where to store the result
  15309. * @returns the unmodified current Vector2
  15310. */
  15311. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15312. /**
  15313. * Gets a boolean if two vectors are equals
  15314. * @param otherVector defines the other vector
  15315. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15316. */
  15317. equals(otherVector: Vector2): boolean;
  15318. /**
  15319. * Gets a boolean if two vectors are equals (using an epsilon value)
  15320. * @param otherVector defines the other vector
  15321. * @param epsilon defines the minimal distance to consider equality
  15322. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15323. */
  15324. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15325. /**
  15326. * Gets the length of the vector
  15327. * @returns the vector length (float)
  15328. */
  15329. length(): number;
  15330. /**
  15331. * Gets the vector squared length
  15332. * @returns the vector squared length (float)
  15333. */
  15334. lengthSquared(): number;
  15335. /**
  15336. * Normalize the vector
  15337. * @returns the current updated Vector2
  15338. */
  15339. normalize(): Vector2;
  15340. /**
  15341. * Gets a new Vector2 copied from the Vector2
  15342. * @returns a new Vector2
  15343. */
  15344. clone(): Vector2;
  15345. /**
  15346. * Gets a new Vector2(0, 0)
  15347. * @returns a new Vector2
  15348. */
  15349. static Zero(): Vector2;
  15350. /**
  15351. * Gets a new Vector2(1, 1)
  15352. * @returns a new Vector2
  15353. */
  15354. static One(): Vector2;
  15355. /**
  15356. * Gets a new Vector2 set from the given index element of the given array
  15357. * @param array defines the data source
  15358. * @param offset defines the offset in the data source
  15359. * @returns a new Vector2
  15360. */
  15361. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15362. /**
  15363. * Sets "result" from the given index element of the given array
  15364. * @param array defines the data source
  15365. * @param offset defines the offset in the data source
  15366. * @param result defines the target vector
  15367. */
  15368. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15369. /**
  15370. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15371. * @param value1 defines 1st point of control
  15372. * @param value2 defines 2nd point of control
  15373. * @param value3 defines 3rd point of control
  15374. * @param value4 defines 4th point of control
  15375. * @param amount defines the interpolation factor
  15376. * @returns a new Vector2
  15377. */
  15378. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15379. /**
  15380. * 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".
  15381. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15382. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15383. * @param value defines the value to clamp
  15384. * @param min defines the lower limit
  15385. * @param max defines the upper limit
  15386. * @returns a new Vector2
  15387. */
  15388. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15389. /**
  15390. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15391. * @param value1 defines the 1st control point
  15392. * @param tangent1 defines the outgoing tangent
  15393. * @param value2 defines the 2nd control point
  15394. * @param tangent2 defines the incoming tangent
  15395. * @param amount defines the interpolation factor
  15396. * @returns a new Vector2
  15397. */
  15398. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15399. /**
  15400. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15401. * @param start defines the start vector
  15402. * @param end defines the end vector
  15403. * @param amount defines the interpolation factor
  15404. * @returns a new Vector2
  15405. */
  15406. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15407. /**
  15408. * Gets the dot product of the vector "left" and the vector "right"
  15409. * @param left defines first vector
  15410. * @param right defines second vector
  15411. * @returns the dot product (float)
  15412. */
  15413. static Dot(left: Vector2, right: Vector2): number;
  15414. /**
  15415. * Returns a new Vector2 equal to the normalized given vector
  15416. * @param vector defines the vector to normalize
  15417. * @returns a new Vector2
  15418. */
  15419. static Normalize(vector: Vector2): Vector2;
  15420. /**
  15421. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15422. * @param left defines 1st vector
  15423. * @param right defines 2nd vector
  15424. * @returns a new Vector2
  15425. */
  15426. static Minimize(left: Vector2, right: Vector2): Vector2;
  15427. /**
  15428. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15429. * @param left defines 1st vector
  15430. * @param right defines 2nd vector
  15431. * @returns a new Vector2
  15432. */
  15433. static Maximize(left: Vector2, right: Vector2): Vector2;
  15434. /**
  15435. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15436. * @param vector defines the vector to transform
  15437. * @param transformation defines the matrix to apply
  15438. * @returns a new Vector2
  15439. */
  15440. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15441. /**
  15442. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15443. * @param vector defines the vector to transform
  15444. * @param transformation defines the matrix to apply
  15445. * @param result defines the target vector
  15446. */
  15447. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15448. /**
  15449. * Determines if a given vector is included in a triangle
  15450. * @param p defines the vector to test
  15451. * @param p0 defines 1st triangle point
  15452. * @param p1 defines 2nd triangle point
  15453. * @param p2 defines 3rd triangle point
  15454. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15455. */
  15456. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15457. /**
  15458. * Gets the distance between the vectors "value1" and "value2"
  15459. * @param value1 defines first vector
  15460. * @param value2 defines second vector
  15461. * @returns the distance between vectors
  15462. */
  15463. static Distance(value1: Vector2, value2: Vector2): number;
  15464. /**
  15465. * Returns the squared distance between the vectors "value1" and "value2"
  15466. * @param value1 defines first vector
  15467. * @param value2 defines second vector
  15468. * @returns the squared distance between vectors
  15469. */
  15470. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15471. /**
  15472. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15473. * @param value1 defines first vector
  15474. * @param value2 defines second vector
  15475. * @returns a new Vector2
  15476. */
  15477. static Center(value1: Vector2, value2: Vector2): Vector2;
  15478. /**
  15479. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15480. * @param p defines the middle point
  15481. * @param segA defines one point of the segment
  15482. * @param segB defines the other point of the segment
  15483. * @returns the shortest distance
  15484. */
  15485. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15486. }
  15487. /**
  15488. * Classed used to store (x,y,z) vector representation
  15489. * A Vector3 is the main object used in 3D geometry
  15490. * It can represent etiher the coordinates of a point the space, either a direction
  15491. * Reminder: Babylon.js uses a left handed forward facing system
  15492. */
  15493. class Vector3 {
  15494. /**
  15495. * Defines the first coordinates (on X axis)
  15496. */
  15497. x: number;
  15498. /**
  15499. * Defines the second coordinates (on Y axis)
  15500. */
  15501. y: number;
  15502. /**
  15503. * Defines the third coordinates (on Z axis)
  15504. */
  15505. z: number;
  15506. /**
  15507. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15508. * @param x defines the first coordinates (on X axis)
  15509. * @param y defines the second coordinates (on Y axis)
  15510. * @param z defines the third coordinates (on Z axis)
  15511. */
  15512. constructor(
  15513. /**
  15514. * Defines the first coordinates (on X axis)
  15515. */
  15516. x: number,
  15517. /**
  15518. * Defines the second coordinates (on Y axis)
  15519. */
  15520. y: number,
  15521. /**
  15522. * Defines the third coordinates (on Z axis)
  15523. */
  15524. z: number);
  15525. /**
  15526. * Creates a string representation of the Vector3
  15527. * @returns a string with the Vector3 coordinates.
  15528. */
  15529. toString(): string;
  15530. /**
  15531. * Gets the class name
  15532. * @returns the string "Vector3"
  15533. */
  15534. getClassName(): string;
  15535. /**
  15536. * Creates the Vector3 hash code
  15537. * @returns a number which tends to be unique between Vector3 instances
  15538. */
  15539. getHashCode(): number;
  15540. /**
  15541. * Creates an array containing three elements : the coordinates of the Vector3
  15542. * @returns a new array of numbers
  15543. */
  15544. asArray(): number[];
  15545. /**
  15546. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15547. * @param array defines the destination array
  15548. * @param index defines the offset in the destination array
  15549. * @returns the current Vector3
  15550. */
  15551. toArray(array: FloatArray, index?: number): Vector3;
  15552. /**
  15553. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15554. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15555. */
  15556. toQuaternion(): Quaternion;
  15557. /**
  15558. * Adds the given vector to the current Vector3
  15559. * @param otherVector defines the second operand
  15560. * @returns the current updated Vector3
  15561. */
  15562. addInPlace(otherVector: Vector3): Vector3;
  15563. /**
  15564. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15565. * @param otherVector defines the second operand
  15566. * @returns the resulting Vector3
  15567. */
  15568. add(otherVector: Vector3): Vector3;
  15569. /**
  15570. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15571. * @param otherVector defines the second operand
  15572. * @param result defines the Vector3 object where to store the result
  15573. * @returns the current Vector3
  15574. */
  15575. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15576. /**
  15577. * Subtract the given vector from the current Vector3
  15578. * @param otherVector defines the second operand
  15579. * @returns the current updated Vector3
  15580. */
  15581. subtractInPlace(otherVector: Vector3): Vector3;
  15582. /**
  15583. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15584. * @param otherVector defines the second operand
  15585. * @returns the resulting Vector3
  15586. */
  15587. subtract(otherVector: Vector3): Vector3;
  15588. /**
  15589. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15590. * @param otherVector defines the second operand
  15591. * @param result defines the Vector3 object where to store the result
  15592. * @returns the current Vector3
  15593. */
  15594. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15595. /**
  15596. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15597. * @param x defines the x coordinate of the operand
  15598. * @param y defines the y coordinate of the operand
  15599. * @param z defines the z coordinate of the operand
  15600. * @returns the resulting Vector3
  15601. */
  15602. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15603. /**
  15604. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15605. * @param x defines the x coordinate of the operand
  15606. * @param y defines the y coordinate of the operand
  15607. * @param z defines the z coordinate of the operand
  15608. * @param result defines the Vector3 object where to store the result
  15609. * @returns the current Vector3
  15610. */
  15611. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15612. /**
  15613. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15614. * @returns a new Vector3
  15615. */
  15616. negate(): Vector3;
  15617. /**
  15618. * Multiplies the Vector3 coordinates by the float "scale"
  15619. * @param scale defines the multiplier factor
  15620. * @returns the current updated Vector3
  15621. */
  15622. scaleInPlace(scale: number): Vector3;
  15623. /**
  15624. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15625. * @param scale defines the multiplier factor
  15626. * @returns a new Vector3
  15627. */
  15628. scale(scale: number): Vector3;
  15629. /**
  15630. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15631. * @param scale defines the multiplier factor
  15632. * @param result defines the Vector3 object where to store the result
  15633. * @returns the current Vector3
  15634. */
  15635. scaleToRef(scale: number, result: Vector3): Vector3;
  15636. /**
  15637. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15638. * @param scale defines the scale factor
  15639. * @param result defines the Vector3 object where to store the result
  15640. * @returns the unmodified current Vector3
  15641. */
  15642. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15643. /**
  15644. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15645. * @param otherVector defines the second operand
  15646. * @returns true if both vectors are equals
  15647. */
  15648. equals(otherVector: Vector3): boolean;
  15649. /**
  15650. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15651. * @param otherVector defines the second operand
  15652. * @param epsilon defines the minimal distance to define values as equals
  15653. * @returns true if both vectors are distant less than epsilon
  15654. */
  15655. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15656. /**
  15657. * Returns true if the current Vector3 coordinates equals the given floats
  15658. * @param x defines the x coordinate of the operand
  15659. * @param y defines the y coordinate of the operand
  15660. * @param z defines the z coordinate of the operand
  15661. * @returns true if both vectors are equals
  15662. */
  15663. equalsToFloats(x: number, y: number, z: number): boolean;
  15664. /**
  15665. * Multiplies the current Vector3 coordinates by the given ones
  15666. * @param otherVector defines the second operand
  15667. * @returns the current updated Vector3
  15668. */
  15669. multiplyInPlace(otherVector: Vector3): Vector3;
  15670. /**
  15671. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15672. * @param otherVector defines the second operand
  15673. * @returns the new Vector3
  15674. */
  15675. multiply(otherVector: Vector3): Vector3;
  15676. /**
  15677. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  15678. * @param otherVector defines the second operand
  15679. * @param result defines the Vector3 object where to store the result
  15680. * @returns the current Vector3
  15681. */
  15682. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15683. /**
  15684. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15685. * @param x defines the x coordinate of the operand
  15686. * @param y defines the y coordinate of the operand
  15687. * @param z defines the z coordinate of the operand
  15688. * @returns the new Vector3
  15689. */
  15690. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15691. /**
  15692. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15693. * @param otherVector defines the second operand
  15694. * @returns the new Vector3
  15695. */
  15696. divide(otherVector: Vector3): Vector3;
  15697. /**
  15698. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15699. * @param otherVector defines the second operand
  15700. * @param result defines the Vector3 object where to store the result
  15701. * @returns the current Vector3
  15702. */
  15703. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15704. /**
  15705. * Divides the current Vector3 coordinates by the given ones.
  15706. * @param otherVector defines the second operand
  15707. * @returns the current updated Vector3
  15708. */
  15709. divideInPlace(otherVector: Vector3): Vector3;
  15710. /**
  15711. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  15712. * @param other defines the second operand
  15713. * @returns the current updated Vector3
  15714. */
  15715. minimizeInPlace(other: Vector3): Vector3;
  15716. /**
  15717. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  15718. * @param other defines the second operand
  15719. * @returns the current updated Vector3
  15720. */
  15721. maximizeInPlace(other: Vector3): Vector3;
  15722. /**
  15723. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15724. */
  15725. readonly isNonUniform: boolean;
  15726. /**
  15727. * Gets the length of the Vector3
  15728. * @returns the length of the Vecto3
  15729. */
  15730. length(): number;
  15731. /**
  15732. * Gets the squared length of the Vector3
  15733. * @returns squared length of the Vector3
  15734. */
  15735. lengthSquared(): number;
  15736. /**
  15737. * Normalize the current Vector3.
  15738. * Please note that this is an in place operation.
  15739. * @returns the current updated Vector3
  15740. */
  15741. normalize(): Vector3;
  15742. /**
  15743. * Normalize the current Vector3 to a new vector
  15744. * @returns the new Vector3
  15745. */
  15746. normalizeToNew(): Vector3;
  15747. /**
  15748. * Normalize the current Vector3 to the reference
  15749. * @param reference define the Vector3 to update
  15750. * @returns the updated Vector3
  15751. */
  15752. normalizeToRef(reference: Vector3): Vector3;
  15753. /**
  15754. * Creates a new Vector3 copied from the current Vector3
  15755. * @returns the new Vector3
  15756. */
  15757. clone(): Vector3;
  15758. /**
  15759. * Copies the given vector coordinates to the current Vector3 ones
  15760. * @param source defines the source Vector3
  15761. * @returns the current updated Vector3
  15762. */
  15763. copyFrom(source: Vector3): Vector3;
  15764. /**
  15765. * Copies the given floats to the current Vector3 coordinates
  15766. * @param x defines the x coordinate of the operand
  15767. * @param y defines the y coordinate of the operand
  15768. * @param z defines the z coordinate of the operand
  15769. * @returns the current updated Vector3
  15770. */
  15771. copyFromFloats(x: number, y: number, z: number): Vector3;
  15772. /**
  15773. * Copies the given floats to the current Vector3 coordinates
  15774. * @param x defines the x coordinate of the operand
  15775. * @param y defines the y coordinate of the operand
  15776. * @param z defines the z coordinate of the operand
  15777. * @returns the current updated Vector3
  15778. */
  15779. set(x: number, y: number, z: number): Vector3;
  15780. /**
  15781. * Get the clip factor between two vectors
  15782. * @param vector0 defines the first operand
  15783. * @param vector1 defines the second operand
  15784. * @param axis defines the axis to use
  15785. * @param size defines the size along the axis
  15786. * @returns the clip factor
  15787. */
  15788. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  15789. /**
  15790. * Get angle between two vectors
  15791. * @param vector0 angle between vector0 and vector1
  15792. * @param vector1 angle between vector0 and vector1
  15793. * @param normal direction of the normal
  15794. * @return the angle between vector0 and vector1
  15795. */
  15796. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  15797. /**
  15798. * Returns a new Vector3 set from the index "offset" of the given array
  15799. * @param array defines the source array
  15800. * @param offset defines the offset in the source array
  15801. * @returns the new Vector3
  15802. */
  15803. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  15804. /**
  15805. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  15806. * This function is deprecated. Use FromArray instead
  15807. * @param array defines the source array
  15808. * @param offset defines the offset in the source array
  15809. * @returns the new Vector3
  15810. */
  15811. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  15812. /**
  15813. * Sets the given vector "result" with the element values from the index "offset" of the given array
  15814. * @param array defines the source array
  15815. * @param offset defines the offset in the source array
  15816. * @param result defines the Vector3 where to store the result
  15817. */
  15818. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  15819. /**
  15820. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  15821. * This function is deprecated. Use FromArrayToRef instead.
  15822. * @param array defines the source array
  15823. * @param offset defines the offset in the source array
  15824. * @param result defines the Vector3 where to store the result
  15825. */
  15826. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  15827. /**
  15828. * Sets the given vector "result" with the given floats.
  15829. * @param x defines the x coordinate of the source
  15830. * @param y defines the y coordinate of the source
  15831. * @param z defines the z coordinate of the source
  15832. * @param result defines the Vector3 where to store the result
  15833. */
  15834. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  15835. /**
  15836. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  15837. * @returns a new empty Vector3
  15838. */
  15839. static Zero(): Vector3;
  15840. /**
  15841. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  15842. * @returns a new unit Vector3
  15843. */
  15844. static One(): Vector3;
  15845. /**
  15846. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  15847. * @returns a new up Vector3
  15848. */
  15849. static Up(): Vector3;
  15850. /**
  15851. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  15852. * @returns a new forward Vector3
  15853. */
  15854. static Forward(): Vector3;
  15855. /**
  15856. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  15857. * @returns a new right Vector3
  15858. */
  15859. static Right(): Vector3;
  15860. /**
  15861. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  15862. * @returns a new left Vector3
  15863. */
  15864. static Left(): Vector3;
  15865. /**
  15866. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  15867. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15868. * @param vector defines the Vector3 to transform
  15869. * @param transformation defines the transformation matrix
  15870. * @returns the transformed Vector3
  15871. */
  15872. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  15873. /**
  15874. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  15875. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15876. * @param vector defines the Vector3 to transform
  15877. * @param transformation defines the transformation matrix
  15878. * @param result defines the Vector3 where to store the result
  15879. */
  15880. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15881. /**
  15882. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  15883. * This method computes tranformed coordinates only, not transformed direction vectors
  15884. * @param x define the x coordinate of the source vector
  15885. * @param y define the y coordinate of the source vector
  15886. * @param z define the z coordinate of the source vector
  15887. * @param transformation defines the transformation matrix
  15888. * @param result defines the Vector3 where to store the result
  15889. */
  15890. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15891. /**
  15892. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  15893. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15894. * @param vector defines the Vector3 to transform
  15895. * @param transformation defines the transformation matrix
  15896. * @returns the new Vector3
  15897. */
  15898. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  15899. /**
  15900. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  15901. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15902. * @param vector defines the Vector3 to transform
  15903. * @param transformation defines the transformation matrix
  15904. * @param result defines the Vector3 where to store the result
  15905. */
  15906. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15907. /**
  15908. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  15909. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15910. * @param x define the x coordinate of the source vector
  15911. * @param y define the y coordinate of the source vector
  15912. * @param z define the z coordinate of the source vector
  15913. * @param transformation defines the transformation matrix
  15914. * @param result defines the Vector3 where to store the result
  15915. */
  15916. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15917. /**
  15918. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  15919. * @param value1 defines the first control point
  15920. * @param value2 defines the second control point
  15921. * @param value3 defines the third control point
  15922. * @param value4 defines the fourth control point
  15923. * @param amount defines the amount on the spline to use
  15924. * @returns the new Vector3
  15925. */
  15926. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  15927. /**
  15928. * 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"
  15929. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  15930. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  15931. * @param value defines the current value
  15932. * @param min defines the lower range value
  15933. * @param max defines the upper range value
  15934. * @returns the new Vector3
  15935. */
  15936. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  15937. /**
  15938. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  15939. * @param value1 defines the first control point
  15940. * @param tangent1 defines the first tangent vector
  15941. * @param value2 defines the second control point
  15942. * @param tangent2 defines the second tangent vector
  15943. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  15944. * @returns the new Vector3
  15945. */
  15946. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  15947. /**
  15948. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  15949. * @param start defines the start value
  15950. * @param end defines the end value
  15951. * @param amount max defines amount between both (between 0 and 1)
  15952. * @returns the new Vector3
  15953. */
  15954. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  15955. /**
  15956. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  15957. * @param start defines the start value
  15958. * @param end defines the end value
  15959. * @param amount max defines amount between both (between 0 and 1)
  15960. * @param result defines the Vector3 where to store the result
  15961. */
  15962. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  15963. /**
  15964. * Returns the dot product (float) between the vectors "left" and "right"
  15965. * @param left defines the left operand
  15966. * @param right defines the right operand
  15967. * @returns the dot product
  15968. */
  15969. static Dot(left: Vector3, right: Vector3): number;
  15970. /**
  15971. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  15972. * The cross product is then orthogonal to both "left" and "right"
  15973. * @param left defines the left operand
  15974. * @param right defines the right operand
  15975. * @returns the cross product
  15976. */
  15977. static Cross(left: Vector3, right: Vector3): Vector3;
  15978. /**
  15979. * Sets the given vector "result" with the cross product of "left" and "right"
  15980. * The cross product is then orthogonal to both "left" and "right"
  15981. * @param left defines the left operand
  15982. * @param right defines the right operand
  15983. * @param result defines the Vector3 where to store the result
  15984. */
  15985. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  15986. /**
  15987. * Returns a new Vector3 as the normalization of the given vector
  15988. * @param vector defines the Vector3 to normalize
  15989. * @returns the new Vector3
  15990. */
  15991. static Normalize(vector: Vector3): Vector3;
  15992. /**
  15993. * Sets the given vector "result" with the normalization of the given first vector
  15994. * @param vector defines the Vector3 to normalize
  15995. * @param result defines the Vector3 where to store the result
  15996. */
  15997. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  15998. private static _viewportMatrixCache;
  15999. /**
  16000. * Project a Vector3 onto screen space
  16001. * @param vector defines the Vector3 to project
  16002. * @param world defines the world matrix to use
  16003. * @param transform defines the transform (view x projection) matrix to use
  16004. * @param viewport defines the screen viewport to use
  16005. * @returns the new Vector3
  16006. */
  16007. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16008. /**
  16009. * Unproject from screen space to object space
  16010. * @param source defines the screen space Vector3 to use
  16011. * @param viewportWidth defines the current width of the viewport
  16012. * @param viewportHeight defines the current height of the viewport
  16013. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16014. * @param transform defines the transform (view x projection) matrix to use
  16015. * @returns the new Vector3
  16016. */
  16017. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16018. /**
  16019. * Unproject from screen space to object space
  16020. * @param source defines the screen space Vector3 to use
  16021. * @param viewportWidth defines the current width of the viewport
  16022. * @param viewportHeight defines the current height of the viewport
  16023. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16024. * @param view defines the view matrix to use
  16025. * @param projection defines the projection matrix to use
  16026. * @returns the new Vector3
  16027. */
  16028. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16029. /**
  16030. * Unproject from screen space to object space
  16031. * @param source defines the screen space Vector3 to use
  16032. * @param viewportWidth defines the current width of the viewport
  16033. * @param viewportHeight defines the current height of the viewport
  16034. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16035. * @param view defines the view matrix to use
  16036. * @param projection defines the projection matrix to use
  16037. * @param result defines the Vector3 where to store the result
  16038. */
  16039. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16040. /**
  16041. * Unproject from screen space to object space
  16042. * @param sourceX defines the screen space x coordinate to use
  16043. * @param sourceY defines the screen space y coordinate to use
  16044. * @param sourceZ defines the screen space z coordinate to use
  16045. * @param viewportWidth defines the current width of the viewport
  16046. * @param viewportHeight defines the current height of the viewport
  16047. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16048. * @param view defines the view matrix to use
  16049. * @param projection defines the projection matrix to use
  16050. * @param result defines the Vector3 where to store the result
  16051. */
  16052. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16053. /**
  16054. * Gets the minimal coordinate values between two Vector3
  16055. * @param left defines the first operand
  16056. * @param right defines the second operand
  16057. * @returns the new Vector3
  16058. */
  16059. static Minimize(left: Vector3, right: Vector3): Vector3;
  16060. /**
  16061. * Gets the maximal coordinate values between two Vector3
  16062. * @param left defines the first operand
  16063. * @param right defines the second operand
  16064. * @returns the new Vector3
  16065. */
  16066. static Maximize(left: Vector3, right: Vector3): Vector3;
  16067. /**
  16068. * Returns the distance between the vectors "value1" and "value2"
  16069. * @param value1 defines the first operand
  16070. * @param value2 defines the second operand
  16071. * @returns the distance
  16072. */
  16073. static Distance(value1: Vector3, value2: Vector3): number;
  16074. /**
  16075. * Returns the squared distance between the vectors "value1" and "value2"
  16076. * @param value1 defines the first operand
  16077. * @param value2 defines the second operand
  16078. * @returns the squared distance
  16079. */
  16080. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16081. /**
  16082. * Returns a new Vector3 located at the center between "value1" and "value2"
  16083. * @param value1 defines the first operand
  16084. * @param value2 defines the second operand
  16085. * @returns the new Vector3
  16086. */
  16087. static Center(value1: Vector3, value2: Vector3): Vector3;
  16088. /**
  16089. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16090. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16091. * to something in order to rotate it from its local system to the given target system
  16092. * Note: axis1, axis2 and axis3 are normalized during this operation
  16093. * @param axis1 defines the first axis
  16094. * @param axis2 defines the second axis
  16095. * @param axis3 defines the third axis
  16096. * @returns a new Vector3
  16097. */
  16098. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16099. /**
  16100. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16101. * @param axis1 defines the first axis
  16102. * @param axis2 defines the second axis
  16103. * @param axis3 defines the third axis
  16104. * @param ref defines the Vector3 where to store the result
  16105. */
  16106. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16107. }
  16108. class Vector4 {
  16109. x: number;
  16110. y: number;
  16111. z: number;
  16112. w: number;
  16113. /**
  16114. * Creates a Vector4 object from the given floats.
  16115. */
  16116. constructor(x: number, y: number, z: number, w: number);
  16117. /**
  16118. * Returns the string with the Vector4 coordinates.
  16119. */
  16120. toString(): string;
  16121. /**
  16122. * Returns the string "Vector4".
  16123. */
  16124. getClassName(): string;
  16125. /**
  16126. * Returns the Vector4 hash code.
  16127. */
  16128. getHashCode(): number;
  16129. /**
  16130. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16131. */
  16132. asArray(): number[];
  16133. /**
  16134. * Populates the given array from the given index with the Vector4 coordinates.
  16135. * Returns the Vector4.
  16136. */
  16137. toArray(array: FloatArray, index?: number): Vector4;
  16138. /**
  16139. * Adds the given vector to the current Vector4.
  16140. * Returns the updated Vector4.
  16141. */
  16142. addInPlace(otherVector: Vector4): Vector4;
  16143. /**
  16144. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16145. */
  16146. add(otherVector: Vector4): Vector4;
  16147. /**
  16148. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16149. * Returns the current Vector4.
  16150. */
  16151. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16152. /**
  16153. * Subtract in place the given vector from the current Vector4.
  16154. * Returns the updated Vector4.
  16155. */
  16156. subtractInPlace(otherVector: Vector4): Vector4;
  16157. /**
  16158. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16159. */
  16160. subtract(otherVector: Vector4): Vector4;
  16161. /**
  16162. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16163. * Returns the current Vector4.
  16164. */
  16165. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16166. /**
  16167. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16168. */
  16169. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16170. /**
  16171. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16172. * Returns the current Vector4.
  16173. */
  16174. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16175. /**
  16176. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16177. */
  16178. negate(): Vector4;
  16179. /**
  16180. * Multiplies the current Vector4 coordinates by scale (float).
  16181. * Returns the updated Vector4.
  16182. */
  16183. scaleInPlace(scale: number): Vector4;
  16184. /**
  16185. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16186. */
  16187. scale(scale: number): Vector4;
  16188. /**
  16189. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16190. * Returns the current Vector4.
  16191. */
  16192. scaleToRef(scale: number, result: Vector4): Vector4;
  16193. /**
  16194. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16195. * @param scale defines the scale factor
  16196. * @param result defines the Vector4 object where to store the result
  16197. * @returns the unmodified current Vector4
  16198. */
  16199. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16200. /**
  16201. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16202. */
  16203. equals(otherVector: Vector4): boolean;
  16204. /**
  16205. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16206. */
  16207. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16208. /**
  16209. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16210. */
  16211. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16212. /**
  16213. * Multiplies in place the current Vector4 by the given one.
  16214. * Returns the updated Vector4.
  16215. */
  16216. multiplyInPlace(otherVector: Vector4): Vector4;
  16217. /**
  16218. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16219. */
  16220. multiply(otherVector: Vector4): Vector4;
  16221. /**
  16222. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16223. * Returns the current Vector4.
  16224. */
  16225. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16226. /**
  16227. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16228. */
  16229. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16230. /**
  16231. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16232. */
  16233. divide(otherVector: Vector4): Vector4;
  16234. /**
  16235. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16236. * Returns the current Vector4.
  16237. */
  16238. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16239. /**
  16240. * Divides the current Vector3 coordinates by the given ones.
  16241. * @returns the updated Vector3.
  16242. */
  16243. divideInPlace(otherVector: Vector4): Vector4;
  16244. /**
  16245. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16246. * @param other defines the second operand
  16247. * @returns the current updated Vector4
  16248. */
  16249. minimizeInPlace(other: Vector4): Vector4;
  16250. /**
  16251. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16252. * @param other defines the second operand
  16253. * @returns the current updated Vector4
  16254. */
  16255. maximizeInPlace(other: Vector4): Vector4;
  16256. /**
  16257. * Returns the Vector4 length (float).
  16258. */
  16259. length(): number;
  16260. /**
  16261. * Returns the Vector4 squared length (float).
  16262. */
  16263. lengthSquared(): number;
  16264. /**
  16265. * Normalizes in place the Vector4.
  16266. * Returns the updated Vector4.
  16267. */
  16268. normalize(): Vector4;
  16269. /**
  16270. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16271. */
  16272. toVector3(): Vector3;
  16273. /**
  16274. * Returns a new Vector4 copied from the current one.
  16275. */
  16276. clone(): Vector4;
  16277. /**
  16278. * Updates the current Vector4 with the given one coordinates.
  16279. * Returns the updated Vector4.
  16280. */
  16281. copyFrom(source: Vector4): Vector4;
  16282. /**
  16283. * Updates the current Vector4 coordinates with the given floats.
  16284. * Returns the updated Vector4.
  16285. */
  16286. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16287. /**
  16288. * Updates the current Vector4 coordinates with the given floats.
  16289. * Returns the updated Vector4.
  16290. */
  16291. set(x: number, y: number, z: number, w: number): Vector4;
  16292. /**
  16293. * Returns a new Vector4 set from the starting index of the given array.
  16294. */
  16295. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16296. /**
  16297. * Updates the given vector "result" from the starting index of the given array.
  16298. */
  16299. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16300. /**
  16301. * Updates the given vector "result" from the starting index of the given Float32Array.
  16302. */
  16303. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16304. /**
  16305. * Updates the given vector "result" coordinates from the given floats.
  16306. */
  16307. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16308. /**
  16309. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16310. */
  16311. static Zero(): Vector4;
  16312. /**
  16313. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16314. */
  16315. static One(): Vector4;
  16316. /**
  16317. * Returns a new normalized Vector4 from the given one.
  16318. */
  16319. static Normalize(vector: Vector4): Vector4;
  16320. /**
  16321. * Updates the given vector "result" from the normalization of the given one.
  16322. */
  16323. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16324. static Minimize(left: Vector4, right: Vector4): Vector4;
  16325. static Maximize(left: Vector4, right: Vector4): Vector4;
  16326. /**
  16327. * Returns the distance (float) between the vectors "value1" and "value2".
  16328. */
  16329. static Distance(value1: Vector4, value2: Vector4): number;
  16330. /**
  16331. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16332. */
  16333. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16334. /**
  16335. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16336. */
  16337. static Center(value1: Vector4, value2: Vector4): Vector4;
  16338. /**
  16339. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16340. * This methods computes transformed normalized direction vectors only.
  16341. */
  16342. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16343. /**
  16344. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16345. * This methods computes transformed normalized direction vectors only.
  16346. */
  16347. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16348. /**
  16349. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16350. * This methods computes transformed normalized direction vectors only.
  16351. */
  16352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16353. }
  16354. interface ISize {
  16355. width: number;
  16356. height: number;
  16357. }
  16358. class Size implements ISize {
  16359. width: number;
  16360. height: number;
  16361. /**
  16362. * Creates a Size object from the given width and height (floats).
  16363. */
  16364. constructor(width: number, height: number);
  16365. toString(): string;
  16366. /**
  16367. * Returns the string "Size"
  16368. */
  16369. getClassName(): string;
  16370. /**
  16371. * Returns the Size hash code.
  16372. */
  16373. getHashCode(): number;
  16374. /**
  16375. * Updates the current size from the given one.
  16376. * Returns the updated Size.
  16377. */
  16378. copyFrom(src: Size): void;
  16379. /**
  16380. * Updates in place the current Size from the given floats.
  16381. * Returns the updated Size.
  16382. */
  16383. copyFromFloats(width: number, height: number): Size;
  16384. /**
  16385. * Updates in place the current Size from the given floats.
  16386. * Returns the updated Size.
  16387. */
  16388. set(width: number, height: number): Size;
  16389. /**
  16390. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16391. */
  16392. multiplyByFloats(w: number, h: number): Size;
  16393. /**
  16394. * Returns a new Size copied from the given one.
  16395. */
  16396. clone(): Size;
  16397. /**
  16398. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16399. */
  16400. equals(other: Size): boolean;
  16401. /**
  16402. * Returns the surface of the Size : width * height (float).
  16403. */
  16404. readonly surface: number;
  16405. /**
  16406. * Returns a new Size set to (0.0, 0.0)
  16407. */
  16408. static Zero(): Size;
  16409. /**
  16410. * Returns a new Size set as the addition result of the current Size and the given one.
  16411. */
  16412. add(otherSize: Size): Size;
  16413. /**
  16414. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16415. */
  16416. subtract(otherSize: Size): Size;
  16417. /**
  16418. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16419. */
  16420. static Lerp(start: Size, end: Size, amount: number): Size;
  16421. }
  16422. /**
  16423. * Class used to store quaternion data
  16424. * @see https://en.wikipedia.org/wiki/Quaternion
  16425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16426. */
  16427. class Quaternion {
  16428. /** defines the first component (0 by default) */
  16429. x: number;
  16430. /** defines the second component (0 by default) */
  16431. y: number;
  16432. /** defines the third component (0 by default) */
  16433. z: number;
  16434. /** defines the fourth component (1.0 by default) */
  16435. w: number;
  16436. /**
  16437. * Creates a new Quaternion from the given floats
  16438. * @param x defines the first component (0 by default)
  16439. * @param y defines the second component (0 by default)
  16440. * @param z defines the third component (0 by default)
  16441. * @param w defines the fourth component (1.0 by default)
  16442. */
  16443. constructor(
  16444. /** defines the first component (0 by default) */
  16445. x?: number,
  16446. /** defines the second component (0 by default) */
  16447. y?: number,
  16448. /** defines the third component (0 by default) */
  16449. z?: number,
  16450. /** defines the fourth component (1.0 by default) */
  16451. w?: number);
  16452. /**
  16453. * Gets a string representation for the current quaternion
  16454. * @returns a string with the Quaternion coordinates
  16455. */
  16456. toString(): string;
  16457. /**
  16458. * Gets the class name of the quaternion
  16459. * @returns the string "Quaternion"
  16460. */
  16461. getClassName(): string;
  16462. /**
  16463. * Gets a hash code for this quaternion
  16464. * @returns the quaternion hash code
  16465. */
  16466. getHashCode(): number;
  16467. /**
  16468. * Copy the quaternion to an array
  16469. * @returns a new array populated with 4 elements from the quaternion coordinates
  16470. */
  16471. asArray(): number[];
  16472. /**
  16473. * Check if two quaternions are equals
  16474. * @param otherQuaternion defines the second operand
  16475. * @return true if the current quaternion and the given one coordinates are strictly equals
  16476. */
  16477. equals(otherQuaternion: Quaternion): boolean;
  16478. /**
  16479. * Clone the current quaternion
  16480. * @returns a new quaternion copied from the current one
  16481. */
  16482. clone(): Quaternion;
  16483. /**
  16484. * Copy a quaternion to the current one
  16485. * @param other defines the other quaternion
  16486. * @returns the updated current quaternion
  16487. */
  16488. copyFrom(other: Quaternion): Quaternion;
  16489. /**
  16490. * Updates the current quaternion with the given float coordinates
  16491. * @param x defines the x coordinate
  16492. * @param y defines the y coordinate
  16493. * @param z defines the z coordinate
  16494. * @param w defines the w coordinate
  16495. * @returns the updated current quaternion
  16496. */
  16497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16498. /**
  16499. * Updates the current quaternion from the given float coordinates
  16500. * @param x defines the x coordinate
  16501. * @param y defines the y coordinate
  16502. * @param z defines the z coordinate
  16503. * @param w defines the w coordinate
  16504. * @returns the updated current quaternion
  16505. */
  16506. set(x: number, y: number, z: number, w: number): Quaternion;
  16507. /**
  16508. * Adds two quaternions
  16509. * @param other defines the second operand
  16510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16511. */
  16512. add(other: Quaternion): Quaternion;
  16513. /**
  16514. * Add a quaternion to the current one
  16515. * @param other defines the quaternion to add
  16516. * @returns the current quaternion
  16517. */
  16518. addInPlace(other: Quaternion): Quaternion;
  16519. /**
  16520. * Subtract two quaternions
  16521. * @param other defines the second operand
  16522. * @returns a new quaternion as the subtraction result of the given one from the current one
  16523. */
  16524. subtract(other: Quaternion): Quaternion;
  16525. /**
  16526. * Multiplies the current quaternion by a scale factor
  16527. * @param value defines the scale factor
  16528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16529. */
  16530. scale(value: number): Quaternion;
  16531. /**
  16532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16533. * @param scale defines the scale factor
  16534. * @param result defines the Quaternion object where to store the result
  16535. * @returns the unmodified current quaternion
  16536. */
  16537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16538. /**
  16539. * Multiplies in place the current quaternion by a scale factor
  16540. * @param value defines the scale factor
  16541. * @returns the current modified quaternion
  16542. */
  16543. scaleInPlace(value: number): Quaternion;
  16544. /**
  16545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16546. * @param scale defines the scale factor
  16547. * @param result defines the Quaternion object where to store the result
  16548. * @returns the unmodified current quaternion
  16549. */
  16550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16551. /**
  16552. * Multiplies two quaternions
  16553. * @param q1 defines the second operand
  16554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16555. */
  16556. multiply(q1: Quaternion): Quaternion;
  16557. /**
  16558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16559. * @param q1 defines the second operand
  16560. * @param result defines the target quaternion
  16561. * @returns the current quaternion
  16562. */
  16563. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16564. /**
  16565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16566. * @param q1 defines the second operand
  16567. * @returns the currentupdated quaternion
  16568. */
  16569. multiplyInPlace(q1: Quaternion): Quaternion;
  16570. /**
  16571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16572. * @param ref defines the target quaternion
  16573. * @returns the current quaternion
  16574. */
  16575. conjugateToRef(ref: Quaternion): Quaternion;
  16576. /**
  16577. * Conjugates in place (1-q) the current quaternion
  16578. * @returns the current updated quaternion
  16579. */
  16580. conjugateInPlace(): Quaternion;
  16581. /**
  16582. * Conjugates in place (1-q) the current quaternion
  16583. * @returns a new quaternion
  16584. */
  16585. conjugate(): Quaternion;
  16586. /**
  16587. * Gets length of current quaternion
  16588. * @returns the quaternion length (float)
  16589. */
  16590. length(): number;
  16591. /**
  16592. * Normalize in place the current quaternion
  16593. * @returns the current updated quaternion
  16594. */
  16595. normalize(): Quaternion;
  16596. /**
  16597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16598. * @param order is a reserved parameter and is ignore for now
  16599. * @returns a new Vector3 containing the Euler angles
  16600. */
  16601. toEulerAngles(order?: string): Vector3;
  16602. /**
  16603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16604. * @param result defines the vector which will be filled with the Euler angles
  16605. * @param order is a reserved parameter and is ignore for now
  16606. * @returns the current unchanged quaternion
  16607. */
  16608. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16609. /**
  16610. * Updates the given rotation matrix with the current quaternion values
  16611. * @param result defines the target matrix
  16612. * @returns the current unchanged quaternion
  16613. */
  16614. toRotationMatrix(result: Matrix): Quaternion;
  16615. /**
  16616. * Updates the current quaternion from the given rotation matrix values
  16617. * @param matrix defines the source matrix
  16618. * @returns the current updated quaternion
  16619. */
  16620. fromRotationMatrix(matrix: Matrix): Quaternion;
  16621. /**
  16622. * Creates a new quaternion from a rotation matrix
  16623. * @param matrix defines the source matrix
  16624. * @returns a new quaternion created from the given rotation matrix values
  16625. */
  16626. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16627. /**
  16628. * Updates the given quaternion with the given rotation matrix values
  16629. * @param matrix defines the source matrix
  16630. * @param result defines the target quaternion
  16631. */
  16632. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16633. /**
  16634. * Returns the dot product (float) between the quaternions "left" and "right"
  16635. * @param left defines the left operand
  16636. * @param right defines the right operand
  16637. * @returns the dot product
  16638. */
  16639. static Dot(left: Quaternion, right: Quaternion): number;
  16640. /**
  16641. * Checks if the two quaternions are close to each other
  16642. * @param quat0 defines the first quaternion to check
  16643. * @param quat1 defines the second quaternion to check
  16644. * @returns true if the two quaternions are close to each other
  16645. */
  16646. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16647. /**
  16648. * Creates an empty quaternion
  16649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16650. */
  16651. static Zero(): Quaternion;
  16652. /**
  16653. * Inverse a given quaternion
  16654. * @param q defines the source quaternion
  16655. * @returns a new quaternion as the inverted current quaternion
  16656. */
  16657. static Inverse(q: Quaternion): Quaternion;
  16658. /**
  16659. * Creates an identity quaternion
  16660. * @returns the identity quaternion
  16661. */
  16662. static Identity(): Quaternion;
  16663. /**
  16664. * Gets a boolean indicating if the given quaternion is identity
  16665. * @param quaternion defines the quaternion to check
  16666. * @returns true if the quaternion is identity
  16667. */
  16668. static IsIdentity(quaternion: Quaternion): boolean;
  16669. /**
  16670. * Creates a quaternion from a rotation around an axis
  16671. * @param axis defines the axis to use
  16672. * @param angle defines the angle to use
  16673. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16674. */
  16675. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16676. /**
  16677. * Creates a rotation around an axis and stores it into the given quaternion
  16678. * @param axis defines the axis to use
  16679. * @param angle defines the angle to use
  16680. * @param result defines the target quaternion
  16681. * @returns the target quaternion
  16682. */
  16683. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16684. /**
  16685. * Creates a new quaternion from data stored into an array
  16686. * @param array defines the data source
  16687. * @param offset defines the offset in the source array where the data starts
  16688. * @returns a new quaternion
  16689. */
  16690. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16691. /**
  16692. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16693. * @param yaw defines the rotation around Y axis
  16694. * @param pitch defines the rotation around X axis
  16695. * @param roll defines the rotation around Z axis
  16696. * @returns the new quaternion
  16697. */
  16698. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16699. /**
  16700. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  16701. * @param yaw defines the rotation around Y axis
  16702. * @param pitch defines the rotation around X axis
  16703. * @param roll defines the rotation around Z axis
  16704. * @param result defines the target quaternion
  16705. */
  16706. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16707. /**
  16708. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  16709. * @param alpha defines the rotation around first axis
  16710. * @param beta defines the rotation around second axis
  16711. * @param gamma defines the rotation around third axis
  16712. * @returns the new quaternion
  16713. */
  16714. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16715. /**
  16716. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  16717. * @param alpha defines the rotation around first axis
  16718. * @param beta defines the rotation around second axis
  16719. * @param gamma defines the rotation around third axis
  16720. * @param result defines the target quaternion
  16721. */
  16722. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16723. /**
  16724. * 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)
  16725. * @param axis1 defines the first axis
  16726. * @param axis2 defines the second axis
  16727. * @param axis3 defines the third axis
  16728. * @returns the new quaternion
  16729. */
  16730. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  16731. /**
  16732. * 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
  16733. * @param axis1 defines the first axis
  16734. * @param axis2 defines the second axis
  16735. * @param axis3 defines the third axis
  16736. * @param ref defines the target quaternion
  16737. */
  16738. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16739. /**
  16740. * Interpolates between two quaternions
  16741. * @param left defines first quaternion
  16742. * @param right defines second quaternion
  16743. * @param amount defines the gradient to use
  16744. * @returns the new interpolated quaternion
  16745. */
  16746. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  16747. /**
  16748. * Interpolates between two quaternions and stores it into a target quaternion
  16749. * @param left defines first quaternion
  16750. * @param right defines second quaternion
  16751. * @param amount defines the gradient to use
  16752. * @param result defines the target quaternion
  16753. */
  16754. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  16755. /**
  16756. * Interpolate between two quaternions using Hermite interpolation
  16757. * @param value1 defines first quaternion
  16758. * @param tangent1 defines the incoming tangent
  16759. * @param value2 defines second quaternion
  16760. * @param tangent2 defines the outgoing tangent
  16761. * @param amount defines the target quaternion
  16762. * @returns the new interpolated quaternion
  16763. */
  16764. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  16765. }
  16766. /**
  16767. * Class used to store matrix data (4x4)
  16768. */
  16769. class Matrix {
  16770. private static _tempQuaternion;
  16771. private static _xAxis;
  16772. private static _yAxis;
  16773. private static _zAxis;
  16774. private static _updateFlagSeed;
  16775. private static _identityReadOnly;
  16776. private _isIdentity;
  16777. private _isIdentityDirty;
  16778. /**
  16779. * Gets the update flag of the matrix which is an unique number for the matrix.
  16780. * It will be incremented every time the matrix data change.
  16781. * You can use it to speed the comparison between two versions of the same matrix.
  16782. */
  16783. updateFlag: number;
  16784. /**
  16785. * Gets or sets the internal data of the matrix
  16786. */
  16787. m: Float32Array;
  16788. /** @hidden */
  16789. _markAsUpdated(): void;
  16790. /**
  16791. * Creates an empty matrix (filled with zeros)
  16792. */
  16793. constructor();
  16794. /**
  16795. * Check if the current matrix is indentity
  16796. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  16797. * @returns true is the matrix is the identity matrix
  16798. */
  16799. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  16800. /**
  16801. * Gets the determinant of the matrix
  16802. * @returns the matrix determinant
  16803. */
  16804. determinant(): number;
  16805. /**
  16806. * Returns the matrix as a Float32Array
  16807. * @returns the matrix underlying array
  16808. */
  16809. toArray(): Float32Array;
  16810. /**
  16811. * Returns the matrix as a Float32Array
  16812. * @returns the matrix underlying array.
  16813. */
  16814. asArray(): Float32Array;
  16815. /**
  16816. * Inverts the current matrix in place
  16817. * @returns the current inverted matrix
  16818. */
  16819. invert(): Matrix;
  16820. /**
  16821. * Sets all the matrix elements to zero
  16822. * @returns the current matrix
  16823. */
  16824. reset(): Matrix;
  16825. /**
  16826. * Adds the current matrix with a second one
  16827. * @param other defines the matrix to add
  16828. * @returns a new matrix as the addition of the current matrix and the given one
  16829. */
  16830. add(other: Matrix): Matrix;
  16831. /**
  16832. * Sets the given matrix "result" to the addition of the current matrix and the given one
  16833. * @param other defines the matrix to add
  16834. * @param result defines the target matrix
  16835. * @returns the current matrix
  16836. */
  16837. addToRef(other: Matrix, result: Matrix): Matrix;
  16838. /**
  16839. * Adds in place the given matrix to the current matrix
  16840. * @param other defines the second operand
  16841. * @returns the current updated matrix
  16842. */
  16843. addToSelf(other: Matrix): Matrix;
  16844. /**
  16845. * Sets the given matrix to the current inverted Matrix
  16846. * @param other defines the target matrix
  16847. * @returns the unmodified current matrix
  16848. */
  16849. invertToRef(other: Matrix): Matrix;
  16850. /**
  16851. * Inserts the translation vector (using 3 floats) in the current matrix
  16852. * @param x defines the 1st component of the translation
  16853. * @param y defines the 2nd component of the translation
  16854. * @param z defines the 3rd component of the translation
  16855. * @returns the current updated matrix
  16856. */
  16857. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  16858. /**
  16859. * Inserts the translation vector in the current matrix
  16860. * @param vector3 defines the translation to insert
  16861. * @returns the current updated matrix
  16862. */
  16863. setTranslation(vector3: Vector3): Matrix;
  16864. /**
  16865. * Gets the translation value of the current matrix
  16866. * @returns a new Vector3 as the extracted translation from the matrix
  16867. */
  16868. getTranslation(): Vector3;
  16869. /**
  16870. * Fill a Vector3 with the extracted translation from the matrix
  16871. * @param result defines the Vector3 where to store the translation
  16872. * @returns the current matrix
  16873. */
  16874. getTranslationToRef(result: Vector3): Matrix;
  16875. /**
  16876. * Remove rotation and scaling part from the matrix
  16877. * @returns the updated matrix
  16878. */
  16879. removeRotationAndScaling(): Matrix;
  16880. /**
  16881. * Multiply two matrices
  16882. * @param other defines the second operand
  16883. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  16884. */
  16885. multiply(other: Matrix): Matrix;
  16886. /**
  16887. * Copy the current matrix from the given one
  16888. * @param other defines the source matrix
  16889. * @returns the current updated matrix
  16890. */
  16891. copyFrom(other: Matrix): Matrix;
  16892. /**
  16893. * Populates the given array from the starting index with the current matrix values
  16894. * @param array defines the target array
  16895. * @param offset defines the offset in the target array where to start storing values
  16896. * @returns the current matrix
  16897. */
  16898. copyToArray(array: Float32Array, offset?: number): Matrix;
  16899. /**
  16900. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  16901. * @param other defines the second operand
  16902. * @param result defines the matrix where to store the multiplication
  16903. * @returns the current matrix
  16904. */
  16905. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  16906. /**
  16907. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  16908. * @param other defines the second operand
  16909. * @param result defines the array where to store the multiplication
  16910. * @param offset defines the offset in the target array where to start storing values
  16911. * @returns the current matrix
  16912. */
  16913. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  16914. /**
  16915. * Check equality between this matrix and a second one
  16916. * @param value defines the second matrix to compare
  16917. * @returns true is the current matrix and the given one values are strictly equal
  16918. */
  16919. equals(value: Matrix): boolean;
  16920. /**
  16921. * Clone the current matrix
  16922. * @returns a new matrix from the current matrix
  16923. */
  16924. clone(): Matrix;
  16925. /**
  16926. * Returns the name of the current matrix class
  16927. * @returns the string "Matrix"
  16928. */
  16929. getClassName(): string;
  16930. /**
  16931. * Gets the hash code of the current matrix
  16932. * @returns the hash code
  16933. */
  16934. getHashCode(): number;
  16935. /**
  16936. * Decomposes the current Matrix into a translation, rotation and scaling components
  16937. * @param scale defines the scale vector3 given as a reference to update
  16938. * @param rotation defines the rotation quaternion given as a reference to update
  16939. * @param translation defines the translation vector3 given as a reference to update
  16940. * @returns true if operation was successful
  16941. */
  16942. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  16943. /**
  16944. * Gets specific row of the matrix
  16945. * @param index defines the number of the row to get
  16946. * @returns the index-th row of the current matrix as a new Vector4
  16947. */
  16948. getRow(index: number): Nullable<Vector4>;
  16949. /**
  16950. * Sets the index-th row of the current matrix to the vector4 values
  16951. * @param index defines the number of the row to set
  16952. * @param row defines the target vector4
  16953. * @returns the updated current matrix
  16954. */
  16955. setRow(index: number, row: Vector4): Matrix;
  16956. /**
  16957. * Compute the transpose of the matrix
  16958. * @returns the new transposed matrix
  16959. */
  16960. transpose(): Matrix;
  16961. /**
  16962. * Compute the transpose of the matrix and store it in a given matrix
  16963. * @param result defines the target matrix
  16964. * @returns the current matrix
  16965. */
  16966. transposeToRef(result: Matrix): Matrix;
  16967. /**
  16968. * Sets the index-th row of the current matrix with the given 4 x float values
  16969. * @param index defines the row index
  16970. * @param x defines the x component to set
  16971. * @param y defines the y component to set
  16972. * @param z defines the z component to set
  16973. * @param w defines the w component to set
  16974. * @returns the updated current matrix
  16975. */
  16976. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  16977. /**
  16978. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  16979. * @param scale defines the scale factor
  16980. * @returns a new matrix
  16981. */
  16982. scale(scale: number): Matrix;
  16983. /**
  16984. * Scale the current matrix values by a factor to a given result matrix
  16985. * @param scale defines the scale factor
  16986. * @param result defines the matrix to store the result
  16987. * @returns the current matrix
  16988. */
  16989. scaleToRef(scale: number, result: Matrix): Matrix;
  16990. /**
  16991. * Scale the current matrix values by a factor and add the result to a given matrix
  16992. * @param scale defines the scale factor
  16993. * @param result defines the Matrix to store the result
  16994. * @returns the current matrix
  16995. */
  16996. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  16997. /**
  16998. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  16999. * @param ref matrix to store the result
  17000. */
  17001. toNormalMatrix(ref: Matrix): void;
  17002. /**
  17003. * Gets only rotation part of the current matrix
  17004. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17005. */
  17006. getRotationMatrix(): Matrix;
  17007. /**
  17008. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17009. * @param result defines the target matrix to store data to
  17010. * @returns the current matrix
  17011. */
  17012. getRotationMatrixToRef(result: Matrix): Matrix;
  17013. /**
  17014. * Creates a matrix from an array
  17015. * @param array defines the source array
  17016. * @param offset defines an offset in the source array
  17017. * @returns a new Matrix set from the starting index of the given array
  17018. */
  17019. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17020. /**
  17021. * Copy the content of an array into a given matrix
  17022. * @param array defines the source array
  17023. * @param offset defines an offset in the source array
  17024. * @param result defines the target matrix
  17025. */
  17026. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17027. /**
  17028. * Stores an array into a matrix after having multiplied each component by a given factor
  17029. * @param array defines the source array
  17030. * @param offset defines the offset in the source array
  17031. * @param scale defines the scaling factor
  17032. * @param result defines the target matrix
  17033. */
  17034. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17035. /**
  17036. * Stores a list of values (16) inside a given matrix
  17037. * @param initialM11 defines 1st value of 1st row
  17038. * @param initialM12 defines 2nd value of 1st row
  17039. * @param initialM13 defines 3rd value of 1st row
  17040. * @param initialM14 defines 4th value of 1st row
  17041. * @param initialM21 defines 1st value of 2nd row
  17042. * @param initialM22 defines 2nd value of 2nd row
  17043. * @param initialM23 defines 3rd value of 2nd row
  17044. * @param initialM24 defines 4th value of 2nd row
  17045. * @param initialM31 defines 1st value of 3rd row
  17046. * @param initialM32 defines 2nd value of 3rd row
  17047. * @param initialM33 defines 3rd value of 3rd row
  17048. * @param initialM34 defines 4th value of 3rd row
  17049. * @param initialM41 defines 1st value of 4th row
  17050. * @param initialM42 defines 2nd value of 4th row
  17051. * @param initialM43 defines 3rd value of 4th row
  17052. * @param initialM44 defines 4th value of 4th row
  17053. * @param result defines the target matrix
  17054. */
  17055. 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;
  17056. /**
  17057. * Gets an identity matrix that must not be updated
  17058. */
  17059. static readonly IdentityReadOnly: Matrix;
  17060. /**
  17061. * Creates new matrix from a list of values (16)
  17062. * @param initialM11 defines 1st value of 1st row
  17063. * @param initialM12 defines 2nd value of 1st row
  17064. * @param initialM13 defines 3rd value of 1st row
  17065. * @param initialM14 defines 4th value of 1st row
  17066. * @param initialM21 defines 1st value of 2nd row
  17067. * @param initialM22 defines 2nd value of 2nd row
  17068. * @param initialM23 defines 3rd value of 2nd row
  17069. * @param initialM24 defines 4th value of 2nd row
  17070. * @param initialM31 defines 1st value of 3rd row
  17071. * @param initialM32 defines 2nd value of 3rd row
  17072. * @param initialM33 defines 3rd value of 3rd row
  17073. * @param initialM34 defines 4th value of 3rd row
  17074. * @param initialM41 defines 1st value of 4th row
  17075. * @param initialM42 defines 2nd value of 4th row
  17076. * @param initialM43 defines 3rd value of 4th row
  17077. * @param initialM44 defines 4th value of 4th row
  17078. * @returns the new matrix
  17079. */
  17080. 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;
  17081. /**
  17082. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17083. * @param scale defines the scale vector3
  17084. * @param rotation defines the rotation quaternion
  17085. * @param translation defines the translation vector3
  17086. * @returns a new matrix
  17087. */
  17088. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17089. /**
  17090. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17091. * @param scale defines the scale vector3
  17092. * @param rotation defines the rotation quaternion
  17093. * @param translation defines the translation vector3
  17094. * @param result defines the target matrix
  17095. */
  17096. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17097. /**
  17098. * Creates a new identity matrix
  17099. * @returns a new identity matrix
  17100. */
  17101. static Identity(): Matrix;
  17102. /**
  17103. * Creates a new identity matrix and stores the result in a given matrix
  17104. * @param result defines the target matrix
  17105. */
  17106. static IdentityToRef(result: Matrix): void;
  17107. /**
  17108. * Creates a new zero matrix
  17109. * @returns a new zero matrix
  17110. */
  17111. static Zero(): Matrix;
  17112. /**
  17113. * Creates a new rotation matrix for "angle" radians around the X axis
  17114. * @param angle defines the angle (in radians) to use
  17115. * @return the new matrix
  17116. */
  17117. static RotationX(angle: number): Matrix;
  17118. /**
  17119. * Creates a new matrix as the invert of a given matrix
  17120. * @param source defines the source matrix
  17121. * @returns the new matrix
  17122. */
  17123. static Invert(source: Matrix): Matrix;
  17124. /**
  17125. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17126. * @param angle defines the angle (in radians) to use
  17127. * @param result defines the target matrix
  17128. */
  17129. static RotationXToRef(angle: number, result: Matrix): void;
  17130. /**
  17131. * Creates a new rotation matrix for "angle" radians around the Y axis
  17132. * @param angle defines the angle (in radians) to use
  17133. * @return the new matrix
  17134. */
  17135. static RotationY(angle: number): Matrix;
  17136. /**
  17137. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17138. * @param angle defines the angle (in radians) to use
  17139. * @param result defines the target matrix
  17140. */
  17141. static RotationYToRef(angle: number, result: Matrix): void;
  17142. /**
  17143. * Creates a new rotation matrix for "angle" radians around the Z axis
  17144. * @param angle defines the angle (in radians) to use
  17145. * @return the new matrix
  17146. */
  17147. static RotationZ(angle: number): Matrix;
  17148. /**
  17149. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17150. * @param angle defines the angle (in radians) to use
  17151. * @param result defines the target matrix
  17152. */
  17153. static RotationZToRef(angle: number, result: Matrix): void;
  17154. /**
  17155. * Creates a new rotation matrix for "angle" radians around the given axis
  17156. * @param axis defines the axis to use
  17157. * @param angle defines the angle (in radians) to use
  17158. * @return the new matrix
  17159. */
  17160. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17161. /**
  17162. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17163. * @param axis defines the axis to use
  17164. * @param angle defines the angle (in radians) to use
  17165. * @param result defines the target matrix
  17166. */
  17167. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17168. /**
  17169. * Creates a rotation matrix
  17170. * @param yaw defines the yaw angle in radians (Y axis)
  17171. * @param pitch defines the pitch angle in radians (X axis)
  17172. * @param roll defines the roll angle in radians (X axis)
  17173. * @returns the new rotation matrix
  17174. */
  17175. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17176. /**
  17177. * Creates a rotation matrix and stores it in a given matrix
  17178. * @param yaw defines the yaw angle in radians (Y axis)
  17179. * @param pitch defines the pitch angle in radians (X axis)
  17180. * @param roll defines the roll angle in radians (X axis)
  17181. * @param result defines the target matrix
  17182. */
  17183. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17184. /**
  17185. * Creates a scaling matrix
  17186. * @param x defines the scale factor on X axis
  17187. * @param y defines the scale factor on Y axis
  17188. * @param z defines the scale factor on Z axis
  17189. * @returns the new matrix
  17190. */
  17191. static Scaling(x: number, y: number, z: number): Matrix;
  17192. /**
  17193. * Creates a scaling matrix and stores it in a given matrix
  17194. * @param x defines the scale factor on X axis
  17195. * @param y defines the scale factor on Y axis
  17196. * @param z defines the scale factor on Z axis
  17197. * @param result defines the target matrix
  17198. */
  17199. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17200. /**
  17201. * Creates a translation matrix
  17202. * @param x defines the translation on X axis
  17203. * @param y defines the translation on Y axis
  17204. * @param z defines the translationon Z axis
  17205. * @returns the new matrix
  17206. */
  17207. static Translation(x: number, y: number, z: number): Matrix;
  17208. /**
  17209. * Creates a translation matrix and stores it in a given matrix
  17210. * @param x defines the translation on X axis
  17211. * @param y defines the translation on Y axis
  17212. * @param z defines the translationon Z axis
  17213. * @param result defines the target matrix
  17214. */
  17215. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17216. /**
  17217. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17218. * @param startValue defines the start value
  17219. * @param endValue defines the end value
  17220. * @param gradient defines the gradient factor
  17221. * @returns the new matrix
  17222. */
  17223. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17224. /**
  17225. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17226. * @param startValue defines the start value
  17227. * @param endValue defines the end value
  17228. * @param gradient defines the gradient factor
  17229. * @param result defines the Matrix object where to store data
  17230. */
  17231. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17232. /**
  17233. * Builds a new matrix whose values are computed by:
  17234. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17235. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17236. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17237. * @param startValue defines the first matrix
  17238. * @param endValue defines the second matrix
  17239. * @param gradient defines the gradient between the two matrices
  17240. * @returns the new matrix
  17241. */
  17242. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17243. /**
  17244. * Update a matrix to values which are computed by:
  17245. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17246. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17247. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17248. * @param startValue defines the first matrix
  17249. * @param endValue defines the second matrix
  17250. * @param gradient defines the gradient between the two matrices
  17251. * @param result defines the target matrix
  17252. */
  17253. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17254. /**
  17255. * 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"
  17256. * This function works in left handed mode
  17257. * @param eye defines the final position of the entity
  17258. * @param target defines where the entity should look at
  17259. * @param up defines the up vector for the entity
  17260. * @returns the new matrix
  17261. */
  17262. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17263. /**
  17264. * 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".
  17265. * This function works in left handed mode
  17266. * @param eye defines the final position of the entity
  17267. * @param target defines where the entity should look at
  17268. * @param up defines the up vector for the entity
  17269. * @param result defines the target matrix
  17270. */
  17271. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17272. /**
  17273. * 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"
  17274. * This function works in right handed mode
  17275. * @param eye defines the final position of the entity
  17276. * @param target defines where the entity should look at
  17277. * @param up defines the up vector for the entity
  17278. * @returns the new matrix
  17279. */
  17280. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17281. /**
  17282. * 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".
  17283. * This function works in right handed mode
  17284. * @param eye defines the final position of the entity
  17285. * @param target defines where the entity should look at
  17286. * @param up defines the up vector for the entity
  17287. * @param result defines the target matrix
  17288. */
  17289. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17290. /**
  17291. * Create a left-handed orthographic projection matrix
  17292. * @param width defines the viewport width
  17293. * @param height defines the viewport height
  17294. * @param znear defines the near clip plane
  17295. * @param zfar defines the far clip plane
  17296. * @returns a new matrix as a left-handed orthographic projection matrix
  17297. */
  17298. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17299. /**
  17300. * Store a left-handed orthographic projection to a given matrix
  17301. * @param width defines the viewport width
  17302. * @param height defines the viewport height
  17303. * @param znear defines the near clip plane
  17304. * @param zfar defines the far clip plane
  17305. * @param result defines the target matrix
  17306. */
  17307. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17308. /**
  17309. * Create a left-handed orthographic projection matrix
  17310. * @param left defines the viewport left coordinate
  17311. * @param right defines the viewport right coordinate
  17312. * @param bottom defines the viewport bottom coordinate
  17313. * @param top defines the viewport top coordinate
  17314. * @param znear defines the near clip plane
  17315. * @param zfar defines the far clip plane
  17316. * @returns a new matrix as a left-handed orthographic projection matrix
  17317. */
  17318. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17319. /**
  17320. * Stores a left-handed orthographic projection into a given matrix
  17321. * @param left defines the viewport left coordinate
  17322. * @param right defines the viewport right coordinate
  17323. * @param bottom defines the viewport bottom coordinate
  17324. * @param top defines the viewport top coordinate
  17325. * @param znear defines the near clip plane
  17326. * @param zfar defines the far clip plane
  17327. * @param result defines the target matrix
  17328. */
  17329. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17330. /**
  17331. * Creates a right-handed orthographic projection matrix
  17332. * @param left defines the viewport left coordinate
  17333. * @param right defines the viewport right coordinate
  17334. * @param bottom defines the viewport bottom coordinate
  17335. * @param top defines the viewport top coordinate
  17336. * @param znear defines the near clip plane
  17337. * @param zfar defines the far clip plane
  17338. * @returns a new matrix as a right-handed orthographic projection matrix
  17339. */
  17340. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17341. /**
  17342. * Stores a right-handed orthographic projection into a given matrix
  17343. * @param left defines the viewport left coordinate
  17344. * @param right defines the viewport right coordinate
  17345. * @param bottom defines the viewport bottom coordinate
  17346. * @param top defines the viewport top coordinate
  17347. * @param znear defines the near clip plane
  17348. * @param zfar defines the far clip plane
  17349. * @param result defines the target matrix
  17350. */
  17351. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17352. /**
  17353. * Creates a left-handed perspective projection matrix
  17354. * @param width defines the viewport width
  17355. * @param height defines the viewport height
  17356. * @param znear defines the near clip plane
  17357. * @param zfar defines the far clip plane
  17358. * @returns a new matrix as a left-handed perspective projection matrix
  17359. */
  17360. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17361. /**
  17362. * Creates a left-handed perspective projection matrix
  17363. * @param fov defines the horizontal field of view
  17364. * @param aspect defines the aspect ratio
  17365. * @param znear defines the near clip plane
  17366. * @param zfar defines the far clip plane
  17367. * @returns a new matrix as a left-handed perspective projection matrix
  17368. */
  17369. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17370. /**
  17371. * Stores a left-handed perspective projection into a given matrix
  17372. * @param fov defines the horizontal field of view
  17373. * @param aspect defines the aspect ratio
  17374. * @param znear defines the near clip plane
  17375. * @param zfar defines the far clip plane
  17376. * @param result defines the target matrix
  17377. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17378. */
  17379. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17380. /**
  17381. * Creates a right-handed perspective projection matrix
  17382. * @param fov defines the horizontal field of view
  17383. * @param aspect defines the aspect ratio
  17384. * @param znear defines the near clip plane
  17385. * @param zfar defines the far clip plane
  17386. * @returns a new matrix as a right-handed perspective projection matrix
  17387. */
  17388. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17389. /**
  17390. * Stores a right-handed perspective projection into a given matrix
  17391. * @param fov defines the horizontal field of view
  17392. * @param aspect defines the aspect ratio
  17393. * @param znear defines the near clip plane
  17394. * @param zfar defines the far clip plane
  17395. * @param result defines the target matrix
  17396. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17397. */
  17398. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17399. /**
  17400. * Stores a perspective projection for WebVR info a given matrix
  17401. * @param fov defines the field of view
  17402. * @param znear defines the near clip plane
  17403. * @param zfar defines the far clip plane
  17404. * @param result defines the target matrix
  17405. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17406. */
  17407. static PerspectiveFovWebVRToRef(fov: {
  17408. upDegrees: number;
  17409. downDegrees: number;
  17410. leftDegrees: number;
  17411. rightDegrees: number;
  17412. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17413. /**
  17414. * Computes a complete transformation matrix
  17415. * @param viewport defines the viewport to use
  17416. * @param world defines the world matrix
  17417. * @param view defines the view matrix
  17418. * @param projection defines the projection matrix
  17419. * @param zmin defines the near clip plane
  17420. * @param zmax defines the far clip plane
  17421. * @returns the transformation matrix
  17422. */
  17423. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17424. /**
  17425. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17426. * @param matrix defines the matrix to use
  17427. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17428. */
  17429. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17430. /**
  17431. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17432. * @param matrix defines the matrix to use
  17433. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17434. */
  17435. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17436. /**
  17437. * Compute the transpose of a given matrix
  17438. * @param matrix defines the matrix to transpose
  17439. * @returns the new matrix
  17440. */
  17441. static Transpose(matrix: Matrix): Matrix;
  17442. /**
  17443. * Compute the transpose of a matrix and store it in a target matrix
  17444. * @param matrix defines the matrix to transpose
  17445. * @param result defines the target matrix
  17446. */
  17447. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17448. /**
  17449. * Computes a reflection matrix from a plane
  17450. * @param plane defines the reflection plane
  17451. * @returns a new matrix
  17452. */
  17453. static Reflection(plane: Plane): Matrix;
  17454. /**
  17455. * Computes a reflection matrix from a plane
  17456. * @param plane defines the reflection plane
  17457. * @param result defines the target matrix
  17458. */
  17459. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17460. /**
  17461. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17462. * @param xaxis defines the value of the 1st axis
  17463. * @param yaxis defines the value of the 2nd axis
  17464. * @param zaxis defines the value of the 3rd axis
  17465. * @param result defines the target matrix
  17466. */
  17467. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17468. /**
  17469. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17470. * @param quat defines the quaternion to use
  17471. * @param result defines the target matrix
  17472. */
  17473. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17474. }
  17475. class Plane {
  17476. normal: Vector3;
  17477. d: number;
  17478. /**
  17479. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17480. */
  17481. constructor(a: number, b: number, c: number, d: number);
  17482. /**
  17483. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17484. */
  17485. asArray(): number[];
  17486. /**
  17487. * Returns a new plane copied from the current Plane.
  17488. */
  17489. clone(): Plane;
  17490. /**
  17491. * Returns the string "Plane".
  17492. */
  17493. getClassName(): string;
  17494. /**
  17495. * Returns the Plane hash code.
  17496. */
  17497. getHashCode(): number;
  17498. /**
  17499. * Normalize the current Plane in place.
  17500. * Returns the updated Plane.
  17501. */
  17502. normalize(): Plane;
  17503. /**
  17504. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17505. */
  17506. transform(transformation: Matrix): Plane;
  17507. /**
  17508. * Returns the dot product (float) of the point coordinates and the plane normal.
  17509. */
  17510. dotCoordinate(point: Vector3): number;
  17511. /**
  17512. * Updates the current Plane from the plane defined by the three given points.
  17513. * Returns the updated Plane.
  17514. */
  17515. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17516. /**
  17517. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17518. */
  17519. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17520. /**
  17521. * Returns the signed distance (float) from the given point to the Plane.
  17522. */
  17523. signedDistanceTo(point: Vector3): number;
  17524. /**
  17525. * Returns a new Plane from the given array.
  17526. */
  17527. static FromArray(array: ArrayLike<number>): Plane;
  17528. /**
  17529. * Returns a new Plane defined by the three given points.
  17530. */
  17531. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17532. /**
  17533. * Returns a new Plane the normal vector to this plane at the given origin point.
  17534. * Note : the vector "normal" is updated because normalized.
  17535. */
  17536. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17537. /**
  17538. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17539. */
  17540. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17541. }
  17542. class Viewport {
  17543. x: number;
  17544. y: number;
  17545. width: number;
  17546. height: number;
  17547. /**
  17548. * Creates a Viewport object located at (x, y) and sized (width, height).
  17549. */
  17550. constructor(x: number, y: number, width: number, height: number);
  17551. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17552. /**
  17553. * Returns a new Viewport copied from the current one.
  17554. */
  17555. clone(): Viewport;
  17556. }
  17557. class Frustum {
  17558. /**
  17559. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17560. */
  17561. static GetPlanes(transform: Matrix): Plane[];
  17562. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17563. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17564. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17565. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17566. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17567. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17568. /**
  17569. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17570. */
  17571. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17572. }
  17573. /** Defines supported spaces */
  17574. enum Space {
  17575. /** Local (object) space */
  17576. LOCAL = 0,
  17577. /** World space */
  17578. WORLD = 1,
  17579. /** Bone space */
  17580. BONE = 2,
  17581. }
  17582. /** Defines the 3 main axes */
  17583. class Axis {
  17584. /** X axis */
  17585. static X: Vector3;
  17586. /** Y axis */
  17587. static Y: Vector3;
  17588. /** Z axis */
  17589. static Z: Vector3;
  17590. }
  17591. class BezierCurve {
  17592. /**
  17593. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17594. */
  17595. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17596. }
  17597. /**
  17598. * Defines potential orientation for back face culling
  17599. */
  17600. enum Orientation {
  17601. /**
  17602. * Clockwise
  17603. */
  17604. CW = 0,
  17605. /** Counter clockwise */
  17606. CCW = 1,
  17607. }
  17608. /**
  17609. * Defines angle representation
  17610. */
  17611. class Angle {
  17612. private _radians;
  17613. /**
  17614. * Creates an Angle object of "radians" radians (float).
  17615. */
  17616. constructor(radians: number);
  17617. /**
  17618. * Get value in degrees
  17619. * @returns the Angle value in degrees (float)
  17620. */
  17621. degrees(): number;
  17622. /**
  17623. * Get value in radians
  17624. * @returns the Angle value in radians (float)
  17625. */
  17626. radians(): number;
  17627. /**
  17628. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17629. * @param a defines first vector
  17630. * @param b defines second vector
  17631. * @returns a new Angle
  17632. */
  17633. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17634. /**
  17635. * Gets a new Angle object from the given float in radians
  17636. * @param radians defines the angle value in radians
  17637. * @returns a new Angle
  17638. */
  17639. static FromRadians(radians: number): Angle;
  17640. /**
  17641. * Gets a new Angle object from the given float in degrees
  17642. * @param degrees defines the angle value in degrees
  17643. * @returns a new Angle
  17644. */
  17645. static FromDegrees(degrees: number): Angle;
  17646. }
  17647. class Arc2 {
  17648. startPoint: Vector2;
  17649. midPoint: Vector2;
  17650. endPoint: Vector2;
  17651. centerPoint: Vector2;
  17652. radius: number;
  17653. angle: Angle;
  17654. startAngle: Angle;
  17655. orientation: Orientation;
  17656. /**
  17657. * Creates an Arc object from the three given points : start, middle and end.
  17658. */
  17659. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17660. }
  17661. class Path2 {
  17662. private _points;
  17663. private _length;
  17664. closed: boolean;
  17665. /**
  17666. * Creates a Path2 object from the starting 2D coordinates x and y.
  17667. */
  17668. constructor(x: number, y: number);
  17669. /**
  17670. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17671. * Returns the updated Path2.
  17672. */
  17673. addLineTo(x: number, y: number): Path2;
  17674. /**
  17675. * 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.
  17676. * Returns the updated Path2.
  17677. */
  17678. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17679. /**
  17680. * Closes the Path2.
  17681. * Returns the Path2.
  17682. */
  17683. close(): Path2;
  17684. /**
  17685. * Returns the Path2 total length (float).
  17686. */
  17687. length(): number;
  17688. /**
  17689. * Returns the Path2 internal array of points.
  17690. */
  17691. getPoints(): Vector2[];
  17692. /**
  17693. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17694. */
  17695. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17696. /**
  17697. * Returns a new Path2 starting at the coordinates (x, y).
  17698. */
  17699. static StartingAt(x: number, y: number): Path2;
  17700. }
  17701. class Path3D {
  17702. path: Vector3[];
  17703. private _curve;
  17704. private _distances;
  17705. private _tangents;
  17706. private _normals;
  17707. private _binormals;
  17708. private _raw;
  17709. /**
  17710. * new Path3D(path, normal, raw)
  17711. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  17712. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  17713. * path : an array of Vector3, the curve axis of the Path3D
  17714. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  17715. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  17716. */
  17717. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  17718. /**
  17719. * Returns the Path3D array of successive Vector3 designing its curve.
  17720. */
  17721. getCurve(): Vector3[];
  17722. /**
  17723. * Returns an array populated with tangent vectors on each Path3D curve point.
  17724. */
  17725. getTangents(): Vector3[];
  17726. /**
  17727. * Returns an array populated with normal vectors on each Path3D curve point.
  17728. */
  17729. getNormals(): Vector3[];
  17730. /**
  17731. * Returns an array populated with binormal vectors on each Path3D curve point.
  17732. */
  17733. getBinormals(): Vector3[];
  17734. /**
  17735. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  17736. */
  17737. getDistances(): number[];
  17738. /**
  17739. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  17740. * Returns the same object updated.
  17741. */
  17742. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  17743. private _compute(firstNormal);
  17744. private _getFirstNonNullVector(index);
  17745. private _getLastNonNullVector(index);
  17746. private _normalVector(v0, vt, va);
  17747. }
  17748. class Curve3 {
  17749. private _points;
  17750. private _length;
  17751. /**
  17752. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  17753. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  17754. * @param v1 (Vector3) the control point
  17755. * @param v2 (Vector3) the end point of the Quadratic Bezier
  17756. * @param nbPoints (integer) the wanted number of points in the curve
  17757. */
  17758. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  17759. /**
  17760. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  17761. * @param v0 (Vector3) the origin point of the Cubic Bezier
  17762. * @param v1 (Vector3) the first control point
  17763. * @param v2 (Vector3) the second control point
  17764. * @param v3 (Vector3) the end point of the Cubic Bezier
  17765. * @param nbPoints (integer) the wanted number of points in the curve
  17766. */
  17767. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  17768. /**
  17769. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  17770. * @param p1 (Vector3) the origin point of the Hermite Spline
  17771. * @param t1 (Vector3) the tangent vector at the origin point
  17772. * @param p2 (Vector3) the end point of the Hermite Spline
  17773. * @param t2 (Vector3) the tangent vector at the end point
  17774. * @param nbPoints (integer) the wanted number of points in the curve
  17775. */
  17776. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  17777. /**
  17778. * Returns a Curve3 object along a CatmullRom Spline curve :
  17779. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  17780. * @param nbPoints (integer) the wanted number of points between each curve control points
  17781. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  17782. */
  17783. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  17784. /**
  17785. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  17786. * A Curve3 is designed from a series of successive Vector3.
  17787. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  17788. */
  17789. constructor(points: Vector3[]);
  17790. /**
  17791. * Returns the Curve3 stored array of successive Vector3
  17792. */
  17793. getPoints(): Vector3[];
  17794. /**
  17795. * Returns the computed length (float) of the curve.
  17796. */
  17797. length(): number;
  17798. /**
  17799. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  17800. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  17801. * curveA and curveB keep unchanged.
  17802. */
  17803. continue(curve: Curve3): Curve3;
  17804. private _computeLength(path);
  17805. }
  17806. class PositionNormalVertex {
  17807. position: Vector3;
  17808. normal: Vector3;
  17809. constructor(position?: Vector3, normal?: Vector3);
  17810. clone(): PositionNormalVertex;
  17811. }
  17812. class PositionNormalTextureVertex {
  17813. position: Vector3;
  17814. normal: Vector3;
  17815. uv: Vector2;
  17816. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  17817. clone(): PositionNormalTextureVertex;
  17818. }
  17819. class Tmp {
  17820. static Color3: Color3[];
  17821. static Vector2: Vector2[];
  17822. static Vector3: Vector3[];
  17823. static Vector4: Vector4[];
  17824. static Quaternion: Quaternion[];
  17825. static Matrix: Matrix[];
  17826. }
  17827. }
  17828. declare module BABYLON {
  17829. class SphericalPolynomial {
  17830. x: Vector3;
  17831. y: Vector3;
  17832. z: Vector3;
  17833. xx: Vector3;
  17834. yy: Vector3;
  17835. zz: Vector3;
  17836. xy: Vector3;
  17837. yz: Vector3;
  17838. zx: Vector3;
  17839. addAmbient(color: Color3): void;
  17840. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  17841. scale(scale: number): void;
  17842. }
  17843. class SphericalHarmonics {
  17844. L00: Vector3;
  17845. L1_1: Vector3;
  17846. L10: Vector3;
  17847. L11: Vector3;
  17848. L2_2: Vector3;
  17849. L2_1: Vector3;
  17850. L20: Vector3;
  17851. L21: Vector3;
  17852. L22: Vector3;
  17853. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  17854. scale(scale: number): void;
  17855. convertIncidentRadianceToIrradiance(): void;
  17856. convertIrradianceToLambertianRadiance(): void;
  17857. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  17858. }
  17859. }
  17860. declare module BABYLON {
  17861. /**
  17862. * This represents a GPU particle system in Babylon
  17863. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17864. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17865. */
  17866. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17867. /**
  17868. * The id of the Particle system.
  17869. */
  17870. id: string;
  17871. /**
  17872. * The friendly name of the Particle system.
  17873. */
  17874. name: string;
  17875. /**
  17876. * The emitter represents the Mesh or position we are attaching the particle system to.
  17877. */
  17878. emitter: Nullable<AbstractMesh | Vector3>;
  17879. /**
  17880. * The rendering group used by the Particle system to chose when to render.
  17881. */
  17882. renderingGroupId: number;
  17883. /**
  17884. * The layer mask we are rendering the particles through.
  17885. */
  17886. layerMask: number;
  17887. private _capacity;
  17888. private _activeCount;
  17889. private _currentActiveCount;
  17890. private _renderEffect;
  17891. private _updateEffect;
  17892. private _buffer0;
  17893. private _buffer1;
  17894. private _spriteBuffer;
  17895. private _updateVAO;
  17896. private _renderVAO;
  17897. private _targetIndex;
  17898. private _sourceBuffer;
  17899. private _targetBuffer;
  17900. private _scene;
  17901. private _engine;
  17902. private _currentRenderId;
  17903. private _started;
  17904. private _stopped;
  17905. private _timeDelta;
  17906. private _randomTexture;
  17907. private readonly _attributesStrideSize;
  17908. private _updateEffectOptions;
  17909. private _randomTextureSize;
  17910. private _actualFrame;
  17911. /**
  17912. * List of animations used by the particle system.
  17913. */
  17914. animations: Animation[];
  17915. /**
  17916. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17917. */
  17918. static readonly IsSupported: boolean;
  17919. /**
  17920. * An event triggered when the system is disposed.
  17921. */
  17922. onDisposeObservable: Observable<GPUParticleSystem>;
  17923. /**
  17924. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17925. */
  17926. updateSpeed: number;
  17927. /**
  17928. * The amount of time the particle system is running (depends of the overall update speed).
  17929. */
  17930. targetStopDuration: number;
  17931. /**
  17932. * The texture used to render each particle. (this can be a spritesheet)
  17933. */
  17934. particleTexture: Nullable<Texture>;
  17935. /**
  17936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17937. */
  17938. blendMode: number;
  17939. /**
  17940. * Minimum life time of emitting particles.
  17941. */
  17942. minLifeTime: number;
  17943. /**
  17944. * Maximum life time of emitting particles.
  17945. */
  17946. maxLifeTime: number;
  17947. /**
  17948. * Minimum Size of emitting particles.
  17949. */
  17950. minSize: number;
  17951. /**
  17952. * Maximum Size of emitting particles.
  17953. */
  17954. maxSize: number;
  17955. /**
  17956. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17957. */
  17958. color1: Color4;
  17959. /**
  17960. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17961. */
  17962. color2: Color4;
  17963. /**
  17964. * Color the particle will have at the end of its lifetime.
  17965. */
  17966. colorDead: Color4;
  17967. /**
  17968. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17969. */
  17970. emitRate: number;
  17971. /**
  17972. * You can use gravity if you want to give an orientation to your particles.
  17973. */
  17974. gravity: Vector3;
  17975. /**
  17976. * Minimum power of emitting particles.
  17977. */
  17978. minEmitPower: number;
  17979. /**
  17980. * Maximum power of emitting particles.
  17981. */
  17982. maxEmitPower: number;
  17983. /**
  17984. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17985. */
  17986. minAngularSpeed: number;
  17987. /**
  17988. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17989. */
  17990. maxAngularSpeed: number;
  17991. /**
  17992. * The particle emitter type defines the emitter used by the particle system.
  17993. * It can be for example box, sphere, or cone...
  17994. */
  17995. particleEmitterType: Nullable<IParticleEmitterType>;
  17996. /**
  17997. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17998. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17999. */
  18000. direction1: Vector3;
  18001. /**
  18002. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18003. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18004. */
  18005. direction2: Vector3;
  18006. /**
  18007. * 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.
  18008. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18009. */
  18010. minEmitBox: Vector3;
  18011. /**
  18012. * 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.
  18013. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18014. */
  18015. maxEmitBox: Vector3;
  18016. /**
  18017. * Gets the maximum number of particles active at the same time.
  18018. * @returns The max number of active particles.
  18019. */
  18020. getCapacity(): number;
  18021. /**
  18022. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18023. * to override the particles.
  18024. */
  18025. forceDepthWrite: boolean;
  18026. /**
  18027. * Gets or set the number of active particles
  18028. */
  18029. activeParticleCount: number;
  18030. /**
  18031. * Is this system ready to be used/rendered
  18032. * @return true if the system is ready
  18033. */
  18034. isReady(): boolean;
  18035. /**
  18036. * Gets Wether the system has been started.
  18037. * @returns True if it has been started, otherwise false.
  18038. */
  18039. isStarted(): boolean;
  18040. /**
  18041. * Starts the particle system and begins to emit.
  18042. */
  18043. start(): void;
  18044. /**
  18045. * Stops the particle system.
  18046. */
  18047. stop(): void;
  18048. /**
  18049. * Remove all active particles
  18050. */
  18051. reset(): void;
  18052. /**
  18053. * Returns the string "GPUParticleSystem"
  18054. * @returns a string containing the class name
  18055. */
  18056. getClassName(): string;
  18057. /**
  18058. * Instantiates a GPU particle system.
  18059. * 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.
  18060. * @param name The name of the particle system
  18061. * @param capacity The max number of particles alive at the same time
  18062. * @param scene The scene the particle system belongs to
  18063. */
  18064. constructor(name: string, options: Partial<{
  18065. capacity: number;
  18066. randomTextureSize: number;
  18067. }>, scene: Scene);
  18068. private _createUpdateVAO(source);
  18069. private _createRenderVAO(source, spriteSource);
  18070. private _initialize(force?);
  18071. /** @hidden */
  18072. _recreateUpdateEffect(): void;
  18073. /** @hidden */
  18074. _recreateRenderEffect(): void;
  18075. /**
  18076. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18077. */
  18078. animate(): void;
  18079. /**
  18080. * Renders the particle system in its current state.
  18081. * @returns the current number of particles
  18082. */
  18083. render(): number;
  18084. /**
  18085. * Rebuilds the particle system
  18086. */
  18087. rebuild(): void;
  18088. private _releaseBuffers();
  18089. private _releaseVAOs();
  18090. /**
  18091. * Disposes the particle system and free the associated resources
  18092. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18093. */
  18094. dispose(disposeTexture?: boolean): void;
  18095. /**
  18096. * Clones the particle system.
  18097. * @param name The name of the cloned object
  18098. * @param newEmitter The new emitter to use
  18099. * @returns the cloned particle system
  18100. */
  18101. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  18102. /**
  18103. * Serializes the particle system to a JSON object.
  18104. * @returns the JSON object
  18105. */
  18106. serialize(): any;
  18107. /**
  18108. * Parses a JSON object to create a GPU particle system.
  18109. * @param parsedParticleSystem The JSON object to parse
  18110. * @param scene The scene to create the particle system in
  18111. * @param rootUrl The root url to use to load external dependencies like texture
  18112. * @returns the parsed GPU particle system
  18113. */
  18114. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  18115. }
  18116. }
  18117. declare module BABYLON {
  18118. /**
  18119. * Interface representing a particle system in Babylon.
  18120. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18121. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18122. */
  18123. interface IParticleSystem {
  18124. /**
  18125. * The id of the Particle system.
  18126. */
  18127. id: string;
  18128. /**
  18129. * The name of the Particle system.
  18130. */
  18131. name: string;
  18132. /**
  18133. * The emitter represents the Mesh or position we are attaching the particle system to.
  18134. */
  18135. emitter: Nullable<AbstractMesh | Vector3>;
  18136. /**
  18137. * The rendering group used by the Particle system to chose when to render.
  18138. */
  18139. renderingGroupId: number;
  18140. /**
  18141. * The layer mask we are rendering the particles through.
  18142. */
  18143. layerMask: number;
  18144. /**
  18145. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18146. */
  18147. updateSpeed: number;
  18148. /**
  18149. * The amount of time the particle system is running (depends of the overall update speed).
  18150. */
  18151. targetStopDuration: number;
  18152. /**
  18153. * The texture used to render each particle. (this can be a spritesheet)
  18154. */
  18155. particleTexture: Nullable<Texture>;
  18156. /**
  18157. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18158. */
  18159. blendMode: number;
  18160. /**
  18161. * Minimum life time of emitting particles.
  18162. */
  18163. minLifeTime: number;
  18164. /**
  18165. * Maximum life time of emitting particles.
  18166. */
  18167. maxLifeTime: number;
  18168. /**
  18169. * Minimum Size of emitting particles.
  18170. */
  18171. minSize: number;
  18172. /**
  18173. * Maximum Size of emitting particles.
  18174. */
  18175. maxSize: number;
  18176. /**
  18177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18178. */
  18179. color1: Color4;
  18180. /**
  18181. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18182. */
  18183. color2: Color4;
  18184. /**
  18185. * Color the particle will have at the end of its lifetime.
  18186. */
  18187. colorDead: Color4;
  18188. /**
  18189. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18190. */
  18191. emitRate: number;
  18192. /**
  18193. * You can use gravity if you want to give an orientation to your particles.
  18194. */
  18195. gravity: Vector3;
  18196. /**
  18197. * Minimum power of emitting particles.
  18198. */
  18199. minEmitPower: number;
  18200. /**
  18201. * Maximum power of emitting particles.
  18202. */
  18203. maxEmitPower: number;
  18204. /**
  18205. * The particle emitter type defines the emitter used by the particle system.
  18206. * It can be for example box, sphere, or cone...
  18207. */
  18208. particleEmitterType: Nullable<IParticleEmitterType>;
  18209. /**
  18210. * Gets the maximum number of particles active at the same time.
  18211. * @returns The max number of active particles.
  18212. */
  18213. getCapacity(): number;
  18214. /**
  18215. * Gets Wether the system has been started.
  18216. * @returns True if it has been started, otherwise false.
  18217. */
  18218. isStarted(): boolean;
  18219. /**
  18220. * Gets if the particle system has been started.
  18221. * @return true if the system has been started, otherwise false.
  18222. */
  18223. isStarted(): boolean;
  18224. /**
  18225. * Animates the particle system for this frame.
  18226. */
  18227. animate(): void;
  18228. /**
  18229. * Renders the particle system in its current state.
  18230. * @returns the current number of particles
  18231. */
  18232. render(): number;
  18233. /**
  18234. * Dispose the particle system and frees its associated resources.
  18235. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18236. */
  18237. dispose(disposeTexture?: boolean): void;
  18238. /**
  18239. * Clones the particle system.
  18240. * @param name The name of the cloned object
  18241. * @param newEmitter The new emitter to use
  18242. * @returns the cloned particle system
  18243. */
  18244. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18245. /**
  18246. * Serializes the particle system to a JSON object.
  18247. * @returns the JSON object
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * Rebuild the particle system
  18252. */
  18253. rebuild(): void;
  18254. /**
  18255. * Starts the particle system and begins to emit.
  18256. */
  18257. start(): void;
  18258. /**
  18259. * Stops the particle system.
  18260. */
  18261. stop(): void;
  18262. /**
  18263. * Remove all active particles
  18264. */
  18265. reset(): void;
  18266. /**
  18267. * Is this system ready to be used/rendered
  18268. * @return true if the system is ready
  18269. */
  18270. isReady(): boolean;
  18271. }
  18272. }
  18273. declare module BABYLON {
  18274. /**
  18275. * A particle represents one of the element emitted by a particle system.
  18276. * This is mainly define by its coordinates, direction, velocity and age.
  18277. */
  18278. class Particle {
  18279. /**
  18280. * particleSystem the particle system the particle belongs to.
  18281. */
  18282. particleSystem: ParticleSystem;
  18283. /**
  18284. * The world position of the particle in the scene.
  18285. */
  18286. position: Vector3;
  18287. /**
  18288. * The world direction of the particle in the scene.
  18289. */
  18290. direction: Vector3;
  18291. /**
  18292. * The color of the particle.
  18293. */
  18294. color: Color4;
  18295. /**
  18296. * The color change of the particle per step.
  18297. */
  18298. colorStep: Color4;
  18299. /**
  18300. * Defines how long will the life of the particle be.
  18301. */
  18302. lifeTime: number;
  18303. /**
  18304. * The current age of the particle.
  18305. */
  18306. age: number;
  18307. /**
  18308. * The current size of the particle.
  18309. */
  18310. size: number;
  18311. /**
  18312. * The current angle of the particle.
  18313. */
  18314. angle: number;
  18315. /**
  18316. * Defines how fast is the angle changing.
  18317. */
  18318. angularSpeed: number;
  18319. /**
  18320. * Defines the cell index used by the particle to be rendered from a sprite.
  18321. */
  18322. cellIndex: number;
  18323. private _currentFrameCounter;
  18324. /**
  18325. * Creates a new instance Particle
  18326. * @param particleSystem the particle system the particle belongs to
  18327. */
  18328. constructor(
  18329. /**
  18330. * particleSystem the particle system the particle belongs to.
  18331. */
  18332. particleSystem: ParticleSystem);
  18333. private updateCellInfoFromSystem();
  18334. /**
  18335. * Defines how the sprite cell index is updated for the particle. This is
  18336. * defined as a callback.
  18337. */
  18338. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18339. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18340. private _updateCellIndexWithCustomSpeed();
  18341. /**
  18342. * Copy the properties of particle to another one.
  18343. * @param other the particle to copy the information to.
  18344. */
  18345. copyTo(other: Particle): void;
  18346. }
  18347. }
  18348. declare module BABYLON {
  18349. /**
  18350. * This represents a particle system in Babylon.
  18351. * 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.
  18352. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18353. * @example https://doc.babylonjs.com/babylon101/particles
  18354. */
  18355. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18356. /**
  18357. * Source color is added to the destination color without alpha affecting the result.
  18358. */
  18359. static BLENDMODE_ONEONE: number;
  18360. /**
  18361. * Blend current color and particle color using particle’s alpha.
  18362. */
  18363. static BLENDMODE_STANDARD: number;
  18364. /**
  18365. * List of animations used by the particle system.
  18366. */
  18367. animations: Animation[];
  18368. /**
  18369. * The id of the Particle system.
  18370. */
  18371. id: string;
  18372. /**
  18373. * The friendly name of the Particle system.
  18374. */
  18375. name: string;
  18376. /**
  18377. * The rendering group used by the Particle system to chose when to render.
  18378. */
  18379. renderingGroupId: number;
  18380. /**
  18381. * The emitter represents the Mesh or position we are attaching the particle system to.
  18382. */
  18383. emitter: Nullable<AbstractMesh | Vector3>;
  18384. /**
  18385. * The maximum number of particles to emit per frame
  18386. */
  18387. emitRate: number;
  18388. /**
  18389. * If you want to launch only a few particles at once, that can be done, as well.
  18390. */
  18391. manualEmitCount: number;
  18392. /**
  18393. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18394. */
  18395. updateSpeed: number;
  18396. /**
  18397. * The amount of time the particle system is running (depends of the overall update speed).
  18398. */
  18399. targetStopDuration: number;
  18400. /**
  18401. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18402. */
  18403. disposeOnStop: boolean;
  18404. /**
  18405. * Minimum power of emitting particles.
  18406. */
  18407. minEmitPower: number;
  18408. /**
  18409. * Maximum power of emitting particles.
  18410. */
  18411. maxEmitPower: number;
  18412. /**
  18413. * Minimum life time of emitting particles.
  18414. */
  18415. minLifeTime: number;
  18416. /**
  18417. * Maximum life time of emitting particles.
  18418. */
  18419. maxLifeTime: number;
  18420. /**
  18421. * Minimum Size of emitting particles.
  18422. */
  18423. minSize: number;
  18424. /**
  18425. * Maximum Size of emitting particles.
  18426. */
  18427. maxSize: number;
  18428. /**
  18429. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18430. */
  18431. minAngularSpeed: number;
  18432. /**
  18433. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18434. */
  18435. maxAngularSpeed: number;
  18436. /**
  18437. * The texture used to render each particle. (this can be a spritesheet)
  18438. */
  18439. particleTexture: Nullable<Texture>;
  18440. /**
  18441. * The layer mask we are rendering the particles through.
  18442. */
  18443. layerMask: number;
  18444. /**
  18445. * This can help using your own shader to render the particle system.
  18446. * The according effect will be created
  18447. */
  18448. customShader: any;
  18449. /**
  18450. * By default particle system starts as soon as they are created. This prevents the
  18451. * automatic start to happen and let you decide when to start emitting particles.
  18452. */
  18453. preventAutoStart: boolean;
  18454. /**
  18455. * This function can be defined to provide custom update for active particles.
  18456. * This function will be called instead of regular update (age, position, color, etc.).
  18457. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18458. */
  18459. updateFunction: (particles: Particle[]) => void;
  18460. /**
  18461. * Callback triggered when the particle animation is ending.
  18462. */
  18463. onAnimationEnd: Nullable<() => void>;
  18464. /**
  18465. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18466. */
  18467. blendMode: number;
  18468. /**
  18469. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18470. * to override the particles.
  18471. */
  18472. forceDepthWrite: boolean;
  18473. /**
  18474. * You can use gravity if you want to give an orientation to your particles.
  18475. */
  18476. gravity: Vector3;
  18477. /**
  18478. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18480. */
  18481. direction1: Vector3;
  18482. /**
  18483. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18484. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18485. */
  18486. direction2: Vector3;
  18487. /**
  18488. * 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.
  18489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18490. */
  18491. minEmitBox: Vector3;
  18492. /**
  18493. * 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.
  18494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18495. */
  18496. maxEmitBox: Vector3;
  18497. /**
  18498. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18499. */
  18500. color1: Color4;
  18501. /**
  18502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18503. */
  18504. color2: Color4;
  18505. /**
  18506. * Color the particle will have at the end of its lifetime.
  18507. */
  18508. colorDead: Color4;
  18509. /**
  18510. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  18511. */
  18512. textureMask: Color4;
  18513. /**
  18514. * The particle emitter type defines the emitter used by the particle system.
  18515. * It can be for example box, sphere, or cone...
  18516. */
  18517. particleEmitterType: IParticleEmitterType;
  18518. /**
  18519. * This function can be defined to specify initial direction for every new particle.
  18520. * It by default use the emitterType defined function.
  18521. */
  18522. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18523. /**
  18524. * This function can be defined to specify initial position for every new particle.
  18525. * It by default use the emitterType defined function.
  18526. */
  18527. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18528. /**
  18529. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  18530. */
  18531. spriteCellLoop: boolean;
  18532. /**
  18533. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  18534. */
  18535. spriteCellChangeSpeed: number;
  18536. /**
  18537. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  18538. */
  18539. startSpriteCellID: number;
  18540. /**
  18541. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  18542. */
  18543. endSpriteCellID: number;
  18544. /**
  18545. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  18546. */
  18547. spriteCellWidth: number;
  18548. /**
  18549. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  18550. */
  18551. spriteCellHeight: number;
  18552. /**
  18553. * An event triggered when the system is disposed.
  18554. */
  18555. onDisposeObservable: Observable<ParticleSystem>;
  18556. private _onDisposeObserver;
  18557. /**
  18558. * Sets a callback that will be triggered when the system is disposed.
  18559. */
  18560. onDispose: () => void;
  18561. /**
  18562. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  18563. */
  18564. readonly isAnimationSheetEnabled: Boolean;
  18565. private _particles;
  18566. private _epsilon;
  18567. private _capacity;
  18568. private _scene;
  18569. private _stockParticles;
  18570. private _newPartsExcess;
  18571. private _vertexData;
  18572. private _vertexBuffer;
  18573. private _vertexBuffers;
  18574. private _indexBuffer;
  18575. private _effect;
  18576. private _customEffect;
  18577. private _cachedDefines;
  18578. private _scaledColorStep;
  18579. private _colorDiff;
  18580. private _scaledDirection;
  18581. private _scaledGravity;
  18582. private _currentRenderId;
  18583. private _alive;
  18584. private _started;
  18585. private _stopped;
  18586. private _actualFrame;
  18587. private _scaledUpdateSpeed;
  18588. private _vertexBufferSize;
  18589. private _isAnimationSheetEnabled;
  18590. /**
  18591. * 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.
  18592. */
  18593. subEmitters: ParticleSystem[];
  18594. /**
  18595. * The current active Sub-systems, this property is used by the root particle system only.
  18596. */
  18597. activeSubSystems: Array<ParticleSystem>;
  18598. private _rootParticleSystem;
  18599. /**
  18600. * Gets the current list of active particles
  18601. */
  18602. readonly particles: Particle[];
  18603. /**
  18604. * Returns the string "ParticleSystem"
  18605. * @returns a string containing the class name
  18606. */
  18607. getClassName(): string;
  18608. /**
  18609. * Instantiates a particle system.
  18610. * 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.
  18611. * @param name The name of the particle system
  18612. * @param capacity The max number of particles alive at the same time
  18613. * @param scene The scene the particle system belongs to
  18614. * @param customEffect a custom effect used to change the way particles are rendered by default
  18615. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18616. * @param epsilon Offset used to render the particles
  18617. */
  18618. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18619. private _createIndexBuffer();
  18620. /**
  18621. * Gets the maximum number of particles active at the same time.
  18622. * @returns The max number of active particles.
  18623. */
  18624. getCapacity(): number;
  18625. /**
  18626. * Gets Wether there are still active particles in the system.
  18627. * @returns True if it is alive, otherwise false.
  18628. */
  18629. isAlive(): boolean;
  18630. /**
  18631. * Gets Wether the system has been started.
  18632. * @returns True if it has been started, otherwise false.
  18633. */
  18634. isStarted(): boolean;
  18635. /**
  18636. * Starts the particle system and begins to emit.
  18637. */
  18638. start(): void;
  18639. /**
  18640. * Stops the particle system.
  18641. * @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.
  18642. */
  18643. stop(stopSubEmitters?: boolean): void;
  18644. /**
  18645. * Remove all active particles
  18646. */
  18647. reset(): void;
  18648. /**
  18649. * @hidden (for internal use only)
  18650. */
  18651. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18652. /**
  18653. * @hidden (for internal use only)
  18654. */
  18655. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18656. /**
  18657. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18658. * Its lifetime will start back at 0.
  18659. */
  18660. recycleParticle: (particle: Particle) => void;
  18661. private _stopSubEmitters();
  18662. private _createParticle;
  18663. private _removeFromRoot();
  18664. private _emitFromParticle;
  18665. private _update(newParticles);
  18666. private _getEffect();
  18667. /**
  18668. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18669. */
  18670. animate(): void;
  18671. private _appendParticleVertexes;
  18672. private _appenedParticleVertexesWithSheet(offset, particle);
  18673. private _appenedParticleVertexesNoSheet(offset, particle);
  18674. /**
  18675. * Rebuilds the particle system.
  18676. */
  18677. rebuild(): void;
  18678. /**
  18679. * Is this system ready to be used/rendered
  18680. * @return true if the system is ready
  18681. */
  18682. isReady(): boolean;
  18683. /**
  18684. * Renders the particle system in its current state.
  18685. * @returns the current number of particles
  18686. */
  18687. render(): number;
  18688. /**
  18689. * Disposes the particle system and free the associated resources
  18690. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18691. */
  18692. dispose(disposeTexture?: boolean): void;
  18693. /**
  18694. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  18695. * @param radius The radius of the sphere to emit from
  18696. * @returns the emitter
  18697. */
  18698. createSphereEmitter(radius?: number): SphereParticleEmitter;
  18699. /**
  18700. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  18701. * @param radius The radius of the sphere to emit from
  18702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18704. * @returns the emitter
  18705. */
  18706. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  18707. /**
  18708. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  18709. * @param radius The radius of the cone to emit from
  18710. * @param angle The base angle of the cone
  18711. * @returns the emitter
  18712. */
  18713. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  18714. /**
  18715. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18718. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18719. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18720. * @returns the emitter
  18721. */
  18722. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18723. /**
  18724. * Clones the particle system.
  18725. * @param name The name of the cloned object
  18726. * @param newEmitter The new emitter to use
  18727. * @returns the cloned particle system
  18728. */
  18729. clone(name: string, newEmitter: any): ParticleSystem;
  18730. /**
  18731. * Serializes the particle system to a JSON object.
  18732. * @returns the JSON object
  18733. */
  18734. serialize(): any;
  18735. /**
  18736. * Parses a JSON object to create a particle system.
  18737. * @param parsedParticleSystem The JSON object to parse
  18738. * @param scene The scene to create the particle system in
  18739. * @param rootUrl The root url to use to load external dependencies like texture
  18740. * @returns the Parsed particle system
  18741. */
  18742. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18743. }
  18744. }
  18745. declare module BABYLON {
  18746. /**
  18747. * Represents one particle of a solid particle system.
  18748. */
  18749. class SolidParticle {
  18750. /**
  18751. * particle global index
  18752. */
  18753. idx: number;
  18754. /**
  18755. * The color of the particle
  18756. */
  18757. color: Nullable<Color4>;
  18758. /**
  18759. * The world space position of the particle.
  18760. */
  18761. position: Vector3;
  18762. /**
  18763. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18764. */
  18765. rotation: Vector3;
  18766. /**
  18767. * The world space rotation quaternion of the particle.
  18768. */
  18769. rotationQuaternion: Nullable<Quaternion>;
  18770. /**
  18771. * The scaling of the particle.
  18772. */
  18773. scaling: Vector3;
  18774. /**
  18775. * The uvs of the particle.
  18776. */
  18777. uvs: Vector4;
  18778. /**
  18779. * The current speed of the particle.
  18780. */
  18781. velocity: Vector3;
  18782. /**
  18783. * The pivot point in the particle local space.
  18784. */
  18785. pivot: Vector3;
  18786. /**
  18787. * Must the particle be translated from its pivot point in its local space ?
  18788. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18789. * Default : false
  18790. */
  18791. translateFromPivot: boolean;
  18792. /**
  18793. * Is the particle active or not ?
  18794. */
  18795. alive: boolean;
  18796. /**
  18797. * Is the particle visible or not ?
  18798. */
  18799. isVisible: boolean;
  18800. /**
  18801. * Index of this particle in the global "positions" array (Internal use)
  18802. */
  18803. _pos: number;
  18804. /**
  18805. * Index of this particle in the global "indices" array (Internal use)
  18806. */
  18807. _ind: number;
  18808. /**
  18809. * ModelShape of this particle (Internal use)
  18810. */
  18811. _model: ModelShape;
  18812. /**
  18813. * ModelShape id of this particle
  18814. */
  18815. shapeId: number;
  18816. /**
  18817. * Index of the particle in its shape id (Internal use)
  18818. */
  18819. idxInShape: number;
  18820. /**
  18821. * Reference to the shape model BoundingInfo object (Internal use)
  18822. */
  18823. _modelBoundingInfo: BoundingInfo;
  18824. /**
  18825. * Particle BoundingInfo object (Internal use)
  18826. */
  18827. _boundingInfo: BoundingInfo;
  18828. /**
  18829. * Reference to the SPS what the particle belongs to (Internal use)
  18830. */
  18831. _sps: SolidParticleSystem;
  18832. /**
  18833. * Still set as invisible in order to skip useless computations (Internal use)
  18834. */
  18835. _stillInvisible: boolean;
  18836. /**
  18837. * Last computed particle rotation matrix
  18838. */
  18839. _rotationMatrix: number[];
  18840. /**
  18841. * Parent particle Id, if any.
  18842. * Default null.
  18843. */
  18844. parentId: Nullable<number>;
  18845. /**
  18846. * Internal global position in the SPS.
  18847. */
  18848. _globalPosition: Vector3;
  18849. /**
  18850. * Creates a Solid Particle object.
  18851. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18852. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18853. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18854. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18855. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18856. * @param shapeId (integer) is the model shape identifier in the SPS.
  18857. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18858. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18859. */
  18860. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18861. /**
  18862. * Legacy support, changed scale to scaling
  18863. */
  18864. /**
  18865. * Legacy support, changed scale to scaling
  18866. */
  18867. scale: Vector3;
  18868. /**
  18869. * Legacy support, changed quaternion to rotationQuaternion
  18870. */
  18871. /**
  18872. * Legacy support, changed quaternion to rotationQuaternion
  18873. */
  18874. quaternion: Nullable<Quaternion>;
  18875. /**
  18876. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18877. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18878. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18879. * @returns true if it intersects
  18880. */
  18881. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18882. }
  18883. /**
  18884. * Represents the shape of the model used by one particle of a solid particle system.
  18885. * SPS internal tool, don't use it manually.
  18886. */
  18887. class ModelShape {
  18888. /**
  18889. * The shape id.
  18890. */
  18891. shapeID: number;
  18892. /**
  18893. * flat array of model positions (internal use)
  18894. */
  18895. _shape: Vector3[];
  18896. /**
  18897. * flat array of model UVs (internal use)
  18898. */
  18899. _shapeUV: number[];
  18900. /**
  18901. * length of the shape in the model indices array (internal use)
  18902. */
  18903. _indicesLength: number;
  18904. /**
  18905. * Custom position function (internal use)
  18906. */
  18907. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18908. /**
  18909. * Custom vertex function (internal use)
  18910. */
  18911. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18912. /**
  18913. * 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.
  18914. * SPS internal tool, don't use it manually.
  18915. * @hidden
  18916. */
  18917. 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>);
  18918. }
  18919. /**
  18920. * Represents a Depth Sorted Particle in the solid particle system.
  18921. */
  18922. class DepthSortedParticle {
  18923. /**
  18924. * Index of the particle in the "indices" array
  18925. */
  18926. ind: number;
  18927. /**
  18928. * Length of the particle shape in the "indices" array
  18929. */
  18930. indicesLength: number;
  18931. /**
  18932. * Squared distance from the particle to the camera
  18933. */
  18934. sqDistance: number;
  18935. }
  18936. }
  18937. declare module BABYLON {
  18938. /**
  18939. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18940. *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.
  18941. * The SPS is also a particle system. It provides some methods to manage the particles.
  18942. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18943. *
  18944. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18945. */
  18946. class SolidParticleSystem implements IDisposable {
  18947. /**
  18948. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18949. * Example : var p = SPS.particles[i];
  18950. */
  18951. particles: SolidParticle[];
  18952. /**
  18953. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18954. */
  18955. nbParticles: number;
  18956. /**
  18957. * If the particles must ever face the camera (default false). Useful for planar particles.
  18958. */
  18959. billboard: boolean;
  18960. /**
  18961. * Recompute normals when adding a shape
  18962. */
  18963. recomputeNormals: boolean;
  18964. /**
  18965. * This a counter ofr your own usage. It's not set by any SPS functions.
  18966. */
  18967. counter: number;
  18968. /**
  18969. * The SPS name. This name is also given to the underlying mesh.
  18970. */
  18971. name: string;
  18972. /**
  18973. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18974. */
  18975. mesh: Mesh;
  18976. /**
  18977. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18978. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18979. */
  18980. vars: any;
  18981. /**
  18982. * This array is populated when the SPS is set as 'pickable'.
  18983. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18984. * Each element of this array is an object `{idx: int, faceId: int}`.
  18985. * `idx` is the picked particle index in the `SPS.particles` array
  18986. * `faceId` is the picked face index counted within this particle.
  18987. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18988. */
  18989. pickedParticles: {
  18990. idx: number;
  18991. faceId: number;
  18992. }[];
  18993. /**
  18994. * This array is populated when `enableDepthSort` is set to true.
  18995. * Each element of this array is an instance of the class DepthSortedParticle.
  18996. */
  18997. depthSortedParticles: DepthSortedParticle[];
  18998. /**
  18999. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  19000. */
  19001. _bSphereOnly: boolean;
  19002. /**
  19003. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  19004. */
  19005. _bSphereRadiusFactor: number;
  19006. private _scene;
  19007. private _positions;
  19008. private _indices;
  19009. private _normals;
  19010. private _colors;
  19011. private _uvs;
  19012. private _indices32;
  19013. private _positions32;
  19014. private _normals32;
  19015. private _fixedNormal32;
  19016. private _colors32;
  19017. private _uvs32;
  19018. private _index;
  19019. private _updatable;
  19020. private _pickable;
  19021. private _isVisibilityBoxLocked;
  19022. private _alwaysVisible;
  19023. private _depthSort;
  19024. private _shapeCounter;
  19025. private _copy;
  19026. private _shape;
  19027. private _shapeUV;
  19028. private _color;
  19029. private _computeParticleColor;
  19030. private _computeParticleTexture;
  19031. private _computeParticleRotation;
  19032. private _computeParticleVertex;
  19033. private _computeBoundingBox;
  19034. private _depthSortParticles;
  19035. private _cam_axisZ;
  19036. private _cam_axisY;
  19037. private _cam_axisX;
  19038. private _axisZ;
  19039. private _camera;
  19040. private _particle;
  19041. private _camDir;
  19042. private _camInvertedPosition;
  19043. private _rotMatrix;
  19044. private _invertMatrix;
  19045. private _rotated;
  19046. private _quaternion;
  19047. private _vertex;
  19048. private _normal;
  19049. private _yaw;
  19050. private _pitch;
  19051. private _roll;
  19052. private _halfroll;
  19053. private _halfpitch;
  19054. private _halfyaw;
  19055. private _sinRoll;
  19056. private _cosRoll;
  19057. private _sinPitch;
  19058. private _cosPitch;
  19059. private _sinYaw;
  19060. private _cosYaw;
  19061. private _mustUnrotateFixedNormals;
  19062. private _minimum;
  19063. private _maximum;
  19064. private _minBbox;
  19065. private _maxBbox;
  19066. private _particlesIntersect;
  19067. private _depthSortFunction;
  19068. private _needs32Bits;
  19069. private _pivotBackTranslation;
  19070. private _scaledPivot;
  19071. private _particleHasParent;
  19072. private _parent;
  19073. /**
  19074. * Creates a SPS (Solid Particle System) object.
  19075. * @param name (String) is the SPS name, this will be the underlying mesh name.
  19076. * @param scene (Scene) is the scene in which the SPS is added.
  19077. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  19078. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  19079. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  19080. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  19081. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  19082. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  19083. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  19084. */
  19085. constructor(name: string, scene: Scene, options?: {
  19086. updatable?: boolean;
  19087. isPickable?: boolean;
  19088. enableDepthSort?: boolean;
  19089. particleIntersection?: boolean;
  19090. boundingSphereOnly?: boolean;
  19091. bSphereRadiusFactor?: number;
  19092. });
  19093. /**
  19094. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19095. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19096. * @returns the created mesh
  19097. */
  19098. buildMesh(): Mesh;
  19099. /**
  19100. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19101. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19102. * Thus the particles generated from `digest()` have their property `position` set yet.
  19103. * @param mesh ( Mesh ) is the mesh to be digested
  19104. * @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
  19105. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19106. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19107. * @returns the current SPS
  19108. */
  19109. digest(mesh: Mesh, options?: {
  19110. facetNb?: number;
  19111. number?: number;
  19112. delta?: number;
  19113. }): SolidParticleSystem;
  19114. private _unrotateFixedNormals();
  19115. private _resetCopy();
  19116. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  19117. private _posToShape(positions);
  19118. private _uvsToShapeUV(uvs);
  19119. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  19120. /**
  19121. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19122. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19123. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19124. * @param nb (positive integer) the number of particles to be created from this model
  19125. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19126. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19127. * @returns the number of shapes in the system
  19128. */
  19129. addShape(mesh: Mesh, nb: number, options?: {
  19130. positionFunction?: any;
  19131. vertexFunction?: any;
  19132. }): number;
  19133. private _rebuildParticle(particle);
  19134. /**
  19135. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19136. * @returns the SPS.
  19137. */
  19138. rebuildMesh(): SolidParticleSystem;
  19139. /**
  19140. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19141. * This method calls `updateParticle()` for each particle of the SPS.
  19142. * For an animated SPS, it is usually called within the render loop.
  19143. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19144. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19145. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19146. * @returns the SPS.
  19147. */
  19148. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19149. private _quaternionRotationYPR();
  19150. private _quaternionToRotationMatrix();
  19151. /**
  19152. * Disposes the SPS.
  19153. */
  19154. dispose(): void;
  19155. /**
  19156. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19157. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19158. * @returns the SPS.
  19159. */
  19160. refreshVisibleSize(): SolidParticleSystem;
  19161. /**
  19162. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19163. * @param size the size (float) of the visibility box
  19164. * note : this doesn't lock the SPS mesh bounding box.
  19165. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19166. */
  19167. setVisibilityBox(size: number): void;
  19168. /**
  19169. * Gets whether the SPS as always visible or not
  19170. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19171. */
  19172. /**
  19173. * Sets the SPS as always visible or not
  19174. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19175. */
  19176. isAlwaysVisible: boolean;
  19177. /**
  19178. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19179. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19180. */
  19181. /**
  19182. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19183. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19184. */
  19185. isVisibilityBoxLocked: boolean;
  19186. /**
  19187. * Gets if `setParticles()` computes the particle rotations or not.
  19188. * Default value : true. The SPS is faster when it's set to false.
  19189. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19190. */
  19191. /**
  19192. * Tells to `setParticles()` to compute the particle rotations or not.
  19193. * Default value : true. The SPS is faster when it's set to false.
  19194. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19195. */
  19196. computeParticleRotation: boolean;
  19197. /**
  19198. * Gets if `setParticles()` computes the particle colors or not.
  19199. * Default value : true. The SPS is faster when it's set to false.
  19200. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19201. */
  19202. /**
  19203. * Tells to `setParticles()` to compute the particle colors or not.
  19204. * Default value : true. The SPS is faster when it's set to false.
  19205. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19206. */
  19207. computeParticleColor: boolean;
  19208. /**
  19209. * Gets if `setParticles()` computes the particle textures or not.
  19210. * Default value : true. The SPS is faster when it's set to false.
  19211. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19212. */
  19213. computeParticleTexture: boolean;
  19214. /**
  19215. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19216. * Default value : false. The SPS is faster when it's set to false.
  19217. * Note : the particle custom vertex positions aren't stored values.
  19218. */
  19219. /**
  19220. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19221. * Default value : false. The SPS is faster when it's set to false.
  19222. * Note : the particle custom vertex positions aren't stored values.
  19223. */
  19224. computeParticleVertex: boolean;
  19225. /**
  19226. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19227. */
  19228. /**
  19229. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19230. */
  19231. computeBoundingBox: boolean;
  19232. /**
  19233. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19234. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19235. * Default : `true`
  19236. */
  19237. /**
  19238. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19239. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19240. * Default : `true`
  19241. */
  19242. depthSortParticles: boolean;
  19243. /**
  19244. * This function does nothing. It may be overwritten to set all the particle first values.
  19245. * The SPS doesn't call this function, you may have to call it by your own.
  19246. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19247. */
  19248. initParticles(): void;
  19249. /**
  19250. * This function does nothing. It may be overwritten to recycle a particle.
  19251. * The SPS doesn't call this function, you may have to call it by your own.
  19252. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19253. * @param particle The particle to recycle
  19254. * @returns the recycled particle
  19255. */
  19256. recycleParticle(particle: SolidParticle): SolidParticle;
  19257. /**
  19258. * Updates a particle : this function should be overwritten by the user.
  19259. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19260. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19261. * @example : just set a particle position or velocity and recycle conditions
  19262. * @param particle The particle to update
  19263. * @returns the updated particle
  19264. */
  19265. updateParticle(particle: SolidParticle): SolidParticle;
  19266. /**
  19267. * Updates a vertex of a particle : it can be overwritten by the user.
  19268. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19269. * @param particle the current particle
  19270. * @param vertex the current index of the current particle
  19271. * @param pt the index of the current vertex in the particle shape
  19272. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19273. * @example : just set a vertex particle position
  19274. * @returns the updated vertex
  19275. */
  19276. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19277. /**
  19278. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19279. * This does nothing and may be overwritten by the user.
  19280. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19281. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19282. * @param update the boolean update value actually passed to setParticles()
  19283. */
  19284. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19285. /**
  19286. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19287. * This will be passed three parameters.
  19288. * This does nothing and may be overwritten by the user.
  19289. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19290. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19291. * @param update the boolean update value actually passed to setParticles()
  19292. */
  19293. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19294. }
  19295. }
  19296. declare module BABYLON {
  19297. /**
  19298. * Class used to store all common mesh properties
  19299. */
  19300. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19301. /** No occlusion */
  19302. static OCCLUSION_TYPE_NONE: number;
  19303. /** Occlusion set to optimisitic */
  19304. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19305. /** Occlusion set to strict */
  19306. static OCCLUSION_TYPE_STRICT: number;
  19307. /** Use an accurante occlusion algorithm */
  19308. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19309. /** Use a conservative occlusion algorithm */
  19310. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19311. /**
  19312. * No billboard
  19313. */
  19314. static readonly BILLBOARDMODE_NONE: number;
  19315. /** Billboard on X axis */
  19316. static readonly BILLBOARDMODE_X: number;
  19317. /** Billboard on Y axis */
  19318. static readonly BILLBOARDMODE_Y: number;
  19319. /** Billboard on Z axis */
  19320. static readonly BILLBOARDMODE_Z: number;
  19321. /** Billboard on all axes */
  19322. static readonly BILLBOARDMODE_ALL: number;
  19323. private _facetPositions;
  19324. private _facetNormals;
  19325. private _facetPartitioning;
  19326. private _facetNb;
  19327. private _partitioningSubdivisions;
  19328. private _partitioningBBoxRatio;
  19329. private _facetDataEnabled;
  19330. private _facetParameters;
  19331. private _bbSize;
  19332. private _subDiv;
  19333. private _facetDepthSort;
  19334. private _facetDepthSortEnabled;
  19335. private _depthSortedIndices;
  19336. private _depthSortedFacets;
  19337. private _facetDepthSortFunction;
  19338. private _facetDepthSortFrom;
  19339. private _facetDepthSortOrigin;
  19340. private _invertedMatrix;
  19341. /**
  19342. * Gets the number of facets in the mesh
  19343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19344. */
  19345. readonly facetNb: number;
  19346. /**
  19347. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19349. */
  19350. partitioningSubdivisions: number;
  19351. /**
  19352. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19353. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19355. */
  19356. partitioningBBoxRatio: number;
  19357. /**
  19358. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19359. * Works only for updatable meshes.
  19360. * Doesn't work with multi-materials
  19361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19362. */
  19363. mustDepthSortFacets: boolean;
  19364. /**
  19365. * The location (Vector3) where the facet depth sort must be computed from.
  19366. * By default, the active camera position.
  19367. * Used only when facet depth sort is enabled
  19368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19369. */
  19370. facetDepthSortFrom: Vector3;
  19371. /**
  19372. * gets a boolean indicating if facetData is enabled
  19373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19374. */
  19375. readonly isFacetDataEnabled: boolean;
  19376. /** @hidden */
  19377. _updateNonUniformScalingState(value: boolean): boolean;
  19378. /**
  19379. * An event triggered when this mesh collides with another one
  19380. */
  19381. onCollideObservable: Observable<AbstractMesh>;
  19382. private _onCollideObserver;
  19383. /** Set a function to call when this mesh collides with another one */
  19384. onCollide: () => void;
  19385. /**
  19386. * An event triggered when the collision's position changes
  19387. */
  19388. onCollisionPositionChangeObservable: Observable<Vector3>;
  19389. private _onCollisionPositionChangeObserver;
  19390. /** Set a function to call when the collision's position changes */
  19391. onCollisionPositionChange: () => void;
  19392. /**
  19393. * An event triggered when material is changed
  19394. */
  19395. onMaterialChangedObservable: Observable<AbstractMesh>;
  19396. /**
  19397. * Gets or sets the orientation for POV movement & rotation
  19398. */
  19399. definedFacingForward: boolean;
  19400. /**
  19401. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19402. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19403. * * 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.
  19404. * @see http://doc.babylonjs.com/features/occlusionquery
  19405. */
  19406. occlusionQueryAlgorithmType: number;
  19407. /**
  19408. * 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:
  19409. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19410. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19411. * * 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.
  19412. * @see http://doc.babylonjs.com/features/occlusionquery
  19413. */
  19414. occlusionType: number;
  19415. /**
  19416. * 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.
  19417. * The default value is -1 which means don't break the query and wait till the result
  19418. * @see http://doc.babylonjs.com/features/occlusionquery
  19419. */
  19420. occlusionRetryCount: number;
  19421. private _occlusionInternalRetryCounter;
  19422. protected _isOccluded: boolean;
  19423. /**
  19424. * 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
  19425. * @see http://doc.babylonjs.com/features/occlusionquery
  19426. */
  19427. isOccluded: boolean;
  19428. private _isOcclusionQueryInProgress;
  19429. /**
  19430. * Flag to check the progress status of the query
  19431. * @see http://doc.babylonjs.com/features/occlusionquery
  19432. */
  19433. readonly isOcclusionQueryInProgress: boolean;
  19434. private _occlusionQuery;
  19435. private _visibility;
  19436. /**
  19437. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19438. */
  19439. /**
  19440. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19441. */
  19442. visibility: number;
  19443. /** Gets or sets the alpha index used to sort transparent meshes
  19444. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19445. */
  19446. alphaIndex: number;
  19447. /**
  19448. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19449. */
  19450. isVisible: boolean;
  19451. /**
  19452. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19453. */
  19454. isPickable: boolean;
  19455. /**
  19456. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  19457. */
  19458. showBoundingBox: boolean;
  19459. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19460. showSubMeshesBoundingBox: boolean;
  19461. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19463. */
  19464. isBlocker: boolean;
  19465. /**
  19466. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19467. */
  19468. enablePointerMoveEvents: boolean;
  19469. /**
  19470. * Specifies the rendering group id for this mesh (0 by default)
  19471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19472. */
  19473. renderingGroupId: number;
  19474. private _material;
  19475. /** Gets or sets current material */
  19476. material: Nullable<Material>;
  19477. private _receiveShadows;
  19478. /**
  19479. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19480. * @see http://doc.babylonjs.com/babylon101/shadows
  19481. */
  19482. receiveShadows: boolean;
  19483. /**
  19484. * Gets or sets a boolean indicating if the outline must be rendered as well
  19485. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19486. */
  19487. renderOutline: boolean;
  19488. /** Defines color to use when rendering outline */
  19489. outlineColor: Color3;
  19490. /** Define width to use when rendering outline */
  19491. outlineWidth: number;
  19492. /**
  19493. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19494. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19495. */
  19496. renderOverlay: boolean;
  19497. /** Defines color to use when rendering overlay */
  19498. overlayColor: Color3;
  19499. /** Defines alpha to use when rendering overlay */
  19500. overlayAlpha: number;
  19501. private _hasVertexAlpha;
  19502. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19503. hasVertexAlpha: boolean;
  19504. private _useVertexColors;
  19505. /** 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) */
  19506. useVertexColors: boolean;
  19507. private _computeBonesUsingShaders;
  19508. /**
  19509. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19510. */
  19511. computeBonesUsingShaders: boolean;
  19512. private _numBoneInfluencers;
  19513. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19514. numBoneInfluencers: number;
  19515. private _applyFog;
  19516. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19517. applyFog: boolean;
  19518. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19519. useOctreeForRenderingSelection: boolean;
  19520. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19521. useOctreeForPicking: boolean;
  19522. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19523. useOctreeForCollisions: boolean;
  19524. private _layerMask;
  19525. /**
  19526. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19527. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19528. */
  19529. layerMask: number;
  19530. /**
  19531. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19532. */
  19533. alwaysSelectAsActiveMesh: boolean;
  19534. /**
  19535. * Gets or sets the current action manager
  19536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19537. */
  19538. actionManager: Nullable<ActionManager>;
  19539. /**
  19540. * Gets or sets impostor used for physic simulation
  19541. * @see http://doc.babylonjs.com/features/physics_engine
  19542. */
  19543. physicsImpostor: Nullable<PhysicsImpostor>;
  19544. private _checkCollisions;
  19545. private _collisionMask;
  19546. private _collisionGroup;
  19547. /**
  19548. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19550. */
  19551. ellipsoid: Vector3;
  19552. /**
  19553. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19554. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19555. */
  19556. ellipsoidOffset: Vector3;
  19557. private _collider;
  19558. private _oldPositionForCollisions;
  19559. private _diffPositionForCollisions;
  19560. /**
  19561. * Gets or sets a collision mask used to mask collisions (default is -1).
  19562. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19563. */
  19564. collisionMask: number;
  19565. /**
  19566. * Gets or sets the current collision group mask (-1 by default).
  19567. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19568. */
  19569. collisionGroup: number;
  19570. /**
  19571. * Defines edge width used when edgesRenderer is enabled
  19572. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19573. */
  19574. edgesWidth: number;
  19575. /**
  19576. * Defines edge color used when edgesRenderer is enabled
  19577. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19578. */
  19579. edgesColor: Color4;
  19580. /** @hidden */
  19581. _edgesRenderer: Nullable<EdgesRenderer>;
  19582. private _collisionsTransformMatrix;
  19583. private _collisionsScalingMatrix;
  19584. /** @hidden */
  19585. _masterMesh: Nullable<AbstractMesh>;
  19586. /** @hidden */
  19587. _boundingInfo: Nullable<BoundingInfo>;
  19588. /** @hidden */
  19589. _renderId: number;
  19590. /**
  19591. * Gets or sets the list of subMeshes
  19592. * @see http://doc.babylonjs.com/how_to/multi_materials
  19593. */
  19594. subMeshes: SubMesh[];
  19595. /** @hidden */
  19596. _submeshesOctree: Octree<SubMesh>;
  19597. /** @hidden */
  19598. _intersectionsInProgress: AbstractMesh[];
  19599. /** @hidden */
  19600. _unIndexed: boolean;
  19601. /** @hidden */
  19602. _lightSources: Light[];
  19603. /** @hidden */
  19604. readonly _positions: Nullable<Vector3[]>;
  19605. /** @hidden */
  19606. _waitingActions: any;
  19607. /** @hidden */
  19608. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19609. private _skeleton;
  19610. /** @hidden */
  19611. _bonesTransformMatrices: Nullable<Float32Array>;
  19612. /**
  19613. * Gets or sets a skeleton to apply skining transformations
  19614. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19615. */
  19616. skeleton: Nullable<Skeleton>;
  19617. /**
  19618. * Creates a new AbstractMesh
  19619. * @param name defines the name of the mesh
  19620. * @param scene defines the hosting scene
  19621. */
  19622. constructor(name: string, scene?: Nullable<Scene>);
  19623. /**
  19624. * Returns the string "AbstractMesh"
  19625. * @returns "AbstractMesh"
  19626. */
  19627. getClassName(): string;
  19628. /**
  19629. * Gets a string representation of the current mesh
  19630. * @param fullDetails defines a boolean indicating if full details must be included
  19631. * @returns a string representation of the current mesh
  19632. */
  19633. toString(fullDetails?: boolean): string;
  19634. /** @hidden */
  19635. _rebuild(): void;
  19636. /** @hidden */
  19637. _resyncLightSources(): void;
  19638. /** @hidden */
  19639. _resyncLighSource(light: Light): void;
  19640. /** @hidden */
  19641. _unBindEffect(): void;
  19642. /** @hidden */
  19643. _removeLightSource(light: Light): void;
  19644. private _markSubMeshesAsDirty(func);
  19645. /** @hidden */
  19646. _markSubMeshesAsLightDirty(): void;
  19647. /** @hidden */
  19648. _markSubMeshesAsAttributesDirty(): void;
  19649. /** @hidden */
  19650. _markSubMeshesAsMiscDirty(): void;
  19651. /**
  19652. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19653. */
  19654. scaling: Vector3;
  19655. /**
  19656. * Disables the mesh edge rendering mode
  19657. * @returns the currentAbstractMesh
  19658. */
  19659. disableEdgesRendering(): AbstractMesh;
  19660. /**
  19661. * Enables the edge rendering mode on the mesh.
  19662. * This mode makes the mesh edges visible
  19663. * @param epsilon defines the maximal distance between two angles to detect a face
  19664. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19665. * @returns the currentAbstractMesh
  19666. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19667. */
  19668. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19669. /**
  19670. * Returns true if the mesh is blocked. Implemented by child classes
  19671. */
  19672. readonly isBlocked: boolean;
  19673. /**
  19674. * Returns the mesh itself by default. Implemented by child classes
  19675. * @param camera defines the camera to use to pick the right LOD level
  19676. * @returns the currentAbstractMesh
  19677. */
  19678. getLOD(camera: Camera): AbstractMesh;
  19679. /**
  19680. * Returns 0 by default. Implemented by child classes
  19681. * @returns an integer
  19682. */
  19683. getTotalVertices(): number;
  19684. /**
  19685. * Returns null by default. Implemented by child classes
  19686. * @returns null
  19687. */
  19688. getIndices(): Nullable<IndicesArray>;
  19689. /**
  19690. * Returns the array of the requested vertex data kind. Implemented by child classes
  19691. * @param kind defines the vertex data kind to use
  19692. * @returns null
  19693. */
  19694. getVerticesData(kind: string): Nullable<FloatArray>;
  19695. /**
  19696. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19697. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19698. * Note that a new underlying VertexBuffer object is created each call.
  19699. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19700. * @param kind defines vertex data kind:
  19701. * * BABYLON.VertexBuffer.PositionKind
  19702. * * BABYLON.VertexBuffer.UVKind
  19703. * * BABYLON.VertexBuffer.UV2Kind
  19704. * * BABYLON.VertexBuffer.UV3Kind
  19705. * * BABYLON.VertexBuffer.UV4Kind
  19706. * * BABYLON.VertexBuffer.UV5Kind
  19707. * * BABYLON.VertexBuffer.UV6Kind
  19708. * * BABYLON.VertexBuffer.ColorKind
  19709. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19710. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19711. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19712. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19713. * @param data defines the data source
  19714. * @param updatable defines if the data must be flagged as updatable (or static)
  19715. * @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
  19716. * @returns the current mesh
  19717. */
  19718. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19719. /**
  19720. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19721. * If the mesh has no geometry, it is simply returned as it is.
  19722. * @param kind defines vertex data kind:
  19723. * * BABYLON.VertexBuffer.PositionKind
  19724. * * BABYLON.VertexBuffer.UVKind
  19725. * * BABYLON.VertexBuffer.UV2Kind
  19726. * * BABYLON.VertexBuffer.UV3Kind
  19727. * * BABYLON.VertexBuffer.UV4Kind
  19728. * * BABYLON.VertexBuffer.UV5Kind
  19729. * * BABYLON.VertexBuffer.UV6Kind
  19730. * * BABYLON.VertexBuffer.ColorKind
  19731. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19732. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19733. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19734. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19735. * @param data defines the data source
  19736. * @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
  19737. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19738. * @returns the current mesh
  19739. */
  19740. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19741. /**
  19742. * Sets the mesh indices,
  19743. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19744. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19745. * @param totalVertices Defines the total number of vertices
  19746. * @returns the current mesh
  19747. */
  19748. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19749. /**
  19750. * Gets a boolean indicating if specific vertex data is present
  19751. * @param kind defines the vertex data kind to use
  19752. * @returns true is data kind is present
  19753. */
  19754. isVerticesDataPresent(kind: string): boolean;
  19755. /**
  19756. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19757. * @returns a BoundingInfo
  19758. */
  19759. getBoundingInfo(): BoundingInfo;
  19760. /**
  19761. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19762. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19763. * @returns the current mesh
  19764. */
  19765. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19766. /**
  19767. * Overwrite the current bounding info
  19768. * @param boundingInfo defines the new bounding info
  19769. * @returns the current mesh
  19770. */
  19771. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19772. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19773. readonly useBones: boolean;
  19774. /** @hidden */
  19775. _preActivate(): void;
  19776. /** @hidden */
  19777. _preActivateForIntermediateRendering(renderId: number): void;
  19778. /** @hidden */
  19779. _activate(renderId: number): void;
  19780. /**
  19781. * Gets the current world matrix
  19782. * @returns a Matrix
  19783. */
  19784. getWorldMatrix(): Matrix;
  19785. /** @hidden */
  19786. _getWorldMatrixDeterminant(): number;
  19787. /**
  19788. * Perform relative position change from the point of view of behind the front of the mesh.
  19789. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19790. * Supports definition of mesh facing forward or backward
  19791. * @param amountRight defines the distance on the right axis
  19792. * @param amountUp defines the distance on the up axis
  19793. * @param amountForward defines the distance on the forward axis
  19794. * @returns the current mesh
  19795. */
  19796. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19797. /**
  19798. * Calculate relative position change from the point of view of behind the front of the mesh.
  19799. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19800. * Supports definition of mesh facing forward or backward
  19801. * @param amountRight defines the distance on the right axis
  19802. * @param amountUp defines the distance on the up axis
  19803. * @param amountForward defines the distance on the forward axis
  19804. * @returns the new displacement vector
  19805. */
  19806. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19807. /**
  19808. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19809. * Supports definition of mesh facing forward or backward
  19810. * @param flipBack defines the flip
  19811. * @param twirlClockwise defines the twirl
  19812. * @param tiltRight defines the tilt
  19813. * @returns the current mesh
  19814. */
  19815. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19816. /**
  19817. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19818. * Supports definition of mesh facing forward or backward.
  19819. * @param flipBack defines the flip
  19820. * @param twirlClockwise defines the twirl
  19821. * @param tiltRight defines the tilt
  19822. * @returns the new rotation vector
  19823. */
  19824. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19825. /**
  19826. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19827. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19828. * @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
  19829. * @returns the new bounding vectors
  19830. */
  19831. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19832. min: Vector3;
  19833. max: Vector3;
  19834. };
  19835. /** @hidden */
  19836. _updateBoundingInfo(): AbstractMesh;
  19837. /** @hidden */
  19838. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19839. /** @hidden */
  19840. protected _afterComputeWorldMatrix(): void;
  19841. /**
  19842. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19843. * A mesh is in the frustum if its bounding box intersects the frustum
  19844. * @param frustumPlanes defines the frustum to test
  19845. * @returns true if the mesh is in the frustum planes
  19846. */
  19847. isInFrustum(frustumPlanes: Plane[]): boolean;
  19848. /**
  19849. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19850. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19851. * @param frustumPlanes defines the frustum to test
  19852. * @returns true if the mesh is completely in the frustum planes
  19853. */
  19854. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19855. /**
  19856. * True if the mesh intersects another mesh or a SolidParticle object
  19857. * @param mesh defines a target mesh or SolidParticle to test
  19858. * @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)
  19859. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19860. * @returns true if there is an intersection
  19861. */
  19862. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19863. /**
  19864. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19865. * @param point defines the point to test
  19866. * @returns true if there is an intersection
  19867. */
  19868. intersectsPoint(point: Vector3): boolean;
  19869. /**
  19870. * Gets the current physics impostor
  19871. * @see http://doc.babylonjs.com/features/physics_engine
  19872. * @returns a physics impostor or null
  19873. */
  19874. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19875. /**
  19876. * Gets the position of the current mesh in camera space
  19877. * @param camera defines the camera to use
  19878. * @returns a position
  19879. */
  19880. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19881. /**
  19882. * Returns the distance from the mesh to the active camera
  19883. * @param camera defines the camera to use
  19884. * @returns the distance
  19885. */
  19886. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19887. /**
  19888. * Apply a physic impulse to the mesh
  19889. * @param force defines the force to apply
  19890. * @param contactPoint defines where to apply the force
  19891. * @returns the current mesh
  19892. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19893. */
  19894. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19895. /**
  19896. * Creates a physic joint between two meshes
  19897. * @param otherMesh defines the other mesh to use
  19898. * @param pivot1 defines the pivot to use on this mesh
  19899. * @param pivot2 defines the pivot to use on the other mesh
  19900. * @param options defines additional options (can be plugin dependent)
  19901. * @returns the current mesh
  19902. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19903. */
  19904. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19905. /**
  19906. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19907. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19908. */
  19909. checkCollisions: boolean;
  19910. /**
  19911. * Gets Collider object used to compute collisions (not physics)
  19912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19913. */
  19914. readonly collider: Collider;
  19915. /**
  19916. * Move the mesh using collision engine
  19917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19918. * @param displacement defines the requested displacement vector
  19919. * @returns the current mesh
  19920. */
  19921. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19922. private _onCollisionPositionChange;
  19923. /**
  19924. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19925. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19926. * @param maxCapacity defines the maximum size of each block (64 by default)
  19927. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19928. * @returns the new octree
  19929. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19931. */
  19932. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19933. /** @hidden */
  19934. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19935. /** @hidden */
  19936. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19937. /** @hidden */
  19938. _checkCollision(collider: Collider): AbstractMesh;
  19939. /** @hidden */
  19940. _generatePointsArray(): boolean;
  19941. /**
  19942. * Checks if the passed Ray intersects with the mesh
  19943. * @param ray defines the ray to use
  19944. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19945. * @returns the picking info
  19946. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19947. */
  19948. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19949. /**
  19950. * Clones the current mesh
  19951. * @param name defines the mesh name
  19952. * @param newParent defines the new mesh parent
  19953. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19954. * @returns the new mesh
  19955. */
  19956. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19957. /**
  19958. * Disposes all the submeshes of the current meshnp
  19959. * @returns the current mesh
  19960. */
  19961. releaseSubMeshes(): AbstractMesh;
  19962. /**
  19963. * Releases resources associated with this abstract mesh.
  19964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19966. */
  19967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19968. /**
  19969. * Adds the passed mesh as a child to the current mesh
  19970. * @param mesh defines the child mesh
  19971. * @returns the current mesh
  19972. */
  19973. addChild(mesh: AbstractMesh): AbstractMesh;
  19974. /**
  19975. * Removes the passed mesh from the current mesh children list
  19976. * @param mesh defines the child mesh
  19977. * @returns the current mesh
  19978. */
  19979. removeChild(mesh: AbstractMesh): AbstractMesh;
  19980. /** @hidden */
  19981. private _initFacetData();
  19982. /**
  19983. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19984. * This method can be called within the render loop.
  19985. * 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
  19986. * @returns the current mesh
  19987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19988. */
  19989. updateFacetData(): AbstractMesh;
  19990. /**
  19991. * Returns the facetLocalNormals array.
  19992. * The normals are expressed in the mesh local spac
  19993. * @returns an array of Vector3
  19994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19995. */
  19996. getFacetLocalNormals(): Vector3[];
  19997. /**
  19998. * Returns the facetLocalPositions array.
  19999. * The facet positions are expressed in the mesh local space
  20000. * @returns an array of Vector3
  20001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20002. */
  20003. getFacetLocalPositions(): Vector3[];
  20004. /**
  20005. * Returns the facetLocalPartioning array
  20006. * @returns an array of array of numbers
  20007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20008. */
  20009. getFacetLocalPartitioning(): number[][];
  20010. /**
  20011. * Returns the i-th facet position in the world system.
  20012. * This method allocates a new Vector3 per call
  20013. * @param i defines the facet index
  20014. * @returns a new Vector3
  20015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20016. */
  20017. getFacetPosition(i: number): Vector3;
  20018. /**
  20019. * Sets the reference Vector3 with the i-th facet position in the world system
  20020. * @param i defines the facet index
  20021. * @param ref defines the target vector
  20022. * @returns the current mesh
  20023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20024. */
  20025. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20026. /**
  20027. * Returns the i-th facet normal in the world system.
  20028. * This method allocates a new Vector3 per call
  20029. * @param i defines the facet index
  20030. * @returns a new Vector3
  20031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20032. */
  20033. getFacetNormal(i: number): Vector3;
  20034. /**
  20035. * Sets the reference Vector3 with the i-th facet normal in the world system
  20036. * @param i defines the facet index
  20037. * @param ref defines the target vector
  20038. * @returns the current mesh
  20039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20040. */
  20041. getFacetNormalToRef(i: number, ref: Vector3): this;
  20042. /**
  20043. * 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)
  20044. * @param x defines x coordinate
  20045. * @param y defines y coordinate
  20046. * @param z defines z coordinate
  20047. * @returns the array of facet indexes
  20048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20049. */
  20050. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20051. /**
  20052. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20053. * @param projected sets as the (x,y,z) world projection on the facet
  20054. * @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
  20055. * @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
  20056. * @param x defines x coordinate
  20057. * @param y defines y coordinate
  20058. * @param z defines z coordinate
  20059. * @returns the face index if found (or null instead)
  20060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20061. */
  20062. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20063. /**
  20064. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20065. * @param projected sets as the (x,y,z) local projection on the facet
  20066. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  20067. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  20068. * @param x defines x coordinate
  20069. * @param y defines y coordinate
  20070. * @param z defines z coordinate
  20071. * @returns the face index if found (or null instead)
  20072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20073. */
  20074. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20075. /**
  20076. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20077. * @returns the parameters
  20078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20079. */
  20080. getFacetDataParameters(): any;
  20081. /**
  20082. * Disables the feature FacetData and frees the related memory
  20083. * @returns the current mesh
  20084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20085. */
  20086. disableFacetData(): AbstractMesh;
  20087. /**
  20088. * Updates the AbstractMesh indices array
  20089. * @param indices defines the data source
  20090. * @returns the current mesh
  20091. */
  20092. updateIndices(indices: IndicesArray): AbstractMesh;
  20093. /**
  20094. * Creates new normals data for the mesh
  20095. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20096. * @returns the current mesh
  20097. */
  20098. createNormals(updatable: boolean): AbstractMesh;
  20099. /**
  20100. * Align the mesh with a normal
  20101. * @param normal defines the normal to use
  20102. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20103. * @returns the current mesh
  20104. */
  20105. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20106. /** @hidden */
  20107. protected _checkOcclusionQuery(): void;
  20108. }
  20109. }
  20110. declare module BABYLON {
  20111. class Buffer {
  20112. private _engine;
  20113. private _buffer;
  20114. private _data;
  20115. private _updatable;
  20116. private _instanced;
  20117. /**
  20118. * Gets the byte stride.
  20119. */
  20120. readonly byteStride: number;
  20121. /**
  20122. * Constructor
  20123. * @param engine the engine
  20124. * @param data the data to use for this buffer
  20125. * @param updatable whether the data is updatable
  20126. * @param stride the stride (optional)
  20127. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20128. * @param instanced whether the buffer is instanced (optional)
  20129. * @param useBytes set to true if the stride in in bytes (optional)
  20130. */
  20131. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20132. /**
  20133. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20134. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20135. * @param offset defines offset in the buffer (0 by default)
  20136. * @param size defines the size in floats of attributes (position is 3 for instance)
  20137. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20138. * @param instanced defines if the vertex buffer contains indexed data
  20139. * @param useBytes defines if the offset and stride are in bytes
  20140. * @returns the new vertex buffer
  20141. */
  20142. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20143. isUpdatable(): boolean;
  20144. getData(): Nullable<DataArray>;
  20145. getBuffer(): Nullable<WebGLBuffer>;
  20146. /**
  20147. * Gets the stride in float32 units (i.e. byte stride / 4).
  20148. * May not be an integer if the byte stride is not divisible by 4.
  20149. * DEPRECATED. Use byteStride instead.
  20150. * @returns the stride in float32 units
  20151. */
  20152. getStrideSize(): number;
  20153. create(data?: Nullable<DataArray>): void;
  20154. _rebuild(): void;
  20155. update(data: DataArray): void;
  20156. /**
  20157. * Updates the data directly.
  20158. * @param data the new data
  20159. * @param offset the new offset
  20160. * @param vertexCount the vertex count (optional)
  20161. * @param useBytes set to true if the offset is in bytes
  20162. */
  20163. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20164. dispose(): void;
  20165. }
  20166. }
  20167. declare module BABYLON {
  20168. class CSG {
  20169. private polygons;
  20170. matrix: Matrix;
  20171. position: Vector3;
  20172. rotation: Vector3;
  20173. rotationQuaternion: Nullable<Quaternion>;
  20174. scaling: Vector3;
  20175. static FromMesh(mesh: Mesh): CSG;
  20176. private static FromPolygons(polygons);
  20177. clone(): CSG;
  20178. union(csg: CSG): CSG;
  20179. unionInPlace(csg: CSG): void;
  20180. subtract(csg: CSG): CSG;
  20181. subtractInPlace(csg: CSG): void;
  20182. intersect(csg: CSG): CSG;
  20183. intersectInPlace(csg: CSG): void;
  20184. inverse(): CSG;
  20185. inverseInPlace(): void;
  20186. copyTransformAttributes(csg: CSG): CSG;
  20187. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20188. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20189. }
  20190. }
  20191. declare module BABYLON {
  20192. /**
  20193. * Class used to store geometry data (vertex buffers + index buffer)
  20194. */
  20195. class Geometry implements IGetSetVerticesData {
  20196. /**
  20197. * Gets or sets the unique ID of the geometry
  20198. */
  20199. id: string;
  20200. /**
  20201. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20202. */
  20203. delayLoadState: number;
  20204. /**
  20205. * Gets the file containing the data to load when running in delay load state
  20206. */
  20207. delayLoadingFile: Nullable<string>;
  20208. /**
  20209. * Callback called when the geometry is updated
  20210. */
  20211. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20212. private _scene;
  20213. private _engine;
  20214. private _meshes;
  20215. private _totalVertices;
  20216. private _indices;
  20217. private _vertexBuffers;
  20218. private _isDisposed;
  20219. private _extend;
  20220. private _boundingBias;
  20221. /** @hidden */
  20222. _delayInfo: Array<string>;
  20223. private _indexBuffer;
  20224. private _indexBufferIsUpdatable;
  20225. /** @hidden */
  20226. _boundingInfo: Nullable<BoundingInfo>;
  20227. /** @hidden */
  20228. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20229. /** @hidden */
  20230. _softwareSkinningRenderId: number;
  20231. private _vertexArrayObjects;
  20232. private _updatable;
  20233. /** @hidden */
  20234. _positions: Nullable<Vector3[]>;
  20235. /**
  20236. * 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
  20237. */
  20238. /**
  20239. * 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
  20240. */
  20241. boundingBias: Vector2;
  20242. /**
  20243. * Static function used to attach a new empty geometry to a mesh
  20244. * @param mesh defines the mesh to attach the geometry to
  20245. * @returns the new {BABYLON.Geometry}
  20246. */
  20247. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20248. /**
  20249. * Creates a new geometry
  20250. * @param id defines the unique ID
  20251. * @param scene defines the hosting scene
  20252. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20253. * @param updatable defines if geometry must be updatable (false by default)
  20254. * @param mesh defines the mesh that will be associated with the geometry
  20255. */
  20256. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20257. /**
  20258. * Gets the current extend of the geometry
  20259. */
  20260. readonly extend: {
  20261. minimum: Vector3;
  20262. maximum: Vector3;
  20263. };
  20264. /**
  20265. * Gets the hosting scene
  20266. * @returns the hosting {BABYLON.Scene}
  20267. */
  20268. getScene(): Scene;
  20269. /**
  20270. * Gets the hosting engine
  20271. * @returns the hosting {BABYLON.Engine}
  20272. */
  20273. getEngine(): Engine;
  20274. /**
  20275. * Defines if the geometry is ready to use
  20276. * @returns true if the geometry is ready to be used
  20277. */
  20278. isReady(): boolean;
  20279. /**
  20280. * Gets a value indicating that the geometry should not be serialized
  20281. */
  20282. readonly doNotSerialize: boolean;
  20283. /** @hidden */
  20284. _rebuild(): void;
  20285. /**
  20286. * Affects all gemetry data in one call
  20287. * @param vertexData defines the geometry data
  20288. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20289. */
  20290. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20291. /**
  20292. * Set specific vertex data
  20293. * @param kind defines the data kind (Position, normal, etc...)
  20294. * @param data defines the vertex data to use
  20295. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20296. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20297. */
  20298. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20299. /**
  20300. * Removes a specific vertex data
  20301. * @param kind defines the data kind (Position, normal, etc...)
  20302. */
  20303. removeVerticesData(kind: string): void;
  20304. /**
  20305. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20306. * @param buffer defines the vertex buffer to use
  20307. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20308. */
  20309. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20310. /**
  20311. * Update a specific vertex buffer
  20312. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20313. * It will do nothing if the buffer is not updatable
  20314. * @param kind defines the data kind (Position, normal, etc...)
  20315. * @param data defines the data to use
  20316. * @param offset defines the offset in the target buffer where to store the data
  20317. * @param useBytes set to true if the offset is in bytes
  20318. */
  20319. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20320. /**
  20321. * Update a specific vertex buffer
  20322. * This function will create a new buffer if the current one is not updatable
  20323. * @param kind defines the data kind (Position, normal, etc...)
  20324. * @param data defines the data to use
  20325. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20326. */
  20327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20328. private _updateBoundingInfo(updateExtends, data);
  20329. /** @hidden */
  20330. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20331. /**
  20332. * Gets total number of vertices
  20333. * @returns the total number of vertices
  20334. */
  20335. getTotalVertices(): number;
  20336. /**
  20337. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20338. * @param kind defines the data kind (Position, normal, etc...)
  20339. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20341. * @returns a float array containing vertex data
  20342. */
  20343. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20344. /**
  20345. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20346. * @param kind defines the data kind (Position, normal, etc...)
  20347. * @returns true if the vertex buffer with the specified kind is updatable
  20348. */
  20349. isVertexBufferUpdatable(kind: string): boolean;
  20350. /**
  20351. * Gets a specific vertex buffer
  20352. * @param kind defines the data kind (Position, normal, etc...)
  20353. * @returns a {BABYLON.VertexBuffer}
  20354. */
  20355. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20356. /**
  20357. * Returns all vertex buffers
  20358. * @return an object holding all vertex buffers indexed by kind
  20359. */
  20360. getVertexBuffers(): Nullable<{
  20361. [key: string]: VertexBuffer;
  20362. }>;
  20363. /**
  20364. * Gets a boolean indicating if specific vertex buffer is present
  20365. * @param kind defines the data kind (Position, normal, etc...)
  20366. * @returns true if data is present
  20367. */
  20368. isVerticesDataPresent(kind: string): boolean;
  20369. /**
  20370. * Gets a list of all attached data kinds (Position, normal, etc...)
  20371. * @returns a list of string containing all kinds
  20372. */
  20373. getVerticesDataKinds(): string[];
  20374. /**
  20375. * Update index buffer
  20376. * @param indices defines the indices to store in the index buffer
  20377. * @param offset defines the offset in the target buffer where to store the data
  20378. */
  20379. updateIndices(indices: IndicesArray, offset?: number): void;
  20380. /**
  20381. * Creates a new index buffer
  20382. * @param indices defines the indices to store in the index buffer
  20383. * @param totalVertices defines the total number of vertices (could be null)
  20384. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20385. */
  20386. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20387. /**
  20388. * Return the total number of indices
  20389. * @returns the total number of indices
  20390. */
  20391. getTotalIndices(): number;
  20392. /**
  20393. * Gets the index buffer array
  20394. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20395. * @returns the index buffer array
  20396. */
  20397. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20398. /**
  20399. * Gets the index buffer
  20400. * @return the index buffer
  20401. */
  20402. getIndexBuffer(): Nullable<WebGLBuffer>;
  20403. /** @hidden */
  20404. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20405. /**
  20406. * Release the associated resources for a specific mesh
  20407. * @param mesh defines the source mesh
  20408. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20409. */
  20410. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20411. /**
  20412. * Apply current geometry to a given mesh
  20413. * @param mesh defines the mesh to apply geometry to
  20414. */
  20415. applyToMesh(mesh: Mesh): void;
  20416. private _updateExtend(data?);
  20417. private _applyToMesh(mesh);
  20418. private notifyUpdate(kind?);
  20419. /**
  20420. * Load the geometry if it was flagged as delay loaded
  20421. * @param scene defines the hosting scene
  20422. * @param onLoaded defines a callback called when the geometry is loaded
  20423. */
  20424. load(scene: Scene, onLoaded?: () => void): void;
  20425. private _queueLoad(scene, onLoaded?);
  20426. /**
  20427. * Invert the geometry to move from a right handed system to a left handed one.
  20428. */
  20429. toLeftHanded(): void;
  20430. /** @hidden */
  20431. _resetPointsArrayCache(): void;
  20432. /** @hidden */
  20433. _generatePointsArray(): boolean;
  20434. /**
  20435. * Gets a value indicating if the geometry is disposed
  20436. * @returns true if the geometry was disposed
  20437. */
  20438. isDisposed(): boolean;
  20439. private _disposeVertexArrayObjects();
  20440. /**
  20441. * Free all associated resources
  20442. */
  20443. dispose(): void;
  20444. /**
  20445. * Clone the current geometry into a new geometry
  20446. * @param id defines the unique ID of the new geometry
  20447. * @returns a new geometry object
  20448. */
  20449. copy(id: string): Geometry;
  20450. /**
  20451. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20452. * @return a JSON representation of the current geometry data (without the vertices data)
  20453. */
  20454. serialize(): any;
  20455. private toNumberArray(origin);
  20456. /**
  20457. * Serialize all vertices data into a JSON oject
  20458. * @returns a JSON representation of the current geometry data
  20459. */
  20460. serializeVerticeData(): any;
  20461. /**
  20462. * Extracts a clone of a mesh geometry
  20463. * @param mesh defines the source mesh
  20464. * @param id defines the unique ID of the new geometry object
  20465. * @returns the new geometry object
  20466. */
  20467. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20468. /**
  20469. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20470. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20471. * Be aware Math.random() could cause collisions, but:
  20472. * "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"
  20473. * @returns a string containing a new GUID
  20474. */
  20475. static RandomId(): string;
  20476. /** @hidden */
  20477. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20478. private static _CleanMatricesWeights(parsedGeometry, mesh);
  20479. /**
  20480. * Create a new geometry from persisted data (Using .babylon file format)
  20481. * @param parsedVertexData defines the persisted data
  20482. * @param scene defines the hosting scene
  20483. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20484. * @returns the new geometry object
  20485. */
  20486. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20487. }
  20488. /**
  20489. * Abstract class used to provide common services for all typed geometries
  20490. * @hidden
  20491. */
  20492. class _PrimitiveGeometry extends Geometry {
  20493. private _canBeRegenerated;
  20494. private _beingRegenerated;
  20495. /**
  20496. * Creates a new typed geometry
  20497. * @param id defines the unique ID of the geometry
  20498. * @param scene defines the hosting scene
  20499. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20500. * @param mesh defines the hosting mesh (can be null)
  20501. */
  20502. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20503. /**
  20504. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20505. * @returns true if the geometry can be regenerated
  20506. */
  20507. canBeRegenerated(): boolean;
  20508. /**
  20509. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20510. */
  20511. regenerate(): void;
  20512. /**
  20513. * Clone the geometry
  20514. * @param id defines the unique ID of the new geometry
  20515. * @returns the new geometry
  20516. */
  20517. asNewGeometry(id: string): Geometry;
  20518. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20519. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20520. /** @hidden */
  20521. _regenerateVertexData(): VertexData;
  20522. copy(id: string): Geometry;
  20523. serialize(): any;
  20524. }
  20525. /**
  20526. * Creates a ribbon geometry
  20527. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20528. */
  20529. class RibbonGeometry extends _PrimitiveGeometry {
  20530. /**
  20531. * Defines the array of paths to use
  20532. */
  20533. pathArray: Vector3[][];
  20534. /**
  20535. * Defines if the last and first points of each path in your pathArray must be joined
  20536. */
  20537. closeArray: boolean;
  20538. /**
  20539. * Defines if the last and first points of each path in your pathArray must be joined
  20540. */
  20541. closePath: boolean;
  20542. /**
  20543. * Defines the offset between points
  20544. */
  20545. offset: number;
  20546. /**
  20547. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20548. */
  20549. side: number;
  20550. /**
  20551. * Creates a ribbon geometry
  20552. * @param id defines the unique ID of the geometry
  20553. * @param scene defines the hosting scene
  20554. * @param pathArray defines the array of paths to use
  20555. * @param closeArray defines if the last path and the first path must be joined
  20556. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20557. * @param offset defines the offset between points
  20558. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20559. * @param mesh defines the hosting mesh (can be null)
  20560. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20561. */
  20562. constructor(id: string, scene: Scene,
  20563. /**
  20564. * Defines the array of paths to use
  20565. */
  20566. pathArray: Vector3[][],
  20567. /**
  20568. * Defines if the last and first points of each path in your pathArray must be joined
  20569. */
  20570. closeArray: boolean,
  20571. /**
  20572. * Defines if the last and first points of each path in your pathArray must be joined
  20573. */
  20574. closePath: boolean,
  20575. /**
  20576. * Defines the offset between points
  20577. */
  20578. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20579. /**
  20580. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20581. */
  20582. side?: number);
  20583. /** @hidden */
  20584. _regenerateVertexData(): VertexData;
  20585. copy(id: string): Geometry;
  20586. }
  20587. /**
  20588. * Creates a box geometry
  20589. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20590. */
  20591. class BoxGeometry extends _PrimitiveGeometry {
  20592. /**
  20593. * Defines the zise of the box (width, height and depth are the same)
  20594. */
  20595. size: number;
  20596. /**
  20597. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20598. */
  20599. side: number;
  20600. /**
  20601. * Creates a box geometry
  20602. * @param id defines the unique ID of the geometry
  20603. * @param scene defines the hosting scene
  20604. * @param size defines the zise of the box (width, height and depth are the same)
  20605. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20606. * @param mesh defines the hosting mesh (can be null)
  20607. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20608. */
  20609. constructor(id: string, scene: Scene,
  20610. /**
  20611. * Defines the zise of the box (width, height and depth are the same)
  20612. */
  20613. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20614. /**
  20615. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20616. */
  20617. side?: number);
  20618. _regenerateVertexData(): VertexData;
  20619. copy(id: string): Geometry;
  20620. serialize(): any;
  20621. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20622. }
  20623. /**
  20624. * Creates a sphere geometry
  20625. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20626. */
  20627. class SphereGeometry extends _PrimitiveGeometry {
  20628. /**
  20629. * Defines the number of segments to use to create the sphere
  20630. */
  20631. segments: number;
  20632. /**
  20633. * Defines the diameter of the sphere
  20634. */
  20635. diameter: number;
  20636. /**
  20637. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20638. */
  20639. side: number;
  20640. /**
  20641. * Create a new sphere geometry
  20642. * @param id defines the unique ID of the geometry
  20643. * @param scene defines the hosting scene
  20644. * @param segments defines the number of segments to use to create the sphere
  20645. * @param diameter defines the diameter of the sphere
  20646. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20647. * @param mesh defines the hosting mesh (can be null)
  20648. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20649. */
  20650. constructor(id: string, scene: Scene,
  20651. /**
  20652. * Defines the number of segments to use to create the sphere
  20653. */
  20654. segments: number,
  20655. /**
  20656. * Defines the diameter of the sphere
  20657. */
  20658. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20659. /**
  20660. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20661. */
  20662. side?: number);
  20663. _regenerateVertexData(): VertexData;
  20664. copy(id: string): Geometry;
  20665. serialize(): any;
  20666. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20667. }
  20668. /**
  20669. * Creates a disc geometry
  20670. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20671. */
  20672. class DiscGeometry extends _PrimitiveGeometry {
  20673. /**
  20674. * Defines the radius of the disc
  20675. */
  20676. radius: number;
  20677. /**
  20678. * Defines the tesselation factor to apply to the disc
  20679. */
  20680. tessellation: number;
  20681. /**
  20682. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20683. */
  20684. side: number;
  20685. /**
  20686. * Creates a new disc geometry
  20687. * @param id defines the unique ID of the geometry
  20688. * @param scene defines the hosting scene
  20689. * @param radius defines the radius of the disc
  20690. * @param tessellation defines the tesselation factor to apply to the disc
  20691. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20692. * @param mesh defines the hosting mesh (can be null)
  20693. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20694. */
  20695. constructor(id: string, scene: Scene,
  20696. /**
  20697. * Defines the radius of the disc
  20698. */
  20699. radius: number,
  20700. /**
  20701. * Defines the tesselation factor to apply to the disc
  20702. */
  20703. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20704. /**
  20705. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20706. */
  20707. side?: number);
  20708. _regenerateVertexData(): VertexData;
  20709. copy(id: string): Geometry;
  20710. }
  20711. /**
  20712. * Creates a new cylinder geometry
  20713. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20714. */
  20715. class CylinderGeometry extends _PrimitiveGeometry {
  20716. /**
  20717. * Defines the height of the cylinder
  20718. */
  20719. height: number;
  20720. /**
  20721. * Defines the diameter of the cylinder's top cap
  20722. */
  20723. diameterTop: number;
  20724. /**
  20725. * Defines the diameter of the cylinder's bottom cap
  20726. */
  20727. diameterBottom: number;
  20728. /**
  20729. * Defines the tessellation factor to apply to the cylinder
  20730. */
  20731. tessellation: number;
  20732. /**
  20733. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20734. */
  20735. subdivisions: number;
  20736. /**
  20737. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20738. */
  20739. side: number;
  20740. /**
  20741. * Creates a new cylinder geometry
  20742. * @param id defines the unique ID of the geometry
  20743. * @param scene defines the hosting scene
  20744. * @param height defines the height of the cylinder
  20745. * @param diameterTop defines the diameter of the cylinder's top cap
  20746. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20747. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20748. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20749. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20750. * @param mesh defines the hosting mesh (can be null)
  20751. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20752. */
  20753. constructor(id: string, scene: Scene,
  20754. /**
  20755. * Defines the height of the cylinder
  20756. */
  20757. height: number,
  20758. /**
  20759. * Defines the diameter of the cylinder's top cap
  20760. */
  20761. diameterTop: number,
  20762. /**
  20763. * Defines the diameter of the cylinder's bottom cap
  20764. */
  20765. diameterBottom: number,
  20766. /**
  20767. * Defines the tessellation factor to apply to the cylinder
  20768. */
  20769. tessellation: number,
  20770. /**
  20771. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20772. */
  20773. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20774. /**
  20775. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20776. */
  20777. side?: number);
  20778. _regenerateVertexData(): VertexData;
  20779. copy(id: string): Geometry;
  20780. serialize(): any;
  20781. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20782. }
  20783. /**
  20784. * Creates a new torus geometry
  20785. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20786. */
  20787. class TorusGeometry extends _PrimitiveGeometry {
  20788. /**
  20789. * Defines the diameter of the torus
  20790. */
  20791. diameter: number;
  20792. /**
  20793. * Defines the thickness of the torus (ie. internal diameter)
  20794. */
  20795. thickness: number;
  20796. /**
  20797. * Defines the tesselation factor to apply to the torus
  20798. */
  20799. tessellation: number;
  20800. /**
  20801. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20802. */
  20803. side: number;
  20804. /**
  20805. * Creates a new torus geometry
  20806. * @param id defines the unique ID of the geometry
  20807. * @param scene defines the hosting scene
  20808. * @param diameter defines the diameter of the torus
  20809. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20810. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20811. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20812. * @param mesh defines the hosting mesh (can be null)
  20813. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20814. */
  20815. constructor(id: string, scene: Scene,
  20816. /**
  20817. * Defines the diameter of the torus
  20818. */
  20819. diameter: number,
  20820. /**
  20821. * Defines the thickness of the torus (ie. internal diameter)
  20822. */
  20823. thickness: number,
  20824. /**
  20825. * Defines the tesselation factor to apply to the torus
  20826. */
  20827. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20828. /**
  20829. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20830. */
  20831. side?: number);
  20832. _regenerateVertexData(): VertexData;
  20833. copy(id: string): Geometry;
  20834. serialize(): any;
  20835. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20836. }
  20837. /**
  20838. * Creates a new ground geometry
  20839. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20840. */
  20841. class GroundGeometry extends _PrimitiveGeometry {
  20842. /**
  20843. * Defines the width of the ground
  20844. */
  20845. width: number;
  20846. /**
  20847. * Defines the height of the ground
  20848. */
  20849. height: number;
  20850. /**
  20851. * Defines the subdivisions to apply to the ground
  20852. */
  20853. subdivisions: number;
  20854. /**
  20855. * Creates a new ground geometry
  20856. * @param id defines the unique ID of the geometry
  20857. * @param scene defines the hosting scene
  20858. * @param width defines the width of the ground
  20859. * @param height defines the height of the ground
  20860. * @param subdivisions defines the subdivisions to apply to the ground
  20861. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20862. * @param mesh defines the hosting mesh (can be null)
  20863. */
  20864. constructor(id: string, scene: Scene,
  20865. /**
  20866. * Defines the width of the ground
  20867. */
  20868. width: number,
  20869. /**
  20870. * Defines the height of the ground
  20871. */
  20872. height: number,
  20873. /**
  20874. * Defines the subdivisions to apply to the ground
  20875. */
  20876. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20877. _regenerateVertexData(): VertexData;
  20878. copy(id: string): Geometry;
  20879. serialize(): any;
  20880. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20881. }
  20882. /**
  20883. * Creates a tiled ground geometry
  20884. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20885. */
  20886. class TiledGroundGeometry extends _PrimitiveGeometry {
  20887. /**
  20888. * Defines the minimum value on X axis
  20889. */
  20890. xmin: number;
  20891. /**
  20892. * Defines the minimum value on Z axis
  20893. */
  20894. zmin: number;
  20895. /**
  20896. * Defines the maximum value on X axis
  20897. */
  20898. xmax: number;
  20899. /**
  20900. * Defines the maximum value on Z axis
  20901. */
  20902. zmax: number;
  20903. /**
  20904. * Defines the subdivisions to apply to the ground
  20905. */
  20906. subdivisions: {
  20907. w: number;
  20908. h: number;
  20909. };
  20910. /**
  20911. * Defines the precision to use when computing the tiles
  20912. */
  20913. precision: {
  20914. w: number;
  20915. h: number;
  20916. };
  20917. /**
  20918. * Creates a tiled ground geometry
  20919. * @param id defines the unique ID of the geometry
  20920. * @param scene defines the hosting scene
  20921. * @param xmin defines the minimum value on X axis
  20922. * @param zmin defines the minimum value on Z axis
  20923. * @param xmax defines the maximum value on X axis
  20924. * @param zmax defines the maximum value on Z axis
  20925. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20926. * @param precision defines the precision to use when computing the tiles
  20927. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20928. * @param mesh defines the hosting mesh (can be null)
  20929. */
  20930. constructor(id: string, scene: Scene,
  20931. /**
  20932. * Defines the minimum value on X axis
  20933. */
  20934. xmin: number,
  20935. /**
  20936. * Defines the minimum value on Z axis
  20937. */
  20938. zmin: number,
  20939. /**
  20940. * Defines the maximum value on X axis
  20941. */
  20942. xmax: number,
  20943. /**
  20944. * Defines the maximum value on Z axis
  20945. */
  20946. zmax: number,
  20947. /**
  20948. * Defines the subdivisions to apply to the ground
  20949. */
  20950. subdivisions: {
  20951. w: number;
  20952. h: number;
  20953. },
  20954. /**
  20955. * Defines the precision to use when computing the tiles
  20956. */
  20957. precision: {
  20958. w: number;
  20959. h: number;
  20960. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20961. _regenerateVertexData(): VertexData;
  20962. copy(id: string): Geometry;
  20963. }
  20964. /**
  20965. * Creates a plane geometry
  20966. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20967. */
  20968. class PlaneGeometry extends _PrimitiveGeometry {
  20969. /**
  20970. * Defines the size of the plane (width === height)
  20971. */
  20972. size: number;
  20973. /**
  20974. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20975. */
  20976. side: number;
  20977. /**
  20978. * Creates a plane geometry
  20979. * @param id defines the unique ID of the geometry
  20980. * @param scene defines the hosting scene
  20981. * @param size defines the size of the plane (width === height)
  20982. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20983. * @param mesh defines the hosting mesh (can be null)
  20984. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20985. */
  20986. constructor(id: string, scene: Scene,
  20987. /**
  20988. * Defines the size of the plane (width === height)
  20989. */
  20990. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20991. /**
  20992. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20993. */
  20994. side?: number);
  20995. _regenerateVertexData(): VertexData;
  20996. copy(id: string): Geometry;
  20997. serialize(): any;
  20998. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20999. }
  21000. /**
  21001. * Creates a torus knot geometry
  21002. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21003. */
  21004. class TorusKnotGeometry extends _PrimitiveGeometry {
  21005. /**
  21006. * Defines the radius of the torus knot
  21007. */
  21008. radius: number;
  21009. /**
  21010. * Defines the thickness of the torus knot tube
  21011. */
  21012. tube: number;
  21013. /**
  21014. * Defines the number of radial segments
  21015. */
  21016. radialSegments: number;
  21017. /**
  21018. * Defines the number of tubular segments
  21019. */
  21020. tubularSegments: number;
  21021. /**
  21022. * Defines the first number of windings
  21023. */
  21024. p: number;
  21025. /**
  21026. * Defines the second number of windings
  21027. */
  21028. q: number;
  21029. /**
  21030. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21031. */
  21032. side: number;
  21033. /**
  21034. * Creates a torus knot geometry
  21035. * @param id defines the unique ID of the geometry
  21036. * @param scene defines the hosting scene
  21037. * @param radius defines the radius of the torus knot
  21038. * @param tube defines the thickness of the torus knot tube
  21039. * @param radialSegments defines the number of radial segments
  21040. * @param tubularSegments defines the number of tubular segments
  21041. * @param p defines the first number of windings
  21042. * @param q defines the second number of windings
  21043. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21044. * @param mesh defines the hosting mesh (can be null)
  21045. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21046. */
  21047. constructor(id: string, scene: Scene,
  21048. /**
  21049. * Defines the radius of the torus knot
  21050. */
  21051. radius: number,
  21052. /**
  21053. * Defines the thickness of the torus knot tube
  21054. */
  21055. tube: number,
  21056. /**
  21057. * Defines the number of radial segments
  21058. */
  21059. radialSegments: number,
  21060. /**
  21061. * Defines the number of tubular segments
  21062. */
  21063. tubularSegments: number,
  21064. /**
  21065. * Defines the first number of windings
  21066. */
  21067. p: number,
  21068. /**
  21069. * Defines the second number of windings
  21070. */
  21071. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21072. /**
  21073. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21074. */
  21075. side?: number);
  21076. _regenerateVertexData(): VertexData;
  21077. copy(id: string): Geometry;
  21078. serialize(): any;
  21079. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21080. }
  21081. }
  21082. declare module BABYLON {
  21083. class GroundMesh extends Mesh {
  21084. generateOctree: boolean;
  21085. private _heightQuads;
  21086. _subdivisionsX: number;
  21087. _subdivisionsY: number;
  21088. _width: number;
  21089. _height: number;
  21090. _minX: number;
  21091. _maxX: number;
  21092. _minZ: number;
  21093. _maxZ: number;
  21094. constructor(name: string, scene: Scene);
  21095. getClassName(): string;
  21096. readonly subdivisions: number;
  21097. readonly subdivisionsX: number;
  21098. readonly subdivisionsY: number;
  21099. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21100. /**
  21101. * Returns a height (y) value in the Worl system :
  21102. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21103. * Returns the ground y position if (x, z) are outside the ground surface.
  21104. */
  21105. getHeightAtCoordinates(x: number, z: number): number;
  21106. /**
  21107. * Returns a normalized vector (Vector3) orthogonal to the ground
  21108. * at the ground coordinates (x, z) expressed in the World system.
  21109. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21110. */
  21111. getNormalAtCoordinates(x: number, z: number): Vector3;
  21112. /**
  21113. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21114. * at the ground coordinates (x, z) expressed in the World system.
  21115. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21116. * Returns the GroundMesh.
  21117. */
  21118. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21119. /**
  21120. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21121. * if the ground has been updated.
  21122. * This can be used in the render loop.
  21123. * Returns the GroundMesh.
  21124. */
  21125. updateCoordinateHeights(): GroundMesh;
  21126. private _getFacetAt(x, z);
  21127. private _initHeightQuads();
  21128. private _computeHeightQuads();
  21129. serialize(serializationObject: any): void;
  21130. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21131. }
  21132. }
  21133. declare module BABYLON {
  21134. /**
  21135. * Creates an instance based on a source mesh.
  21136. */
  21137. class InstancedMesh extends AbstractMesh {
  21138. private _sourceMesh;
  21139. private _currentLOD;
  21140. constructor(name: string, source: Mesh);
  21141. /**
  21142. * Returns the string "InstancedMesh".
  21143. */
  21144. getClassName(): string;
  21145. readonly receiveShadows: boolean;
  21146. readonly material: Nullable<Material>;
  21147. readonly visibility: number;
  21148. readonly skeleton: Nullable<Skeleton>;
  21149. renderingGroupId: number;
  21150. /**
  21151. * Returns the total number of vertices (integer).
  21152. */
  21153. getTotalVertices(): number;
  21154. readonly sourceMesh: Mesh;
  21155. /**
  21156. * Is this node ready to be used/rendered
  21157. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21158. * @return {boolean} is it ready
  21159. */
  21160. isReady(completeCheck?: boolean): boolean;
  21161. /**
  21162. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21163. */
  21164. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21165. /**
  21166. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21167. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21168. * The `data` are either a numeric array either a Float32Array.
  21169. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21170. * 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).
  21171. * Note that a new underlying VertexBuffer object is created each call.
  21172. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21173. *
  21174. * Possible `kind` values :
  21175. * - BABYLON.VertexBuffer.PositionKind
  21176. * - BABYLON.VertexBuffer.UVKind
  21177. * - BABYLON.VertexBuffer.UV2Kind
  21178. * - BABYLON.VertexBuffer.UV3Kind
  21179. * - BABYLON.VertexBuffer.UV4Kind
  21180. * - BABYLON.VertexBuffer.UV5Kind
  21181. * - BABYLON.VertexBuffer.UV6Kind
  21182. * - BABYLON.VertexBuffer.ColorKind
  21183. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21184. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21185. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21186. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21187. *
  21188. * Returns the Mesh.
  21189. */
  21190. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21191. /**
  21192. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21193. * If the mesh has no geometry, it is simply returned as it is.
  21194. * The `data` are either a numeric array either a Float32Array.
  21195. * No new underlying VertexBuffer object is created.
  21196. * 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.
  21197. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21198. *
  21199. * Possible `kind` values :
  21200. * - BABYLON.VertexBuffer.PositionKind
  21201. * - BABYLON.VertexBuffer.UVKind
  21202. * - BABYLON.VertexBuffer.UV2Kind
  21203. * - BABYLON.VertexBuffer.UV3Kind
  21204. * - BABYLON.VertexBuffer.UV4Kind
  21205. * - BABYLON.VertexBuffer.UV5Kind
  21206. * - BABYLON.VertexBuffer.UV6Kind
  21207. * - BABYLON.VertexBuffer.ColorKind
  21208. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21209. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21210. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21211. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21212. *
  21213. * Returns the Mesh.
  21214. */
  21215. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21216. /**
  21217. * Sets the mesh indices.
  21218. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21219. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21220. * This method creates a new index buffer each call.
  21221. * Returns the Mesh.
  21222. */
  21223. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21224. /**
  21225. * Boolean : True if the mesh owns the requested kind of data.
  21226. */
  21227. isVerticesDataPresent(kind: string): boolean;
  21228. /**
  21229. * Returns an array of indices (IndicesArray).
  21230. */
  21231. getIndices(): Nullable<IndicesArray>;
  21232. readonly _positions: Nullable<Vector3[]>;
  21233. /**
  21234. * Sets a new updated BoundingInfo to the mesh.
  21235. * Returns the mesh.
  21236. */
  21237. refreshBoundingInfo(): InstancedMesh;
  21238. _preActivate(): InstancedMesh;
  21239. _activate(renderId: number): InstancedMesh;
  21240. /**
  21241. * Returns the current associated LOD AbstractMesh.
  21242. */
  21243. getLOD(camera: Camera): AbstractMesh;
  21244. _syncSubMeshes(): InstancedMesh;
  21245. _generatePointsArray(): boolean;
  21246. /**
  21247. * Creates a new InstancedMesh from the current mesh.
  21248. * - name (string) : the cloned mesh name
  21249. * - newParent (optional Node) : the optional Node to parent the clone to.
  21250. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21251. *
  21252. * Returns the clone.
  21253. */
  21254. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21255. /**
  21256. * Disposes the InstancedMesh.
  21257. * Returns nothing.
  21258. */
  21259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21260. }
  21261. }
  21262. declare module BABYLON {
  21263. class LinesMesh extends Mesh {
  21264. useVertexColor: boolean | undefined;
  21265. useVertexAlpha: boolean | undefined;
  21266. color: Color3;
  21267. alpha: number;
  21268. /**
  21269. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21270. * This margin is expressed in world space coordinates, so its value may vary.
  21271. * Default value is 0.1
  21272. * @returns the intersection Threshold value.
  21273. */
  21274. /**
  21275. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21276. * This margin is expressed in world space coordinates, so its value may vary.
  21277. * @param value the new threshold to apply
  21278. */
  21279. intersectionThreshold: number;
  21280. private _intersectionThreshold;
  21281. private _colorShader;
  21282. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21283. /**
  21284. * Returns the string "LineMesh"
  21285. */
  21286. getClassName(): string;
  21287. material: Material;
  21288. readonly checkCollisions: boolean;
  21289. createInstance(name: string): InstancedMesh;
  21290. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21291. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21292. dispose(doNotRecurse?: boolean): void;
  21293. /**
  21294. * Returns a new LineMesh object cloned from the current one.
  21295. */
  21296. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21297. }
  21298. }
  21299. declare module BABYLON {
  21300. /**
  21301. * @hidden
  21302. **/
  21303. class _InstancesBatch {
  21304. mustReturn: boolean;
  21305. visibleInstances: Nullable<InstancedMesh[]>[];
  21306. renderSelf: boolean[];
  21307. }
  21308. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21309. static _FRONTSIDE: number;
  21310. static _BACKSIDE: number;
  21311. static _DOUBLESIDE: number;
  21312. static _DEFAULTSIDE: number;
  21313. static _NO_CAP: number;
  21314. static _CAP_START: number;
  21315. static _CAP_END: number;
  21316. static _CAP_ALL: number;
  21317. /**
  21318. * Mesh side orientation : usually the external or front surface
  21319. */
  21320. static readonly FRONTSIDE: number;
  21321. /**
  21322. * Mesh side orientation : usually the internal or back surface
  21323. */
  21324. static readonly BACKSIDE: number;
  21325. /**
  21326. * Mesh side orientation : both internal and external or front and back surfaces
  21327. */
  21328. static readonly DOUBLESIDE: number;
  21329. /**
  21330. * Mesh side orientation : by default, `FRONTSIDE`
  21331. */
  21332. static readonly DEFAULTSIDE: number;
  21333. /**
  21334. * Mesh cap setting : no cap
  21335. */
  21336. static readonly NO_CAP: number;
  21337. /**
  21338. * Mesh cap setting : one cap at the beginning of the mesh
  21339. */
  21340. static readonly CAP_START: number;
  21341. /**
  21342. * Mesh cap setting : one cap at the end of the mesh
  21343. */
  21344. static readonly CAP_END: number;
  21345. /**
  21346. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21347. */
  21348. static readonly CAP_ALL: number;
  21349. /**
  21350. * An event triggered before rendering the mesh
  21351. */
  21352. onBeforeRenderObservable: Observable<Mesh>;
  21353. /**
  21354. * An event triggered after rendering the mesh
  21355. */
  21356. onAfterRenderObservable: Observable<Mesh>;
  21357. /**
  21358. * An event triggered before drawing the mesh
  21359. */
  21360. onBeforeDrawObservable: Observable<Mesh>;
  21361. private _onBeforeDrawObserver;
  21362. onBeforeDraw: () => void;
  21363. delayLoadState: number;
  21364. instances: InstancedMesh[];
  21365. delayLoadingFile: string;
  21366. _binaryInfo: any;
  21367. private _LODLevels;
  21368. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  21369. private _morphTargetManager;
  21370. morphTargetManager: Nullable<MorphTargetManager>;
  21371. _geometry: Nullable<Geometry>;
  21372. _delayInfo: Array<string>;
  21373. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21374. _visibleInstances: any;
  21375. private _renderIdForInstances;
  21376. private _batchCache;
  21377. private _instancesBufferSize;
  21378. private _instancesBuffer;
  21379. private _instancesData;
  21380. private _overridenInstanceCount;
  21381. private _effectiveMaterial;
  21382. _shouldGenerateFlatShading: boolean;
  21383. private _preActivateId;
  21384. _originalBuilderSideOrientation: number;
  21385. overrideMaterialSideOrientation: Nullable<number>;
  21386. private _areNormalsFrozen;
  21387. private _sourcePositions;
  21388. private _sourceNormals;
  21389. private _source;
  21390. readonly source: Nullable<Mesh>;
  21391. isUnIndexed: boolean;
  21392. /**
  21393. * @constructor
  21394. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21395. * @param {Scene} scene The scene to add this mesh to.
  21396. * @param {Node} parent The parent of this mesh, if it has one
  21397. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21398. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21399. * When false, achieved by calling a clone(), also passing False.
  21400. * This will make creation of children, recursive.
  21401. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21402. */
  21403. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21404. /**
  21405. * Returns the string "Mesh".
  21406. */
  21407. getClassName(): string;
  21408. /**
  21409. * Returns a string.
  21410. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21411. */
  21412. toString(fullDetails?: boolean): string;
  21413. _unBindEffect(): void;
  21414. /**
  21415. * True if the mesh has some Levels Of Details (LOD).
  21416. * Returns a boolean.
  21417. */
  21418. readonly hasLODLevels: boolean;
  21419. /**
  21420. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21421. * @returns an array of {BABYLON.MeshLODLevel}
  21422. */
  21423. getLODLevels(): MeshLODLevel[];
  21424. private _sortLODLevels();
  21425. /**
  21426. * Add a mesh as LOD level triggered at the given distance.
  21427. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21428. * @param {number} distance The distance from the center of the object to show this level
  21429. * @param {Mesh} mesh The mesh to be added as LOD level
  21430. * @return {Mesh} This mesh (for chaining)
  21431. */
  21432. addLODLevel(distance: number, mesh: Mesh): Mesh;
  21433. /**
  21434. * Returns the LOD level mesh at the passed distance or null if not found.
  21435. * It is related to the method `addLODLevel(distance, mesh)`.
  21436. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21437. * Returns an object Mesh or `null`.
  21438. */
  21439. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21440. /**
  21441. * Remove a mesh from the LOD array
  21442. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21443. * @param {Mesh} mesh The mesh to be removed.
  21444. * @return {Mesh} This mesh (for chaining)
  21445. */
  21446. removeLODLevel(mesh: Mesh): Mesh;
  21447. /**
  21448. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21449. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21450. */
  21451. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  21452. /**
  21453. * Returns the mesh internal Geometry object.
  21454. */
  21455. readonly geometry: Nullable<Geometry>;
  21456. /**
  21457. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21458. */
  21459. getTotalVertices(): number;
  21460. /**
  21461. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21462. * 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.
  21463. * You can force the copy with forceCopy === true
  21464. * Returns null if the mesh has no geometry or no vertex buffer.
  21465. * Possible `kind` values :
  21466. * - BABYLON.VertexBuffer.PositionKind
  21467. * - BABYLON.VertexBuffer.UVKind
  21468. * - BABYLON.VertexBuffer.UV2Kind
  21469. * - BABYLON.VertexBuffer.UV3Kind
  21470. * - BABYLON.VertexBuffer.UV4Kind
  21471. * - BABYLON.VertexBuffer.UV5Kind
  21472. * - BABYLON.VertexBuffer.UV6Kind
  21473. * - BABYLON.VertexBuffer.ColorKind
  21474. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21475. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21476. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21477. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21478. */
  21479. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21480. /**
  21481. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21482. * Returns `null` if the mesh has no geometry.
  21483. * Possible `kind` values :
  21484. * - BABYLON.VertexBuffer.PositionKind
  21485. * - BABYLON.VertexBuffer.UVKind
  21486. * - BABYLON.VertexBuffer.UV2Kind
  21487. * - BABYLON.VertexBuffer.UV3Kind
  21488. * - BABYLON.VertexBuffer.UV4Kind
  21489. * - BABYLON.VertexBuffer.UV5Kind
  21490. * - BABYLON.VertexBuffer.UV6Kind
  21491. * - BABYLON.VertexBuffer.ColorKind
  21492. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21493. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21494. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21495. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21496. */
  21497. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21498. isVerticesDataPresent(kind: string): boolean;
  21499. /**
  21500. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21501. * Possible `kind` values :
  21502. * - BABYLON.VertexBuffer.PositionKind
  21503. * - BABYLON.VertexBuffer.UVKind
  21504. * - BABYLON.VertexBuffer.UV2Kind
  21505. * - BABYLON.VertexBuffer.UV3Kind
  21506. * - BABYLON.VertexBuffer.UV4Kind
  21507. * - BABYLON.VertexBuffer.UV5Kind
  21508. * - BABYLON.VertexBuffer.UV6Kind
  21509. * - BABYLON.VertexBuffer.ColorKind
  21510. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21511. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21512. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21513. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21514. */
  21515. isVertexBufferUpdatable(kind: string): boolean;
  21516. /**
  21517. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21518. * Possible `kind` values :
  21519. * - BABYLON.VertexBuffer.PositionKind
  21520. * - BABYLON.VertexBuffer.UVKind
  21521. * - BABYLON.VertexBuffer.UV2Kind
  21522. * - BABYLON.VertexBuffer.UV3Kind
  21523. * - BABYLON.VertexBuffer.UV4Kind
  21524. * - BABYLON.VertexBuffer.UV5Kind
  21525. * - BABYLON.VertexBuffer.UV6Kind
  21526. * - BABYLON.VertexBuffer.ColorKind
  21527. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21528. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21529. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21530. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21531. */
  21532. getVerticesDataKinds(): string[];
  21533. /**
  21534. * Returns a positive integer : the total number of indices in this mesh geometry.
  21535. * Returns zero if the mesh has no geometry.
  21536. */
  21537. getTotalIndices(): number;
  21538. /**
  21539. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21540. * 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.
  21541. * Returns an empty array if the mesh has no geometry.
  21542. */
  21543. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21544. readonly isBlocked: boolean;
  21545. /**
  21546. * Determine if the current mesh is ready to be rendered
  21547. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21548. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21549. * @returns true if all associated assets are ready (material, textures, shaders)
  21550. */
  21551. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21552. /**
  21553. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21554. * This property is pertinent only for updatable parametric shapes.
  21555. */
  21556. readonly areNormalsFrozen: boolean;
  21557. /**
  21558. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21559. * It has no effect at all on other shapes.
  21560. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21561. * Returns the Mesh.
  21562. */
  21563. freezeNormals(): Mesh;
  21564. /**
  21565. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21566. * It has no effect at all on other shapes.
  21567. * It reactivates the mesh normals computation if it was previously frozen.
  21568. * Returns the Mesh.
  21569. */
  21570. unfreezeNormals(): Mesh;
  21571. /**
  21572. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21573. */
  21574. overridenInstanceCount: number;
  21575. _preActivate(): Mesh;
  21576. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21577. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21578. /**
  21579. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21580. * This means the mesh underlying bounding box and sphere are recomputed.
  21581. * Returns the Mesh.
  21582. */
  21583. refreshBoundingInfo(): Mesh;
  21584. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21585. private _getPositionData(applySkeleton);
  21586. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21587. subdivide(count: number): void;
  21588. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21589. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21590. /**
  21591. * Sets the mesh VertexBuffer.
  21592. * Returns the Mesh.
  21593. */
  21594. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21596. /**
  21597. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21598. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21599. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21600. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21601. * Returns the Mesh.
  21602. */
  21603. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21604. /**
  21605. * Creates a un-shared specific occurence of the geometry for the mesh.
  21606. * Returns the Mesh.
  21607. */
  21608. makeGeometryUnique(): Mesh;
  21609. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21610. /**
  21611. * Update the current index buffer
  21612. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21613. * Returns the Mesh.
  21614. */
  21615. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21616. /**
  21617. * Invert the geometry to move from a right handed system to a left handed one.
  21618. * Returns the Mesh.
  21619. */
  21620. toLeftHanded(): Mesh;
  21621. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21622. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21623. /**
  21624. * Registers for this mesh a javascript function called just before the rendering process.
  21625. * This function is passed the current mesh.
  21626. * Return the Mesh.
  21627. */
  21628. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21629. /**
  21630. * Disposes a previously registered javascript function called before the rendering.
  21631. * This function is passed the current mesh.
  21632. * Returns the Mesh.
  21633. */
  21634. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21635. /**
  21636. * Registers for this mesh a javascript function called just after the rendering is complete.
  21637. * This function is passed the current mesh.
  21638. * Returns the Mesh.
  21639. */
  21640. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21641. /**
  21642. * Disposes a previously registered javascript function called after the rendering.
  21643. * This function is passed the current mesh.
  21644. * Return the Mesh.
  21645. */
  21646. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21647. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21648. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21649. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21650. /**
  21651. * Triggers the draw call for the mesh.
  21652. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  21653. * Returns the Mesh.
  21654. */
  21655. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21656. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21657. /**
  21658. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21659. */
  21660. getEmittedParticleSystems(): IParticleSystem[];
  21661. /**
  21662. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21663. */
  21664. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21665. /**
  21666. * Normalize matrix weights so that all vertices have a total weight set to 1
  21667. */
  21668. cleanMatrixWeights(): void;
  21669. _checkDelayState(): Mesh;
  21670. private _queueLoad(scene);
  21671. /**
  21672. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21673. */
  21674. isInFrustum(frustumPlanes: Plane[]): boolean;
  21675. /**
  21676. * Sets the mesh material by the material or multiMaterial `id` property.
  21677. * The material `id` is a string identifying the material or the multiMaterial.
  21678. * This method returns the Mesh.
  21679. */
  21680. setMaterialByID(id: string): Mesh;
  21681. /**
  21682. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21683. */
  21684. getAnimatables(): IAnimatable[];
  21685. /**
  21686. * Modifies the mesh geometry according to the passed transformation matrix.
  21687. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21688. * The mesh normals are modified accordingly the same transformation.
  21689. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21690. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21691. * Returns the Mesh.
  21692. */
  21693. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21694. /**
  21695. * Modifies the mesh geometry according to its own current World Matrix.
  21696. * The mesh World Matrix is then reset.
  21697. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21698. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21699. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21700. * Returns the Mesh.
  21701. */
  21702. bakeCurrentTransformIntoVertices(): Mesh;
  21703. readonly _positions: Nullable<Vector3[]>;
  21704. _resetPointsArrayCache(): Mesh;
  21705. _generatePointsArray(): boolean;
  21706. /**
  21707. * Returns a new Mesh object generated from the current mesh properties.
  21708. * This method must not get confused with createInstance().
  21709. * The parameter `name` is a string, the name given to the new mesh.
  21710. * The optional parameter `newParent` can be any Node object (default `null`).
  21711. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21712. * 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.
  21713. */
  21714. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21715. /**
  21716. * Releases resources associated with this mesh.
  21717. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21718. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21719. */
  21720. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21721. /**
  21722. * Modifies the mesh geometry according to a displacement map.
  21723. * 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.
  21724. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21725. * This method returns nothing.
  21726. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21727. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21728. * 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.
  21729. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21730. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21731. *
  21732. * Returns the Mesh.
  21733. */
  21734. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21735. /**
  21736. * Modifies the mesh geometry according to a displacementMap buffer.
  21737. * 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.
  21738. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21739. * This method returns nothing.
  21740. * 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.
  21741. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21742. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21743. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21744. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21745. *
  21746. * Returns the Mesh.
  21747. */
  21748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21749. /**
  21750. * Modify the mesh to get a flat shading rendering.
  21751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21752. * This method returns the Mesh.
  21753. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21754. */
  21755. convertToFlatShadedMesh(): Mesh;
  21756. /**
  21757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21758. * In other words, more vertices, no more indices and a single bigger VBO.
  21759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21760. * Returns the Mesh.
  21761. */
  21762. convertToUnIndexedMesh(): Mesh;
  21763. /**
  21764. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21765. * This method returns the Mesh.
  21766. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21767. */
  21768. flipFaces(flipNormals?: boolean): Mesh;
  21769. /**
  21770. * Creates a new InstancedMesh object from the mesh model.
  21771. * An instance shares the same properties and the same material than its model.
  21772. * Only these properties of each instance can then be set individually :
  21773. * - position
  21774. * - rotation
  21775. * - rotationQuaternion
  21776. * - setPivotMatrix
  21777. * - scaling
  21778. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21779. * Warning : this method is not supported for Line mesh and LineSystem
  21780. */
  21781. createInstance(name: string): InstancedMesh;
  21782. /**
  21783. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21784. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21785. * This method returns the Mesh.
  21786. */
  21787. synchronizeInstances(): Mesh;
  21788. /**
  21789. * Simplify the mesh according to the given array of settings.
  21790. * Function will return immediately and will simplify async. It returns the Mesh.
  21791. * @param settings a collection of simplification settings.
  21792. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21793. * @param type the type of simplification to run.
  21794. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21795. */
  21796. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21797. /**
  21798. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21799. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21800. * This should be used together with the simplification to avoid disappearing triangles.
  21801. * Returns the Mesh.
  21802. * @param successCallback an optional success callback to be called after the optimization finished.
  21803. */
  21804. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21805. serialize(serializationObject: any): void;
  21806. _syncGeometryWithMorphTargetManager(): void;
  21807. /**
  21808. * Returns a new Mesh object parsed from the source provided.
  21809. * The parameter `parsedMesh` is the source.
  21810. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21811. */
  21812. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21813. /**
  21814. * Creates a ribbon mesh.
  21815. * Please consider using the same method from the MeshBuilder class instead.
  21816. * 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.
  21817. *
  21818. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21819. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21820. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21821. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21822. * 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.
  21823. * 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.
  21824. * 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
  21825. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21826. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21827. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21828. */
  21829. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21830. /**
  21831. * Creates a plane polygonal mesh. By default, this is a disc.
  21832. * Please consider using the same method from the MeshBuilder class instead.
  21833. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21834. * 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.
  21835. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21836. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21837. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21838. */
  21839. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21840. /**
  21841. * Creates a box mesh.
  21842. * Please consider using the same method from the MeshBuilder class instead.
  21843. * The parameter `size` sets the size (float) of each box side (default 1).
  21844. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21845. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21846. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21847. */
  21848. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21849. /**
  21850. * Creates a sphere mesh.
  21851. * Please consider using the same method from the MeshBuilder class instead.
  21852. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21853. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21854. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21855. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21856. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21857. */
  21858. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21859. /**
  21860. * Creates a cylinder or a cone mesh.
  21861. * Please consider using the same method from the MeshBuilder class instead.
  21862. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21863. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21864. * 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.
  21865. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21866. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21867. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21868. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21869. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21870. */
  21871. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21872. /**
  21873. * Creates a torus mesh.
  21874. * Please consider using the same method from the MeshBuilder class instead.
  21875. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21876. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21877. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21878. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21879. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21880. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21881. */
  21882. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21883. /**
  21884. * Creates a torus knot mesh.
  21885. * Please consider using the same method from the MeshBuilder class instead.
  21886. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21887. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21888. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21889. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21890. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21891. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21892. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21893. */
  21894. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21895. /**
  21896. * Creates a line mesh.
  21897. * Please consider using the same method from the MeshBuilder class instead.
  21898. * 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.
  21899. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21900. * The parameter `points` is an array successive Vector3.
  21901. * 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
  21902. * When updating an instance, remember that only point positions can change, not the number of points.
  21903. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21904. */
  21905. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21906. /**
  21907. * Creates a dashed line mesh.
  21908. * Please consider using the same method from the MeshBuilder class instead.
  21909. * 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.
  21910. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21911. * The parameter `points` is an array successive Vector3.
  21912. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21913. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21914. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21915. * 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
  21916. * When updating an instance, remember that only point positions can change, not the number of points.
  21917. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21918. */
  21919. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21920. /**
  21921. * Creates a polygon mesh.
  21922. * Please consider using the same method from the MeshBuilder class instead.
  21923. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21924. * 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.
  21925. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21926. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21927. * Remember you can only change the shape positions, not their number when updating a polygon.
  21928. */
  21929. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21930. /**
  21931. * Creates an extruded polygon mesh, with depth in the Y direction.
  21932. * Please consider using the same method from the MeshBuilder class instead.
  21933. */
  21934. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21935. /**
  21936. * Creates an extruded shape mesh.
  21937. * 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.
  21938. * Please consider using the same method from the MeshBuilder class instead.
  21939. *
  21940. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21941. * 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
  21942. * extruded along the Z axis.
  21943. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21944. * 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.
  21945. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21946. * 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
  21947. * 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
  21948. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21949. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21950. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21951. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21952. */
  21953. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21954. /**
  21955. * Creates an custom extruded shape mesh.
  21956. * 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.
  21957. * Please consider using the same method from the MeshBuilder class instead.
  21958. *
  21959. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21960. * 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
  21961. * extruded along the Z axis.
  21962. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21963. * 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
  21964. * and the distance of this point from the begining of the path :
  21965. * ```javascript
  21966. * var rotationFunction = function(i, distance) {
  21967. * // do things
  21968. * return rotationValue; }
  21969. * ```
  21970. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21971. * 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
  21972. * and the distance of this point from the begining of the path :
  21973. * ```javascript
  21974. * var scaleFunction = function(i, distance) {
  21975. * // do things
  21976. * return scaleValue;}
  21977. * ```
  21978. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21979. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21980. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21981. * 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
  21982. * 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
  21983. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21984. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21985. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21986. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21987. */
  21988. 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;
  21989. /**
  21990. * Creates lathe mesh.
  21991. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21992. * Please consider using the same method from the MeshBuilder class instead.
  21993. * 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
  21994. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21995. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21996. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21997. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21998. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21999. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22000. */
  22001. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22002. /**
  22003. * Creates a plane mesh.
  22004. * Please consider using the same method from the MeshBuilder class instead.
  22005. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22006. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22007. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22008. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22009. */
  22010. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22011. /**
  22012. * Creates a ground mesh.
  22013. * Please consider using the same method from the MeshBuilder class instead.
  22014. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22015. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22016. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22017. */
  22018. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22019. /**
  22020. * Creates a tiled ground mesh.
  22021. * Please consider using the same method from the MeshBuilder class instead.
  22022. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22023. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22024. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22025. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22026. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22027. * numbers of subdivisions on the ground width and height of each tile.
  22028. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22029. */
  22030. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22031. w: number;
  22032. h: number;
  22033. }, precision: {
  22034. w: number;
  22035. h: number;
  22036. }, scene: Scene, updatable?: boolean): Mesh;
  22037. /**
  22038. * Creates a ground mesh from a height map.
  22039. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22040. * Please consider using the same method from the MeshBuilder class instead.
  22041. * The parameter `url` sets the URL of the height map image resource.
  22042. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22043. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22044. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22045. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22046. * 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).
  22047. * This function is passed the newly built mesh :
  22048. * ```javascript
  22049. * function(mesh) { // do things
  22050. * return; }
  22051. * ```
  22052. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22053. */
  22054. 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;
  22055. /**
  22056. * Creates a tube mesh.
  22057. * 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.
  22058. * Please consider using the same method from the MeshBuilder class instead.
  22059. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22060. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22061. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22062. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22063. * 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.
  22064. * It must return a radius value (positive float) :
  22065. * ```javascript
  22066. * var radiusFunction = function(i, distance) {
  22067. * // do things
  22068. * return radius; }
  22069. * ```
  22070. * 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
  22071. * 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
  22072. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22073. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22074. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22075. */
  22076. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22077. (i: number, distance: number): number;
  22078. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22079. /**
  22080. * Creates a polyhedron mesh.
  22081. * Please consider using the same method from the MeshBuilder class instead.
  22082. * 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
  22083. * to choose the wanted type.
  22084. * The parameter `size` (positive float, default 1) sets the polygon size.
  22085. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22086. * 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`.
  22087. * 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
  22088. * 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)`).
  22089. * 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
  22090. * 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.
  22091. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22092. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22093. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22094. */
  22095. static CreatePolyhedron(name: string, options: {
  22096. type?: number;
  22097. size?: number;
  22098. sizeX?: number;
  22099. sizeY?: number;
  22100. sizeZ?: number;
  22101. custom?: any;
  22102. faceUV?: Vector4[];
  22103. faceColors?: Color4[];
  22104. updatable?: boolean;
  22105. sideOrientation?: number;
  22106. }, scene: Scene): Mesh;
  22107. /**
  22108. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22109. * Please consider using the same method from the MeshBuilder class instead.
  22110. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22111. * 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`).
  22112. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22113. * 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.
  22114. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22115. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22116. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22117. */
  22118. static CreateIcoSphere(name: string, options: {
  22119. radius?: number;
  22120. flat?: boolean;
  22121. subdivisions?: number;
  22122. sideOrientation?: number;
  22123. updatable?: boolean;
  22124. }, scene: Scene): Mesh;
  22125. /**
  22126. * Creates a decal mesh.
  22127. * Please consider using the same method from the MeshBuilder class instead.
  22128. * 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.
  22129. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22130. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22131. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22132. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22133. */
  22134. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22135. /**
  22136. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22137. */
  22138. setPositionsForCPUSkinning(): Float32Array;
  22139. /**
  22140. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22141. */
  22142. setNormalsForCPUSkinning(): Float32Array;
  22143. /**
  22144. * Updates the vertex buffer by applying transformation from the bones.
  22145. * Returns the Mesh.
  22146. *
  22147. * @param {skeleton} skeleton to apply
  22148. */
  22149. applySkeleton(skeleton: Skeleton): Mesh;
  22150. /**
  22151. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22152. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22153. */
  22154. static MinMax(meshes: AbstractMesh[]): {
  22155. min: Vector3;
  22156. max: Vector3;
  22157. };
  22158. /**
  22159. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22160. */
  22161. static Center(meshesOrMinMaxVector: {
  22162. min: Vector3;
  22163. max: Vector3;
  22164. } | AbstractMesh[]): Vector3;
  22165. /**
  22166. * Merge the array of meshes into a single mesh for performance reasons.
  22167. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  22168. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  22169. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22170. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22171. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22172. */
  22173. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22174. }
  22175. }
  22176. declare module BABYLON {
  22177. /**
  22178. * Define an interface for all classes that will get and set the data on vertices
  22179. */
  22180. interface IGetSetVerticesData {
  22181. isVerticesDataPresent(kind: string): boolean;
  22182. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22183. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22184. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22185. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22186. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22187. }
  22188. /**
  22189. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22190. */
  22191. class VertexData {
  22192. /**
  22193. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22194. */
  22195. positions: Nullable<FloatArray>;
  22196. /**
  22197. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22198. */
  22199. normals: Nullable<FloatArray>;
  22200. /**
  22201. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22202. */
  22203. tangents: Nullable<FloatArray>;
  22204. /**
  22205. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22206. */
  22207. uvs: Nullable<FloatArray>;
  22208. /**
  22209. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22210. */
  22211. uvs2: Nullable<FloatArray>;
  22212. /**
  22213. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22214. */
  22215. uvs3: Nullable<FloatArray>;
  22216. /**
  22217. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22218. */
  22219. uvs4: Nullable<FloatArray>;
  22220. /**
  22221. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22222. */
  22223. uvs5: Nullable<FloatArray>;
  22224. /**
  22225. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22226. */
  22227. uvs6: Nullable<FloatArray>;
  22228. /**
  22229. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22230. */
  22231. colors: Nullable<FloatArray>;
  22232. /**
  22233. * 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).
  22234. */
  22235. matricesIndices: Nullable<FloatArray>;
  22236. /**
  22237. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22238. */
  22239. matricesWeights: Nullable<FloatArray>;
  22240. /**
  22241. * An array extending the number of possible indices
  22242. */
  22243. matricesIndicesExtra: Nullable<FloatArray>;
  22244. /**
  22245. * An array extending the number of possible weights when the number of indices is extended
  22246. */
  22247. matricesWeightsExtra: Nullable<FloatArray>;
  22248. /**
  22249. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22250. */
  22251. indices: Nullable<IndicesArray>;
  22252. /**
  22253. * Uses the passed data array to set the set the values for the specified kind of data
  22254. * @param data a linear array of floating numbers
  22255. * @param kind the type of data that is being set, eg positions, colors etc
  22256. */
  22257. set(data: FloatArray, kind: string): void;
  22258. /**
  22259. * Associates the vertexData to the passed Mesh.
  22260. * Sets it as updatable or not (default `false`)
  22261. * @param mesh the mesh the vertexData is applied to
  22262. * @param updatable when used and having the value true allows new data to update the vertexData
  22263. * @returns the VertexData
  22264. */
  22265. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22266. /**
  22267. * Associates the vertexData to the passed Geometry.
  22268. * Sets it as updatable or not (default `false`)
  22269. * @param geometry the geometry the vertexData is applied to
  22270. * @param updatable when used and having the value true allows new data to update the vertexData
  22271. * @returns VertexData
  22272. */
  22273. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22274. /**
  22275. * Updates the associated mesh
  22276. * @param mesh the mesh to be updated
  22277. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22278. * @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
  22279. * @returns VertexData
  22280. */
  22281. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22282. /**
  22283. * Updates the associated geometry
  22284. * @param geometry the geometry to be updated
  22285. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22286. * @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
  22287. * @returns VertexData.
  22288. */
  22289. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22290. private _applyTo(meshOrGeometry, updatable?);
  22291. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  22292. /**
  22293. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22294. * @param matrix the transforming matrix
  22295. * @returns the VertexData
  22296. */
  22297. transform(matrix: Matrix): VertexData;
  22298. /**
  22299. * Merges the passed VertexData into the current one
  22300. * @param other the VertexData to be merged into the current one
  22301. * @returns the modified VertexData
  22302. */
  22303. merge(other: VertexData): VertexData;
  22304. private _mergeElement(source, other);
  22305. private _validate();
  22306. /**
  22307. * Serializes the VertexData
  22308. * @returns a serialized object
  22309. */
  22310. serialize(): any;
  22311. /**
  22312. * Extracts the vertexData from a mesh
  22313. * @param mesh the mesh from which to extract the VertexData
  22314. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22315. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22316. * @returns the object VertexData associated to the passed mesh
  22317. */
  22318. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22319. /**
  22320. * Extracts the vertexData from the geometry
  22321. * @param geometry the geometry from which to extract the VertexData
  22322. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22323. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22324. * @returns the object VertexData associated to the passed mesh
  22325. */
  22326. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22327. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  22328. /**
  22329. * Creates the VertexData for a Ribbon
  22330. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22331. * * pathArray array of paths, each of which an array of successive Vector3
  22332. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22333. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22334. * * 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
  22335. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22336. * * 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)
  22337. * * 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)
  22338. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22339. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22340. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22341. * @returns the VertexData of the ribbon
  22342. */
  22343. static CreateRibbon(options: {
  22344. pathArray: Vector3[][];
  22345. closeArray?: boolean;
  22346. closePath?: boolean;
  22347. offset?: number;
  22348. sideOrientation?: number;
  22349. frontUVs?: Vector4;
  22350. backUVs?: Vector4;
  22351. invertUV?: boolean;
  22352. uvs?: Vector2[];
  22353. colors?: Color4[];
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a box
  22357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22358. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22359. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22360. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22361. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22362. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22363. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22364. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22365. * * 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)
  22366. * * 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)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateBox(options: {
  22370. size?: number;
  22371. width?: number;
  22372. height?: number;
  22373. depth?: number;
  22374. faceUV?: Vector4[];
  22375. faceColors?: Color4[];
  22376. sideOrientation?: number;
  22377. frontUVs?: Vector4;
  22378. backUVs?: Vector4;
  22379. }): VertexData;
  22380. /**
  22381. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22382. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22383. * * segments sets the number of horizontal strips optional, default 32
  22384. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22385. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22386. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22387. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22388. * * 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
  22389. * * 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
  22390. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22391. * * 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)
  22392. * * 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)
  22393. * @returns the VertexData of the ellipsoid
  22394. */
  22395. static CreateSphere(options: {
  22396. segments?: number;
  22397. diameter?: number;
  22398. diameterX?: number;
  22399. diameterY?: number;
  22400. diameterZ?: number;
  22401. arc?: number;
  22402. slice?: number;
  22403. sideOrientation?: number;
  22404. frontUVs?: Vector4;
  22405. backUVs?: Vector4;
  22406. }): VertexData;
  22407. /**
  22408. * Creates the VertexData for a cylinder, cone or prism
  22409. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22410. * * height sets the height (y direction) of the cylinder, optional, default 2
  22411. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22412. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22413. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22414. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22415. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22416. * * 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
  22417. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22418. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22419. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22420. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22421. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22422. * * 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)
  22423. * * 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)
  22424. * @returns the VertexData of the cylinder, cone or prism
  22425. */
  22426. static CreateCylinder(options: {
  22427. height?: number;
  22428. diameterTop?: number;
  22429. diameterBottom?: number;
  22430. diameter?: number;
  22431. tessellation?: number;
  22432. subdivisions?: number;
  22433. arc?: number;
  22434. faceColors?: Color4[];
  22435. faceUV?: Vector4[];
  22436. hasRings?: boolean;
  22437. enclose?: boolean;
  22438. sideOrientation?: number;
  22439. frontUVs?: Vector4;
  22440. backUVs?: Vector4;
  22441. }): VertexData;
  22442. /**
  22443. * Creates the VertexData for a torus
  22444. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22445. * * diameter the diameter of the torus, optional default 1
  22446. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22447. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22448. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22449. * * 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)
  22450. * * 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)
  22451. * @returns the VertexData of the torus
  22452. */
  22453. static CreateTorus(options: {
  22454. diameter?: number;
  22455. thickness?: number;
  22456. tessellation?: number;
  22457. sideOrientation?: number;
  22458. frontUVs?: Vector4;
  22459. backUVs?: Vector4;
  22460. }): VertexData;
  22461. /**
  22462. * Creates the VertexData of the LineSystem
  22463. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22464. * - lines an array of lines, each line being an array of successive Vector3
  22465. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22466. * @returns the VertexData of the LineSystem
  22467. */
  22468. static CreateLineSystem(options: {
  22469. lines: Vector3[][];
  22470. colors?: Nullable<Color4[][]>;
  22471. }): VertexData;
  22472. /**
  22473. * Create the VertexData for a DashedLines
  22474. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22475. * - points an array successive Vector3
  22476. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22477. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22478. * - dashNb the intended total number of dashes, optional, default 200
  22479. * @returns the VertexData for the DashedLines
  22480. */
  22481. static CreateDashedLines(options: {
  22482. points: Vector3[];
  22483. dashSize?: number;
  22484. gapSize?: number;
  22485. dashNb?: number;
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a Ground
  22489. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22490. * - width the width (x direction) of the ground, optional, default 1
  22491. * - height the height (z direction) of the ground, optional, default 1
  22492. * - subdivisions the number of subdivisions per side, optional, default 1
  22493. * @returns the VertexData of the Ground
  22494. */
  22495. static CreateGround(options: {
  22496. width?: number;
  22497. height?: number;
  22498. subdivisions?: number;
  22499. subdivisionsX?: number;
  22500. subdivisionsY?: number;
  22501. }): VertexData;
  22502. /**
  22503. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22504. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22505. * * xmin the ground minimum X coordinate, optional, default -1
  22506. * * zmin the ground minimum Z coordinate, optional, default -1
  22507. * * xmax the ground maximum X coordinate, optional, default 1
  22508. * * zmax the ground maximum Z coordinate, optional, default 1
  22509. * * 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}
  22510. * * 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}
  22511. * @returns the VertexData of the TiledGround
  22512. */
  22513. static CreateTiledGround(options: {
  22514. xmin: number;
  22515. zmin: number;
  22516. xmax: number;
  22517. zmax: number;
  22518. subdivisions?: {
  22519. w: number;
  22520. h: number;
  22521. };
  22522. precision?: {
  22523. w: number;
  22524. h: number;
  22525. };
  22526. }): VertexData;
  22527. /**
  22528. * Creates the VertexData of the Ground designed from a heightmap
  22529. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22530. * * width the width (x direction) of the ground
  22531. * * height the height (z direction) of the ground
  22532. * * subdivisions the number of subdivisions per side
  22533. * * minHeight the minimum altitude on the ground, optional, default 0
  22534. * * maxHeight the maximum altitude on the ground, optional default 1
  22535. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22536. * * buffer the array holding the image color data
  22537. * * bufferWidth the width of image
  22538. * * bufferHeight the height of image
  22539. * @returns the VertexData of the Ground designed from a heightmap
  22540. */
  22541. static CreateGroundFromHeightMap(options: {
  22542. width: number;
  22543. height: number;
  22544. subdivisions: number;
  22545. minHeight: number;
  22546. maxHeight: number;
  22547. colorFilter: Color3;
  22548. buffer: Uint8Array;
  22549. bufferWidth: number;
  22550. bufferHeight: number;
  22551. }): VertexData;
  22552. /**
  22553. * Creates the VertexData for a Plane
  22554. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22555. * * size sets the width and height of the plane to the value of size, optional default 1
  22556. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22557. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22558. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22559. * * 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)
  22560. * * 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)
  22561. * @returns the VertexData of the box
  22562. */
  22563. static CreatePlane(options: {
  22564. size?: number;
  22565. width?: number;
  22566. height?: number;
  22567. sideOrientation?: number;
  22568. frontUVs?: Vector4;
  22569. backUVs?: Vector4;
  22570. }): VertexData;
  22571. /**
  22572. * Creates the VertexData of the Disc or regular Polygon
  22573. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22574. * * radius the radius of the disc, optional default 0.5
  22575. * * tessellation the number of polygon sides, optional, default 64
  22576. * * 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
  22577. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22578. * * 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)
  22579. * * 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)
  22580. * @returns the VertexData of the box
  22581. */
  22582. static CreateDisc(options: {
  22583. radius?: number;
  22584. tessellation?: number;
  22585. arc?: number;
  22586. sideOrientation?: number;
  22587. frontUVs?: Vector4;
  22588. backUVs?: Vector4;
  22589. }): VertexData;
  22590. /**
  22591. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22592. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22593. * @param polygon a mesh built from polygonTriangulation.build()
  22594. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22595. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22596. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22597. * @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)
  22598. * @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)
  22599. * @returns the VertexData of the Polygon
  22600. */
  22601. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22602. /**
  22603. * Creates the VertexData of the IcoSphere
  22604. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22605. * * radius the radius of the IcoSphere, optional default 1
  22606. * * radiusX allows stretching in the x direction, optional, default radius
  22607. * * radiusY allows stretching in the y direction, optional, default radius
  22608. * * radiusZ allows stretching in the z direction, optional, default radius
  22609. * * flat when true creates a flat shaded mesh, optional, default true
  22610. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22611. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22612. * * 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)
  22613. * * 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)
  22614. * @returns the VertexData of the IcoSphere
  22615. */
  22616. static CreateIcoSphere(options: {
  22617. radius?: number;
  22618. radiusX?: number;
  22619. radiusY?: number;
  22620. radiusZ?: number;
  22621. flat?: boolean;
  22622. subdivisions?: number;
  22623. sideOrientation?: number;
  22624. frontUVs?: Vector4;
  22625. backUVs?: Vector4;
  22626. }): VertexData;
  22627. /**
  22628. * Creates the VertexData for a Polyhedron
  22629. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22630. * * type provided types are:
  22631. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22632. * * 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)
  22633. * * size the size of the IcoSphere, optional default 1
  22634. * * sizeX allows stretching in the x direction, optional, default size
  22635. * * sizeY allows stretching in the y direction, optional, default size
  22636. * * sizeZ allows stretching in the z direction, optional, default size
  22637. * * 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
  22638. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22639. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22640. * * flat when true creates a flat shaded mesh, optional, default true
  22641. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22642. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22643. * * 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)
  22644. * * 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)
  22645. * @returns the VertexData of the Polyhedron
  22646. */
  22647. static CreatePolyhedron(options: {
  22648. type?: number;
  22649. size?: number;
  22650. sizeX?: number;
  22651. sizeY?: number;
  22652. sizeZ?: number;
  22653. custom?: any;
  22654. faceUV?: Vector4[];
  22655. faceColors?: Color4[];
  22656. flat?: boolean;
  22657. sideOrientation?: number;
  22658. frontUVs?: Vector4;
  22659. backUVs?: Vector4;
  22660. }): VertexData;
  22661. /**
  22662. * Creates the VertexData for a TorusKnot
  22663. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22664. * * radius the radius of the torus knot, optional, default 2
  22665. * * tube the thickness of the tube, optional, default 0.5
  22666. * * radialSegments the number of sides on each tube segments, optional, default 32
  22667. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22668. * * p the number of windings around the z axis, optional, default 2
  22669. * * q the number of windings around the x axis, optional, default 3
  22670. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22671. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22672. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22673. * @returns the VertexData of the Torus Knot
  22674. */
  22675. static CreateTorusKnot(options: {
  22676. radius?: number;
  22677. tube?: number;
  22678. radialSegments?: number;
  22679. tubularSegments?: number;
  22680. p?: number;
  22681. q?: number;
  22682. sideOrientation?: number;
  22683. frontUVs?: Vector4;
  22684. backUVs?: Vector4;
  22685. }): VertexData;
  22686. /**
  22687. * Compute normals for given positions and indices
  22688. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22689. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22690. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22691. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22692. * * facetNormals : optional array of facet normals (vector3)
  22693. * * facetPositions : optional array of facet positions (vector3)
  22694. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22695. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22696. * * bInfo : optional bounding info, required for facetPartitioning computation
  22697. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22698. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22699. * * useRightHandedSystem: optional boolean to for right handed system computation
  22700. * * depthSort : optional boolean to enable the facet depth sort computation
  22701. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22702. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22703. */
  22704. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22705. facetNormals?: any;
  22706. facetPositions?: any;
  22707. facetPartitioning?: any;
  22708. ratio?: number;
  22709. bInfo?: any;
  22710. bbSize?: Vector3;
  22711. subDiv?: any;
  22712. useRightHandedSystem?: boolean;
  22713. depthSort?: boolean;
  22714. distanceTo?: Vector3;
  22715. depthSortedFacets?: any;
  22716. }): void;
  22717. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22718. /**
  22719. * Applies VertexData created from the imported parameters to the geometry
  22720. * @param parsedVertexData the parsed data from an imported file
  22721. * @param geometry the geometry to apply the VertexData to
  22722. */
  22723. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22724. }
  22725. }
  22726. declare module BABYLON {
  22727. /**
  22728. * Class containing static functions to help procedurally build meshes
  22729. */
  22730. class MeshBuilder {
  22731. private static updateSideOrientation(orientation?);
  22732. /**
  22733. * Creates a box mesh
  22734. * * The parameter `size` sets the size (float) of each box side (default 1)
  22735. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22736. * * 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)
  22737. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22739. * * 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
  22740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22741. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22742. * @param name defines the name of the mesh
  22743. * @param options defines the options used to create the mesh
  22744. * @param scene defines the hosting scene
  22745. * @returns the box mesh
  22746. */
  22747. static CreateBox(name: string, options: {
  22748. size?: number;
  22749. width?: number;
  22750. height?: number;
  22751. depth?: number;
  22752. faceUV?: Vector4[];
  22753. faceColors?: Color4[];
  22754. sideOrientation?: number;
  22755. frontUVs?: Vector4;
  22756. backUVs?: Vector4;
  22757. updatable?: boolean;
  22758. }, scene?: Nullable<Scene>): Mesh;
  22759. /**
  22760. * Creates a sphere mesh
  22761. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22762. * * 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`)
  22763. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22764. * * 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
  22765. * * 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)
  22766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22767. * * 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
  22768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22769. * @param name defines the name of the mesh
  22770. * @param options defines the options used to create the mesh
  22771. * @param scene defines the hosting scene
  22772. * @returns the sphere mesh
  22773. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22774. */
  22775. static CreateSphere(name: string, options: {
  22776. segments?: number;
  22777. diameter?: number;
  22778. diameterX?: number;
  22779. diameterY?: number;
  22780. diameterZ?: number;
  22781. arc?: number;
  22782. slice?: number;
  22783. sideOrientation?: number;
  22784. frontUVs?: Vector4;
  22785. backUVs?: Vector4;
  22786. updatable?: boolean;
  22787. }, scene: any): Mesh;
  22788. /**
  22789. * Creates a plane polygonal mesh. By default, this is a disc
  22790. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22791. * * 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
  22792. * * 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
  22793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22794. * * 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
  22795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22796. * @param name defines the name of the mesh
  22797. * @param options defines the options used to create the mesh
  22798. * @param scene defines the hosting scene
  22799. * @returns the plane polygonal mesh
  22800. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22801. */
  22802. static CreateDisc(name: string, options: {
  22803. radius?: number;
  22804. tessellation?: number;
  22805. arc?: number;
  22806. updatable?: boolean;
  22807. sideOrientation?: number;
  22808. frontUVs?: Vector4;
  22809. backUVs?: Vector4;
  22810. }, scene?: Nullable<Scene>): Mesh;
  22811. /**
  22812. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22813. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22814. * * 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`)
  22815. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22816. * * 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
  22817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22818. * * 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
  22819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22820. * @param name defines the name of the mesh
  22821. * @param options defines the options used to create the mesh
  22822. * @param scene defines the hosting scene
  22823. * @returns the icosahedron mesh
  22824. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22825. */
  22826. static CreateIcoSphere(name: string, options: {
  22827. radius?: number;
  22828. radiusX?: number;
  22829. radiusY?: number;
  22830. radiusZ?: number;
  22831. flat?: boolean;
  22832. subdivisions?: number;
  22833. sideOrientation?: number;
  22834. frontUVs?: Vector4;
  22835. backUVs?: Vector4;
  22836. updatable?: boolean;
  22837. }, scene: Scene): Mesh;
  22838. /**
  22839. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22840. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22841. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22842. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22843. * * 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
  22844. * * 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
  22845. * * 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
  22846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22847. * * 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
  22848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22849. * * 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
  22850. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22851. * * 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
  22852. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22854. * @param name defines the name of the mesh
  22855. * @param options defines the options used to create the mesh
  22856. * @param scene defines the hosting scene
  22857. * @returns the ribbon mesh
  22858. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22859. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22860. */
  22861. static CreateRibbon(name: string, options: {
  22862. pathArray: Vector3[][];
  22863. closeArray?: boolean;
  22864. closePath?: boolean;
  22865. offset?: number;
  22866. updatable?: boolean;
  22867. sideOrientation?: number;
  22868. frontUVs?: Vector4;
  22869. backUVs?: Vector4;
  22870. instance?: Mesh;
  22871. invertUV?: boolean;
  22872. uvs?: Vector2[];
  22873. colors?: Color4[];
  22874. }, scene?: Nullable<Scene>): Mesh;
  22875. /**
  22876. * Creates a cylinder or a cone mesh
  22877. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22878. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22879. * * 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.
  22880. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22881. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22882. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22883. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22884. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22885. * * 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).
  22886. * * 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
  22887. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22888. * * 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
  22889. * * 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.
  22890. * * If `enclose` is false, a ring surface is one element.
  22891. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22892. * * 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
  22893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22894. * * 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
  22895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22896. * @param name defines the name of the mesh
  22897. * @param options defines the options used to create the mesh
  22898. * @param scene defines the hosting scene
  22899. * @returns the cylinder mesh
  22900. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22901. */
  22902. static CreateCylinder(name: string, options: {
  22903. height?: number;
  22904. diameterTop?: number;
  22905. diameterBottom?: number;
  22906. diameter?: number;
  22907. tessellation?: number;
  22908. subdivisions?: number;
  22909. arc?: number;
  22910. faceColors?: Color4[];
  22911. faceUV?: Vector4[];
  22912. updatable?: boolean;
  22913. hasRings?: boolean;
  22914. enclose?: boolean;
  22915. sideOrientation?: number;
  22916. frontUVs?: Vector4;
  22917. backUVs?: Vector4;
  22918. }, scene: any): Mesh;
  22919. /**
  22920. * Creates a torus mesh
  22921. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22922. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22923. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22925. * * 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
  22926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22927. * @param name defines the name of the mesh
  22928. * @param options defines the options used to create the mesh
  22929. * @param scene defines the hosting scene
  22930. * @returns the torus mesh
  22931. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22932. */
  22933. static CreateTorus(name: string, options: {
  22934. diameter?: number;
  22935. thickness?: number;
  22936. tessellation?: number;
  22937. updatable?: boolean;
  22938. sideOrientation?: number;
  22939. frontUVs?: Vector4;
  22940. backUVs?: Vector4;
  22941. }, scene: any): Mesh;
  22942. /**
  22943. * Creates a torus knot mesh
  22944. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22945. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22946. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22947. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22949. * * 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
  22950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22951. * @param name defines the name of the mesh
  22952. * @param options defines the options used to create the mesh
  22953. * @param scene defines the hosting scene
  22954. * @returns the torus knot mesh
  22955. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22956. */
  22957. static CreateTorusKnot(name: string, options: {
  22958. radius?: number;
  22959. tube?: number;
  22960. radialSegments?: number;
  22961. tubularSegments?: number;
  22962. p?: number;
  22963. q?: number;
  22964. updatable?: boolean;
  22965. sideOrientation?: number;
  22966. frontUVs?: Vector4;
  22967. backUVs?: Vector4;
  22968. }, scene: any): Mesh;
  22969. /**
  22970. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22971. * * 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
  22972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22973. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22974. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22975. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22976. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22977. * * 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
  22978. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22980. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22981. * @param name defines the name of the new line system
  22982. * @param options defines the options used to create the line system
  22983. * @param scene defines the hosting scene
  22984. * @returns a new line system mesh
  22985. */
  22986. static CreateLineSystem(name: string, options: {
  22987. lines: Vector3[][];
  22988. updatable?: boolean;
  22989. instance?: Nullable<LinesMesh>;
  22990. colors?: Nullable<Color4[][]>;
  22991. useVertexAlpha?: boolean;
  22992. }, scene: Nullable<Scene>): LinesMesh;
  22993. /**
  22994. * Creates a line mesh
  22995. * 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
  22996. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22997. * * The parameter `points` is an array successive Vector3
  22998. * * 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
  22999. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23000. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23001. * * When updating an instance, remember that only point positions can change, not the number of points
  23002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23003. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23004. * @param name defines the name of the new line system
  23005. * @param options defines the options used to create the line system
  23006. * @param scene defines the hosting scene
  23007. * @returns a new line mesh
  23008. */
  23009. static CreateLines(name: string, options: {
  23010. points: Vector3[];
  23011. updatable?: boolean;
  23012. instance?: Nullable<LinesMesh>;
  23013. colors?: Color4[];
  23014. useVertexAlpha?: boolean;
  23015. }, scene?: Nullable<Scene>): LinesMesh;
  23016. /**
  23017. * Creates a dashed line mesh
  23018. * * 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
  23019. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23020. * * The parameter `points` is an array successive Vector3
  23021. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23022. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23023. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23024. * * 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
  23025. * * When updating an instance, remember that only point positions can change, not the number of points
  23026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23027. * @param name defines the name of the mesh
  23028. * @param options defines the options used to create the mesh
  23029. * @param scene defines the hosting scene
  23030. * @returns the dashed line mesh
  23031. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23032. */
  23033. static CreateDashedLines(name: string, options: {
  23034. points: Vector3[];
  23035. dashSize?: number;
  23036. gapSize?: number;
  23037. dashNb?: number;
  23038. updatable?: boolean;
  23039. instance?: LinesMesh;
  23040. }, scene?: Nullable<Scene>): LinesMesh;
  23041. /**
  23042. * 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.
  23043. * * 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.
  23044. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23045. * * 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.
  23046. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23047. * * 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
  23048. * * 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
  23049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23051. * * 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
  23052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23054. * @param name defines the name of the mesh
  23055. * @param options defines the options used to create the mesh
  23056. * @param scene defines the hosting scene
  23057. * @returns the extruded shape mesh
  23058. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23059. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23060. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23061. */
  23062. static ExtrudeShape(name: string, options: {
  23063. shape: Vector3[];
  23064. path: Vector3[];
  23065. scale?: number;
  23066. rotation?: number;
  23067. cap?: number;
  23068. updatable?: boolean;
  23069. sideOrientation?: number;
  23070. frontUVs?: Vector4;
  23071. backUVs?: Vector4;
  23072. instance?: Mesh;
  23073. invertUV?: boolean;
  23074. }, scene?: Nullable<Scene>): Mesh;
  23075. /**
  23076. * Creates an custom extruded shape mesh.
  23077. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23078. * * 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.
  23079. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23080. * * 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
  23081. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23082. * * 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
  23083. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23084. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23085. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23086. * * 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
  23087. * * 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
  23088. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23090. * * 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
  23091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23093. * @param name defines the name of the mesh
  23094. * @param options defines the options used to create the mesh
  23095. * @param scene defines the hosting scene
  23096. * @returns the custom extruded shape mesh
  23097. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23098. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23099. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23100. */
  23101. static ExtrudeShapeCustom(name: string, options: {
  23102. shape: Vector3[];
  23103. path: Vector3[];
  23104. scaleFunction?: any;
  23105. rotationFunction?: any;
  23106. ribbonCloseArray?: boolean;
  23107. ribbonClosePath?: boolean;
  23108. cap?: number;
  23109. updatable?: boolean;
  23110. sideOrientation?: number;
  23111. frontUVs?: Vector4;
  23112. backUVs?: Vector4;
  23113. instance?: Mesh;
  23114. invertUV?: boolean;
  23115. }, scene: Scene): Mesh;
  23116. /**
  23117. * Creates lathe mesh.
  23118. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23119. * * 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
  23120. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23121. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23122. * * 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
  23123. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23124. * * 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
  23125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23126. * * 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
  23127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23129. * @param name defines the name of the mesh
  23130. * @param options defines the options used to create the mesh
  23131. * @param scene defines the hosting scene
  23132. * @returns the lathe mesh
  23133. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23134. */
  23135. static CreateLathe(name: string, options: {
  23136. shape: Vector3[];
  23137. radius?: number;
  23138. tessellation?: number;
  23139. arc?: number;
  23140. closed?: boolean;
  23141. updatable?: boolean;
  23142. sideOrientation?: number;
  23143. frontUVs?: Vector4;
  23144. backUVs?: Vector4;
  23145. cap?: number;
  23146. invertUV?: boolean;
  23147. }, scene: Scene): Mesh;
  23148. /**
  23149. * Creates a plane mesh
  23150. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23151. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23152. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23154. * * 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
  23155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23156. * @param name defines the name of the mesh
  23157. * @param options defines the options used to create the mesh
  23158. * @param scene defines the hosting scene
  23159. * @returns the plane mesh
  23160. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23161. */
  23162. static CreatePlane(name: string, options: {
  23163. size?: number;
  23164. width?: number;
  23165. height?: number;
  23166. sideOrientation?: number;
  23167. frontUVs?: Vector4;
  23168. backUVs?: Vector4;
  23169. updatable?: boolean;
  23170. sourcePlane?: Plane;
  23171. }, scene: Scene): Mesh;
  23172. /**
  23173. * Creates a ground mesh
  23174. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23175. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23177. * @param name defines the name of the mesh
  23178. * @param options defines the options used to create the mesh
  23179. * @param scene defines the hosting scene
  23180. * @returns the ground mesh
  23181. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23182. */
  23183. static CreateGround(name: string, options: {
  23184. width?: number;
  23185. height?: number;
  23186. subdivisions?: number;
  23187. subdivisionsX?: number;
  23188. subdivisionsY?: number;
  23189. updatable?: boolean;
  23190. }, scene: any): Mesh;
  23191. /**
  23192. * Creates a tiled ground mesh
  23193. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23194. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23195. * * 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
  23196. * * 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
  23197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23198. * @param name defines the name of the mesh
  23199. * @param options defines the options used to create the mesh
  23200. * @param scene defines the hosting scene
  23201. * @returns the tiled ground mesh
  23202. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23203. */
  23204. static CreateTiledGround(name: string, options: {
  23205. xmin: number;
  23206. zmin: number;
  23207. xmax: number;
  23208. zmax: number;
  23209. subdivisions?: {
  23210. w: number;
  23211. h: number;
  23212. };
  23213. precision?: {
  23214. w: number;
  23215. h: number;
  23216. };
  23217. updatable?: boolean;
  23218. }, scene: Scene): Mesh;
  23219. /**
  23220. * Creates a ground mesh from a height map
  23221. * * The parameter `url` sets the URL of the height map image resource.
  23222. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23223. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23224. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23225. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23226. * * 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.
  23227. * * 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).
  23228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23229. * @param name defines the name of the mesh
  23230. * @param url defines the url to the height map
  23231. * @param options defines the options used to create the mesh
  23232. * @param scene defines the hosting scene
  23233. * @returns the ground mesh
  23234. * @see http://doc.babylonjs.com/babylon101/height_map
  23235. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23236. */
  23237. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23238. width?: number;
  23239. height?: number;
  23240. subdivisions?: number;
  23241. minHeight?: number;
  23242. maxHeight?: number;
  23243. colorFilter?: Color3;
  23244. updatable?: boolean;
  23245. onReady?: (mesh: GroundMesh) => void;
  23246. }, scene: Scene): GroundMesh;
  23247. /**
  23248. * Creates a polygon mesh
  23249. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23250. * * 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
  23251. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23253. * * 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)
  23254. * * Remember you can only change the shape positions, not their number when updating a polygon
  23255. * @param name defines the name of the mesh
  23256. * @param options defines the options used to create the mesh
  23257. * @param scene defines the hosting scene
  23258. * @returns the polygon mesh
  23259. */
  23260. static CreatePolygon(name: string, options: {
  23261. shape: Vector3[];
  23262. holes?: Vector3[][];
  23263. depth?: number;
  23264. faceUV?: Vector4[];
  23265. faceColors?: Color4[];
  23266. updatable?: boolean;
  23267. sideOrientation?: number;
  23268. frontUVs?: Vector4;
  23269. backUVs?: Vector4;
  23270. }, scene: Scene): Mesh;
  23271. /**
  23272. * Creates an extruded polygon mesh, with depth in the Y direction.
  23273. * * 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)
  23274. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23275. * @param name defines the name of the mesh
  23276. * @param options defines the options used to create the mesh
  23277. * @param scene defines the hosting scene
  23278. * @returns the polygon mesh
  23279. */
  23280. static ExtrudePolygon(name: string, options: {
  23281. shape: Vector3[];
  23282. holes?: Vector3[][];
  23283. depth?: number;
  23284. faceUV?: Vector4[];
  23285. faceColors?: Color4[];
  23286. updatable?: boolean;
  23287. sideOrientation?: number;
  23288. frontUVs?: Vector4;
  23289. backUVs?: Vector4;
  23290. }, scene: Scene): Mesh;
  23291. /**
  23292. * Creates a tube mesh.
  23293. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23294. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23295. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23296. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23297. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23298. * * 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)
  23299. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23300. * * 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
  23301. * * 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
  23302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23303. * * 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
  23304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23306. * @param name defines the name of the mesh
  23307. * @param options defines the options used to create the mesh
  23308. * @param scene defines the hosting scene
  23309. * @returns the tube mesh
  23310. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23311. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23312. */
  23313. static CreateTube(name: string, options: {
  23314. path: Vector3[];
  23315. radius?: number;
  23316. tessellation?: number;
  23317. radiusFunction?: {
  23318. (i: number, distance: number): number;
  23319. };
  23320. cap?: number;
  23321. arc?: number;
  23322. updatable?: boolean;
  23323. sideOrientation?: number;
  23324. frontUVs?: Vector4;
  23325. backUVs?: Vector4;
  23326. instance?: Mesh;
  23327. invertUV?: boolean;
  23328. }, scene: Scene): Mesh;
  23329. /**
  23330. * Creates a polyhedron mesh
  23331. * * 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
  23332. * * The parameter `size` (positive float, default 1) sets the polygon size
  23333. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23334. * * 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`
  23335. * * 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
  23336. * * 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)`)
  23337. * * 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
  23338. * * 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
  23339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23340. * * 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
  23341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23342. * @param name defines the name of the mesh
  23343. * @param options defines the options used to create the mesh
  23344. * @param scene defines the hosting scene
  23345. * @returns the polyhedron mesh
  23346. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23347. */
  23348. static CreatePolyhedron(name: string, options: {
  23349. type?: number;
  23350. size?: number;
  23351. sizeX?: number;
  23352. sizeY?: number;
  23353. sizeZ?: number;
  23354. custom?: any;
  23355. faceUV?: Vector4[];
  23356. faceColors?: Color4[];
  23357. flat?: boolean;
  23358. updatable?: boolean;
  23359. sideOrientation?: number;
  23360. frontUVs?: Vector4;
  23361. backUVs?: Vector4;
  23362. }, scene: Scene): Mesh;
  23363. /**
  23364. * Creates a decal mesh.
  23365. * 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
  23366. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23367. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23368. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23369. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23370. * @param name defines the name of the mesh
  23371. * @param sourceMesh defines the mesh where the decal must be applied
  23372. * @param options defines the options used to create the mesh
  23373. * @param scene defines the hosting scene
  23374. * @returns the decal mesh
  23375. * @see http://doc.babylonjs.com/how_to/decals
  23376. */
  23377. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23378. position?: Vector3;
  23379. normal?: Vector3;
  23380. size?: Vector3;
  23381. angle?: number;
  23382. }): Mesh;
  23383. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  23384. }
  23385. }
  23386. declare module BABYLON {
  23387. class MeshLODLevel {
  23388. distance: number;
  23389. mesh: Mesh;
  23390. constructor(distance: number, mesh: Mesh);
  23391. }
  23392. }
  23393. declare module BABYLON {
  23394. /**
  23395. * A simplifier interface for future simplification implementations.
  23396. */
  23397. interface ISimplifier {
  23398. /**
  23399. * Simplification of a given mesh according to the given settings.
  23400. * Since this requires computation, it is assumed that the function runs async.
  23401. * @param settings The settings of the simplification, including quality and distance
  23402. * @param successCallback A callback that will be called after the mesh was simplified.
  23403. * @param errorCallback in case of an error, this callback will be called. optional.
  23404. */
  23405. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23406. }
  23407. /**
  23408. * Expected simplification settings.
  23409. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23410. */
  23411. interface ISimplificationSettings {
  23412. quality: number;
  23413. distance: number;
  23414. optimizeMesh?: boolean;
  23415. }
  23416. class SimplificationSettings implements ISimplificationSettings {
  23417. quality: number;
  23418. distance: number;
  23419. optimizeMesh: boolean | undefined;
  23420. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23421. }
  23422. interface ISimplificationTask {
  23423. settings: Array<ISimplificationSettings>;
  23424. simplificationType: SimplificationType;
  23425. mesh: Mesh;
  23426. successCallback?: () => void;
  23427. parallelProcessing: boolean;
  23428. }
  23429. class SimplificationQueue {
  23430. private _simplificationArray;
  23431. running: boolean;
  23432. constructor();
  23433. addTask(task: ISimplificationTask): void;
  23434. executeNext(): void;
  23435. runSimplification(task: ISimplificationTask): void;
  23436. private getSimplifier(task);
  23437. }
  23438. /**
  23439. * The implemented types of simplification
  23440. * At the moment only Quadratic Error Decimation is implemented
  23441. */
  23442. enum SimplificationType {
  23443. /** Quadratic error decimation */
  23444. QUADRATIC = 0,
  23445. }
  23446. class DecimationTriangle {
  23447. vertices: Array<DecimationVertex>;
  23448. normal: Vector3;
  23449. error: Array<number>;
  23450. deleted: boolean;
  23451. isDirty: boolean;
  23452. borderFactor: number;
  23453. deletePending: boolean;
  23454. originalOffset: number;
  23455. constructor(vertices: Array<DecimationVertex>);
  23456. }
  23457. class DecimationVertex {
  23458. position: Vector3;
  23459. id: number;
  23460. q: QuadraticMatrix;
  23461. isBorder: boolean;
  23462. triangleStart: number;
  23463. triangleCount: number;
  23464. originalOffsets: Array<number>;
  23465. constructor(position: Vector3, id: number);
  23466. updatePosition(newPosition: Vector3): void;
  23467. }
  23468. class QuadraticMatrix {
  23469. data: Array<number>;
  23470. constructor(data?: Array<number>);
  23471. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23472. addInPlace(matrix: QuadraticMatrix): void;
  23473. addArrayInPlace(data: Array<number>): void;
  23474. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23475. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23476. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23477. }
  23478. class Reference {
  23479. vertexId: number;
  23480. triangleId: number;
  23481. constructor(vertexId: number, triangleId: number);
  23482. }
  23483. /**
  23484. * An implementation of the Quadratic Error simplification algorithm.
  23485. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23486. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23487. * @author RaananW
  23488. */
  23489. class QuadraticErrorSimplification implements ISimplifier {
  23490. private _mesh;
  23491. private triangles;
  23492. private vertices;
  23493. private references;
  23494. private _reconstructedMesh;
  23495. syncIterations: number;
  23496. aggressiveness: number;
  23497. decimationIterations: number;
  23498. boundingBoxEpsilon: number;
  23499. constructor(_mesh: Mesh);
  23500. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23501. private runDecimation(settings, submeshIndex, successCallback);
  23502. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  23503. private init(callback);
  23504. private reconstructMesh(submeshIndex);
  23505. private initDecimatedMesh();
  23506. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  23507. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  23508. private identifyBorder();
  23509. private updateMesh(identifyBorders?);
  23510. private vertexError(q, point);
  23511. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  23512. }
  23513. }
  23514. declare module BABYLON {
  23515. class Polygon {
  23516. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23517. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23518. static Parse(input: string): Vector2[];
  23519. static StartingAt(x: number, y: number): Path2;
  23520. }
  23521. class PolygonMeshBuilder {
  23522. private _points;
  23523. private _outlinepoints;
  23524. private _holes;
  23525. private _name;
  23526. private _scene;
  23527. private _epoints;
  23528. private _eholes;
  23529. private _addToepoint(points);
  23530. constructor(name: string, contours: Path2, scene: Scene);
  23531. constructor(name: string, contours: Vector2[], scene: Scene);
  23532. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23533. build(updatable?: boolean, depth?: number): Mesh;
  23534. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23535. }
  23536. }
  23537. declare module BABYLON {
  23538. class BaseSubMesh {
  23539. _materialDefines: Nullable<MaterialDefines>;
  23540. _materialEffect: Nullable<Effect>;
  23541. readonly effect: Nullable<Effect>;
  23542. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23543. }
  23544. class SubMesh extends BaseSubMesh implements ICullable {
  23545. materialIndex: number;
  23546. verticesStart: number;
  23547. verticesCount: number;
  23548. indexStart: number;
  23549. indexCount: number;
  23550. linesIndexCount: number;
  23551. private _mesh;
  23552. private _renderingMesh;
  23553. private _boundingInfo;
  23554. private _linesIndexBuffer;
  23555. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23556. _trianglePlanes: Plane[];
  23557. _lastColliderTransformMatrix: Matrix;
  23558. _renderId: number;
  23559. _alphaIndex: number;
  23560. _distanceToCamera: number;
  23561. _id: number;
  23562. private _currentMaterial;
  23563. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23564. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23565. readonly IsGlobal: boolean;
  23566. /**
  23567. * Returns the submesh BoudingInfo object.
  23568. */
  23569. getBoundingInfo(): BoundingInfo;
  23570. /**
  23571. * Sets the submesh BoundingInfo.
  23572. * Return the SubMesh.
  23573. */
  23574. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23575. /**
  23576. * Returns the mesh of the current submesh.
  23577. */
  23578. getMesh(): AbstractMesh;
  23579. /**
  23580. * Returns the rendering mesh of the submesh.
  23581. */
  23582. getRenderingMesh(): Mesh;
  23583. /**
  23584. * Returns the submesh material.
  23585. */
  23586. getMaterial(): Nullable<Material>;
  23587. /**
  23588. * Sets a new updated BoundingInfo object to the submesh.
  23589. * Returns the SubMesh.
  23590. */
  23591. refreshBoundingInfo(): SubMesh;
  23592. _checkCollision(collider: Collider): boolean;
  23593. /**
  23594. * Updates the submesh BoundingInfo.
  23595. * Returns the Submesh.
  23596. */
  23597. updateBoundingInfo(world: Matrix): SubMesh;
  23598. /**
  23599. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23600. * Boolean returned.
  23601. */
  23602. isInFrustum(frustumPlanes: Plane[]): boolean;
  23603. /**
  23604. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23605. * Boolean returned.
  23606. */
  23607. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23608. /**
  23609. * Renders the submesh.
  23610. * Returns it.
  23611. */
  23612. render(enableAlphaMode: boolean): SubMesh;
  23613. /**
  23614. * Returns a new Index Buffer.
  23615. * Type returned : WebGLBuffer.
  23616. */
  23617. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23618. /**
  23619. * True is the passed Ray intersects the submesh bounding box.
  23620. * Boolean returned.
  23621. */
  23622. canIntersects(ray: Ray): boolean;
  23623. /**
  23624. * Returns an object IntersectionInfo.
  23625. */
  23626. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23627. _rebuild(): void;
  23628. /**
  23629. * Creates a new Submesh from the passed Mesh.
  23630. */
  23631. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23632. /**
  23633. * Disposes the Submesh.
  23634. * Returns nothing.
  23635. */
  23636. dispose(): void;
  23637. /**
  23638. * Creates a new Submesh from the passed parameters :
  23639. * - materialIndex (integer) : the index of the main mesh material.
  23640. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23641. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23642. * - mesh (Mesh) : the main mesh to create the submesh from.
  23643. * - renderingMesh (optional Mesh) : rendering mesh.
  23644. */
  23645. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23646. }
  23647. }
  23648. declare module BABYLON {
  23649. class TransformNode extends Node {
  23650. static BILLBOARDMODE_NONE: number;
  23651. static BILLBOARDMODE_X: number;
  23652. static BILLBOARDMODE_Y: number;
  23653. static BILLBOARDMODE_Z: number;
  23654. static BILLBOARDMODE_ALL: number;
  23655. private _forward;
  23656. private _forwardInverted;
  23657. private _up;
  23658. private _right;
  23659. private _rightInverted;
  23660. private _rotation;
  23661. private _rotationQuaternion;
  23662. protected _scaling: Vector3;
  23663. protected _isDirty: boolean;
  23664. private _transformToBoneReferal;
  23665. billboardMode: number;
  23666. scalingDeterminant: number;
  23667. infiniteDistance: boolean;
  23668. position: Vector3;
  23669. _poseMatrix: Matrix;
  23670. private _localWorld;
  23671. _worldMatrix: Matrix;
  23672. _worldMatrixDeterminant: number;
  23673. private _absolutePosition;
  23674. private _pivotMatrix;
  23675. private _pivotMatrixInverse;
  23676. private _postMultiplyPivotMatrix;
  23677. protected _isWorldMatrixFrozen: boolean;
  23678. /**
  23679. * An event triggered after the world matrix is updated
  23680. */
  23681. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23682. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23683. /**
  23684. * Gets a string idenfifying the name of the class
  23685. * @returns "TransformNode" string
  23686. */
  23687. getClassName(): string;
  23688. /**
  23689. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23690. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23691. * Default : (0.0, 0.0, 0.0)
  23692. */
  23693. rotation: Vector3;
  23694. /**
  23695. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23696. * Default : (1.0, 1.0, 1.0)
  23697. */
  23698. /**
  23699. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23700. * Default : (1.0, 1.0, 1.0)
  23701. */
  23702. scaling: Vector3;
  23703. /**
  23704. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23705. * It's null by default.
  23706. * 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)
  23707. */
  23708. rotationQuaternion: Nullable<Quaternion>;
  23709. /**
  23710. * The forward direction of that transform in world space.
  23711. */
  23712. readonly forward: Vector3;
  23713. /**
  23714. * The up direction of that transform in world space.
  23715. */
  23716. readonly up: Vector3;
  23717. /**
  23718. * The right direction of that transform in world space.
  23719. */
  23720. readonly right: Vector3;
  23721. /**
  23722. * Returns the latest update of the World matrix
  23723. * Returns a Matrix.
  23724. */
  23725. getWorldMatrix(): Matrix;
  23726. /** @hidden */
  23727. _getWorldMatrixDeterminant(): number;
  23728. /**
  23729. * Returns directly the latest state of the mesh World matrix.
  23730. * A Matrix is returned.
  23731. */
  23732. readonly worldMatrixFromCache: Matrix;
  23733. /**
  23734. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23735. * Returns the TransformNode.
  23736. */
  23737. updatePoseMatrix(matrix: Matrix): TransformNode;
  23738. /**
  23739. * Returns the mesh Pose matrix.
  23740. * Returned object : Matrix
  23741. */
  23742. getPoseMatrix(): Matrix;
  23743. _isSynchronized(): boolean;
  23744. _initCache(): void;
  23745. markAsDirty(property: string): TransformNode;
  23746. /**
  23747. * Returns the current mesh absolute position.
  23748. * Retuns a Vector3.
  23749. */
  23750. readonly absolutePosition: Vector3;
  23751. /**
  23752. * Sets a new matrix to apply before all other transformation
  23753. * @param matrix defines the transform matrix
  23754. * @returns the current TransformNode
  23755. */
  23756. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23757. /**
  23758. * Sets a new pivot matrix to the current node
  23759. * @param matrix defines the new pivot matrix to use
  23760. * @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
  23761. * @returns the current TransformNode
  23762. */
  23763. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23764. /**
  23765. * Returns the mesh pivot matrix.
  23766. * Default : Identity.
  23767. * A Matrix is returned.
  23768. */
  23769. getPivotMatrix(): Matrix;
  23770. /**
  23771. * Prevents the World matrix to be computed any longer.
  23772. * Returns the TransformNode.
  23773. */
  23774. freezeWorldMatrix(): TransformNode;
  23775. /**
  23776. * Allows back the World matrix computation.
  23777. * Returns the TransformNode.
  23778. */
  23779. unfreezeWorldMatrix(): this;
  23780. /**
  23781. * True if the World matrix has been frozen.
  23782. * Returns a boolean.
  23783. */
  23784. readonly isWorldMatrixFrozen: boolean;
  23785. /**
  23786. * Retuns the mesh absolute position in the World.
  23787. * Returns a Vector3.
  23788. */
  23789. getAbsolutePosition(): Vector3;
  23790. /**
  23791. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23792. * Returns the TransformNode.
  23793. */
  23794. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23795. /**
  23796. * Sets the mesh position in its local space.
  23797. * Returns the TransformNode.
  23798. */
  23799. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23800. /**
  23801. * Returns the mesh position in the local space from the current World matrix values.
  23802. * Returns a new Vector3.
  23803. */
  23804. getPositionExpressedInLocalSpace(): Vector3;
  23805. /**
  23806. * Translates the mesh along the passed Vector3 in its local space.
  23807. * Returns the TransformNode.
  23808. */
  23809. locallyTranslate(vector3: Vector3): TransformNode;
  23810. private static _lookAtVectorCache;
  23811. /**
  23812. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23813. * @param targetPoint the position (must be in same space as current mesh) to look at
  23814. * @param yawCor optional yaw (y-axis) correction in radians
  23815. * @param pitchCor optional pitch (x-axis) correction in radians
  23816. * @param rollCor optional roll (z-axis) correction in radians
  23817. * @param space the choosen space of the target
  23818. * @returns the TransformNode.
  23819. */
  23820. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23821. /**
  23822. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23823. * This Vector3 is expressed in the World space.
  23824. */
  23825. getDirection(localAxis: Vector3): Vector3;
  23826. /**
  23827. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23828. * localAxis is expressed in the mesh local space.
  23829. * result is computed in the Wordl space from the mesh World matrix.
  23830. * Returns the TransformNode.
  23831. */
  23832. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23833. /**
  23834. * Sets a new pivot point to the current node
  23835. * @param point defines the new pivot point to use
  23836. * @param space defines if the point is in world or local space (local by default)
  23837. * @returns the current TransformNode
  23838. */
  23839. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23840. /**
  23841. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23842. */
  23843. getPivotPoint(): Vector3;
  23844. /**
  23845. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23846. * Returns the TransformNode.
  23847. */
  23848. getPivotPointToRef(result: Vector3): TransformNode;
  23849. /**
  23850. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23851. */
  23852. getAbsolutePivotPoint(): Vector3;
  23853. /**
  23854. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23855. * Returns the TransformNode.
  23856. */
  23857. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23858. /**
  23859. * Defines the passed node as the parent of the current node.
  23860. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23861. * Returns the TransformNode.
  23862. */
  23863. setParent(node: Nullable<Node>): TransformNode;
  23864. private _nonUniformScaling;
  23865. readonly nonUniformScaling: boolean;
  23866. _updateNonUniformScalingState(value: boolean): boolean;
  23867. /**
  23868. * Attach the current TransformNode to another TransformNode associated with a bone
  23869. * @param bone Bone affecting the TransformNode
  23870. * @param affectedTransformNode TransformNode associated with the bone
  23871. */
  23872. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23873. detachFromBone(): TransformNode;
  23874. private static _rotationAxisCache;
  23875. /**
  23876. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23877. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23878. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23879. * The passed axis is also normalized.
  23880. * Returns the TransformNode.
  23881. */
  23882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23883. /**
  23884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23886. * The passed axis is also normalized.
  23887. * Returns the TransformNode.
  23888. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23889. */
  23890. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23891. /**
  23892. * Translates the mesh along the axis vector for the passed distance in the given space.
  23893. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23894. * Returns the TransformNode.
  23895. */
  23896. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23897. /**
  23898. * Adds a rotation step to the mesh current rotation.
  23899. * x, y, z are Euler angles expressed in radians.
  23900. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23901. * This means this rotation is made in the mesh local space only.
  23902. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23903. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23904. * ```javascript
  23905. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23906. * ```
  23907. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23908. * 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.
  23909. * Returns the TransformNode.
  23910. */
  23911. addRotation(x: number, y: number, z: number): TransformNode;
  23912. /**
  23913. * Computes the mesh World matrix and returns it.
  23914. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23915. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23916. * If the parameter `force`is set to `true`, the actual computation is done.
  23917. * Returns the mesh World Matrix.
  23918. */
  23919. computeWorldMatrix(force?: boolean): Matrix;
  23920. protected _afterComputeWorldMatrix(): void;
  23921. /**
  23922. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23923. * @param func: callback function to add
  23924. *
  23925. * Returns the TransformNode.
  23926. */
  23927. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23928. /**
  23929. * Removes a registered callback function.
  23930. * Returns the TransformNode.
  23931. */
  23932. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23933. /**
  23934. * Clone the current transform node
  23935. * Returns the new transform node
  23936. * @param name Name of the new clone
  23937. * @param newParent New parent for the clone
  23938. * @param doNotCloneChildren Do not clone children hierarchy
  23939. */
  23940. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23941. serialize(currentSerializationObject?: any): any;
  23942. /**
  23943. * Returns a new TransformNode object parsed from the source provided.
  23944. * The parameter `parsedMesh` is the source.
  23945. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23946. */
  23947. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23948. /**
  23949. * Releases resources associated with this transform node.
  23950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23952. */
  23953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23954. }
  23955. }
  23956. declare module BABYLON {
  23957. class VertexBuffer {
  23958. private _buffer;
  23959. private _kind;
  23960. private _size;
  23961. private _ownsBuffer;
  23962. private _instanced;
  23963. private _instanceDivisor;
  23964. /**
  23965. * The byte type.
  23966. */
  23967. static readonly BYTE: number;
  23968. /**
  23969. * The unsigned byte type.
  23970. */
  23971. static readonly UNSIGNED_BYTE: number;
  23972. /**
  23973. * The short type.
  23974. */
  23975. static readonly SHORT: number;
  23976. /**
  23977. * The unsigned short type.
  23978. */
  23979. static readonly UNSIGNED_SHORT: number;
  23980. /**
  23981. * The integer type.
  23982. */
  23983. static readonly INT: number;
  23984. /**
  23985. * The unsigned integer type.
  23986. */
  23987. static readonly UNSIGNED_INT: number;
  23988. /**
  23989. * The float type.
  23990. */
  23991. static readonly FLOAT: number;
  23992. /**
  23993. * Gets or sets the instance divisor when in instanced mode
  23994. */
  23995. instanceDivisor: number;
  23996. /**
  23997. * Gets the byte stride.
  23998. */
  23999. readonly byteStride: number;
  24000. /**
  24001. * Gets the byte offset.
  24002. */
  24003. readonly byteOffset: number;
  24004. /**
  24005. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24006. */
  24007. readonly normalized: boolean;
  24008. /**
  24009. * Gets the data type of each component in the array.
  24010. */
  24011. readonly type: number;
  24012. /**
  24013. * Constructor
  24014. * @param engine the engine
  24015. * @param data the data to use for this vertex buffer
  24016. * @param kind the vertex buffer kind
  24017. * @param updatable whether the data is updatable
  24018. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24019. * @param stride the stride (optional)
  24020. * @param instanced whether the buffer is instanced (optional)
  24021. * @param offset the offset of the data (optional)
  24022. * @param size the number of components (optional)
  24023. * @param type the type of the component (optional)
  24024. * @param normalized whether the data contains normalized data (optional)
  24025. * @param useBytes set to true if stride and offset are in bytes (optional)
  24026. */
  24027. 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);
  24028. _rebuild(): void;
  24029. /**
  24030. * Returns the kind of the VertexBuffer (string).
  24031. */
  24032. getKind(): string;
  24033. /**
  24034. * Boolean : is the VertexBuffer updatable ?
  24035. */
  24036. isUpdatable(): boolean;
  24037. /**
  24038. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24039. */
  24040. getData(): Nullable<DataArray>;
  24041. /**
  24042. * Returns the WebGLBuffer associated to the VertexBuffer.
  24043. */
  24044. getBuffer(): Nullable<WebGLBuffer>;
  24045. /**
  24046. * Returns the stride as a multiple of the type byte length.
  24047. * DEPRECATED. Use byteStride instead.
  24048. */
  24049. getStrideSize(): number;
  24050. /**
  24051. * Returns the offset as a multiple of the type byte length.
  24052. * DEPRECATED. Use byteOffset instead.
  24053. */
  24054. getOffset(): number;
  24055. /**
  24056. * Returns the number of components per vertex attribute (integer).
  24057. */
  24058. getSize(): number;
  24059. /**
  24060. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24061. */
  24062. getIsInstanced(): boolean;
  24063. /**
  24064. * Returns the instancing divisor, zero for non-instanced (integer).
  24065. */
  24066. getInstanceDivisor(): number;
  24067. /**
  24068. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24069. * Returns the created WebGLBuffer.
  24070. */
  24071. create(data?: DataArray): void;
  24072. /**
  24073. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24074. * This function will create a new buffer if the current one is not updatable
  24075. * Returns the updated WebGLBuffer.
  24076. */
  24077. update(data: DataArray): void;
  24078. /**
  24079. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24080. * Returns the directly updated WebGLBuffer.
  24081. * @param data the new data
  24082. * @param offset the new offset
  24083. * @param useBytes set to true if the offset is in bytes
  24084. */
  24085. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24086. /**
  24087. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24088. */
  24089. dispose(): void;
  24090. /**
  24091. * Enumerates each value of this vertex buffer as numbers.
  24092. * @param count the number of values to enumerate
  24093. * @param callback the callback function called for each value
  24094. */
  24095. forEach(count: number, callback: (value: number, index: number) => void): void;
  24096. private static _PositionKind;
  24097. private static _NormalKind;
  24098. private static _TangentKind;
  24099. private static _UVKind;
  24100. private static _UV2Kind;
  24101. private static _UV3Kind;
  24102. private static _UV4Kind;
  24103. private static _UV5Kind;
  24104. private static _UV6Kind;
  24105. private static _ColorKind;
  24106. private static _MatricesIndicesKind;
  24107. private static _MatricesWeightsKind;
  24108. private static _MatricesIndicesExtraKind;
  24109. private static _MatricesWeightsExtraKind;
  24110. static readonly PositionKind: string;
  24111. static readonly NormalKind: string;
  24112. static readonly TangentKind: string;
  24113. static readonly UVKind: string;
  24114. static readonly UV2Kind: string;
  24115. static readonly UV3Kind: string;
  24116. static readonly UV4Kind: string;
  24117. static readonly UV5Kind: string;
  24118. static readonly UV6Kind: string;
  24119. static readonly ColorKind: string;
  24120. static readonly MatricesIndicesKind: string;
  24121. static readonly MatricesWeightsKind: string;
  24122. static readonly MatricesIndicesExtraKind: string;
  24123. static readonly MatricesWeightsExtraKind: string;
  24124. /**
  24125. * Deduces the stride given a kind.
  24126. * @param kind The kind string to deduce
  24127. * @returns The deduced stride
  24128. */
  24129. static DeduceStride(kind: string): number;
  24130. /**
  24131. * Gets the byte length of the given type.
  24132. * @param type the type
  24133. * @returns the number of bytes
  24134. */
  24135. static GetTypeByteLength(type: number): number;
  24136. /**
  24137. * Enumerates each value of the given parameters as numbers.
  24138. * @param data the data to enumerate
  24139. * @param byteOffset the byte offset of the data
  24140. * @param byteStride the byte stride of the data
  24141. * @param componentCount the number of components per element
  24142. * @param componentType the type of the component
  24143. * @param count the total number of components
  24144. * @param normalized whether the data is normalized
  24145. * @param callback the callback function called for each value
  24146. */
  24147. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24148. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  24149. }
  24150. }
  24151. declare module BABYLON {
  24152. interface PhysicsImpostorJoint {
  24153. mainImpostor: PhysicsImpostor;
  24154. connectedImpostor: PhysicsImpostor;
  24155. joint: PhysicsJoint;
  24156. }
  24157. class PhysicsEngine {
  24158. private _physicsPlugin;
  24159. gravity: Vector3;
  24160. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24161. setGravity(gravity: Vector3): void;
  24162. /**
  24163. * Set the time step of the physics engine.
  24164. * default is 1/60.
  24165. * To slow it down, enter 1/600 for example.
  24166. * To speed it up, 1/30
  24167. * @param {number} newTimeStep the new timestep to apply to this world.
  24168. */
  24169. setTimeStep(newTimeStep?: number): void;
  24170. /**
  24171. * Get the time step of the physics engine.
  24172. */
  24173. getTimeStep(): number;
  24174. dispose(): void;
  24175. getPhysicsPluginName(): string;
  24176. static Epsilon: number;
  24177. private _impostors;
  24178. private _joints;
  24179. /**
  24180. * Adding a new impostor for the impostor tracking.
  24181. * This will be done by the impostor itself.
  24182. * @param {PhysicsImpostor} impostor the impostor to add
  24183. */
  24184. addImpostor(impostor: PhysicsImpostor): void;
  24185. /**
  24186. * Remove an impostor from the engine.
  24187. * This impostor and its mesh will not longer be updated by the physics engine.
  24188. * @param {PhysicsImpostor} impostor the impostor to remove
  24189. */
  24190. removeImpostor(impostor: PhysicsImpostor): void;
  24191. /**
  24192. * Add a joint to the physics engine
  24193. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24194. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24195. * @param {PhysicsJoint} the joint that will connect both impostors.
  24196. */
  24197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24198. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24199. /**
  24200. * Called by the scene. no need to call it.
  24201. */
  24202. _step(delta: number): void;
  24203. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24204. getImpostors(): Array<PhysicsImpostor>;
  24205. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24206. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24207. }
  24208. interface IPhysicsEnginePlugin {
  24209. world: any;
  24210. name: string;
  24211. setGravity(gravity: Vector3): void;
  24212. setTimeStep(timeStep: number): void;
  24213. getTimeStep(): number;
  24214. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24215. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24216. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24217. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24218. removePhysicsBody(impostor: PhysicsImpostor): void;
  24219. generateJoint(joint: PhysicsImpostorJoint): void;
  24220. removeJoint(joint: PhysicsImpostorJoint): void;
  24221. isSupported(): boolean;
  24222. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24223. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24224. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24225. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24226. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24227. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24228. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24229. getBodyMass(impostor: PhysicsImpostor): number;
  24230. getBodyFriction(impostor: PhysicsImpostor): number;
  24231. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24232. getBodyRestitution(impostor: PhysicsImpostor): number;
  24233. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24234. sleepBody(impostor: PhysicsImpostor): void;
  24235. wakeUpBody(impostor: PhysicsImpostor): void;
  24236. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24237. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24238. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24239. getRadius(impostor: PhysicsImpostor): number;
  24240. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24241. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24242. dispose(): void;
  24243. }
  24244. }
  24245. declare module BABYLON {
  24246. class PhysicsHelper {
  24247. private _scene;
  24248. private _physicsEngine;
  24249. constructor(scene: Scene);
  24250. /**
  24251. * @param {Vector3} origin the origin of the explosion
  24252. * @param {number} radius the explosion radius
  24253. * @param {number} strength the explosion strength
  24254. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24255. */
  24256. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24257. /**
  24258. * @param {Vector3} origin the origin of the explosion
  24259. * @param {number} radius the explosion radius
  24260. * @param {number} strength the explosion strength
  24261. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24262. */
  24263. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24264. /**
  24265. * @param {Vector3} origin the origin of the explosion
  24266. * @param {number} radius the explosion radius
  24267. * @param {number} strength the explosion strength
  24268. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24269. */
  24270. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24271. /**
  24272. * @param {Vector3} origin the origin of the updraft
  24273. * @param {number} radius the radius of the updraft
  24274. * @param {number} strength the strength of the updraft
  24275. * @param {number} height the height of the updraft
  24276. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24277. */
  24278. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24279. /**
  24280. * @param {Vector3} origin the of the vortex
  24281. * @param {number} radius the radius of the vortex
  24282. * @param {number} strength the strength of the vortex
  24283. * @param {number} height the height of the vortex
  24284. */
  24285. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24286. }
  24287. /***** Radial explosion *****/
  24288. class PhysicsRadialExplosionEvent {
  24289. private _scene;
  24290. private _sphere;
  24291. private _sphereOptions;
  24292. private _rays;
  24293. private _dataFetched;
  24294. constructor(scene: Scene);
  24295. /**
  24296. * Returns the data related to the radial explosion event (sphere & rays).
  24297. * @returns {PhysicsRadialExplosionEventData}
  24298. */
  24299. getData(): PhysicsRadialExplosionEventData;
  24300. /**
  24301. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24302. * @param impostor
  24303. * @param {Vector3} origin the origin of the explosion
  24304. * @param {number} radius the explosion radius
  24305. * @param {number} strength the explosion strength
  24306. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24307. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24308. */
  24309. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24310. /**
  24311. * Disposes the sphere.
  24312. * @param {bolean} force
  24313. */
  24314. dispose(force?: boolean): void;
  24315. /*** Helpers ***/
  24316. private _prepareSphere();
  24317. private _intersectsWithSphere(impostor, origin, radius);
  24318. }
  24319. /***** Gravitational Field *****/
  24320. class PhysicsGravitationalFieldEvent {
  24321. private _physicsHelper;
  24322. private _scene;
  24323. private _origin;
  24324. private _radius;
  24325. private _strength;
  24326. private _falloff;
  24327. private _tickCallback;
  24328. private _sphere;
  24329. private _dataFetched;
  24330. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24331. /**
  24332. * Returns the data related to the gravitational field event (sphere).
  24333. * @returns {PhysicsGravitationalFieldEventData}
  24334. */
  24335. getData(): PhysicsGravitationalFieldEventData;
  24336. /**
  24337. * Enables the gravitational field.
  24338. */
  24339. enable(): void;
  24340. /**
  24341. * Disables the gravitational field.
  24342. */
  24343. disable(): void;
  24344. /**
  24345. * Disposes the sphere.
  24346. * @param {bolean} force
  24347. */
  24348. dispose(force?: boolean): void;
  24349. private _tick();
  24350. }
  24351. /***** Updraft *****/
  24352. class PhysicsUpdraftEvent {
  24353. private _scene;
  24354. private _origin;
  24355. private _radius;
  24356. private _strength;
  24357. private _height;
  24358. private _updraftMode;
  24359. private _physicsEngine;
  24360. private _originTop;
  24361. private _originDirection;
  24362. private _tickCallback;
  24363. private _cylinder;
  24364. private _cylinderPosition;
  24365. private _dataFetched;
  24366. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24367. /**
  24368. * Returns the data related to the updraft event (cylinder).
  24369. * @returns {PhysicsUpdraftEventData}
  24370. */
  24371. getData(): PhysicsUpdraftEventData;
  24372. /**
  24373. * Enables the updraft.
  24374. */
  24375. enable(): void;
  24376. /**
  24377. * Disables the cortex.
  24378. */
  24379. disable(): void;
  24380. /**
  24381. * Disposes the sphere.
  24382. * @param {bolean} force
  24383. */
  24384. dispose(force?: boolean): void;
  24385. private getImpostorForceAndContactPoint(impostor);
  24386. private _tick();
  24387. /*** Helpers ***/
  24388. private _prepareCylinder();
  24389. private _intersectsWithCylinder(impostor);
  24390. }
  24391. /***** Vortex *****/
  24392. class PhysicsVortexEvent {
  24393. private _scene;
  24394. private _origin;
  24395. private _radius;
  24396. private _strength;
  24397. private _height;
  24398. private _physicsEngine;
  24399. private _originTop;
  24400. private _centripetalForceThreshold;
  24401. private _updraftMultiplier;
  24402. private _tickCallback;
  24403. private _cylinder;
  24404. private _cylinderPosition;
  24405. private _dataFetched;
  24406. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24407. /**
  24408. * Returns the data related to the vortex event (cylinder).
  24409. * @returns {PhysicsVortexEventData}
  24410. */
  24411. getData(): PhysicsVortexEventData;
  24412. /**
  24413. * Enables the vortex.
  24414. */
  24415. enable(): void;
  24416. /**
  24417. * Disables the cortex.
  24418. */
  24419. disable(): void;
  24420. /**
  24421. * Disposes the sphere.
  24422. * @param {bolean} force
  24423. */
  24424. dispose(force?: boolean): void;
  24425. private getImpostorForceAndContactPoint(impostor);
  24426. private _tick();
  24427. /*** Helpers ***/
  24428. private _prepareCylinder();
  24429. private _intersectsWithCylinder(impostor);
  24430. }
  24431. /***** Enums *****/
  24432. /**
  24433. * The strenght of the force in correspondence to the distance of the affected object
  24434. */
  24435. enum PhysicsRadialImpulseFalloff {
  24436. /** Defines that impulse is constant in strength across it's whole radius */
  24437. Constant = 0,
  24438. /** DEfines that impulse gets weaker if it's further from the origin */
  24439. Linear = 1,
  24440. }
  24441. /**
  24442. * The strenght of the force in correspondence to the distance of the affected object
  24443. */
  24444. enum PhysicsUpdraftMode {
  24445. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24446. Center = 0,
  24447. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24448. Perpendicular = 1,
  24449. }
  24450. /***** Data interfaces *****/
  24451. interface PhysicsForceAndContactPoint {
  24452. force: Vector3;
  24453. contactPoint: Vector3;
  24454. }
  24455. interface PhysicsRadialExplosionEventData {
  24456. sphere: Mesh;
  24457. rays: Array<Ray>;
  24458. }
  24459. interface PhysicsGravitationalFieldEventData {
  24460. sphere: Mesh;
  24461. }
  24462. interface PhysicsUpdraftEventData {
  24463. cylinder: Mesh;
  24464. }
  24465. interface PhysicsVortexEventData {
  24466. cylinder: Mesh;
  24467. }
  24468. }
  24469. declare module BABYLON {
  24470. interface PhysicsImpostorParameters {
  24471. mass: number;
  24472. friction?: number;
  24473. restitution?: number;
  24474. nativeOptions?: any;
  24475. ignoreParent?: boolean;
  24476. disableBidirectionalTransformation?: boolean;
  24477. }
  24478. interface IPhysicsEnabledObject {
  24479. position: Vector3;
  24480. rotationQuaternion: Nullable<Quaternion>;
  24481. scaling: Vector3;
  24482. rotation?: Vector3;
  24483. parent?: any;
  24484. getBoundingInfo(): BoundingInfo;
  24485. computeWorldMatrix(force: boolean): Matrix;
  24486. getWorldMatrix?(): Matrix;
  24487. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24488. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24489. getIndices?(): Nullable<IndicesArray>;
  24490. getScene?(): Scene;
  24491. getAbsolutePosition(): Vector3;
  24492. getAbsolutePivotPoint(): Vector3;
  24493. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24494. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24495. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24496. getClassName(): string;
  24497. }
  24498. class PhysicsImpostor {
  24499. object: IPhysicsEnabledObject;
  24500. type: number;
  24501. private _options;
  24502. private _scene;
  24503. static DEFAULT_OBJECT_SIZE: Vector3;
  24504. static IDENTITY_QUATERNION: Quaternion;
  24505. private _physicsEngine;
  24506. private _physicsBody;
  24507. private _bodyUpdateRequired;
  24508. private _onBeforePhysicsStepCallbacks;
  24509. private _onAfterPhysicsStepCallbacks;
  24510. private _onPhysicsCollideCallbacks;
  24511. private _deltaPosition;
  24512. private _deltaRotation;
  24513. private _deltaRotationConjugated;
  24514. private _parent;
  24515. private _isDisposed;
  24516. private static _tmpVecs;
  24517. private static _tmpQuat;
  24518. readonly isDisposed: boolean;
  24519. mass: number;
  24520. friction: number;
  24521. restitution: number;
  24522. uniqueId: number;
  24523. private _joints;
  24524. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24525. /**
  24526. * This function will completly initialize this impostor.
  24527. * It will create a new body - but only if this mesh has no parent.
  24528. * If it has, this impostor will not be used other than to define the impostor
  24529. * of the child mesh.
  24530. */
  24531. _init(): void;
  24532. private _getPhysicsParent();
  24533. /**
  24534. * Should a new body be generated.
  24535. */
  24536. isBodyInitRequired(): boolean;
  24537. setScalingUpdated(updated: boolean): void;
  24538. /**
  24539. * Force a regeneration of this or the parent's impostor's body.
  24540. * Use under cautious - This will remove all joints already implemented.
  24541. */
  24542. forceUpdate(): void;
  24543. /**
  24544. * Gets the body that holds this impostor. Either its own, or its parent.
  24545. */
  24546. /**
  24547. * Set the physics body. Used mainly by the physics engine/plugin
  24548. */
  24549. physicsBody: any;
  24550. parent: Nullable<PhysicsImpostor>;
  24551. resetUpdateFlags(): void;
  24552. getObjectExtendSize(): Vector3;
  24553. getObjectCenter(): Vector3;
  24554. /**
  24555. * Get a specific parametes from the options parameter.
  24556. */
  24557. getParam(paramName: string): any;
  24558. /**
  24559. * Sets a specific parameter in the options given to the physics plugin
  24560. */
  24561. setParam(paramName: string, value: number): void;
  24562. /**
  24563. * Specifically change the body's mass option. Won't recreate the physics body object
  24564. */
  24565. setMass(mass: number): void;
  24566. getLinearVelocity(): Nullable<Vector3>;
  24567. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24568. getAngularVelocity(): Nullable<Vector3>;
  24569. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24570. /**
  24571. * Execute a function with the physics plugin native code.
  24572. * Provide a function the will have two variables - the world object and the physics body object.
  24573. */
  24574. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24575. /**
  24576. * Register a function that will be executed before the physics world is stepping forward.
  24577. */
  24578. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24579. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24580. /**
  24581. * Register a function that will be executed after the physics step
  24582. */
  24583. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24584. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24585. /**
  24586. * register a function that will be executed when this impostor collides against a different body.
  24587. */
  24588. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24589. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24590. private _tmpQuat;
  24591. private _tmpQuat2;
  24592. getParentsRotation(): Quaternion;
  24593. /**
  24594. * this function is executed by the physics engine.
  24595. */
  24596. beforeStep: () => void;
  24597. /**
  24598. * this function is executed by the physics engine.
  24599. */
  24600. afterStep: () => void;
  24601. /**
  24602. * Legacy collision detection event support
  24603. */
  24604. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24605. onCollide: (e: {
  24606. body: any;
  24607. }) => void;
  24608. /**
  24609. * Apply a force
  24610. */
  24611. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24612. /**
  24613. * Apply an impulse
  24614. */
  24615. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24616. /**
  24617. * A help function to create a joint.
  24618. */
  24619. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24620. /**
  24621. * Add a joint to this impostor with a different impostor.
  24622. */
  24623. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24624. /**
  24625. * Will keep this body still, in a sleep mode.
  24626. */
  24627. sleep(): PhysicsImpostor;
  24628. /**
  24629. * Wake the body up.
  24630. */
  24631. wakeUp(): PhysicsImpostor;
  24632. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24633. dispose(): void;
  24634. setDeltaPosition(position: Vector3): void;
  24635. setDeltaRotation(rotation: Quaternion): void;
  24636. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24637. getRadius(): number;
  24638. /**
  24639. * Sync a bone with this impostor
  24640. * @param bone The bone to sync to the impostor.
  24641. * @param boneMesh The mesh that the bone is influencing.
  24642. * @param jointPivot The pivot of the joint / bone in local space.
  24643. * @param distToJoint Optional distance from the impostor to the joint.
  24644. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24645. */
  24646. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24647. /**
  24648. * Sync impostor to a bone
  24649. * @param bone The bone that the impostor will be synced to.
  24650. * @param boneMesh The mesh that the bone is influencing.
  24651. * @param jointPivot The pivot of the joint / bone in local space.
  24652. * @param distToJoint Optional distance from the impostor to the joint.
  24653. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24654. * @param boneAxis Optional vector3 axis the bone is aligned with
  24655. */
  24656. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24657. static NoImpostor: number;
  24658. static SphereImpostor: number;
  24659. static BoxImpostor: number;
  24660. static PlaneImpostor: number;
  24661. static MeshImpostor: number;
  24662. static CylinderImpostor: number;
  24663. static ParticleImpostor: number;
  24664. static HeightmapImpostor: number;
  24665. }
  24666. }
  24667. declare module BABYLON {
  24668. interface PhysicsJointData {
  24669. mainPivot?: Vector3;
  24670. connectedPivot?: Vector3;
  24671. mainAxis?: Vector3;
  24672. connectedAxis?: Vector3;
  24673. collision?: boolean;
  24674. nativeParams?: any;
  24675. }
  24676. /**
  24677. * This is a holder class for the physics joint created by the physics plugin.
  24678. * It holds a set of functions to control the underlying joint.
  24679. */
  24680. class PhysicsJoint {
  24681. type: number;
  24682. jointData: PhysicsJointData;
  24683. private _physicsJoint;
  24684. protected _physicsPlugin: IPhysicsEnginePlugin;
  24685. constructor(type: number, jointData: PhysicsJointData);
  24686. physicsJoint: any;
  24687. physicsPlugin: IPhysicsEnginePlugin;
  24688. /**
  24689. * Execute a function that is physics-plugin specific.
  24690. * @param {Function} func the function that will be executed.
  24691. * It accepts two parameters: the physics world and the physics joint.
  24692. */
  24693. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24694. static DistanceJoint: number;
  24695. static HingeJoint: number;
  24696. static BallAndSocketJoint: number;
  24697. static WheelJoint: number;
  24698. static SliderJoint: number;
  24699. static PrismaticJoint: number;
  24700. static UniversalJoint: number;
  24701. static Hinge2Joint: number;
  24702. static PointToPointJoint: number;
  24703. static SpringJoint: number;
  24704. static LockJoint: number;
  24705. }
  24706. /**
  24707. * A class representing a physics distance joint.
  24708. */
  24709. class DistanceJoint extends PhysicsJoint {
  24710. constructor(jointData: DistanceJointData);
  24711. /**
  24712. * Update the predefined distance.
  24713. */
  24714. updateDistance(maxDistance: number, minDistance?: number): void;
  24715. }
  24716. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24717. constructor(type: number, jointData: PhysicsJointData);
  24718. /**
  24719. * Set the motor values.
  24720. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24721. * @param {number} force the force to apply
  24722. * @param {number} maxForce max force for this motor.
  24723. */
  24724. setMotor(force?: number, maxForce?: number): void;
  24725. /**
  24726. * Set the motor's limits.
  24727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24728. */
  24729. setLimit(upperLimit: number, lowerLimit?: number): void;
  24730. }
  24731. /**
  24732. * This class represents a single hinge physics joint
  24733. */
  24734. class HingeJoint extends MotorEnabledJoint {
  24735. constructor(jointData: PhysicsJointData);
  24736. /**
  24737. * Set the motor values.
  24738. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24739. * @param {number} force the force to apply
  24740. * @param {number} maxForce max force for this motor.
  24741. */
  24742. setMotor(force?: number, maxForce?: number): void;
  24743. /**
  24744. * Set the motor's limits.
  24745. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24746. */
  24747. setLimit(upperLimit: number, lowerLimit?: number): void;
  24748. }
  24749. /**
  24750. * This class represents a dual hinge physics joint (same as wheel joint)
  24751. */
  24752. class Hinge2Joint extends MotorEnabledJoint {
  24753. constructor(jointData: PhysicsJointData);
  24754. /**
  24755. * Set the motor values.
  24756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24757. * @param {number} force the force to apply
  24758. * @param {number} maxForce max force for this motor.
  24759. * @param {motorIndex} the motor's index, 0 or 1.
  24760. */
  24761. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24762. /**
  24763. * Set the motor limits.
  24764. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24765. * @param {number} upperLimit the upper limit
  24766. * @param {number} lowerLimit lower limit
  24767. * @param {motorIndex} the motor's index, 0 or 1.
  24768. */
  24769. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24770. }
  24771. interface IMotorEnabledJoint {
  24772. physicsJoint: any;
  24773. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24774. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24775. }
  24776. interface DistanceJointData extends PhysicsJointData {
  24777. maxDistance: number;
  24778. }
  24779. interface SpringJointData extends PhysicsJointData {
  24780. length: number;
  24781. stiffness: number;
  24782. damping: number;
  24783. }
  24784. }
  24785. declare module BABYLON {
  24786. /**
  24787. * Defines a target to use with MorphTargetManager
  24788. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24789. */
  24790. class MorphTarget implements IAnimatable {
  24791. /** defines the name of the target */
  24792. name: string;
  24793. /**
  24794. * Gets or sets the list of animations
  24795. */
  24796. animations: Animation[];
  24797. private _scene;
  24798. private _positions;
  24799. private _normals;
  24800. private _tangents;
  24801. private _influence;
  24802. /**
  24803. * Observable raised when the influence changes
  24804. */
  24805. onInfluenceChanged: Observable<boolean>;
  24806. /**
  24807. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24808. */
  24809. influence: number;
  24810. private _animationPropertiesOverride;
  24811. /**
  24812. * Gets or sets the animation properties override
  24813. */
  24814. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24815. /**
  24816. * Creates a new MorphTarget
  24817. * @param name defines the name of the target
  24818. * @param influence defines the influence to use
  24819. */
  24820. constructor(
  24821. /** defines the name of the target */
  24822. name: string, influence?: number, scene?: Nullable<Scene>);
  24823. /**
  24824. * Gets a boolean defining if the target contains position data
  24825. */
  24826. readonly hasPositions: boolean;
  24827. /**
  24828. * Gets a boolean defining if the target contains normal data
  24829. */
  24830. readonly hasNormals: boolean;
  24831. /**
  24832. * Gets a boolean defining if the target contains tangent data
  24833. */
  24834. readonly hasTangents: boolean;
  24835. /**
  24836. * Affects position data to this target
  24837. * @param data defines the position data to use
  24838. */
  24839. setPositions(data: Nullable<FloatArray>): void;
  24840. /**
  24841. * Gets the position data stored in this target
  24842. * @returns a FloatArray containing the position data (or null if not present)
  24843. */
  24844. getPositions(): Nullable<FloatArray>;
  24845. /**
  24846. * Affects normal data to this target
  24847. * @param data defines the normal data to use
  24848. */
  24849. setNormals(data: Nullable<FloatArray>): void;
  24850. /**
  24851. * Gets the normal data stored in this target
  24852. * @returns a FloatArray containing the normal data (or null if not present)
  24853. */
  24854. getNormals(): Nullable<FloatArray>;
  24855. /**
  24856. * Affects tangent data to this target
  24857. * @param data defines the tangent data to use
  24858. */
  24859. setTangents(data: Nullable<FloatArray>): void;
  24860. /**
  24861. * Gets the tangent data stored in this target
  24862. * @returns a FloatArray containing the tangent data (or null if not present)
  24863. */
  24864. getTangents(): Nullable<FloatArray>;
  24865. /**
  24866. * Serializes the current target into a Serialization object
  24867. * @returns the serialized object
  24868. */
  24869. serialize(): any;
  24870. /**
  24871. * Creates a new target from serialized data
  24872. * @param serializationObject defines the serialized data to use
  24873. * @returns a new MorphTarget
  24874. */
  24875. static Parse(serializationObject: any): MorphTarget;
  24876. /**
  24877. * Creates a MorphTarget from mesh data
  24878. * @param mesh defines the source mesh
  24879. * @param name defines the name to use for the new target
  24880. * @param influence defines the influence to attach to the target
  24881. * @returns a new MorphTarget
  24882. */
  24883. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24884. }
  24885. }
  24886. declare module BABYLON {
  24887. /**
  24888. * This class is used to deform meshes using morphing between different targets
  24889. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24890. */
  24891. class MorphTargetManager {
  24892. private _targets;
  24893. private _targetObservable;
  24894. private _activeTargets;
  24895. private _scene;
  24896. private _influences;
  24897. private _supportsNormals;
  24898. private _supportsTangents;
  24899. private _vertexCount;
  24900. private _uniqueId;
  24901. private _tempInfluences;
  24902. /**
  24903. * Creates a new MorphTargetManager
  24904. * @param scene defines the current scene
  24905. */
  24906. constructor(scene?: Nullable<Scene>);
  24907. /**
  24908. * Gets the unique ID of this manager
  24909. */
  24910. readonly uniqueId: number;
  24911. /**
  24912. * Gets the number of vertices handled by this manager
  24913. */
  24914. readonly vertexCount: number;
  24915. /**
  24916. * Gets a boolean indicating if this manager supports morphing of normals
  24917. */
  24918. readonly supportsNormals: boolean;
  24919. /**
  24920. * Gets a boolean indicating if this manager supports morphing of tangents
  24921. */
  24922. readonly supportsTangents: boolean;
  24923. /**
  24924. * Gets the number of targets stored in this manager
  24925. */
  24926. readonly numTargets: number;
  24927. /**
  24928. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24929. */
  24930. readonly numInfluencers: number;
  24931. /**
  24932. * Gets the list of influences (one per target)
  24933. */
  24934. readonly influences: Float32Array;
  24935. /**
  24936. * Gets the active target at specified index. An active target is a target with an influence > 0
  24937. * @param index defines the index to check
  24938. * @returns the requested target
  24939. */
  24940. getActiveTarget(index: number): MorphTarget;
  24941. /**
  24942. * Gets the target at specified index
  24943. * @param index defines the index to check
  24944. * @returns the requested target
  24945. */
  24946. getTarget(index: number): MorphTarget;
  24947. /**
  24948. * Add a new target to this manager
  24949. * @param target defines the target to add
  24950. */
  24951. addTarget(target: MorphTarget): void;
  24952. /**
  24953. * Removes a target from the manager
  24954. * @param target defines the target to remove
  24955. */
  24956. removeTarget(target: MorphTarget): void;
  24957. /**
  24958. * Serializes the current manager into a Serialization object
  24959. * @returns the serialized object
  24960. */
  24961. serialize(): any;
  24962. private _syncActiveTargets(needUpdate);
  24963. /**
  24964. * Syncrhonize the targets with all the meshes using this morph target manager
  24965. */
  24966. synchronize(): void;
  24967. /**
  24968. * Creates a new MorphTargetManager from serialized data
  24969. * @param serializationObject defines the serialized data
  24970. * @param scene defines the hosting scene
  24971. * @returns the new MorphTargetManager
  24972. */
  24973. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24974. }
  24975. }
  24976. declare module BABYLON {
  24977. /**
  24978. * Postprocess used to generate anaglyphic rendering
  24979. */
  24980. class AnaglyphPostProcess extends PostProcess {
  24981. private _passedProcess;
  24982. /**
  24983. * Creates a new AnaglyphPostProcess
  24984. * @param name defines postprocess name
  24985. * @param options defines creation options or target ratio scale
  24986. * @param rigCameras defines cameras using this postprocess
  24987. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  24988. * @param engine defines hosting engine
  24989. * @param reusable defines if the postprocess will be reused multiple times per frame
  24990. */
  24991. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  24992. }
  24993. }
  24994. declare module BABYLON {
  24995. class BlackAndWhitePostProcess extends PostProcess {
  24996. degree: number;
  24997. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24998. }
  24999. }
  25000. declare module BABYLON {
  25001. /**
  25002. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25003. */
  25004. class BloomEffect extends PostProcessRenderEffect {
  25005. private bloomScale;
  25006. /**
  25007. * Internal
  25008. */
  25009. _effects: Array<PostProcess>;
  25010. /**
  25011. * Internal
  25012. */
  25013. _downscale: ExtractHighlightsPostProcess;
  25014. private _blurX;
  25015. private _blurY;
  25016. private _merge;
  25017. /**
  25018. * The luminance threshold to find bright areas of the image to bloom.
  25019. */
  25020. threshold: number;
  25021. /**
  25022. * The strength of the bloom.
  25023. */
  25024. weight: number;
  25025. /**
  25026. * Specifies the size of the bloom blur kernel, relative to the final output size
  25027. */
  25028. kernel: number;
  25029. /**
  25030. * Creates a new instance of @see BloomEffect
  25031. * @param scene The scene the effect belongs to.
  25032. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25033. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25034. * @param bloomWeight The the strength of bloom.
  25035. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25036. * @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)
  25037. */
  25038. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25039. /**
  25040. * Disposes each of the internal effects for a given camera.
  25041. * @param camera The camera to dispose the effect on.
  25042. */
  25043. disposeEffects(camera: Camera): void;
  25044. /**
  25045. * Internal
  25046. */
  25047. _updateEffects(): void;
  25048. /**
  25049. * Internal
  25050. * @returns if all the contained post processes are ready.
  25051. */
  25052. _isReady(): boolean;
  25053. }
  25054. }
  25055. declare module BABYLON {
  25056. /**
  25057. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25058. */
  25059. class BloomMergePostProcess extends PostProcess {
  25060. /** Weight of the bloom to be added to the original input. */ weight: number;
  25061. /**
  25062. * Creates a new instance of @see BloomMergePostProcess
  25063. * @param name The name of the effect.
  25064. * @param originalFromInput Post process which's input will be used for the merge.
  25065. * @param blurred Blurred highlights post process which's output will be used.
  25066. * @param weight Weight of the bloom to be added to the original input.
  25067. * @param options The required width/height ratio to downsize to before computing the render pass.
  25068. * @param camera The camera to apply the render pass to.
  25069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25070. * @param engine The engine which the post process will be applied. (default: current engine)
  25071. * @param reusable If the post process can be reused on the same frame. (default: false)
  25072. * @param textureType Type of textures used when performing the post process. (default: 0)
  25073. * @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)
  25074. */
  25075. 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);
  25076. }
  25077. }
  25078. declare module BABYLON {
  25079. /**
  25080. * The Blur Post Process which blurs an image based on a kernel and direction.
  25081. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25082. */
  25083. class BlurPostProcess extends PostProcess {
  25084. /** The direction in which to blur the image. */ direction: Vector2;
  25085. private blockCompilation;
  25086. protected _kernel: number;
  25087. protected _idealKernel: number;
  25088. protected _packedFloat: boolean;
  25089. private _staticDefines;
  25090. /**
  25091. * Gets the length in pixels of the blur sample region
  25092. */
  25093. /**
  25094. * Sets the length in pixels of the blur sample region
  25095. */
  25096. kernel: number;
  25097. /**
  25098. * Gets wether or not the blur is unpacking/repacking floats
  25099. */
  25100. /**
  25101. * Sets wether or not the blur needs to unpack/repack floats
  25102. */
  25103. packedFloat: boolean;
  25104. /**
  25105. * Creates a new instance BlurPostProcess
  25106. * @param name The name of the effect.
  25107. * @param direction The direction in which to blur the image.
  25108. * @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.
  25109. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25110. * @param camera The camera to apply the render pass to.
  25111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25112. * @param engine The engine which the post process will be applied. (default: current engine)
  25113. * @param reusable If the post process can be reused on the same frame. (default: false)
  25114. * @param textureType Type of textures used when performing the post process. (default: 0)
  25115. * @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)
  25116. */
  25117. 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);
  25118. /**
  25119. * Updates the effect with the current post process compile time values and recompiles the shader.
  25120. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25121. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25122. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25123. * @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
  25124. * @param onCompiled Called when the shader has been compiled.
  25125. * @param onError Called if there is an error when compiling a shader.
  25126. */
  25127. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25128. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25129. /**
  25130. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25131. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25132. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25133. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25134. * The gaps between physical kernels are compensated for in the weighting of the samples
  25135. * @param idealKernel Ideal blur kernel.
  25136. * @return Nearest best kernel.
  25137. */
  25138. protected _nearestBestKernel(idealKernel: number): number;
  25139. /**
  25140. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25141. * @param x The point on the Gaussian distribution to sample.
  25142. * @return the value of the Gaussian function at x.
  25143. */
  25144. protected _gaussianWeight(x: number): number;
  25145. /**
  25146. * Generates a string that can be used as a floating point number in GLSL.
  25147. * @param x Value to print.
  25148. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25149. * @return GLSL float string.
  25150. */
  25151. protected _glslFloat(x: number, decimalFigures?: number): string;
  25152. }
  25153. }
  25154. declare module BABYLON {
  25155. /**
  25156. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25157. */
  25158. class ChromaticAberrationPostProcess extends PostProcess {
  25159. /**
  25160. * The amount of seperation of rgb channels (default: 30)
  25161. */
  25162. aberrationAmount: number;
  25163. /**
  25164. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25165. */
  25166. radialIntensity: number;
  25167. /**
  25168. * 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))
  25169. */
  25170. direction: Vector2;
  25171. /**
  25172. * 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))
  25173. */
  25174. centerPosition: Vector2;
  25175. /**
  25176. * Creates a new instance ChromaticAberrationPostProcess
  25177. * @param name The name of the effect.
  25178. * @param screenWidth The width of the screen to apply the effect on.
  25179. * @param screenHeight The height of the screen to apply the effect on.
  25180. * @param options The required width/height ratio to downsize to before computing the render pass.
  25181. * @param camera The camera to apply the render pass to.
  25182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25183. * @param engine The engine which the post process will be applied. (default: current engine)
  25184. * @param reusable If the post process can be reused on the same frame. (default: false)
  25185. * @param textureType Type of textures used when performing the post process. (default: 0)
  25186. * @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)
  25187. */
  25188. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25189. }
  25190. }
  25191. declare module BABYLON {
  25192. /**
  25193. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25194. */
  25195. class CircleOfConfusionPostProcess extends PostProcess {
  25196. /**
  25197. * 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.
  25198. */
  25199. lensSize: number;
  25200. /**
  25201. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25202. */
  25203. fStop: number;
  25204. /**
  25205. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25206. */
  25207. focusDistance: number;
  25208. /**
  25209. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25210. */
  25211. focalLength: number;
  25212. private _depthTexture;
  25213. /**
  25214. * Creates a new instance CircleOfConfusionPostProcess
  25215. * @param name The name of the effect.
  25216. * @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.
  25217. * @param options The required width/height ratio to downsize to before computing the render pass.
  25218. * @param camera The camera to apply the render pass to.
  25219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25220. * @param engine The engine which the post process will be applied. (default: current engine)
  25221. * @param reusable If the post process can be reused on the same frame. (default: false)
  25222. * @param textureType Type of textures used when performing the post process. (default: 0)
  25223. * @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)
  25224. */
  25225. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25226. /**
  25227. * 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.
  25228. */
  25229. depthTexture: RenderTargetTexture;
  25230. }
  25231. }
  25232. declare module BABYLON {
  25233. class ColorCorrectionPostProcess extends PostProcess {
  25234. private _colorTableTexture;
  25235. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25236. }
  25237. }
  25238. declare module BABYLON {
  25239. /**
  25240. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25241. * input texture to perform effects such as edge detection or sharpening
  25242. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25243. */
  25244. class ConvolutionPostProcess extends PostProcess {
  25245. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25246. /**
  25247. * Creates a new instance ConvolutionPostProcess
  25248. * @param name The name of the effect.
  25249. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25250. * @param options The required width/height ratio to downsize to before computing the render pass.
  25251. * @param camera The camera to apply the render pass to.
  25252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25253. * @param engine The engine which the post process will be applied. (default: current engine)
  25254. * @param reusable If the post process can be reused on the same frame. (default: false)
  25255. * @param textureType Type of textures used when performing the post process. (default: 0)
  25256. */
  25257. 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);
  25258. /**
  25259. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25260. */
  25261. static EdgeDetect0Kernel: number[];
  25262. /**
  25263. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25264. */
  25265. static EdgeDetect1Kernel: number[];
  25266. /**
  25267. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25268. */
  25269. static EdgeDetect2Kernel: number[];
  25270. /**
  25271. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25272. */
  25273. static SharpenKernel: number[];
  25274. /**
  25275. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25276. */
  25277. static EmbossKernel: number[];
  25278. /**
  25279. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25280. */
  25281. static GaussianKernel: number[];
  25282. }
  25283. }
  25284. declare module BABYLON {
  25285. /**
  25286. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25287. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25288. * based on samples that have a large difference in distance than the center pixel.
  25289. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25290. */
  25291. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25292. direction: Vector2;
  25293. /**
  25294. * Creates a new instance CircleOfConfusionPostProcess
  25295. * @param name The name of the effect.
  25296. * @param scene The scene the effect belongs to.
  25297. * @param direction The direction the blur should be applied.
  25298. * @param kernel The size of the kernel used to blur.
  25299. * @param options The required width/height ratio to downsize to before computing the render pass.
  25300. * @param camera The camera to apply the render pass to.
  25301. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25302. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25304. * @param engine The engine which the post process will be applied. (default: current engine)
  25305. * @param reusable If the post process can be reused on the same frame. (default: false)
  25306. * @param textureType Type of textures used when performing the post process. (default: 0)
  25307. * @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)
  25308. */
  25309. 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);
  25310. }
  25311. }
  25312. declare module BABYLON {
  25313. /**
  25314. * Specifies the level of max blur that should be applied when using the depth of field effect
  25315. */
  25316. enum DepthOfFieldEffectBlurLevel {
  25317. /**
  25318. * Subtle blur
  25319. */
  25320. Low = 0,
  25321. /**
  25322. * Medium blur
  25323. */
  25324. Medium = 1,
  25325. /**
  25326. * Large blur
  25327. */
  25328. High = 2,
  25329. }
  25330. /**
  25331. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25332. */
  25333. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25334. private _circleOfConfusion;
  25335. /**
  25336. * Internal, blurs from high to low
  25337. */
  25338. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25339. private _depthOfFieldBlurY;
  25340. private _dofMerge;
  25341. /**
  25342. * Internal post processes in depth of field effect
  25343. */
  25344. _effects: Array<PostProcess>;
  25345. /**
  25346. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25347. */
  25348. focalLength: number;
  25349. /**
  25350. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25351. */
  25352. fStop: number;
  25353. /**
  25354. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25355. */
  25356. focusDistance: number;
  25357. /**
  25358. * 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.
  25359. */
  25360. lensSize: number;
  25361. /**
  25362. * Creates a new instance DepthOfFieldEffect
  25363. * @param scene The scene the effect belongs to.
  25364. * @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.
  25365. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25366. * @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)
  25367. */
  25368. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25369. /**
  25370. * 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.
  25371. */
  25372. depthTexture: RenderTargetTexture;
  25373. /**
  25374. * Disposes each of the internal effects for a given camera.
  25375. * @param camera The camera to dispose the effect on.
  25376. */
  25377. disposeEffects(camera: Camera): void;
  25378. /**
  25379. * Internal
  25380. */
  25381. _updateEffects(): void;
  25382. /**
  25383. * Internal
  25384. * @returns if all the contained post processes are ready.
  25385. */
  25386. _isReady(): boolean;
  25387. }
  25388. }
  25389. declare module BABYLON {
  25390. /**
  25391. * Options to be set when merging outputs from the default pipeline.
  25392. */
  25393. class DepthOfFieldMergePostProcessOptions {
  25394. /**
  25395. * The original image to merge on top of
  25396. */
  25397. originalFromInput: PostProcess;
  25398. /**
  25399. * Parameters to perform the merge of the depth of field effect
  25400. */
  25401. depthOfField?: {
  25402. circleOfConfusion: PostProcess;
  25403. blurSteps: Array<PostProcess>;
  25404. };
  25405. /**
  25406. * Parameters to perform the merge of bloom effect
  25407. */
  25408. bloom?: {
  25409. blurred: PostProcess;
  25410. weight: number;
  25411. };
  25412. }
  25413. /**
  25414. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25415. */
  25416. class DepthOfFieldMergePostProcess extends PostProcess {
  25417. private blurSteps;
  25418. /**
  25419. * Creates a new instance of DepthOfFieldMergePostProcess
  25420. * @param name The name of the effect.
  25421. * @param originalFromInput Post process which's input will be used for the merge.
  25422. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25423. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25424. * @param options The required width/height ratio to downsize to before computing the render pass.
  25425. * @param camera The camera to apply the render pass to.
  25426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25427. * @param engine The engine which the post process will be applied. (default: current engine)
  25428. * @param reusable If the post process can be reused on the same frame. (default: false)
  25429. * @param textureType Type of textures used when performing the post process. (default: 0)
  25430. * @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)
  25431. */
  25432. 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);
  25433. /**
  25434. * Updates the effect with the current post process compile time values and recompiles the shader.
  25435. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25436. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25437. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25438. * @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
  25439. * @param onCompiled Called when the shader has been compiled.
  25440. * @param onError Called if there is an error when compiling a shader.
  25441. */
  25442. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25443. }
  25444. }
  25445. declare module BABYLON {
  25446. class DisplayPassPostProcess extends PostProcess {
  25447. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25448. }
  25449. }
  25450. declare module BABYLON {
  25451. /**
  25452. * 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.
  25453. */
  25454. class ExtractHighlightsPostProcess extends PostProcess {
  25455. /**
  25456. * The luminance threshold, pixels below this value will be set to black.
  25457. */
  25458. threshold: number;
  25459. /**
  25460. * Internal
  25461. */
  25462. _exposure: number;
  25463. /**
  25464. * Post process which has the input texture to be used when performing highlight extraction
  25465. */
  25466. _inputPostProcess: Nullable<PostProcess>;
  25467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25468. }
  25469. }
  25470. declare module BABYLON {
  25471. class FilterPostProcess extends PostProcess {
  25472. kernelMatrix: Matrix;
  25473. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25474. }
  25475. }
  25476. declare module BABYLON {
  25477. class FxaaPostProcess extends PostProcess {
  25478. texelWidth: number;
  25479. texelHeight: number;
  25480. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25481. private _getDefines();
  25482. }
  25483. }
  25484. declare module BABYLON {
  25485. /**
  25486. * The GrainPostProcess adds noise to the image at mid luminance levels
  25487. */
  25488. class GrainPostProcess extends PostProcess {
  25489. /**
  25490. * The intensity of the grain added (default: 30)
  25491. */
  25492. intensity: number;
  25493. /**
  25494. * If the grain should be randomized on every frame
  25495. */
  25496. animated: boolean;
  25497. /**
  25498. * Creates a new instance of @see GrainPostProcess
  25499. * @param name The name of the effect.
  25500. * @param options The required width/height ratio to downsize to before computing the render pass.
  25501. * @param camera The camera to apply the render pass to.
  25502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25503. * @param engine The engine which the post process will be applied. (default: current engine)
  25504. * @param reusable If the post process can be reused on the same frame. (default: false)
  25505. * @param textureType Type of textures used when performing the post process. (default: 0)
  25506. * @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)
  25507. */
  25508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25509. }
  25510. }
  25511. declare module BABYLON {
  25512. class HighlightsPostProcess extends PostProcess {
  25513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25514. }
  25515. }
  25516. declare module BABYLON {
  25517. class ImageProcessingPostProcess extends PostProcess {
  25518. /**
  25519. * Default configuration related to image processing available in the PBR Material.
  25520. */
  25521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25522. /**
  25523. * Gets the image processing configuration used either in this material.
  25524. */
  25525. /**
  25526. * Sets the Default image processing configuration used either in the this material.
  25527. *
  25528. * If sets to null, the scene one is in use.
  25529. */
  25530. imageProcessingConfiguration: ImageProcessingConfiguration;
  25531. /**
  25532. * Keep track of the image processing observer to allow dispose and replace.
  25533. */
  25534. private _imageProcessingObserver;
  25535. /**
  25536. * Attaches a new image processing configuration to the PBR Material.
  25537. * @param configuration
  25538. */
  25539. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25540. /**
  25541. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25542. */
  25543. /**
  25544. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25545. */
  25546. colorCurves: Nullable<ColorCurves>;
  25547. /**
  25548. * Gets wether the color curves effect is enabled.
  25549. */
  25550. /**
  25551. * Sets wether the color curves effect is enabled.
  25552. */
  25553. colorCurvesEnabled: boolean;
  25554. /**
  25555. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25556. */
  25557. /**
  25558. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25559. */
  25560. colorGradingTexture: Nullable<BaseTexture>;
  25561. /**
  25562. * Gets wether the color grading effect is enabled.
  25563. */
  25564. /**
  25565. * Gets wether the color grading effect is enabled.
  25566. */
  25567. colorGradingEnabled: boolean;
  25568. /**
  25569. * Gets exposure used in the effect.
  25570. */
  25571. /**
  25572. * Sets exposure used in the effect.
  25573. */
  25574. exposure: number;
  25575. /**
  25576. * Gets wether tonemapping is enabled or not.
  25577. */
  25578. /**
  25579. * Sets wether tonemapping is enabled or not
  25580. */
  25581. toneMappingEnabled: boolean;
  25582. /**
  25583. * Gets contrast used in the effect.
  25584. */
  25585. /**
  25586. * Sets contrast used in the effect.
  25587. */
  25588. contrast: number;
  25589. /**
  25590. * Gets Vignette stretch size.
  25591. */
  25592. /**
  25593. * Sets Vignette stretch size.
  25594. */
  25595. vignetteStretch: number;
  25596. /**
  25597. * Gets Vignette centre X Offset.
  25598. */
  25599. /**
  25600. * Sets Vignette centre X Offset.
  25601. */
  25602. vignetteCentreX: number;
  25603. /**
  25604. * Gets Vignette centre Y Offset.
  25605. */
  25606. /**
  25607. * Sets Vignette centre Y Offset.
  25608. */
  25609. vignetteCentreY: number;
  25610. /**
  25611. * Gets Vignette weight or intensity of the vignette effect.
  25612. */
  25613. /**
  25614. * Sets Vignette weight or intensity of the vignette effect.
  25615. */
  25616. vignetteWeight: number;
  25617. /**
  25618. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25619. * if vignetteEnabled is set to true.
  25620. */
  25621. /**
  25622. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25623. * if vignetteEnabled is set to true.
  25624. */
  25625. vignetteColor: Color4;
  25626. /**
  25627. * Gets Camera field of view used by the Vignette effect.
  25628. */
  25629. /**
  25630. * Sets Camera field of view used by the Vignette effect.
  25631. */
  25632. vignetteCameraFov: number;
  25633. /**
  25634. * Gets the vignette blend mode allowing different kind of effect.
  25635. */
  25636. /**
  25637. * Sets the vignette blend mode allowing different kind of effect.
  25638. */
  25639. vignetteBlendMode: number;
  25640. /**
  25641. * Gets wether the vignette effect is enabled.
  25642. */
  25643. /**
  25644. * Sets wether the vignette effect is enabled.
  25645. */
  25646. vignetteEnabled: boolean;
  25647. private _fromLinearSpace;
  25648. /**
  25649. * Gets wether the input of the processing is in Gamma or Linear Space.
  25650. */
  25651. /**
  25652. * Sets wether the input of the processing is in Gamma or Linear Space.
  25653. */
  25654. fromLinearSpace: boolean;
  25655. /**
  25656. * Defines cache preventing GC.
  25657. */
  25658. private _defines;
  25659. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25660. getClassName(): string;
  25661. protected _updateParameters(): void;
  25662. dispose(camera?: Camera): void;
  25663. }
  25664. }
  25665. declare module BABYLON {
  25666. class PassPostProcess extends PostProcess {
  25667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25668. }
  25669. }
  25670. declare module BABYLON {
  25671. type PostProcessOptions = {
  25672. width: number;
  25673. height: number;
  25674. };
  25675. /**
  25676. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25677. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25678. */
  25679. class PostProcess {
  25680. /** Name of the PostProcess. */ name: string;
  25681. /**
  25682. * Width of the texture to apply the post process on
  25683. */
  25684. width: number;
  25685. /**
  25686. * Height of the texture to apply the post process on
  25687. */
  25688. height: number;
  25689. /**
  25690. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25691. */
  25692. _outputTexture: Nullable<InternalTexture>;
  25693. /**
  25694. * Sampling mode used by the shader
  25695. * See https://doc.babylonjs.com/classes/3.1/texture
  25696. */
  25697. renderTargetSamplingMode: number;
  25698. /**
  25699. * Clear color to use when screen clearing
  25700. */
  25701. clearColor: Color4;
  25702. /**
  25703. * If the buffer needs to be cleared before applying the post process. (default: true)
  25704. * Should be set to false if shader will overwrite all previous pixels.
  25705. */
  25706. autoClear: boolean;
  25707. /**
  25708. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25709. */
  25710. alphaMode: number;
  25711. /**
  25712. * Sets the setAlphaBlendConstants of the babylon engine
  25713. */
  25714. alphaConstants: Color4;
  25715. /**
  25716. * Animations to be used for the post processing
  25717. */
  25718. animations: Animation[];
  25719. /**
  25720. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  25721. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  25722. */
  25723. enablePixelPerfectMode: boolean;
  25724. /**
  25725. * Force the postprocess to be applied without taking in account viewport
  25726. */
  25727. forceFullscreenViewport: boolean;
  25728. /**
  25729. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  25730. */
  25731. scaleMode: number;
  25732. /**
  25733. * Force textures to be a power of two (default: false)
  25734. */
  25735. alwaysForcePOT: boolean;
  25736. /**
  25737. * Number of sample textures (default: 1)
  25738. */
  25739. samples: number;
  25740. /**
  25741. * Modify the scale of the post process to be the same as the viewport (default: false)
  25742. */
  25743. adaptScaleToCurrentViewport: boolean;
  25744. private _camera;
  25745. private _scene;
  25746. private _engine;
  25747. private _options;
  25748. private _reusable;
  25749. private _textureType;
  25750. /**
  25751. * Smart array of input and output textures for the post process.
  25752. */
  25753. _textures: SmartArray<InternalTexture>;
  25754. /**
  25755. * The index in _textures that corresponds to the output texture.
  25756. */
  25757. _currentRenderTextureInd: number;
  25758. private _effect;
  25759. private _samplers;
  25760. private _fragmentUrl;
  25761. private _vertexUrl;
  25762. private _parameters;
  25763. private _scaleRatio;
  25764. protected _indexParameters: any;
  25765. private _shareOutputWithPostProcess;
  25766. private _texelSize;
  25767. private _forcedOutputTexture;
  25768. /**
  25769. * An event triggered when the postprocess is activated.
  25770. */
  25771. onActivateObservable: Observable<Camera>;
  25772. private _onActivateObserver;
  25773. /**
  25774. * A function that is added to the onActivateObservable
  25775. */
  25776. onActivate: Nullable<(camera: Camera) => void>;
  25777. /**
  25778. * An event triggered when the postprocess changes its size.
  25779. */
  25780. onSizeChangedObservable: Observable<PostProcess>;
  25781. private _onSizeChangedObserver;
  25782. /**
  25783. * A function that is added to the onSizeChangedObservable
  25784. */
  25785. onSizeChanged: (postProcess: PostProcess) => void;
  25786. /**
  25787. * An event triggered when the postprocess applies its effect.
  25788. */
  25789. onApplyObservable: Observable<Effect>;
  25790. private _onApplyObserver;
  25791. /**
  25792. * A function that is added to the onApplyObservable
  25793. */
  25794. onApply: (effect: Effect) => void;
  25795. /**
  25796. * An event triggered before rendering the postprocess
  25797. */
  25798. onBeforeRenderObservable: Observable<Effect>;
  25799. private _onBeforeRenderObserver;
  25800. /**
  25801. * A function that is added to the onBeforeRenderObservable
  25802. */
  25803. onBeforeRender: (effect: Effect) => void;
  25804. /**
  25805. * An event triggered after rendering the postprocess
  25806. */
  25807. onAfterRenderObservable: Observable<Effect>;
  25808. private _onAfterRenderObserver;
  25809. /**
  25810. * A function that is added to the onAfterRenderObservable
  25811. */
  25812. onAfterRender: (efect: Effect) => void;
  25813. /**
  25814. * 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
  25815. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  25816. */
  25817. inputTexture: InternalTexture;
  25818. /**
  25819. * Gets the camera which post process is applied to.
  25820. * @returns The camera the post process is applied to.
  25821. */
  25822. getCamera(): Camera;
  25823. /**
  25824. * Gets the texel size of the postprocess.
  25825. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  25826. */
  25827. readonly texelSize: Vector2;
  25828. /**
  25829. * Creates a new instance PostProcess
  25830. * @param name The name of the PostProcess.
  25831. * @param fragmentUrl The url of the fragment shader to be used.
  25832. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  25833. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  25834. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25835. * @param camera The camera to apply the render pass to.
  25836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25837. * @param engine The engine which the post process will be applied. (default: current engine)
  25838. * @param reusable If the post process can be reused on the same frame. (default: false)
  25839. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  25840. * @param textureType Type of textures used when performing the post process. (default: 0)
  25841. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  25842. * @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
  25843. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  25844. */
  25845. 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);
  25846. /**
  25847. * Gets the engine which this post process belongs to.
  25848. * @returns The engine the post process was enabled with.
  25849. */
  25850. getEngine(): Engine;
  25851. /**
  25852. * The effect that is created when initializing the post process.
  25853. * @returns The created effect corrisponding the the postprocess.
  25854. */
  25855. getEffect(): Effect;
  25856. /**
  25857. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  25858. * @param postProcess The post process to share the output with.
  25859. * @returns This post process.
  25860. */
  25861. shareOutputWith(postProcess: PostProcess): PostProcess;
  25862. /**
  25863. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  25864. * This should be called if the post process that shares output with this post process is disabled/disposed.
  25865. */
  25866. useOwnOutput(): void;
  25867. /**
  25868. * Updates the effect with the current post process compile time values and recompiles the shader.
  25869. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25870. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25871. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25872. * @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
  25873. * @param onCompiled Called when the shader has been compiled.
  25874. * @param onError Called if there is an error when compiling a shader.
  25875. */
  25876. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25877. /**
  25878. * The post process is reusable if it can be used multiple times within one frame.
  25879. * @returns If the post process is reusable
  25880. */
  25881. isReusable(): boolean;
  25882. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  25883. markTextureDirty(): void;
  25884. /**
  25885. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  25886. * 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.
  25887. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  25888. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  25889. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  25890. * @returns The target texture that was bound to be written to.
  25891. */
  25892. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  25893. /**
  25894. * If the post process is supported.
  25895. */
  25896. readonly isSupported: boolean;
  25897. /**
  25898. * The aspect ratio of the output texture.
  25899. */
  25900. readonly aspectRatio: number;
  25901. /**
  25902. * Get a value indicating if the post-process is ready to be used
  25903. * @returns true if the post-process is ready (shader is compiled)
  25904. */
  25905. isReady(): boolean;
  25906. /**
  25907. * Binds all textures and uniforms to the shader, this will be run on every pass.
  25908. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  25909. */
  25910. apply(): Nullable<Effect>;
  25911. private _disposeTextures();
  25912. /**
  25913. * Disposes the post process.
  25914. * @param camera The camera to dispose the post process on.
  25915. */
  25916. dispose(camera?: Camera): void;
  25917. }
  25918. }
  25919. declare module BABYLON {
  25920. /**
  25921. * PostProcessManager is used to manage one or more post processes or post process pipelines
  25922. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25923. */
  25924. class PostProcessManager {
  25925. private _scene;
  25926. private _indexBuffer;
  25927. private _vertexBuffers;
  25928. /**
  25929. * Creates a new instance PostProcess
  25930. * @param scene The scene that the post process is associated with.
  25931. */
  25932. constructor(scene: Scene);
  25933. private _prepareBuffers();
  25934. private _buildIndexBuffer();
  25935. /**
  25936. * Rebuilds the vertex buffers of the manager.
  25937. */
  25938. _rebuild(): void;
  25939. /**
  25940. * Prepares a frame to be run through a post process.
  25941. * @param sourceTexture The input texture to the post procesess. (default: null)
  25942. * @param postProcesses An array of post processes to be run. (default: null)
  25943. * @returns True if the post processes were able to be run.
  25944. */
  25945. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  25946. /**
  25947. * Manually render a set of post processes to a texture.
  25948. * @param postProcesses An array of post processes to be run.
  25949. * @param targetTexture The target texture to render to.
  25950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  25951. */
  25952. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  25953. /**
  25954. * Finalize the result of the output of the postprocesses.
  25955. * @param doNotPresent If true the result will not be displayed to the screen.
  25956. * @param targetTexture The target texture to render to.
  25957. * @param faceIndex The index of the face to bind the target texture to.
  25958. * @param postProcesses The array of post processes to render.
  25959. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25960. */
  25961. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  25962. /**
  25963. * Disposes of the post process manager.
  25964. */
  25965. dispose(): void;
  25966. }
  25967. }
  25968. declare module BABYLON {
  25969. class RefractionPostProcess extends PostProcess {
  25970. color: Color3;
  25971. depth: number;
  25972. colorLevel: number;
  25973. private _refTexture;
  25974. private _ownRefractionTexture;
  25975. /**
  25976. * Gets or sets the refraction texture
  25977. * Please note that you are responsible for disposing the texture if you set it manually
  25978. */
  25979. refractionTexture: Texture;
  25980. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25981. dispose(camera: Camera): void;
  25982. }
  25983. }
  25984. declare module BABYLON {
  25985. /**
  25986. * The SharpenPostProcess applies a sharpen kernel to every pixel
  25987. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25988. */
  25989. class SharpenPostProcess extends PostProcess {
  25990. /**
  25991. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  25992. */
  25993. colorAmount: number;
  25994. /**
  25995. * How much sharpness should be applied (default: 0.3)
  25996. */
  25997. edgeAmount: number;
  25998. /**
  25999. * Creates a new instance ConvolutionPostProcess
  26000. * @param name The name of the effect.
  26001. * @param options The required width/height ratio to downsize to before computing the render pass.
  26002. * @param camera The camera to apply the render pass to.
  26003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26004. * @param engine The engine which the post process will be applied. (default: current engine)
  26005. * @param reusable If the post process can be reused on the same frame. (default: false)
  26006. * @param textureType Type of textures used when performing the post process. (default: 0)
  26007. * @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)
  26008. */
  26009. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26010. }
  26011. }
  26012. declare module BABYLON {
  26013. class StereoscopicInterlacePostProcess extends PostProcess {
  26014. private _stepSize;
  26015. private _passedProcess;
  26016. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26017. }
  26018. }
  26019. declare module BABYLON {
  26020. /** Defines operator used for tonemapping */
  26021. enum TonemappingOperator {
  26022. /** Hable */
  26023. Hable = 0,
  26024. /** Reinhard */
  26025. Reinhard = 1,
  26026. /** HejiDawson */
  26027. HejiDawson = 2,
  26028. /** Photographic */
  26029. Photographic = 3,
  26030. }
  26031. /**
  26032. * Defines a post process to apply tone mapping
  26033. */
  26034. class TonemapPostProcess extends PostProcess {
  26035. private _operator;
  26036. /** Defines the required exposure adjustement */
  26037. exposureAdjustment: number;
  26038. /**
  26039. * Creates a new TonemapPostProcess
  26040. * @param name defines the name of the postprocess
  26041. * @param _operator defines the operator to use
  26042. * @param exposureAdjustment defines the required exposure adjustement
  26043. * @param camera defines the camera to use (can be null)
  26044. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26045. * @param engine defines the hosting engine (can be ignore if camera is set)
  26046. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26047. */
  26048. constructor(name: string, _operator: TonemappingOperator,
  26049. /** Defines the required exposure adjustement */
  26050. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26051. }
  26052. }
  26053. declare module BABYLON {
  26054. class VolumetricLightScatteringPostProcess extends PostProcess {
  26055. private _volumetricLightScatteringPass;
  26056. private _volumetricLightScatteringRTT;
  26057. private _viewPort;
  26058. private _screenCoordinates;
  26059. private _cachedDefines;
  26060. /**
  26061. * If not undefined, the mesh position is computed from the attached node position
  26062. */
  26063. attachedNode: {
  26064. position: Vector3;
  26065. };
  26066. /**
  26067. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26068. */
  26069. customMeshPosition: Vector3;
  26070. /**
  26071. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26072. */
  26073. useCustomMeshPosition: boolean;
  26074. /**
  26075. * If the post-process should inverse the light scattering direction
  26076. */
  26077. invert: boolean;
  26078. /**
  26079. * The internal mesh used by the post-process
  26080. */
  26081. mesh: Mesh;
  26082. useDiffuseColor: boolean;
  26083. /**
  26084. * Array containing the excluded meshes not rendered in the internal pass
  26085. */
  26086. excludedMeshes: AbstractMesh[];
  26087. /**
  26088. * Controls the overall intensity of the post-process
  26089. */
  26090. exposure: number;
  26091. /**
  26092. * Dissipates each sample's contribution in range [0, 1]
  26093. */
  26094. decay: number;
  26095. /**
  26096. * Controls the overall intensity of each sample
  26097. */
  26098. weight: number;
  26099. /**
  26100. * Controls the density of each sample
  26101. */
  26102. density: number;
  26103. /**
  26104. * @constructor
  26105. * @param {string} name - The post-process name
  26106. * @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)
  26107. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26108. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26109. * @param {number} samples - The post-process quality, default 100
  26110. * @param {number} samplingMode - The post-process filtering mode
  26111. * @param {BABYLON.Engine} engine - The babylon engine
  26112. * @param {boolean} reusable - If the post-process is reusable
  26113. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26114. */
  26115. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26116. getClassName(): string;
  26117. private _isReady(subMesh, useInstances);
  26118. /**
  26119. * Sets the new light position for light scattering effect
  26120. * @param {BABYLON.Vector3} The new custom light position
  26121. */
  26122. setCustomMeshPosition(position: Vector3): void;
  26123. /**
  26124. * Returns the light position for light scattering effect
  26125. * @return {BABYLON.Vector3} The custom light position
  26126. */
  26127. getCustomMeshPosition(): Vector3;
  26128. /**
  26129. * Disposes the internal assets and detaches the post-process from the camera
  26130. */
  26131. dispose(camera: Camera): void;
  26132. /**
  26133. * Returns the render target texture used by the post-process
  26134. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26135. */
  26136. getPass(): RenderTargetTexture;
  26137. private _meshExcluded(mesh);
  26138. private _createPass(scene, ratio);
  26139. private _updateMeshScreenCoordinates(scene);
  26140. /**
  26141. * Creates a default mesh for the Volumeric Light Scattering post-process
  26142. * @param {string} The mesh name
  26143. * @param {BABYLON.Scene} The scene where to create the mesh
  26144. * @return {BABYLON.Mesh} the default mesh
  26145. */
  26146. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26147. }
  26148. }
  26149. declare module BABYLON {
  26150. class VRDistortionCorrectionPostProcess extends PostProcess {
  26151. private _isRightEye;
  26152. private _distortionFactors;
  26153. private _postProcessScaleFactor;
  26154. private _lensCenterOffset;
  26155. private _scaleIn;
  26156. private _scaleFactor;
  26157. private _lensCenter;
  26158. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26159. }
  26160. }
  26161. declare module BABYLON {
  26162. class ReflectionProbe {
  26163. name: string;
  26164. private _scene;
  26165. private _renderTargetTexture;
  26166. private _projectionMatrix;
  26167. private _viewMatrix;
  26168. private _target;
  26169. private _add;
  26170. private _attachedMesh;
  26171. private _invertYAxis;
  26172. position: Vector3;
  26173. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26174. samples: number;
  26175. refreshRate: number;
  26176. getScene(): Scene;
  26177. readonly cubeTexture: RenderTargetTexture;
  26178. readonly renderList: Nullable<AbstractMesh[]>;
  26179. attachToMesh(mesh: AbstractMesh): void;
  26180. /**
  26181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26182. *
  26183. * @param renderingGroupId The rendering group id corresponding to its index
  26184. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26185. */
  26186. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26187. dispose(): void;
  26188. }
  26189. }
  26190. declare module BABYLON {
  26191. class BoundingBoxRenderer {
  26192. frontColor: Color3;
  26193. backColor: Color3;
  26194. showBackLines: boolean;
  26195. renderList: SmartArray<BoundingBox>;
  26196. private _scene;
  26197. private _colorShader;
  26198. private _vertexBuffers;
  26199. private _indexBuffer;
  26200. constructor(scene: Scene);
  26201. private _prepareRessources();
  26202. private _createIndexBuffer();
  26203. _rebuild(): void;
  26204. reset(): void;
  26205. render(): void;
  26206. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26207. dispose(): void;
  26208. }
  26209. }
  26210. declare module BABYLON {
  26211. /**
  26212. * This represents a depth renderer in Babylon.
  26213. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26214. */
  26215. class DepthRenderer {
  26216. private _scene;
  26217. private _depthMap;
  26218. private _effect;
  26219. private _cachedDefines;
  26220. private _camera;
  26221. /**
  26222. * Instantiates a depth renderer
  26223. * @param scene The scene the renderer belongs to
  26224. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26225. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26226. */
  26227. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26228. /**
  26229. * Creates the depth rendering effect and checks if the effect is ready.
  26230. * @param subMesh The submesh to be used to render the depth map of
  26231. * @param useInstances If multiple world instances should be used
  26232. * @returns if the depth renderer is ready to render the depth map
  26233. */
  26234. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26235. /**
  26236. * Gets the texture which the depth map will be written to.
  26237. * @returns The depth map texture
  26238. */
  26239. getDepthMap(): RenderTargetTexture;
  26240. /**
  26241. * Disposes of the depth renderer.
  26242. */
  26243. dispose(): void;
  26244. }
  26245. }
  26246. declare module BABYLON {
  26247. class EdgesRenderer {
  26248. edgesWidthScalerForOrthographic: number;
  26249. edgesWidthScalerForPerspective: number;
  26250. private _source;
  26251. private _linesPositions;
  26252. private _linesNormals;
  26253. private _linesIndices;
  26254. private _epsilon;
  26255. private _indicesCount;
  26256. private _lineShader;
  26257. private _ib;
  26258. private _buffers;
  26259. private _checkVerticesInsteadOfIndices;
  26260. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26261. private _prepareRessources();
  26262. _rebuild(): void;
  26263. dispose(): void;
  26264. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26265. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26266. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26267. _generateEdgesLines(): void;
  26268. render(): void;
  26269. }
  26270. }
  26271. declare module BABYLON {
  26272. /**
  26273. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26274. */
  26275. class GeometryBufferRenderer {
  26276. private _scene;
  26277. private _multiRenderTarget;
  26278. private _ratio;
  26279. private _enablePosition;
  26280. protected _effect: Effect;
  26281. protected _cachedDefines: string;
  26282. /**
  26283. * Set the render list (meshes to be rendered) used in the G buffer.
  26284. */
  26285. renderList: Mesh[];
  26286. /**
  26287. * Gets wether or not G buffer are supported by the running hardware.
  26288. * This requires draw buffer supports
  26289. */
  26290. readonly isSupported: boolean;
  26291. /**
  26292. * Gets wether or not position are enabled for the G buffer.
  26293. */
  26294. /**
  26295. * Sets wether or not position are enabled for the G buffer.
  26296. */
  26297. enablePosition: boolean;
  26298. /**
  26299. * Gets the scene associated with the buffer.
  26300. */
  26301. readonly scene: Scene;
  26302. /**
  26303. * Gets the ratio used by the buffer during its creation.
  26304. * How big is the buffer related to the main canvas.
  26305. */
  26306. readonly ratio: number;
  26307. /**
  26308. * Creates a new G Buffer for the scene
  26309. * @param scene The scene the buffer belongs to
  26310. * @param ratio How big is the buffer related to the main canvas.
  26311. */
  26312. constructor(scene: Scene, ratio?: number);
  26313. /**
  26314. * Checks wether everything is ready to render a submesh to the G buffer.
  26315. * @param subMesh the submesh to check readiness for
  26316. * @param useInstances is the mesh drawn using instance or not
  26317. * @returns true if ready otherwise false
  26318. */
  26319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26320. /**
  26321. * Gets the current underlying G Buffer.
  26322. * @returns the buffer
  26323. */
  26324. getGBuffer(): MultiRenderTarget;
  26325. /**
  26326. * Gets the number of samples used to render the buffer (anti aliasing).
  26327. */
  26328. /**
  26329. * Sets the number of samples used to render the buffer (anti aliasing).
  26330. */
  26331. samples: number;
  26332. /**
  26333. * Disposes the renderer and frees up associated resources.
  26334. */
  26335. dispose(): void;
  26336. protected _createRenderTargets(): void;
  26337. }
  26338. }
  26339. declare module BABYLON {
  26340. class OutlineRenderer {
  26341. private _scene;
  26342. private _effect;
  26343. private _cachedDefines;
  26344. zOffset: number;
  26345. constructor(scene: Scene);
  26346. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26347. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26348. }
  26349. }
  26350. declare module BABYLON {
  26351. class RenderingGroup {
  26352. index: number;
  26353. private _scene;
  26354. private _opaqueSubMeshes;
  26355. private _transparentSubMeshes;
  26356. private _alphaTestSubMeshes;
  26357. private _depthOnlySubMeshes;
  26358. private _particleSystems;
  26359. private _spriteManagers;
  26360. private _opaqueSortCompareFn;
  26361. private _alphaTestSortCompareFn;
  26362. private _transparentSortCompareFn;
  26363. private _renderOpaque;
  26364. private _renderAlphaTest;
  26365. private _renderTransparent;
  26366. private _edgesRenderers;
  26367. onBeforeTransparentRendering: () => void;
  26368. /**
  26369. * Set the opaque sort comparison function.
  26370. * If null the sub meshes will be render in the order they were created
  26371. */
  26372. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26373. /**
  26374. * Set the alpha test sort comparison function.
  26375. * If null the sub meshes will be render in the order they were created
  26376. */
  26377. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26378. /**
  26379. * Set the transparent sort comparison function.
  26380. * If null the sub meshes will be render in the order they were created
  26381. */
  26382. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26383. /**
  26384. * Creates a new rendering group.
  26385. * @param index The rendering group index
  26386. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26387. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26388. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26389. */
  26390. 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>);
  26391. /**
  26392. * Render all the sub meshes contained in the group.
  26393. * @param customRenderFunction Used to override the default render behaviour of the group.
  26394. * @returns true if rendered some submeshes.
  26395. */
  26396. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26397. /**
  26398. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26399. * @param subMeshes The submeshes to render
  26400. */
  26401. private renderOpaqueSorted(subMeshes);
  26402. /**
  26403. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26404. * @param subMeshes The submeshes to render
  26405. */
  26406. private renderAlphaTestSorted(subMeshes);
  26407. /**
  26408. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26409. * @param subMeshes The submeshes to render
  26410. */
  26411. private renderTransparentSorted(subMeshes);
  26412. /**
  26413. * Renders the submeshes in a specified order.
  26414. * @param subMeshes The submeshes to sort before render
  26415. * @param sortCompareFn The comparison function use to sort
  26416. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26417. * @param transparent Specifies to activate blending if true
  26418. */
  26419. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26420. /**
  26421. * Renders the submeshes in the order they were dispatched (no sort applied).
  26422. * @param subMeshes The submeshes to render
  26423. */
  26424. private static renderUnsorted(subMeshes);
  26425. /**
  26426. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26427. * are rendered back to front if in the same alpha index.
  26428. *
  26429. * @param a The first submesh
  26430. * @param b The second submesh
  26431. * @returns The result of the comparison
  26432. */
  26433. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26434. /**
  26435. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26436. * are rendered back to front.
  26437. *
  26438. * @param a The first submesh
  26439. * @param b The second submesh
  26440. * @returns The result of the comparison
  26441. */
  26442. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26443. /**
  26444. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26445. * are rendered front to back (prevent overdraw).
  26446. *
  26447. * @param a The first submesh
  26448. * @param b The second submesh
  26449. * @returns The result of the comparison
  26450. */
  26451. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26452. /**
  26453. * Resets the different lists of submeshes to prepare a new frame.
  26454. */
  26455. prepare(): void;
  26456. dispose(): void;
  26457. /**
  26458. * Inserts the submesh in its correct queue depending on its material.
  26459. * @param subMesh The submesh to dispatch
  26460. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26461. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26462. */
  26463. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26464. dispatchSprites(spriteManager: SpriteManager): void;
  26465. dispatchParticles(particleSystem: IParticleSystem): void;
  26466. private _renderParticles(activeMeshes);
  26467. private _renderSprites();
  26468. }
  26469. }
  26470. declare module BABYLON {
  26471. class RenderingManager {
  26472. /**
  26473. * The max id used for rendering groups (not included)
  26474. */
  26475. static MAX_RENDERINGGROUPS: number;
  26476. /**
  26477. * The min id used for rendering groups (included)
  26478. */
  26479. static MIN_RENDERINGGROUPS: number;
  26480. /**
  26481. * Used to globally prevent autoclearing scenes.
  26482. */
  26483. static AUTOCLEAR: boolean;
  26484. private _scene;
  26485. private _renderingGroups;
  26486. private _depthStencilBufferAlreadyCleaned;
  26487. private _autoClearDepthStencil;
  26488. private _customOpaqueSortCompareFn;
  26489. private _customAlphaTestSortCompareFn;
  26490. private _customTransparentSortCompareFn;
  26491. private _renderinGroupInfo;
  26492. constructor(scene: Scene);
  26493. private _clearDepthStencilBuffer(depth?, stencil?);
  26494. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26495. reset(): void;
  26496. dispose(): void;
  26497. /**
  26498. * Clear the info related to rendering groups preventing retention points during dispose.
  26499. */
  26500. freeRenderingGroups(): void;
  26501. private _prepareRenderingGroup(renderingGroupId);
  26502. dispatchSprites(spriteManager: SpriteManager): void;
  26503. dispatchParticles(particleSystem: IParticleSystem): void;
  26504. /**
  26505. * @param subMesh The submesh to dispatch
  26506. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26507. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26508. */
  26509. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26510. /**
  26511. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26512. * This allowed control for front to back rendering or reversly depending of the special needs.
  26513. *
  26514. * @param renderingGroupId The rendering group id corresponding to its index
  26515. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26516. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26517. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26518. */
  26519. 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;
  26520. /**
  26521. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26522. *
  26523. * @param renderingGroupId The rendering group id corresponding to its index
  26524. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26525. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26526. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26527. */
  26528. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26529. }
  26530. }
  26531. declare module BABYLON {
  26532. class Sprite {
  26533. name: string;
  26534. position: Vector3;
  26535. color: Color4;
  26536. width: number;
  26537. height: number;
  26538. angle: number;
  26539. cellIndex: number;
  26540. invertU: number;
  26541. invertV: number;
  26542. disposeWhenFinishedAnimating: boolean;
  26543. animations: Animation[];
  26544. isPickable: boolean;
  26545. actionManager: ActionManager;
  26546. private _animationStarted;
  26547. private _loopAnimation;
  26548. private _fromIndex;
  26549. private _toIndex;
  26550. private _delay;
  26551. private _direction;
  26552. private _manager;
  26553. private _time;
  26554. private _onAnimationEnd;
  26555. size: number;
  26556. constructor(name: string, manager: SpriteManager);
  26557. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26558. stopAnimation(): void;
  26559. _animate(deltaTime: number): void;
  26560. dispose(): void;
  26561. }
  26562. }
  26563. declare module BABYLON {
  26564. class SpriteManager {
  26565. name: string;
  26566. sprites: Sprite[];
  26567. renderingGroupId: number;
  26568. layerMask: number;
  26569. fogEnabled: boolean;
  26570. isPickable: boolean;
  26571. cellWidth: number;
  26572. cellHeight: number;
  26573. /**
  26574. * An event triggered when the manager is disposed.
  26575. */
  26576. onDisposeObservable: Observable<SpriteManager>;
  26577. private _onDisposeObserver;
  26578. onDispose: () => void;
  26579. private _capacity;
  26580. private _spriteTexture;
  26581. private _epsilon;
  26582. private _scene;
  26583. private _vertexData;
  26584. private _buffer;
  26585. private _vertexBuffers;
  26586. private _indexBuffer;
  26587. private _effectBase;
  26588. private _effectFog;
  26589. texture: Texture;
  26590. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26591. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26592. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26593. render(): void;
  26594. dispose(): void;
  26595. }
  26596. }
  26597. declare module BABYLON {
  26598. /**
  26599. * @hidden
  26600. **/
  26601. class _AlphaState {
  26602. private _isAlphaBlendDirty;
  26603. private _isBlendFunctionParametersDirty;
  26604. private _isBlendEquationParametersDirty;
  26605. private _isBlendConstantsDirty;
  26606. private _alphaBlend;
  26607. private _blendFunctionParameters;
  26608. private _blendEquationParameters;
  26609. private _blendConstants;
  26610. /**
  26611. * Initializes the state.
  26612. */
  26613. constructor();
  26614. readonly isDirty: boolean;
  26615. alphaBlend: boolean;
  26616. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26617. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26618. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26619. reset(): void;
  26620. apply(gl: WebGLRenderingContext): void;
  26621. }
  26622. }
  26623. declare module BABYLON {
  26624. /**
  26625. * @hidden
  26626. **/
  26627. class _DepthCullingState {
  26628. private _isDepthTestDirty;
  26629. private _isDepthMaskDirty;
  26630. private _isDepthFuncDirty;
  26631. private _isCullFaceDirty;
  26632. private _isCullDirty;
  26633. private _isZOffsetDirty;
  26634. private _isFrontFaceDirty;
  26635. private _depthTest;
  26636. private _depthMask;
  26637. private _depthFunc;
  26638. private _cull;
  26639. private _cullFace;
  26640. private _zOffset;
  26641. private _frontFace;
  26642. /**
  26643. * Initializes the state.
  26644. */
  26645. constructor();
  26646. readonly isDirty: boolean;
  26647. zOffset: number;
  26648. cullFace: Nullable<number>;
  26649. cull: Nullable<boolean>;
  26650. depthFunc: Nullable<number>;
  26651. depthMask: boolean;
  26652. depthTest: boolean;
  26653. frontFace: Nullable<number>;
  26654. reset(): void;
  26655. apply(gl: WebGLRenderingContext): void;
  26656. }
  26657. }
  26658. declare module BABYLON {
  26659. /**
  26660. * @hidden
  26661. **/
  26662. class _StencilState {
  26663. private _isStencilTestDirty;
  26664. private _isStencilMaskDirty;
  26665. private _isStencilFuncDirty;
  26666. private _isStencilOpDirty;
  26667. private _stencilTest;
  26668. private _stencilMask;
  26669. private _stencilFunc;
  26670. private _stencilFuncRef;
  26671. private _stencilFuncMask;
  26672. private _stencilOpStencilFail;
  26673. private _stencilOpDepthFail;
  26674. private _stencilOpStencilDepthPass;
  26675. readonly isDirty: boolean;
  26676. stencilFunc: number;
  26677. stencilFuncRef: number;
  26678. stencilFuncMask: number;
  26679. stencilOpStencilFail: number;
  26680. stencilOpDepthFail: number;
  26681. stencilOpStencilDepthPass: number;
  26682. stencilMask: number;
  26683. stencilTest: boolean;
  26684. constructor();
  26685. reset(): void;
  26686. apply(gl: WebGLRenderingContext): void;
  26687. }
  26688. }
  26689. declare module BABYLON {
  26690. /**
  26691. * Class used to evalaute queries containing `and` and `or` operators
  26692. */
  26693. class AndOrNotEvaluator {
  26694. /**
  26695. * Evaluate a query
  26696. * @param query defines the query to evaluate
  26697. * @param evaluateCallback defines the callback used to filter result
  26698. * @returns true if the query matches
  26699. */
  26700. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26701. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26702. private static _SimplifyNegation(booleanString);
  26703. }
  26704. }
  26705. declare module BABYLON {
  26706. /**
  26707. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26708. */
  26709. enum AssetTaskState {
  26710. /**
  26711. * Initialization
  26712. */
  26713. INIT = 0,
  26714. /**
  26715. * Running
  26716. */
  26717. RUNNING = 1,
  26718. /**
  26719. * Done
  26720. */
  26721. DONE = 2,
  26722. /**
  26723. * Error
  26724. */
  26725. ERROR = 3,
  26726. }
  26727. /**
  26728. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26729. */
  26730. abstract class AbstractAssetTask {
  26731. /**
  26732. * Task name
  26733. */ name: string;
  26734. /**
  26735. * Callback called when the task is successful
  26736. */
  26737. onSuccess: (task: any) => void;
  26738. /**
  26739. * Callback called when the task is not successful
  26740. */
  26741. onError: (task: any, message?: string, exception?: any) => void;
  26742. /**
  26743. * Creates a new {BABYLON.AssetsManager}
  26744. * @param name defines the name of the task
  26745. */
  26746. constructor(
  26747. /**
  26748. * Task name
  26749. */ name: string);
  26750. private _isCompleted;
  26751. private _taskState;
  26752. private _errorObject;
  26753. /**
  26754. * Get if the task is completed
  26755. */
  26756. readonly isCompleted: boolean;
  26757. /**
  26758. * Gets the current state of the task
  26759. */
  26760. readonly taskState: AssetTaskState;
  26761. /**
  26762. * Gets the current error object (if task is in error)
  26763. */
  26764. readonly errorObject: {
  26765. message?: string;
  26766. exception?: any;
  26767. };
  26768. /**
  26769. * Internal only
  26770. * @hidden
  26771. */
  26772. _setErrorObject(message?: string, exception?: any): void;
  26773. /**
  26774. * Execute the current task
  26775. * @param scene defines the scene where you want your assets to be loaded
  26776. * @param onSuccess is a callback called when the task is successfully executed
  26777. * @param onError is a callback called if an error occurs
  26778. */
  26779. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26780. /**
  26781. * Execute the current task
  26782. * @param scene defines the scene where you want your assets to be loaded
  26783. * @param onSuccess is a callback called when the task is successfully executed
  26784. * @param onError is a callback called if an error occurs
  26785. */
  26786. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26787. private onErrorCallback(onError, message?, exception?);
  26788. private onDoneCallback(onSuccess, onError);
  26789. }
  26790. /**
  26791. * Define the interface used by progress events raised during assets loading
  26792. */
  26793. interface IAssetsProgressEvent {
  26794. /**
  26795. * Defines the number of remaining tasks to process
  26796. */
  26797. remainingCount: number;
  26798. /**
  26799. * Defines the total number of tasks
  26800. */
  26801. totalCount: number;
  26802. /**
  26803. * Defines the task that was just processed
  26804. */
  26805. task: AbstractAssetTask;
  26806. }
  26807. /**
  26808. * Class used to share progress information about assets loading
  26809. */
  26810. class AssetsProgressEvent implements IAssetsProgressEvent {
  26811. /**
  26812. * Defines the number of remaining tasks to process
  26813. */
  26814. remainingCount: number;
  26815. /**
  26816. * Defines the total number of tasks
  26817. */
  26818. totalCount: number;
  26819. /**
  26820. * Defines the task that was just processed
  26821. */
  26822. task: AbstractAssetTask;
  26823. /**
  26824. * Creates a {BABYLON.AssetsProgressEvent}
  26825. * @param remainingCount defines the number of remaining tasks to process
  26826. * @param totalCount defines the total number of tasks
  26827. * @param task defines the task that was just processed
  26828. */
  26829. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26830. }
  26831. /**
  26832. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26833. */
  26834. class MeshAssetTask extends AbstractAssetTask {
  26835. /**
  26836. * Defines the name of the task
  26837. */
  26838. name: string;
  26839. /**
  26840. * Defines the list of mesh's names you want to load
  26841. */
  26842. meshesNames: any;
  26843. /**
  26844. * Defines the root url to use as a base to load your meshes and associated resources
  26845. */
  26846. rootUrl: string;
  26847. /**
  26848. * Defines the filename of the scene to load from
  26849. */
  26850. sceneFilename: string;
  26851. /**
  26852. * Gets the list of loaded meshes
  26853. */
  26854. loadedMeshes: Array<AbstractMesh>;
  26855. /**
  26856. * Gets the list of loaded particle systems
  26857. */
  26858. loadedParticleSystems: Array<ParticleSystem>;
  26859. /**
  26860. * Gets the list of loaded skeletons
  26861. */
  26862. loadedSkeletons: Array<Skeleton>;
  26863. /**
  26864. * Callback called when the task is successful
  26865. */
  26866. onSuccess: (task: MeshAssetTask) => void;
  26867. /**
  26868. * Callback called when the task is successful
  26869. */
  26870. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26871. /**
  26872. * Creates a new {BABYLON.MeshAssetTask}
  26873. * @param name defines the name of the task
  26874. * @param meshesNames defines the list of mesh's names you want to load
  26875. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26876. * @param sceneFilename defines the filename of the scene to load from
  26877. */
  26878. constructor(
  26879. /**
  26880. * Defines the name of the task
  26881. */
  26882. name: string,
  26883. /**
  26884. * Defines the list of mesh's names you want to load
  26885. */
  26886. meshesNames: any,
  26887. /**
  26888. * Defines the root url to use as a base to load your meshes and associated resources
  26889. */
  26890. rootUrl: string,
  26891. /**
  26892. * Defines the filename of the scene to load from
  26893. */
  26894. sceneFilename: string);
  26895. /**
  26896. * Execute the current task
  26897. * @param scene defines the scene where you want your assets to be loaded
  26898. * @param onSuccess is a callback called when the task is successfully executed
  26899. * @param onError is a callback called if an error occurs
  26900. */
  26901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26902. }
  26903. /**
  26904. * Define a task used by {BABYLON.AssetsManager} to load text content
  26905. */
  26906. class TextFileAssetTask extends AbstractAssetTask {
  26907. /**
  26908. * Defines the name of the task
  26909. */
  26910. name: string;
  26911. /**
  26912. * Defines the location of the file to load
  26913. */
  26914. url: string;
  26915. /**
  26916. * Gets the loaded text string
  26917. */
  26918. text: string;
  26919. /**
  26920. * Callback called when the task is successful
  26921. */
  26922. onSuccess: (task: TextFileAssetTask) => void;
  26923. /**
  26924. * Callback called when the task is successful
  26925. */
  26926. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26927. /**
  26928. * Creates a new TextFileAssetTask object
  26929. * @param name defines the name of the task
  26930. * @param url defines the location of the file to load
  26931. */
  26932. constructor(
  26933. /**
  26934. * Defines the name of the task
  26935. */
  26936. name: string,
  26937. /**
  26938. * Defines the location of the file to load
  26939. */
  26940. url: string);
  26941. /**
  26942. * Execute the current task
  26943. * @param scene defines the scene where you want your assets to be loaded
  26944. * @param onSuccess is a callback called when the task is successfully executed
  26945. * @param onError is a callback called if an error occurs
  26946. */
  26947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26948. }
  26949. /**
  26950. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26951. */
  26952. class BinaryFileAssetTask extends AbstractAssetTask {
  26953. /**
  26954. * Defines the name of the task
  26955. */
  26956. name: string;
  26957. /**
  26958. * Defines the location of the file to load
  26959. */
  26960. url: string;
  26961. /**
  26962. * Gets the lodaded data (as an array buffer)
  26963. */
  26964. data: ArrayBuffer;
  26965. /**
  26966. * Callback called when the task is successful
  26967. */
  26968. onSuccess: (task: BinaryFileAssetTask) => void;
  26969. /**
  26970. * Callback called when the task is successful
  26971. */
  26972. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26973. /**
  26974. * Creates a new BinaryFileAssetTask object
  26975. * @param name defines the name of the new task
  26976. * @param url defines the location of the file to load
  26977. */
  26978. constructor(
  26979. /**
  26980. * Defines the name of the task
  26981. */
  26982. name: string,
  26983. /**
  26984. * Defines the location of the file to load
  26985. */
  26986. url: string);
  26987. /**
  26988. * Execute the current task
  26989. * @param scene defines the scene where you want your assets to be loaded
  26990. * @param onSuccess is a callback called when the task is successfully executed
  26991. * @param onError is a callback called if an error occurs
  26992. */
  26993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26994. }
  26995. /**
  26996. * Define a task used by {BABYLON.AssetsManager} to load images
  26997. */
  26998. class ImageAssetTask extends AbstractAssetTask {
  26999. /**
  27000. * Defines the name of the task
  27001. */
  27002. name: string;
  27003. /**
  27004. * Defines the location of the image to load
  27005. */
  27006. url: string;
  27007. /**
  27008. * Gets the loaded images
  27009. */
  27010. image: HTMLImageElement;
  27011. /**
  27012. * Callback called when the task is successful
  27013. */
  27014. onSuccess: (task: ImageAssetTask) => void;
  27015. /**
  27016. * Callback called when the task is successful
  27017. */
  27018. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27019. /**
  27020. * Creates a new ImageAssetTask
  27021. * @param name defines the name of the task
  27022. * @param url defines the location of the image to load
  27023. */
  27024. constructor(
  27025. /**
  27026. * Defines the name of the task
  27027. */
  27028. name: string,
  27029. /**
  27030. * Defines the location of the image to load
  27031. */
  27032. url: string);
  27033. /**
  27034. * Execute the current task
  27035. * @param scene defines the scene where you want your assets to be loaded
  27036. * @param onSuccess is a callback called when the task is successfully executed
  27037. * @param onError is a callback called if an error occurs
  27038. */
  27039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27040. }
  27041. /**
  27042. * Defines the interface used by texture loading tasks
  27043. */
  27044. interface ITextureAssetTask<TEX extends BaseTexture> {
  27045. /**
  27046. * Gets the loaded texture
  27047. */
  27048. texture: TEX;
  27049. }
  27050. /**
  27051. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27052. */
  27053. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27054. /**
  27055. * Defines the name of the task
  27056. */
  27057. name: string;
  27058. /**
  27059. * Defines the location of the file to load
  27060. */
  27061. url: string;
  27062. /**
  27063. * Defines if mipmap should not be generated (default is false)
  27064. */
  27065. noMipmap: boolean | undefined;
  27066. /**
  27067. * Defines if texture must be inverted on Y axis (default is false)
  27068. */
  27069. invertY: boolean | undefined;
  27070. /**
  27071. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27072. */
  27073. samplingMode: number;
  27074. /**
  27075. * Gets the loaded texture
  27076. */
  27077. texture: Texture;
  27078. /**
  27079. * Callback called when the task is successful
  27080. */
  27081. onSuccess: (task: TextureAssetTask) => void;
  27082. /**
  27083. * Callback called when the task is successful
  27084. */
  27085. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27086. /**
  27087. * Creates a new TextureAssetTask object
  27088. * @param name defines the name of the task
  27089. * @param url defines the location of the file to load
  27090. * @param noMipmap defines if mipmap should not be generated (default is false)
  27091. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27092. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27093. */
  27094. constructor(
  27095. /**
  27096. * Defines the name of the task
  27097. */
  27098. name: string,
  27099. /**
  27100. * Defines the location of the file to load
  27101. */
  27102. url: string,
  27103. /**
  27104. * Defines if mipmap should not be generated (default is false)
  27105. */
  27106. noMipmap?: boolean | undefined,
  27107. /**
  27108. * Defines if texture must be inverted on Y axis (default is false)
  27109. */
  27110. invertY?: boolean | undefined,
  27111. /**
  27112. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27113. */
  27114. samplingMode?: number);
  27115. /**
  27116. * Execute the current task
  27117. * @param scene defines the scene where you want your assets to be loaded
  27118. * @param onSuccess is a callback called when the task is successfully executed
  27119. * @param onError is a callback called if an error occurs
  27120. */
  27121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27122. }
  27123. /**
  27124. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27125. */
  27126. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27127. /**
  27128. * Defines the name of the task
  27129. */
  27130. name: string;
  27131. /**
  27132. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27133. */
  27134. url: string;
  27135. /**
  27136. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27137. */
  27138. extensions: string[] | undefined;
  27139. /**
  27140. * Defines if mipmaps should not be generated (default is false)
  27141. */
  27142. noMipmap: boolean | undefined;
  27143. /**
  27144. * Defines the explicit list of files (undefined by default)
  27145. */
  27146. files: string[] | undefined;
  27147. /**
  27148. * Gets the loaded texture
  27149. */
  27150. texture: CubeTexture;
  27151. /**
  27152. * Callback called when the task is successful
  27153. */
  27154. onSuccess: (task: CubeTextureAssetTask) => void;
  27155. /**
  27156. * Callback called when the task is successful
  27157. */
  27158. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27159. /**
  27160. * Creates a new CubeTextureAssetTask
  27161. * @param name defines the name of the task
  27162. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27163. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27164. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27165. * @param files defines the explicit list of files (undefined by default)
  27166. */
  27167. constructor(
  27168. /**
  27169. * Defines the name of the task
  27170. */
  27171. name: string,
  27172. /**
  27173. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27174. */
  27175. url: string,
  27176. /**
  27177. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27178. */
  27179. extensions?: string[] | undefined,
  27180. /**
  27181. * Defines if mipmaps should not be generated (default is false)
  27182. */
  27183. noMipmap?: boolean | undefined,
  27184. /**
  27185. * Defines the explicit list of files (undefined by default)
  27186. */
  27187. files?: string[] | undefined);
  27188. /**
  27189. * Execute the current task
  27190. * @param scene defines the scene where you want your assets to be loaded
  27191. * @param onSuccess is a callback called when the task is successfully executed
  27192. * @param onError is a callback called if an error occurs
  27193. */
  27194. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27195. }
  27196. /**
  27197. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27198. */
  27199. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27200. /**
  27201. * Defines the name of the task
  27202. */
  27203. name: string;
  27204. /**
  27205. * Defines the location of the file to load
  27206. */
  27207. url: string;
  27208. /**
  27209. * Defines the desired size (the more it increases the longer the generation will be)
  27210. */
  27211. size: number;
  27212. /**
  27213. * Defines if mipmaps should not be generated (default is false)
  27214. */
  27215. noMipmap: boolean;
  27216. /**
  27217. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27218. */
  27219. generateHarmonics: boolean;
  27220. /**
  27221. * 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)
  27222. */
  27223. gammaSpace: boolean;
  27224. /**
  27225. * Internal Use Only
  27226. */
  27227. reserved: boolean;
  27228. /**
  27229. * Gets the loaded texture
  27230. */
  27231. texture: HDRCubeTexture;
  27232. /**
  27233. * Callback called when the task is successful
  27234. */
  27235. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27236. /**
  27237. * Callback called when the task is successful
  27238. */
  27239. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27240. /**
  27241. * Creates a new HDRCubeTextureAssetTask object
  27242. * @param name defines the name of the task
  27243. * @param url defines the location of the file to load
  27244. * @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.
  27245. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27246. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27247. * @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)
  27248. * @param reserved Internal use only
  27249. */
  27250. constructor(
  27251. /**
  27252. * Defines the name of the task
  27253. */
  27254. name: string,
  27255. /**
  27256. * Defines the location of the file to load
  27257. */
  27258. url: string,
  27259. /**
  27260. * Defines the desired size (the more it increases the longer the generation will be)
  27261. */
  27262. size: number,
  27263. /**
  27264. * Defines if mipmaps should not be generated (default is false)
  27265. */
  27266. noMipmap?: boolean,
  27267. /**
  27268. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27269. */
  27270. generateHarmonics?: boolean,
  27271. /**
  27272. * 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)
  27273. */
  27274. gammaSpace?: boolean,
  27275. /**
  27276. * Internal Use Only
  27277. */
  27278. reserved?: boolean);
  27279. /**
  27280. * Execute the current task
  27281. * @param scene defines the scene where you want your assets to be loaded
  27282. * @param onSuccess is a callback called when the task is successfully executed
  27283. * @param onError is a callback called if an error occurs
  27284. */
  27285. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27286. }
  27287. /**
  27288. * This class can be used to easily import assets into a scene
  27289. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27290. */
  27291. class AssetsManager {
  27292. private _scene;
  27293. private _isLoading;
  27294. protected _tasks: AbstractAssetTask[];
  27295. protected _waitingTasksCount: number;
  27296. protected _totalTasksCount: number;
  27297. /**
  27298. * Callback called when all tasks are processed
  27299. */
  27300. onFinish: (tasks: AbstractAssetTask[]) => void;
  27301. /**
  27302. * Callback called when a task is successful
  27303. */
  27304. onTaskSuccess: (task: AbstractAssetTask) => void;
  27305. /**
  27306. * Callback called when a task had an error
  27307. */
  27308. onTaskError: (task: AbstractAssetTask) => void;
  27309. /**
  27310. * Callback called when a task is done (whatever the result is)
  27311. */
  27312. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27313. /**
  27314. * Observable called when all tasks are processed
  27315. */
  27316. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27317. /**
  27318. * Observable called when a task had an error
  27319. */
  27320. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27321. /**
  27322. * Observable called when a task is successful
  27323. */
  27324. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27325. /**
  27326. * Observable called when a task is done (whatever the result is)
  27327. */
  27328. onProgressObservable: Observable<IAssetsProgressEvent>;
  27329. /**
  27330. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27331. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27332. */
  27333. useDefaultLoadingScreen: boolean;
  27334. /**
  27335. * Creates a new AssetsManager
  27336. * @param scene defines the scene to work on
  27337. */
  27338. constructor(scene: Scene);
  27339. /**
  27340. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27341. * @param taskName defines the name of the new task
  27342. * @param meshesNames defines the name of meshes to load
  27343. * @param rootUrl defines the root url to use to locate files
  27344. * @param sceneFilename defines the filename of the scene file
  27345. * @returns a new {BABYLON.MeshAssetTask} object
  27346. */
  27347. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27348. /**
  27349. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27350. * @param taskName defines the name of the new task
  27351. * @param url defines the url of the file to load
  27352. * @returns a new {BABYLON.TextFileAssetTask} object
  27353. */
  27354. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27355. /**
  27356. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27357. * @param taskName defines the name of the new task
  27358. * @param url defines the url of the file to load
  27359. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27360. */
  27361. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27362. /**
  27363. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27364. * @param taskName defines the name of the new task
  27365. * @param url defines the url of the file to load
  27366. * @returns a new {BABYLON.ImageAssetTask} object
  27367. */
  27368. addImageTask(taskName: string, url: string): ImageAssetTask;
  27369. /**
  27370. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27371. * @param taskName defines the name of the new task
  27372. * @param url defines the url of the file to load
  27373. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27374. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27375. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27376. * @returns a new {BABYLON.TextureAssetTask} object
  27377. */
  27378. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27379. /**
  27380. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27381. * @param taskName defines the name of the new task
  27382. * @param url defines the url of the file to load
  27383. * @param extensions defines the extension to use to load the cube map (can be null)
  27384. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27385. * @param files defines the list of files to load (can be null)
  27386. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27387. */
  27388. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27389. /**
  27390. *
  27391. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27392. * @param taskName defines the name of the new task
  27393. * @param url defines the url of the file to load
  27394. * @param size defines the size you want for the cubemap (can be null)
  27395. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27396. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27397. * @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)
  27398. * @param reserved Internal use only
  27399. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27400. */
  27401. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27402. private _decreaseWaitingTasksCount(task);
  27403. private _runTask(task);
  27404. /**
  27405. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27406. * @return the current instance of the {BABYLON.AssetsManager}
  27407. */
  27408. reset(): AssetsManager;
  27409. /**
  27410. * Start the loading process
  27411. * @return the current instance of the {BABYLON.AssetsManager}
  27412. */
  27413. load(): AssetsManager;
  27414. }
  27415. }
  27416. declare module BABYLON {
  27417. /**
  27418. * Class used to enable access to IndexedDB
  27419. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27420. */
  27421. class Database {
  27422. private callbackManifestChecked;
  27423. private currentSceneUrl;
  27424. private db;
  27425. private _enableSceneOffline;
  27426. private _enableTexturesOffline;
  27427. private manifestVersionFound;
  27428. private mustUpdateRessources;
  27429. private hasReachedQuota;
  27430. private isSupported;
  27431. private idbFactory;
  27432. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27433. static IsUASupportingBlobStorage: boolean;
  27434. /** Gets a boolean indicating if Database storate is enabled */
  27435. static IDBStorageEnabled: boolean;
  27436. /**
  27437. * Gets a boolean indicating if scene must be saved in the database
  27438. */
  27439. readonly enableSceneOffline: boolean;
  27440. /**
  27441. * Gets a boolean indicating if textures must be saved in the database
  27442. */
  27443. readonly enableTexturesOffline: boolean;
  27444. /**
  27445. * Creates a new Database
  27446. * @param urlToScene defines the url to load the scene
  27447. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27448. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27449. */
  27450. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27451. private static _ParseURL;
  27452. private static _ReturnFullUrlLocation;
  27453. private _checkManifestFile();
  27454. /**
  27455. * Open the database and make it available
  27456. * @param successCallback defines the callback to call on success
  27457. * @param errorCallback defines the callback to call on error
  27458. */
  27459. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27460. /**
  27461. * Loads an image from the database
  27462. * @param url defines the url to load from
  27463. * @param image defines the target DOM image
  27464. */
  27465. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27466. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27467. private _saveImageIntoDBAsync(url, image);
  27468. private _checkVersionFromDB(url, versionLoaded);
  27469. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27470. private _saveVersionIntoDBAsync(url, callback);
  27471. /**
  27472. * Loads a file from database
  27473. * @param url defines the URL to load from
  27474. * @param sceneLoaded defines a callback to call on success
  27475. * @param progressCallBack defines a callback to call when progress changed
  27476. * @param errorCallback defines a callback to call on error
  27477. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27478. */
  27479. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27480. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27481. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27482. }
  27483. }
  27484. declare module BABYLON {
  27485. interface DDSInfo {
  27486. width: number;
  27487. height: number;
  27488. mipmapCount: number;
  27489. isFourCC: boolean;
  27490. isRGB: boolean;
  27491. isLuminance: boolean;
  27492. isCube: boolean;
  27493. isCompressed: boolean;
  27494. dxgiFormat: number;
  27495. textureType: number;
  27496. /** Sphericle polynomial created for the dds texture */
  27497. sphericalPolynomial?: SphericalPolynomial;
  27498. }
  27499. class DDSTools {
  27500. static StoreLODInAlphaChannel: boolean;
  27501. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27502. private static _FloatView;
  27503. private static _Int32View;
  27504. private static _ToHalfFloat(value);
  27505. private static _FromHalfFloat(value);
  27506. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27507. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27508. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27509. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27510. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27511. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27512. private static _ExtractLongWordOrder(value);
  27513. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27514. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27515. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27516. }
  27517. }
  27518. declare module BABYLON {
  27519. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27520. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27521. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27522. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27523. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27524. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27525. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27526. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27527. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27528. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27529. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27530. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27531. /**
  27532. * Decorator used to define property that can be serialized as reference to a camera
  27533. * @param sourceName defines the name of the property to decorate
  27534. */
  27535. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27536. class SerializationHelper {
  27537. static Serialize<T>(entity: T, serializationObject?: any): any;
  27538. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27539. static Clone<T>(creationFunction: () => T, source: T): T;
  27540. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27541. }
  27542. }
  27543. declare module BABYLON {
  27544. /**
  27545. * Wrapper class for promise with external resolve and reject.
  27546. */
  27547. class Deferred<T> {
  27548. /**
  27549. * The promise associated with this deferred object.
  27550. */
  27551. readonly promise: Promise<T>;
  27552. private _resolve;
  27553. private _reject;
  27554. /**
  27555. * The resolve method of the promise associated with this deferred object.
  27556. */
  27557. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27558. /**
  27559. * The reject method of the promise associated with this deferred object.
  27560. */
  27561. readonly reject: (reason?: any) => void;
  27562. /**
  27563. * Constructor for this deferred object.
  27564. */
  27565. constructor();
  27566. }
  27567. }
  27568. declare module BABYLON {
  27569. class FilesInput {
  27570. static FilesToLoad: {
  27571. [key: string]: File;
  27572. };
  27573. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27574. private _engine;
  27575. private _currentScene;
  27576. private _sceneLoadedCallback;
  27577. private _progressCallback;
  27578. private _additionalRenderLoopLogicCallback;
  27579. private _textureLoadingCallback;
  27580. private _startingProcessingFilesCallback;
  27581. private _onReloadCallback;
  27582. private _errorCallback;
  27583. private _elementToMonitor;
  27584. private _sceneFileToLoad;
  27585. private _filesToLoad;
  27586. 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);
  27587. private _dragEnterHandler;
  27588. private _dragOverHandler;
  27589. private _dropHandler;
  27590. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27591. dispose(): void;
  27592. private renderFunction();
  27593. private drag(e);
  27594. private drop(eventDrop);
  27595. private _traverseFolder(folder, files, remaining, callback);
  27596. private _processFiles(files);
  27597. loadFiles(event: any): void;
  27598. private _processReload();
  27599. reload(): void;
  27600. }
  27601. }
  27602. declare module BABYLON {
  27603. /**
  27604. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27605. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27606. */
  27607. class KhronosTextureContainer {
  27608. arrayBuffer: any;
  27609. static HEADER_LEN: number;
  27610. static COMPRESSED_2D: number;
  27611. static COMPRESSED_3D: number;
  27612. static TEX_2D: number;
  27613. static TEX_3D: number;
  27614. glType: number;
  27615. glTypeSize: number;
  27616. glFormat: number;
  27617. glInternalFormat: number;
  27618. glBaseInternalFormat: number;
  27619. pixelWidth: number;
  27620. pixelHeight: number;
  27621. pixelDepth: number;
  27622. numberOfArrayElements: number;
  27623. numberOfFaces: number;
  27624. numberOfMipmapLevels: number;
  27625. bytesOfKeyValueData: number;
  27626. loadType: number;
  27627. /**
  27628. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27629. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27630. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27631. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27632. */
  27633. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27634. switchEndainness(val: number): number;
  27635. /**
  27636. * It is assumed that the texture has already been created & is currently bound
  27637. */
  27638. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27639. private _upload2DCompressedLevels(gl, loadMipmaps);
  27640. }
  27641. }
  27642. declare module BABYLON {
  27643. /**
  27644. * A class serves as a medium between the observable and its observers
  27645. */
  27646. class EventState {
  27647. /**
  27648. * Create a new EventState
  27649. * @param mask defines the mask associated with this state
  27650. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27651. * @param target defines the original target of the state
  27652. * @param currentTarget defines the current target of the state
  27653. */
  27654. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27655. /**
  27656. * Initialize the current event state
  27657. * @param mask defines the mask associated with this state
  27658. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27659. * @param target defines the original target of the state
  27660. * @param currentTarget defines the current target of the state
  27661. * @returns the current event state
  27662. */
  27663. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27664. /**
  27665. * An Observer can set this property to true to prevent subsequent observers of being notified
  27666. */
  27667. skipNextObservers: boolean;
  27668. /**
  27669. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27670. */
  27671. mask: number;
  27672. /**
  27673. * The object that originally notified the event
  27674. */
  27675. target?: any;
  27676. /**
  27677. * The current object in the bubbling phase
  27678. */
  27679. currentTarget?: any;
  27680. /**
  27681. * This will be populated with the return value of the last function that was executed.
  27682. * If it is the first function in the callback chain it will be the event data.
  27683. */
  27684. lastReturnValue?: any;
  27685. }
  27686. /**
  27687. * Represent an Observer registered to a given Observable object.
  27688. */
  27689. class Observer<T> {
  27690. /**
  27691. * Defines the callback to call when the observer is notified
  27692. */
  27693. callback: (eventData: T, eventState: EventState) => void;
  27694. /**
  27695. * Defines the mask of the observer (used to filter notifications)
  27696. */
  27697. mask: number;
  27698. /**
  27699. * Defines the current scope used to restore the JS context
  27700. */
  27701. scope: any;
  27702. /** @hidden */
  27703. _willBeUnregistered: boolean;
  27704. /**
  27705. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27706. */
  27707. unregisterOnNextCall: boolean;
  27708. /**
  27709. * Creates a new observer
  27710. * @param callback defines the callback to call when the observer is notified
  27711. * @param mask defines the mask of the observer (used to filter notifications)
  27712. * @param scope defines the current scope used to restore the JS context
  27713. */
  27714. constructor(
  27715. /**
  27716. * Defines the callback to call when the observer is notified
  27717. */
  27718. callback: (eventData: T, eventState: EventState) => void,
  27719. /**
  27720. * Defines the mask of the observer (used to filter notifications)
  27721. */
  27722. mask: number,
  27723. /**
  27724. * Defines the current scope used to restore the JS context
  27725. */
  27726. scope?: any);
  27727. }
  27728. /**
  27729. * Represent a list of observers registered to multiple Observables object.
  27730. */
  27731. class MultiObserver<T> {
  27732. private _observers;
  27733. private _observables;
  27734. /**
  27735. * Release associated resources
  27736. */
  27737. dispose(): void;
  27738. /**
  27739. * Raise a callback when one of the observable will notify
  27740. * @param observables defines a list of observables to watch
  27741. * @param callback defines the callback to call on notification
  27742. * @param mask defines the mask used to filter notifications
  27743. * @param scope defines the current scope used to restore the JS context
  27744. * @returns the new MultiObserver
  27745. */
  27746. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27747. }
  27748. /**
  27749. * The Observable class is a simple implementation of the Observable pattern.
  27750. *
  27751. * 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.
  27752. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27753. * 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).
  27754. * 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.
  27755. */
  27756. class Observable<T> {
  27757. private _observers;
  27758. private _eventState;
  27759. private _onObserverAdded;
  27760. /**
  27761. * Creates a new observable
  27762. * @param onObserverAdded defines a callback to call when a new observer is added
  27763. */
  27764. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27765. /**
  27766. * Create a new Observer with the specified callback
  27767. * @param callback the callback that will be executed for that Observer
  27768. * @param mask the mask used to filter observers
  27769. * @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.
  27770. * @param scope optional scope for the callback to be called from
  27771. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27772. * @returns the new observer created for the callback
  27773. */
  27774. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27775. /**
  27776. * Remove an Observer from the Observable object
  27777. * @param observer the instance of the Observer to remove
  27778. * @returns false if it doesn't belong to this Observable
  27779. */
  27780. remove(observer: Nullable<Observer<T>>): boolean;
  27781. /**
  27782. * Remove a callback from the Observable object
  27783. * @param callback the callback to remove
  27784. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27785. * @returns false if it doesn't belong to this Observable
  27786. */
  27787. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27788. private _deferUnregister(observer);
  27789. /**
  27790. * Notify all Observers by calling their respective callback with the given data
  27791. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27792. * @param eventData defines the data to send to all observers
  27793. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27794. * @param target defines the original target of the state
  27795. * @param currentTarget defines the current target of the state
  27796. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27797. */
  27798. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27799. /**
  27800. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27801. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27802. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27803. * and it is crucial that all callbacks will be executed.
  27804. * The order of the callbacks is kept, callbacks are not executed parallel.
  27805. *
  27806. * @param eventData The data to be sent to each callback
  27807. * @param mask is used to filter observers defaults to -1
  27808. * @param target defines the callback target (see EventState)
  27809. * @param currentTarget defines he current object in the bubbling phase
  27810. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27811. */
  27812. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27813. /**
  27814. * Notify a specific observer
  27815. * @param observer defines the observer to notify
  27816. * @param eventData defines the data to be sent to each callback
  27817. * @param mask is used to filter observers defaults to -1
  27818. */
  27819. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27820. /**
  27821. * Gets a boolean indicating if the observable has at least one observer
  27822. * @returns true is the Observable has at least one Observer registered
  27823. */
  27824. hasObservers(): boolean;
  27825. /**
  27826. * Clear the list of observers
  27827. */
  27828. clear(): void;
  27829. /**
  27830. * Clone the current observable
  27831. * @returns a new observable
  27832. */
  27833. clone(): Observable<T>;
  27834. /**
  27835. * Does this observable handles observer registered with a given mask
  27836. * @param mask defines the mask to be tested
  27837. * @return whether or not one observer registered with the given mask is handeled
  27838. **/
  27839. hasSpecificMask(mask?: number): boolean;
  27840. }
  27841. }
  27842. declare module BABYLON {
  27843. /**
  27844. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27845. */
  27846. class PerformanceMonitor {
  27847. private _enabled;
  27848. private _rollingFrameTime;
  27849. private _lastFrameTimeMs;
  27850. /**
  27851. * constructor
  27852. * @param frameSampleSize The number of samples required to saturate the sliding window
  27853. */
  27854. constructor(frameSampleSize?: number);
  27855. /**
  27856. * Samples current frame
  27857. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27858. */
  27859. sampleFrame(timeMs?: number): void;
  27860. /**
  27861. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27862. * @return Average frame time in milliseconds
  27863. */
  27864. readonly averageFrameTime: number;
  27865. /**
  27866. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27867. * @return Frame time variance in milliseconds squared
  27868. */
  27869. readonly averageFrameTimeVariance: number;
  27870. /**
  27871. * Returns the frame time of the most recent frame
  27872. * @return Frame time in milliseconds
  27873. */
  27874. readonly instantaneousFrameTime: number;
  27875. /**
  27876. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27877. * @return Framerate in frames per second
  27878. */
  27879. readonly averageFPS: number;
  27880. /**
  27881. * Returns the average framerate in frames per second using the most recent frame time
  27882. * @return Framerate in frames per second
  27883. */
  27884. readonly instantaneousFPS: number;
  27885. /**
  27886. * Returns true if enough samples have been taken to completely fill the sliding window
  27887. * @return true if saturated
  27888. */
  27889. readonly isSaturated: boolean;
  27890. /**
  27891. * Enables contributions to the sliding window sample set
  27892. */
  27893. enable(): void;
  27894. /**
  27895. * Disables contributions to the sliding window sample set
  27896. * Samples will not be interpolated over the disabled period
  27897. */
  27898. disable(): void;
  27899. /**
  27900. * Returns true if sampling is enabled
  27901. * @return true if enabled
  27902. */
  27903. readonly isEnabled: boolean;
  27904. /**
  27905. * Resets performance monitor
  27906. */
  27907. reset(): void;
  27908. }
  27909. /**
  27910. * RollingAverage
  27911. *
  27912. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27913. */
  27914. class RollingAverage {
  27915. /**
  27916. * Current average
  27917. */
  27918. average: number;
  27919. /**
  27920. * Current variance
  27921. */
  27922. variance: number;
  27923. protected _samples: Array<number>;
  27924. protected _sampleCount: number;
  27925. protected _pos: number;
  27926. protected _m2: number;
  27927. /**
  27928. * constructor
  27929. * @param length The number of samples required to saturate the sliding window
  27930. */
  27931. constructor(length: number);
  27932. /**
  27933. * Adds a sample to the sample set
  27934. * @param v The sample value
  27935. */
  27936. add(v: number): void;
  27937. /**
  27938. * Returns previously added values or null if outside of history or outside the sliding window domain
  27939. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27940. * @return Value previously recorded with add() or null if outside of range
  27941. */
  27942. history(i: number): number;
  27943. /**
  27944. * Returns true if enough samples have been taken to completely fill the sliding window
  27945. * @return true if sample-set saturated
  27946. */
  27947. isSaturated(): boolean;
  27948. /**
  27949. * Resets the rolling average (equivalent to 0 samples taken so far)
  27950. */
  27951. reset(): void;
  27952. /**
  27953. * Wraps a value around the sample range boundaries
  27954. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27955. * @return Wrapped position in sample range
  27956. */
  27957. protected _wrapPosition(i: number): number;
  27958. }
  27959. }
  27960. declare module BABYLON {
  27961. /**
  27962. * Helper class that provides a small promise polyfill
  27963. */
  27964. class PromisePolyfill {
  27965. /**
  27966. * Static function used to check if the polyfill is required
  27967. * If this is the case then the function will inject the polyfill to window.Promise
  27968. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27969. */
  27970. static Apply(force?: boolean): void;
  27971. }
  27972. }
  27973. declare module BABYLON {
  27974. /**
  27975. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27977. */
  27978. class SceneOptimization {
  27979. /**
  27980. * Defines the priority of this optimization (0 by default which means first in the list)
  27981. */
  27982. priority: number;
  27983. /**
  27984. * Gets a string describing the action executed by the current optimization
  27985. * @returns description string
  27986. */
  27987. getDescription(): string;
  27988. /**
  27989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27990. * @param scene defines the current scene where to apply this optimization
  27991. * @param optimizer defines the current optimizer
  27992. * @returns true if everything that can be done was applied
  27993. */
  27994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27995. /**
  27996. * Creates the SceneOptimization object
  27997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27998. * @param desc defines the description associated with the optimization
  27999. */
  28000. constructor(
  28001. /**
  28002. * Defines the priority of this optimization (0 by default which means first in the list)
  28003. */
  28004. priority?: number);
  28005. }
  28006. /**
  28007. * Defines an optimization used to reduce the size of render target textures
  28008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28009. */
  28010. class TextureOptimization extends SceneOptimization {
  28011. /**
  28012. * Defines the priority of this optimization (0 by default which means first in the list)
  28013. */
  28014. priority: number;
  28015. /**
  28016. * 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
  28017. */
  28018. maximumSize: number;
  28019. /**
  28020. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28021. */
  28022. step: number;
  28023. /**
  28024. * Gets a string describing the action executed by the current optimization
  28025. * @returns description string
  28026. */
  28027. getDescription(): string;
  28028. /**
  28029. * Creates the TextureOptimization object
  28030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28031. * @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
  28032. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28033. */
  28034. constructor(
  28035. /**
  28036. * Defines the priority of this optimization (0 by default which means first in the list)
  28037. */
  28038. priority?: number,
  28039. /**
  28040. * 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
  28041. */
  28042. maximumSize?: number,
  28043. /**
  28044. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28045. */
  28046. step?: number);
  28047. /**
  28048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28049. * @param scene defines the current scene where to apply this optimization
  28050. * @param optimizer defines the current optimizer
  28051. * @returns true if everything that can be done was applied
  28052. */
  28053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28054. }
  28055. /**
  28056. * Defines an optimization used to increase or decrease the rendering resolution
  28057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28058. */
  28059. class HardwareScalingOptimization extends SceneOptimization {
  28060. /**
  28061. * Defines the priority of this optimization (0 by default which means first in the list)
  28062. */
  28063. priority: number;
  28064. /**
  28065. * Defines the maximum scale to use (2 by default)
  28066. */
  28067. maximumScale: number;
  28068. /**
  28069. * Defines the step to use between two passes (0.5 by default)
  28070. */
  28071. step: number;
  28072. private _currentScale;
  28073. private _directionOffset;
  28074. /**
  28075. * Gets a string describing the action executed by the current optimization
  28076. * @return description string
  28077. */
  28078. getDescription(): string;
  28079. /**
  28080. * Creates the HardwareScalingOptimization object
  28081. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28082. * @param maximumScale defines the maximum scale to use (2 by default)
  28083. * @param step defines the step to use between two passes (0.5 by default)
  28084. */
  28085. constructor(
  28086. /**
  28087. * Defines the priority of this optimization (0 by default which means first in the list)
  28088. */
  28089. priority?: number,
  28090. /**
  28091. * Defines the maximum scale to use (2 by default)
  28092. */
  28093. maximumScale?: number,
  28094. /**
  28095. * Defines the step to use between two passes (0.5 by default)
  28096. */
  28097. step?: number);
  28098. /**
  28099. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28100. * @param scene defines the current scene where to apply this optimization
  28101. * @param optimizer defines the current optimizer
  28102. * @returns true if everything that can be done was applied
  28103. */
  28104. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28105. }
  28106. /**
  28107. * Defines an optimization used to remove shadows
  28108. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28109. */
  28110. class ShadowsOptimization extends SceneOptimization {
  28111. /**
  28112. * Gets a string describing the action executed by the current optimization
  28113. * @return description string
  28114. */
  28115. getDescription(): string;
  28116. /**
  28117. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28118. * @param scene defines the current scene where to apply this optimization
  28119. * @param optimizer defines the current optimizer
  28120. * @returns true if everything that can be done was applied
  28121. */
  28122. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28123. }
  28124. /**
  28125. * Defines an optimization used to turn post-processes off
  28126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28127. */
  28128. class PostProcessesOptimization extends SceneOptimization {
  28129. /**
  28130. * Gets a string describing the action executed by the current optimization
  28131. * @return description string
  28132. */
  28133. getDescription(): string;
  28134. /**
  28135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28136. * @param scene defines the current scene where to apply this optimization
  28137. * @param optimizer defines the current optimizer
  28138. * @returns true if everything that can be done was applied
  28139. */
  28140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28141. }
  28142. /**
  28143. * Defines an optimization used to turn lens flares off
  28144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28145. */
  28146. class LensFlaresOptimization extends SceneOptimization {
  28147. /**
  28148. * Gets a string describing the action executed by the current optimization
  28149. * @return description string
  28150. */
  28151. getDescription(): string;
  28152. /**
  28153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28154. * @param scene defines the current scene where to apply this optimization
  28155. * @param optimizer defines the current optimizer
  28156. * @returns true if everything that can be done was applied
  28157. */
  28158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28159. }
  28160. /**
  28161. * Defines an optimization based on user defined callback.
  28162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28163. */
  28164. class CustomOptimization extends SceneOptimization {
  28165. /**
  28166. * Callback called to apply the custom optimization.
  28167. */
  28168. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28169. /**
  28170. * Callback called to get custom description
  28171. */
  28172. onGetDescription: () => string;
  28173. /**
  28174. * Gets a string describing the action executed by the current optimization
  28175. * @returns description string
  28176. */
  28177. getDescription(): string;
  28178. /**
  28179. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28180. * @param scene defines the current scene where to apply this optimization
  28181. * @param optimizer defines the current optimizer
  28182. * @returns true if everything that can be done was applied
  28183. */
  28184. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28185. }
  28186. /**
  28187. * Defines an optimization used to turn particles off
  28188. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28189. */
  28190. class ParticlesOptimization extends SceneOptimization {
  28191. /**
  28192. * Gets a string describing the action executed by the current optimization
  28193. * @return description string
  28194. */
  28195. getDescription(): string;
  28196. /**
  28197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28198. * @param scene defines the current scene where to apply this optimization
  28199. * @param optimizer defines the current optimizer
  28200. * @returns true if everything that can be done was applied
  28201. */
  28202. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28203. }
  28204. /**
  28205. * Defines an optimization used to turn render targets off
  28206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28207. */
  28208. class RenderTargetsOptimization extends SceneOptimization {
  28209. /**
  28210. * Gets a string describing the action executed by the current optimization
  28211. * @return description string
  28212. */
  28213. getDescription(): string;
  28214. /**
  28215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28216. * @param scene defines the current scene where to apply this optimization
  28217. * @param optimizer defines the current optimizer
  28218. * @returns true if everything that can be done was applied
  28219. */
  28220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28221. }
  28222. /**
  28223. * Defines an optimization used to merge meshes with compatible materials
  28224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28225. */
  28226. class MergeMeshesOptimization extends SceneOptimization {
  28227. private static _UpdateSelectionTree;
  28228. /**
  28229. * Gets or sets a boolean which defines if optimization octree has to be updated
  28230. */
  28231. /**
  28232. * Gets or sets a boolean which defines if optimization octree has to be updated
  28233. */
  28234. static UpdateSelectionTree: boolean;
  28235. /**
  28236. * Gets a string describing the action executed by the current optimization
  28237. * @return description string
  28238. */
  28239. getDescription(): string;
  28240. private _canBeMerged;
  28241. /**
  28242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28243. * @param scene defines the current scene where to apply this optimization
  28244. * @param optimizer defines the current optimizer
  28245. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28246. * @returns true if everything that can be done was applied
  28247. */
  28248. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28249. }
  28250. /**
  28251. * Defines a list of options used by SceneOptimizer
  28252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28253. */
  28254. class SceneOptimizerOptions {
  28255. /**
  28256. * Defines the target frame rate to reach (60 by default)
  28257. */
  28258. targetFrameRate: number;
  28259. /**
  28260. * Defines the interval between two checkes (2000ms by default)
  28261. */
  28262. trackerDuration: number;
  28263. /**
  28264. * Gets the list of optimizations to apply
  28265. */
  28266. optimizations: SceneOptimization[];
  28267. /**
  28268. * Creates a new list of options used by SceneOptimizer
  28269. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28270. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28271. */
  28272. constructor(
  28273. /**
  28274. * Defines the target frame rate to reach (60 by default)
  28275. */
  28276. targetFrameRate?: number,
  28277. /**
  28278. * Defines the interval between two checkes (2000ms by default)
  28279. */
  28280. trackerDuration?: number);
  28281. /**
  28282. * Add a new optimization
  28283. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28284. * @returns the current SceneOptimizerOptions
  28285. */
  28286. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28287. /**
  28288. * Add a new custom optimization
  28289. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28290. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28292. * @returns the current SceneOptimizerOptions
  28293. */
  28294. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28295. /**
  28296. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28297. * @param targetFrameRate defines the target frame rate (60 by default)
  28298. * @returns a SceneOptimizerOptions object
  28299. */
  28300. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28301. /**
  28302. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28303. * @param targetFrameRate defines the target frame rate (60 by default)
  28304. * @returns a SceneOptimizerOptions object
  28305. */
  28306. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28307. /**
  28308. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28309. * @param targetFrameRate defines the target frame rate (60 by default)
  28310. * @returns a SceneOptimizerOptions object
  28311. */
  28312. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28313. }
  28314. /**
  28315. * Class used to run optimizations in order to reach a target frame rate
  28316. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28317. */
  28318. class SceneOptimizer implements IDisposable {
  28319. private _isRunning;
  28320. private _options;
  28321. private _scene;
  28322. private _currentPriorityLevel;
  28323. private _targetFrameRate;
  28324. private _trackerDuration;
  28325. private _currentFrameRate;
  28326. private _sceneDisposeObserver;
  28327. private _improvementMode;
  28328. /**
  28329. * Defines an observable called when the optimizer reaches the target frame rate
  28330. */
  28331. onSuccessObservable: Observable<SceneOptimizer>;
  28332. /**
  28333. * Defines an observable called when the optimizer enables an optimization
  28334. */
  28335. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28336. /**
  28337. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28338. */
  28339. onFailureObservable: Observable<SceneOptimizer>;
  28340. /**
  28341. * Gets a boolean indicating if the optimizer is in improvement mode
  28342. */
  28343. readonly isInImprovementMode: boolean;
  28344. /**
  28345. * Gets the current priority level (0 at start)
  28346. */
  28347. readonly currentPriorityLevel: number;
  28348. /**
  28349. * Gets the current frame rate checked by the SceneOptimizer
  28350. */
  28351. readonly currentFrameRate: number;
  28352. /**
  28353. * Gets or sets the current target frame rate (60 by default)
  28354. */
  28355. /**
  28356. * Gets or sets the current target frame rate (60 by default)
  28357. */
  28358. targetFrameRate: number;
  28359. /**
  28360. * Gets or sets the current interval between two checks (every 2000ms by default)
  28361. */
  28362. /**
  28363. * Gets or sets the current interval between two checks (every 2000ms by default)
  28364. */
  28365. trackerDuration: number;
  28366. /**
  28367. * Gets the list of active optimizations
  28368. */
  28369. readonly optimizations: SceneOptimization[];
  28370. /**
  28371. * Creates a new SceneOptimizer
  28372. * @param scene defines the scene to work on
  28373. * @param options defines the options to use with the SceneOptimizer
  28374. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28375. * @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)
  28376. */
  28377. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28378. /**
  28379. * Stops the current optimizer
  28380. */
  28381. stop(): void;
  28382. /**
  28383. * Reset the optimizer to initial step (current priority level = 0)
  28384. */
  28385. reset(): void;
  28386. /**
  28387. * Start the optimizer. By default it will try to reach a specific framerate
  28388. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28389. */
  28390. start(): void;
  28391. private _checkCurrentState();
  28392. /**
  28393. * Release all resources
  28394. */
  28395. dispose(): void;
  28396. /**
  28397. * Helper function to create a SceneOptimizer with one single line of code
  28398. * @param scene defines the scene to work on
  28399. * @param options defines the options to use with the SceneOptimizer
  28400. * @param onSuccess defines a callback to call on success
  28401. * @param onFailure defines a callback to call on failure
  28402. * @returns the new SceneOptimizer object
  28403. */
  28404. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28405. }
  28406. }
  28407. declare module BABYLON {
  28408. class SceneSerializer {
  28409. static ClearCache(): void;
  28410. static Serialize(scene: Scene): any;
  28411. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28412. }
  28413. }
  28414. declare module BABYLON {
  28415. class SmartArray<T> {
  28416. data: Array<T>;
  28417. length: number;
  28418. protected _id: number;
  28419. [index: number]: T;
  28420. constructor(capacity: number);
  28421. push(value: T): void;
  28422. forEach(func: (content: T) => void): void;
  28423. sort(compareFn: (a: T, b: T) => number): void;
  28424. reset(): void;
  28425. dispose(): void;
  28426. concat(array: any): void;
  28427. indexOf(value: T): number;
  28428. contains(value: T): boolean;
  28429. private static _GlobalId;
  28430. }
  28431. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28432. private _duplicateId;
  28433. [index: number]: T;
  28434. push(value: T): void;
  28435. pushNoDuplicate(value: T): boolean;
  28436. reset(): void;
  28437. concatWithNoDuplicate(array: any): void;
  28438. }
  28439. }
  28440. declare module BABYLON {
  28441. /**
  28442. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28443. * The underlying implementation relies on an associative array to ensure the best performances.
  28444. * The value can be anything including 'null' but except 'undefined'
  28445. */
  28446. class StringDictionary<T> {
  28447. /**
  28448. * This will clear this dictionary and copy the content from the 'source' one.
  28449. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28450. * @param source the dictionary to take the content from and copy to this dictionary
  28451. */
  28452. copyFrom(source: StringDictionary<T>): void;
  28453. /**
  28454. * Get a value based from its key
  28455. * @param key the given key to get the matching value from
  28456. * @return the value if found, otherwise undefined is returned
  28457. */
  28458. get(key: string): T | undefined;
  28459. /**
  28460. * Get a value from its key or add it if it doesn't exist.
  28461. * This method will ensure you that a given key/data will be present in the dictionary.
  28462. * @param key the given key to get the matching value from
  28463. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28464. * The factory will only be invoked if there's no data for the given key.
  28465. * @return the value corresponding to the key.
  28466. */
  28467. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28468. /**
  28469. * Get a value from its key if present in the dictionary otherwise add it
  28470. * @param key the key to get the value from
  28471. * @param val if there's no such key/value pair in the dictionary add it with this value
  28472. * @return the value corresponding to the key
  28473. */
  28474. getOrAdd(key: string, val: T): T;
  28475. /**
  28476. * Check if there's a given key in the dictionary
  28477. * @param key the key to check for
  28478. * @return true if the key is present, false otherwise
  28479. */
  28480. contains(key: string): boolean;
  28481. /**
  28482. * Add a new key and its corresponding value
  28483. * @param key the key to add
  28484. * @param value the value corresponding to the key
  28485. * @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
  28486. */
  28487. add(key: string, value: T): boolean;
  28488. set(key: string, value: T): boolean;
  28489. /**
  28490. * Get the element of the given key and remove it from the dictionary
  28491. * @param key
  28492. */
  28493. getAndRemove(key: string): Nullable<T>;
  28494. /**
  28495. * Remove a key/value from the dictionary.
  28496. * @param key the key to remove
  28497. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28498. */
  28499. remove(key: string): boolean;
  28500. /**
  28501. * Clear the whole content of the dictionary
  28502. */
  28503. clear(): void;
  28504. readonly count: number;
  28505. /**
  28506. * Execute a callback on each key/val of the dictionary.
  28507. * Note that you can remove any element in this dictionary in the callback implementation
  28508. * @param callback the callback to execute on a given key/value pair
  28509. */
  28510. forEach(callback: (key: string, val: T) => void): void;
  28511. /**
  28512. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28513. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28514. * Note that you can remove any element in this dictionary in the callback implementation
  28515. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28516. */
  28517. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28518. private _count;
  28519. private _data;
  28520. }
  28521. }
  28522. declare module BABYLON {
  28523. class Tags {
  28524. static EnableFor(obj: any): void;
  28525. static DisableFor(obj: any): void;
  28526. static HasTags(obj: any): boolean;
  28527. static GetTags(obj: any, asString?: boolean): any;
  28528. static AddTagsTo(obj: any, tagsString: string): void;
  28529. static _AddTagTo(obj: any, tag: string): void;
  28530. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28531. static _RemoveTagFrom(obj: any, tag: string): void;
  28532. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28533. }
  28534. }
  28535. declare module BABYLON {
  28536. class TextureTools {
  28537. /**
  28538. * Uses the GPU to create a copy texture rescaled at a given size
  28539. * @param texture Texture to copy from
  28540. * @param width Desired width
  28541. * @param height Desired height
  28542. * @return Generated texture
  28543. */
  28544. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28545. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28546. private static _environmentBRDFBase64Texture;
  28547. }
  28548. }
  28549. declare module BABYLON {
  28550. class TGATools {
  28551. private static _TYPE_INDEXED;
  28552. private static _TYPE_RGB;
  28553. private static _TYPE_GREY;
  28554. private static _TYPE_RLE_INDEXED;
  28555. private static _TYPE_RLE_RGB;
  28556. private static _TYPE_RLE_GREY;
  28557. private static _ORIGIN_MASK;
  28558. private static _ORIGIN_SHIFT;
  28559. private static _ORIGIN_BL;
  28560. private static _ORIGIN_BR;
  28561. private static _ORIGIN_UL;
  28562. private static _ORIGIN_UR;
  28563. static GetTGAHeader(data: Uint8Array): any;
  28564. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28565. 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;
  28566. 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;
  28567. 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;
  28568. 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;
  28569. 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;
  28570. 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;
  28571. }
  28572. }
  28573. declare module BABYLON {
  28574. interface IAnimatable {
  28575. animations: Array<Animation>;
  28576. }
  28577. class LoadFileError extends Error {
  28578. request: XMLHttpRequest | undefined;
  28579. private static _setPrototypeOf;
  28580. constructor(message: string, request?: XMLHttpRequest | undefined);
  28581. }
  28582. class RetryStrategy {
  28583. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28584. }
  28585. interface IFileRequest {
  28586. /**
  28587. * Raised when the request is complete (success or error).
  28588. */
  28589. onCompleteObservable: Observable<IFileRequest>;
  28590. /**
  28591. * Aborts the request for a file.
  28592. */
  28593. abort: () => void;
  28594. }
  28595. class Tools {
  28596. static BaseUrl: string;
  28597. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28598. /**
  28599. * Default behaviour for cors in the application.
  28600. * It can be a string if the expected behavior is identical in the entire app.
  28601. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28602. */
  28603. static CorsBehavior: string | ((url: string | string[]) => string);
  28604. static UseFallbackTexture: boolean;
  28605. /**
  28606. * Use this object to register external classes like custom textures or material
  28607. * to allow the laoders to instantiate them
  28608. */
  28609. static RegisteredExternalClasses: {
  28610. [key: string]: Object;
  28611. };
  28612. static fallbackTexture: string;
  28613. /**
  28614. * Interpolates between a and b via alpha
  28615. * @param a The lower value (returned when alpha = 0)
  28616. * @param b The upper value (returned when alpha = 1)
  28617. * @param alpha The interpolation-factor
  28618. * @return The mixed value
  28619. */
  28620. static Mix(a: number, b: number, alpha: number): number;
  28621. static Instantiate(className: string): any;
  28622. /**
  28623. * Provides a slice function that will work even on IE
  28624. * @param data defines the array to slice
  28625. * @param start defines the start of the data (optional)
  28626. * @param end defines the end of the data (optional)
  28627. * @returns the new sliced array
  28628. */
  28629. static Slice<T>(data: T, start?: number, end?: number): T;
  28630. static SetImmediate(action: () => void): void;
  28631. static IsExponentOfTwo(value: number): boolean;
  28632. private static _tmpFloatArray;
  28633. /**
  28634. * Returns the nearest 32-bit single precision float representation of a Number
  28635. * @param value A Number. If the parameter is of a different type, it will get converted
  28636. * to a number or to NaN if it cannot be converted
  28637. * @returns number
  28638. */
  28639. static FloatRound(value: number): number;
  28640. /**
  28641. * Find the next highest power of two.
  28642. * @param x Number to start search from.
  28643. * @return Next highest power of two.
  28644. */
  28645. static CeilingPOT(x: number): number;
  28646. /**
  28647. * Find the next lowest power of two.
  28648. * @param x Number to start search from.
  28649. * @return Next lowest power of two.
  28650. */
  28651. static FloorPOT(x: number): number;
  28652. /**
  28653. * Find the nearest power of two.
  28654. * @param x Number to start search from.
  28655. * @return Next nearest power of two.
  28656. */
  28657. static NearestPOT(x: number): number;
  28658. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28659. static GetFilename(path: string): string;
  28660. /**
  28661. * Extracts the "folder" part of a path (everything before the filename).
  28662. * @param uri The URI to extract the info from
  28663. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28664. * @returns The "folder" part of the path
  28665. */
  28666. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28667. static GetDOMTextContent(element: HTMLElement): string;
  28668. static ToDegrees(angle: number): number;
  28669. static ToRadians(angle: number): number;
  28670. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28671. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28672. minimum: Vector3;
  28673. maximum: Vector3;
  28674. };
  28675. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28676. minimum: Vector3;
  28677. maximum: Vector3;
  28678. };
  28679. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28680. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28681. minimum: Vector2;
  28682. maximum: Vector2;
  28683. };
  28684. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28685. static GetPointerPrefix(): string;
  28686. /**
  28687. * @param func - the function to be called
  28688. * @param requester - the object that will request the next frame. Falls back to window.
  28689. */
  28690. static QueueNewFrame(func: () => void, requester?: any): number;
  28691. static RequestFullscreen(element: HTMLElement): void;
  28692. static ExitFullscreen(): void;
  28693. static SetCorsBehavior(url: string | string[], element: {
  28694. crossOrigin: string | null;
  28695. }): void;
  28696. static CleanUrl(url: string): string;
  28697. static PreprocessUrl: (url: string) => string;
  28698. /**
  28699. * Loads an image as an HTMLImageElement.
  28700. * @param input url string, ArrayBuffer, or Blob to load
  28701. * @param onLoad callback called when the image successfully loads
  28702. * @param onError callback called when the image fails to load
  28703. * @param database database for caching
  28704. * @returns the HTMLImageElement of the loaded image
  28705. */
  28706. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28707. 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;
  28708. /**
  28709. * Load a script (identified by an url). When the url returns, the
  28710. * content of this file is added into a new script element, attached to the DOM (body element)
  28711. */
  28712. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28713. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28714. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28715. static FileAsURL(content: string): string;
  28716. static Format(value: number, decimals?: number): string;
  28717. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28718. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28719. static IsEmpty(obj: any): boolean;
  28720. static RegisterTopRootEvents(events: {
  28721. name: string;
  28722. handler: Nullable<(e: FocusEvent) => any>;
  28723. }[]): void;
  28724. static UnregisterTopRootEvents(events: {
  28725. name: string;
  28726. handler: Nullable<(e: FocusEvent) => any>;
  28727. }[]): void;
  28728. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28729. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28730. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28731. /**
  28732. * Generates an image screenshot from the specified camera.
  28733. *
  28734. * @param engine The engine to use for rendering
  28735. * @param camera The camera to use for rendering
  28736. * @param size This parameter can be set to a single number or to an object with the
  28737. * following (optional) properties: precision, width, height. If a single number is passed,
  28738. * it will be used for both width and height. If an object is passed, the screenshot size
  28739. * will be derived from the parameters. The precision property is a multiplier allowing
  28740. * rendering at a higher or lower resolution.
  28741. * @param successCallback The callback receives a single parameter which contains the
  28742. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28743. * src parameter of an <img> to display it.
  28744. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28745. * Check your browser for supported MIME types.
  28746. * @param samples Texture samples (default: 1)
  28747. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28748. * @param fileName A name for for the downloaded file.
  28749. * @constructor
  28750. */
  28751. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28752. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28753. /**
  28754. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28755. * Be aware Math.random() could cause collisions, but:
  28756. * "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"
  28757. */
  28758. static RandomId(): string;
  28759. /**
  28760. * Test if the given uri is a base64 string.
  28761. * @param uri The uri to test
  28762. * @return True if the uri is a base64 string or false otherwise.
  28763. */
  28764. static IsBase64(uri: string): boolean;
  28765. /**
  28766. * Decode the given base64 uri.
  28767. * @param uri The uri to decode
  28768. * @return The decoded base64 data.
  28769. */
  28770. static DecodeBase64(uri: string): ArrayBuffer;
  28771. private static _NoneLogLevel;
  28772. private static _MessageLogLevel;
  28773. private static _WarningLogLevel;
  28774. private static _ErrorLogLevel;
  28775. private static _LogCache;
  28776. static errorsCount: number;
  28777. static OnNewCacheEntry: (entry: string) => void;
  28778. static readonly NoneLogLevel: number;
  28779. static readonly MessageLogLevel: number;
  28780. static readonly WarningLogLevel: number;
  28781. static readonly ErrorLogLevel: number;
  28782. static readonly AllLogLevel: number;
  28783. private static _AddLogEntry(entry);
  28784. private static _FormatMessage(message);
  28785. private static _LogDisabled(message);
  28786. private static _LogEnabled(message);
  28787. private static _WarnDisabled(message);
  28788. private static _WarnEnabled(message);
  28789. private static _ErrorDisabled(message);
  28790. private static _ErrorEnabled(message);
  28791. static Log: (message: string) => void;
  28792. static Warn: (message: string) => void;
  28793. static Error: (message: string) => void;
  28794. static readonly LogCache: string;
  28795. static ClearLogCache(): void;
  28796. static LogLevels: number;
  28797. static IsWindowObjectExist(): boolean;
  28798. private static _PerformanceNoneLogLevel;
  28799. private static _PerformanceUserMarkLogLevel;
  28800. private static _PerformanceConsoleLogLevel;
  28801. private static _performance;
  28802. static readonly PerformanceNoneLogLevel: number;
  28803. static readonly PerformanceUserMarkLogLevel: number;
  28804. static readonly PerformanceConsoleLogLevel: number;
  28805. static PerformanceLogLevel: number;
  28806. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28807. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28808. static _StartUserMark(counterName: string, condition?: boolean): void;
  28809. static _EndUserMark(counterName: string, condition?: boolean): void;
  28810. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28811. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28812. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28813. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28814. static readonly Now: number;
  28815. /**
  28816. * This method will return the name of the class used to create the instance of the given object.
  28817. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28818. * @param object the object to get the class name from
  28819. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28820. */
  28821. static GetClassName(object: any, isType?: boolean): string;
  28822. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28823. /**
  28824. * This method will return the name of the full name of the class, including its owning module (if any).
  28825. * 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).
  28826. * @param object the object to get the class name from
  28827. * @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.
  28828. */
  28829. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28830. /**
  28831. * 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.
  28832. * @param array
  28833. */
  28834. static arrayOrStringFeeder(array: any): (i: number) => number;
  28835. /**
  28836. * Compute the hashCode of a stream of number
  28837. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28838. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28839. * @return the hash code computed
  28840. */
  28841. static hashCodeFromStream(feeder: (index: number) => number): number;
  28842. /**
  28843. * Returns a promise that resolves after the given amount of time.
  28844. * @param delay Number of milliseconds to delay
  28845. * @returns Promise that resolves after the given amount of time
  28846. */
  28847. static DelayAsync(delay: number): Promise<void>;
  28848. }
  28849. /**
  28850. * This class is used to track a performance counter which is number based.
  28851. * The user has access to many properties which give statistics of different nature
  28852. *
  28853. * The implementer can track two kinds of Performance Counter: time and count
  28854. * 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.
  28855. * 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.
  28856. */
  28857. class PerfCounter {
  28858. static Enabled: boolean;
  28859. /**
  28860. * Returns the smallest value ever
  28861. */
  28862. readonly min: number;
  28863. /**
  28864. * Returns the biggest value ever
  28865. */
  28866. readonly max: number;
  28867. /**
  28868. * Returns the average value since the performance counter is running
  28869. */
  28870. readonly average: number;
  28871. /**
  28872. * Returns the average value of the last second the counter was monitored
  28873. */
  28874. readonly lastSecAverage: number;
  28875. /**
  28876. * Returns the current value
  28877. */
  28878. readonly current: number;
  28879. readonly total: number;
  28880. readonly count: number;
  28881. constructor();
  28882. /**
  28883. * Call this method to start monitoring a new frame.
  28884. * 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.
  28885. */
  28886. fetchNewFrame(): void;
  28887. /**
  28888. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28889. * @param newCount the count value to add to the monitored count
  28890. * @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.
  28891. */
  28892. addCount(newCount: number, fetchResult: boolean): void;
  28893. /**
  28894. * Start monitoring this performance counter
  28895. */
  28896. beginMonitoring(): void;
  28897. /**
  28898. * Compute the time lapsed since the previous beginMonitoring() call.
  28899. * @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
  28900. */
  28901. endMonitoring(newFrame?: boolean): void;
  28902. private _fetchResult();
  28903. private _startMonitoringTime;
  28904. private _min;
  28905. private _max;
  28906. private _average;
  28907. private _current;
  28908. private _totalValueCount;
  28909. private _totalAccumulated;
  28910. private _lastSecAverage;
  28911. private _lastSecAccumulated;
  28912. private _lastSecTime;
  28913. private _lastSecValueCount;
  28914. }
  28915. /**
  28916. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28917. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28918. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28919. * @param name The name of the class, case should be preserved
  28920. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28921. */
  28922. function className(name: string, module?: string): (target: Object) => void;
  28923. /**
  28924. * An implementation of a loop for asynchronous functions.
  28925. */
  28926. class AsyncLoop {
  28927. iterations: number;
  28928. private _fn;
  28929. private _successCallback;
  28930. index: number;
  28931. private _done;
  28932. /**
  28933. * Constroctor.
  28934. * @param iterations the number of iterations.
  28935. * @param _fn the function to run each iteration
  28936. * @param _successCallback the callback that will be called upon succesful execution
  28937. * @param offset starting offset.
  28938. */
  28939. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28940. /**
  28941. * Execute the next iteration. Must be called after the last iteration was finished.
  28942. */
  28943. executeNext(): void;
  28944. /**
  28945. * Break the loop and run the success callback.
  28946. */
  28947. breakLoop(): void;
  28948. /**
  28949. * Helper function
  28950. */
  28951. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28952. /**
  28953. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28954. * @param iterations total number of iterations
  28955. * @param syncedIterations number of synchronous iterations in each async iteration.
  28956. * @param fn the function to call each iteration.
  28957. * @param callback a success call back that will be called when iterating stops.
  28958. * @param breakFunction a break condition (optional)
  28959. * @param timeout timeout settings for the setTimeout function. default - 0.
  28960. * @constructor
  28961. */
  28962. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28963. }
  28964. }
  28965. declare module BABYLON {
  28966. /**
  28967. * Defines the potential axis of a Joystick
  28968. */
  28969. enum JoystickAxis {
  28970. /** X axis */
  28971. X = 0,
  28972. /** Y axis */
  28973. Y = 1,
  28974. /** Z axis */
  28975. Z = 2,
  28976. }
  28977. /**
  28978. * Class used to define virtual joystick (used in touch mode)
  28979. */
  28980. class VirtualJoystick {
  28981. /**
  28982. * Gets or sets a boolean indicating that left and right values must be inverted
  28983. */
  28984. reverseLeftRight: boolean;
  28985. /**
  28986. * Gets or sets a boolean indicating that up and down values must be inverted
  28987. */
  28988. reverseUpDown: boolean;
  28989. /**
  28990. * Gets the offset value for the position (ie. the change of the position value)
  28991. */
  28992. deltaPosition: Vector3;
  28993. /**
  28994. * Gets a boolean indicating if the virtual joystick was pressed
  28995. */
  28996. pressed: boolean;
  28997. private static _globalJoystickIndex;
  28998. private static vjCanvas;
  28999. private static vjCanvasContext;
  29000. private static vjCanvasWidth;
  29001. private static vjCanvasHeight;
  29002. private static halfWidth;
  29003. private _action;
  29004. private _axisTargetedByLeftAndRight;
  29005. private _axisTargetedByUpAndDown;
  29006. private _joystickSensibility;
  29007. private _inversedSensibility;
  29008. private _joystickPointerID;
  29009. private _joystickColor;
  29010. private _joystickPointerPos;
  29011. private _joystickPreviousPointerPos;
  29012. private _joystickPointerStartPos;
  29013. private _deltaJoystickVector;
  29014. private _leftJoystick;
  29015. private _touches;
  29016. private _onPointerDownHandlerRef;
  29017. private _onPointerMoveHandlerRef;
  29018. private _onPointerUpHandlerRef;
  29019. private _onResize;
  29020. /**
  29021. * Creates a new virtual joystick
  29022. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29023. */
  29024. constructor(leftJoystick?: boolean);
  29025. /**
  29026. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29027. * @param newJoystickSensibility defines the new sensibility
  29028. */
  29029. setJoystickSensibility(newJoystickSensibility: number): void;
  29030. private _onPointerDown(e);
  29031. private _onPointerMove(e);
  29032. private _onPointerUp(e);
  29033. /**
  29034. * Change the color of the virtual joystick
  29035. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29036. */
  29037. setJoystickColor(newColor: string): void;
  29038. /**
  29039. * Defines a callback to call when the joystick is touched
  29040. * @param action defines the callback
  29041. */
  29042. setActionOnTouch(action: () => any): void;
  29043. /**
  29044. * Defines which axis you'd like to control for left & right
  29045. * @param axis defines the axis to use
  29046. */
  29047. setAxisForLeftRight(axis: JoystickAxis): void;
  29048. /**
  29049. * Defines which axis you'd like to control for up & down
  29050. * @param axis defines the axis to use
  29051. */
  29052. setAxisForUpDown(axis: JoystickAxis): void;
  29053. private _drawVirtualJoystick();
  29054. /**
  29055. * Release internal HTML canvas
  29056. */
  29057. releaseCanvas(): void;
  29058. }
  29059. }
  29060. declare module BABYLON {
  29061. /**
  29062. * Helper class to push actions to a pool of workers.
  29063. */
  29064. class WorkerPool implements IDisposable {
  29065. private _workerInfos;
  29066. private _pendingActions;
  29067. /**
  29068. * Constructor
  29069. * @param workers Array of workers to use for actions
  29070. */
  29071. constructor(workers: Array<Worker>);
  29072. /**
  29073. * Terminates all workers and clears any pending actions.
  29074. */
  29075. dispose(): void;
  29076. /**
  29077. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29078. * pended until a worker has completed its action.
  29079. * @param action The action to perform. Call onComplete when the action is complete.
  29080. */
  29081. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29082. private _execute(workerInfo, action);
  29083. }
  29084. }
  29085. declare module BABYLON {
  29086. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29087. readonly name: string;
  29088. private _zoomStopsAnimation;
  29089. private _idleRotationSpeed;
  29090. private _idleRotationWaitTime;
  29091. private _idleRotationSpinupTime;
  29092. /**
  29093. * Gets the flag that indicates if user zooming should stop animation.
  29094. */
  29095. /**
  29096. * Sets the flag that indicates if user zooming should stop animation.
  29097. */
  29098. zoomStopsAnimation: boolean;
  29099. /**
  29100. * Gets the default speed at which the camera rotates around the model.
  29101. */
  29102. /**
  29103. * Sets the default speed at which the camera rotates around the model.
  29104. */
  29105. idleRotationSpeed: number;
  29106. /**
  29107. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29108. */
  29109. /**
  29110. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29111. */
  29112. idleRotationWaitTime: number;
  29113. /**
  29114. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29115. */
  29116. /**
  29117. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29118. */
  29119. idleRotationSpinupTime: number;
  29120. /**
  29121. * Gets a value indicating if the camera is currently rotating because of this behavior
  29122. */
  29123. readonly rotationInProgress: boolean;
  29124. private _onPrePointerObservableObserver;
  29125. private _onAfterCheckInputsObserver;
  29126. private _attachedCamera;
  29127. private _isPointerDown;
  29128. private _lastFrameTime;
  29129. private _lastInteractionTime;
  29130. private _cameraRotationSpeed;
  29131. init(): void;
  29132. attach(camera: ArcRotateCamera): void;
  29133. detach(): void;
  29134. /**
  29135. * Returns true if user is scrolling.
  29136. * @return true if user is scrolling.
  29137. */
  29138. private _userIsZooming();
  29139. private _lastFrameRadius;
  29140. private _shouldAnimationStopForInteraction();
  29141. /**
  29142. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29143. */
  29144. private _applyUserInteraction();
  29145. private _userIsMoving();
  29146. }
  29147. }
  29148. declare module BABYLON {
  29149. /**
  29150. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29151. */
  29152. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29153. readonly name: string;
  29154. /**
  29155. * The easing function used by animations
  29156. */
  29157. static EasingFunction: BackEase;
  29158. /**
  29159. * The easing mode used by animations
  29160. */
  29161. static EasingMode: number;
  29162. /**
  29163. * The duration of the animation, in milliseconds
  29164. */
  29165. transitionDuration: number;
  29166. /**
  29167. * Length of the distance animated by the transition when lower radius is reached
  29168. */
  29169. lowerRadiusTransitionRange: number;
  29170. /**
  29171. * Length of the distance animated by the transition when upper radius is reached
  29172. */
  29173. upperRadiusTransitionRange: number;
  29174. private _autoTransitionRange;
  29175. /**
  29176. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29177. */
  29178. /**
  29179. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29180. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29181. */
  29182. autoTransitionRange: boolean;
  29183. private _attachedCamera;
  29184. private _onAfterCheckInputsObserver;
  29185. private _onMeshTargetChangedObserver;
  29186. init(): void;
  29187. attach(camera: ArcRotateCamera): void;
  29188. detach(): void;
  29189. private _radiusIsAnimating;
  29190. private _radiusBounceTransition;
  29191. private _animatables;
  29192. private _cachedWheelPrecision;
  29193. /**
  29194. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29195. * @param radiusLimit The limit to check against.
  29196. * @return Bool to indicate if at limit.
  29197. */
  29198. private _isRadiusAtLimit(radiusLimit);
  29199. /**
  29200. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29201. * @param radiusDelta The delta by which to animate to. Can be negative.
  29202. */
  29203. private _applyBoundRadiusAnimation(radiusDelta);
  29204. /**
  29205. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29206. */
  29207. protected _clearAnimationLocks(): void;
  29208. /**
  29209. * Stops and removes all animations that have been applied to the camera
  29210. */
  29211. stopAllAnimations(): void;
  29212. }
  29213. }
  29214. declare module BABYLON {
  29215. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29216. readonly name: string;
  29217. private _mode;
  29218. private _radiusScale;
  29219. private _positionScale;
  29220. private _defaultElevation;
  29221. private _elevationReturnTime;
  29222. private _elevationReturnWaitTime;
  29223. private _zoomStopsAnimation;
  29224. private _framingTime;
  29225. /**
  29226. * The easing function used by animations
  29227. */
  29228. static EasingFunction: ExponentialEase;
  29229. /**
  29230. * The easing mode used by animations
  29231. */
  29232. static EasingMode: number;
  29233. /**
  29234. * Gets current mode used by the behavior.
  29235. */
  29236. /**
  29237. * Sets the current mode used by the behavior
  29238. */
  29239. mode: number;
  29240. /**
  29241. * Gets the scale applied to the radius
  29242. */
  29243. /**
  29244. * Sets the scale applied to the radius (1 by default)
  29245. */
  29246. radiusScale: number;
  29247. /**
  29248. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29249. */
  29250. /**
  29251. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29252. */
  29253. positionScale: number;
  29254. /**
  29255. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29256. * behaviour is triggered, in radians.
  29257. */
  29258. /**
  29259. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29260. * behaviour is triggered, in radians.
  29261. */
  29262. defaultElevation: number;
  29263. /**
  29264. * Gets the time (in milliseconds) taken to return to the default beta position.
  29265. * Negative value indicates camera should not return to default.
  29266. */
  29267. /**
  29268. * Sets the time (in milliseconds) taken to return to the default beta position.
  29269. * Negative value indicates camera should not return to default.
  29270. */
  29271. elevationReturnTime: number;
  29272. /**
  29273. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29274. */
  29275. /**
  29276. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29277. */
  29278. elevationReturnWaitTime: number;
  29279. /**
  29280. * Gets the flag that indicates if user zooming should stop animation.
  29281. */
  29282. /**
  29283. * Sets the flag that indicates if user zooming should stop animation.
  29284. */
  29285. zoomStopsAnimation: boolean;
  29286. /**
  29287. * Gets the transition time when framing the mesh, in milliseconds
  29288. */
  29289. /**
  29290. * Sets the transition time when framing the mesh, in milliseconds
  29291. */
  29292. framingTime: number;
  29293. private _onPrePointerObservableObserver;
  29294. private _onAfterCheckInputsObserver;
  29295. private _onMeshTargetChangedObserver;
  29296. private _attachedCamera;
  29297. private _isPointerDown;
  29298. private _lastInteractionTime;
  29299. init(): void;
  29300. attach(camera: ArcRotateCamera): void;
  29301. detach(): void;
  29302. private _animatables;
  29303. private _betaIsAnimating;
  29304. private _betaTransition;
  29305. private _radiusTransition;
  29306. private _vectorTransition;
  29307. /**
  29308. * Targets the given mesh and updates zoom level accordingly.
  29309. * @param mesh The mesh to target.
  29310. * @param radius Optional. If a cached radius position already exists, overrides default.
  29311. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29312. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29313. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29314. */
  29315. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29316. /**
  29317. * Targets the given mesh with its children and updates zoom level accordingly.
  29318. * @param mesh The mesh to target.
  29319. * @param radius Optional. If a cached radius position already exists, overrides default.
  29320. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29321. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29322. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29323. */
  29324. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29325. /**
  29326. * Targets the given meshes with their children and updates zoom level accordingly.
  29327. * @param meshes The mesh to target.
  29328. * @param radius Optional. If a cached radius position already exists, overrides default.
  29329. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29330. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29331. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29332. */
  29333. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29334. /**
  29335. * Targets the given mesh and updates zoom level accordingly.
  29336. * @param mesh The mesh to target.
  29337. * @param radius Optional. If a cached radius position already exists, overrides default.
  29338. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29339. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29340. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29341. */
  29342. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29343. /**
  29344. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29345. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29346. * frustum width.
  29347. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29348. * to fully enclose the mesh in the viewing frustum.
  29349. */
  29350. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29351. /**
  29352. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29353. * is automatically returned to its default position (expected to be above ground plane).
  29354. */
  29355. private _maintainCameraAboveGround();
  29356. /**
  29357. * Returns the frustum slope based on the canvas ratio and camera FOV
  29358. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29359. */
  29360. private _getFrustumSlope();
  29361. /**
  29362. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29363. */
  29364. private _clearAnimationLocks();
  29365. /**
  29366. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29367. */
  29368. private _applyUserInteraction();
  29369. /**
  29370. * Stops and removes all animations that have been applied to the camera
  29371. */
  29372. stopAllAnimations(): void;
  29373. /**
  29374. * Gets a value indicating if the user is moving the camera
  29375. */
  29376. readonly isUserIsMoving: boolean;
  29377. /**
  29378. * The camera can move all the way towards the mesh.
  29379. */
  29380. static IgnoreBoundsSizeMode: number;
  29381. /**
  29382. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29383. */
  29384. static FitFrustumSidesMode: number;
  29385. }
  29386. }
  29387. declare module BABYLON {
  29388. interface IOctreeContainer<T> {
  29389. blocks: Array<OctreeBlock<T>>;
  29390. }
  29391. class Octree<T> {
  29392. maxDepth: number;
  29393. blocks: Array<OctreeBlock<T>>;
  29394. dynamicContent: T[];
  29395. private _maxBlockCapacity;
  29396. private _selectionContent;
  29397. private _creationFunc;
  29398. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29399. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29400. addMesh(entry: T): void;
  29401. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29402. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29403. intersectsRay(ray: Ray): SmartArray<T>;
  29404. 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;
  29405. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29406. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29407. }
  29408. }
  29409. declare module BABYLON {
  29410. class OctreeBlock<T> {
  29411. entries: T[];
  29412. blocks: Array<OctreeBlock<T>>;
  29413. private _depth;
  29414. private _maxDepth;
  29415. private _capacity;
  29416. private _minPoint;
  29417. private _maxPoint;
  29418. private _boundingVectors;
  29419. private _creationFunc;
  29420. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29421. readonly capacity: number;
  29422. readonly minPoint: Vector3;
  29423. readonly maxPoint: Vector3;
  29424. addEntry(entry: T): void;
  29425. addEntries(entries: T[]): void;
  29426. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29427. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29428. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29429. createInnerBlocks(): void;
  29430. }
  29431. }
  29432. declare module BABYLON {
  29433. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29434. camera: ArcRotateCamera;
  29435. gamepad: Nullable<Gamepad>;
  29436. private _onGamepadConnectedObserver;
  29437. private _onGamepadDisconnectedObserver;
  29438. gamepadRotationSensibility: number;
  29439. gamepadMoveSensibility: number;
  29440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29441. detachControl(element: Nullable<HTMLElement>): void;
  29442. checkInputs(): void;
  29443. getClassName(): string;
  29444. getSimpleName(): string;
  29445. }
  29446. }
  29447. declare module BABYLON {
  29448. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29449. camera: ArcRotateCamera;
  29450. private _keys;
  29451. keysUp: number[];
  29452. keysDown: number[];
  29453. keysLeft: number[];
  29454. keysRight: number[];
  29455. keysReset: number[];
  29456. panningSensibility: number;
  29457. zoomingSensibility: number;
  29458. useAltToZoom: boolean;
  29459. private _ctrlPressed;
  29460. private _altPressed;
  29461. private _onCanvasBlurObserver;
  29462. private _onKeyboardObserver;
  29463. private _engine;
  29464. private _scene;
  29465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29466. detachControl(element: Nullable<HTMLElement>): void;
  29467. checkInputs(): void;
  29468. getClassName(): string;
  29469. getSimpleName(): string;
  29470. }
  29471. }
  29472. declare module BABYLON {
  29473. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29474. camera: ArcRotateCamera;
  29475. private _wheel;
  29476. private _observer;
  29477. wheelPrecision: number;
  29478. /**
  29479. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29480. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29481. */
  29482. wheelDeltaPercentage: number;
  29483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29484. detachControl(element: Nullable<HTMLElement>): void;
  29485. getClassName(): string;
  29486. getSimpleName(): string;
  29487. }
  29488. }
  29489. declare module BABYLON {
  29490. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29491. camera: ArcRotateCamera;
  29492. buttons: number[];
  29493. angularSensibilityX: number;
  29494. angularSensibilityY: number;
  29495. pinchPrecision: number;
  29496. /**
  29497. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29498. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29499. */
  29500. pinchDeltaPercentage: number;
  29501. panningSensibility: number;
  29502. multiTouchPanning: boolean;
  29503. multiTouchPanAndZoom: boolean;
  29504. private _isPanClick;
  29505. pinchInwards: boolean;
  29506. private _pointerInput;
  29507. private _observer;
  29508. private _onMouseMove;
  29509. private _onGestureStart;
  29510. private _onGesture;
  29511. private _MSGestureHandler;
  29512. private _onLostFocus;
  29513. private _onContextMenu;
  29514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29515. detachControl(element: Nullable<HTMLElement>): void;
  29516. getClassName(): string;
  29517. getSimpleName(): string;
  29518. }
  29519. }
  29520. declare module BABYLON {
  29521. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29522. camera: ArcRotateCamera;
  29523. alphaCorrection: number;
  29524. betaCorrection: number;
  29525. gammaCorrection: number;
  29526. private _alpha;
  29527. private _gamma;
  29528. private _dirty;
  29529. private _deviceOrientationHandler;
  29530. constructor();
  29531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29532. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29533. checkInputs(): void;
  29534. detachControl(element: Nullable<HTMLElement>): void;
  29535. getClassName(): string;
  29536. getSimpleName(): string;
  29537. }
  29538. }
  29539. declare module BABYLON {
  29540. /**
  29541. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29542. * Screen rotation is taken into account.
  29543. */
  29544. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29545. private _camera;
  29546. private _screenOrientationAngle;
  29547. private _constantTranform;
  29548. private _screenQuaternion;
  29549. private _alpha;
  29550. private _beta;
  29551. private _gamma;
  29552. constructor();
  29553. camera: FreeCamera;
  29554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29555. private _orientationChanged;
  29556. private _deviceOrientation;
  29557. detachControl(element: Nullable<HTMLElement>): void;
  29558. checkInputs(): void;
  29559. getClassName(): string;
  29560. getSimpleName(): string;
  29561. }
  29562. }
  29563. declare module BABYLON {
  29564. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29565. camera: FreeCamera;
  29566. gamepad: Nullable<Gamepad>;
  29567. private _onGamepadConnectedObserver;
  29568. private _onGamepadDisconnectedObserver;
  29569. gamepadAngularSensibility: number;
  29570. gamepadMoveSensibility: number;
  29571. private _cameraTransform;
  29572. private _deltaTransform;
  29573. private _vector3;
  29574. private _vector2;
  29575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29576. detachControl(element: Nullable<HTMLElement>): void;
  29577. checkInputs(): void;
  29578. getClassName(): string;
  29579. getSimpleName(): string;
  29580. }
  29581. }
  29582. declare module BABYLON {
  29583. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29584. camera: FreeCamera;
  29585. private _keys;
  29586. private _onCanvasBlurObserver;
  29587. private _onKeyboardObserver;
  29588. private _engine;
  29589. private _scene;
  29590. keysUp: number[];
  29591. keysDown: number[];
  29592. keysLeft: number[];
  29593. keysRight: number[];
  29594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29595. detachControl(element: Nullable<HTMLElement>): void;
  29596. checkInputs(): void;
  29597. getClassName(): string;
  29598. _onLostFocus(e: FocusEvent): void;
  29599. getSimpleName(): string;
  29600. }
  29601. }
  29602. declare module BABYLON {
  29603. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29604. touchEnabled: boolean;
  29605. camera: FreeCamera;
  29606. buttons: number[];
  29607. angularSensibility: number;
  29608. private _pointerInput;
  29609. private _onMouseMove;
  29610. private _observer;
  29611. private previousPosition;
  29612. constructor(touchEnabled?: boolean);
  29613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29614. detachControl(element: Nullable<HTMLElement>): void;
  29615. getClassName(): string;
  29616. getSimpleName(): string;
  29617. }
  29618. }
  29619. declare module BABYLON {
  29620. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29621. camera: FreeCamera;
  29622. private _offsetX;
  29623. private _offsetY;
  29624. private _pointerPressed;
  29625. private _pointerInput;
  29626. private _observer;
  29627. private _onLostFocus;
  29628. touchAngularSensibility: number;
  29629. touchMoveSensibility: number;
  29630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29631. detachControl(element: Nullable<HTMLElement>): void;
  29632. checkInputs(): void;
  29633. getClassName(): string;
  29634. getSimpleName(): string;
  29635. }
  29636. }
  29637. declare module BABYLON {
  29638. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29639. camera: FreeCamera;
  29640. private _leftjoystick;
  29641. private _rightjoystick;
  29642. getLeftJoystick(): VirtualJoystick;
  29643. getRightJoystick(): VirtualJoystick;
  29644. checkInputs(): void;
  29645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29646. detachControl(element: Nullable<HTMLElement>): void;
  29647. getClassName(): string;
  29648. getSimpleName(): string;
  29649. }
  29650. }
  29651. declare module BABYLON {
  29652. class VRCameraMetrics {
  29653. hResolution: number;
  29654. vResolution: number;
  29655. hScreenSize: number;
  29656. vScreenSize: number;
  29657. vScreenCenter: number;
  29658. eyeToScreenDistance: number;
  29659. lensSeparationDistance: number;
  29660. interpupillaryDistance: number;
  29661. distortionK: number[];
  29662. chromaAbCorrection: number[];
  29663. postProcessScaleFactor: number;
  29664. lensCenterOffset: number;
  29665. compensateDistortion: boolean;
  29666. readonly aspectRatio: number;
  29667. readonly aspectRatioFov: number;
  29668. readonly leftHMatrix: Matrix;
  29669. readonly rightHMatrix: Matrix;
  29670. readonly leftPreViewMatrix: Matrix;
  29671. readonly rightPreViewMatrix: Matrix;
  29672. static GetDefault(): VRCameraMetrics;
  29673. }
  29674. }
  29675. declare module BABYLON {
  29676. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29677. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29678. getClassName(): string;
  29679. }
  29680. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29681. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29682. getClassName(): string;
  29683. }
  29684. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29685. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29686. getClassName(): string;
  29687. }
  29688. }
  29689. declare module BABYLON {
  29690. /**
  29691. * Options to modify the vr teleportation behavior.
  29692. */
  29693. interface VRTeleportationOptions {
  29694. /**
  29695. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29696. */
  29697. floorMeshName?: string;
  29698. /**
  29699. * A list of meshes to be used as the teleportation floor. (default: empty)
  29700. */
  29701. floorMeshes?: Mesh[];
  29702. }
  29703. /**
  29704. * Options to modify the vr experience helper's behavior.
  29705. */
  29706. interface VRExperienceHelperOptions extends WebVROptions {
  29707. /**
  29708. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  29709. */
  29710. createDeviceOrientationCamera?: boolean;
  29711. /**
  29712. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  29713. */
  29714. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29715. /**
  29716. * Uses the main button on the controller to toggle the laser casted. (default: true)
  29717. */
  29718. laserToggle?: boolean;
  29719. /**
  29720. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  29721. */
  29722. floorMeshes?: Mesh[];
  29723. }
  29724. /**
  29725. * Helps to quickly add VR support to an existing scene.
  29726. * See http://doc.babylonjs.com/how_to/webvr_helper
  29727. */
  29728. class VRExperienceHelper {
  29729. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29730. private _scene;
  29731. private _position;
  29732. private _btnVR;
  29733. private _btnVRDisplayed;
  29734. private _webVRsupported;
  29735. private _webVRready;
  29736. private _webVRrequesting;
  29737. private _webVRpresenting;
  29738. private _fullscreenVRpresenting;
  29739. private _canvas;
  29740. private _webVRCamera;
  29741. private _vrDeviceOrientationCamera;
  29742. private _deviceOrientationCamera;
  29743. private _existingCamera;
  29744. private _onKeyDown;
  29745. private _onVrDisplayPresentChange;
  29746. private _onVRDisplayChanged;
  29747. private _onVRRequestPresentStart;
  29748. private _onVRRequestPresentComplete;
  29749. /**
  29750. * Observable raised when entering VR.
  29751. */
  29752. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29753. /**
  29754. * Observable raised when exiting VR.
  29755. */
  29756. onExitingVRObservable: Observable<VRExperienceHelper>;
  29757. /**
  29758. * Observable raised when controller mesh is loaded.
  29759. */
  29760. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29761. /** Return this.onEnteringVRObservable
  29762. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29763. */
  29764. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29765. /** Return this.onExitingVRObservable
  29766. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29767. */
  29768. readonly onExitingVR: Observable<VRExperienceHelper>;
  29769. /** Return this.onControllerMeshLoadedObservable
  29770. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29771. */
  29772. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29773. private _rayLength;
  29774. private _useCustomVRButton;
  29775. private _teleportationRequested;
  29776. private _teleportActive;
  29777. private _floorMeshName;
  29778. private _floorMeshesCollection;
  29779. private _rotationAllowed;
  29780. private _teleportBackwardsVector;
  29781. private _teleportationTarget;
  29782. private _isDefaultTeleportationTarget;
  29783. private _postProcessMove;
  29784. private _teleportationFillColor;
  29785. private _teleportationBorderColor;
  29786. private _rotationAngle;
  29787. private _haloCenter;
  29788. private _cameraGazer;
  29789. private _padSensibilityUp;
  29790. private _padSensibilityDown;
  29791. private leftController;
  29792. private rightController;
  29793. /**
  29794. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29795. */
  29796. onNewMeshSelected: Observable<AbstractMesh>;
  29797. /**
  29798. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29799. */
  29800. onNewMeshPicked: Observable<PickingInfo>;
  29801. private _circleEase;
  29802. /**
  29803. * Observable raised before camera teleportation
  29804. */
  29805. onBeforeCameraTeleport: Observable<Vector3>;
  29806. /**
  29807. * Observable raised after camera teleportation
  29808. */
  29809. onAfterCameraTeleport: Observable<Vector3>;
  29810. /**
  29811. * Observable raised when current selected mesh gets unselected
  29812. */
  29813. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29814. private _raySelectionPredicate;
  29815. /**
  29816. * To be optionaly changed by user to define custom ray selection
  29817. */
  29818. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29819. /**
  29820. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29821. */
  29822. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29823. /**
  29824. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29825. */
  29826. teleportationEnabled: boolean;
  29827. private _defaultHeight;
  29828. private _teleportationInitialized;
  29829. private _interactionsEnabled;
  29830. private _interactionsRequested;
  29831. private _displayGaze;
  29832. private _displayLaserPointer;
  29833. /**
  29834. * The mesh used to display where the user is going to teleport.
  29835. */
  29836. /**
  29837. * Sets the mesh to be used to display where the user is going to teleport.
  29838. */
  29839. teleportationTarget: Mesh;
  29840. /**
  29841. * The mesh used to display where the user is selecting,
  29842. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29843. * See http://doc.babylonjs.com/resources/baking_transformations
  29844. */
  29845. gazeTrackerMesh: Mesh;
  29846. /**
  29847. * If the ray of the gaze should be displayed.
  29848. */
  29849. /**
  29850. * Sets if the ray of the gaze should be displayed.
  29851. */
  29852. displayGaze: boolean;
  29853. /**
  29854. * If the ray of the LaserPointer should be displayed.
  29855. */
  29856. /**
  29857. * Sets if the ray of the LaserPointer should be displayed.
  29858. */
  29859. displayLaserPointer: boolean;
  29860. /**
  29861. * The deviceOrientationCamera used as the camera when not in VR.
  29862. */
  29863. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29864. /**
  29865. * Based on the current WebVR support, returns the current VR camera used.
  29866. */
  29867. readonly currentVRCamera: Nullable<Camera>;
  29868. /**
  29869. * The webVRCamera which is used when in VR.
  29870. */
  29871. readonly webVRCamera: WebVRFreeCamera;
  29872. /**
  29873. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29874. */
  29875. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29876. private readonly _teleportationRequestInitiated;
  29877. /**
  29878. * Instantiates a VRExperienceHelper.
  29879. * Helps to quickly add VR support to an existing scene.
  29880. * @param scene The scene the VRExperienceHelper belongs to.
  29881. * @param webVROptions Options to modify the vr experience helper's behavior.
  29882. */
  29883. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29884. private _onDefaultMeshLoaded(webVRController);
  29885. private _onResize;
  29886. private _onFullscreenChange;
  29887. /**
  29888. * Gets a value indicating if we are currently in VR mode.
  29889. */
  29890. readonly isInVRMode: boolean;
  29891. private onVrDisplayPresentChange();
  29892. private onVRDisplayChanged(eventArgs);
  29893. private moveButtonToBottomRight();
  29894. private displayVRButton();
  29895. private updateButtonVisibility();
  29896. /**
  29897. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29898. * Otherwise, will use the fullscreen API.
  29899. */
  29900. enterVR(): void;
  29901. /**
  29902. * Attempt to exit VR, or fullscreen.
  29903. */
  29904. exitVR(): void;
  29905. /**
  29906. * The position of the vr experience helper.
  29907. */
  29908. /**
  29909. * Sets the position of the vr experience helper.
  29910. */
  29911. position: Vector3;
  29912. /**
  29913. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29914. */
  29915. enableInteractions(): void;
  29916. private beforeRender;
  29917. private _isTeleportationFloor(mesh);
  29918. /**
  29919. * Adds a floor mesh to be used for teleportation.
  29920. * @param floorMesh the mesh to be used for teleportation.
  29921. */
  29922. addFloorMesh(floorMesh: Mesh): void;
  29923. /**
  29924. * Removes a floor mesh from being used for teleportation.
  29925. * @param floorMesh the mesh to be removed.
  29926. */
  29927. removeFloorMesh(floorMesh: Mesh): void;
  29928. /**
  29929. * Enables interactions and teleportation using the VR controllers and gaze.
  29930. * @param vrTeleportationOptions options to modify teleportation behavior.
  29931. */
  29932. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29933. private _onNewGamepadConnected;
  29934. private _tryEnableInteractionOnController;
  29935. private _onNewGamepadDisconnected;
  29936. private _enableInteractionOnController(controller);
  29937. private _checkTeleportWithRay(stateObject, gazer);
  29938. private _checkRotate(stateObject, gazer);
  29939. private _checkTeleportBackwards(stateObject, gazer);
  29940. private _enableTeleportationOnController(controller);
  29941. private _createTeleportationCircles();
  29942. private _displayTeleportationTarget();
  29943. private _hideTeleportationTarget();
  29944. private _rotateCamera(right);
  29945. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29946. private _workingVector;
  29947. private _workingQuaternion;
  29948. private _workingMatrix;
  29949. private _teleportCamera(location);
  29950. private _convertNormalToDirectionOfRay(normal, ray);
  29951. private _castRayAndSelectObject(gazer);
  29952. private _notifySelectedMeshUnselected(mesh);
  29953. /**
  29954. * Sets the color of the laser ray from the vr controllers.
  29955. * @param color new color for the ray.
  29956. */
  29957. changeLaserColor(color: Color3): void;
  29958. /**
  29959. * Sets the color of the ray from the vr headsets gaze.
  29960. * @param color new color for the ray.
  29961. */
  29962. changeGazeColor(color: Color3): void;
  29963. /**
  29964. * Exits VR and disposes of the vr experience helper
  29965. */
  29966. dispose(): void;
  29967. /**
  29968. * Gets the name of the VRExperienceHelper class
  29969. * @returns "VRExperienceHelper"
  29970. */
  29971. getClassName(): string;
  29972. }
  29973. }
  29974. declare module BABYLON {
  29975. /**
  29976. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29977. * IMPORTANT!! The data is right-hand data.
  29978. * @export
  29979. * @interface DevicePose
  29980. */
  29981. interface DevicePose {
  29982. /**
  29983. * The position of the device, values in array are [x,y,z].
  29984. */
  29985. readonly position: Nullable<Float32Array>;
  29986. /**
  29987. * The linearVelocity of the device, values in array are [x,y,z].
  29988. */
  29989. readonly linearVelocity: Nullable<Float32Array>;
  29990. /**
  29991. * The linearAcceleration of the device, values in array are [x,y,z].
  29992. */
  29993. readonly linearAcceleration: Nullable<Float32Array>;
  29994. /**
  29995. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29996. */
  29997. readonly orientation: Nullable<Float32Array>;
  29998. /**
  29999. * The angularVelocity of the device, values in array are [x,y,z].
  30000. */
  30001. readonly angularVelocity: Nullable<Float32Array>;
  30002. /**
  30003. * The angularAcceleration of the device, values in array are [x,y,z].
  30004. */
  30005. readonly angularAcceleration: Nullable<Float32Array>;
  30006. }
  30007. /**
  30008. * Interface representing a pose controlled object in Babylon.
  30009. * A pose controlled object has both regular pose values as well as pose values
  30010. * from an external device such as a VR head mounted display
  30011. */
  30012. interface PoseControlled {
  30013. /**
  30014. * The position of the object in babylon space.
  30015. */
  30016. position: Vector3;
  30017. /**
  30018. * The rotation quaternion of the object in babylon space.
  30019. */
  30020. rotationQuaternion: Quaternion;
  30021. /**
  30022. * The position of the device in babylon space.
  30023. */
  30024. devicePosition?: Vector3;
  30025. /**
  30026. * The rotation quaternion of the device in babylon space.
  30027. */
  30028. deviceRotationQuaternion: Quaternion;
  30029. /**
  30030. * The raw pose coming from the device.
  30031. */
  30032. rawPose: Nullable<DevicePose>;
  30033. /**
  30034. * The scale of the device to be used when translating from device space to babylon space.
  30035. */
  30036. deviceScaleFactor: number;
  30037. /**
  30038. * Updates the poseControlled values based on the input device pose.
  30039. * @param poseData the pose data to update the object with
  30040. */
  30041. updateFromDevice(poseData: DevicePose): void;
  30042. }
  30043. /**
  30044. * Set of options to customize the webVRCamera
  30045. */
  30046. interface WebVROptions {
  30047. /**
  30048. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  30049. */
  30050. trackPosition?: boolean;
  30051. /**
  30052. * Sets the scale of the vrDevice in babylon space. (default: 1)
  30053. */
  30054. positionScale?: number;
  30055. /**
  30056. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  30057. */
  30058. displayName?: string;
  30059. /**
  30060. * Should the native controller meshes be initialized. (default: true)
  30061. */
  30062. controllerMeshes?: boolean;
  30063. /**
  30064. * Creating a default HemiLight only on controllers. (default: true)
  30065. */
  30066. defaultLightingOnControllers?: boolean;
  30067. /**
  30068. * If you don't want to use the default VR button of the helper. (default: false)
  30069. */
  30070. useCustomVRButton?: boolean;
  30071. /**
  30072. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  30073. */
  30074. customVRButton?: HTMLButtonElement;
  30075. /**
  30076. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  30077. */
  30078. rayLength?: number;
  30079. /**
  30080. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  30081. */
  30082. defaultHeight?: number;
  30083. }
  30084. /**
  30085. * This represents a WebVR camera.
  30086. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  30087. * @example http://doc.babylonjs.com/how_to/webvr_camera
  30088. */
  30089. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  30090. private webVROptions;
  30091. /**
  30092. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  30093. */
  30094. _vrDevice: any;
  30095. /**
  30096. * The rawPose of the vrDevice.
  30097. */
  30098. rawPose: Nullable<DevicePose>;
  30099. private _onVREnabled;
  30100. private _specsVersion;
  30101. private _attached;
  30102. private _frameData;
  30103. protected _descendants: Array<Node>;
  30104. private _deviceRoomPosition;
  30105. private _deviceRoomRotationQuaternion;
  30106. private _standingMatrix;
  30107. /**
  30108. * Represents device position in babylon space.
  30109. */
  30110. devicePosition: Vector3;
  30111. /**
  30112. * Represents device rotation in babylon space.
  30113. */
  30114. deviceRotationQuaternion: Quaternion;
  30115. /**
  30116. * The scale of the device to be used when translating from device space to babylon space.
  30117. */
  30118. deviceScaleFactor: number;
  30119. private _deviceToWorld;
  30120. private _worldToDevice;
  30121. /**
  30122. * References to the webVR controllers for the vrDevice.
  30123. */
  30124. controllers: Array<WebVRController>;
  30125. /**
  30126. * Emits an event when a controller is attached.
  30127. */
  30128. onControllersAttachedObservable: Observable<WebVRController[]>;
  30129. /**
  30130. * Emits an event when a controller's mesh has been loaded;
  30131. */
  30132. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30133. /**
  30134. * If the rig cameras be used as parent instead of this camera.
  30135. */
  30136. rigParenting: boolean;
  30137. private _lightOnControllers;
  30138. private _defaultHeight?;
  30139. /**
  30140. * Instantiates a WebVRFreeCamera.
  30141. * @param name The name of the WebVRFreeCamera
  30142. * @param position The starting anchor position for the camera
  30143. * @param scene The scene the camera belongs to
  30144. * @param webVROptions a set of customizable options for the webVRCamera
  30145. */
  30146. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30147. /**
  30148. * Gets the device distance from the ground in meters.
  30149. * @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.
  30150. */
  30151. deviceDistanceToRoomGround(): number;
  30152. /**
  30153. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30154. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30155. */
  30156. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30157. /**
  30158. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30159. * @returns A promise with a boolean set to if the standing matrix is supported.
  30160. */
  30161. useStandingMatrixAsync(): Promise<boolean>;
  30162. /**
  30163. * Disposes the camera
  30164. */
  30165. dispose(): void;
  30166. /**
  30167. * Gets a vrController by name.
  30168. * @param name The name of the controller to retreive
  30169. * @returns the controller matching the name specified or null if not found
  30170. */
  30171. getControllerByName(name: string): Nullable<WebVRController>;
  30172. private _leftController;
  30173. /**
  30174. * The controller corrisponding to the users left hand.
  30175. */
  30176. readonly leftController: Nullable<WebVRController>;
  30177. private _rightController;
  30178. /**
  30179. * The controller corrisponding to the users right hand.
  30180. */
  30181. readonly rightController: Nullable<WebVRController>;
  30182. /**
  30183. * Casts a ray forward from the vrCamera's gaze.
  30184. * @param length Length of the ray (default: 100)
  30185. * @returns the ray corrisponding to the gaze
  30186. */
  30187. getForwardRay(length?: number): Ray;
  30188. /**
  30189. * Updates the camera based on device's frame data
  30190. */
  30191. _checkInputs(): void;
  30192. /**
  30193. * Updates the poseControlled values based on the input device pose.
  30194. * @param poseData Pose coming from the device
  30195. */
  30196. updateFromDevice(poseData: DevicePose): void;
  30197. /**
  30198. * WebVR's attach control will start broadcasting frames to the device.
  30199. * Note that in certain browsers (chrome for example) this function must be called
  30200. * within a user-interaction callback. Example:
  30201. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30202. *
  30203. * @param element html element to attach the vrDevice to
  30204. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30205. */
  30206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30207. /**
  30208. * Detaches the camera from the html element and disables VR
  30209. *
  30210. * @param element html element to detach from
  30211. */
  30212. detachControl(element: HTMLElement): void;
  30213. /**
  30214. * @returns the name of this class
  30215. */
  30216. getClassName(): string;
  30217. /**
  30218. * Calls resetPose on the vrDisplay
  30219. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30220. */
  30221. resetToCurrentRotation(): void;
  30222. /**
  30223. * Updates the rig cameras (left and right eye)
  30224. */
  30225. _updateRigCameras(): void;
  30226. private _workingVector;
  30227. private _oneVector;
  30228. private _workingMatrix;
  30229. private updateCacheCalled;
  30230. /**
  30231. * Updates the cached values of the camera
  30232. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30233. */
  30234. _updateCache(ignoreParentClass?: boolean): void;
  30235. /**
  30236. * Updates the current device position and rotation in the babylon world
  30237. */
  30238. update(): void;
  30239. /**
  30240. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  30241. * @returns an identity matrix
  30242. */
  30243. _getViewMatrix(): Matrix;
  30244. /**
  30245. * This function is called by the two RIG cameras.
  30246. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  30247. */
  30248. protected _getWebVRViewMatrix(): Matrix;
  30249. protected _getWebVRProjectionMatrix(): Matrix;
  30250. private _onGamepadConnectedObserver;
  30251. private _onGamepadDisconnectedObserver;
  30252. /**
  30253. * Initializes the controllers and their meshes
  30254. */
  30255. initControllers(): void;
  30256. }
  30257. }
  30258. declare module BABYLON {
  30259. /**
  30260. * Google Daydream controller
  30261. */
  30262. class DaydreamController extends WebVRController {
  30263. /**
  30264. * Base Url for the controller model.
  30265. */
  30266. static MODEL_BASE_URL: string;
  30267. /**
  30268. * File name for the controller model.
  30269. */
  30270. static MODEL_FILENAME: string;
  30271. /**
  30272. * Gamepad Id prefix used to identify Daydream Controller.
  30273. */
  30274. static readonly GAMEPAD_ID_PREFIX: string;
  30275. /**
  30276. * Creates a new DaydreamController from a gamepad
  30277. * @param vrGamepad the gamepad that the controller should be created from
  30278. */
  30279. constructor(vrGamepad: any);
  30280. /**
  30281. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30282. * @param scene scene in which to add meshes
  30283. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30284. */
  30285. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30286. /**
  30287. * Called once for each button that changed state since the last frame
  30288. * @param buttonIdx Which button index changed
  30289. * @param state New state of the button
  30290. * @param changes Which properties on the state changed since last frame
  30291. */
  30292. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30293. }
  30294. }
  30295. declare module BABYLON {
  30296. /**
  30297. * Gear VR Controller
  30298. */
  30299. class GearVRController extends WebVRController {
  30300. /**
  30301. * Base Url for the controller model.
  30302. */
  30303. static MODEL_BASE_URL: string;
  30304. /**
  30305. * File name for the controller model.
  30306. */
  30307. static MODEL_FILENAME: string;
  30308. /**
  30309. * Gamepad Id prefix used to identify this controller.
  30310. */
  30311. static readonly GAMEPAD_ID_PREFIX: string;
  30312. private readonly _buttonIndexToObservableNameMap;
  30313. /**
  30314. * Creates a new GearVRController from a gamepad
  30315. * @param vrGamepad the gamepad that the controller should be created from
  30316. */
  30317. constructor(vrGamepad: any);
  30318. /**
  30319. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30320. * @param scene scene in which to add meshes
  30321. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30322. */
  30323. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30324. /**
  30325. * Called once for each button that changed state since the last frame
  30326. * @param buttonIdx Which button index changed
  30327. * @param state New state of the button
  30328. * @param changes Which properties on the state changed since last frame
  30329. */
  30330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30331. }
  30332. }
  30333. declare module BABYLON {
  30334. /**
  30335. * Generic Controller
  30336. */
  30337. class GenericController extends WebVRController {
  30338. /**
  30339. * Base Url for the controller model.
  30340. */
  30341. static readonly MODEL_BASE_URL: string;
  30342. /**
  30343. * File name for the controller model.
  30344. */
  30345. static readonly MODEL_FILENAME: string;
  30346. /**
  30347. * Creates a new GenericController from a gamepad
  30348. * @param vrGamepad the gamepad that the controller should be created from
  30349. */
  30350. constructor(vrGamepad: any);
  30351. /**
  30352. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30353. * @param scene scene in which to add meshes
  30354. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30355. */
  30356. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30357. /**
  30358. * Called once for each button that changed state since the last frame
  30359. * @param buttonIdx Which button index changed
  30360. * @param state New state of the button
  30361. * @param changes Which properties on the state changed since last frame
  30362. */
  30363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30364. }
  30365. }
  30366. declare module BABYLON {
  30367. /**
  30368. * Oculus Touch Controller
  30369. */
  30370. class OculusTouchController extends WebVRController {
  30371. /**
  30372. * Base Url for the controller model.
  30373. */
  30374. static MODEL_BASE_URL: string;
  30375. /**
  30376. * File name for the left controller model.
  30377. */
  30378. static MODEL_LEFT_FILENAME: string;
  30379. /**
  30380. * File name for the right controller model.
  30381. */
  30382. static MODEL_RIGHT_FILENAME: string;
  30383. /**
  30384. * Fired when the secondary trigger on this controller is modified
  30385. */
  30386. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30387. /**
  30388. * Fired when the thumb rest on this controller is modified
  30389. */
  30390. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30391. /**
  30392. * Creates a new OculusTouchController from a gamepad
  30393. * @param vrGamepad the gamepad that the controller should be created from
  30394. */
  30395. constructor(vrGamepad: any);
  30396. /**
  30397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30398. * @param scene scene in which to add meshes
  30399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30400. */
  30401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30402. /**
  30403. * Fired when the A button on this controller is modified
  30404. */
  30405. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30406. /**
  30407. * Fired when the B button on this controller is modified
  30408. */
  30409. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30410. /**
  30411. * Fired when the X button on this controller is modified
  30412. */
  30413. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30414. /**
  30415. * Fired when the Y button on this controller is modified
  30416. */
  30417. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30418. /**
  30419. * Called once for each button that changed state since the last frame
  30420. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30421. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30422. * 2) secondary trigger (same)
  30423. * 3) A (right) X (left), touch, pressed = value
  30424. * 4) B / Y
  30425. * 5) thumb rest
  30426. * @param buttonIdx Which button index changed
  30427. * @param state New state of the button
  30428. * @param changes Which properties on the state changed since last frame
  30429. */
  30430. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30431. }
  30432. }
  30433. declare module BABYLON {
  30434. /**
  30435. * Defines the types of pose enabled controllers that are supported
  30436. */
  30437. enum PoseEnabledControllerType {
  30438. /**
  30439. * HTC Vive
  30440. */
  30441. VIVE = 0,
  30442. /**
  30443. * Oculus Rift
  30444. */
  30445. OCULUS = 1,
  30446. /**
  30447. * Windows mixed reality
  30448. */
  30449. WINDOWS = 2,
  30450. /**
  30451. * Samsung gear VR
  30452. */
  30453. GEAR_VR = 3,
  30454. /**
  30455. * Google Daydream
  30456. */
  30457. DAYDREAM = 4,
  30458. /**
  30459. * Generic
  30460. */
  30461. GENERIC = 5,
  30462. }
  30463. /**
  30464. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30465. */
  30466. interface MutableGamepadButton {
  30467. /**
  30468. * Value of the button/trigger
  30469. */
  30470. value: number;
  30471. /**
  30472. * If the button/trigger is currently touched
  30473. */
  30474. touched: boolean;
  30475. /**
  30476. * If the button/trigger is currently pressed
  30477. */
  30478. pressed: boolean;
  30479. }
  30480. /**
  30481. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30482. * @hidden
  30483. */
  30484. interface ExtendedGamepadButton extends GamepadButton {
  30485. /**
  30486. * If the button/trigger is currently pressed
  30487. */
  30488. readonly pressed: boolean;
  30489. /**
  30490. * If the button/trigger is currently touched
  30491. */
  30492. readonly touched: boolean;
  30493. /**
  30494. * Value of the button/trigger
  30495. */
  30496. readonly value: number;
  30497. }
  30498. /**
  30499. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30500. */
  30501. class PoseEnabledControllerHelper {
  30502. /**
  30503. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30504. * @param vrGamepad the gamepad to initialized
  30505. * @returns a vr controller of the type the gamepad identified as
  30506. */
  30507. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30508. }
  30509. /**
  30510. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30511. */
  30512. class PoseEnabledController extends Gamepad implements PoseControlled {
  30513. private _deviceRoomPosition;
  30514. private _deviceRoomRotationQuaternion;
  30515. /**
  30516. * The device position in babylon space
  30517. */
  30518. devicePosition: Vector3;
  30519. /**
  30520. * The device rotation in babylon space
  30521. */
  30522. deviceRotationQuaternion: Quaternion;
  30523. /**
  30524. * The scale factor of the device in babylon space
  30525. */
  30526. deviceScaleFactor: number;
  30527. /**
  30528. * (Likely devicePosition should be used instead) The device position in its room space
  30529. */
  30530. position: Vector3;
  30531. /**
  30532. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30533. */
  30534. rotationQuaternion: Quaternion;
  30535. /**
  30536. * The type of controller (Eg. Windows mixed reality)
  30537. */
  30538. controllerType: PoseEnabledControllerType;
  30539. protected _calculatedPosition: Vector3;
  30540. private _calculatedRotation;
  30541. /**
  30542. * The raw pose from the device
  30543. */
  30544. rawPose: DevicePose;
  30545. /**
  30546. * Internal, the mesh attached to the controller
  30547. */
  30548. _mesh: Nullable<AbstractMesh>;
  30549. private _poseControlledCamera;
  30550. private _leftHandSystemQuaternion;
  30551. /**
  30552. * Internal, matrix used to convert room space to babylon space
  30553. */
  30554. _deviceToWorld: Matrix;
  30555. /**
  30556. * Node to be used when casting a ray from the controller
  30557. */
  30558. _pointingPoseNode: Nullable<AbstractMesh>;
  30559. /**
  30560. * Name of the child mesh that can be used to cast a ray from the controller
  30561. */
  30562. static readonly POINTING_POSE: string;
  30563. /**
  30564. * Creates a new PoseEnabledController from a gamepad
  30565. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30566. */
  30567. constructor(browserGamepad: any);
  30568. private _workingMatrix;
  30569. /**
  30570. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30571. */
  30572. update(): void;
  30573. /**
  30574. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30575. * @param poseData raw pose fromthe device
  30576. */
  30577. updateFromDevice(poseData: DevicePose): void;
  30578. /**
  30579. * @hidden
  30580. */
  30581. _meshAttachedObservable: Observable<AbstractMesh>;
  30582. /**
  30583. * Attaches a mesh to the controller
  30584. * @param mesh the mesh to be attached
  30585. */
  30586. attachToMesh(mesh: AbstractMesh): void;
  30587. /**
  30588. * Attaches the controllers mesh to a camera
  30589. * @param camera the camera the mesh should be attached to
  30590. */
  30591. attachToPoseControlledCamera(camera: TargetCamera): void;
  30592. /**
  30593. * Disposes of the controller
  30594. */
  30595. dispose(): void;
  30596. /**
  30597. * The mesh that is attached to the controller
  30598. */
  30599. readonly mesh: Nullable<AbstractMesh>;
  30600. /**
  30601. * Gets the ray of the controller in the direction the controller is pointing
  30602. * @param length the length the resulting ray should be
  30603. * @returns a ray in the direction the controller is pointing
  30604. */
  30605. getForwardRay(length?: number): Ray;
  30606. }
  30607. }
  30608. declare module BABYLON {
  30609. /**
  30610. * Vive Controller
  30611. */
  30612. class ViveController extends WebVRController {
  30613. /**
  30614. * Base Url for the controller model.
  30615. */
  30616. static MODEL_BASE_URL: string;
  30617. /**
  30618. * File name for the controller model.
  30619. */
  30620. static MODEL_FILENAME: string;
  30621. /**
  30622. * Creates a new ViveController from a gamepad
  30623. * @param vrGamepad the gamepad that the controller should be created from
  30624. */
  30625. constructor(vrGamepad: any);
  30626. /**
  30627. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30628. * @param scene scene in which to add meshes
  30629. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30630. */
  30631. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30632. /**
  30633. * Fired when the left button on this controller is modified
  30634. */
  30635. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30636. /**
  30637. * Fired when the right button on this controller is modified
  30638. */
  30639. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30640. /**
  30641. * Fired when the menu button on this controller is modified
  30642. */
  30643. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30644. /**
  30645. * Called once for each button that changed state since the last frame
  30646. * Vive mapping:
  30647. * 0: touchpad
  30648. * 1: trigger
  30649. * 2: left AND right buttons
  30650. * 3: menu button
  30651. * @param buttonIdx Which button index changed
  30652. * @param state New state of the button
  30653. * @param changes Which properties on the state changed since last frame
  30654. */
  30655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30656. }
  30657. }
  30658. declare module BABYLON {
  30659. /**
  30660. * Defines the WebVRController object that represents controllers tracked in 3D space
  30661. */
  30662. abstract class WebVRController extends PoseEnabledController {
  30663. /**
  30664. * Internal, the default controller model for the controller
  30665. */
  30666. protected _defaultModel: AbstractMesh;
  30667. /**
  30668. * Fired when the trigger state has changed
  30669. */
  30670. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30671. /**
  30672. * Fired when the main button state has changed
  30673. */
  30674. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30675. /**
  30676. * Fired when the secondary button state has changed
  30677. */
  30678. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30679. /**
  30680. * Fired when the pad state has changed
  30681. */
  30682. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30683. /**
  30684. * Fired when controllers stick values have changed
  30685. */
  30686. onPadValuesChangedObservable: Observable<StickValues>;
  30687. /**
  30688. * Array of button availible on the controller
  30689. */
  30690. protected _buttons: Array<MutableGamepadButton>;
  30691. private _onButtonStateChange;
  30692. /**
  30693. * Fired when a controller button's state has changed
  30694. * @param callback the callback containing the button that was modified
  30695. */
  30696. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30697. /**
  30698. * X and Y axis corrisponding to the controllers joystick
  30699. */
  30700. pad: StickValues;
  30701. /**
  30702. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30703. */
  30704. hand: string;
  30705. /**
  30706. * The default controller model for the controller
  30707. */
  30708. readonly defaultModel: AbstractMesh;
  30709. /**
  30710. * Creates a new WebVRController from a gamepad
  30711. * @param vrGamepad the gamepad that the WebVRController should be created from
  30712. */
  30713. constructor(vrGamepad: any);
  30714. /**
  30715. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30716. */
  30717. update(): void;
  30718. /**
  30719. * Function to be called when a button is modified
  30720. */
  30721. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30722. /**
  30723. * Loads a mesh and attaches it to the controller
  30724. * @param scene the scene the mesh should be added to
  30725. * @param meshLoaded callback for when the mesh has been loaded
  30726. */
  30727. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30728. private _setButtonValue(newState, currentState, buttonIndex);
  30729. private _changes;
  30730. private _checkChanges(newState, currentState);
  30731. /**
  30732. * Disposes of th webVRCOntroller
  30733. */
  30734. dispose(): void;
  30735. }
  30736. }
  30737. declare module BABYLON {
  30738. /**
  30739. * Defines the WindowsMotionController object that the state of the windows motion controller
  30740. */
  30741. class WindowsMotionController extends WebVRController {
  30742. /**
  30743. * The base url used to load the left and right controller models
  30744. */
  30745. static MODEL_BASE_URL: string;
  30746. /**
  30747. * The name of the left controller model file
  30748. */
  30749. static MODEL_LEFT_FILENAME: string;
  30750. /**
  30751. * The name of the right controller model file
  30752. */
  30753. static MODEL_RIGHT_FILENAME: string;
  30754. /**
  30755. * The controller name prefix for this controller type
  30756. */
  30757. static readonly GAMEPAD_ID_PREFIX: string;
  30758. /**
  30759. * The controller id pattern for this controller type
  30760. */
  30761. private static readonly GAMEPAD_ID_PATTERN;
  30762. private _loadedMeshInfo;
  30763. private readonly _mapping;
  30764. /**
  30765. * Fired when the trackpad on this controller is clicked
  30766. */
  30767. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30768. /**
  30769. * Fired when the trackpad on this controller is modified
  30770. */
  30771. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30772. /**
  30773. * The current x and y values of this controller's trackpad
  30774. */
  30775. trackpad: StickValues;
  30776. /**
  30777. * Creates a new WindowsMotionController from a gamepad
  30778. * @param vrGamepad the gamepad that the controller should be created from
  30779. */
  30780. constructor(vrGamepad: any);
  30781. /**
  30782. * Fired when the trigger on this controller is modified
  30783. */
  30784. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30785. /**
  30786. * Fired when the menu button on this controller is modified
  30787. */
  30788. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30789. /**
  30790. * Fired when the grip button on this controller is modified
  30791. */
  30792. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30793. /**
  30794. * Fired when the thumbstick button on this controller is modified
  30795. */
  30796. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30797. /**
  30798. * Fired when the touchpad button on this controller is modified
  30799. */
  30800. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30801. /**
  30802. * Fired when the touchpad values on this controller are modified
  30803. */
  30804. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30805. /**
  30806. * Called once per frame by the engine.
  30807. */
  30808. update(): void;
  30809. /**
  30810. * Called once for each button that changed state since the last frame
  30811. * @param buttonIdx Which button index changed
  30812. * @param state New state of the button
  30813. * @param changes Which properties on the state changed since last frame
  30814. */
  30815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30816. /**
  30817. * Moves the buttons on the controller mesh based on their current state
  30818. * @param buttonName the name of the button to move
  30819. * @param buttonValue the value of the button which determines the buttons new position
  30820. */
  30821. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30822. /**
  30823. * Moves the axis on the controller mesh based on its current state
  30824. * @param axis the index of the axis
  30825. * @param axisValue the value of the axis which determines the meshes new position
  30826. * @hidden
  30827. */
  30828. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30829. /**
  30830. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30831. * @param scene scene in which to add meshes
  30832. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30833. */
  30834. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30835. /**
  30836. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30837. * can be transformed by button presses and axes values, based on this._mapping.
  30838. *
  30839. * @param scene scene in which the meshes exist
  30840. * @param meshes list of meshes that make up the controller model to process
  30841. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30842. */
  30843. private processModel(scene, meshes);
  30844. private createMeshInfo(rootNode);
  30845. /**
  30846. * Gets the ray of the controller in the direction the controller is pointing
  30847. * @param length the length the resulting ray should be
  30848. * @returns a ray in the direction the controller is pointing
  30849. */
  30850. getForwardRay(length?: number): Ray;
  30851. /**
  30852. * Disposes of the controller
  30853. */
  30854. dispose(): void;
  30855. }
  30856. }
  30857. declare module BABYLON {
  30858. }
  30859. declare module BABYLON {
  30860. /**
  30861. * Interface to implement to create a shadow generator compatible with BJS.
  30862. */
  30863. interface IShadowGenerator {
  30864. /**
  30865. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30866. * @returns The render target texture if present otherwise, null
  30867. */
  30868. getShadowMap(): Nullable<RenderTargetTexture>;
  30869. /**
  30870. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30871. * @returns The render target texture if the shadow map is present otherwise, null
  30872. */
  30873. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30874. /**
  30875. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30876. * @param subMesh The submesh we want to render in the shadow map
  30877. * @param useInstances Defines wether will draw in the map using instances
  30878. * @returns true if ready otherwise, false
  30879. */
  30880. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30881. /**
  30882. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30883. * @param defines Defines of the material we want to update
  30884. * @param lightIndex Index of the light in the enabled light list of the material
  30885. */
  30886. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30887. /**
  30888. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30889. * defined in the generator but impacting the effect).
  30890. * It implies the unifroms available on the materials are the standard BJS ones.
  30891. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30892. * @param effect The effect we are binfing the information for
  30893. */
  30894. bindShadowLight(lightIndex: string, effect: Effect): void;
  30895. /**
  30896. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30897. * (eq to shadow prjection matrix * light transform matrix)
  30898. * @returns The transform matrix used to create the shadow map
  30899. */
  30900. getTransformMatrix(): Matrix;
  30901. /**
  30902. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30903. * Cube and 2D textures for instance.
  30904. */
  30905. recreateShadowMap(): void;
  30906. /**
  30907. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30908. * @param onCompiled Callback triggered at the and of the effects compilation
  30909. * @param options Sets of optional options forcing the compilation with different modes
  30910. */
  30911. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30912. useInstances: boolean;
  30913. }>): void;
  30914. /**
  30915. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30916. * @param options Sets of optional options forcing the compilation with different modes
  30917. * @returns A promise that resolves when the compilation completes
  30918. */
  30919. forceCompilationAsync(options?: Partial<{
  30920. useInstances: boolean;
  30921. }>): Promise<void>;
  30922. /**
  30923. * Serializes the shadow generator setup to a json object.
  30924. * @returns The serialized JSON object
  30925. */
  30926. serialize(): any;
  30927. /**
  30928. * Disposes the Shadow map and related Textures and effects.
  30929. */
  30930. dispose(): void;
  30931. }
  30932. /**
  30933. * Default implementation IShadowGenerator.
  30934. * This is the main object responsible of generating shadows in the framework.
  30935. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30936. */
  30937. class ShadowGenerator implements IShadowGenerator {
  30938. /**
  30939. * Shadow generator mode None: no filtering applied.
  30940. */
  30941. static readonly FILTER_NONE: number;
  30942. /**
  30943. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30944. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30945. */
  30946. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30947. /**
  30948. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30949. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30950. */
  30951. static readonly FILTER_POISSONSAMPLING: number;
  30952. /**
  30953. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30954. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30955. */
  30956. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30957. /**
  30958. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30959. * edge artifacts on steep falloff.
  30960. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30961. */
  30962. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30963. /**
  30964. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30965. * edge artifacts on steep falloff.
  30966. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30967. */
  30968. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30969. /**
  30970. * Shadow generator mode PCF: Percentage Closer Filtering
  30971. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30972. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30973. */
  30974. static readonly FILTER_PCF: number;
  30975. /**
  30976. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30977. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30978. * Contact Hardening
  30979. */
  30980. static readonly FILTER_PCSS: number;
  30981. /**
  30982. * Reserved for PCF and PCSS
  30983. * Highest Quality.
  30984. *
  30985. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30986. *
  30987. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30988. */
  30989. static readonly QUALITY_HIGH: number;
  30990. /**
  30991. * Reserved for PCF and PCSS
  30992. * Good tradeoff for quality/perf cross devices
  30993. *
  30994. * Execute PCF on a 3*3 kernel.
  30995. *
  30996. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30997. */
  30998. static readonly QUALITY_MEDIUM: number;
  30999. /**
  31000. * Reserved for PCF and PCSS
  31001. * The lowest quality but the fastest.
  31002. *
  31003. * Execute PCF on a 1*1 kernel.
  31004. *
  31005. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31006. */
  31007. static readonly QUALITY_LOW: number;
  31008. private _bias;
  31009. /**
  31010. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31011. */
  31012. /**
  31013. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31014. */
  31015. bias: number;
  31016. private _normalBias;
  31017. /**
  31018. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31019. */
  31020. /**
  31021. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31022. */
  31023. normalBias: number;
  31024. private _blurBoxOffset;
  31025. /**
  31026. * Gets the blur box offset: offset applied during the blur pass.
  31027. * Only usefull if useKernelBlur = false
  31028. */
  31029. /**
  31030. * Sets the blur box offset: offset applied during the blur pass.
  31031. * Only usefull if useKernelBlur = false
  31032. */
  31033. blurBoxOffset: number;
  31034. private _blurScale;
  31035. /**
  31036. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31037. * 2 means half of the size.
  31038. */
  31039. /**
  31040. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31041. * 2 means half of the size.
  31042. */
  31043. blurScale: number;
  31044. private _blurKernel;
  31045. /**
  31046. * Gets the blur kernel: kernel size of the blur pass.
  31047. * Only usefull if useKernelBlur = true
  31048. */
  31049. /**
  31050. * Sets the blur kernel: kernel size of the blur pass.
  31051. * Only usefull if useKernelBlur = true
  31052. */
  31053. blurKernel: number;
  31054. private _useKernelBlur;
  31055. /**
  31056. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31057. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31058. */
  31059. /**
  31060. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31061. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31062. */
  31063. useKernelBlur: boolean;
  31064. private _depthScale;
  31065. /**
  31066. * Gets the depth scale used in ESM mode.
  31067. */
  31068. /**
  31069. * Sets the depth scale used in ESM mode.
  31070. * This can override the scale stored on the light.
  31071. */
  31072. depthScale: number;
  31073. private _filter;
  31074. /**
  31075. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31076. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31077. */
  31078. /**
  31079. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31080. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31081. */
  31082. filter: number;
  31083. /**
  31084. * Gets if the current filter is set to Poisson Sampling.
  31085. */
  31086. /**
  31087. * Sets the current filter to Poisson Sampling.
  31088. */
  31089. usePoissonSampling: boolean;
  31090. /**
  31091. * Gets if the current filter is set to VSM.
  31092. * DEPRECATED. Should use useExponentialShadowMap instead.
  31093. */
  31094. /**
  31095. * Sets the current filter is to VSM.
  31096. * DEPRECATED. Should use useExponentialShadowMap instead.
  31097. */
  31098. useVarianceShadowMap: boolean;
  31099. /**
  31100. * Gets if the current filter is set to blurred VSM.
  31101. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31102. */
  31103. /**
  31104. * Sets the current filter is to blurred VSM.
  31105. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31106. */
  31107. useBlurVarianceShadowMap: boolean;
  31108. /**
  31109. * Gets if the current filter is set to ESM.
  31110. */
  31111. /**
  31112. * Sets the current filter is to ESM.
  31113. */
  31114. useExponentialShadowMap: boolean;
  31115. /**
  31116. * Gets if the current filter is set to filtered ESM.
  31117. */
  31118. /**
  31119. * Gets if the current filter is set to filtered ESM.
  31120. */
  31121. useBlurExponentialShadowMap: boolean;
  31122. /**
  31123. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31124. * exponential to prevent steep falloff artifacts).
  31125. */
  31126. /**
  31127. * Sets the current filter to "close ESM" (using the inverse of the
  31128. * exponential to prevent steep falloff artifacts).
  31129. */
  31130. useCloseExponentialShadowMap: boolean;
  31131. /**
  31132. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31133. * exponential to prevent steep falloff artifacts).
  31134. */
  31135. /**
  31136. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31137. * exponential to prevent steep falloff artifacts).
  31138. */
  31139. useBlurCloseExponentialShadowMap: boolean;
  31140. /**
  31141. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31142. */
  31143. /**
  31144. * Sets the current filter to "PCF" (percentage closer filtering).
  31145. */
  31146. usePercentageCloserFiltering: boolean;
  31147. private _filteringQuality;
  31148. /**
  31149. * Gets the PCF or PCSS Quality.
  31150. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31151. */
  31152. /**
  31153. * Sets the PCF or PCSS Quality.
  31154. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31155. */
  31156. filteringQuality: number;
  31157. /**
  31158. * Gets if the current filter is set to "PCSS" (contact hardening).
  31159. */
  31160. /**
  31161. * Sets the current filter to "PCSS" (contact hardening).
  31162. */
  31163. useContactHardeningShadow: boolean;
  31164. private _contactHardeningLightSizeUVRatio;
  31165. /**
  31166. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31167. * Using a ratio helps keeping shape stability independently of the map size.
  31168. *
  31169. * It does not account for the light projection as it was having too much
  31170. * instability during the light setup or during light position changes.
  31171. *
  31172. * Only valid if useContactHardeningShadow is true.
  31173. */
  31174. /**
  31175. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31176. * Using a ratio helps keeping shape stability independently of the map size.
  31177. *
  31178. * It does not account for the light projection as it was having too much
  31179. * instability during the light setup or during light position changes.
  31180. *
  31181. * Only valid if useContactHardeningShadow is true.
  31182. */
  31183. contactHardeningLightSizeUVRatio: number;
  31184. private _darkness;
  31185. /**
  31186. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31187. * 0 means strongest and 1 would means no shadow.
  31188. * @returns the darkness.
  31189. */
  31190. getDarkness(): number;
  31191. /**
  31192. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31193. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31194. * @returns the shadow generator allowing fluent coding.
  31195. */
  31196. setDarkness(darkness: number): ShadowGenerator;
  31197. private _transparencyShadow;
  31198. /**
  31199. * Sets the ability to have transparent shadow (boolean).
  31200. * @param transparent True if transparent else False
  31201. * @returns the shadow generator allowing fluent coding
  31202. */
  31203. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31204. private _shadowMap;
  31205. private _shadowMap2;
  31206. /**
  31207. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31208. * @returns The render target texture if present otherwise, null
  31209. */
  31210. getShadowMap(): Nullable<RenderTargetTexture>;
  31211. /**
  31212. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31213. * @returns The render target texture if the shadow map is present otherwise, null
  31214. */
  31215. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31216. /**
  31217. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31218. * @param mesh Mesh to add
  31219. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31220. * @returns the Shadow Generator itself
  31221. */
  31222. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31223. /**
  31224. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31225. * @param mesh Mesh to remove
  31226. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31227. * @returns the Shadow Generator itself
  31228. */
  31229. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31230. /**
  31231. * Controls the extent to which the shadows fade out at the edge of the frustum
  31232. * Used only by directionals and spots
  31233. */
  31234. frustumEdgeFalloff: number;
  31235. private _light;
  31236. /**
  31237. * Returns the associated light object.
  31238. * @returns the light generating the shadow
  31239. */
  31240. getLight(): IShadowLight;
  31241. /**
  31242. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31243. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31244. * It might on the other hand introduce peter panning.
  31245. */
  31246. forceBackFacesOnly: boolean;
  31247. private _scene;
  31248. private _lightDirection;
  31249. private _effect;
  31250. private _viewMatrix;
  31251. private _projectionMatrix;
  31252. private _transformMatrix;
  31253. private _cachedPosition;
  31254. private _cachedDirection;
  31255. private _cachedDefines;
  31256. private _currentRenderID;
  31257. private _boxBlurPostprocess;
  31258. private _kernelBlurXPostprocess;
  31259. private _kernelBlurYPostprocess;
  31260. private _blurPostProcesses;
  31261. private _mapSize;
  31262. private _currentFaceIndex;
  31263. private _currentFaceIndexCache;
  31264. private _textureType;
  31265. private _defaultTextureMatrix;
  31266. /**
  31267. * Creates a ShadowGenerator object.
  31268. * A ShadowGenerator is the required tool to use the shadows.
  31269. * Each light casting shadows needs to use its own ShadowGenerator.
  31270. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31271. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31272. * @param light The light object generating the shadows.
  31273. * @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.
  31274. */
  31275. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31276. private _initializeGenerator();
  31277. private _initializeShadowMap();
  31278. private _initializeBlurRTTAndPostProcesses();
  31279. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31280. private _renderSubMeshForShadowMap(subMesh);
  31281. private _applyFilterValues();
  31282. /**
  31283. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31284. * @param onCompiled Callback triggered at the and of the effects compilation
  31285. * @param options Sets of optional options forcing the compilation with different modes
  31286. */
  31287. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31288. useInstances: boolean;
  31289. }>): void;
  31290. /**
  31291. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31292. * @param options Sets of optional options forcing the compilation with different modes
  31293. * @returns A promise that resolves when the compilation completes
  31294. */
  31295. forceCompilationAsync(options?: Partial<{
  31296. useInstances: boolean;
  31297. }>): Promise<void>;
  31298. /**
  31299. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31300. * @param subMesh The submesh we want to render in the shadow map
  31301. * @param useInstances Defines wether will draw in the map using instances
  31302. * @returns true if ready otherwise, false
  31303. */
  31304. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31305. /**
  31306. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31307. * @param defines Defines of the material we want to update
  31308. * @param lightIndex Index of the light in the enabled light list of the material
  31309. */
  31310. prepareDefines(defines: any, lightIndex: number): void;
  31311. /**
  31312. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31313. * defined in the generator but impacting the effect).
  31314. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31315. * @param effect The effect we are binfing the information for
  31316. */
  31317. bindShadowLight(lightIndex: string, effect: Effect): void;
  31318. /**
  31319. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31320. * (eq to shadow prjection matrix * light transform matrix)
  31321. * @returns The transform matrix used to create the shadow map
  31322. */
  31323. getTransformMatrix(): Matrix;
  31324. /**
  31325. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31326. * Cube and 2D textures for instance.
  31327. */
  31328. recreateShadowMap(): void;
  31329. private _disposeBlurPostProcesses();
  31330. private _disposeRTTandPostProcesses();
  31331. /**
  31332. * Disposes the ShadowGenerator.
  31333. * Returns nothing.
  31334. */
  31335. dispose(): void;
  31336. /**
  31337. * Serializes the shadow generator setup to a json object.
  31338. * @returns The serialized JSON object
  31339. */
  31340. serialize(): any;
  31341. /**
  31342. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31343. * @param parsedShadowGenerator The JSON object to parse
  31344. * @param scene The scene to create the shadow map for
  31345. * @returns The parsed shadow generator
  31346. */
  31347. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31348. }
  31349. }
  31350. declare module BABYLON {
  31351. /**
  31352. * Background material used to create an efficient environement around your scene.
  31353. */
  31354. class BackgroundMaterial extends PushMaterial {
  31355. /**
  31356. * Standard reflectance value at parallel view angle.
  31357. */
  31358. static StandardReflectance0: number;
  31359. /**
  31360. * Standard reflectance value at grazing angle.
  31361. */
  31362. static StandardReflectance90: number;
  31363. protected _primaryColor: Color3;
  31364. /**
  31365. * Key light Color (multiply against the environement texture)
  31366. */
  31367. primaryColor: Color3;
  31368. protected __perceptualColor: Nullable<Color3>;
  31369. /**
  31370. * Experimental Internal Use Only.
  31371. *
  31372. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31373. * This acts as a helper to set the primary color to a more "human friendly" value.
  31374. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31375. * output color as close as possible from the chosen value.
  31376. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31377. * part of lighting setup.)
  31378. */
  31379. _perceptualColor: Nullable<Color3>;
  31380. protected _primaryColorShadowLevel: float;
  31381. /**
  31382. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31383. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31384. */
  31385. primaryColorShadowLevel: float;
  31386. protected _primaryColorHighlightLevel: float;
  31387. /**
  31388. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31389. * The primary color is used at the level chosen to define what the white area would look.
  31390. */
  31391. primaryColorHighlightLevel: float;
  31392. protected _reflectionTexture: Nullable<BaseTexture>;
  31393. /**
  31394. * Reflection Texture used in the material.
  31395. * Should be author in a specific way for the best result (refer to the documentation).
  31396. */
  31397. reflectionTexture: Nullable<BaseTexture>;
  31398. protected _reflectionBlur: float;
  31399. /**
  31400. * Reflection Texture level of blur.
  31401. *
  31402. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31403. * texture twice.
  31404. */
  31405. reflectionBlur: float;
  31406. protected _diffuseTexture: Nullable<BaseTexture>;
  31407. /**
  31408. * Diffuse Texture used in the material.
  31409. * Should be author in a specific way for the best result (refer to the documentation).
  31410. */
  31411. diffuseTexture: Nullable<BaseTexture>;
  31412. protected _shadowLights: Nullable<IShadowLight[]>;
  31413. /**
  31414. * Specify the list of lights casting shadow on the material.
  31415. * All scene shadow lights will be included if null.
  31416. */
  31417. shadowLights: Nullable<IShadowLight[]>;
  31418. protected _shadowLevel: float;
  31419. /**
  31420. * Helps adjusting the shadow to a softer level if required.
  31421. * 0 means black shadows and 1 means no shadows.
  31422. */
  31423. shadowLevel: float;
  31424. protected _sceneCenter: Vector3;
  31425. /**
  31426. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31427. * It is usually zero but might be interesting to modify according to your setup.
  31428. */
  31429. sceneCenter: Vector3;
  31430. protected _opacityFresnel: boolean;
  31431. /**
  31432. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31433. * This helps ensuring a nice transition when the camera goes under the ground.
  31434. */
  31435. opacityFresnel: boolean;
  31436. protected _reflectionFresnel: boolean;
  31437. /**
  31438. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31439. * This helps adding a mirror texture on the ground.
  31440. */
  31441. reflectionFresnel: boolean;
  31442. protected _reflectionFalloffDistance: number;
  31443. /**
  31444. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31445. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31446. */
  31447. reflectionFalloffDistance: number;
  31448. protected _reflectionAmount: number;
  31449. /**
  31450. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31451. */
  31452. reflectionAmount: number;
  31453. protected _reflectionReflectance0: number;
  31454. /**
  31455. * This specifies the weight of the reflection at grazing angle.
  31456. */
  31457. reflectionReflectance0: number;
  31458. protected _reflectionReflectance90: number;
  31459. /**
  31460. * This specifies the weight of the reflection at a perpendicular point of view.
  31461. */
  31462. reflectionReflectance90: number;
  31463. /**
  31464. * Sets the reflection reflectance fresnel values according to the default standard
  31465. * empirically know to work well :-)
  31466. */
  31467. reflectionStandardFresnelWeight: number;
  31468. protected _useRGBColor: boolean;
  31469. /**
  31470. * Helps to directly use the maps channels instead of their level.
  31471. */
  31472. useRGBColor: boolean;
  31473. protected _enableNoise: boolean;
  31474. /**
  31475. * This helps reducing the banding effect that could occur on the background.
  31476. */
  31477. enableNoise: boolean;
  31478. /**
  31479. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31480. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31481. * Recommended to be keep at 1.0 except for special cases.
  31482. */
  31483. fovMultiplier: number;
  31484. private _fovMultiplier;
  31485. /**
  31486. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31487. */
  31488. useEquirectangularFOV: boolean;
  31489. private _maxSimultaneousLights;
  31490. /**
  31491. * Number of Simultaneous lights allowed on the material.
  31492. */
  31493. maxSimultaneousLights: int;
  31494. /**
  31495. * Default configuration related to image processing available in the Background Material.
  31496. */
  31497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31498. /**
  31499. * Keep track of the image processing observer to allow dispose and replace.
  31500. */
  31501. private _imageProcessingObserver;
  31502. /**
  31503. * Attaches a new image processing configuration to the PBR Material.
  31504. * @param configuration (if null the scene configuration will be use)
  31505. */
  31506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31507. /**
  31508. * Gets the image processing configuration used either in this material.
  31509. */
  31510. /**
  31511. * Sets the Default image processing configuration used either in the this material.
  31512. *
  31513. * If sets to null, the scene one is in use.
  31514. */
  31515. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31516. /**
  31517. * Gets wether the color curves effect is enabled.
  31518. */
  31519. /**
  31520. * Sets wether the color curves effect is enabled.
  31521. */
  31522. cameraColorCurvesEnabled: boolean;
  31523. /**
  31524. * Gets wether the color grading effect is enabled.
  31525. */
  31526. /**
  31527. * Gets wether the color grading effect is enabled.
  31528. */
  31529. cameraColorGradingEnabled: boolean;
  31530. /**
  31531. * Gets wether tonemapping is enabled or not.
  31532. */
  31533. /**
  31534. * Sets wether tonemapping is enabled or not
  31535. */
  31536. cameraToneMappingEnabled: boolean;
  31537. /**
  31538. * The camera exposure used on this material.
  31539. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31540. * This corresponds to a photographic exposure.
  31541. */
  31542. /**
  31543. * The camera exposure used on this material.
  31544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31545. * This corresponds to a photographic exposure.
  31546. */
  31547. cameraExposure: float;
  31548. /**
  31549. * Gets The camera contrast used on this material.
  31550. */
  31551. /**
  31552. * Sets The camera contrast used on this material.
  31553. */
  31554. cameraContrast: float;
  31555. /**
  31556. * Gets the Color Grading 2D Lookup Texture.
  31557. */
  31558. /**
  31559. * Sets the Color Grading 2D Lookup Texture.
  31560. */
  31561. cameraColorGradingTexture: Nullable<BaseTexture>;
  31562. /**
  31563. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31564. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31565. * 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;
  31566. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31567. */
  31568. /**
  31569. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31570. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31571. * 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;
  31572. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31573. */
  31574. cameraColorCurves: Nullable<ColorCurves>;
  31575. /**
  31576. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31577. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31578. */
  31579. switchToBGR: boolean;
  31580. private _renderTargets;
  31581. private _reflectionControls;
  31582. private _white;
  31583. private _primaryShadowColor;
  31584. private _primaryHighlightColor;
  31585. /**
  31586. * Instantiates a Background Material in the given scene
  31587. * @param name The friendly name of the material
  31588. * @param scene The scene to add the material to
  31589. */
  31590. constructor(name: string, scene: Scene);
  31591. /**
  31592. * The entire material has been created in order to prevent overdraw.
  31593. * @returns false
  31594. */
  31595. needAlphaTesting(): boolean;
  31596. /**
  31597. * The entire material has been created in order to prevent overdraw.
  31598. * @returns true if blending is enable
  31599. */
  31600. needAlphaBlending(): boolean;
  31601. /**
  31602. * Checks wether the material is ready to be rendered for a given mesh.
  31603. * @param mesh The mesh to render
  31604. * @param subMesh The submesh to check against
  31605. * @param useInstances Specify wether or not the material is used with instances
  31606. * @returns true if all the dependencies are ready (Textures, Effects...)
  31607. */
  31608. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31609. /**
  31610. * Compute the primary color according to the chosen perceptual color.
  31611. */
  31612. private _computePrimaryColorFromPerceptualColor();
  31613. /**
  31614. * Compute the highlights and shadow colors according to their chosen levels.
  31615. */
  31616. private _computePrimaryColors();
  31617. /**
  31618. * Build the uniform buffer used in the material.
  31619. */
  31620. buildUniformLayout(): void;
  31621. /**
  31622. * Unbind the material.
  31623. */
  31624. unbind(): void;
  31625. /**
  31626. * Bind only the world matrix to the material.
  31627. * @param world The world matrix to bind.
  31628. */
  31629. bindOnlyWorldMatrix(world: Matrix): void;
  31630. /**
  31631. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31632. * @param world The world matrix to bind.
  31633. * @param subMesh The submesh to bind for.
  31634. */
  31635. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31636. /**
  31637. * Dispose the material.
  31638. * @param forceDisposeEffect Force disposal of the associated effect.
  31639. * @param forceDisposeTextures Force disposal of the associated textures.
  31640. */
  31641. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31642. /**
  31643. * Clones the material.
  31644. * @param name The cloned name.
  31645. * @returns The cloned material.
  31646. */
  31647. clone(name: string): BackgroundMaterial;
  31648. /**
  31649. * Serializes the current material to its JSON representation.
  31650. * @returns The JSON representation.
  31651. */
  31652. serialize(): any;
  31653. /**
  31654. * Gets the class name of the material
  31655. * @returns "BackgroundMaterial"
  31656. */
  31657. getClassName(): string;
  31658. /**
  31659. * Parse a JSON input to create back a background material.
  31660. * @param source The JSON data to parse
  31661. * @param scene The scene to create the parsed material in
  31662. * @param rootUrl The root url of the assets the material depends upon
  31663. * @returns the instantiated BackgroundMaterial.
  31664. */
  31665. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31666. }
  31667. }
  31668. declare module BABYLON {
  31669. /**
  31670. * The Physically based material base class of BJS.
  31671. *
  31672. * This offers the main features of a standard PBR material.
  31673. * For more information, please refer to the documentation :
  31674. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31675. */
  31676. abstract class PBRBaseMaterial extends PushMaterial {
  31677. /**
  31678. * Intensity of the direct lights e.g. the four lights available in your scene.
  31679. * This impacts both the direct diffuse and specular highlights.
  31680. */
  31681. protected _directIntensity: number;
  31682. /**
  31683. * Intensity of the emissive part of the material.
  31684. * This helps controlling the emissive effect without modifying the emissive color.
  31685. */
  31686. protected _emissiveIntensity: number;
  31687. /**
  31688. * Intensity of the environment e.g. how much the environment will light the object
  31689. * either through harmonics for rough material or through the refelction for shiny ones.
  31690. */
  31691. protected _environmentIntensity: number;
  31692. /**
  31693. * This is a special control allowing the reduction of the specular highlights coming from the
  31694. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31695. */
  31696. protected _specularIntensity: number;
  31697. /**
  31698. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31699. */
  31700. private _lightingInfos;
  31701. /**
  31702. * Debug Control allowing disabling the bump map on this material.
  31703. */
  31704. protected _disableBumpMap: boolean;
  31705. /**
  31706. * AKA Diffuse Texture in standard nomenclature.
  31707. */
  31708. protected _albedoTexture: BaseTexture;
  31709. /**
  31710. * AKA Occlusion Texture in other nomenclature.
  31711. */
  31712. protected _ambientTexture: BaseTexture;
  31713. /**
  31714. * AKA Occlusion Texture Intensity in other nomenclature.
  31715. */
  31716. protected _ambientTextureStrength: number;
  31717. /**
  31718. * Stores the alpha values in a texture.
  31719. */
  31720. protected _opacityTexture: BaseTexture;
  31721. /**
  31722. * Stores the reflection values in a texture.
  31723. */
  31724. protected _reflectionTexture: BaseTexture;
  31725. /**
  31726. * Stores the refraction values in a texture.
  31727. */
  31728. protected _refractionTexture: BaseTexture;
  31729. /**
  31730. * Stores the emissive values in a texture.
  31731. */
  31732. protected _emissiveTexture: BaseTexture;
  31733. /**
  31734. * AKA Specular texture in other nomenclature.
  31735. */
  31736. protected _reflectivityTexture: BaseTexture;
  31737. /**
  31738. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31739. */
  31740. protected _metallicTexture: BaseTexture;
  31741. /**
  31742. * Specifies the metallic scalar of the metallic/roughness workflow.
  31743. * Can also be used to scale the metalness values of the metallic texture.
  31744. */
  31745. protected _metallic: number;
  31746. /**
  31747. * Specifies the roughness scalar of the metallic/roughness workflow.
  31748. * Can also be used to scale the roughness values of the metallic texture.
  31749. */
  31750. protected _roughness: number;
  31751. /**
  31752. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31753. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31754. */
  31755. protected _microSurfaceTexture: BaseTexture;
  31756. /**
  31757. * Stores surface normal data used to displace a mesh in a texture.
  31758. */
  31759. protected _bumpTexture: BaseTexture;
  31760. /**
  31761. * Stores the pre-calculated light information of a mesh in a texture.
  31762. */
  31763. protected _lightmapTexture: BaseTexture;
  31764. /**
  31765. * The color of a material in ambient lighting.
  31766. */
  31767. protected _ambientColor: Color3;
  31768. /**
  31769. * AKA Diffuse Color in other nomenclature.
  31770. */
  31771. protected _albedoColor: Color3;
  31772. /**
  31773. * AKA Specular Color in other nomenclature.
  31774. */
  31775. protected _reflectivityColor: Color3;
  31776. /**
  31777. * The color applied when light is reflected from a material.
  31778. */
  31779. protected _reflectionColor: Color3;
  31780. /**
  31781. * The color applied when light is emitted from a material.
  31782. */
  31783. protected _emissiveColor: Color3;
  31784. /**
  31785. * AKA Glossiness in other nomenclature.
  31786. */
  31787. protected _microSurface: number;
  31788. /**
  31789. * source material index of refraction (IOR)' / 'destination material IOR.
  31790. */
  31791. protected _indexOfRefraction: number;
  31792. /**
  31793. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31794. */
  31795. protected _invertRefractionY: boolean;
  31796. /**
  31797. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31798. * Materials half opaque for instance using refraction could benefit from this control.
  31799. */
  31800. protected _linkRefractionWithTransparency: boolean;
  31801. /**
  31802. * Specifies that the material will use the light map as a show map.
  31803. */
  31804. protected _useLightmapAsShadowmap: boolean;
  31805. /**
  31806. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31807. * makes the reflect vector face the model (under horizon).
  31808. */
  31809. protected _useHorizonOcclusion: boolean;
  31810. /**
  31811. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31812. * too much the area relying on ambient texture to define their ambient occlusion.
  31813. */
  31814. protected _useRadianceOcclusion: boolean;
  31815. /**
  31816. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31817. */
  31818. protected _useAlphaFromAlbedoTexture: boolean;
  31819. /**
  31820. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31821. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31822. */
  31823. protected _useSpecularOverAlpha: boolean;
  31824. /**
  31825. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31826. */
  31827. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31828. /**
  31829. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31830. */
  31831. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31832. /**
  31833. * Specifies if the metallic texture contains the roughness information in its green channel.
  31834. */
  31835. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31836. /**
  31837. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31838. */
  31839. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31840. /**
  31841. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31842. */
  31843. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31844. /**
  31845. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31846. */
  31847. protected _useAmbientInGrayScale: boolean;
  31848. /**
  31849. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31850. * The material will try to infer what glossiness each pixel should be.
  31851. */
  31852. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31853. /**
  31854. * BJS is using an harcoded light falloff based on a manually sets up range.
  31855. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31856. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31857. */
  31858. protected _usePhysicalLightFalloff: boolean;
  31859. /**
  31860. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31861. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31862. */
  31863. protected _useRadianceOverAlpha: boolean;
  31864. /**
  31865. * Allows using an object space normal map (instead of tangent space).
  31866. */
  31867. protected _useObjectSpaceNormalMap: boolean;
  31868. /**
  31869. * Allows using the bump map in parallax mode.
  31870. */
  31871. protected _useParallax: boolean;
  31872. /**
  31873. * Allows using the bump map in parallax occlusion mode.
  31874. */
  31875. protected _useParallaxOcclusion: boolean;
  31876. /**
  31877. * Controls the scale bias of the parallax mode.
  31878. */
  31879. protected _parallaxScaleBias: number;
  31880. /**
  31881. * If sets to true, disables all the lights affecting the material.
  31882. */
  31883. protected _disableLighting: boolean;
  31884. /**
  31885. * Number of Simultaneous lights allowed on the material.
  31886. */
  31887. protected _maxSimultaneousLights: number;
  31888. /**
  31889. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31890. */
  31891. protected _invertNormalMapX: boolean;
  31892. /**
  31893. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31894. */
  31895. protected _invertNormalMapY: boolean;
  31896. /**
  31897. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31898. */
  31899. protected _twoSidedLighting: boolean;
  31900. /**
  31901. * Defines the alpha limits in alpha test mode.
  31902. */
  31903. protected _alphaCutOff: number;
  31904. /**
  31905. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31906. */
  31907. protected _forceAlphaTest: boolean;
  31908. /**
  31909. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31910. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  31911. */
  31912. protected _useAlphaFresnel: boolean;
  31913. /**
  31914. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31915. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  31916. */
  31917. protected _useLinearAlphaFresnel: boolean;
  31918. /**
  31919. * The transparency mode of the material.
  31920. */
  31921. protected _transparencyMode: Nullable<number>;
  31922. /**
  31923. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  31924. * from cos thetav and roughness:
  31925. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  31926. */
  31927. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  31928. /**
  31929. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  31930. */
  31931. protected _forceIrradianceInFragment: boolean;
  31932. /**
  31933. * Force normal to face away from face.
  31934. */
  31935. protected _forceNormalForward: boolean;
  31936. /**
  31937. * Enables specular anti aliasing in the PBR shader.
  31938. * It will both interacts on the Geometry for analytical and IBL lighting.
  31939. * It also prefilter the roughness map based on the bump values.
  31940. */
  31941. protected _enableSpecularAntiAliasing: boolean;
  31942. /**
  31943. * Default configuration related to image processing available in the PBR Material.
  31944. */
  31945. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31946. /**
  31947. * Keep track of the image processing observer to allow dispose and replace.
  31948. */
  31949. private _imageProcessingObserver;
  31950. /**
  31951. * Attaches a new image processing configuration to the PBR Material.
  31952. * @param configuration
  31953. */
  31954. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31955. /**
  31956. * Stores the available render targets.
  31957. */
  31958. private _renderTargets;
  31959. /**
  31960. * Sets the global ambient color for the material used in lighting calculations.
  31961. */
  31962. private _globalAmbientColor;
  31963. /**
  31964. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  31965. */
  31966. private _useLogarithmicDepth;
  31967. /**
  31968. * If set to true, no lighting calculations will be applied.
  31969. */
  31970. private _unlit;
  31971. /**
  31972. * Instantiates a new PBRMaterial instance.
  31973. *
  31974. * @param name The material name
  31975. * @param scene The scene the material will be use in.
  31976. */
  31977. constructor(name: string, scene: Scene);
  31978. /**
  31979. * Gets the name of the material class.
  31980. */
  31981. getClassName(): string;
  31982. /**
  31983. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31984. */
  31985. /**
  31986. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31987. */
  31988. useLogarithmicDepth: boolean;
  31989. /**
  31990. * Gets the current transparency mode.
  31991. */
  31992. /**
  31993. * Sets the transparency mode of the material.
  31994. */
  31995. transparencyMode: Nullable<number>;
  31996. /**
  31997. * Returns true if alpha blending should be disabled.
  31998. */
  31999. private readonly _disableAlphaBlending;
  32000. /**
  32001. * Specifies whether or not this material should be rendered in alpha blend mode.
  32002. */
  32003. needAlphaBlending(): boolean;
  32004. /**
  32005. * Specifies if the mesh will require alpha blending.
  32006. * @param mesh - BJS mesh.
  32007. */
  32008. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32009. /**
  32010. * Specifies whether or not this material should be rendered in alpha test mode.
  32011. */
  32012. needAlphaTesting(): boolean;
  32013. /**
  32014. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32015. */
  32016. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32017. /**
  32018. * Gets the texture used for the alpha test.
  32019. */
  32020. getAlphaTestTexture(): BaseTexture;
  32021. /**
  32022. * Stores the reflectivity values based on metallic roughness workflow.
  32023. */
  32024. private static _scaledReflectivity;
  32025. /**
  32026. * Specifies that the submesh is ready to be used.
  32027. * @param mesh - BJS mesh.
  32028. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32029. * @param useInstances - Specifies that instances should be used.
  32030. * @returns - boolean indicating that the submesh is ready or not.
  32031. */
  32032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32033. /**
  32034. * Specifies if the material uses metallic roughness workflow.
  32035. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32036. */
  32037. isMetallicWorkflow(): boolean;
  32038. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32039. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32040. /**
  32041. * Force shader compilation
  32042. */
  32043. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32044. clipPlane: boolean;
  32045. }>): void;
  32046. /**
  32047. * Initializes the uniform buffer layout for the shader.
  32048. */
  32049. buildUniformLayout(): void;
  32050. /**
  32051. * Unbinds the textures.
  32052. */
  32053. unbind(): void;
  32054. /**
  32055. * Binds the submesh data.
  32056. * @param world - The world matrix.
  32057. * @param mesh - The BJS mesh.
  32058. * @param subMesh - A submesh of the BJS mesh.
  32059. */
  32060. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32061. /**
  32062. * Returns the animatable textures.
  32063. * @returns - Array of animatable textures.
  32064. */
  32065. getAnimatables(): IAnimatable[];
  32066. /**
  32067. * Returns the texture used for reflections.
  32068. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32069. */
  32070. private _getReflectionTexture();
  32071. /**
  32072. * Returns the texture used for refraction or null if none is used.
  32073. * @returns - Refection texture if present. If no refraction texture and refraction
  32074. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32075. */
  32076. private _getRefractionTexture();
  32077. /**
  32078. * Disposes the resources of the material.
  32079. * @param forceDisposeEffect - Forces the disposal of effects.
  32080. * @param forceDisposeTextures - Forces the disposal of all textures.
  32081. */
  32082. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32083. }
  32084. }
  32085. declare module BABYLON {
  32086. /**
  32087. * The Physically based simple base material of BJS.
  32088. *
  32089. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32090. * It is used as the base class for both the specGloss and metalRough conventions.
  32091. */
  32092. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32093. /**
  32094. * Number of Simultaneous lights allowed on the material.
  32095. */
  32096. maxSimultaneousLights: number;
  32097. /**
  32098. * If sets to true, disables all the lights affecting the material.
  32099. */
  32100. disableLighting: boolean;
  32101. /**
  32102. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32103. */
  32104. environmentTexture: BaseTexture;
  32105. /**
  32106. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32107. */
  32108. invertNormalMapX: boolean;
  32109. /**
  32110. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32111. */
  32112. invertNormalMapY: boolean;
  32113. /**
  32114. * Normal map used in the model.
  32115. */
  32116. normalTexture: BaseTexture;
  32117. /**
  32118. * Emissivie color used to self-illuminate the model.
  32119. */
  32120. emissiveColor: Color3;
  32121. /**
  32122. * Emissivie texture used to self-illuminate the model.
  32123. */
  32124. emissiveTexture: BaseTexture;
  32125. /**
  32126. * Occlusion Channel Strenght.
  32127. */
  32128. occlusionStrength: number;
  32129. /**
  32130. * Occlusion Texture of the material (adding extra occlusion effects).
  32131. */
  32132. occlusionTexture: BaseTexture;
  32133. /**
  32134. * Defines the alpha limits in alpha test mode.
  32135. */
  32136. alphaCutOff: number;
  32137. /**
  32138. * Gets the current double sided mode.
  32139. */
  32140. /**
  32141. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32142. */
  32143. doubleSided: boolean;
  32144. lightmapTexture: BaseTexture;
  32145. useLightmapAsShadowmap: boolean;
  32146. /**
  32147. * Return the active textures of the material.
  32148. */
  32149. getActiveTextures(): BaseTexture[];
  32150. hasTexture(texture: BaseTexture): boolean;
  32151. /**
  32152. * Instantiates a new PBRMaterial instance.
  32153. *
  32154. * @param name The material name
  32155. * @param scene The scene the material will be use in.
  32156. */
  32157. constructor(name: string, scene: Scene);
  32158. getClassName(): string;
  32159. }
  32160. }
  32161. declare module BABYLON {
  32162. /**
  32163. * The Physically based material of BJS.
  32164. *
  32165. * This offers the main features of a standard PBR material.
  32166. * For more information, please refer to the documentation :
  32167. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32168. */
  32169. class PBRMaterial extends PBRBaseMaterial {
  32170. private static _PBRMATERIAL_OPAQUE;
  32171. /**
  32172. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32173. */
  32174. static readonly PBRMATERIAL_OPAQUE: number;
  32175. /**
  32176. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32177. */
  32178. private static _PBRMATERIAL_ALPHATEST;
  32179. /**
  32180. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32181. */
  32182. static readonly PBRMATERIAL_ALPHATEST: number;
  32183. /**
  32184. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32185. */
  32186. private static _PBRMATERIAL_ALPHABLEND;
  32187. /**
  32188. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32189. */
  32190. static readonly PBRMATERIAL_ALPHABLEND: number;
  32191. /**
  32192. * 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.
  32193. * They are also discarded below the alpha cutoff threshold to improve performances.
  32194. */
  32195. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32196. /**
  32197. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32198. * They are also discarded below the alpha cutoff threshold to improve performances.
  32199. */
  32200. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32201. /**
  32202. * Intensity of the direct lights e.g. the four lights available in your scene.
  32203. * This impacts both the direct diffuse and specular highlights.
  32204. */
  32205. directIntensity: number;
  32206. /**
  32207. * Intensity of the emissive part of the material.
  32208. * This helps controlling the emissive effect without modifying the emissive color.
  32209. */
  32210. emissiveIntensity: number;
  32211. /**
  32212. * Intensity of the environment e.g. how much the environment will light the object
  32213. * either through harmonics for rough material or through the refelction for shiny ones.
  32214. */
  32215. environmentIntensity: number;
  32216. /**
  32217. * This is a special control allowing the reduction of the specular highlights coming from the
  32218. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32219. */
  32220. specularIntensity: number;
  32221. /**
  32222. * Debug Control allowing disabling the bump map on this material.
  32223. */
  32224. disableBumpMap: boolean;
  32225. /**
  32226. * AKA Diffuse Texture in standard nomenclature.
  32227. */
  32228. albedoTexture: BaseTexture;
  32229. /**
  32230. * AKA Occlusion Texture in other nomenclature.
  32231. */
  32232. ambientTexture: BaseTexture;
  32233. /**
  32234. * AKA Occlusion Texture Intensity in other nomenclature.
  32235. */
  32236. ambientTextureStrength: number;
  32237. /**
  32238. * Stores the alpha values in a texture.
  32239. */
  32240. opacityTexture: BaseTexture;
  32241. /**
  32242. * Stores the reflection values in a texture.
  32243. */
  32244. reflectionTexture: Nullable<BaseTexture>;
  32245. /**
  32246. * Stores the emissive values in a texture.
  32247. */
  32248. emissiveTexture: BaseTexture;
  32249. /**
  32250. * AKA Specular texture in other nomenclature.
  32251. */
  32252. reflectivityTexture: BaseTexture;
  32253. /**
  32254. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32255. */
  32256. metallicTexture: BaseTexture;
  32257. /**
  32258. * Specifies the metallic scalar of the metallic/roughness workflow.
  32259. * Can also be used to scale the metalness values of the metallic texture.
  32260. */
  32261. metallic: number;
  32262. /**
  32263. * Specifies the roughness scalar of the metallic/roughness workflow.
  32264. * Can also be used to scale the roughness values of the metallic texture.
  32265. */
  32266. roughness: number;
  32267. /**
  32268. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32269. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32270. */
  32271. microSurfaceTexture: BaseTexture;
  32272. /**
  32273. * Stores surface normal data used to displace a mesh in a texture.
  32274. */
  32275. bumpTexture: BaseTexture;
  32276. /**
  32277. * Stores the pre-calculated light information of a mesh in a texture.
  32278. */
  32279. lightmapTexture: BaseTexture;
  32280. /**
  32281. * Stores the refracted light information in a texture.
  32282. */
  32283. refractionTexture: BaseTexture;
  32284. /**
  32285. * The color of a material in ambient lighting.
  32286. */
  32287. ambientColor: Color3;
  32288. /**
  32289. * AKA Diffuse Color in other nomenclature.
  32290. */
  32291. albedoColor: Color3;
  32292. /**
  32293. * AKA Specular Color in other nomenclature.
  32294. */
  32295. reflectivityColor: Color3;
  32296. /**
  32297. * The color reflected from the material.
  32298. */
  32299. reflectionColor: Color3;
  32300. /**
  32301. * The color emitted from the material.
  32302. */
  32303. emissiveColor: Color3;
  32304. /**
  32305. * AKA Glossiness in other nomenclature.
  32306. */
  32307. microSurface: number;
  32308. /**
  32309. * source material index of refraction (IOR)' / 'destination material IOR.
  32310. */
  32311. indexOfRefraction: number;
  32312. /**
  32313. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32314. */
  32315. invertRefractionY: boolean;
  32316. /**
  32317. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32318. * Materials half opaque for instance using refraction could benefit from this control.
  32319. */
  32320. linkRefractionWithTransparency: boolean;
  32321. useLightmapAsShadowmap: boolean;
  32322. /**
  32323. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32324. */
  32325. useAlphaFromAlbedoTexture: boolean;
  32326. /**
  32327. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32328. */
  32329. forceAlphaTest: boolean;
  32330. /**
  32331. * Defines the alpha limits in alpha test mode.
  32332. */
  32333. alphaCutOff: number;
  32334. /**
  32335. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32336. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32337. */
  32338. useSpecularOverAlpha: boolean;
  32339. /**
  32340. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32341. */
  32342. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32343. /**
  32344. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32345. */
  32346. useRoughnessFromMetallicTextureAlpha: boolean;
  32347. /**
  32348. * Specifies if the metallic texture contains the roughness information in its green channel.
  32349. */
  32350. useRoughnessFromMetallicTextureGreen: boolean;
  32351. /**
  32352. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32353. */
  32354. useMetallnessFromMetallicTextureBlue: boolean;
  32355. /**
  32356. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32357. */
  32358. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32359. /**
  32360. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32361. */
  32362. useAmbientInGrayScale: boolean;
  32363. /**
  32364. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32365. * The material will try to infer what glossiness each pixel should be.
  32366. */
  32367. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32368. /**
  32369. * BJS is using an harcoded light falloff based on a manually sets up range.
  32370. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32371. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32372. */
  32373. usePhysicalLightFalloff: boolean;
  32374. /**
  32375. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32376. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32377. */
  32378. useRadianceOverAlpha: boolean;
  32379. /**
  32380. * Allows using an object space normal map (instead of tangent space).
  32381. */
  32382. useObjectSpaceNormalMap: boolean;
  32383. /**
  32384. * Allows using the bump map in parallax mode.
  32385. */
  32386. useParallax: boolean;
  32387. /**
  32388. * Allows using the bump map in parallax occlusion mode.
  32389. */
  32390. useParallaxOcclusion: boolean;
  32391. /**
  32392. * Controls the scale bias of the parallax mode.
  32393. */
  32394. parallaxScaleBias: number;
  32395. /**
  32396. * If sets to true, disables all the lights affecting the material.
  32397. */
  32398. disableLighting: boolean;
  32399. /**
  32400. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32401. */
  32402. forceIrradianceInFragment: boolean;
  32403. /**
  32404. * Number of Simultaneous lights allowed on the material.
  32405. */
  32406. maxSimultaneousLights: number;
  32407. /**
  32408. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32409. */
  32410. invertNormalMapX: boolean;
  32411. /**
  32412. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32413. */
  32414. invertNormalMapY: boolean;
  32415. /**
  32416. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32417. */
  32418. twoSidedLighting: boolean;
  32419. /**
  32420. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32421. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32422. */
  32423. useAlphaFresnel: boolean;
  32424. /**
  32425. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32426. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32427. */
  32428. useLinearAlphaFresnel: boolean;
  32429. /**
  32430. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32431. * And/Or occlude the blended part.
  32432. */
  32433. environmentBRDFTexture: Nullable<BaseTexture>;
  32434. /**
  32435. * Force normal to face away from face.
  32436. */
  32437. forceNormalForward: boolean;
  32438. /**
  32439. * Enables specular anti aliasing in the PBR shader.
  32440. * It will both interacts on the Geometry for analytical and IBL lighting.
  32441. * It also prefilter the roughness map based on the bump values.
  32442. */
  32443. enableSpecularAntiAliasing: boolean;
  32444. /**
  32445. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32446. * makes the reflect vector face the model (under horizon).
  32447. */
  32448. useHorizonOcclusion: boolean;
  32449. /**
  32450. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32451. * too much the area relying on ambient texture to define their ambient occlusion.
  32452. */
  32453. useRadianceOcclusion: boolean;
  32454. /**
  32455. * If set to true, no lighting calculations will be applied.
  32456. */
  32457. unlit: boolean;
  32458. /**
  32459. * Gets the image processing configuration used either in this material.
  32460. */
  32461. /**
  32462. * Sets the Default image processing configuration used either in the this material.
  32463. *
  32464. * If sets to null, the scene one is in use.
  32465. */
  32466. imageProcessingConfiguration: ImageProcessingConfiguration;
  32467. /**
  32468. * Gets wether the color curves effect is enabled.
  32469. */
  32470. /**
  32471. * Sets wether the color curves effect is enabled.
  32472. */
  32473. cameraColorCurvesEnabled: boolean;
  32474. /**
  32475. * Gets wether the color grading effect is enabled.
  32476. */
  32477. /**
  32478. * Gets wether the color grading effect is enabled.
  32479. */
  32480. cameraColorGradingEnabled: boolean;
  32481. /**
  32482. * Gets wether tonemapping is enabled or not.
  32483. */
  32484. /**
  32485. * Sets wether tonemapping is enabled or not
  32486. */
  32487. cameraToneMappingEnabled: boolean;
  32488. /**
  32489. * The camera exposure used on this material.
  32490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32491. * This corresponds to a photographic exposure.
  32492. */
  32493. /**
  32494. * The camera exposure used on this material.
  32495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32496. * This corresponds to a photographic exposure.
  32497. */
  32498. cameraExposure: number;
  32499. /**
  32500. * Gets The camera contrast used on this material.
  32501. */
  32502. /**
  32503. * Sets The camera contrast used on this material.
  32504. */
  32505. cameraContrast: number;
  32506. /**
  32507. * Gets the Color Grading 2D Lookup Texture.
  32508. */
  32509. /**
  32510. * Sets the Color Grading 2D Lookup Texture.
  32511. */
  32512. cameraColorGradingTexture: Nullable<BaseTexture>;
  32513. /**
  32514. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32515. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32516. * 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;
  32517. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32518. */
  32519. /**
  32520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32522. * 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;
  32523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32524. */
  32525. cameraColorCurves: Nullable<ColorCurves>;
  32526. /**
  32527. * Instantiates a new PBRMaterial instance.
  32528. *
  32529. * @param name The material name
  32530. * @param scene The scene the material will be use in.
  32531. */
  32532. constructor(name: string, scene: Scene);
  32533. /**
  32534. * Returns the name of this material class.
  32535. */
  32536. getClassName(): string;
  32537. /**
  32538. * Returns an array of the actively used textures.
  32539. * @returns - Array of BaseTextures
  32540. */
  32541. getActiveTextures(): BaseTexture[];
  32542. /**
  32543. * Checks to see if a texture is used in the material.
  32544. * @param texture - Base texture to use.
  32545. * @returns - Boolean specifying if a texture is used in the material.
  32546. */
  32547. hasTexture(texture: BaseTexture): boolean;
  32548. /**
  32549. * Makes a duplicate of the current material.
  32550. * @param name - name to use for the new material.
  32551. */
  32552. clone(name: string): PBRMaterial;
  32553. /**
  32554. * Serializes this PBR Material.
  32555. * @returns - An object with the serialized material.
  32556. */
  32557. serialize(): any;
  32558. /**
  32559. * Parses a PBR Material from a serialized object.
  32560. * @param source - Serialized object.
  32561. * @param scene - BJS scene instance.
  32562. * @param rootUrl - url for the scene object
  32563. * @returns - PBRMaterial
  32564. */
  32565. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32566. }
  32567. }
  32568. declare module BABYLON {
  32569. /**
  32570. * The PBR material of BJS following the metal roughness convention.
  32571. *
  32572. * This fits to the PBR convention in the GLTF definition:
  32573. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32574. */
  32575. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32576. /**
  32577. * The base color has two different interpretations depending on the value of metalness.
  32578. * When the material is a metal, the base color is the specific measured reflectance value
  32579. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32580. * of the material.
  32581. */
  32582. baseColor: Color3;
  32583. /**
  32584. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32585. * well as opacity information in the alpha channel.
  32586. */
  32587. baseTexture: BaseTexture;
  32588. /**
  32589. * Specifies the metallic scalar value of the material.
  32590. * Can also be used to scale the metalness values of the metallic texture.
  32591. */
  32592. metallic: number;
  32593. /**
  32594. * Specifies the roughness scalar value of the material.
  32595. * Can also be used to scale the roughness values of the metallic texture.
  32596. */
  32597. roughness: number;
  32598. /**
  32599. * Texture containing both the metallic value in the B channel and the
  32600. * roughness value in the G channel to keep better precision.
  32601. */
  32602. metallicRoughnessTexture: BaseTexture;
  32603. /**
  32604. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32605. *
  32606. * @param name The material name
  32607. * @param scene The scene the material will be use in.
  32608. */
  32609. constructor(name: string, scene: Scene);
  32610. /**
  32611. * Return the currrent class name of the material.
  32612. */
  32613. getClassName(): string;
  32614. /**
  32615. * Return the active textures of the material.
  32616. */
  32617. getActiveTextures(): BaseTexture[];
  32618. /**
  32619. * Checks to see if a texture is used in the material.
  32620. * @param texture - Base texture to use.
  32621. * @returns - Boolean specifying if a texture is used in the material.
  32622. */
  32623. hasTexture(texture: BaseTexture): boolean;
  32624. /**
  32625. * Makes a duplicate of the current material.
  32626. * @param name - name to use for the new material.
  32627. */
  32628. clone(name: string): PBRMetallicRoughnessMaterial;
  32629. /**
  32630. * Serialize the material to a parsable JSON object.
  32631. */
  32632. serialize(): any;
  32633. /**
  32634. * Parses a JSON object correponding to the serialize function.
  32635. */
  32636. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32637. }
  32638. }
  32639. declare module BABYLON {
  32640. /**
  32641. * The PBR material of BJS following the specular glossiness convention.
  32642. *
  32643. * This fits to the PBR convention in the GLTF definition:
  32644. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32645. */
  32646. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32647. /**
  32648. * Specifies the diffuse color of the material.
  32649. */
  32650. diffuseColor: Color3;
  32651. /**
  32652. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32653. * channel.
  32654. */
  32655. diffuseTexture: BaseTexture;
  32656. /**
  32657. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32658. */
  32659. specularColor: Color3;
  32660. /**
  32661. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32662. */
  32663. glossiness: number;
  32664. /**
  32665. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32666. */
  32667. specularGlossinessTexture: BaseTexture;
  32668. /**
  32669. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32670. *
  32671. * @param name The material name
  32672. * @param scene The scene the material will be use in.
  32673. */
  32674. constructor(name: string, scene: Scene);
  32675. /**
  32676. * Return the currrent class name of the material.
  32677. */
  32678. getClassName(): string;
  32679. /**
  32680. * Return the active textures of the material.
  32681. */
  32682. getActiveTextures(): BaseTexture[];
  32683. /**
  32684. * Checks to see if a texture is used in the material.
  32685. * @param texture - Base texture to use.
  32686. * @returns - Boolean specifying if a texture is used in the material.
  32687. */
  32688. hasTexture(texture: BaseTexture): boolean;
  32689. /**
  32690. * Makes a duplicate of the current material.
  32691. * @param name - name to use for the new material.
  32692. */
  32693. clone(name: string): PBRSpecularGlossinessMaterial;
  32694. /**
  32695. * Serialize the material to a parsable JSON object.
  32696. */
  32697. serialize(): any;
  32698. /**
  32699. * Parses a JSON object correponding to the serialize function.
  32700. */
  32701. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32702. }
  32703. }
  32704. declare module BABYLON {
  32705. class BaseTexture {
  32706. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32707. name: string;
  32708. private _hasAlpha;
  32709. hasAlpha: boolean;
  32710. getAlphaFromRGB: boolean;
  32711. level: number;
  32712. coordinatesIndex: number;
  32713. private _coordinatesMode;
  32714. /**
  32715. * How a texture is mapped.
  32716. *
  32717. * | Value | Type | Description |
  32718. * | ----- | ----------------------------------- | ----------- |
  32719. * | 0 | EXPLICIT_MODE | |
  32720. * | 1 | SPHERICAL_MODE | |
  32721. * | 2 | PLANAR_MODE | |
  32722. * | 3 | CUBIC_MODE | |
  32723. * | 4 | PROJECTION_MODE | |
  32724. * | 5 | SKYBOX_MODE | |
  32725. * | 6 | INVCUBIC_MODE | |
  32726. * | 7 | EQUIRECTANGULAR_MODE | |
  32727. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32728. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32729. */
  32730. coordinatesMode: number;
  32731. /**
  32732. * | Value | Type | Description |
  32733. * | ----- | ------------------ | ----------- |
  32734. * | 0 | CLAMP_ADDRESSMODE | |
  32735. * | 1 | WRAP_ADDRESSMODE | |
  32736. * | 2 | MIRROR_ADDRESSMODE | |
  32737. */
  32738. wrapU: number;
  32739. /**
  32740. * | Value | Type | Description |
  32741. * | ----- | ------------------ | ----------- |
  32742. * | 0 | CLAMP_ADDRESSMODE | |
  32743. * | 1 | WRAP_ADDRESSMODE | |
  32744. * | 2 | MIRROR_ADDRESSMODE | |
  32745. */
  32746. wrapV: number;
  32747. /**
  32748. * | Value | Type | Description |
  32749. * | ----- | ------------------ | ----------- |
  32750. * | 0 | CLAMP_ADDRESSMODE | |
  32751. * | 1 | WRAP_ADDRESSMODE | |
  32752. * | 2 | MIRROR_ADDRESSMODE | |
  32753. */
  32754. wrapR: number;
  32755. anisotropicFilteringLevel: number;
  32756. isCube: boolean;
  32757. is3D: boolean;
  32758. gammaSpace: boolean;
  32759. invertZ: boolean;
  32760. lodLevelInAlpha: boolean;
  32761. lodGenerationOffset: number;
  32762. lodGenerationScale: number;
  32763. isRenderTarget: boolean;
  32764. readonly uid: string;
  32765. toString(): string;
  32766. getClassName(): string;
  32767. animations: Animation[];
  32768. /**
  32769. * An event triggered when the texture is disposed.
  32770. */
  32771. onDisposeObservable: Observable<BaseTexture>;
  32772. private _onDisposeObserver;
  32773. onDispose: () => void;
  32774. delayLoadState: number;
  32775. private _scene;
  32776. _texture: Nullable<InternalTexture>;
  32777. private _uid;
  32778. readonly isBlocking: boolean;
  32779. constructor(scene: Nullable<Scene>);
  32780. getScene(): Nullable<Scene>;
  32781. getTextureMatrix(): Matrix;
  32782. getReflectionTextureMatrix(): Matrix;
  32783. getInternalTexture(): Nullable<InternalTexture>;
  32784. isReadyOrNotBlocking(): boolean;
  32785. isReady(): boolean;
  32786. getSize(): ISize;
  32787. getBaseSize(): ISize;
  32788. scale(ratio: number): void;
  32789. readonly canRescale: boolean;
  32790. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  32791. _rebuild(): void;
  32792. delayLoad(): void;
  32793. clone(): Nullable<BaseTexture>;
  32794. readonly textureType: number;
  32795. readonly textureFormat: number;
  32796. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32797. releaseInternalTexture(): void;
  32798. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32799. readonly _lodTextureHigh: Nullable<BaseTexture>;
  32800. readonly _lodTextureMid: Nullable<BaseTexture>;
  32801. readonly _lodTextureLow: Nullable<BaseTexture>;
  32802. dispose(): void;
  32803. serialize(): any;
  32804. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32805. }
  32806. }
  32807. declare module BABYLON {
  32808. /**
  32809. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32810. * It can help converting any input color in a desired output one. This can then be used to create effects
  32811. * from sepia, black and white to sixties or futuristic rendering...
  32812. *
  32813. * The only supported format is currently 3dl.
  32814. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32815. */
  32816. class ColorGradingTexture extends BaseTexture {
  32817. /**
  32818. * The current texture matrix. (will always be identity in color grading texture)
  32819. */
  32820. private _textureMatrix;
  32821. /**
  32822. * The texture URL.
  32823. */
  32824. url: string;
  32825. /**
  32826. * Empty line regex stored for GC.
  32827. */
  32828. private static _noneEmptyLineRegex;
  32829. private _engine;
  32830. /**
  32831. * Instantiates a ColorGradingTexture from the following parameters.
  32832. *
  32833. * @param url The location of the color gradind data (currently only supporting 3dl)
  32834. * @param scene The scene the texture will be used in
  32835. */
  32836. constructor(url: string, scene: Scene);
  32837. /**
  32838. * Returns the texture matrix used in most of the material.
  32839. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32840. */
  32841. getTextureMatrix(): Matrix;
  32842. /**
  32843. * Occurs when the file being loaded is a .3dl LUT file.
  32844. */
  32845. private load3dlTexture();
  32846. /**
  32847. * Starts the loading process of the texture.
  32848. */
  32849. private loadTexture();
  32850. /**
  32851. * Clones the color gradind texture.
  32852. */
  32853. clone(): ColorGradingTexture;
  32854. /**
  32855. * Called during delayed load for textures.
  32856. */
  32857. delayLoad(): void;
  32858. /**
  32859. * Parses a color grading texture serialized by Babylon.
  32860. * @param parsedTexture The texture information being parsedTexture
  32861. * @param scene The scene to load the texture in
  32862. * @param rootUrl The root url of the data assets to load
  32863. * @return A color gradind texture
  32864. */
  32865. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32866. /**
  32867. * Serializes the LUT texture to json format.
  32868. */
  32869. serialize(): any;
  32870. }
  32871. }
  32872. declare module BABYLON {
  32873. class CubeTexture extends BaseTexture {
  32874. url: string;
  32875. coordinatesMode: number;
  32876. /**
  32877. * Gets or sets the center of the bounding box associated with the cube texture
  32878. * It must define where the camera used to render the texture was set
  32879. */
  32880. boundingBoxPosition: Vector3;
  32881. private _boundingBoxSize;
  32882. /**
  32883. * Gets or sets the size of the bounding box associated with the cube texture
  32884. * When defined, the cubemap will switch to local mode
  32885. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32886. * @example https://www.babylonjs-playground.com/#RNASML
  32887. */
  32888. boundingBoxSize: Vector3;
  32889. protected _rotationY: number;
  32890. /**
  32891. * Gets texture matrix rotation angle around Y axis radians.
  32892. */
  32893. /**
  32894. * Sets texture matrix rotation angle around Y axis in radians.
  32895. */
  32896. rotationY: number;
  32897. private _noMipmap;
  32898. private _files;
  32899. private _extensions;
  32900. private _textureMatrix;
  32901. private _format;
  32902. private _prefiltered;
  32903. private _createPolynomials;
  32904. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  32905. /**
  32906. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  32907. * @param url defines the url of the prefiltered texture
  32908. * @param scene defines the scene the texture is attached to
  32909. * @param forcedExtension defines the extension of the file if different from the url
  32910. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  32911. * @return the prefiltered texture
  32912. */
  32913. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  32914. /**
  32915. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  32916. * as prefiltered data.
  32917. * @param rootUrl defines the url of the texture or the root name of the six images
  32918. * @param scene defines the scene the texture is attached to
  32919. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  32920. * @param noMipmap defines if mipmaps should be created or not
  32921. * @param files defines the six files to load for the different faces
  32922. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  32923. * @param onError defines a callback triggered in case of error during load
  32924. * @param format defines the internal format to use for the texture once loaded
  32925. * @param prefiltered defines whether or not the texture is created from prefiltered data
  32926. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  32927. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  32928. * @return the cube texture
  32929. */
  32930. 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);
  32931. delayLoad(): void;
  32932. getReflectionTextureMatrix(): Matrix;
  32933. setReflectionTextureMatrix(value: Matrix): void;
  32934. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  32935. clone(): CubeTexture;
  32936. }
  32937. }
  32938. declare module BABYLON {
  32939. /**
  32940. * A class extending {BABYLON.Texture} allowing drawing on a texture
  32941. * @see http://doc.babylonjs.com/how_to/dynamictexture
  32942. */
  32943. class DynamicTexture extends Texture {
  32944. private _generateMipMaps;
  32945. private _canvas;
  32946. private _context;
  32947. private _engine;
  32948. /**
  32949. * Creates a {BABYLON.DynamicTexture}
  32950. * @param name defines the name of the texture
  32951. * @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
  32952. * @param scene defines the scene where you want the texture
  32953. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  32954. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  32955. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  32956. */
  32957. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  32958. /**
  32959. * Gets the current state of canRescale
  32960. */
  32961. readonly canRescale: boolean;
  32962. private _recreate(textureSize);
  32963. /**
  32964. * Scales the texture
  32965. * @param ratio the scale factor to apply to both width and height
  32966. */
  32967. scale(ratio: number): void;
  32968. /**
  32969. * Resizes the texture
  32970. * @param width the new width
  32971. * @param height the new height
  32972. */
  32973. scaleTo(width: number, height: number): void;
  32974. /**
  32975. * Gets the context of the canvas used by the texture
  32976. * @returns the canvas context of the dynamic texture
  32977. */
  32978. getContext(): CanvasRenderingContext2D;
  32979. /**
  32980. * Clears the texture
  32981. */
  32982. clear(): void;
  32983. /**
  32984. * Updates the texture
  32985. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32986. */
  32987. update(invertY?: boolean): void;
  32988. /**
  32989. * Draws text onto the texture
  32990. * @param text defines the text to be drawn
  32991. * @param x defines the placement of the text from the left
  32992. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  32993. * @param font defines the font to be used with font-style, font-size, font-name
  32994. * @param color defines the color used for the text
  32995. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  32996. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32997. * @param update defines whether texture is immediately update (default is true)
  32998. */
  32999. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33000. /**
  33001. * Clones the texture
  33002. * @returns the clone of the texture.
  33003. */
  33004. clone(): DynamicTexture;
  33005. /** @hidden */
  33006. _rebuild(): void;
  33007. }
  33008. }
  33009. declare module BABYLON {
  33010. /**
  33011. * This represents a texture coming from an HDR input.
  33012. *
  33013. * The only supported format is currently panorama picture stored in RGBE format.
  33014. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33015. */
  33016. class HDRCubeTexture extends BaseTexture {
  33017. private static _facesMapping;
  33018. private _generateHarmonics;
  33019. private _noMipmap;
  33020. private _textureMatrix;
  33021. private _size;
  33022. private _onLoad;
  33023. private _onError;
  33024. /**
  33025. * The texture URL.
  33026. */
  33027. url: string;
  33028. /**
  33029. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33030. */
  33031. coordinatesMode: number;
  33032. protected _isBlocking: boolean;
  33033. /**
  33034. * Gets wether or not the texture is blocking during loading.
  33035. */
  33036. /**
  33037. * Sets wether or not the texture is blocking during loading.
  33038. */
  33039. isBlocking: boolean;
  33040. protected _rotationY: number;
  33041. /**
  33042. * Gets texture matrix rotation angle around Y axis radians.
  33043. */
  33044. /**
  33045. * Sets texture matrix rotation angle around Y axis in radians.
  33046. */
  33047. rotationY: number;
  33048. /**
  33049. * Gets or sets the center of the bounding box associated with the cube texture
  33050. * It must define where the camera used to render the texture was set
  33051. */
  33052. boundingBoxPosition: Vector3;
  33053. private _boundingBoxSize;
  33054. /**
  33055. * Gets or sets the size of the bounding box associated with the cube texture
  33056. * When defined, the cubemap will switch to local mode
  33057. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33058. * @example https://www.babylonjs-playground.com/#RNASML
  33059. */
  33060. boundingBoxSize: Vector3;
  33061. /**
  33062. * Instantiates an HDRTexture from the following parameters.
  33063. *
  33064. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33065. * @param scene The scene the texture will be used in
  33066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33067. * @param noMipmap Forces to not generate the mipmap if true
  33068. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33069. * @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)
  33070. * @param reserved Reserved flag for internal use.
  33071. */
  33072. 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>);
  33073. /**
  33074. * Occurs when the file is raw .hdr file.
  33075. */
  33076. private loadTexture();
  33077. clone(): HDRCubeTexture;
  33078. delayLoad(): void;
  33079. getReflectionTextureMatrix(): Matrix;
  33080. setReflectionTextureMatrix(value: Matrix): void;
  33081. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33082. serialize(): any;
  33083. }
  33084. }
  33085. declare module BABYLON {
  33086. /**
  33087. * Class used to store data associated with WebGL texture data for the engine
  33088. * This class should not be used directly
  33089. */
  33090. class InternalTexture implements IInternalTextureTracker {
  33091. /**
  33092. * The source of the texture data is unknown
  33093. */
  33094. static DATASOURCE_UNKNOWN: number;
  33095. /**
  33096. * Texture data comes from an URL
  33097. */
  33098. static DATASOURCE_URL: number;
  33099. /**
  33100. * Texture data is only used for temporary storage
  33101. */
  33102. static DATASOURCE_TEMP: number;
  33103. /**
  33104. * Texture data comes from raw data (ArrayBuffer)
  33105. */
  33106. static DATASOURCE_RAW: number;
  33107. /**
  33108. * Texture content is dynamic (video or dynamic texture)
  33109. */
  33110. static DATASOURCE_DYNAMIC: number;
  33111. /**
  33112. * Texture content is generated by rendering to it
  33113. */
  33114. static DATASOURCE_RENDERTARGET: number;
  33115. /**
  33116. * Texture content is part of a multi render target process
  33117. */
  33118. static DATASOURCE_MULTIRENDERTARGET: number;
  33119. /**
  33120. * Texture data comes from a cube data file
  33121. */
  33122. static DATASOURCE_CUBE: number;
  33123. /**
  33124. * Texture data comes from a raw cube data
  33125. */
  33126. static DATASOURCE_CUBERAW: number;
  33127. /**
  33128. * Texture data come from a prefiltered cube data file
  33129. */
  33130. static DATASOURCE_CUBEPREFILTERED: number;
  33131. /**
  33132. * Texture content is raw 3D data
  33133. */
  33134. static DATASOURCE_RAW3D: number;
  33135. /**
  33136. * Texture content is a depth texture
  33137. */
  33138. static DATASOURCE_DEPTHTEXTURE: number;
  33139. /**
  33140. * Defines if the texture is ready
  33141. */
  33142. isReady: boolean;
  33143. /**
  33144. * Defines if the texture is a cube texture
  33145. */
  33146. isCube: boolean;
  33147. /**
  33148. * Defines if the texture contains 3D data
  33149. */
  33150. is3D: boolean;
  33151. /**
  33152. * Gets the URL used to load this texture
  33153. */
  33154. url: string;
  33155. /**
  33156. * Gets the sampling mode of the texture
  33157. */
  33158. samplingMode: number;
  33159. /**
  33160. * Gets a boolean indicating if the texture needs mipmaps generation
  33161. */
  33162. generateMipMaps: boolean;
  33163. /**
  33164. * Gets the number of samples used by the texture (WebGL2+ only)
  33165. */
  33166. samples: number;
  33167. /**
  33168. * Gets the type of the texture
  33169. */
  33170. type: number;
  33171. /**
  33172. * Gets the format of the texture
  33173. */
  33174. format: number;
  33175. /**
  33176. * Observable called when the texture is loaded
  33177. */
  33178. onLoadedObservable: Observable<InternalTexture>;
  33179. /**
  33180. * Gets the width of the texture
  33181. */
  33182. width: number;
  33183. /**
  33184. * Gets the height of the texture
  33185. */
  33186. height: number;
  33187. /**
  33188. * Gets the depth of the texture
  33189. */
  33190. depth: number;
  33191. /**
  33192. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33193. */
  33194. baseWidth: number;
  33195. /**
  33196. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33197. */
  33198. baseHeight: number;
  33199. /**
  33200. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33201. */
  33202. baseDepth: number;
  33203. /**
  33204. * Gets a boolean indicating if the texture is inverted on Y axis
  33205. */
  33206. invertY: boolean;
  33207. /**
  33208. * Gets or set the previous tracker in the list
  33209. */
  33210. previous: Nullable<IInternalTextureTracker>;
  33211. /**
  33212. * Gets or set the next tracker in the list
  33213. */
  33214. next: Nullable<IInternalTextureTracker>;
  33215. /** @hidden */
  33216. _initialSlot: number;
  33217. /** @hidden */
  33218. _designatedSlot: number;
  33219. /** @hidden */
  33220. _dataSource: number;
  33221. /** @hidden */
  33222. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  33223. /** @hidden */
  33224. _bufferView: Nullable<ArrayBufferView>;
  33225. /** @hidden */
  33226. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33227. /** @hidden */
  33228. _size: number;
  33229. /** @hidden */
  33230. _extension: string;
  33231. /** @hidden */
  33232. _files: Nullable<string[]>;
  33233. /** @hidden */
  33234. _workingCanvas: HTMLCanvasElement;
  33235. /** @hidden */
  33236. _workingContext: CanvasRenderingContext2D;
  33237. /** @hidden */
  33238. _framebuffer: Nullable<WebGLFramebuffer>;
  33239. /** @hidden */
  33240. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33241. /** @hidden */
  33242. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33243. /** @hidden */
  33244. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33245. /** @hidden */
  33246. _attachments: Nullable<number[]>;
  33247. /** @hidden */
  33248. _cachedCoordinatesMode: Nullable<number>;
  33249. /** @hidden */
  33250. _cachedWrapU: Nullable<number>;
  33251. /** @hidden */
  33252. _cachedWrapV: Nullable<number>;
  33253. /** @hidden */
  33254. _cachedWrapR: Nullable<number>;
  33255. /** @hidden */
  33256. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33257. /** @hidden */
  33258. _isDisabled: boolean;
  33259. /** @hidden */
  33260. _compression: Nullable<string>;
  33261. /** @hidden */
  33262. _generateStencilBuffer: boolean;
  33263. /** @hidden */
  33264. _generateDepthBuffer: boolean;
  33265. /** @hidden */
  33266. _comparisonFunction: number;
  33267. /** @hidden */
  33268. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33269. /** @hidden */
  33270. _lodGenerationScale: number;
  33271. /** @hidden */
  33272. _lodGenerationOffset: number;
  33273. /** @hidden */
  33274. _lodTextureHigh: BaseTexture;
  33275. /** @hidden */
  33276. _lodTextureMid: BaseTexture;
  33277. /** @hidden */
  33278. _lodTextureLow: BaseTexture;
  33279. /** @hidden */
  33280. _webGLTexture: Nullable<WebGLTexture>;
  33281. /** @hidden */
  33282. _references: number;
  33283. private _engine;
  33284. /**
  33285. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33286. */
  33287. readonly dataSource: number;
  33288. /**
  33289. * Creates a new InternalTexture
  33290. * @param engine defines the engine to use
  33291. * @param dataSource defines the type of data that will be used
  33292. */
  33293. constructor(engine: Engine, dataSource: number);
  33294. /**
  33295. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33296. */
  33297. incrementReferences(): void;
  33298. /**
  33299. * Change the size of the texture (not the size of the content)
  33300. * @param width defines the new width
  33301. * @param height defines the new height
  33302. * @param depth defines the new depth (1 by default)
  33303. */
  33304. updateSize(width: int, height: int, depth?: int): void;
  33305. /** @hidden */
  33306. _rebuild(): void;
  33307. private _swapAndDie(target);
  33308. /**
  33309. * Dispose the current allocated resources
  33310. */
  33311. dispose(): void;
  33312. }
  33313. }
  33314. declare module BABYLON {
  33315. /**
  33316. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33317. */
  33318. interface IInternalTextureTracker {
  33319. /**
  33320. * Gets or set the previous tracker in the list
  33321. */
  33322. previous: Nullable<IInternalTextureTracker>;
  33323. /**
  33324. * Gets or set the next tracker in the list
  33325. */
  33326. next: Nullable<IInternalTextureTracker>;
  33327. }
  33328. /**
  33329. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33330. */
  33331. class DummyInternalTextureTracker {
  33332. /**
  33333. * Gets or set the previous tracker in the list
  33334. */
  33335. previous: Nullable<IInternalTextureTracker>;
  33336. /**
  33337. * Gets or set the next tracker in the list
  33338. */
  33339. next: Nullable<IInternalTextureTracker>;
  33340. }
  33341. }
  33342. declare module BABYLON {
  33343. class MirrorTexture extends RenderTargetTexture {
  33344. private scene;
  33345. mirrorPlane: Plane;
  33346. private _transformMatrix;
  33347. private _mirrorMatrix;
  33348. private _savedViewMatrix;
  33349. private _blurX;
  33350. private _blurY;
  33351. private _adaptiveBlurKernel;
  33352. private _blurKernelX;
  33353. private _blurKernelY;
  33354. private _blurRatio;
  33355. blurRatio: number;
  33356. adaptiveBlurKernel: number;
  33357. blurKernel: number;
  33358. blurKernelX: number;
  33359. blurKernelY: number;
  33360. private _autoComputeBlurKernel();
  33361. protected _onRatioRescale(): void;
  33362. private _updateGammaSpace();
  33363. private _imageProcessingConfigChangeObserver;
  33364. constructor(name: string, size: number | {
  33365. width: number;
  33366. height: number;
  33367. } | {
  33368. ratio: number;
  33369. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33370. private _preparePostProcesses();
  33371. clone(): MirrorTexture;
  33372. serialize(): any;
  33373. dispose(): void;
  33374. }
  33375. }
  33376. declare module BABYLON {
  33377. interface IMultiRenderTargetOptions {
  33378. generateMipMaps?: boolean;
  33379. types?: number[];
  33380. samplingModes?: number[];
  33381. generateDepthBuffer?: boolean;
  33382. generateStencilBuffer?: boolean;
  33383. generateDepthTexture?: boolean;
  33384. textureCount?: number;
  33385. doNotChangeAspectRatio?: boolean;
  33386. defaultType?: number;
  33387. }
  33388. class MultiRenderTarget extends RenderTargetTexture {
  33389. private _internalTextures;
  33390. private _textures;
  33391. readonly isSupported: boolean;
  33392. private _multiRenderTargetOptions;
  33393. readonly textures: Texture[];
  33394. readonly depthTexture: Texture;
  33395. wrapU: number;
  33396. wrapV: number;
  33397. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33398. _rebuild(): void;
  33399. private _createInternalTextures();
  33400. private _createTextures();
  33401. samples: number;
  33402. resize(size: any): void;
  33403. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33404. dispose(): void;
  33405. releaseInternalTextures(): void;
  33406. }
  33407. }
  33408. declare module BABYLON {
  33409. class RawTexture extends Texture {
  33410. format: number;
  33411. private _engine;
  33412. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33413. update(data: ArrayBufferView): void;
  33414. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33415. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33416. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33417. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33418. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33419. }
  33420. }
  33421. declare module BABYLON {
  33422. /**
  33423. * Class used to store 3D textures containing user data
  33424. */
  33425. class RawTexture3D extends Texture {
  33426. /** Gets or sets the texture format to use*/
  33427. format: number;
  33428. private _engine;
  33429. /**
  33430. * Create a new RawTexture3D
  33431. * @param data defines the data of the texture
  33432. * @param width defines the width of the texture
  33433. * @param height defines the height of the texture
  33434. * @param depth defines the depth of the texture
  33435. * @param format defines the texture format to use
  33436. * @param scene defines the hosting scene
  33437. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33438. * @param invertY defines if texture must be stored with Y axis inverted
  33439. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33440. */
  33441. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33442. /** Gets or sets the texture format to use*/
  33443. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33444. /**
  33445. * Update the texture with new data
  33446. * @param data defines the data to store in the texture
  33447. */
  33448. update(data: ArrayBufferView): void;
  33449. }
  33450. }
  33451. declare module BABYLON {
  33452. /**
  33453. * Creates a refraction texture used by refraction channel of the standard material.
  33454. * @param name the texture name
  33455. * @param size size of the underlying texture
  33456. * @param scene root scene
  33457. */
  33458. class RefractionTexture extends RenderTargetTexture {
  33459. refractionPlane: Plane;
  33460. depth: number;
  33461. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33462. clone(): RefractionTexture;
  33463. serialize(): any;
  33464. }
  33465. }
  33466. declare module BABYLON {
  33467. class RenderTargetTexture extends Texture {
  33468. isCube: boolean;
  33469. static _REFRESHRATE_RENDER_ONCE: number;
  33470. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33471. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33472. static readonly REFRESHRATE_RENDER_ONCE: number;
  33473. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33474. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33475. /**
  33476. * Use this predicate to dynamically define the list of mesh you want to render.
  33477. * If set, the renderList property will be overwritten.
  33478. */
  33479. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33480. /**
  33481. * Use this list to define the list of mesh you want to render.
  33482. */
  33483. renderList: Nullable<Array<AbstractMesh>>;
  33484. renderParticles: boolean;
  33485. renderSprites: boolean;
  33486. coordinatesMode: number;
  33487. activeCamera: Nullable<Camera>;
  33488. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33489. useCameraPostProcesses: boolean;
  33490. ignoreCameraViewport: boolean;
  33491. private _postProcessManager;
  33492. private _postProcesses;
  33493. private _resizeObserver;
  33494. /**
  33495. * An event triggered when the texture is unbind.
  33496. */
  33497. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33498. /**
  33499. * An event triggered when the texture is unbind.
  33500. */
  33501. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33502. private _onAfterUnbindObserver;
  33503. onAfterUnbind: () => void;
  33504. /**
  33505. * An event triggered before rendering the texture
  33506. */
  33507. onBeforeRenderObservable: Observable<number>;
  33508. private _onBeforeRenderObserver;
  33509. onBeforeRender: (faceIndex: number) => void;
  33510. /**
  33511. * An event triggered after rendering the texture
  33512. */
  33513. onAfterRenderObservable: Observable<number>;
  33514. private _onAfterRenderObserver;
  33515. onAfterRender: (faceIndex: number) => void;
  33516. /**
  33517. * An event triggered after the texture clear
  33518. */
  33519. onClearObservable: Observable<Engine>;
  33520. private _onClearObserver;
  33521. onClear: (Engine: Engine) => void;
  33522. clearColor: Color4;
  33523. protected _size: number | {
  33524. width: number;
  33525. height: number;
  33526. };
  33527. protected _initialSizeParameter: number | {
  33528. width: number;
  33529. height: number;
  33530. } | {
  33531. ratio: number;
  33532. };
  33533. protected _sizeRatio: Nullable<number>;
  33534. _generateMipMaps: boolean;
  33535. protected _renderingManager: RenderingManager;
  33536. _waitingRenderList: string[];
  33537. protected _doNotChangeAspectRatio: boolean;
  33538. protected _currentRefreshId: number;
  33539. protected _refreshRate: number;
  33540. protected _textureMatrix: Matrix;
  33541. protected _samples: number;
  33542. protected _renderTargetOptions: RenderTargetCreationOptions;
  33543. readonly renderTargetOptions: RenderTargetCreationOptions;
  33544. protected _engine: Engine;
  33545. protected _onRatioRescale(): void;
  33546. /**
  33547. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33548. * It must define where the camera used to render the texture is set
  33549. */
  33550. boundingBoxPosition: Vector3;
  33551. private _boundingBoxSize;
  33552. /**
  33553. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33554. * When defined, the cubemap will switch to local mode
  33555. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33556. * @example https://www.babylonjs-playground.com/#RNASML
  33557. */
  33558. boundingBoxSize: Vector3;
  33559. /**
  33560. * In case the RTT has been created with a depth texture, get the associated
  33561. * depth texture.
  33562. * Otherwise, return null.
  33563. */
  33564. depthStencilTexture: Nullable<InternalTexture>;
  33565. /**
  33566. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33567. * or used a shadow, depth texture...
  33568. * @param name The friendly name of the texture
  33569. * @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)
  33570. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33571. * @param generateMipMaps True if mip maps need to be generated after render.
  33572. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33573. * @param type The type of the buffer in the RTT (int, half float, float...)
  33574. * @param isCube True if a cube texture needs to be created
  33575. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33576. * @param generateDepthBuffer True to generate a depth buffer
  33577. * @param generateStencilBuffer True to generate a stencil buffer
  33578. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33579. */
  33580. constructor(name: string, size: number | {
  33581. width: number;
  33582. height: number;
  33583. } | {
  33584. ratio: number;
  33585. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33586. /**
  33587. * Creates a depth stencil texture.
  33588. * This is only available in WebGL 2 or with the depth texture extension available.
  33589. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33590. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33591. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33592. */
  33593. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33594. private _processSizeParameter(size);
  33595. samples: number;
  33596. resetRefreshCounter(): void;
  33597. refreshRate: number;
  33598. addPostProcess(postProcess: PostProcess): void;
  33599. clearPostProcesses(dispose?: boolean): void;
  33600. removePostProcess(postProcess: PostProcess): void;
  33601. _shouldRender(): boolean;
  33602. getRenderSize(): number;
  33603. getRenderWidth(): number;
  33604. getRenderHeight(): number;
  33605. readonly canRescale: boolean;
  33606. scale(ratio: number): void;
  33607. getReflectionTextureMatrix(): Matrix;
  33608. resize(size: number | {
  33609. width: number;
  33610. height: number;
  33611. } | {
  33612. ratio: number;
  33613. }): void;
  33614. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33615. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33616. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33617. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33618. /**
  33619. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33620. * This allowed control for front to back rendering or reversly depending of the special needs.
  33621. *
  33622. * @param renderingGroupId The rendering group id corresponding to its index
  33623. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33624. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33625. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33626. */
  33627. 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;
  33628. /**
  33629. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33630. *
  33631. * @param renderingGroupId The rendering group id corresponding to its index
  33632. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33633. */
  33634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33635. clone(): RenderTargetTexture;
  33636. serialize(): any;
  33637. disposeFramebufferObjects(): void;
  33638. dispose(): void;
  33639. _rebuild(): void;
  33640. /**
  33641. * Clear the info related to rendering groups preventing retention point in material dispose.
  33642. */
  33643. freeRenderingGroups(): void;
  33644. }
  33645. }
  33646. declare module BABYLON {
  33647. class Texture extends BaseTexture {
  33648. static NEAREST_SAMPLINGMODE: number;
  33649. static NEAREST_NEAREST_MIPLINEAR: number;
  33650. static BILINEAR_SAMPLINGMODE: number;
  33651. static LINEAR_LINEAR_MIPNEAREST: number;
  33652. static TRILINEAR_SAMPLINGMODE: number;
  33653. static LINEAR_LINEAR_MIPLINEAR: number;
  33654. static NEAREST_NEAREST_MIPNEAREST: number;
  33655. static NEAREST_LINEAR_MIPNEAREST: number;
  33656. static NEAREST_LINEAR_MIPLINEAR: number;
  33657. static NEAREST_LINEAR: number;
  33658. static NEAREST_NEAREST: number;
  33659. static LINEAR_NEAREST_MIPNEAREST: number;
  33660. static LINEAR_NEAREST_MIPLINEAR: number;
  33661. static LINEAR_LINEAR: number;
  33662. static LINEAR_NEAREST: number;
  33663. static EXPLICIT_MODE: number;
  33664. static SPHERICAL_MODE: number;
  33665. static PLANAR_MODE: number;
  33666. static CUBIC_MODE: number;
  33667. static PROJECTION_MODE: number;
  33668. static SKYBOX_MODE: number;
  33669. static INVCUBIC_MODE: number;
  33670. static EQUIRECTANGULAR_MODE: number;
  33671. static FIXED_EQUIRECTANGULAR_MODE: number;
  33672. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33673. static CLAMP_ADDRESSMODE: number;
  33674. static WRAP_ADDRESSMODE: number;
  33675. static MIRROR_ADDRESSMODE: number;
  33676. /**
  33677. * 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
  33678. */
  33679. static UseSerializedUrlIfAny: boolean;
  33680. url: Nullable<string>;
  33681. uOffset: number;
  33682. vOffset: number;
  33683. uScale: number;
  33684. vScale: number;
  33685. uAng: number;
  33686. vAng: number;
  33687. wAng: number;
  33688. /**
  33689. * Defines the center of rotation (U)
  33690. */
  33691. uRotationCenter: number;
  33692. /**
  33693. * Defines the center of rotation (V)
  33694. */
  33695. vRotationCenter: number;
  33696. /**
  33697. * Defines the center of rotation (W)
  33698. */
  33699. wRotationCenter: number;
  33700. readonly noMipmap: boolean;
  33701. private _noMipmap;
  33702. _invertY: boolean;
  33703. private _rowGenerationMatrix;
  33704. private _cachedTextureMatrix;
  33705. private _projectionModeMatrix;
  33706. private _t0;
  33707. private _t1;
  33708. private _t2;
  33709. private _cachedUOffset;
  33710. private _cachedVOffset;
  33711. private _cachedUScale;
  33712. private _cachedVScale;
  33713. private _cachedUAng;
  33714. private _cachedVAng;
  33715. private _cachedWAng;
  33716. private _cachedProjectionMatrixId;
  33717. private _cachedCoordinatesMode;
  33718. _samplingMode: number;
  33719. private _buffer;
  33720. private _deleteBuffer;
  33721. protected _format: Nullable<number>;
  33722. private _delayedOnLoad;
  33723. private _delayedOnError;
  33724. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33725. protected _isBlocking: boolean;
  33726. isBlocking: boolean;
  33727. readonly samplingMode: number;
  33728. 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);
  33729. /**
  33730. * Update the url (and optional buffer) of this texture if url was null during construction.
  33731. * @param url the url of the texture
  33732. * @param buffer the buffer of the texture (defaults to null)
  33733. */
  33734. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  33735. delayLoad(): void;
  33736. updateSamplingMode(samplingMode: number): void;
  33737. private _prepareRowForTextureGeneration(x, y, z, t);
  33738. getTextureMatrix(): Matrix;
  33739. getReflectionTextureMatrix(): Matrix;
  33740. clone(): Texture;
  33741. readonly onLoadObservable: Observable<Texture>;
  33742. serialize(): any;
  33743. getClassName(): string;
  33744. dispose(): void;
  33745. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33746. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33747. 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;
  33748. }
  33749. }
  33750. declare module BABYLON {
  33751. /**
  33752. * Settings for finer control over video usage
  33753. */
  33754. interface VideoTextureSettings {
  33755. /**
  33756. * Applies `autoplay` to video, if specified
  33757. */
  33758. autoPlay?: boolean;
  33759. /**
  33760. * Applies `loop` to video, if specified
  33761. */
  33762. loop?: boolean;
  33763. /**
  33764. * Automatically updates internal texture from video at every frame in the render loop
  33765. */
  33766. autoUpdateTexture: boolean;
  33767. }
  33768. class VideoTexture extends Texture {
  33769. /**
  33770. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33771. */
  33772. readonly autoUpdateTexture: boolean;
  33773. /**
  33774. * The video instance used by the texture internally
  33775. */
  33776. readonly video: HTMLVideoElement;
  33777. private _generateMipMaps;
  33778. private _engine;
  33779. private _stillImageCaptured;
  33780. /**
  33781. * Creates a video texture.
  33782. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33783. * @param {string | null} name optional name, will detect from video source, if not defined
  33784. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33785. * @param {BABYLON.Scene} scene is obviously the current scene.
  33786. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33787. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33788. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33789. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33790. */
  33791. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33792. private _getName(src);
  33793. private _getVideo(src);
  33794. private _createInternalTexture;
  33795. private reset;
  33796. /**
  33797. * Internal method to initiate `update`.
  33798. */
  33799. _rebuild(): void;
  33800. /**
  33801. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33802. */
  33803. update(): void;
  33804. /**
  33805. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33806. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33807. */
  33808. updateTexture(isVisible: boolean): void;
  33809. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33810. /**
  33811. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33812. * @param url New url.
  33813. */
  33814. updateURL(url: string): void;
  33815. dispose(): void;
  33816. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33817. minWidth: number;
  33818. maxWidth: number;
  33819. minHeight: number;
  33820. maxHeight: number;
  33821. deviceId: string;
  33822. }): void;
  33823. }
  33824. }
  33825. declare module BABYLON {
  33826. /**
  33827. * Particle emitter emitting particles from the inside of a box.
  33828. * It emits the particles randomly between 2 given directions.
  33829. */
  33830. class BoxParticleEmitter implements IParticleEmitterType {
  33831. /**
  33832. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33833. */
  33834. direction1: Vector3;
  33835. /**
  33836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33837. */
  33838. direction2: Vector3;
  33839. /**
  33840. * 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.
  33841. */
  33842. minEmitBox: Vector3;
  33843. /**
  33844. * 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.
  33845. */
  33846. maxEmitBox: Vector3;
  33847. /**
  33848. * Creates a new instance BoxParticleEmitter
  33849. */
  33850. constructor();
  33851. /**
  33852. * Called by the particle System when the direction is computed for the created particle.
  33853. * @param emitPower is the power of the particle (speed)
  33854. * @param worldMatrix is the world matrix of the particle system
  33855. * @param directionToUpdate is the direction vector to update with the result
  33856. * @param particle is the particle we are computed the direction for
  33857. */
  33858. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33859. /**
  33860. * Called by the particle System when the position is computed for the created particle.
  33861. * @param worldMatrix is the world matrix of the particle system
  33862. * @param positionToUpdate is the position vector to update with the result
  33863. * @param particle is the particle we are computed the position for
  33864. */
  33865. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33866. /**
  33867. * Clones the current emitter and returns a copy of it
  33868. * @returns the new emitter
  33869. */
  33870. clone(): BoxParticleEmitter;
  33871. /**
  33872. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33873. * @param effect defines the update shader
  33874. */
  33875. applyToShader(effect: Effect): void;
  33876. /**
  33877. * Returns a string to use to update the GPU particles update shader
  33878. * @returns a string containng the defines string
  33879. */
  33880. getEffectDefines(): string;
  33881. /**
  33882. * Returns the string "BoxEmitter"
  33883. * @returns a string containing the class name
  33884. */
  33885. getClassName(): string;
  33886. /**
  33887. * Serializes the particle system to a JSON object.
  33888. * @returns the JSON object
  33889. */
  33890. serialize(): any;
  33891. /**
  33892. * Parse properties from a JSON object
  33893. * @param serializationObject defines the JSON object
  33894. */
  33895. parse(serializationObject: any): void;
  33896. }
  33897. }
  33898. declare module BABYLON {
  33899. /**
  33900. * Particle emitter emitting particles from the inside of a cone.
  33901. * It emits the particles alongside the cone volume from the base to the particle.
  33902. * The emission direction might be randomized.
  33903. */
  33904. class ConeParticleEmitter implements IParticleEmitterType {
  33905. /**
  33906. * The radius of the emission cone.
  33907. */
  33908. angle: number;
  33909. /**
  33910. * The cone base angle.
  33911. */
  33912. directionRandomizer: number;
  33913. private _radius;
  33914. private _height;
  33915. /**
  33916. * Gets the radius of the emission cone.
  33917. */
  33918. /**
  33919. * Sets the radius of the emission cone.
  33920. */
  33921. radius: number;
  33922. /**
  33923. * Creates a new instance ConeParticleEmitter
  33924. * @param radius the radius of the emission cone (1 by default)
  33925. * @param angles the cone base angle (PI by default)
  33926. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33927. */
  33928. constructor(radius?: number,
  33929. /**
  33930. * The radius of the emission cone.
  33931. */
  33932. angle?: number,
  33933. /**
  33934. * The cone base angle.
  33935. */
  33936. directionRandomizer?: number);
  33937. /**
  33938. * Called by the particle System when the direction is computed for the created particle.
  33939. * @param emitPower is the power of the particle (speed)
  33940. * @param worldMatrix is the world matrix of the particle system
  33941. * @param directionToUpdate is the direction vector to update with the result
  33942. * @param particle is the particle we are computed the direction for
  33943. */
  33944. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33945. /**
  33946. * Called by the particle System when the position is computed for the created particle.
  33947. * @param worldMatrix is the world matrix of the particle system
  33948. * @param positionToUpdate is the position vector to update with the result
  33949. * @param particle is the particle we are computed the position for
  33950. */
  33951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33952. /**
  33953. * Clones the current emitter and returns a copy of it
  33954. * @returns the new emitter
  33955. */
  33956. clone(): ConeParticleEmitter;
  33957. /**
  33958. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33959. * @param effect defines the update shader
  33960. */
  33961. applyToShader(effect: Effect): void;
  33962. /**
  33963. * Returns a string to use to update the GPU particles update shader
  33964. * @returns a string containng the defines string
  33965. */
  33966. getEffectDefines(): string;
  33967. /**
  33968. * Returns the string "BoxEmitter"
  33969. * @returns a string containing the class name
  33970. */
  33971. getClassName(): string;
  33972. /**
  33973. * Serializes the particle system to a JSON object.
  33974. * @returns the JSON object
  33975. */
  33976. serialize(): any;
  33977. /**
  33978. * Parse properties from a JSON object
  33979. * @param serializationObject defines the JSON object
  33980. */
  33981. parse(serializationObject: any): void;
  33982. }
  33983. }
  33984. declare module BABYLON {
  33985. /**
  33986. * Particle emitter represents a volume emitting particles.
  33987. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33988. */
  33989. interface IParticleEmitterType {
  33990. /**
  33991. * Called by the particle System when the direction is computed for the created particle.
  33992. * @param emitPower is the power of the particle (speed)
  33993. * @param worldMatrix is the world matrix of the particle system
  33994. * @param directionToUpdate is the direction vector to update with the result
  33995. * @param particle is the particle we are computed the direction for
  33996. */
  33997. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33998. /**
  33999. * Called by the particle System when the position is computed for the created particle.
  34000. * @param worldMatrix is the world matrix of the particle system
  34001. * @param positionToUpdate is the position vector to update with the result
  34002. * @param particle is the particle we are computed the position for
  34003. */
  34004. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34005. /**
  34006. * Clones the current emitter and returns a copy of it
  34007. * @returns the new emitter
  34008. */
  34009. clone(): IParticleEmitterType;
  34010. /**
  34011. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34012. * @param effect defines the update shader
  34013. */
  34014. applyToShader(effect: Effect): void;
  34015. /**
  34016. * Returns a string to use to update the GPU particles update shader
  34017. * @returns the effect defines string
  34018. */
  34019. getEffectDefines(): string;
  34020. /**
  34021. * Returns a string representing the class name
  34022. * @returns a string containing the class name
  34023. */
  34024. getClassName(): string;
  34025. /**
  34026. * Serializes the particle system to a JSON object.
  34027. * @returns the JSON object
  34028. */
  34029. serialize(): any;
  34030. /**
  34031. * Parse properties from a JSON object
  34032. * @param serializationObject defines the JSON object
  34033. */
  34034. parse(serializationObject: any): void;
  34035. }
  34036. }
  34037. declare module BABYLON {
  34038. /**
  34039. * Particle emitter emitting particles from the inside of a sphere.
  34040. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34041. */
  34042. class SphereParticleEmitter implements IParticleEmitterType {
  34043. /**
  34044. * The radius of the emission sphere.
  34045. */
  34046. radius: number;
  34047. /**
  34048. * How much to randomize the particle direction [0-1].
  34049. */
  34050. directionRandomizer: number;
  34051. /**
  34052. * Creates a new instance SphereParticleEmitter
  34053. * @param radius the radius of the emission sphere (1 by default)
  34054. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34055. */
  34056. constructor(
  34057. /**
  34058. * The radius of the emission sphere.
  34059. */
  34060. radius?: number,
  34061. /**
  34062. * How much to randomize the particle direction [0-1].
  34063. */
  34064. directionRandomizer?: number);
  34065. /**
  34066. * Called by the particle System when the direction is computed for the created particle.
  34067. * @param emitPower is the power of the particle (speed)
  34068. * @param worldMatrix is the world matrix of the particle system
  34069. * @param directionToUpdate is the direction vector to update with the result
  34070. * @param particle is the particle we are computed the direction for
  34071. */
  34072. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34073. /**
  34074. * Called by the particle System when the position is computed for the created particle.
  34075. * @param worldMatrix is the world matrix of the particle system
  34076. * @param positionToUpdate is the position vector to update with the result
  34077. * @param particle is the particle we are computed the position for
  34078. */
  34079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34080. /**
  34081. * Clones the current emitter and returns a copy of it
  34082. * @returns the new emitter
  34083. */
  34084. clone(): SphereParticleEmitter;
  34085. /**
  34086. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34087. * @param effect defines the update shader
  34088. */
  34089. applyToShader(effect: Effect): void;
  34090. /**
  34091. * Returns a string to use to update the GPU particles update shader
  34092. * @returns a string containng the defines string
  34093. */
  34094. getEffectDefines(): string;
  34095. /**
  34096. * Returns the string "SphereParticleEmitter"
  34097. * @returns a string containing the class name
  34098. */
  34099. getClassName(): string;
  34100. /**
  34101. * Serializes the particle system to a JSON object.
  34102. * @returns the JSON object
  34103. */
  34104. serialize(): any;
  34105. /**
  34106. * Parse properties from a JSON object
  34107. * @param serializationObject defines the JSON object
  34108. */
  34109. parse(serializationObject: any): void;
  34110. }
  34111. /**
  34112. * Particle emitter emitting particles from the inside of a sphere.
  34113. * It emits the particles randomly between two vectors.
  34114. */
  34115. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34116. /**
  34117. * The min limit of the emission direction.
  34118. */
  34119. direction1: Vector3;
  34120. /**
  34121. * The max limit of the emission direction.
  34122. */
  34123. direction2: Vector3;
  34124. /**
  34125. * Creates a new instance SphereDirectedParticleEmitter
  34126. * @param radius the radius of the emission sphere (1 by default)
  34127. * @param direction1 the min limit of the emission direction (up vector by default)
  34128. * @param direction2 the max limit of the emission direction (up vector by default)
  34129. */
  34130. constructor(radius?: number,
  34131. /**
  34132. * The min limit of the emission direction.
  34133. */
  34134. direction1?: Vector3,
  34135. /**
  34136. * The max limit of the emission direction.
  34137. */
  34138. direction2?: Vector3);
  34139. /**
  34140. * Called by the particle System when the direction is computed for the created particle.
  34141. * @param emitPower is the power of the particle (speed)
  34142. * @param worldMatrix is the world matrix of the particle system
  34143. * @param directionToUpdate is the direction vector to update with the result
  34144. * @param particle is the particle we are computed the direction for
  34145. */
  34146. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34147. /**
  34148. * Clones the current emitter and returns a copy of it
  34149. * @returns the new emitter
  34150. */
  34151. clone(): SphereDirectedParticleEmitter;
  34152. /**
  34153. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34154. * @param effect defines the update shader
  34155. */
  34156. applyToShader(effect: Effect): void;
  34157. /**
  34158. * Returns a string to use to update the GPU particles update shader
  34159. * @returns a string containng the defines string
  34160. */
  34161. getEffectDefines(): string;
  34162. /**
  34163. * Returns the string "SphereDirectedParticleEmitter"
  34164. * @returns a string containing the class name
  34165. */
  34166. getClassName(): string;
  34167. /**
  34168. * Serializes the particle system to a JSON object.
  34169. * @returns the JSON object
  34170. */
  34171. serialize(): any;
  34172. /**
  34173. * Parse properties from a JSON object
  34174. * @param serializationObject defines the JSON object
  34175. */
  34176. parse(serializationObject: any): void;
  34177. }
  34178. }
  34179. declare var DracoDecoderModule: any;
  34180. declare var WebAssembly: any;
  34181. declare module BABYLON {
  34182. /**
  34183. * Configuration for Draco compression
  34184. */
  34185. interface IDracoCompressionConfiguration {
  34186. /**
  34187. * Configuration for the decoder.
  34188. */
  34189. decoder?: {
  34190. /**
  34191. * The url to the WebAssembly module.
  34192. */
  34193. wasmUrl?: string;
  34194. /**
  34195. * The url to the WebAssembly binary.
  34196. */
  34197. wasmBinaryUrl?: string;
  34198. /**
  34199. * The url to the fallback JavaScript module.
  34200. */
  34201. fallbackUrl?: string;
  34202. };
  34203. }
  34204. /**
  34205. * Draco compression (https://google.github.io/draco/)
  34206. *
  34207. * This class wraps the Draco module.
  34208. *
  34209. * **Encoder**
  34210. *
  34211. * The encoder is not currently implemented.
  34212. *
  34213. * **Decoder**
  34214. *
  34215. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  34216. *
  34217. * To update the configuration, use the following code:
  34218. * ```javascript
  34219. * BABYLON.DracoCompression.Configuration = {
  34220. * decoder: {
  34221. * wasmUrl: "<url to the WebAssembly library>",
  34222. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  34223. * fallbackUrl: "<url to the fallback JavaScript library>",
  34224. * }
  34225. * };
  34226. * ```
  34227. *
  34228. * 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.
  34229. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  34230. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  34231. *
  34232. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  34233. * ```javascript
  34234. * var dracoCompression = new BABYLON.DracoCompression();
  34235. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  34236. * [BABYLON.VertexBuffer.PositionKind]: 0
  34237. * });
  34238. * ```
  34239. *
  34240. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  34241. */
  34242. class DracoCompression implements IDisposable {
  34243. private static _DecoderModulePromise;
  34244. /**
  34245. * The configuration. Defaults to the following urls:
  34246. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  34247. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  34248. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  34249. */
  34250. static Configuration: IDracoCompressionConfiguration;
  34251. /**
  34252. * Returns true if the decoder is available.
  34253. */
  34254. static readonly DecoderAvailable: boolean;
  34255. /**
  34256. * Constructor
  34257. */
  34258. constructor();
  34259. /**
  34260. * Stop all async operations and release resources.
  34261. */
  34262. dispose(): void;
  34263. /**
  34264. * Decode Draco compressed mesh data to vertex data.
  34265. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  34266. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  34267. * @returns A promise that resolves with the decoded vertex data
  34268. */
  34269. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  34270. [kind: string]: number;
  34271. }): Promise<VertexData>;
  34272. private static _GetDecoderModule();
  34273. private static _LoadScriptAsync(url);
  34274. private static _LoadFileAsync(url);
  34275. }
  34276. }
  34277. declare module BABYLON {
  34278. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34279. private _useDeltaForWorldStep;
  34280. world: any;
  34281. name: string;
  34282. private _physicsMaterials;
  34283. private _fixedTimeStep;
  34284. BJSCANNON: any;
  34285. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34286. setGravity(gravity: Vector3): void;
  34287. setTimeStep(timeStep: number): void;
  34288. getTimeStep(): number;
  34289. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34290. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34291. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34292. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34293. private _processChildMeshes(mainImpostor);
  34294. removePhysicsBody(impostor: PhysicsImpostor): void;
  34295. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34296. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34297. private _addMaterial(name, friction, restitution);
  34298. private _checkWithEpsilon(value);
  34299. private _createShape(impostor);
  34300. private _createHeightmap(object, pointDepth?);
  34301. private _minus90X;
  34302. private _plus90X;
  34303. private _tmpPosition;
  34304. private _tmpDeltaPosition;
  34305. private _tmpUnityRotation;
  34306. private _updatePhysicsBodyTransformation(impostor);
  34307. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34308. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34309. isSupported(): boolean;
  34310. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34311. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34312. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34313. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34314. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34315. getBodyMass(impostor: PhysicsImpostor): number;
  34316. getBodyFriction(impostor: PhysicsImpostor): number;
  34317. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34318. getBodyRestitution(impostor: PhysicsImpostor): number;
  34319. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34320. sleepBody(impostor: PhysicsImpostor): void;
  34321. wakeUpBody(impostor: PhysicsImpostor): void;
  34322. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34323. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34324. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34325. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34326. getRadius(impostor: PhysicsImpostor): number;
  34327. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34328. dispose(): void;
  34329. private _extendNamespace();
  34330. }
  34331. }
  34332. declare module BABYLON {
  34333. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34334. world: any;
  34335. name: string;
  34336. BJSOIMO: any;
  34337. constructor(iterations?: number);
  34338. setGravity(gravity: Vector3): void;
  34339. setTimeStep(timeStep: number): void;
  34340. getTimeStep(): number;
  34341. private _tmpImpostorsArray;
  34342. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34343. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34344. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34345. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34346. private _tmpPositionVector;
  34347. removePhysicsBody(impostor: PhysicsImpostor): void;
  34348. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34349. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34350. isSupported(): boolean;
  34351. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34353. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34354. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34355. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34356. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34357. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34358. getBodyMass(impostor: PhysicsImpostor): number;
  34359. getBodyFriction(impostor: PhysicsImpostor): number;
  34360. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34361. getBodyRestitution(impostor: PhysicsImpostor): number;
  34362. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34363. sleepBody(impostor: PhysicsImpostor): void;
  34364. wakeUpBody(impostor: PhysicsImpostor): void;
  34365. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34366. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34367. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34368. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34369. getRadius(impostor: PhysicsImpostor): number;
  34370. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34371. dispose(): void;
  34372. }
  34373. }
  34374. declare module BABYLON {
  34375. /**
  34376. * This represents a set of one or more post processes in Babylon.
  34377. * A post process can be used to apply a shader to a texture after it is rendered.
  34378. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34379. */
  34380. class PostProcessRenderEffect {
  34381. private _postProcesses;
  34382. private _getPostProcesses;
  34383. private _singleInstance;
  34384. private _cameras;
  34385. private _indicesForCamera;
  34386. /**
  34387. * Name of the effect
  34388. */
  34389. _name: string;
  34390. /**
  34391. * Instantiates a post process render effect.
  34392. * A post process can be used to apply a shader to a texture after it is rendered.
  34393. * @param engine The engine the effect is tied to
  34394. * @param name The name of the effect
  34395. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34396. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34397. */
  34398. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34399. /**
  34400. * Checks if all the post processes in the effect are supported.
  34401. */
  34402. readonly isSupported: boolean;
  34403. /**
  34404. * Updates the current state of the effect
  34405. */
  34406. _update(): void;
  34407. /**
  34408. * Attaches the effect on cameras
  34409. * @param cameras The camera to attach to.
  34410. */
  34411. _attachCameras(cameras: Camera): void;
  34412. /**
  34413. * Attaches the effect on cameras
  34414. * @param cameras The camera to attach to.
  34415. */
  34416. _attachCameras(cameras: Camera[]): void;
  34417. /**
  34418. * Detatches the effect on cameras
  34419. * @param cameras The camera to detatch from.
  34420. */
  34421. _detachCameras(cameras: Camera): void;
  34422. /**
  34423. * Detatches the effect on cameras
  34424. * @param cameras The camera to detatch from.
  34425. */
  34426. _detachCameras(cameras: Camera[]): void;
  34427. /**
  34428. * Enables the effect on given cameras
  34429. * @param cameras The camera to enable.
  34430. */
  34431. _enable(cameras: Camera): void;
  34432. /**
  34433. * Enables the effect on given cameras
  34434. * @param cameras The camera to enable.
  34435. */
  34436. _enable(cameras: Nullable<Camera[]>): void;
  34437. /**
  34438. * Disables the effect on the given cameras
  34439. * @param cameras The camera to disable.
  34440. */
  34441. _disable(cameras: Camera): void;
  34442. /**
  34443. * Disables the effect on the given cameras
  34444. * @param cameras The camera to disable.
  34445. */
  34446. _disable(cameras: Nullable<Camera[]>): void;
  34447. /**
  34448. * Gets a list of the post processes contained in the effect.
  34449. * @param camera The camera to get the post processes on.
  34450. * @returns The list of the post processes in the effect.
  34451. */
  34452. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34453. }
  34454. }
  34455. declare module BABYLON {
  34456. class PostProcessRenderPipeline {
  34457. private engine;
  34458. private _renderEffects;
  34459. private _renderEffectsForIsolatedPass;
  34460. protected _cameras: Camera[];
  34461. _name: string;
  34462. constructor(engine: Engine, name: string);
  34463. getClassName(): string;
  34464. readonly isSupported: boolean;
  34465. addEffect(renderEffect: PostProcessRenderEffect): void;
  34466. _rebuild(): void;
  34467. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34468. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34469. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34470. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34471. _attachCameras(cameras: Camera, unique: boolean): void;
  34472. _attachCameras(cameras: Camera[], unique: boolean): void;
  34473. _detachCameras(cameras: Camera): void;
  34474. _detachCameras(cameras: Nullable<Camera[]>): void;
  34475. _update(): void;
  34476. _reset(): void;
  34477. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34478. dispose(): void;
  34479. }
  34480. }
  34481. declare module BABYLON {
  34482. class PostProcessRenderPipelineManager {
  34483. private _renderPipelines;
  34484. constructor();
  34485. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34486. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34487. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34488. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34489. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34490. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34491. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34492. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34493. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34494. update(): void;
  34495. _rebuild(): void;
  34496. dispose(): void;
  34497. }
  34498. }
  34499. declare module BABYLON {
  34500. /**
  34501. * Helper class dealing with the extraction of spherical polynomial dataArray
  34502. * from a cube map.
  34503. */
  34504. class CubeMapToSphericalPolynomialTools {
  34505. private static FileFaces;
  34506. /**
  34507. * Converts a texture to the according Spherical Polynomial data.
  34508. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34509. *
  34510. * @param texture The texture to extract the information from.
  34511. * @return The Spherical Polynomial data.
  34512. */
  34513. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34514. /**
  34515. * Converts a cubemap to the according Spherical Polynomial data.
  34516. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34517. *
  34518. * @param cubeInfo The Cube map to extract the information from.
  34519. * @return The Spherical Polynomial data.
  34520. */
  34521. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34522. }
  34523. }
  34524. declare module BABYLON {
  34525. /**
  34526. * Header information of HDR texture files.
  34527. */
  34528. interface HDRInfo {
  34529. /**
  34530. * The height of the texture in pixels.
  34531. */
  34532. height: number;
  34533. /**
  34534. * The width of the texture in pixels.
  34535. */
  34536. width: number;
  34537. /**
  34538. * The index of the beginning of the data in the binary file.
  34539. */
  34540. dataPosition: number;
  34541. }
  34542. /**
  34543. * This groups tools to convert HDR texture to native colors array.
  34544. */
  34545. class HDRTools {
  34546. private static Ldexp(mantissa, exponent);
  34547. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34548. private static readStringLine(uint8array, startIndex);
  34549. /**
  34550. * Reads header information from an RGBE texture stored in a native array.
  34551. * More information on this format are available here:
  34552. * https://en.wikipedia.org/wiki/RGBE_image_format
  34553. *
  34554. * @param uint8array The binary file stored in native array.
  34555. * @return The header information.
  34556. */
  34557. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34558. /**
  34559. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34560. * This RGBE texture needs to store the information as a panorama.
  34561. *
  34562. * More information on this format are available here:
  34563. * https://en.wikipedia.org/wiki/RGBE_image_format
  34564. *
  34565. * @param buffer The binary file stored in an array buffer.
  34566. * @param size The expected size of the extracted cubemap.
  34567. * @return The Cube Map information.
  34568. */
  34569. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34570. /**
  34571. * Returns the pixels data extracted from an RGBE texture.
  34572. * This pixels will be stored left to right up to down in the R G B order in one array.
  34573. *
  34574. * More information on this format are available here:
  34575. * https://en.wikipedia.org/wiki/RGBE_image_format
  34576. *
  34577. * @param uint8array The binary file stored in an array buffer.
  34578. * @param hdrInfo The header information of the file.
  34579. * @return The pixels data in RGB right to left up to down order.
  34580. */
  34581. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34582. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34583. }
  34584. }
  34585. declare module BABYLON {
  34586. /**
  34587. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34588. */
  34589. interface CubeMapInfo {
  34590. /**
  34591. * The pixel array for the front face.
  34592. * This is stored in format, left to right, up to down format.
  34593. */
  34594. front: Nullable<ArrayBufferView>;
  34595. /**
  34596. * The pixel array for the back face.
  34597. * This is stored in format, left to right, up to down format.
  34598. */
  34599. back: Nullable<ArrayBufferView>;
  34600. /**
  34601. * The pixel array for the left face.
  34602. * This is stored in format, left to right, up to down format.
  34603. */
  34604. left: Nullable<ArrayBufferView>;
  34605. /**
  34606. * The pixel array for the right face.
  34607. * This is stored in format, left to right, up to down format.
  34608. */
  34609. right: Nullable<ArrayBufferView>;
  34610. /**
  34611. * The pixel array for the up face.
  34612. * This is stored in format, left to right, up to down format.
  34613. */
  34614. up: Nullable<ArrayBufferView>;
  34615. /**
  34616. * The pixel array for the down face.
  34617. * This is stored in format, left to right, up to down format.
  34618. */
  34619. down: Nullable<ArrayBufferView>;
  34620. /**
  34621. * The size of the cubemap stored.
  34622. *
  34623. * Each faces will be size * size pixels.
  34624. */
  34625. size: number;
  34626. /**
  34627. * The format of the texture.
  34628. *
  34629. * RGBA, RGB.
  34630. */
  34631. format: number;
  34632. /**
  34633. * The type of the texture data.
  34634. *
  34635. * UNSIGNED_INT, FLOAT.
  34636. */
  34637. type: number;
  34638. /**
  34639. * Specifies whether the texture is in gamma space.
  34640. */
  34641. gammaSpace: boolean;
  34642. }
  34643. /**
  34644. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34645. */
  34646. class PanoramaToCubeMapTools {
  34647. private static FACE_FRONT;
  34648. private static FACE_BACK;
  34649. private static FACE_RIGHT;
  34650. private static FACE_LEFT;
  34651. private static FACE_DOWN;
  34652. private static FACE_UP;
  34653. /**
  34654. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34655. *
  34656. * @param float32Array The source data.
  34657. * @param inputWidth The width of the input panorama.
  34658. * @param inputhHeight The height of the input panorama.
  34659. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34660. * @return The cubemap data
  34661. */
  34662. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34663. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34664. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34665. }
  34666. }
  34667. declare module BABYLON {
  34668. class CustomProceduralTexture extends ProceduralTexture {
  34669. private _animate;
  34670. private _time;
  34671. private _config;
  34672. private _texturePath;
  34673. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34674. private loadJson(jsonUrl);
  34675. isReady(): boolean;
  34676. render(useCameraPostProcess?: boolean): void;
  34677. updateTextures(): void;
  34678. updateShaderUniforms(): void;
  34679. animate: boolean;
  34680. }
  34681. }
  34682. declare module BABYLON {
  34683. class ProceduralTexture extends Texture {
  34684. isCube: boolean;
  34685. private _size;
  34686. _generateMipMaps: boolean;
  34687. isEnabled: boolean;
  34688. private _currentRefreshId;
  34689. private _refreshRate;
  34690. onGenerated: () => void;
  34691. private _vertexBuffers;
  34692. private _indexBuffer;
  34693. private _effect;
  34694. private _uniforms;
  34695. private _samplers;
  34696. private _fragment;
  34697. _textures: {
  34698. [key: string]: Texture;
  34699. };
  34700. private _floats;
  34701. private _floatsArrays;
  34702. private _colors3;
  34703. private _colors4;
  34704. private _vectors2;
  34705. private _vectors3;
  34706. private _matrices;
  34707. private _fallbackTexture;
  34708. private _fallbackTextureUsed;
  34709. private _engine;
  34710. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34711. private _createIndexBuffer();
  34712. _rebuild(): void;
  34713. reset(): void;
  34714. isReady(): boolean;
  34715. resetRefreshCounter(): void;
  34716. setFragment(fragment: any): void;
  34717. refreshRate: number;
  34718. _shouldRender(): boolean;
  34719. getRenderSize(): number;
  34720. resize(size: number, generateMipMaps: boolean): void;
  34721. private _checkUniform(uniformName);
  34722. setTexture(name: string, texture: Texture): ProceduralTexture;
  34723. setFloat(name: string, value: number): ProceduralTexture;
  34724. setFloats(name: string, value: number[]): ProceduralTexture;
  34725. setColor3(name: string, value: Color3): ProceduralTexture;
  34726. setColor4(name: string, value: Color4): ProceduralTexture;
  34727. setVector2(name: string, value: Vector2): ProceduralTexture;
  34728. setVector3(name: string, value: Vector3): ProceduralTexture;
  34729. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34730. render(useCameraPostProcess?: boolean): void;
  34731. clone(): ProceduralTexture;
  34732. dispose(): void;
  34733. }
  34734. }
  34735. declare module BABYLON {
  34736. /**
  34737. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34738. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34739. */
  34740. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34741. private _scene;
  34742. private _originalCameras;
  34743. /**
  34744. * ID of the sharpen post process,
  34745. */
  34746. private readonly SharpenPostProcessId;
  34747. /**
  34748. * ID of the image processing post process;
  34749. */
  34750. readonly ImageProcessingPostProcessId: string;
  34751. /**
  34752. * ID of the Fast Approximate Anti-Aliasing post process;
  34753. */
  34754. readonly FxaaPostProcessId: string;
  34755. /**
  34756. * ID of the chromatic aberration post process,
  34757. */
  34758. private readonly ChromaticAberrationPostProcessId;
  34759. /**
  34760. * ID of the grain post process
  34761. */
  34762. private readonly GrainPostProcessId;
  34763. /**
  34764. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34765. */
  34766. sharpen: SharpenPostProcess;
  34767. private _sharpenEffect;
  34768. private bloom;
  34769. /**
  34770. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34771. */
  34772. depthOfField: DepthOfFieldEffect;
  34773. /**
  34774. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34775. */
  34776. fxaa: FxaaPostProcess;
  34777. /**
  34778. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34779. */
  34780. imageProcessing: ImageProcessingPostProcess;
  34781. /**
  34782. * Chromatic aberration post process which will shift rgb colors in the image
  34783. */
  34784. chromaticAberration: ChromaticAberrationPostProcess;
  34785. private _chromaticAberrationEffect;
  34786. /**
  34787. * Grain post process which add noise to the image
  34788. */
  34789. grain: GrainPostProcess;
  34790. private _grainEffect;
  34791. /**
  34792. * Glow post process which adds a glow to emmisive areas of the image
  34793. */
  34794. private _glowLayer;
  34795. /**
  34796. * Animations which can be used to tweak settings over a period of time
  34797. */
  34798. animations: Animation[];
  34799. private _imageProcessingConfigurationObserver;
  34800. private _sharpenEnabled;
  34801. private _bloomEnabled;
  34802. private _depthOfFieldEnabled;
  34803. private _depthOfFieldBlurLevel;
  34804. private _fxaaEnabled;
  34805. private _imageProcessingEnabled;
  34806. private _defaultPipelineTextureType;
  34807. private _bloomScale;
  34808. private _chromaticAberrationEnabled;
  34809. private _grainEnabled;
  34810. private _buildAllowed;
  34811. /**
  34812. * Enable or disable the sharpen process from the pipeline
  34813. */
  34814. sharpenEnabled: boolean;
  34815. private _resizeObserver;
  34816. private _hardwareScaleLevel;
  34817. private _bloomKernel;
  34818. /**
  34819. * Specifies the size of the bloom blur kernel, relative to the final output size
  34820. */
  34821. bloomKernel: number;
  34822. /**
  34823. * Specifies the weight of the bloom in the final rendering
  34824. */
  34825. private _bloomWeight;
  34826. /**
  34827. * Specifies the luma threshold for the area that will be blurred by the bloom
  34828. */
  34829. private _bloomThreshold;
  34830. private _hdr;
  34831. /**
  34832. * The strength of the bloom.
  34833. */
  34834. bloomWeight: number;
  34835. /**
  34836. * The strength of the bloom.
  34837. */
  34838. bloomThreshold: number;
  34839. /**
  34840. * The scale of the bloom, lower value will provide better performance.
  34841. */
  34842. bloomScale: number;
  34843. /**
  34844. * Enable or disable the bloom from the pipeline
  34845. */
  34846. bloomEnabled: boolean;
  34847. private _rebuildBloom();
  34848. /**
  34849. * If the depth of field is enabled.
  34850. */
  34851. depthOfFieldEnabled: boolean;
  34852. /**
  34853. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34854. */
  34855. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34856. /**
  34857. * If the anti aliasing is enabled.
  34858. */
  34859. fxaaEnabled: boolean;
  34860. private _samples;
  34861. /**
  34862. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34863. */
  34864. samples: number;
  34865. /**
  34866. * If image processing is enabled.
  34867. */
  34868. imageProcessingEnabled: boolean;
  34869. /**
  34870. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  34871. */
  34872. glowLayerEnabled: boolean;
  34873. /**
  34874. * Enable or disable the chromaticAberration process from the pipeline
  34875. */
  34876. chromaticAberrationEnabled: boolean;
  34877. /**
  34878. * Enable or disable the grain process from the pipeline
  34879. */
  34880. grainEnabled: boolean;
  34881. /**
  34882. * @constructor
  34883. * @param {string} name - The rendering pipeline name (default: "")
  34884. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  34885. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  34886. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  34887. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  34888. */
  34889. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34890. /**
  34891. * Force the compilation of the entire pipeline.
  34892. */
  34893. prepare(): void;
  34894. private _hasCleared;
  34895. private _prevPostProcess;
  34896. private _prevPrevPostProcess;
  34897. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34898. private _buildPipeline();
  34899. private _disposePostProcesses(disposeNonRecreated?);
  34900. /**
  34901. * Dispose of the pipeline and stop all post processes
  34902. */
  34903. dispose(): void;
  34904. /**
  34905. * Serialize the rendering pipeline (Used when exporting)
  34906. * @returns the serialized object
  34907. */
  34908. serialize(): any;
  34909. /**
  34910. * Parse the serialized pipeline
  34911. * @param source Source pipeline.
  34912. * @param scene The scene to load the pipeline to.
  34913. * @param rootUrl The URL of the serialized pipeline.
  34914. * @returns An instantiated pipeline from the serialized object.
  34915. */
  34916. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34917. }
  34918. }
  34919. declare module BABYLON {
  34920. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34921. /**
  34922. * The chromatic aberration PostProcess id in the pipeline
  34923. */
  34924. LensChromaticAberrationEffect: string;
  34925. /**
  34926. * The highlights enhancing PostProcess id in the pipeline
  34927. */
  34928. HighlightsEnhancingEffect: string;
  34929. /**
  34930. * The depth-of-field PostProcess id in the pipeline
  34931. */
  34932. LensDepthOfFieldEffect: string;
  34933. private _scene;
  34934. private _depthTexture;
  34935. private _grainTexture;
  34936. private _chromaticAberrationPostProcess;
  34937. private _highlightsPostProcess;
  34938. private _depthOfFieldPostProcess;
  34939. private _edgeBlur;
  34940. private _grainAmount;
  34941. private _chromaticAberration;
  34942. private _distortion;
  34943. private _highlightsGain;
  34944. private _highlightsThreshold;
  34945. private _dofDistance;
  34946. private _dofAperture;
  34947. private _dofDarken;
  34948. private _dofPentagon;
  34949. private _blurNoise;
  34950. /**
  34951. * @constructor
  34952. *
  34953. * Effect parameters are as follow:
  34954. * {
  34955. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34956. * edge_blur: number; // from 0 to x (1 for realism)
  34957. * distortion: number; // from 0 to x (1 for realism)
  34958. * grain_amount: number; // from 0 to 1
  34959. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34960. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34961. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34962. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34963. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34964. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34965. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34966. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34967. * }
  34968. * Note: if an effect parameter is unset, effect is disabled
  34969. *
  34970. * @param {string} name - The rendering pipeline name
  34971. * @param {object} parameters - An object containing all parameters (see above)
  34972. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34973. * @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)
  34974. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34975. */
  34976. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34977. setEdgeBlur(amount: number): void;
  34978. disableEdgeBlur(): void;
  34979. setGrainAmount(amount: number): void;
  34980. disableGrain(): void;
  34981. setChromaticAberration(amount: number): void;
  34982. disableChromaticAberration(): void;
  34983. setEdgeDistortion(amount: number): void;
  34984. disableEdgeDistortion(): void;
  34985. setFocusDistance(amount: number): void;
  34986. disableDepthOfField(): void;
  34987. setAperture(amount: number): void;
  34988. setDarkenOutOfFocus(amount: number): void;
  34989. enablePentagonBokeh(): void;
  34990. disablePentagonBokeh(): void;
  34991. enableNoiseBlur(): void;
  34992. disableNoiseBlur(): void;
  34993. setHighlightsGain(amount: number): void;
  34994. setHighlightsThreshold(amount: number): void;
  34995. disableHighlights(): void;
  34996. /**
  34997. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34998. */
  34999. dispose(disableDepthRender?: boolean): void;
  35000. private _createChromaticAberrationPostProcess(ratio);
  35001. private _createHighlightsPostProcess(ratio);
  35002. private _createDepthOfFieldPostProcess(ratio);
  35003. private _createGrainTexture();
  35004. }
  35005. }
  35006. declare module BABYLON {
  35007. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35008. /**
  35009. * The PassPostProcess id in the pipeline that contains the original scene color
  35010. */
  35011. SSAOOriginalSceneColorEffect: string;
  35012. /**
  35013. * The SSAO PostProcess id in the pipeline
  35014. */
  35015. SSAORenderEffect: string;
  35016. /**
  35017. * The horizontal blur PostProcess id in the pipeline
  35018. */
  35019. SSAOBlurHRenderEffect: string;
  35020. /**
  35021. * The vertical blur PostProcess id in the pipeline
  35022. */
  35023. SSAOBlurVRenderEffect: string;
  35024. /**
  35025. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35026. */
  35027. SSAOCombineRenderEffect: string;
  35028. /**
  35029. * The output strength of the SSAO post-process. Default value is 1.0.
  35030. */
  35031. totalStrength: number;
  35032. /**
  35033. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35034. */
  35035. maxZ: number;
  35036. /**
  35037. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35038. */
  35039. minZAspect: number;
  35040. /**
  35041. * Number of samples used for the SSAO calculations. Default value is 8
  35042. */
  35043. private _samples;
  35044. /**
  35045. * Ratio object used for SSAO ratio and blur ratio
  35046. */
  35047. private _ratio;
  35048. /**
  35049. * Dynamically generated sphere sampler.
  35050. */
  35051. private _sampleSphere;
  35052. /**
  35053. * Blur filter offsets
  35054. */
  35055. private _samplerOffsets;
  35056. samples: number;
  35057. /**
  35058. * Are we using bilateral blur ?
  35059. */
  35060. private _expensiveBlur;
  35061. expensiveBlur: boolean;
  35062. /**
  35063. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35064. */
  35065. radius: number;
  35066. /**
  35067. * The base color of the SSAO post-process
  35068. * The final result is "base + ssao" between [0, 1]
  35069. */
  35070. base: number;
  35071. /**
  35072. * Support test.
  35073. */
  35074. static readonly IsSupported: boolean;
  35075. private _scene;
  35076. private _depthTexture;
  35077. private _normalTexture;
  35078. private _randomTexture;
  35079. private _originalColorPostProcess;
  35080. private _ssaoPostProcess;
  35081. private _blurHPostProcess;
  35082. private _blurVPostProcess;
  35083. private _ssaoCombinePostProcess;
  35084. private _firstUpdate;
  35085. /**
  35086. * @constructor
  35087. * @param {string} name - The rendering pipeline name
  35088. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35089. * @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 }
  35090. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35091. */
  35092. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35093. /**
  35094. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35095. */
  35096. dispose(disableGeometryBufferRenderer?: boolean): void;
  35097. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35098. _rebuild(): void;
  35099. private _generateHemisphere();
  35100. private _createSSAOPostProcess(ratio);
  35101. private _createSSAOCombinePostProcess(ratio);
  35102. private _createRandomTexture();
  35103. /**
  35104. * Serialize the rendering pipeline (Used when exporting)
  35105. * @returns the serialized object
  35106. */
  35107. serialize(): any;
  35108. /**
  35109. * Parse the serialized pipeline
  35110. * @param source Source pipeline.
  35111. * @param scene The scene to load the pipeline to.
  35112. * @param rootUrl The URL of the serialized pipeline.
  35113. * @returns An instantiated pipeline from the serialized object.
  35114. */
  35115. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35116. }
  35117. }
  35118. declare module BABYLON {
  35119. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35120. /**
  35121. * The PassPostProcess id in the pipeline that contains the original scene color
  35122. */
  35123. SSAOOriginalSceneColorEffect: string;
  35124. /**
  35125. * The SSAO PostProcess id in the pipeline
  35126. */
  35127. SSAORenderEffect: string;
  35128. /**
  35129. * The horizontal blur PostProcess id in the pipeline
  35130. */
  35131. SSAOBlurHRenderEffect: string;
  35132. /**
  35133. * The vertical blur PostProcess id in the pipeline
  35134. */
  35135. SSAOBlurVRenderEffect: string;
  35136. /**
  35137. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35138. */
  35139. SSAOCombineRenderEffect: string;
  35140. /**
  35141. * The output strength of the SSAO post-process. Default value is 1.0.
  35142. */
  35143. totalStrength: number;
  35144. /**
  35145. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35146. */
  35147. radius: number;
  35148. /**
  35149. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35150. * Must not be equal to fallOff and superior to fallOff.
  35151. * Default value is 0.975
  35152. */
  35153. area: number;
  35154. /**
  35155. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35156. * Must not be equal to area and inferior to area.
  35157. * Default value is 0.0
  35158. */
  35159. fallOff: number;
  35160. /**
  35161. * The base color of the SSAO post-process
  35162. * The final result is "base + ssao" between [0, 1]
  35163. */
  35164. base: number;
  35165. private _scene;
  35166. private _depthTexture;
  35167. private _randomTexture;
  35168. private _originalColorPostProcess;
  35169. private _ssaoPostProcess;
  35170. private _blurHPostProcess;
  35171. private _blurVPostProcess;
  35172. private _ssaoCombinePostProcess;
  35173. private _firstUpdate;
  35174. /**
  35175. * @constructor
  35176. * @param {string} name - The rendering pipeline name
  35177. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35178. * @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 }
  35179. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35180. */
  35181. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35182. /**
  35183. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35184. */
  35185. dispose(disableDepthRender?: boolean): void;
  35186. private _createBlurPostProcess(ratio);
  35187. _rebuild(): void;
  35188. private _createSSAOPostProcess(ratio);
  35189. private _createSSAOCombinePostProcess(ratio);
  35190. private _createRandomTexture();
  35191. }
  35192. }
  35193. declare module BABYLON {
  35194. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35195. /**
  35196. * Public members
  35197. */
  35198. originalPostProcess: Nullable<PostProcess>;
  35199. downSampleX4PostProcess: Nullable<PostProcess>;
  35200. brightPassPostProcess: Nullable<PostProcess>;
  35201. blurHPostProcesses: PostProcess[];
  35202. blurVPostProcesses: PostProcess[];
  35203. textureAdderPostProcess: Nullable<PostProcess>;
  35204. volumetricLightPostProcess: Nullable<PostProcess>;
  35205. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  35206. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  35207. volumetricLightMergePostProces: Nullable<PostProcess>;
  35208. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  35209. luminancePostProcess: Nullable<PostProcess>;
  35210. luminanceDownSamplePostProcesses: PostProcess[];
  35211. hdrPostProcess: Nullable<PostProcess>;
  35212. textureAdderFinalPostProcess: Nullable<PostProcess>;
  35213. lensFlareFinalPostProcess: Nullable<PostProcess>;
  35214. hdrFinalPostProcess: Nullable<PostProcess>;
  35215. lensFlarePostProcess: Nullable<PostProcess>;
  35216. lensFlareComposePostProcess: Nullable<PostProcess>;
  35217. motionBlurPostProcess: Nullable<PostProcess>;
  35218. depthOfFieldPostProcess: Nullable<PostProcess>;
  35219. brightThreshold: number;
  35220. blurWidth: number;
  35221. horizontalBlur: boolean;
  35222. exposure: number;
  35223. lensTexture: Nullable<Texture>;
  35224. volumetricLightCoefficient: number;
  35225. volumetricLightPower: number;
  35226. volumetricLightBlurScale: number;
  35227. sourceLight: Nullable<SpotLight | DirectionalLight>;
  35228. hdrMinimumLuminance: number;
  35229. hdrDecreaseRate: number;
  35230. hdrIncreaseRate: number;
  35231. lensColorTexture: Nullable<Texture>;
  35232. lensFlareStrength: number;
  35233. lensFlareGhostDispersal: number;
  35234. lensFlareHaloWidth: number;
  35235. lensFlareDistortionStrength: number;
  35236. lensStarTexture: Nullable<Texture>;
  35237. lensFlareDirtTexture: Nullable<Texture>;
  35238. depthOfFieldDistance: number;
  35239. depthOfFieldBlurWidth: number;
  35240. motionStrength: number;
  35241. animations: Animation[];
  35242. /**
  35243. * Private members
  35244. */
  35245. private _scene;
  35246. private _currentDepthOfFieldSource;
  35247. private _basePostProcess;
  35248. private _hdrCurrentLuminance;
  35249. private _floatTextureType;
  35250. private _ratio;
  35251. private _bloomEnabled;
  35252. private _depthOfFieldEnabled;
  35253. private _vlsEnabled;
  35254. private _lensFlareEnabled;
  35255. private _hdrEnabled;
  35256. private _motionBlurEnabled;
  35257. private _motionBlurSamples;
  35258. private _volumetricLightStepsCount;
  35259. BloomEnabled: boolean;
  35260. DepthOfFieldEnabled: boolean;
  35261. LensFlareEnabled: boolean;
  35262. HDREnabled: boolean;
  35263. VLSEnabled: boolean;
  35264. MotionBlurEnabled: boolean;
  35265. volumetricLightStepsCount: number;
  35266. motionBlurSamples: number;
  35267. /**
  35268. * @constructor
  35269. * @param {string} name - The rendering pipeline name
  35270. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35271. * @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)
  35272. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35273. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35274. */
  35275. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35276. private _buildPipeline();
  35277. private _createDownSampleX4PostProcess(scene, ratio);
  35278. private _createBrightPassPostProcess(scene, ratio);
  35279. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35280. private _createTextureAdderPostProcess(scene, ratio);
  35281. private _createVolumetricLightPostProcess(scene, ratio);
  35282. private _createLuminancePostProcesses(scene, textureType);
  35283. private _createHdrPostProcess(scene, ratio);
  35284. private _createLensFlarePostProcess(scene, ratio);
  35285. private _createDepthOfFieldPostProcess(scene, ratio);
  35286. private _createMotionBlurPostProcess(scene, ratio);
  35287. private _getDepthTexture();
  35288. private _disposePostProcesses();
  35289. /**
  35290. * Dispose of the pipeline and stop all post processes
  35291. */
  35292. dispose(): void;
  35293. /**
  35294. * Serialize the rendering pipeline (Used when exporting)
  35295. * @returns the serialized object
  35296. */
  35297. serialize(): any;
  35298. /**
  35299. * Parse the serialized pipeline
  35300. * @param source Source pipeline.
  35301. * @param scene The scene to load the pipeline to.
  35302. * @param rootUrl The URL of the serialized pipeline.
  35303. * @returns An instantiated pipeline from the serialized object.
  35304. */
  35305. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35306. static LuminanceSteps: number;
  35307. }
  35308. }